cfm: Migrate cfm/show unixctl command to CFM module.
[sliver-openvswitch.git] / vswitchd / bridge.c
index 3faeee1..aba0b94 100644 (file)
@@ -164,7 +164,6 @@ static bool bridge_has_bond_fake_iface(const struct bridge *,
                                        const char *name);
 static bool port_is_bond_fake_iface(const struct port *);
 
-static unixctl_cb_func cfm_unixctl_show;
 static unixctl_cb_func qos_unixctl_show;
 
 static struct port *port_create(struct bridge *, const struct ovsrec_port *);
@@ -268,7 +267,6 @@ bridge_init(const char *remote)
     ovsdb_idl_omit(idl, &ovsrec_ssl_col_external_ids);
 
     /* Register unixctl commands. */
-    unixctl_command_register("cfm/show", cfm_unixctl_show, NULL);
     unixctl_command_register("qos/show", qos_unixctl_show, NULL);
     unixctl_command_register("bridge/dump-flows", bridge_unixctl_dump_flows,
                              NULL);
@@ -276,6 +274,7 @@ bridge_init(const char *remote)
                              NULL);
     lacp_init();
     bond_init();
+    cfm_init();
 }
 
 void
@@ -528,6 +527,10 @@ port_configure(struct port *port)
     } else {
         s.bond = NULL;
         s.bond_stable_ids = NULL;
+
+        LIST_FOR_EACH (iface, port_elem, &port->ifaces) {
+            netdev_set_miimon_interval(iface->netdev, 0);
+        }
     }
 
     /* Register. */
@@ -1497,33 +1500,6 @@ bridge_wait(void)
     }
 }
 \f
-/* CFM unixctl user interface functions. */
-static void
-cfm_unixctl_show(struct unixctl_conn *conn,
-                 const char *args, void *aux OVS_UNUSED)
-{
-    struct ds ds = DS_EMPTY_INITIALIZER;
-    struct iface *iface;
-    const struct cfm *cfm;
-
-    iface = iface_find(args);
-    if (!iface) {
-        unixctl_command_reply(conn, 501, "no such interface");
-        return;
-    }
-
-    cfm = ofproto_port_get_cfm(iface->port->bridge->ofproto, iface->ofp_port);
-
-    if (!cfm) {
-        unixctl_command_reply(conn, 501, "CFM not enabled");
-        return;
-    }
-
-    cfm_dump_ds(cfm, &ds);
-    unixctl_command_reply(conn, 200, ds_cstr(&ds));
-    ds_destroy(&ds);
-}
-\f
 /* QoS unixctl user interface functions. */
 
 struct qos_unixctl_show_cbdata {
@@ -2226,6 +2202,7 @@ port_configure_bond(struct port *port, struct bond_settings *s,
 {
     const char *detect_s;
     struct iface *iface;
+    int miimon_interval;
     size_t i;
 
     s->name = port->name;
@@ -2237,18 +2214,19 @@ port_configure_bond(struct port *port, struct bond_settings *s,
                   bond_mode_to_string(s->balance));
     }
 
-    s->detect = BLSM_CARRIER;
-    detect_s = get_port_other_config(port->cfg, "bond-detect-mode", NULL);
-    if (detect_s && !bond_detect_mode_from_string(&s->detect, detect_s)) {
-        VLOG_WARN("port %s: unsupported bond-detect-mode %s, "
-                  "defaulting to %s",
-                  port->name, detect_s, bond_detect_mode_to_string(s->detect));
+    miimon_interval = atoi(get_port_other_config(port->cfg,
+                                                 "bond-miimon-interval", "0"));
+    if (miimon_interval <= 0) {
+        miimon_interval = 200;
     }
 
-    s->miimon_interval = atoi(
-        get_port_other_config(port->cfg, "bond-miimon-interval", "200"));
-    if (s->miimon_interval < 100) {
-        s->miimon_interval = 100;
+    detect_s = get_port_other_config(port->cfg, "bond-detect-mode", "carrier");
+    if (!strcmp(detect_s, "carrier")) {
+        miimon_interval = 0;
+    } else if (strcmp(detect_s, "miimon")) {
+        VLOG_WARN("port %s: unsupported bond-detect-mode %s, "
+                  "defaulting to carrier", port->name, detect_s);
+        miimon_interval = 0;
     }
 
     s->up_delay = MAX(0, port->cfg->bond_updelay);
@@ -2272,6 +2250,8 @@ port_configure_bond(struct port *port, struct bond_settings *s,
             stable_id = iface->ofp_port;
         }
         bond_stable_ids[i++] = stable_id;
+
+        netdev_set_miimon_interval(iface->netdev, miimon_interval);
     }
 }
 \f
@@ -2541,6 +2521,7 @@ iface_configure_cfm(struct iface *iface)
 
     cfm.mpid     = mon->mpid;
     cfm.interval = mon->interval ? *mon->interval : 1000;
+    cfm.name = iface->name;
 
     memcpy(cfm.maid, maid, sizeof cfm.maid);