Skip to content

Commit 0b680e7

Browse files
Jay VosburghJeff Garzik
Jay Vosburgh
authored and
Jeff Garzik
committed
[PATCH] bonding: Add priv_flag to avoid event mishandling
Add priv_flag to specifically identify bonding-involved devices. Needed because IFF_MASTER is an unreliable identifier (vlan interfaces above bonding will inherit IFF_MASTER). Misidentification of devices would cause notifier events for other devices to be erroneously processed by bonding, causing various havoc. Bug discovered by Martin Papik <[email protected]>; this patch is modified from his original. Signed-off-by: Martin Papik <[email protected]> Signed-off-by: Jay Vosburgh <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>
1 parent 54ef313 commit 0b680e7

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

drivers/net/bonding/bond_main.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
13711371
}
13721372

13731373
new_slave->dev = slave_dev;
1374+
slave_dev->priv_flags |= IFF_BONDING;
13741375

13751376
if ((bond->params.mode == BOND_MODE_TLB) ||
13761377
(bond->params.mode == BOND_MODE_ALB)) {
@@ -1784,7 +1785,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
17841785
dev_set_mac_address(slave_dev, &addr);
17851786

17861787
slave_dev->priv_flags &= ~(IFF_MASTER_8023AD | IFF_MASTER_ALB |
1787-
IFF_SLAVE_INACTIVE);
1788+
IFF_SLAVE_INACTIVE | IFF_BONDING);
17881789

17891790
kfree(slave);
17901791

@@ -3216,6 +3217,9 @@ static int bond_netdev_event(struct notifier_block *this, unsigned long event, v
32163217
(event_dev ? event_dev->name : "None"),
32173218
event);
32183219

3220+
if (!(event_dev->priv_flags & IFF_BONDING))
3221+
return NOTIFY_DONE;
3222+
32193223
if (event_dev->flags & IFF_MASTER) {
32203224
dprintk("IFF_MASTER\n");
32213225
return bond_master_netdev_event(event, event_dev);
@@ -4185,6 +4189,7 @@ static int bond_init(struct net_device *bond_dev, struct bond_params *params)
41854189
/* Initialize the device options */
41864190
bond_dev->tx_queue_len = 0;
41874191
bond_dev->flags |= IFF_MASTER|IFF_MULTICAST;
4192+
bond_dev->priv_flags |= IFF_BONDING;
41884193

41894194
/* At first, we block adding VLANs. That's the only way to
41904195
* prevent problems that occur when adding VLANs over an

include/linux/if.h

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#define IFF_SLAVE_INACTIVE 0x4 /* bonding slave not the curr. active */
6060
#define IFF_MASTER_8023AD 0x8 /* bonding master, 802.3ad. */
6161
#define IFF_MASTER_ALB 0x10 /* bonding master, balance-alb. */
62+
#define IFF_BONDING 0x20 /* bonding master or slave */
6263

6364
#define IF_GET_IFACE 0x0001 /* for querying only */
6465
#define IF_GET_PROTO 0x0002

0 commit comments

Comments
 (0)