static struct hmap all_bonds__ = HMAP_INITIALIZER(&all_bonds__);
static struct hmap *const all_bonds OVS_GUARDED_BY(rwlock) = &all_bonds__;
-/* Bit-mask for hashing a flow down to a bucket.
- * There are (BOND_MASK + 1) buckets. */
+/* Bit-mask for hashing a flow down to a bucket. */
#define BOND_MASK 0xff
+#define BOND_BUCKETS (BOND_MASK + 1)
#define RECIRC_RULE_PRIORITY 20 /* Priority level for internal rules */
/* A hash bucket for mapping a flow to a slave.
- * "struct bond" has an array of (BOND_MASK + 1) of these. */
+ * "struct bond" has an array of BOND_BUCKETS of these. */
struct bond_entry {
struct bond_slave *slave; /* Assigned slave, NULL if unassigned. */
- uint64_t tx_bytes; /* Count of bytes recently transmitted. */
+ uint64_t tx_bytes /* Count of bytes recently transmitted. */
+ OVS_GUARDED_BY(rwlock);
struct list list_node; /* In bond_slave's 'entries' list. */
- /* Recirculation. */
- struct rule *pr_rule; /* Post recirculation rule for this entry.*/
- uint64_t pr_tx_bytes; /* Record the rule tx_bytes to figure out
- the delta to update the tx_bytes entry
- above.*/
+ /* Recirculation.
+ *
+ * 'pr_rule' is the post-recirculation rule for this entry.
+ * 'pr_tx_bytes' is the most recently seen statistics for 'pr_rule', which
+ * is used to determine delta (applied to 'tx_bytes' above.) */
+ struct rule *pr_rule;
+ uint64_t pr_tx_bytes OVS_GUARDED_BY(rwlock);
};
/* A bond slave, that is, one of the links comprising a bond. */
uint32_t basis; /* Basis for flow hash function. */
/* SLB specific bonding info. */
- struct bond_entry *hash; /* An array of (BOND_MASK + 1) elements. */
+ struct bond_entry *hash; /* An array of BOND_BUCKETS elements. */
int rebalance_interval; /* Interval between rebalances, in ms. */
long long int next_rebalance; /* Next rebalancing time. */
bool send_learning_packets;
static void bond_link_status_update(struct bond_slave *)
OVS_REQ_WRLOCK(rwlock);
static void bond_choose_active_slave(struct bond *)
- OVS_REQ_WRLOCK(rwlock);;
+ OVS_REQ_WRLOCK(rwlock);
static unsigned int bond_hash_src(const uint8_t mac[ETH_ADDR_LEN],
uint16_t vlan, uint32_t basis);
static unsigned int bond_hash_tcp(const struct flow *, uint16_t vlan,
return;
}
- for (i = 0; i < BOND_MASK + 1; i++) {
+ for (i = 0; i < BOND_BUCKETS; i++) {
struct bond_slave *slave = bond->hash[i].slave;
if (slave) {
/* Recirculation. */
static void
bond_entry_account(struct bond_entry *entry, uint64_t rule_tx_bytes)
- OVS_REQ_RDLOCK(rwlock)
+ OVS_REQ_WRLOCK(rwlock)
{
if (entry->slave) {
uint64_t delta;
{
int i;
- ovs_rwlock_rdlock(&rwlock);
+ ovs_rwlock_wrlock(&rwlock);
for (i=0; i<=BOND_MASK; i++) {
struct bond_entry *entry = &bond->hash[i];
struct rule *rule = entry->pr_rule;
static void
log_bals(struct bond *bond, const struct list *bals)
+ OVS_REQ_RDLOCK(rwlock)
{
if (VLOG_IS_DBG_ENABLED()) {
struct ds ds = DS_EMPTY_INITIALIZER;
/* Shifts 'hash' from its current slave to 'to'. */
static void
bond_shift_load(struct bond_entry *hash, struct bond_slave *to)
+ OVS_REQ_WRLOCK(rwlock)
{
struct bond_slave *from = hash->slave;
struct bond *bond = from->bond;
* shift away small hashes or large hashes. */
static struct bond_entry *
choose_entry_to_migrate(const struct bond_slave *from, uint64_t to_tx_bytes)
+ OVS_REQ_WRLOCK(rwlock)
{
struct bond_entry *e;
bond_entry_reset(struct bond *bond)
{
if (bond->balance != BM_AB) {
- size_t hash_len = (BOND_MASK + 1) * sizeof *bond->hash;
+ size_t hash_len = BOND_BUCKETS * sizeof *bond->hash;
if (!bond->hash) {
bond->hash = xmalloc(hash_len);