X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=ofproto%2Fbond.c;h=c1a84482af80c6a73fb354b5b2278e42b9e86b53;hb=6d308b28c023e864925b1a6775b3b91d215e89bf;hp=630e535c98709f48637371d68bff1107147d1ee7;hpb=4a750708bc9b6d76d67d88cd1b7193a9c62fdb9e;p=sliver-openvswitch.git diff --git a/ofproto/bond.c b/ofproto/bond.c index 630e535c9..c1a84482a 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -861,7 +861,7 @@ bond_entry_account(struct bond_entry *entry, uint64_t rule_tx_bytes) } /* Maintain bond stats using post recirculation rule byte counters.*/ -void +static void bond_recirculation_account(struct bond *bond) { int i; @@ -888,7 +888,7 @@ bool bond_may_recirc(const struct bond *bond, uint32_t *recirc_id, uint32_t *hash_bias) { - if (bond->balance == BM_TCP) { + if (bond->balance == BM_TCP && recirc_id) { if (recirc_id) { *recirc_id = bond->recirc_id; } @@ -1087,15 +1087,15 @@ reinsert_bal(struct list *bals, struct bond_slave *slave) * The caller should have called bond_account() for each active flow, or in case * of recirculation is used, have called bond_recirculation_account(bond), * to ensure that flow data is consistently accounted at this point. - * - * Return whether rebalancing took place.*/ -bool + */ +void bond_rebalance(struct bond *bond) { struct bond_slave *slave; struct bond_entry *e; struct list bals; bool rebalanced = false; + bool use_recirc; ovs_rwlock_wrlock(&rwlock); if (!bond_is_balanced(bond) || time_msec() < bond->next_rebalance) { @@ -1103,6 +1103,13 @@ bond_rebalance(struct bond *bond) } bond->next_rebalance = time_msec() + bond->rebalance_interval; + use_recirc = ofproto_dpif_get_enable_recirc(bond->ofproto) && + bond_may_recirc(bond, NULL, NULL); + + if (use_recirc) { + bond_recirculation_account(bond); + } + /* Add each bond_entry to its slave's 'entries' list. * Compute each slave's tx_bytes as the sum of its entries' tx_bytes. */ HMAP_FOR_EACH (slave, hmap_node, &bond->slaves) { @@ -1158,7 +1165,7 @@ bond_rebalance(struct bond *bond) /* Re-sort 'bals'. */ reinsert_bal(&bals, from); reinsert_bal(&bals, to); - rebalanced = true; + rebalanced = true; } else { /* Can't usefully migrate anything away from 'from'. * Don't reconsider it. */ @@ -1173,9 +1180,12 @@ bond_rebalance(struct bond *bond) e->tx_bytes /= 2; } + if (use_recirc && rebalanced) { + bond_update_post_recirc_rules(bond,true); + } + done: ovs_rwlock_unlock(&rwlock); - return rebalanced; } /* Bonding unixctl user interface functions. */