bonding: permit enslaving interfaces without set_mac support
authorVeaceslav Falico <vfalico@gmail.com>
Tue, 15 Jul 2014 11:26:01 +0000 (13:26 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Jul 2014 05:54:49 +0000 (22:54 -0700)
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.

CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c

index 6d3b8db882a1066d5525861c141decef8d664fdd..d643807a8e6af81b5b20a76305c869f48cd1edd9 100644 (file)
@@ -1302,19 +1302,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;
                }
        }