netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF to prevent ipv6 addrconf
@ 2022-12-09 15:21 Xin Long
  2022-12-09 15:21 ` [PATCH net-next 1/3] net: add IFF_NO_ADDRCONF and use it in bonding " Xin Long
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Xin Long @ 2022-12-09 15:21 UTC (permalink / raw)
  To: network dev
  Cc: davem, kuba, Eric Dumazet, Paolo Abeni, Jiri Pirko, Jay Vosburgh,
	Veaceslav Falico, Andy Gospodarek, Sridhar Samudrala,
	Stephen Hemminger, LiLiang

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.

Xin Long (3):
  net: add IFF_NO_ADDRCONF and use it in bonding to prevent ipv6
    addrconf
  net: team: use IFF_NO_ADDRCONF flag to prevent ipv6 addrconf
  net: failover: use IFF_NO_ADDRCONF flag to prevent ipv6 addrconf

 drivers/net/bonding/bond_main.c | 18 +++++++++++++-----
 drivers/net/team/team.c         |  2 ++
 include/linux/netdevice.h       |  3 ++-
 net/core/failover.c             |  6 +++---
 net/ipv6/addrconf.c             |  4 ++--
 5 files changed, 22 insertions(+), 11 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH net-next 1/3] net: add IFF_NO_ADDRCONF and use it in bonding to prevent ipv6 addrconf
  2022-12-09 15:21 [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF to prevent ipv6 addrconf Xin Long
@ 2022-12-09 15:21 ` Xin Long
  2022-12-09 15:21 ` [PATCH net-next 2/3] net: team: use IFF_NO_ADDRCONF flag " Xin Long
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Xin Long @ 2022-12-09 15:21 UTC (permalink / raw)
  To: network dev
  Cc: davem, kuba, Eric Dumazet, Paolo Abeni, Jiri Pirko, Jay Vosburgh,
	Veaceslav Falico, Andy Gospodarek, Sridhar Samudrala,
	Stephen Hemminger, LiLiang

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 <lucien.xin@gmail.com>
---
 drivers/net/bonding/bond_main.c | 18 +++++++++++++-----
 include/linux/netdevice.h       |  3 ++-
 net/ipv6/addrconf.c             |  4 ++--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index e01bb0412f1c..c1cc44223786 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1632,13 +1632,19 @@ static int bond_master_upper_dev_link(struct bonding *bond, struct slave *slave,
 {
 	struct netdev_lag_upper_info lag_upper_info;
 	enum netdev_lag_tx_type type;
+	int err;
 
 	type = bond_lag_tx_type(bond);
 	lag_upper_info.tx_type = type;
 	lag_upper_info.hash_type = bond_lag_hash_type(bond, type);
 
-	return netdev_master_upper_dev_link(slave->dev, bond->dev, slave,
-					    &lag_upper_info, extack);
+	err = netdev_master_upper_dev_link(slave->dev, bond->dev, slave,
+					   &lag_upper_info, extack);
+	if (err)
+		return err;
+
+	slave->dev->flags |= IFF_SLAVE;
+	return 0;
 }
 
 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,
 		}
 	}
 
-	/* set slave flag before open to prevent IPv6 addrconf */
-	slave_dev->flags |= IFF_SLAVE;
+	/* set no_addrconf flag before open to prevent IPv6 addrconf */
+	slave_dev->priv_flags |= IFF_NO_ADDRCONF;
 
 	/* open the slave since the application closed it */
 	res = dev_open(slave_dev, extack);
@@ -2254,7 +2260,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 	dev_close(slave_dev);
 
 err_restore_mac:
-	slave_dev->flags &= ~IFF_SLAVE;
+	slave_dev->priv_flags &= ~IFF_NO_ADDRCONF;
 	if (!bond->params.fail_over_mac ||
 	    BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
 		/* XXX TODO - fom follow mode needs to change master's
@@ -2446,6 +2452,8 @@ static int __bond_release_one(struct net_device *bond_dev,
 	/* close slave before restoring its mac address */
 	dev_close(slave_dev);
 
+	slave_dev->priv_flags &= ~IFF_NO_ADDRCONF;
+
 	if (bond->params.fail_over_mac != BOND_FOM_ACTIVE ||
 	    BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) {
 		/* restore original ("permanent") mac address */
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index f78db610ada5..34f9752a715b 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1658,6 +1658,7 @@ struct net_device_ops {
  * @IFF_FAILOVER: device is a failover master device
  * @IFF_FAILOVER_SLAVE: device is lower dev of a failover master device
  * @IFF_L3MDEV_RX_HANDLER: only invoke the rx handler of L3 master device
+ * @IFF_NO_ADDRCONF: prevent ipv6 addrconf
  * @IFF_TX_SKB_NO_LINEAR: device/driver is capable of xmitting frames with
  *	skb_headlen(skb) == 0 (data starts from frag0)
  * @IFF_CHANGE_PROTO_DOWN: device supports setting carrier via IFLA_PROTO_DOWN
@@ -1693,7 +1694,7 @@ enum netdev_priv_flags {
 	IFF_FAILOVER			= 1<<27,
 	IFF_FAILOVER_SLAVE		= 1<<28,
 	IFF_L3MDEV_RX_HANDLER		= 1<<29,
-	/* was IFF_LIVE_RENAME_OK */
+	IFF_NO_ADDRCONF			= BIT_ULL(30),
 	IFF_TX_SKB_NO_LINEAR		= BIT_ULL(31),
 	IFF_CHANGE_PROTO_DOWN		= BIT_ULL(32),
 };
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 9c3f5202a97b..c338dfb05d2c 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -3320,7 +3320,7 @@ static void addrconf_addr_gen(struct inet6_dev *idev, bool prefix_route)
 		return;
 
 	/* no link local addresses on devices flagged as slaves */
-	if (idev->dev->flags & IFF_SLAVE)
+	if (idev->dev->priv_flags & IFF_NO_ADDRCONF)
 		return;
 
 	ipv6_addr_set(&addr, htonl(0xFE800000), 0, 0, 0);
@@ -3560,7 +3560,7 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
 		if (idev && idev->cnf.disable_ipv6)
 			break;
 
-		if (dev->flags & IFF_SLAVE) {
+		if (dev->priv_flags & IFF_NO_ADDRCONF) {
 			if (event == NETDEV_UP && !IS_ERR_OR_NULL(idev) &&
 			    dev->flags & IFF_UP && dev->flags & IFF_MULTICAST)
 				ipv6_mc_up(idev);
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 2/3] net: team: use IFF_NO_ADDRCONF flag to prevent ipv6 addrconf
  2022-12-09 15:21 [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF to prevent ipv6 addrconf Xin Long
  2022-12-09 15:21 ` [PATCH net-next 1/3] net: add IFF_NO_ADDRCONF and use it in bonding " Xin Long
