[ovs-dev] [PATCH] bond: Bonds never sleep if carrier changes.

Ethan Jackson ethan at nicira.com
Tue May 17 21:04:12 UTC 2011


The bonding code neglected to call netdev_monitor_poll() on its
monitor during bond_run().  Thus carrier changes would be
permanently queued in the monitor, preventing it from ever allowing
poll_loop to sleep.
---

I think you are right.  I could imagine other users needing something like this
in the future.

---
 lib/bond.c   |    4 ++++
 lib/netdev.c |    9 +++++++++
 lib/netdev.h |    1 +
 3 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/lib/bond.c b/lib/bond.c
index 929d682..cf1d057 100644
--- a/lib/bond.c
+++ b/lib/bond.c
@@ -466,6 +466,10 @@ bond_run(struct bond *bond, struct tag_set *tags, bool lacp_negotiated)
         bond->miimon_next_update = time_msec() + bond->miimon_interval;
     }
 
+    if (bond->monitor) {
+        netdev_monitor_flush(bond->monitor);
+    }
+
     /* Enable slaves based on link status and LACP feedback. */
     HMAP_FOR_EACH (slave, hmap_node, &bond->slaves) {
         bond_link_status_update(slave, tags);
diff --git a/lib/netdev.c b/lib/netdev.c
index 771db5a..01d91db 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -1549,6 +1549,15 @@ netdev_monitor_poll(struct netdev_monitor *monitor, char **devnamep)
     }
 }
 
+/* Clears all notifications from 'monitor'.  May be called instead of
+ * netdev_monitor_poll() by clients which don't care specifically which netdevs
+ * have changed.  */
+void
+netdev_monitor_flush(struct netdev_monitor *monitor)
+{
+    sset_clear(&monitor->changed_netdevs);
+}
+
 /* Registers with the poll loop to wake up from the next call to poll_block()
  * when netdev_monitor_poll(monitor) would indicate that a device has
  * changed. */
diff --git a/lib/netdev.h b/lib/netdev.h
index 30bcf5e..81d74ae 100644
--- a/lib/netdev.h
+++ b/lib/netdev.h
@@ -214,6 +214,7 @@ void netdev_monitor_destroy(struct netdev_monitor *);
 int netdev_monitor_add(struct netdev_monitor *, struct netdev *);
 void netdev_monitor_remove(struct netdev_monitor *, struct netdev *);
 int netdev_monitor_poll(struct netdev_monitor *, char **devnamep);
+void netdev_monitor_flush(struct netdev_monitor *);
 void netdev_monitor_poll_wait(const struct netdev_monitor *);
 
 #ifdef  __cplusplus
-- 
1.7.4.4




More information about the dev mailing list