bonding: 802.3ad: make aggregator_identifier bond-private
Subsystems (3)
PATCH 1/1 bonding: 802.3ad: make aggregator_identifier bond-private
aggregator_identifier is used to assign unique aggregator identifiers to aggregators of a bond during device enslaving.
aggregator_identifier is currently a global variable that is zeroed in bond_3ad_initialize().
This sequence will lead to duplicate aggregator identifiers for eth1 and eth3:
create bond0
change bond0 mode to 802.3ad
enslave eth0 to bond0 //eth0 gets agg id 1
enslave eth1 to bond0 //eth1 gets agg id 2
create bond1
change bond1 mode to 802.3ad
enslave eth2 to bond1 //aggregator_identifier is reset to 0
//eth2 gets agg id 1
enslave eth3 to bond0 //eth3 gets agg id 2
Fix this by making aggregator_identifier private to the bond.
--- drivers/net/bonding/bond_3ad.c | 6 ++---- drivers/net/bonding/bond_3ad.h | 1 + 2 files changed, 3 insertions(+), 4 deletions(-)
drivers/net/bonding/bond_3ad.c +2 -4
@@ -1806,8 +1806,6 @@ void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout)BOND_AD_INFO (bond).agg_select_timer = timeout; } -static u16 aggregator_identifier; -/** * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures * @bond: bonding struct to work on
@@ -1821,7 +1819,7 @@ void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution)if (MAC_ADDRESS_COMPARE (&(BOND_AD_INFO (bond).system.sys_mac_addr), bond->dev->dev_addr)) { - aggregator_identifier =0 ; +BOND_AD_INFO (bond).aggregator_identifier =0 ;BOND_AD_INFO (bond).system.sys_priority =0xFFFF ;BOND_AD_INFO (bond).system.sys_mac_addr = *((struct mac_addr *)bond->dev->dev_addr);
@@ -1892,7 +1890,7 @@ int bond_3ad_bind_slave(struct slave *slave)ad_initialize_agg (aggregator); aggregator->aggregator_mac_address = *((struct mac_addr *)bond->dev->dev_addr); - aggregator->aggregator_identifier = (++aggregator_identifier); + aggregator->aggregator_identifier = ++BOND_AD_INFO (bond).aggregator_identifier; aggregator->slave = slave; aggregator->is_active =0 ; aggregator->num_of_ports =0 ;
drivers/net/bonding/bond_3ad.h +1 -0
@@ -253,6 +253,7 @@ struct ad_system {struct ad_bond_info {struct ad_system system;/* 802.3ad system structure */ u32 agg_select_timer;// Timer to select aggregator after all adapter's hand shakes +u16 aggregator_identifier; };struct ad_slave_info {
Signature · 2 lines
Jiri Bohac e-mail/jabber: [email protected]
Quoted 15 lines · Jiri Bohac
aggregator_identifieris used to assign unique aggregator identifiers to aggregators of a bond during device enslaving.
aggregator_identifieris currently a global variable that is zeroed inbond_3ad_initialize().This sequence will lead to duplicate aggregator identifiers for eth1 and eth3:
create bond0
change bond0 mode to 802.3ad
enslave eth0 to bond0 //eth0 gets agg id 1
enslave eth1 to bond0 //eth1 gets agg id 2
create bond1
change bond1 mode to 802.3ad
enslave eth2 to bond1 //aggregator_identifier is reset to 0
Quoted 6 lines
//eth2 gets agg id 1enslave eth3 to bond0 //eth3 gets agg id 2
Fix this by making
aggregator_identifierprivate to the bond.Signed-off-by Jiri Bohac <[email protected]>
Quoted 52 lines
---
drivers/net/bonding/bond_3ad.c| 6 ++----drivers/net/bonding/bond_3ad.h| 1 +2 files changed, 3 insertions(+), 4 deletions(-)drivers/net/bonding/bond_3ad.c +2
-4@@ -1806,8 +1806,6 @@ void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout)BOND_AD_INFO (bond).agg_select_timer = timeout; } -static u16 aggregator_identifier; -/** * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures * @bond: bonding struct to work on @@ -1821,7 +1819,7 @@ void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution)if (MAC_ADDRESS_COMPARE (&(BOND_AD_INFO (bond).system.sys_mac_addr), bond->dev->dev_addr)) { - aggregator_identifier =0 ; +BOND_AD_INFO (bond).aggregator_identifier =0 ;BOND_AD_INFO (bond).system.sys_priority =0xFFFF ;BOND_AD_INFO (bond).system.sys_mac_addr = *((struct mac_addr *)bond->dev->dev_addr);@@ -1892,7 +1890,7 @@ int bond_3ad_bind_slave(struct slave *slave)ad_initialize_agg (aggregator); aggregator->aggregator_mac_address = *((struct mac_addr *)bond->dev->dev_addr); - aggregator->aggregator_identifier = (++aggregator_identifier); + aggregator->aggregator_identifier = ++BOND_AD_INFO (bond).aggregator_identifier; aggregator->slave = slave; aggregator->is_active =0 ; aggregator->num_of_ports =0 ;drivers/net/bonding/bond_3ad.h +1
-0@@ -253,6 +253,7 @@ struct ad_system {struct ad_bond_info {struct ad_system system;/* 802.3ad system structure */ u32 agg_select_timer;// Timer to select aggregator after all adapter's hand shakes +u16 aggregator_identifier; };struct ad_slave_info {Signature · 3 lines
-- Jiri Bohac e-mail/jabber: [email protected]
Quoted 15 lines · Jiri Bohac
aggregator_identifieris used to assign unique aggregator identifiers to aggregators of a bond during device enslaving.
aggregator_identifieris currently a global variable that is zeroed inbond_3ad_initialize().This sequence will lead to duplicate aggregator identifiers for eth1 and eth3:
create bond0
change bond0 mode to 802.3ad
enslave eth0 to bond0 //eth0 gets agg id 1
enslave eth1 to bond0 //eth1 gets agg id 2
create bond1
change bond1 mode to 802.3ad
enslave eth2 to bond1 //aggregator_identifier is reset to 0
Quoted 4 lines
//eth2 gets agg id 1enslave eth3 to bond0 //eth3 gets agg id 2
Fix this by making
aggregator_identifierprivate to the bond.
I don't see how you fix the duplicate agg id with this patch because you initialize for each bond to 0, then use the same algo further on. So, what is changing?
Actually, aggregator_identifier is a global variable to make sure the counter is always increasing for new bonds. So, the fix would be to not reset it to zero, isn't it?
Thanks,
fbl
Quoted 58 lines
Signed-off-by Jiri Bohac <[email protected]>--- drivers/net/bonding/bond_3ad.c | 6 ++---- drivers/net/bonding/bond_3ad.h | 1 + 2 files changed, 3 insertions(+), 4 deletions(-)drivers/net/bonding/bond_3ad.c +2
-4@@ -1806,8 +1806,6 @@ void bond_3ad_initiate_agg_selection(struct bonding *bond, int timeout)BOND_AD_INFO (bond).agg_select_timer = timeout; } -static u16 aggregator_identifier; -/** * bond_3ad_initialize - initialize a bond's 802.3ad parameters and structures * @bond: bonding struct to work on @@ -1821,7 +1819,7 @@ void bond_3ad_initialize(struct bonding *bond, u16 tick_resolution)if (MAC_ADDRESS_COMPARE (&(BOND_AD_INFO (bond).system.sys_mac_addr), bond->dev->dev_addr)) { - aggregator_identifier =0 ; +BOND_AD_INFO (bond).aggregator_identifier =0 ;BOND_AD_INFO (bond).system.sys_priority =0xFFFF ;BOND_AD_INFO (bond).system.sys_mac_addr = *((struct mac_addr *)bond->dev->dev_addr);@@ -1892,7 +1890,7 @@ int bond_3ad_bind_slave(struct slave *slave)ad_initialize_agg (aggregator); aggregator->aggregator_mac_address = *((struct mac_addr *)bond->dev->dev_addr); - aggregator->aggregator_identifier = (++aggregator_identifier); + aggregator->aggregator_identifier = ++BOND_AD_INFO (bond).aggregator_identifier; aggregator->slave = slave; aggregator->is_active =0 ; aggregator->num_of_ports =0 ;drivers/net/bonding/bond_3ad.h +1
-0@@ -253,6 +253,7 @@ struct ad_system {struct ad_bond_info {struct ad_system system;/* 802.3ad system structure */ u32 agg_select_timer;// Timer to select aggregator after all adapter's hand shakes +u16 aggregator_identifier; };struct ad_slave_info {Signature · 7 lines
-- Jiri Bohac e-mail/jabber: [email protected] -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · Flavio Leitner
Quoted 1 line · Jiri Bohac
Fix this by making
aggregator_identifierprivate to the bond.I don't see how you fix the duplicate agg id with this patch because you initialize for each bond to 0, then use the same algo further on. So, what is changing?
My understanding is that the aggregator identifier is used internally by the bond and never appears anywhere in the LACP traffic.
So having duplicate aggregator ids between two bonds on the same machine does not matter. But it is a problem if two aggregators in the same bond share the same id.
Is my understanding wrong?
Quoted 3 lines
Actually,
aggregator_identifieris a global variable to make sure the counter is always increasing for new bonds. So, the fix would be to not reset it to zero, isn't it?
I was considering this fix, but my concern was that the variable (u16) would overflow sooner than it does now. It would take 2^16 enslavings on the machine, while with my patch you need 2^16 enslavings on a single bond.
Hypothetically, a rogue NET_ADMIN in one net namespace may cause this overflow to break a bond in another nemespace.
Maybe I'm being paranoid? ;)
Signature · 6 lines
Jiri Bohac <[email protected]> SUSE Labs, SUSE CZ -- Jiri Bohac <[email protected]> SUSE Labs, SUSE CZ
Quoted 12 lines · Jiri Bohac
Quoted 6 lines · Flavio Leitner
Quoted 1 line · Jiri Bohac
Fix this by making
aggregator_identifierprivate to the bond.I don't see how you fix the duplicate agg id with this patch because you initialize for each bond to 0, then use the same algo further on. So, what is changing?
My understanding is that the aggregator identifier is used internally by the bond and never appears anywhere in the LACP traffic.
Quoted 5 lines
So having duplicate aggregator ids between two bonds on the same machine does not matter. But it is a problem if two aggregators in the same bond share the same id.
Is my understanding wrong?
Your understanding is correct.
Quoted 9 lines
Quoted 3 lines
Actually,
aggregator_identifieris a global variable to make sure the counter is always increasing for new bonds. So, the fix would be to not reset it to zero, isn't it?I was considering this fix, but my concern was that the variable (u16) would overflow sooner than it does now. It would take 2^16 enslavings on the machine, while with my patch you need 2^16 enslavings on a single bond.
Quoted 4 lines
Hypothetically, a rogue
NET_ADMINin one net namespace may cause this overflow to break a bond in another nemespace.Maybe I'm being paranoid? ;)
Personally, for ease of reading debug messages, I would prefer
the globally unique ID (or a patch to update the pr_debugs to add the bond name). From a technical point of view either way will function correctly. I'm not too worried about the overflow of the ID.
-J
---
-Jay Vosburgh, IBM Linux Technology Center, [email protected]
Quoted 12 lines · Jiri Bohac
Quoted 6 lines · Flavio Leitner
Quoted 1 line · Jiri Bohac
Fix this by making
aggregator_identifierprivate to the bond.I don't see how you fix the duplicate agg id with this patch because you initialize for each bond to 0, then use the same algo further on. So, what is changing?
My understanding is that the aggregator identifier is used internally by the bond and never appears anywhere in the LACP traffic.
Quoted 5 lines
So having duplicate aggregator ids between two bonds on the same machine does not matter. But it is a problem if two aggregators in the same bond share the same id.
Is my understanding wrong?
No, I agree that having two agg id in the same bond is a problem while we can have the same agg id in different bonds.
Quoted 11 lines
Quoted 3 lines
Actually,
aggregator_identifieris a global variable to make sure the counter is always increasing for new bonds. So, the fix would be to not reset it to zero, isn't it?I was considering this fix, but my concern was that the variable (u16) would overflow sooner than it does now. It would take 2^16 enslavings on the machine, while with my patch you need 2^16 enslavings on a single bond.
Hypothetically, a rogue
NET_ADMINin one net namespace may cause this overflow to break a bond in another nemespace.
Well, I think it is easier to troubleshoot if you have one agg id regardless of bonding. Also, the id is visible in /proc and I recall to have seen a script using it somehow, but yeah you made a good point.
Quoted 1 line
Maybe I'm being paranoid? ;)
I will defer to bonding maintainer to decide. :P
Thanks,
fbl
David Miller
maintainerFrom: Jiri Bohac <[email protected]>
Date: Fri, 14 Feb 2014 18:13:50 +0100
Quoted 15 lines
aggregator_identifieris used to assign unique aggregator identifiers to aggregators of a bond during device enslaving.
aggregator_identifieris currently a global variable that is zeroed inbond_3ad_initialize().This sequence will lead to duplicate aggregator identifiers for eth1 and eth3:
create bond0
change bond0 mode to 802.3ad
enslave eth0 to bond0 //eth0 gets agg id 1
enslave eth1 to bond0 //eth1 gets agg id 2
create bond1
change bond1 mode to 802.3ad
enslave eth2 to bond1 //aggregator_identifier is reset to 0
Quoted 6 lines
//eth2 gets agg id 1enslave eth3 to bond0 //eth3 gets agg id 2
Fix this by making
aggregator_identifierprivate to the bond.Signed-off-by Jiri Bohac <[email protected]>
Looks good, and I think this matches what the original author of this code probably intended.
Applied and queued up for -stable, thanks.