vswitchd: Reduce number of calls to reconfigure() during mgmt updates
authorJustin Pettit <jpettit@nicira.com>
Sat, 20 Jun 2009 00:41:42 +0000 (17:41 -0700)
committerJustin Pettit <jpettit@nicira.com>
Sat, 20 Jun 2009 00:41:42 +0000 (17:41 -0700)
When we receive an OpenFlow management protocol Config Update, we
immediately force the switch to reconfigure itself.  This is
functionally correct, but it can cause long delays before return control
back to the switch.  We now keep track of whether there were any changes
and then only force a reconfigure once per management run.

vswitchd/mgmt.c
vswitchd/mgmt.h
vswitchd/ovs-vswitchd.c

index e43c6e8..a65934b 100644 (file)
@@ -46,6 +46,7 @@
 
 static struct svec mgmt_cfg;
 static uint8_t cfg_cookie[CFG_COOKIE_LEN];
+static bool need_reconfigure = false;
 static struct rconn *mgmt_rconn;
 static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(60, 60);
 static struct svec capabilities;
@@ -655,8 +656,7 @@ recv_ofmp_config_update(uint32_t xid, const struct ofmp_header *ofmph,
      * connection settings may have changed. */
     send_config_update_ack(xid, true);
 
-    reconfigure();
-
+    need_reconfigure = true;
 
     return 0;
 }
@@ -807,15 +807,16 @@ handle_msg(uint32_t xid, const void *msg, size_t length)
     return handler(xid, msg);
 }
 
-void 
+bool 
 mgmt_run(void)
 {
     int i;
 
     if (!mgmt_rconn) {
-        return;
+        return false;
     }
 
+    need_reconfigure = false;
     rconn_run(mgmt_rconn);
 
     /* Do some processing, but cap it at a reasonable amount so that
@@ -837,6 +838,8 @@ mgmt_run(void)
             VLOG_WARN_RL(&rl, "received too-short OpenFlow message");
         }
     }
+
+    return need_reconfigure;
 }
 
 void
index 83950cd..f05c916 100644 (file)
@@ -18,7 +18,7 @@
 
 void mgmt_init(void);
 void mgmt_reconfigure(void);
-void mgmt_run(void);
+bool mgmt_run(void);
 void mgmt_wait(void);
 uint64_t mgmt_get_mgmt_id(void);
 
index 01a0e7e..8c87fea 100644 (file)
@@ -93,7 +93,9 @@ main(int argc, char *argv[])
             vlog_reopen_log_file();
             reconfigure();
         }
-        mgmt_run();
+        if (mgmt_run()) {
+            need_reconfigure = true;
+        }
         if (bridge_run()) {
             need_reconfigure = true;
         }