Commit fe9d04af authored by dingtianhong's avatar dingtianhong Committed by David S. Miller

bonding: disable arp and enable mii monitoring when bond change to no uses arp mode

Because the ARP monitoring is not support for 802.3ad, but I still
could change the mode to 802.3ad from ab mode while ARP monitoring
is running, it is incorrect.

So add a check for 802.3ad in bonding_store_mode to fix the problem,
and make a new macro BOND_NO_USES_ARP() to simplify the code.

v2: according to the Dan Williams's suggestion, bond mode is the most
    important bond option, it should override any of the other sub-options.
    So when the mode is changed, the conficting values should be cleared
    or reset, otherwise the user has to duplicate more operations to modify
    the logic. I disable the arp and enable mii monitoring when the bond mode
    is changed to AB, TB and 8023AD if the arp interval is true.

v3: according to the Nik's suggestion, the default value of miimon should need
    a name, there is several place to use it, and the bond_store_arp_interval()
    could use micro BOND_NO_USES_ARP to make the code more simpify.
Suggested-by: default avatarDan Williams <dcbw@redhat.com>
Suggested-by: default avatarNikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: default avatarDing Tianhong <dingtianhong@huawei.com>
Reviewed-by: default avatarNikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 31e20bad
......@@ -4110,7 +4110,7 @@ static int bond_check_params(struct bond_params *params)
if (!miimon) {
pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed and duplex which are essential for 802.3ad operation\n");
pr_warning("Forcing miimon to 100msec\n");
miimon = 100;
miimon = BOND_DEFAULT_MIIMON;
}
}
......@@ -4147,7 +4147,7 @@ static int bond_check_params(struct bond_params *params)
if (!miimon) {
pr_warning("Warning: miimon must be specified, otherwise bonding will not detect link failure and link speed which are essential for TLB/ALB load balancing\n");
pr_warning("Forcing miimon to 100msec\n");
miimon = 100;
miimon = BOND_DEFAULT_MIIMON;
}
}
......
......@@ -45,10 +45,15 @@ int bond_option_mode_set(struct bonding *bond, int mode)
return -EPERM;
}
if (BOND_MODE_IS_LB(mode) && bond->params.arp_interval) {
pr_err("%s: %s mode is incompatible with arp monitoring.\n",
bond->dev->name, bond_mode_tbl[mode].modename);
return -EINVAL;
if (BOND_NO_USES_ARP(mode) && bond->params.arp_interval) {
pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n",
bond->dev->name, bond_mode_tbl[mode].modename);
/* disable arp monitoring */
bond->params.arp_interval = 0;
/* set miimon to default value */
bond->params.miimon = BOND_DEFAULT_MIIMON;
pr_info("%s: Setting MII monitoring interval to %d.\n",
bond->dev->name, bond->params.miimon);
}
/* don't cache arp_validate between modes */
......
......@@ -523,9 +523,7 @@ static ssize_t bonding_store_arp_interval(struct device *d,
ret = -EINVAL;
goto out;
}
if (bond->params.mode == BOND_MODE_ALB ||
bond->params.mode == BOND_MODE_TLB ||
bond->params.mode == BOND_MODE_8023AD) {
if (BOND_NO_USES_ARP(bond->params.mode)) {
pr_info("%s: ARP monitoring cannot be used with ALB/TLB/802.3ad. Only MII monitoring is supported on %s.\n",
bond->dev->name, bond->dev->name);
ret = -EINVAL;
......
......@@ -35,6 +35,8 @@
#define BOND_MAX_ARP_TARGETS 16
#define BOND_DEFAULT_MIIMON 100
#define IS_UP(dev) \
((((dev)->flags & IFF_UP) == IFF_UP) && \
netif_running(dev) && \
......@@ -55,6 +57,11 @@
((mode) == BOND_MODE_TLB) || \
((mode) == BOND_MODE_ALB))
#define BOND_NO_USES_ARP(mode) \
(((mode) == BOND_MODE_8023AD) || \
((mode) == BOND_MODE_TLB) || \
((mode) == BOND_MODE_ALB))
#define TX_QUEUE_OVERRIDE(mode) \
(((mode) == BOND_MODE_ACTIVEBACKUP) || \
((mode) == BOND_MODE_ROUNDROBIN))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment