From 76ed83fc3f82f6d3074c4f87a38dd9ef164b6dc0 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 13 May 2011 16:47:01 -0700 Subject: [PATCH] bridge: Fix uninitialized bond_stable_ids in port_configure_bond(). The recent merge of "master" added a new bond_stable_ids member to struct ofproto_bundle_settings, but neglected to initialize it. This fixes the problem. Found and verified using valgrind. --- vswitchd/bridge.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 127e0b7cf..f0ff91d92 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -175,7 +175,8 @@ static struct port *port_lookup(const struct bridge *, const char *name); static void port_configure(struct port *); static struct lacp_settings *port_configure_lacp(struct port *, struct lacp_settings *); -static void port_configure_bond(struct port *, struct bond_settings *); +static void port_configure_bond(struct port *, struct bond_settings *, + uint32_t *bond_stable_ids); static void bridge_configure_mirrors(struct bridge *); static struct mirror *mirror_create(struct bridge *, @@ -521,10 +522,12 @@ port_configure(struct port *port) /* Get bond settings. */ if (s.n_slaves > 1) { - port_configure_bond(port, &bond_settings); s.bond = &bond_settings; + s.bond_stable_ids = xmalloc(s.n_slaves * sizeof *s.bond_stable_ids); + port_configure_bond(port, &bond_settings, s.bond_stable_ids); } else { s.bond = NULL; + s.bond_stable_ids = NULL; } /* Register. */ @@ -533,6 +536,7 @@ port_configure(struct port *port) /* Clean up. */ free(s.trunks); free(s.lacp_slaves); + free(s.bond_stable_ids); } /* Pick local port hardware address and datapath ID for 'br'. */ @@ -2214,9 +2218,12 @@ iface_configure_lacp(struct iface *iface, struct lacp_slave_settings *s) } static void -port_configure_bond(struct port *port, struct bond_settings *s) +port_configure_bond(struct port *port, struct bond_settings *s, + uint32_t *bond_stable_ids) { const char *detect_s; + struct iface *iface; + size_t i; s->name = port->name; s->balance = BM_SLB; @@ -2251,6 +2258,18 @@ port_configure_bond(struct port *port, struct bond_settings *s) } s->fake_iface = port->cfg->bond_fake_iface; + + i = 0; + LIST_FOR_EACH (iface, port_elem, &port->ifaces) { + long long stable_id; + + stable_id = atoll(get_interface_other_config(iface->cfg, + "bond-stable-id", "0")); + if (stable_id <= 0 || stable_id >= UINT32_MAX) { + stable_id = iface->ofp_port; + } + bond_stable_ids[i++] = stable_id; + } } /* Interface functions. */ -- 2.43.0