From: Justin Pettit Date: Thu, 14 May 2009 22:07:03 +0000 (-0700) Subject: vswitch: reduce passes through config loop X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a83ce9e87eb7c8dcc472f2702fb616e89232517b;p=openvswitch vswitch: reduce passes through config loop When vswitchd configures itself, it loops through the bridges to pull relevant configuration information from vswitchd.conf. Configuration for determining the dpid, controller, and NetFlow was inside a loop for configuring a bridge's interfaces. This meant that these configuration parameters were being re-set for each interface in the bridge as opposed to just once for the bridge. This change pushes this configuration outside of that interface loop. The LIST_FOR_EACH_SAFE macro to loop through the bridges is switched to LIST_FOR_EACH, since bridges are not deleted in this loop. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 2a907ebd..cd4dfe73 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -466,15 +466,16 @@ bridge_reconfigure(void) svec_destroy(&want_ifaces); svec_destroy(&add_ifaces); } - LIST_FOR_EACH_SAFE (br, next, struct bridge, node, &all_bridges) { + LIST_FOR_EACH (br, struct bridge, node, &all_bridges) { + uint8_t ea[8]; + uint64_t dpid; + struct iface *local_iface = NULL; + const char *devname; + struct svec nf_hosts; + bridge_fetch_dp_ifaces(br); for (i = 0; i < br->n_ports; ) { struct port *port = br->ports[i]; - struct iface *local_iface = NULL; - const char *devname; - uint8_t ea[8]; - uint64_t dpid; - struct svec nf_hosts; for (j = 0; j < port->n_ifaces; ) { struct iface *iface = port->ifaces[j]; @@ -496,39 +497,38 @@ bridge_reconfigure(void) port_destroy(port); continue; } + i++; + } - /* Pick local port hardware address, datapath ID. */ - bridge_pick_local_hw_addr(br, ea, &devname); - if (local_iface) { - int error = netdev_nodev_set_etheraddr(local_iface->name, ea); - if (error) { - static struct vlog_rate_limit rl - = VLOG_RATE_LIMIT_INIT(1, 5); - VLOG_ERR_RL(&rl, "bridge %s: failed to set bridge " - "Ethernet address: %s", - br->name, strerror(error)); - } + /* Pick local port hardware address, datapath ID. */ + bridge_pick_local_hw_addr(br, ea, &devname); + if (local_iface) { + int error = netdev_nodev_set_etheraddr(local_iface->name, ea); + if (error) { + static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5); + VLOG_ERR_RL(&rl, "bridge %s: failed to set bridge " + "Ethernet address: %s", + br->name, strerror(error)); } + } - dpid = bridge_pick_datapath_id(br, ea, devname); - ofproto_set_datapath_id(br->ofproto, dpid); - - /* Set NetFlow configuration on this bridge. */ - svec_init(&nf_hosts); - cfg_get_all_keys(&nf_hosts, "netflow.%s.host", br->name); - if (ofproto_set_netflow(br->ofproto, &nf_hosts)) { - VLOG_ERR("bridge %s: problem setting netflow collectors", - br->name); - } + dpid = bridge_pick_datapath_id(br, ea, devname); + ofproto_set_datapath_id(br->ofproto, dpid); - /* Set the controller. (It would be more straightforward to do - * this in bridge_reconfigure_one(), but then the - * ofproto_set_datapath_id() above would disconnect right away, and - * we can't call ofproto_set_datapath_id() until we know the set of - * ports actually in the bridge, hence not until now.) */ - ofproto_set_controller(br->ofproto, br->controller); - i++; + /* Set NetFlow configuration on this bridge. */ + svec_init(&nf_hosts); + cfg_get_all_keys(&nf_hosts, "netflow.%s.host", br->name); + if (ofproto_set_netflow(br->ofproto, &nf_hosts)) { + VLOG_ERR("bridge %s: problem setting netflow collectors", + br->name); } + + /* Set the controller. (It would be more straightforward to do + * this in bridge_reconfigure_one(), but then the + * ofproto_set_datapath_id() above would disconnect right away, and + * we can't call ofproto_set_datapath_id() until we know the set of + * ports actually in the bridge, hence not until now.) */ + ofproto_set_controller(br->ofproto, br->controller); } LIST_FOR_EACH (br, struct bridge, node, &all_bridges) { for (i = 0; i < br->n_ports; i++) {