From: Ben Pfaff Date: Mon, 13 Dec 2010 19:12:37 +0000 (-0800) Subject: bridge: Eliminate bond_rebalance_port() dependency on DP_MAX_PORTS. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c47cd5f01377c54251fbf093f8fb390f631a8264;p=openvswitch bridge: Eliminate bond_rebalance_port() dependency on DP_MAX_PORTS. There's no reason to allocate the bals[] array on the stack here, since this is not on any fast-path. As an alternative, we could limit the number of interfaces on a single bond to some reasonable maximum, such as 8 or 32, but this commit's change is simpler. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 6691746f..69241dab 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2943,7 +2943,7 @@ bond_shift_load(struct slave_balance *from, struct slave_balance *to, static void bond_rebalance_port(struct port *port) { - struct slave_balance bals[DP_MAX_PORTS]; + struct slave_balance *bals; size_t n_bals; struct bond_entry *hashes[BOND_MASK + 1]; struct slave_balance *b, *from, *to; @@ -2961,6 +2961,7 @@ bond_rebalance_port(struct port *port) * become contiguous in memory, and then we point each 'hashes' members of * a slave_balance structure to the start of a contiguous group. */ n_bals = port->n_ifaces; + bals = xmalloc(n_bals * sizeof *bals); for (b = bals; b < &bals[n_bals]; b++) { b->iface = port->ifaces[b - bals]; b->tx_bytes = 0; @@ -2990,7 +2991,7 @@ bond_rebalance_port(struct port *port) while (!bals[n_bals - 1].iface->enabled) { n_bals--; if (!n_bals) { - return; + goto exit; } } @@ -3082,6 +3083,9 @@ bond_rebalance_port(struct port *port) for (e = &port->bond_hash[0]; e <= &port->bond_hash[BOND_MASK]; e++) { e->tx_bytes /= 2; } + +exit: + free(bals); } static void