[ovs-dev] [stable 3/3] bond: New bonding mode "stable".

Ethan Jackson ethan at nicira.com
Thu Apr 14 18:05:39 UTC 2011


> What motivated this change?

Just defensive coding.  I noticed it when looking over the patch
again.  If n_stb_slaves is 0, e.g. there are no enabled slaves.  It's
better to choose something (e.g. the active slave) instead of trigger
a divide by zero.

Ethan


>
>> @@ -1518,9 +1520,13 @@ choose_output_slave(const struct bond *bond, const struct flow *flow,
>>      switch (bond->balance) {
>>      case BM_AB:
>>          return bond->active_slave;
>> -    case BM_STB:
>> -        return bond->stb_slaves[bond_hash(bond, flow, vlan)
>> -            % bond->n_stb_slaves];
>> +    case BM_STABLE:
>> +        if (bond->n_stb_slaves) {
>> +            return bond->stb_slaves[bond_hash(bond, flow, vlan)
>> +                % bond->n_stb_slaves];
>> +        } else {
>> +            return bond->active_slave;
>> +        }
>>      case BM_SLB:
>>      case BM_TCP:
>>          e = lookup_bond_entry(bond, flow, vlan);
>



More information about the dev mailing list