Skip to content

Commit

Permalink
bond: Fix using uninitialized 'lacp_fallback_ab_cfg' for 'bond-primary'.
Browse files Browse the repository at this point in the history
's->lacp_fallback_ab_cfg' initialized down below in the code, so
we're using it uninitialized to detect if we need to get 'bond-primary'
configuration.

Found by valgrind:

 Conditional jump or move depends on uninitialised value(s)
    at 0x409114: port_configure_bond (bridge.c:4569)
    by 0x409114: port_configure (bridge.c:1284)
    by 0x40F6E6: bridge_reconfigure (bridge.c:917)
    by 0x411425: bridge_run (bridge.c:3330)
    by 0x406D84: main (ovs-vswitchd.c:127)
  Uninitialised value was created by a stack allocation
    at 0x408C53: port_configure (bridge.c:1190)

Fix that by moving this code to the point where 'lacp_fallback_ab_cfg'
already initialized.  Additionally clarified behavior of 'bond-primary'
in manpages for the fallback to AB case.

Fixes: b4e5021 ("bond: Add 'primary' interface concept for active-backup mode.")
Acked-by: Jeff Squyres <jsquyres@cisco.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
  • Loading branch information
igsilya committed Oct 17, 2020
1 parent f3b345b commit 07d5758
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 4 additions & 5 deletions vswitchd/bridge.c
Expand Up @@ -4564,11 +4564,6 @@ port_configure_bond(struct port *port, struct bond_settings *s)
port->name);
}

s->primary = NULL;
if (s->balance == BM_AB || s->lacp_fallback_ab_cfg) {
s->primary = smap_get(&port->cfg->other_config, "bond-primary");
}

miimon_interval = smap_get_int(&port->cfg->other_config,
"bond-miimon-interval", 0);
if (miimon_interval <= 0) {
Expand All @@ -4595,6 +4590,10 @@ port_configure_bond(struct port *port, struct bond_settings *s)

s->lacp_fallback_ab_cfg = smap_get_bool(&port->cfg->other_config,
"lacp-fallback-ab", false);
s->primary = NULL;
if (s->balance == BM_AB || s->lacp_fallback_ab_cfg) {
s->primary = smap_get(&port->cfg->other_config, "bond-primary");
}

LIST_FOR_EACH (iface, port_elem, &port->ifaces) {
netdev_set_miimon_interval(iface->netdev, miimon_interval);
Expand Down
5 changes: 4 additions & 1 deletion vswitchd/vswitch.xml
Expand Up @@ -2008,7 +2008,10 @@
If a slave interface with this name exists in the bond and
is up, it will be made active. Relevant only when <ref
column="other_config" key="bond_mode"/> is
<code>active-backup</code>.
<code>active-backup</code> or if <code>balance-tcp</code> falls back
to <code>active-backup</code> (e.g., LACP negotiation fails and
<ref column="other_config" key="lacp-fallback-ab"/> is
<code>true</code>).
</column>

<group title="Link Failure Detection">
Expand Down

0 comments on commit 07d5758

Please sign in to comment.