@ 2022-12-09 15:21 ` Xin Long
  2022-12-09 15:21 ` [PATCH net-next 3/3] net: failover: " Xin Long
  2022-12-12 23:30 ` [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF " patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Xin Long @ 2022-12-09 15:21 UTC (permalink / raw)
  To: network dev
  Cc: davem, kuba, Eric Dumazet, Paolo Abeni, Jiri Pirko, Jay Vosburgh,
	Veaceslav Falico, Andy Gospodarek, Sridhar Samudrala,
	Stephen Hemminger, LiLiang

This patch is to use IFF_NO_ADDRCONF flag to prevent ipv6 addrconf
for Team port. This flag will be set in team_port_enter(), which
is called before dev_open(), and cleared in team_port_leave(),
called after dev_close() and the err path in team_port_add().

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 drivers/net/team/team.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
index d10606f257c4..fcd43d62d86b 100644
--- a/drivers/net/team/team.c
+++ b/drivers/net/team/team.c
@@ -1044,6 +1044,7 @@ static int team_port_enter(struct team *team, struct team_port *port)
 			goto err_port_enter;
 		}
 	}
+	port->dev->priv_flags |= IFF_NO_ADDRCONF;
 
 	return 0;
 
@@ -1057,6 +1058,7 @@ static void team_port_leave(struct team *team, struct team_port *port)
 {
 	if (team->ops.port_leave)
 		team->ops.port_leave(team, port);
+	port->dev->priv_flags &= ~IFF_NO_ADDRCONF;
 	dev_put(team->dev);
 }
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH net-next 3/3] net: failover: use IFF_NO_ADDRCONF flag to prevent ipv6 addrconf
  2022-12-09 15:21 [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF to prevent ipv6 addrconf Xin Long
  2022-12-09 15:21 ` [PATCH net-next 1/3] net: add IFF_NO_ADDRCONF and use it in bonding " Xin Long
  2022-12-09 15:21 ` [PATCH net-next 2/3] net: team: use IFF_NO_ADDRCONF flag " Xin Long
@ 2022-12-09 15:21 ` Xin Long
  2022-12-12 23:30 ` [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF " patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Xin Long @ 2022-12-09 15:21 UTC (permalink / raw)
  To: network dev
  Cc: davem, kuba, Eric Dumazet, Paolo Abeni, Jiri Pirko, Jay Vosburgh,
	Veaceslav Falico, Andy Gospodarek, Sridhar Samudrala,
	Stephen Hemminger, LiLiang

Similar to Bonding and Team, to prevent ipv6 addrconf with
IFF_NO_ADDRCONF in slave_dev->priv_flags for slave ports
is also needed in net failover.

Note that dev_open(slave_dev) is called in .slave_register,
which is called after the IFF_NO_ADDRCONF flag is set in
failover_slave_register().

Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/core/failover.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/core/failover.c b/net/core/failover.c
index 655411c4ca51..2a140b3ea669 100644
--- a/net/core/failover.c
+++ b/net/core/failover.c
@@ -80,14 +80,14 @@ static int failover_slave_register(struct net_device *slave_dev)
 		goto err_upper_link;
 	}
 
-	slave_dev->priv_flags |= IFF_FAILOVER_SLAVE;
+	slave_dev->priv_flags |= (IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF);
 
 	if (fops && fops->slave_register &&
 	    !fops->slave_register(slave_dev, failover_dev))
 		return NOTIFY_OK;
 
 	netdev_upper_dev_unlink(slave_dev, failover_dev);
-	slave_dev->priv_flags &= ~IFF_FAILOVER_SLAVE;
+	slave_dev->priv_flags &= ~(IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF);
 err_upper_link:
 	netdev_rx_handler_unregister(slave_dev);
 done:
@@ -121,7 +121,7 @@ int failover_slave_unregister(struct net_device *slave_dev)
 
 	netdev_rx_handler_unregister(slave_dev);
 	netdev_upper_dev_unlink(slave_dev, failover_dev);
-	slave_dev->priv_flags &= ~IFF_FAILOVER_SLAVE;
+	slave_dev->priv_flags &= ~(IFF_FAILOVER_SLAVE | IFF_NO_ADDRCONF);
 
 	if (fops && fops->slave_unregister &&
 	    !fops->slave_unregister(slave_dev, failover_dev))
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF to prevent ipv6 addrconf
  2022-12-09 15:21 [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF to prevent ipv6 addrconf Xin Long
                   ` (2 preceding siblings ...)
  2022-12-09 15:21 ` [PATCH net-next 3/3] net: failover: " Xin Long
@ 2022-12-12 23:30 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-12 23:30 UTC (permalink / raw)
  To: Xin Long
  Cc: netdev, davem, kuba, edumazet, pabeni, jiri, j.vosburgh, vfalico,
	andy, sridhar.samudrala, stephen, liali

Hello:

This series was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Fri,  9 Dec 2022 10:21:37 -0500 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,1/3] net: add IFF_NO_ADDRCONF and use it in bonding to prevent ipv6 addrconf
    https://git.kernel.org/netdev/net-next/c/8a321cf7becc
  - [net-next,2/3] net: team: use IFF_NO_ADDRCONF flag to prevent ipv6 addrconf
    https://git.kernel.org/netdev/net-next/c/0aa64df30b38
  - [net-next,3/3] net: failover: use IFF_NO_ADDRCONF flag to prevent ipv6 addrconf
    https://git.kernel.org/netdev/net-next/c/cb54d392279d

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-12-12 23:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-09 15:21 [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF to prevent ipv6 addrconf Xin Long
2022-12-09 15:21 ` [PATCH net-next 1/3] net: add IFF_NO_ADDRCONF and use it in bonding " Xin Long
2022-12-09 15:21 ` [PATCH net-next 2/3] net: team: use IFF_NO_ADDRCONF flag " Xin Long
2022-12-09 15:21 ` [PATCH net-next 3/3] net: failover: " Xin Long
2022-12-12 23:30 ` [PATCH net-next 0/3] net: add IFF_NO_ADDRCONF " patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).