bonding: permit enslaving interfaces without set_mac support
Subsystems (3)
PATCH 1/1 bonding: permit enslaving interfaces without set_mac support
Currently we exit if the slave isn't the first slave, doesn't support mac address setting and fail_over_mac isn't FOM_ACTIVE. It's wrong because we only require ndo_set_mac_address in case bonding is in active-backup mode and FOM isn't FOM_ACTIVE.
To fix this - only exit with an error if we're in a/b mode and have fail_over_mac != FOM_ACTIVE.
Also, maintain current behaviour on the first slave (forcibly change fom to FOM_ACTIVE) to not break anyone's configuration.
--- drivers/net/bonding/bond_main.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/net/bonding/bond_main.c +10 -9
@@ -1298,19 +1298,20 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) }if (slave_ops->ndo_set_mac_address ==NULL ) { -if (!bond_has_slaves (bond)) { -pr_warn ("%s: Warning: The first slave device specified does not support setting the MAC address\n" , - bond_dev->name); -if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP ) { +pr_warn ("%s: Warning: The slave device specified does not support setting the MAC address\n" , + bond_dev->name); +if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP && + bond->params.fail_over_mac !=BOND_FOM_ACTIVE ) { +if (!bond_has_slaves (bond)) { bond->params.fail_over_mac =BOND_FOM_ACTIVE ;pr_warn ("%s: Setting fail_over_mac to active for active-backup mode\n" , bond_dev->name); + }else { +pr_err ("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n" , + bond_dev->name); + res = -EOPNOTSUPP ; + goto err_undo_flags; } - }else if (bond->params.fail_over_mac !=BOND_FOM_ACTIVE ) { -pr_err ("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n" , - bond_dev->name); - res = -EOPNOTSUPP ; - goto err_undo_flags; } }
Signature · 1 line
1.8.4
Quoted 23 lines · Veaceslav Falico
Currently we exit if the slave isn't the first slave, doesn't support mac address setting and
fail_over_macisn'tFOM_ACTIVE. It's wrong because we only requirendo_set_mac_addressin case bonding is in active-backup mode and FOM isn'tFOM_ACTIVE.To fix this - only exit with an error if we're in a/b mode and have
fail_over_mac!=FOM_ACTIVE.Also, maintain current behaviour on the first slave (forcibly change fom to
FOM_ACTIVE) to not break anyone's configuration.CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>Signed-off-by Veaceslav Falico <[email protected]>--- drivers/net/bonding/bond_main.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-)drivers/net/bonding/bond_main.c +0
-0
drivers/net/bonding/bond_main.c int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) · line 1302
Quoted 9 lines
drivers/net/bonding/bond_main.c +2
-4@@ -1298,19 +1298,20 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) }if (slave_ops->ndo_set_mac_address ==NULL ) { -if (!bond_has_slaves (bond)) { -pr_warn ("%s: Warning: The first slave device specified does not support setting the MAC address\n" , - bond_dev->name); -if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP ) { +pr_warn ("%s: Warning: The slave device specified does not support setting the MAC address\n" , + bond_dev->name);
netdev_warn() instead of pr_warn()... We are having net_device object?
drivers/net/bonding/bond_main.c int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) · line 1311
Quoted 9 lines
drivers/net/bonding/bond_main.c +6
-0+if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP && + bond->params.fail_over_mac !=BOND_FOM_ACTIVE ) { +if (!bond_has_slaves (bond)) { bond->params.fail_over_mac =BOND_FOM_ACTIVE ;pr_warn ("%s: Setting fail_over_mac to active for active-backup mode\n" , bond_dev->name); + }else { +pr_err ("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n" , + bond_dev->name);
netdev_err()...?
Quoted 11 lines
drivers/net/bonding/bond_main.c +2
-5+ res = -EOPNOTSUPP ; + goto err_undo_flags; } - }else if (bond->params.fail_over_mac !=BOND_FOM_ACTIVE ) { -pr_err ("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n" , - bond_dev->name); - res = -EOPNOTSUPP ; - goto err_undo_flags; } }
Signature · 2 lines
Regards, Varka Bhadram.
Quoted 1 line · Varka Bhadram
On 07/15/2014 04:56 PM, Veaceslav Falico wrote:
...snip...
Quoted 7 lines
drivers/net/bonding/bond_main.c int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) · line 1302
Quoted 5 lines
drivers/net/bonding/bond_main.c +2
-3-pr_warn ("%s: Warning: The first slave device specified does not support setting the MAC address\n" , - bond_dev->name); -if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP ) { +pr_warn ("%s: Warning: The slave device specified does not support setting the MAC address\n" , + bond_dev->name);
netdev_warn()instead ofpr_warn()... We are havingnet_deviceobject?
It's done in consistency with the whole function - there are pr_* everywhere there, and netdev_x here and there would only mess things up.
I'll send a follow-up patch that transforms all pr_* into netdev_*.
Thank you!
From: Veaceslav Falico <[email protected]>
Date: Tue, 15 Jul 2014 13:26:01 +0200
Quoted 8 lines
Currently we exit if the slave isn't the first slave, doesn't support mac address setting and
fail_over_macisn'tFOM_ACTIVE. It's wrong because we only requirendo_set_mac_addressin case bonding is in active-backup mode and FOM isn'tFOM_ACTIVE.To fix this - only exit with an error if we're in a/b mode and have
fail_over_mac!=FOM_ACTIVE.
Quoted 6 lines
Also, maintain current behaviour on the first slave (forcibly change fom to
FOM_ACTIVE) to not break anyone's configuration.CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>Signed-off-by Veaceslav Falico <[email protected]>
Applied, thank you.
Quoted 10 lines · Veaceslav Falico
Currently we exit if the slave isn't the first slave, doesn't support mac address setting and
fail_over_macisn'tFOM_ACTIVE. It's wrong because we only requirendo_set_mac_addressin case bonding is in active-backup mode and FOM isn'tFOM_ACTIVE.To fix this - only exit with an error if we're in a/b mode and have
fail_over_mac!=FOM_ACTIVE.Also, maintain current behaviour on the first slave (forcibly change fom to
FOM_ACTIVE) to not break anyone's configuration.
I'm just catching up on this, so I apologize for being late to
the party here, but the main point of that test was to prohibit slaves that cannot change their MAC from joining a bond whose mode requires changing the MAC (which is all of them except for active-backup).
It looks like the new code path will still fail whenbond_enslave() later on attempts to change the MAC, as long as fail_over_mac is not set. If f_o_m is set, the enslave will succeed, after bypassing the dev_set_mac_address call. That in turn would seem to allow creating a bond of any mode, setting fail_over_mac, then filling it with, e.g., ipoib devices. That bond won't function correctly in the modes other than active-backup.
Am I missing something here? -J
Quoted 44 lines
CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>Signed-off-by Veaceslav Falico <[email protected]>---
drivers/net/bonding/bond_main.c| 19 ++++++++++---------1 file changed, 10 insertions(+), 9 deletions(-)drivers/net/bonding/bond_main.c +10
-9@@ -1298,19 +1298,20 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) }if (slave_ops->ndo_set_mac_address ==NULL ) { -if (!bond_has_slaves (bond)) { -pr_warn ("%s: Warning: The first slave device specified does not support setting the MAC address\n" , - bond_dev->name); -if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP ) { +pr_warn ("%s: Warning: The slave device specified does not support setting the MAC address\n" , + bond_dev->name); +if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP && + bond->params.fail_over_mac !=BOND_FOM_ACTIVE ) { +if (!bond_has_slaves (bond)) { bond->params.fail_over_mac =BOND_FOM_ACTIVE ;pr_warn ("%s: Setting fail_over_mac to active for active-backup mode\n" , bond_dev->name); + }else { +pr_err ("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n" , + bond_dev->name); + res = -EOPNOTSUPP ; + goto err_undo_flags; } - }else if (bond->params.fail_over_mac !=BOND_FOM_ACTIVE ) { -pr_err ("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n" , - bond_dev->name); - res = -EOPNOTSUPP ; - goto err_undo_flags; } }Signature · 1 line
1.8.4
---
-Jay Vosburgh, [email protected]
Quoted 18 lines · Jay Vosburgh
Quoted 10 lines · Veaceslav Falico
Currently we exit if the slave isn't the first slave, doesn't support mac address setting and
fail_over_macisn'tFOM_ACTIVE. It's wrong because we only requirendo_set_mac_addressin case bonding is in active-backup mode and FOM isn'tFOM_ACTIVE.To fix this - only exit with an error if we're in a/b mode and have
fail_over_mac!=FOM_ACTIVE.Also, maintain current behaviour on the first slave (forcibly change fom to
FOM_ACTIVE) to not break anyone's configuration.I'm just catching up on this, so I apologize for being late to
the party here, but the main point of that test was to prohibit slaves that cannot change their MAC from joining a bond whose mode requires changing the MAC (which is all of them except for active-backup).
Quoted 7 lines
It looks like the new code path will still fail when
bond_enslave()later on attempts to change the MAC, as long asfail_over_macis not set. Iff_o_mis set, the enslave will succeed, after bypassing thedev_set_mac_addresscall. That in turn would seem to allow creating a bond of any mode, settingfail_over_mac, then filling it with, e.g., ipoib devices. That bond won't function correctly in the modes other than active-backup.
Hm, good catch, it wasn't covered in my testing I guess. I don't have the time/code at hand right now, so can't re-test it.
I'll verify it tomorrow and, if it's true (most probably), will send a follow-up.
Thank you!
Quoted 52 lines
Am I missing something here? -JQuoted 42 lines
CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>Signed-off-by Veaceslav Falico <[email protected]>---
drivers/net/bonding/bond_main.c| 19 ++++++++++---------1 file changed, 10 insertions(+), 9 deletions(-)drivers/net/bonding/bond_main.c +10
-10@@ -1298,19 +1298,20 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) }if (slave_ops->ndo_set_mac_address ==NULL ) { -if (!bond_has_slaves (bond)) { -pr_warn ("%s: Warning: The first slave device specified does not support setting the MAC address\n" , - bond_dev->name); -if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP ) { +pr_warn ("%s: Warning: The slave device specified does not support setting the MAC address\n" , + bond_dev->name); +if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP && + bond->params.fail_over_mac !=BOND_FOM_ACTIVE ) { +if (!bond_has_slaves (bond)) { bond->params.fail_over_mac =BOND_FOM_ACTIVE ;pr_warn ("%s: Setting fail_over_mac to active for active-backup mode\n" , bond_dev->name); + }else { +pr_err ("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n" , + bond_dev->name); + res = -EOPNOTSUPP ; + goto err_undo_flags; } - }else if (bond->params.fail_over_mac !=BOND_FOM_ACTIVE ) { -pr_err ("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active\n" , - bond_dev->name); - res = -EOPNOTSUPP ; - goto err_undo_flags; } } --Quoted 2 lines
1.8.4
---
-Jay Vosburgh, [email protected]