diff options
author | Veaceslav Falico <vfalico@redhat.com> | 2014-01-15 20:04:29 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-01-16 20:26:47 -0500 |
commit | 3ec775b9fb950db19175ab7984a0d65fda1142b4 (patch) | |
tree | e0ed6d128eac94293e4b9171f55527d87969ce60 | |
parent | 6c80563c2fdd9b32e37e2570e5b1ba9befd591c0 (diff) |
bonding: handle slave's name change with primary_slave logic
Currently, if a slave's name change, we just pass it by. However, if the
slave is a current primary_slave, then we end up with using a slave, whose
name != params.primary, for primary_slave. And vice-versa, if we don't have
a primary_slave but have params.primary set - we will not detected a new
primary_slave.
Fix this by catching the NETDEV_CHANGENAME event and setting primary_slave
accordingly. Also, if the primary_slave was changed, issue a reselection of
the active slave, cause the priorities have changed.
Reported-by: Ding Tianhong <dingtianhong@huawei.com>
CC: Ding Tianhong <dingtianhong@huawei.com>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Acked-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bonding/bond_main.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index f2fe6cba384e..f00dd45b0308 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -2860,9 +2860,27 @@ static int bond_slave_netdev_event(unsigned long event, | |||
2860 | */ | 2860 | */ |
2861 | break; | 2861 | break; |
2862 | case NETDEV_CHANGENAME: | 2862 | case NETDEV_CHANGENAME: |
2863 | /* | 2863 | /* we don't care if we don't have primary set */ |
2864 | * TODO: handle changing the primary's name | 2864 | if (!USES_PRIMARY(bond->params.mode) || |
2865 | */ | 2865 | !bond->params.primary[0]) |
2866 | break; | ||
2867 | |||
2868 | if (slave == bond->primary_slave) { | ||
2869 | /* slave's name changed - he's no longer primary */ | ||
2870 | bond->primary_slave = NULL; | ||
2871 | } else if (!strcmp(slave_dev->name, bond->params.primary)) { | ||
2872 | /* we have a new primary slave */ | ||
2873 | bond->primary_slave = slave; | ||
2874 | } else { /* we didn't change primary - exit */ | ||
2875 | break; | ||
2876 | } | ||
2877 | |||
2878 | pr_info("%s: Primary slave changed to %s, reselecting active slave.\n", | ||
2879 | bond->dev->name, bond->primary_slave ? slave_dev->name : | ||
2880 | "none"); | ||
2881 | write_lock_bh(&bond->curr_slave_lock); | ||
2882 | bond_select_active_slave(bond); | ||
2883 | write_unlock_bh(&bond->curr_slave_lock); | ||
2866 | break; | 2884 | break; |
2867 | case NETDEV_FEAT_CHANGE: | 2885 | case NETDEV_FEAT_CHANGE: |
2868 | bond_compute_features(bond); | 2886 | bond_compute_features(bond); |