aboutsummaryrefslogtreecommitdiff
path: root/vswitchd/ovs-brcompatd.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2009-07-15 12:09:43 -0700
committerBen Pfaff <blp@nicira.com>2009-07-16 09:18:21 -0700
commit14551ceac68a7acf3a584fac3586dcbd9ad8745c (patch)
tree8d5db03dad5bf212006b8aa4d95806e4406c0352 /vswitchd/ovs-brcompatd.c
parentb5dae6846aa511ce4347ce988beb685ad20afdcb (diff)
brcompatd: Factor code out of prune_ports().
An upcoming commit will also need to gather all of the interfaces on a specified bridge, so break this code into a helper function.
Diffstat (limited to 'vswitchd/ovs-brcompatd.c')
-rw-r--r--vswitchd/ovs-brcompatd.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/vswitchd/ovs-brcompatd.c b/vswitchd/ovs-brcompatd.c
index 5bb60cb8..9274da0a 100644
--- a/vswitchd/ovs-brcompatd.c
+++ b/vswitchd/ovs-brcompatd.c
@@ -200,6 +200,32 @@ rewrite_and_reload_config(void)
return 0;
}
+/* Get all the interfaces for 'bridge' as 'ifaces', breaking bonded interfaces
+ * down into their constituent parts. */
+static void
+get_bridge_ifaces(const char *bridge, struct svec *ifaces)
+{
+ struct svec ports;
+ int i;
+
+ svec_init(&ports);
+ svec_init(ifaces);
+ cfg_get_all_keys(&ports, "bridge.%s.port", bridge);
+ for (i = 0; i < ports.n; i++) {
+ const char *port_name = ports.names[i];
+ if (cfg_has_section("bonding.%s", port_name)) {
+ struct svec slaves;
+ svec_init(&slaves);
+ cfg_get_all_keys(&slaves, "bonding.%s.slave", port_name);
+ svec_append(ifaces, &slaves);
+ svec_destroy(&slaves);
+ } else {
+ svec_add(ifaces, port_name);
+ }
+ }
+ svec_destroy(&ports);
+}
+
/* Go through the configuration file and remove any ports that no longer
* exist associated with a bridge. */
static void
@@ -219,29 +245,10 @@ prune_ports(void)
cfg_get_subsections(&bridges, "bridge");
for (i=0; i<bridges.n; i++) {
const char *br_name = bridges.names[i];
- struct svec ports, ifaces;
-
- svec_init(&ports);
-
- /* Get all the interfaces for the given bridge, breaking bonded
- * interfaces down into their constituent parts. */
- svec_init(&ifaces);
- cfg_get_all_keys(&ports, "bridge.%s.port", br_name);
- for (j=0; j<ports.n; j++) {
- const char *port_name = ports.names[j];
- if (cfg_has_section("bonding.%s", port_name)) {
- struct svec slaves;
- svec_init(&slaves);
- cfg_get_all_keys(&slaves, "bonding.%s.slave", port_name);
- svec_append(&ifaces, &slaves);
- svec_destroy(&slaves);
- } else {
- svec_add(&ifaces, port_name);
- }
- }
- svec_destroy(&ports);
+ struct svec ifaces;
- /* Check that the interfaces exist. */
+ /* Check that each bridge interface exists. */
+ get_bridge_ifaces(br_name, &ifaces);
for (j = 0; j < ifaces.n; j++) {
const char *iface_name = ifaces.names[j];
enum netdev_flags flags;