ofproto: Properly initialize table_id when creating rules.
[sliver-openvswitch.git] / ofproto / ofproto-dpif.c
index 5807c56..fd3f212 100644 (file)
@@ -296,8 +296,7 @@ ofport_dpif_cast(const struct ofport *ofport)
 
 static void port_run(struct ofport_dpif *);
 static void port_wait(struct ofport_dpif *);
-static int set_cfm(struct ofport *, const struct cfm *,
-                   const uint16_t *remote_mps, size_t n_remote_mps);
+static int set_cfm(struct ofport *, const struct cfm_settings *);
 
 struct ofproto_dpif {
     struct ofproto up;
@@ -681,7 +680,7 @@ port_destruct(struct ofport *port_)
     struct ofproto_dpif *ofproto = ofproto_dpif_cast(port->up.ofproto);
 
     bundle_remove(port_);
-    set_cfm(port_, NULL, NULL, 0);
+    set_cfm(port_, NULL);
     if (ofproto->sflow) {
         ofproto_sflow_del_port(ofproto->sflow, port->odp_port);
     }
@@ -735,27 +734,19 @@ set_sflow(struct ofproto *ofproto_,
 }
 
 static int
-set_cfm(struct ofport *ofport_, const struct cfm *cfm,
-        const uint16_t *remote_mps, size_t n_remote_mps)
+set_cfm(struct ofport *ofport_, const struct cfm_settings *s)
 {
     struct ofport_dpif *ofport = ofport_dpif_cast(ofport_);
     int error;
 
-    if (!cfm) {
+    if (!s) {
         error = 0;
     } else {
         if (!ofport->cfm) {
             ofport->cfm = cfm_create();
         }
 
-        ofport->cfm->mpid = cfm->mpid;
-        ofport->cfm->interval = cfm->interval;
-        ofport->cfm->name = cfm->name;
-        memcpy(ofport->cfm->maid, cfm->maid, CCM_MAID_LEN);
-
-        cfm_update_remote_mps(ofport->cfm, remote_mps, n_remote_mps);
-
-        if (cfm_configure(ofport->cfm)) {
+        if (cfm_configure(ofport->cfm, s)) {
             return 0;
         }
 
@@ -767,11 +758,11 @@ set_cfm(struct ofport *ofport_, const struct cfm *cfm,
 }
 
 static int
-get_cfm(struct ofport *ofport_, const struct cfm **cfmp)
+get_cfm_fault(const struct ofport *ofport_)
 {
     struct ofport_dpif *ofport = ofport_dpif_cast(ofport_);
-    *cfmp = ofport->cfm;
-    return 0;
+
+    return ofport->cfm ? cfm_get_fault(ofport->cfm) : -1;
 }
 \f
 /* Bundles. */
@@ -1142,7 +1133,11 @@ bundle_run(struct ofbundle *bundle)
 
         LIST_FOR_EACH (port, bundle_node, &bundle->ports) {
             bool may_enable = lacp_slave_may_enable(bundle->lacp, port);
-            bond_slave_set_lacp_may_enable(bundle->bond, port, may_enable);
+
+            if (may_enable && port->cfm) {
+                may_enable = !cfm_get_fault(port->cfm);
+            }
+            bond_slave_set_may_enable(bundle->bond, port, may_enable);
         }
 
         bond_run(bundle->bond, &bundle->ofproto->revalidate_set,
@@ -1384,12 +1379,9 @@ port_run(struct ofport_dpif *ofport)
 
         if (cfm_should_send_ccm(ofport->cfm)) {
             struct ofpbuf packet;
-            struct ccm *ccm;
 
             ofpbuf_init(&packet, 0);
-            ccm = eth_compose(&packet, eth_addr_ccm, ofport->up.opp.hw_addr,
-                              ETH_TYPE_CFM, sizeof *ccm);
-            cfm_compose_ccm(ofport->cfm, ccm);
+            cfm_compose_ccm(ofport->cfm, &packet, ofport->up.opp.hw_addr);
             send_packet(ofproto_dpif_cast(ofport->up.ofproto),
                         ofport->odp_port, &packet);
             ofpbuf_uninit(&packet);
@@ -3934,6 +3926,7 @@ const struct ofproto_class ofproto_dpif_class = {
     port_poll,
     port_poll_wait,
     port_is_lacp_current,
+    NULL,                       /* rule_choose_table */
     rule_alloc,
     rule_construct,
     rule_destruct,
@@ -3948,7 +3941,7 @@ const struct ofproto_class ofproto_dpif_class = {
     get_netflow_ids,
     set_sflow,
     set_cfm,
-    get_cfm,
+    get_cfm_fault,
     bundle_set,
     bundle_remove,
     mirror_set,