diff options
author | Debabrata Banerjee <dbanerje@akamai.com> | 2018-05-14 14:48:10 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-05-16 12:15:11 -0400 |
commit | 1386c36b30388f46a95100924bfcae75160db715 (patch) | |
tree | db9d63a1cb1d8afe910fc0bbf24ad16dd3fdf887 | |
parent | e79c1055749e3183a2beee04a24da378623329c5 (diff) |
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: Debabrata Banerjee <dbanerje@akamai.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | Documentation/networking/bonding.txt | 4 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 12 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 7 |
3 files changed, 14 insertions, 9 deletions
diff --git a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt index c13214d073a4..86d07fbb592d 100644 --- a/Documentation/networking/bonding.txt +++ b/Documentation/networking/bonding.txt | |||
@@ -828,8 +828,8 @@ use_carrier | |||
828 | MII / ETHTOOL ioctl method to determine the link state. | 828 | MII / ETHTOOL ioctl method to determine the link state. |
829 | 829 | ||
830 | A value of 1 enables the use of netif_carrier_ok(), a value of | 830 | A value of 1 enables the use of netif_carrier_ok(), a value of |
831 | 0 will use the deprecated MII / ETHTOOL ioctls. The default | 831 | 0 will use the deprecated MII / ETHTOOL ioctls. A value of 2 |
832 | value is 1. | 832 | will check both. The default value is 1. |
833 | 833 | ||
834 | xmit_hash_policy | 834 | xmit_hash_policy |
835 | 835 | ||
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index a4cd7f6bfd4d..e4c253dc7dfb 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -132,7 +132,7 @@ MODULE_PARM_DESC(downdelay, "Delay before considering link down, " | |||
132 | "in milliseconds"); | 132 | "in milliseconds"); |
133 | module_param(use_carrier, int, 0); | 133 | module_param(use_carrier, int, 0); |
134 | MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; " | 134 | MODULE_PARM_DESC(use_carrier, "Use netif_carrier_ok (vs MII ioctls) in miimon; " |
135 | "0 for off, 1 for on (default)"); | 135 | "0 for off, 1 for on (default), 2 for carrier then legacy checks"); |
136 | module_param(mode, charp, 0); | 136 | module_param(mode, charp, 0); |
137 | MODULE_PARM_DESC(mode, "Mode of operation; 0 for balance-rr, " | 137 | MODULE_PARM_DESC(mode, "Mode of operation; 0 for balance-rr, " |
138 | "1 for active-backup, 2 for balance-xor, " | 138 | "1 for active-backup, 2 for balance-xor, " |
@@ -434,12 +434,16 @@ static int bond_check_dev_link(struct bonding *bond, | |||
434 | int (*ioctl)(struct net_device *, struct ifreq *, int); | 434 | int (*ioctl)(struct net_device *, struct ifreq *, int); |
435 | struct ifreq ifr; | 435 | struct ifreq ifr; |
436 | struct mii_ioctl_data *mii; | 436 | struct mii_ioctl_data *mii; |
437 | bool carrier = true; | ||
437 | 438 | ||
438 | if (!reporting && !netif_running(slave_dev)) | 439 | if (!reporting && !netif_running(slave_dev)) |
439 | return 0; | 440 | return 0; |
440 | 441 | ||
441 | if (bond->params.use_carrier) | 442 | if (bond->params.use_carrier) |
442 | return netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0; | 443 | carrier = netif_carrier_ok(slave_dev) ? BMSR_LSTATUS : 0; |
444 | |||
445 | if (!carrier) | ||
446 | return carrier; | ||
443 | 447 | ||
444 | /* Try to get link status using Ethtool first. */ | 448 | /* Try to get link status using Ethtool first. */ |
445 | if (slave_dev->ethtool_ops->get_link) | 449 | if (slave_dev->ethtool_ops->get_link) |
@@ -4403,8 +4407,8 @@ static int bond_check_params(struct bond_params *params) | |||
4403 | downdelay = 0; | 4407 | downdelay = 0; |
4404 | } | 4408 | } |
4405 | 4409 | ||
4406 | if ((use_carrier != 0) && (use_carrier != 1)) { | 4410 | if (use_carrier < 0 || use_carrier > 2) { |
4407 | pr_warn("Warning: use_carrier module parameter (%d), not of valid value (0/1), so it was set to 1\n", | 4411 | pr_warn("Warning: use_carrier module parameter (%d), not of valid value (0-2), so it was set to 1\n", |
4408 | use_carrier); | 4412 | use_carrier); |
4409 | use_carrier = 1; | 4413 | use_carrier = 1; |
4410 | } | 4414 | } |
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 8a945c9341d6..dba6cef05134 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -164,9 +164,10 @@ static const struct bond_opt_value bond_primary_reselect_tbl[] = { | |||
164 | }; | 164 | }; |
165 | 165 | ||
166 | static const struct bond_opt_value bond_use_carrier_tbl[] = { | 166 | static const struct bond_opt_value bond_use_carrier_tbl[] = { |
167 | { "off", 0, 0}, | 167 | { "off", 0, 0}, |
168 | { "on", 1, BOND_VALFLAG_DEFAULT}, | 168 | { "on", 1, BOND_VALFLAG_DEFAULT}, |
169 | { NULL, -1, 0} | 169 | { "both", 2, 0}, |
170 | { NULL, -1, 0} | ||
170 | }; | 171 | }; |
171 | 172 | ||
172 | static const struct bond_opt_value bond_all_slaves_active_tbl[] = { | 173 | static const struct bond_opt_value bond_all_slaves_active_tbl[] = { |