Skip to content

Commit 2a78dd2

Browse files
committed
Merge branch 'net-add-iff_no_addrconf-to-prevent-ipv6-addrconf'
Xin Long says: ==================== net: add IFF_NO_ADDRCONF to prevent ipv6 addrconf This patchset adds IFF_NO_ADDRCONF flag for dev->priv_flags to prevent ipv6 addrconf, as Jiri Pirko's suggestion. For Bonding it changes to use this flag instead of IFF_SLAVE flag in Patch 1, and for Teaming and Net Failover it sets this flag before calling dev_open() in Patch 2 and 3. ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 1280d4b + cb54d39 commit 2a78dd2

File tree

5 files changed

+22
-11
lines changed

5 files changed

+22
-11
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 */

drivers/net/team/team.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,7 @@ static int team_port_enter(struct team *team, struct team_port *port)
10441044
goto err_port_enter;
10451045
}
10461046
}
1047+
port->dev->priv_flags |= IFF_NO_ADDRCONF;
10471048

10481049
return 0;
10491050

@@ -1057,6 +1058,7 @@ static void team_port_leave(struct team *team, struct team_port *port)
10571058
{
10581059
if (team->ops.port_leave)
10591060
team->ops.port_leave(team, port);
1061+
port->dev->priv_flags &= ~IFF_NO_ADDRCONF;
10601062
dev_put(team->dev);
10611063
}
10621064

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/core/failover.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,14 @@ static int failover_slave_register(struct net_device *slave_dev)
8080
goto err_upper_link;
8181
}
8282

83-
slave_dev->priv_flags |= IFF_FAILOVER_SLAVE;
83+
slave_dev->priv_flags |= (IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF);
8484

8585
if (fops && fops->slave_register &&
8686
!fops->slave_register(slave_dev, failover_dev))
8787
return NOTIFY_OK;
8888

8989
netdev_upper_dev_unlink(slave_dev, failover_dev);
90-
slave_dev->priv_flags &= ~IFF_FAILOVER_SLAVE;
90+
slave_dev->priv_flags &= ~(IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF);
9191
err_upper_link:
9292
netdev_rx_handler_unregister(slave_dev);
9393
done:
@@ -121,7 +121,7 @@ int failover_slave_unregister(struct net_device *slave_dev)
121121

122122
netdev_rx_handler_unregister(slave_dev);
123123
netdev_upper_dev_unlink(slave_dev, failover_dev);
124-
slave_dev->priv_flags &= ~IFF_FAILOVER_SLAVE;
124+
slave_dev->priv_flags &= ~(IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF);
125125

126126
if (fops && fops->slave_unregister &&
127127
!fops->slave_unregister(slave_dev, failover_dev))

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)