diff options
author | Ethan Jackson <ethan@nicira.com> | 2011-04-12 13:39:32 -0700 |
---|---|---|
committer | Ethan Jackson <ethan@nicira.com> | 2011-04-13 16:26:36 -0700 |
commit | 1b137691320fbf0d1e545a146495d8988cd62200 (patch) | |
tree | 0289cc1304d74bdeef8185da6ba90f6f7bf56688 /lib/bond.c | |
parent | b49b7df441d6609f9a1e20720b491c75507d8fba (diff) |
bond: New function bond_is_balanced().
As new bond modes are added, it will be nice to have the logic
indicating whether or not a given bond mode requires rebalancing in
one place.
Diffstat (limited to 'lib/bond.c')
-rw-r--r-- | lib/bond.c | 23 |
1 files changed, 10 insertions, 13 deletions
@@ -682,23 +682,20 @@ bond_process_lacp(struct bond *bond, void *slave_, const struct ofpbuf *packet) /* Rebalancing. */ +static bool +bond_is_balanced(const struct bond *bond) +{ + return bond->balance == BM_SLB || bond->balance == BM_TCP; +} + /* Notifies 'bond' that 'n_bytes' bytes were sent in 'flow' within 'vlan'. */ void bond_account(struct bond *bond, const struct flow *flow, uint16_t vlan, uint64_t n_bytes) { - switch (bond->balance) { - case BM_AB: - /* Nothing to do. */ - break; - case BM_SLB: - case BM_TCP: + if (bond_is_balanced(bond)) { lookup_bond_entry(bond, flow, vlan)->tx_bytes += n_bytes; - break; - - default: - NOT_REACHED(); } } @@ -844,7 +841,7 @@ bond_rebalance(struct bond *bond, struct tag_set *tags) struct bond_entry *e; struct list bals; - if (bond->balance == BM_AB || time_msec() < bond->next_rebalance) { + if (!bond_is_balanced(bond) || time_msec() < bond->next_rebalance) { return; } bond->next_rebalance = time_msec() + bond->rebalance_interval; @@ -1020,7 +1017,7 @@ bond_unixctl_show(struct unixctl_conn *conn, ds_put_format(&ds, "updelay: %d ms\n", bond->updelay); ds_put_format(&ds, "downdelay: %d ms\n", bond->downdelay); - if (bond->balance != BM_AB) { + if (bond_is_balanced(bond)) { ds_put_format(&ds, "next rebalance: %lld ms\n", bond->next_rebalance - time_msec()); } @@ -1041,7 +1038,7 @@ bond_unixctl_show(struct unixctl_conn *conn, slave->delay_expires - time_msec()); } - if (bond->balance == BM_AB) { + if (!bond_is_balanced(bond)) { continue; } |