vswitchd: Update link_state instantly.
authorEthan Jackson <ethan@nicira.com>
Sat, 15 Oct 2011 00:29:35 +0000 (17:29 -0700)
committerEthan Jackson <ethan@nicira.com>
Mon, 17 Oct 2011 22:03:03 +0000 (15:03 -0700)
With this patch, instead of updating an interface's link_state once
every 5 seconds, it's updated immediately when changed.  To avoid
stressing the database, these updates are rate limited to once per
second.

vswitchd/bridge.c

index 1adf06f24f733759d0ecbf335940a3efafad9df2..b3c62187c069615b398588cd256f5f32f45f4a15 100644 (file)
@@ -1274,11 +1274,6 @@ iface_refresh_status(struct iface *iface)
         ovsrec_interface_set_link_speed(iface->cfg, NULL, 0);
     }
 
-    ovsrec_interface_set_link_state(iface->cfg,
-                                    (netdev_get_carrier(iface->netdev)
-                                     ? "up"
-                                     : "down"));
-
     error = netdev_get_mtu(iface->netdev, &mtu);
     if (!error) {
         mtu_64 = mtu;
@@ -1578,6 +1573,7 @@ bridge_run(void)
             struct iface *iface;
 
             HMAP_FOR_EACH (iface, name_node, &br->iface_by_name) {
+                const char *link_state;
                 int current;
 
                 if (iface_is_synthetic(iface)) {
@@ -1592,6 +1588,9 @@ bridge_run(void)
                 } else {
                     ovsrec_interface_set_lacp_current(iface->cfg, NULL, 0);
                 }
+
+                link_state = netdev_get_carrier(iface->netdev) ? "up" : "down";
+                ovsrec_interface_set_link_state(iface->cfg, link_state);
             }
         }