Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -4110,7 +4110,7 @@ static int bond_check_params(struct bond_params *params)
		if (!miimon) {
		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("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");
			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) {
		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("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");
			pr_warning("Forcing miimon to 100msec\n");
			miimon = 100;
			miimon = BOND_DEFAULT_MIIMON;
		}
		}
	}
	}


+9 −4
Original line number Original line Diff line number Diff line
@@ -45,10 +45,15 @@ int bond_option_mode_set(struct bonding *bond, int mode)
		return -EPERM;
		return -EPERM;
	}
	}


	if (BOND_MODE_IS_LB(mode) && bond->params.arp_interval) {
	if (BOND_NO_USES_ARP(mode) && bond->params.arp_interval) {
		pr_err("%s: %s mode is incompatible with arp monitoring.\n",
		pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n",
			bond->dev->name, bond_mode_tbl[mode].modename);
			bond->dev->name, bond_mode_tbl[mode].modename);
		return -EINVAL;
		/* 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 */
	/* don't cache arp_validate between modes */
+1 −3
Original line number Original line Diff line number Diff line
@@ -523,9 +523,7 @@ static ssize_t bonding_store_arp_interval(struct device *d,
		ret = -EINVAL;
		ret = -EINVAL;
		goto out;
		goto out;
	}
	}
	if (bond->params.mode == BOND_MODE_ALB ||
	if (BOND_NO_USES_ARP(bond->params.mode)) {
	    bond->params.mode == BOND_MODE_TLB ||
	    bond->params.mode == BOND_MODE_8023AD) {
		pr_info("%s: ARP monitoring cannot be used with ALB/TLB/802.3ad. Only MII monitoring is supported on %s.\n",
		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);
			bond->dev->name, bond->dev->name);
		ret = -EINVAL;
		ret = -EINVAL;
+7 −0
Original line number Original line Diff line number Diff line
@@ -35,6 +35,8 @@


#define BOND_MAX_ARP_TARGETS	16
#define BOND_MAX_ARP_TARGETS	16


#define BOND_DEFAULT_MIIMON	100

#define IS_UP(dev)					   \
#define IS_UP(dev)					   \
	      ((((dev)->flags & IFF_UP) == IFF_UP)	&& \
	      ((((dev)->flags & IFF_UP) == IFF_UP)	&& \
	       netif_running(dev)			&& \
	       netif_running(dev)			&& \
@@ -55,6 +57,11 @@
		 ((mode) == BOND_MODE_TLB)          ||	\
		 ((mode) == BOND_MODE_TLB)          ||	\
		 ((mode) == BOND_MODE_ALB))
		 ((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)				\
#define TX_QUEUE_OVERRIDE(mode)				\
			(((mode) == BOND_MODE_ACTIVEBACKUP) ||	\
			(((mode) == BOND_MODE_ACTIVEBACKUP) ||	\
			 ((mode) == BOND_MODE_ROUNDROBIN))
			 ((mode) == BOND_MODE_ROUNDROBIN))