From: Justin Pettit Date: Sat, 20 Jun 2009 00:41:42 +0000 (-0700) Subject: vswitchd: Reduce number of calls to reconfigure() during mgmt updates X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23834de273c6bd42362f4e6c013703c5b6fa2fd5;p=openvswitch vswitchd: Reduce number of calls to reconfigure() during mgmt updates 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. --- diff --git a/vswitchd/mgmt.c b/vswitchd/mgmt.c index e43c6e87..a65934b6 100644 --- a/vswitchd/mgmt.c +++ b/vswitchd/mgmt.c @@ -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 diff --git a/vswitchd/mgmt.h b/vswitchd/mgmt.h index 83950cd4..f05c9169 100644 --- a/vswitchd/mgmt.h +++ b/vswitchd/mgmt.h @@ -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); diff --git a/vswitchd/ovs-vswitchd.c b/vswitchd/ovs-vswitchd.c index 01a0e7ed..8c87feab 100644 --- a/vswitchd/ovs-vswitchd.c +++ b/vswitchd/ovs-vswitchd.c @@ -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; }