Commit 1386c36b authored by Debabrata Banerjee's avatar Debabrata Banerjee Committed by David S. Miller

bonding: allow carrier and link status to determine link state

In a mixed environment it may be difficult to tell if your hardware
support carrier, if it does not it can always report true. With a new
use_carrier option of 2, we can check both carrier and link status
sequentially, instead of one or the other
Signed-off-by: default avatarDebabrata Banerjee <dbanerje@akamai.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e79c1055
...@@ -828,8 +828,8 @@ use_carrier ...@@ -828,8 +828,8 @@ use_carrier
MII / ETHTOOL ioctl method to determine the link state. MII / ETHTOOL ioctl method to determine the link state.
A value of 1 enables the use of netif_carrier_ok(), a value of A value of 1 enables the use of netif_carrier_ok(), a value of
0 will use the deprecated MII / ETHTOOL ioctls. The default 0 will use the deprecated MII / ETHTOOL ioctls. A value of 2
value is 1. will check both. The default value is 1.
xmit_hash_policy xmit_hash_policy
......
...@@ -132,7 +132,7 @@ MODULE_PARM_DESC(downdelay, "Delay before considering link down, " ...@@ -132,7 +132,7 @@ MODULE_PARM_DESC(downdelay, "Delay before considering link down, "
"in milliseconds"); "in milliseconds");
module_param(use_carrier, int, 0); module_param(use_carrier, int, 0);
MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; " MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; "
"0 for off, 1 for on (default)"); "0 for off, 1 for on (default), 2 for carrier then legacy checks");
module_param(mode, charp, 0); module_param(mode, charp, 0);
MODULE_PARM_DESC(mode, "Mode of operation; 0 for balance-rr, " MODULE_PARM_DESC(mode, "Mode of operation; 0 for balance-rr, "
"1 for active-backup, 2 for balance-xor, " "1 for active-backup, 2 for balance-xor, "
...@@ -434,12 +434,16 @@ static int bond_check_dev_link(struct bonding *bond, ...@@ -434,12 +434,16 @@ static int bond_check_dev_link(struct bonding *bond,
int (*ioctl)(struct net_device *, struct ifreq *, int); int (*ioctl)(struct net_device *, struct ifreq *, int);
struct ifreq ifr; struct ifreq ifr;
struct mii_ioctl_data *mii; struct mii_ioctl_data *mii;
bool carrier = true;
if (!reporting && !netif_running(slave_dev)) if (!reporting && !netif_running(slave_dev))
return 0; return 0;
if (bond->params.use_carrier) if (bond->params.use_carrier)
return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0; carrier = netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0;
if (!carrier)
return carrier;
/* Try to get link status using Ethtool first. */ /* Try to get link status using Ethtool first. */
if (slave_dev->ethtool_ops->get_link) if (slave_dev->ethtool_ops->get_link)
...@@ -4403,8 +4407,8 @@ static int bond_check_params(struct bond_params *params) ...@@ -4403,8 +4407,8 @@ static int bond_check_params(struct bond_params *params)
downdelay = 0; downdelay = 0;
} }
if ((use_carrier != 0) && (use_carrier != 1)) { if (use_carrier < 0 || use_carrier > 2) {
pr_warn("Warning: use_carrier module parameter (%d), not of valid value (0/1), so it was set to 1\n", pr_warn("Warning: use_carrier module parameter (%d), not of valid value (0-2), so it was set to 1\n",
use_carrier); use_carrier);
use_carrier = 1; use_carrier = 1;
} }
......
...@@ -164,9 +164,10 @@ static const struct bond_opt_value bond_primary_reselect_tbl[] = { ...@@ -164,9 +164,10 @@ static const struct bond_opt_value bond_primary_reselect_tbl[] = {
}; };
static const struct bond_opt_value bond_use_carrier_tbl[] = { static const struct bond_opt_value bond_use_carrier_tbl[] = {
{ "off", 0, 0}, { "off", 0, 0},
{ "on", 1, BOND_VALFLAG_DEFAULT}, { "on", 1, BOND_VALFLAG_DEFAULT},
{ NULL, -1, 0} { "both", 2, 0},
{ NULL, -1, 0}
}; };
static const struct bond_opt_value bond_all_slaves_active_tbl[] = { static const struct bond_opt_value bond_all_slaves_active_tbl[] = {
......
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