Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bonding: fix disabling of arp_interval and miimon

Currently if either arp_interval or miimon is disabled, they both get
disabled, and upon disabling they get executed once more which is not
the proper behaviour. Also when doing a no-op and disabling an already
disabled one, the other again gets disabled.
Also fix the error messages with the proper valid ranges, and a small
typo fix in the up delay error message (outputting "down delay", instead
of "up delay").

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

nikolay@redhat.com and committed by
David S. Miller
1bc7db16 1c4a154e

+48 -44
+48 -44
drivers/net/bonding/bond_sysfs.c
··· 527 527 goto out; 528 528 } 529 529 if (new_value < 0) { 530 - pr_err("%s: Invalid arp_interval value %d not in range 1-%d; rejected.\n", 530 + pr_err("%s: Invalid arp_interval value %d not in range 0-%d; rejected.\n", 531 531 bond->dev->name, new_value, INT_MAX); 532 532 ret = -EINVAL; 533 533 goto out; ··· 542 542 pr_info("%s: Setting ARP monitoring interval to %d.\n", 543 543 bond->dev->name, new_value); 544 544 bond->params.arp_interval = new_value; 545 - if (bond->params.miimon) { 546 - pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", 547 - bond->dev->name, bond->dev->name); 548 - bond->params.miimon = 0; 549 - } 550 - if (!bond->params.arp_targets[0]) { 551 - pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n", 552 - bond->dev->name); 545 + if (new_value) { 546 + if (bond->params.miimon) { 547 + pr_info("%s: ARP monitoring cannot be used with MII monitoring. %s Disabling MII monitoring.\n", 548 + bond->dev->name, bond->dev->name); 549 + bond->params.miimon = 0; 550 + } 551 + if (!bond->params.arp_targets[0]) 552 + pr_info("%s: ARP monitoring has been set up, but no ARP targets have been specified.\n", 553 + bond->dev->name); 553 554 } 554 555 if (bond->dev->flags & IFF_UP) { 555 556 /* If the interface is up, we may need to fire off ··· 558 557 * timer will get fired off when the open function 559 558 * is called. 560 559 */ 561 - cancel_delayed_work_sync(&bond->mii_work); 562 - queue_delayed_work(bond->wq, &bond->arp_work, 0); 560 + if (!new_value) { 561 + cancel_delayed_work_sync(&bond->arp_work); 562 + } else { 563 + cancel_delayed_work_sync(&bond->mii_work); 564 + queue_delayed_work(bond->wq, &bond->arp_work, 0); 565 + } 563 566 } 564 - 565 567 out: 566 568 rtnl_unlock(); 567 569 return ret; ··· 706 702 } 707 703 if (new_value < 0) { 708 704 pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n", 709 - bond->dev->name, new_value, 1, INT_MAX); 705 + bond->dev->name, new_value, 0, INT_MAX); 710 706 ret = -EINVAL; 711 707 goto out; 712 708 } else { ··· 761 757 goto out; 762 758 } 763 759 if (new_value < 0) { 764 - pr_err("%s: Invalid down delay value %d not in range %d-%d; rejected.\n", 765 - bond->dev->name, new_value, 1, INT_MAX); 760 + pr_err("%s: Invalid up delay value %d not in range %d-%d; rejected.\n", 761 + bond->dev->name, new_value, 0, INT_MAX); 766 762 ret = -EINVAL; 767 763 goto out; 768 764 } else { ··· 972 968 } 973 969 if (new_value < 0) { 974 970 pr_err("%s: Invalid miimon value %d not in range %d-%d; rejected.\n", 975 - bond->dev->name, new_value, 1, INT_MAX); 971 + bond->dev->name, new_value, 0, INT_MAX); 976 972 ret = -EINVAL; 977 973 goto out; 978 - } else { 979 - pr_info("%s: Setting MII monitoring interval to %d.\n", 980 - bond->dev->name, new_value); 981 - bond->params.miimon = new_value; 982 - if (bond->params.updelay) 983 - pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n", 984 - bond->dev->name, 985 - bond->params.updelay * bond->params.miimon); 986 - if (bond->params.downdelay) 987 - pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n", 988 - bond->dev->name, 989 - bond->params.downdelay * bond->params.miimon); 990 - if (bond->params.arp_interval) { 991 - pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n", 992 - bond->dev->name); 993 - bond->params.arp_interval = 0; 994 - if (bond->params.arp_validate) { 995 - bond->params.arp_validate = 996 - BOND_ARP_VALIDATE_NONE; 997 - } 998 - } 999 - 1000 - if (bond->dev->flags & IFF_UP) { 1001 - /* If the interface is up, we may need to fire off 1002 - * the MII timer. If the interface is down, the 1003 - * timer will get fired off when the open function 1004 - * is called. 1005 - */ 974 + } 975 + pr_info("%s: Setting MII monitoring interval to %d.\n", 976 + bond->dev->name, new_value); 977 + bond->params.miimon = new_value; 978 + if (bond->params.updelay) 979 + pr_info("%s: Note: Updating updelay (to %d) since it is a multiple of the miimon value.\n", 980 + bond->dev->name, 981 + bond->params.updelay * bond->params.miimon); 982 + if (bond->params.downdelay) 983 + pr_info("%s: Note: Updating downdelay (to %d) since it is a multiple of the miimon value.\n", 984 + bond->dev->name, 985 + bond->params.downdelay * bond->params.miimon); 986 + if (new_value && bond->params.arp_interval) { 987 + pr_info("%s: MII monitoring cannot be used with ARP monitoring. Disabling ARP monitoring...\n", 988 + bond->dev->name); 989 + bond->params.arp_interval = 0; 990 + if (bond->params.arp_validate) 991 + bond->params.arp_validate = BOND_ARP_VALIDATE_NONE; 992 + } 993 + if (bond->dev->flags & IFF_UP) { 994 + /* If the interface is up, we may need to fire off 995 + * the MII timer. If the interface is down, the 996 + * timer will get fired off when the open function 997 + * is called. 998 + */ 999 + if (!new_value) { 1000 + cancel_delayed_work_sync(&bond->mii_work); 1001 + } else { 1006 1002 cancel_delayed_work_sync(&bond->arp_work); 1007 1003 queue_delayed_work(bond->wq, &bond->mii_work, 0); 1008 1004 }