cfm: Update netdev when changed.
authorEthan Jackson <ethan@nicira.com>
Mon, 3 Jun 2013 20:49:13 +0000 (13:49 -0700)
committerEthan Jackson <ethan@nicira.com>
Mon, 3 Jun 2013 21:37:56 +0000 (14:37 -0700)
If ofproto decided to change the netdev of a particular ofport,
cfm_demand mode would improperly continue using the old netdev to
collect stats.

Bug #17583.
Signed-off-by: Ethan Jackson <ethan@nicira.com>
lib/cfm.c
lib/cfm.h
ofproto/ofproto-dpif.c

index 69d8188..8f22a35 100644 (file)
--- a/lib/cfm.c
+++ b/lib/cfm.c
@@ -566,6 +566,15 @@ cfm_configure(struct cfm *cfm, const struct cfm_settings *s)
     return true;
 }
 
+/* Must be called when the netdev owned by 'cfm' should change. */
+void
+cfm_set_netdev(struct cfm *cfm, const struct netdev *netdev)
+{
+    if (cfm->netdev != netdev) {
+        cfm->netdev = netdev;
+    }
+}
+
 /* Returns true if 'cfm' should process packets from 'flow'. */
 bool
 cfm_should_process_flow(const struct cfm *cfm, const struct flow *flow)
index eec9704..057da04 100644 (file)
--- a/lib/cfm.h
+++ b/lib/cfm.h
@@ -71,6 +71,7 @@ bool cfm_should_send_ccm(struct cfm *);
 void cfm_compose_ccm(struct cfm *, struct ofpbuf *packet, uint8_t eth_src[6]);
 void cfm_wait(struct cfm *);
 bool cfm_configure(struct cfm *, const struct cfm_settings *);
+void cfm_set_netdev(struct cfm *, const struct netdev *);
 bool cfm_should_process_flow(const struct cfm *cfm, const struct flow *);
 void cfm_process_heartbeat(struct cfm *, const struct ofpbuf *packet);
 int cfm_get_fault(const struct cfm *);
index 0288bb8..6673985 100644 (file)
@@ -1908,6 +1908,10 @@ port_modified(struct ofport *port_)
     if (port->bundle && port->bundle->bond) {
         bond_slave_set_netdev(port->bundle->bond, port, port->up.netdev);
     }
+
+    if (port->cfm) {
+        cfm_set_netdev(port->cfm, port->up.netdev);
+    }
 }
 
 static void