bonding: ensure that TLB mode's active slave has correct mac filter
Subsystems (3)
PATCH 1/1 bonding: ensure that TLB mode's active slave has correct mac filter
Currently, in TLB mode we change mac addresses only by memcpy-ing the to net_device->dev_addr, without actually setting them via dev_set_mac_address(). This permits us to receive all the traffic always on one mac address.
However, in case the interface flips, some drivers might enforce the mac filtering for its FW/HW based on current ->dev_addr, and thus we won't be able to receive traffic on that interface, in case it will be selected as active in TLB mode.
Fix it by setting the mac address forcefully on every new active slave that we select in TLB mode.
---
Notes:
It seems that it's the least intrusive fix. The, maybe, better way would be to leave the dev_addr unchainged and play around with mac addresses in logic, however it's making the code a lot more bloated, error prone and hard to read, so it's not worth it, imho.
drivers/net/bonding/bond_alb.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/net/bonding/bond_alb.c +17 -0
@@ -1699,6 +1699,23 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slaveASSERT_RTNL (); +/* in TLB mode, the slave might flip down/up with the old dev_addr, +* and thus filter bond->dev_addr's packets, so force bond's mac +*/ +if (bond->params.mode ==BOND_MODE_TLB ) { +struct sockaddr sa; +u8 tmp_addr[ETH_ALEN ]; + +memcpy (tmp_addr, new_slave->dev->dev_addr,ETH_ALEN ); + +memcpy (sa.sa_data, bond->dev->dev_addr, bond->dev->addr_len); + sa.sa_family = bond->dev->type; +/* we don't care if it can't change its mac, best effort */ +dev_set_mac_address (new_slave->dev, &sa); + +memcpy (new_slave->dev->dev_addr, tmp_addr,ETH_ALEN ); + } +/* curr_active_slave must be set before calling alb_swap_mac_addr */ if (swap_slave) {/* swap mac address */
Signature · 1 line
1.8.4
From: Veaceslav Falico <[email protected]>
Date: Mon, 7 Oct 2013 09:17:20 +0200
Quoted 13 lines
Currently, in TLB mode we change mac addresses only by memcpy-ing the to
net_device->dev_addr, without actually setting them viadev_set_mac_address(). This permits us to receive all the traffic always on one mac address.However, in case the interface flips, some drivers might enforce the mac filtering for its FW/HW based on current ->dev_addr, and thus we won't be able to receive traffic on that interface, in case it will be selected as active in TLB mode.
Fix it by setting the mac address forcefully on every new active slave that we select in TLB mode.
Quoted 6 lines
CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>CC Yuval Mintz <[email protected]>Reported-by Yuval Mintz <[email protected]>Tested-by Yuval Mintz <[email protected]>Signed-off-by Veaceslav Falico <[email protected]>
Since we hole the RTNL during this tricky operation I guess this is fine.
Applied, thanks.