Skip to content

Commit 8a321cf

Browse files
lxinkuba-moo
authored andcommitted
net: add IFF_NO_ADDRCONF and use it in bonding to prevent ipv6 addrconf
Currently, in bonding it reused the IFF_SLAVE flag and checked it in ipv6 addrconf to prevent ipv6 addrconf. However, it is not a proper flag to use for no ipv6 addrconf, for bonding it has to move IFF_SLAVE flag setting ahead of dev_open() in bond_enslave(). Also, IFF_MASTER/SLAVE are historical flags used in bonding and eql, as Jiri mentioned, the new devices like Team, Failover do not use this flag. So as Jiri suggested, this patch adds IFF_NO_ADDRCONF in priv_flags of the device to indicate no ipv6 addconf, and uses it in bonding and moves IFF_SLAVE flag setting back to its original place. Signed-off-by: Xin Long <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 1280d4b commit 8a321cf

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,13 +1632,19 @@ static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave,
16321632
{
16331633
struct netdev_lag_upper_info lag_upper_info;
16341634
enum netdev_lag_tx_type type;
1635+
int err;
16351636

16361637
type = bond_lag_tx_type(bond);
16371638
lag_upper_info.tx_type = type;
16381639
lag_upper_info.hash_type = bond_lag_hash_type(bond, type);
16391640

1640-
return netdev_master_upper_dev_link(slave->dev, bond->dev, slave,
1641-
&lag_upper_info, extack);
1641+
err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave,
1642+
&lag_upper_info, extack);
1643+
if (err)
1644+
return err;
1645+
1646+
slave->dev->flags |= IFF_SLAVE;
1647+
return 0;
16421648
}
16431649

16441650
static void bond_upper_dev_unlink(struct bonding *bond, struct slave *slave)
@@ -1950,8 +1956,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
19501956
}
19511957
}
19521958

1953-
/* set slave flag before open to prevent IPv6 addrconf */
1954-
slave_dev->flags |= IFF_SLAVE;
1959+
/* set no_addrconf flag before open to prevent IPv6 addrconf */
1960+
slave_dev->priv_flags |= IFF_NO_ADDRCONF;
19551961

19561962
/* open the slave since the application closed it */
19571963
res = dev_open(slave_dev, extack);
@@ -2254,7 +2260,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
22542260
dev_close(slave_dev);
22552261

22562262
err_restore_mac:
2257-
slave_dev->flags &= ~IFF_SLAVE;
2263+
slave_dev->priv_flags &= ~IFF_NO_ADDRCONF;
22582264
if (!bond->params.fail_over_mac ||
22592265
BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
22602266
/* XXX TODO - fom follow mode needs to change master's
@@ -2446,6 +2452,8 @@ static int __bond_release_one(struct net_device *bond_dev,
24462452
/* close slave before restoring its mac address */
24472453
dev_close(slave_dev);
24482454

2455+
slave_dev->priv_flags &= ~IFF_NO_ADDRCONF;
2456+
24492457
if (bond->params.fail_over_mac != BOND_FOM_ACTIVE ||
24502458
BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
24512459
/* restore original ("permanent") mac address */

include/linux/netdevice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1662,6 +1662,7 @@ struct net_device_ops {
16621662
* @IFF_FAILOVER: device is a failover master device
16631663
* @IFF_FAILOVER_SLAVE: device is lower dev of a failover master device
16641664
* @IFF_L3MDEV_RX_HANDLER: only invoke the rx handler of L3 master device
1665+
* @IFF_NO_ADDRCONF: prevent ipv6 addrconf
16651666
* @IFF_TX_SKB_NO_LINEAR: device/driver is capable of xmitting frames with
16661667
* skb_headlen(skb) == 0 (data starts from frag0)
16671668
* @IFF_CHANGE_PROTO_DOWN: device supports setting carrier via IFLA_PROTO_DOWN
@@ -1697,7 +1698,7 @@ enum netdev_priv_flags {
16971698
IFF_FAILOVER = 1<<27,
16981699
IFF_FAILOVER_SLAVE = 1<<28,
16991700
IFF_L3MDEV_RX_HANDLER = 1<<29,
1700-
/* was IFF_LIVE_RENAME_OK */
1701+
IFF_NO_ADDRCONF = BIT_ULL(30),
17011702
IFF_TX_SKB_NO_LINEAR = BIT_ULL(31),
17021703
IFF_CHANGE_PROTO_DOWN = BIT_ULL(32),
17031704
};

net/ipv6/addrconf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,7 +3320,7 @@ static void addrconf_addr_gen(struct inet6_dev *idev, bool prefix_route)
33203320
return;
33213321

33223322
/* no link local addresses on devices flagged as slaves */
3323-
if (idev->dev->flags & IFF_SLAVE)
3323+
if (idev->dev->priv_flags & IFF_NO_ADDRCONF)
33243324
return;
33253325

33263326
ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0);
@@ -3560,7 +3560,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
35603560
if (idev && idev->cnf.disable_ipv6)
35613561
break;
35623562

3563-
if (dev->flags & IFF_SLAVE) {
3563+
if (dev->priv_flags & IFF_NO_ADDRCONF) {
35643564
if (event == NETDEV_UP && !IS_ERR_OR_NULL(idev) &&
35653565
dev->flags & IFF_UP && dev->flags & IFF_MULTICAST)
35663566
ipv6_mc_up(idev);

0 commit comments

Comments
 (0)