bonding: Prevent IPv6 link local address on enslaved devices
Subsystems (3)
PATCH 1/1 bonding: Prevent IPv6 link local address on enslaved devices
Upstream commit 1f718f0f4f97 ("bonding: populate neighbour's private on enslave") undoes the fix provided by commit c2edacf80e15 ("bonding / ipv6: no addrconf for slaves separately from master") by effectively setting the slave flag after the slave has been opened. If the slave comes up quickly enough, it will go through the IPv6 addrconf before the slave flag has been set and will get a link local IPv6 address.
Set IFF_SLAVE before dev_open() and clear it after dev_close() to ensure that addrconf knows to ignore on state change.
--- drivers/net/bonding/bond_main.c | 8 ++++++-- 1 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +6 -2
@@ -1207,7 +1207,6 @@ static int bond_master_upper_dev_link(struct net_device *bond_dev, err =netdev_master_upper_dev_link_private (slave_dev, bond_dev, slave);if (err)return err; - slave_dev->flags |=IFF_SLAVE ;rtmsg_ifinfo (RTM_NEWLINK , slave_dev,IFF_SLAVE ,GFP_KERNEL );return 0 ; }
@@ -1216,7 +1215,6 @@ static void bond_upper_dev_unlink(struct net_device *bond_dev, struct net_device *slave_dev) {netdev_upper_dev_unlink (slave_dev, bond_dev); - slave_dev->flags &= ~IFF_SLAVE ;rtmsg_ifinfo (RTM_NEWLINK , slave_dev,IFF_SLAVE ,GFP_KERNEL ); }
@@ -1465,6 +1463,9 @@ 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 ; +/* open the slave since the application closed it */ res =dev_open (slave_dev);if (res) {
@@ -1725,6 +1726,7 @@ err_close:dev_close (slave_dev); err_restore_mac: + slave_dev->flags &= ~IFF_SLAVE ;if (!bond->params.fail_over_mac ||BOND_MODE (bond) !=BOND_MODE_ACTIVEBACKUP ) {/* XXX TODO - fom follow mode needs to change master's
@@ -1906,6 +1908,8 @@ static int __bond_release_one(struct net_device *bond_dev,/* close slave before restoring its mac address */ dev_close (slave_dev); + slave_dev->flags &= ~IFF_SLAVE ; +if (bond->params.fail_over_mac !=BOND_FOM_ACTIVE ||BOND_MODE (bond) !=BOND_MODE_ACTIVEBACKUP ) {/* restore original ("permanent") mac address */
Signature · 1 line
1.7.1
Quoted 9 lines · Karl Heiss
Upstream commit
1f718f0f4f97("bonding: populate neighbour's private on enslave") undoes the fix provided by commitc2edacf80e15("bonding / ipv6: no addrconf for slaves separately from master") by effectively setting the slave flag after the slave has been opened. If the slave comes up quickly enough, it will go through the IPv6 addrconf before the slave flag has been set and will get a link local IPv6 address.Set
IFF_SLAVEbeforedev_open()and clear it afterdev_close()to ensure that addrconf knows to ignore on state change.
I think prepending "During bonding enslavement and removal
processing," (or the equivalent) makes the above sentence a bit clearer as to what's going on.
Quoted 20 lines
Fixes 1f718f0f4f97 ("bonding: populate neighbour's private on enslave")Signed-off-by Karl Heiss <[email protected]>---
drivers/net/bonding/bond_main.c| 8 ++++++--1 files changed, 6 insertions(+), 2 deletions(-)drivers/net/bonding/bond_main.c +0
-1@@ -1207,7 +1207,6 @@ static int bond_master_upper_dev_link(struct net_device *bond_dev, err =netdev_master_upper_dev_link_private (slave_dev, bond_dev, slave);if (err)return err; - slave_dev->flags |=IFF_SLAVE ;rtmsg_ifinfo (RTM_NEWLINK , slave_dev,IFF_SLAVE ,GFP_KERNEL );return 0 ; }
drivers/net/bonding/bond_main.c static void bond_upper_dev_unlink(struct net_device *bond_dev, · line 1219
Quoted 6 lines
drivers/net/bonding/bond_main.c +0
-1@@ -1216,7 +1215,6 @@ static void bond_upper_dev_unlink(struct net_device *bond_dev, struct net_device *slave_dev) {netdev_upper_dev_unlink (slave_dev, bond_dev); - slave_dev->flags &= ~IFF_SLAVE ;rtmsg_ifinfo (RTM_NEWLINK , slave_dev,IFF_SLAVE ,GFP_KERNEL ); }
Will this change cause issues for user space monitoring of theRTM_NEWLINKs, as now the message will have IFF_SLAVE in the flags for both the "link" and "unlink" cases? How would link be distinguished from unlink?
Since the unlink happens only in __bond_release_one or in the
case of a failure within bond_enslave, does clearing the flag in bond_upper_dev_unlink cause any actual issues?
-J
Quoted 30 lines
drivers/net/bonding/bond_main.c +3
-0@@ -1465,6 +1463,9 @@ 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 ; +/* open the slave since the application closed it */ res =dev_open (slave_dev);if (res) {@@ -1725,6 +1726,7 @@ err_close:dev_close (slave_dev);
err_restore_mac:drivers/net/bonding/bond_main.c +1
-0+ slave_dev->flags &= ~IFF_SLAVE ;if (!bond->params.fail_over_mac || BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { /* XXX TODO - fom follow mode needs to change master'sdrivers/net/bonding/bond_main.c +2
-0@@ -1906,6 +1908,8 @@ static int __bond_release_one(struct net_device *bond_dev,/* close slave before restoring its mac address */ dev_close (slave_dev); + slave_dev->flags &= ~IFF_SLAVE ; +if (bond->params.fail_over_mac !=BOND_FOM_ACTIVE ||BOND_MODE (bond) !=BOND_MODE_ACTIVEBACKUP ) {/* restore original ("permanent") mac address */ Signature · 1 line
1.7.1
---
-Jay Vosburgh, [email protected]
Quoted 9 lines · Jay Vosburgh
Quoted 7 lines · Karl Heiss
Upstream commit
1f718f0f4f97("bonding: populate neighbour's private on enslave") undoes the fix provided by commitc2edacf80e15("bonding / ipv6: no addrconf for slaves separately from master") by effectively setting the slave flag after the slave has been opened. If the slave comes up quickly enough, it will go through the IPv6 addrconf before the slave flag has been set and will get a link local IPv6 address.
Quoted 7 lines
Quoted 2 lines
Set
IFF_SLAVEbeforedev_open()and clear it afterdev_close()to ensure that addrconf knows to ignore on state change.I think prepending "During bonding enslavement and removal
processing," (or the equivalent) makes the above sentence a bit clearer as to what's going on.
Agreed
Quoted 32 lines
Quoted 20 lines
Fixes 1f718f0f4f97 ("bonding: populate neighbour's private on enslave")Signed-off-by Karl Heiss <[email protected]>---
drivers/net/bonding/bond_main.c| 8 ++++++--1 files changed, 6 insertions(+), 2 deletions(-)drivers/net/bonding/bond_main.c +0
-1@@ -1207,7 +1207,6 @@ static int bond_master_upper_dev_link(struct net_device *bond_dev, err =netdev_master_upper_dev_link_private (slave_dev, bond_dev, slave);if (err)return err; - slave_dev->flags |=IFF_SLAVE ;rtmsg_ifinfo (RTM_NEWLINK , slave_dev,IFF_SLAVE ,GFP_KERNEL );return 0 ; }drivers/net/bonding/bond_main.c static void bond_upper_dev_unlink(struct net_device *bond_dev, · line 1219
Quoted 6 lines
drivers/net/bonding/bond_main.c +0
-1@@ -1216,7 +1215,6 @@ static void bond_upper_dev_unlink(struct net_device *bond_dev, struct net_device *slave_dev) {netdev_upper_dev_unlink (slave_dev, bond_dev); - slave_dev->flags &= ~IFF_SLAVE ;rtmsg_ifinfo (RTM_NEWLINK , slave_dev,IFF_SLAVE ,GFP_KERNEL ); }Will this change cause issues for user space monitoring of the
RTM_NEWLINKs, as now the message will haveIFF_SLAVEin the flags for both the "link" and "unlink" cases? How would link be distinguished from unlink?
Quoted 6 lines
Since the unlink happens only in
__bond_release_oneor in the
case of a failure withinbond_enslave, does clearing the flag inbond_upper_dev_unlinkcause any actual issues?-J
Oops. You are correct that the RTM_NEWLINK would appear to be identical to the link case. I had originally done this to prevent any NETDEV_CHANGE events from causing the link local address and subsequent neighbor advertisements just as the device is unlinked. However, the bond_upper_dev_unlink() changes were a result of speculation, not actual observation.
If we feel that we are safe from any NETDEV_CHANGE events and/or the consequences during unlink, I am fine with leaving the bond_upper_dev_unlink() code as-is.
Karl
(P.S.: Sorry for the resend, Jay)
Quoted 33 lines
Quoted 28 lines
drivers/net/bonding/bond_main.c +3
-0@@ -1465,6 +1463,9 @@ 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 ; +/* open the slave since the application closed it */ res =dev_open (slave_dev);if (res) {@@ -1725,6 +1726,7 @@ err_close:dev_close (slave_dev);
err_restore_mac:drivers/net/bonding/bond_main.c +3
-1+ slave_dev->flags &= ~IFF_SLAVE ;if (!bond->params.fail_over_mac ||BOND_MODE (bond) !=BOND_MODE_ACTIVEBACKUP ) {/* XXX TODO - fom follow mode needs to change master's @@ -1906,6 +1908,8 @@ static int __bond_release_one(struct net_device *bond_dev,/* close slave before restoring its mac address */ dev_close (slave_dev); + slave_dev->flags &= ~IFF_SLAVE ; +if (bond->params.fail_over_mac !=BOND_FOM_ACTIVE ||BOND_MODE (bond) !=BOND_MODE_ACTIVEBACKUP ) {/* restore original ("permanent") mac address */ --Quoted 2 lines
1.7.1
---
-Jay Vosburgh, [email protected]
Quoted 2 lines · Karl Heiss
Quoted 1 line · Jay Vosburgh
Karl Heiss <[email protected]> wrote:
[...]
Quoted 26 lines
Quoted 13 lines
drivers/net/bonding/bond_main.c static void bond_upper_dev_unlink(struct net_device *bond_dev, · line 1219
Quoted 7 lines
drivers/net/bonding/bond_main.c +0
-1@@ -1216,7 +1215,6 @@ static void bond_upper_dev_unlink(struct net_device *bond_dev, struct net_device *slave_dev) {netdev_upper_dev_unlink (slave_dev, bond_dev); - slave_dev->flags &= ~IFF_SLAVE ;rtmsg_ifinfo (RTM_NEWLINK , slave_dev,IFF_SLAVE ,GFP_KERNEL ); }Will this change cause issues for user space monitoring of the
RTM_NEWLINKs, as now the message will haveIFF_SLAVEin the flags for both the "link" and "unlink" cases? How would link be distinguished from unlink?Quoted 6 lines
Since the unlink happens only in
__bond_release_oneor in the
case of a failure withinbond_enslave, does clearing the flag inbond_upper_dev_unlinkcause any actual issues?-JOops. You are correct that the
RTM_NEWLINKwould appear to be identical to the link case. I had originally done this to prevent anyNETDEV_CHANGEevents from causing the link local address and subsequent neighbor advertisements just as the device is unlinked. However, thebond_upper_dev_unlink()changes were a result of speculation, not actual observation.
Quoted 3 lines
If we feel that we are safe from any
NETDEV_CHANGEevents and/or the consequences during unlink, I am fine with leaving thebond_upper_dev_unlink()code as-is.
I looked briefly, and I don't see a source of NETDEV_CHANGE
notifiers between the bond_upper_dev_unlink and dev_close calls in __bond_release_one. Note that dev_set_promiscuity / allmulti do end up in __dev_notify_flags, but it excludes NETDEV_CHANGE for PROMISC and ALLMULTI, so I think that's not an issue.
-J
---
-Jay Vosburgh, [email protected]