Commit ad246c992bea6d33c6421ba1f03e2b405792adf9

Authored by Ben Hutchings
Committed by David S. Miller
1 parent 7d36a991e8

ipv4, ipv6, bonding: Restore control over number of peer notifications

For backward compatibility, we should retain the module parameters and
sysfs attributes to control the number of peer notifications
(gratuitous ARPs and unsolicited NAs) sent after bonding failover.
Also, it is possible for failover to take place even though the new
active slave does not have link up, and in that case the peer
notification should be deferred until it does.

Change ipv4 and ipv6 so they do not automatically send peer
notifications on bonding failover.

Change the bonding driver to send separate NETDEV_NOTIFY_PEERS
notifications when the link is up, as many times as requested.  Since
it does not directly control which protocols send notifications, make
num_grat_arp and num_unsol_na aliases for a single parameter.  Bump
the bonding version number and update its documentation.

Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Acked-by: Brian Haley <brian.haley@hp.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 6 changed files with 105 additions and 22 deletions Side-by-side Diff

Documentation/networking/bonding.txt
1 1  
2 2 Linux Ethernet Bonding Driver HOWTO
3 3  
4   - Latest update: 23 September 2009
  4 + Latest update: 27 April 2011
5 5  
6 6 Initial release : Thomas Davis <tadavis at lbl.gov>
7 7 Corrections, HA extensions : 2000/10/03-15 :
8 8  
9 9  
... ... @@ -585,25 +585,23 @@
585 585 chosen.
586 586  
587 587 num_grat_arp
588   -
589   - Specifies the number of gratuitous ARPs to be issued after a
590   - failover event. One gratuitous ARP is issued immediately after
591   - the failover, subsequent ARPs are sent at a rate of one per link
592   - monitor interval (arp_interval or miimon, whichever is active).
593   -
594   - The valid range is 0 - 255; the default value is 1. This option
595   - affects only the active-backup mode. This option was added for
596   - bonding version 3.3.0.
597   -
598 588 num_unsol_na
599 589  
600   - Specifies the number of unsolicited IPv6 Neighbor Advertisements
601   - to be issued after a failover event. One unsolicited NA is issued
602   - immediately after the failover.
  590 + Specify the number of peer notifications (gratuitous ARPs and
  591 + unsolicited IPv6 Neighbor Advertisements) to be issued after a
  592 + failover event. As soon as the link is up on the new slave
  593 + (possibly immediately) a peer notification is sent on the
  594 + bonding device and each VLAN sub-device. This is repeated at
  595 + each link monitor interval (arp_interval or miimon, whichever
  596 + is active) if the number is greater than 1.
603 597  
604   - The valid range is 0 - 255; the default value is 1. This option
605   - affects only the active-backup mode. This option was added for
606   - bonding version 3.4.0.
  598 + The valid range is 0 - 255; the default value is 1. These options
  599 + affect only the active-backup mode. These options were added for
  600 + bonding versions 3.3.0 and 3.4.0 respectively.
  601 +
  602 + From Linux 2.6.40 and bonding version 3.7.1, these notifications
  603 + are generated by the ipv4 and ipv6 code and the numbers of
  604 + repetitions cannot be set independently.
607 605  
608 606 primary
609 607  
drivers/net/bonding/bond_main.c
... ... @@ -89,6 +89,7 @@
89 89  
90 90 static int max_bonds = BOND_DEFAULT_MAX_BONDS;
91 91 static int tx_queues = BOND_DEFAULT_TX_QUEUES;
  92 +static int num_peer_notif = 1;
92 93 static int miimon = BOND_LINK_MON_INTERV;
93 94 static int updelay;
94 95 static int downdelay;
... ... @@ -111,6 +112,10 @@
111 112 MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
112 113 module_param(tx_queues, int, 0);
113 114 MODULE_PARM_DESC(tx_queues, "Max number of transmit queues (default = 16)");
  115 +module_param_named(num_grat_arp, num_peer_notif, int, 0644);
  116 +MODULE_PARM_DESC(num_grat_arp, "Number of peer notifications to send on failover event (alias of num_unsol_na)");
  117 +module_param_named(num_unsol_na, num_peer_notif, int, 0644);
  118 +MODULE_PARM_DESC(num_unsol_na, "Number of peer notifications to send on failover event (alias of num_grat_arp)");
114 119 module_param(miimon, int, 0);
115 120 MODULE_PARM_DESC(miimon, "Link check interval in milliseconds");
116 121 module_param(updelay, int, 0);
... ... @@ -1082,6 +1087,21 @@
1082 1087 return bestslave;
1083 1088 }
1084 1089  
  1090 +static bool bond_should_notify_peers(struct bonding *bond)
  1091 +{
  1092 + struct slave *slave = bond->curr_active_slave;
  1093 +
  1094 + pr_debug("bond_should_notify_peers: bond %s slave %s\n",
  1095 + bond->dev->name, slave ? slave->dev->name : "NULL");
  1096 +
  1097 + if (!slave || !bond->send_peer_notif ||
  1098 + test_bit(__LINK_STATE_LINKWATCH_PENDING, &slave->dev->state))
  1099 + return false;
  1100 +
  1101 + bond->send_peer_notif--;
  1102 + return true;
  1103 +}
  1104 +
1085 1105 /**
1086 1106 * change_active_interface - change the active slave into the specified one
1087 1107 * @bond: our bonding struct
1088 1108  
1089 1109  
... ... @@ -1149,16 +1169,28 @@
1149 1169 bond_set_slave_inactive_flags(old_active);
1150 1170  
1151 1171 if (new_active) {
  1172 + bool should_notify_peers = false;
  1173 +
1152 1174 bond_set_slave_active_flags(new_active);
1153 1175  
1154 1176 if (bond->params.fail_over_mac)
1155 1177 bond_do_fail_over_mac(bond, new_active,
1156 1178 old_active);
1157 1179  
  1180 + if (netif_running(bond->dev)) {
  1181 + bond->send_peer_notif =
  1182 + bond->params.num_peer_notif;
  1183 + should_notify_peers =
  1184 + bond_should_notify_peers(bond);
  1185 + }
  1186 +
1158 1187 write_unlock_bh(&bond->curr_slave_lock);
1159 1188 read_unlock(&bond->lock);
1160 1189  
1161 1190 netdev_bonding_change(bond->dev, NETDEV_BONDING_FAILOVER);
  1191 + if (should_notify_peers)
  1192 + netdev_bonding_change(bond->dev,
  1193 + NETDEV_NOTIFY_PEERS);
1162 1194  
1163 1195 read_lock(&bond->lock);
1164 1196 write_lock_bh(&bond->curr_slave_lock);
... ... @@ -2556,6 +2588,7 @@
2556 2588 {
2557 2589 struct bonding *bond = container_of(work, struct bonding,
2558 2590 mii_work.work);
  2591 + bool should_notify_peers = false;
2559 2592  
2560 2593 read_lock(&bond->lock);
2561 2594 if (bond->kill_timers)
... ... @@ -2564,6 +2597,8 @@
2564 2597 if (bond->slave_cnt == 0)
2565 2598 goto re_arm;
2566 2599  
  2600 + should_notify_peers = bond_should_notify_peers(bond);
  2601 +
2567 2602 if (bond_miimon_inspect(bond)) {
2568 2603 read_unlock(&bond->lock);
2569 2604 rtnl_lock();
... ... @@ -2582,6 +2617,12 @@
2582 2617 msecs_to_jiffies(bond->params.miimon));
2583 2618 out:
2584 2619 read_unlock(&bond->lock);
  2620 +
  2621 + if (should_notify_peers) {
  2622 + rtnl_lock();
  2623 + netdev_bonding_change(bond->dev, NETDEV_NOTIFY_PEERS);
  2624 + rtnl_unlock();
  2625 + }
2585 2626 }
2586 2627  
2587 2628 static __be32 bond_glean_dev_ip(struct net_device *dev)
... ... @@ -3154,6 +3195,7 @@
3154 3195 {
3155 3196 struct bonding *bond = container_of(work, struct bonding,
3156 3197 arp_work.work);
  3198 + bool should_notify_peers = false;
3157 3199 int delta_in_ticks;
3158 3200  
3159 3201 read_lock(&bond->lock);
... ... @@ -3166,6 +3208,8 @@
3166 3208 if (bond->slave_cnt == 0)
3167 3209 goto re_arm;
3168 3210  
  3211 + should_notify_peers = bond_should_notify_peers(bond);
  3212 +
3169 3213 if (bond_ab_arp_inspect(bond, delta_in_ticks)) {
3170 3214 read_unlock(&bond->lock);
3171 3215 rtnl_lock();
... ... @@ -3185,6 +3229,12 @@
3185 3229 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks);
3186 3230 out:
3187 3231 read_unlock(&bond->lock);
  3232 +
  3233 + if (should_notify_peers) {
  3234 + rtnl_lock();
  3235 + netdev_bonding_change(bond->dev, NETDEV_NOTIFY_PEERS);
  3236 + rtnl_unlock();
  3237 + }
3188 3238 }
3189 3239  
3190 3240 /*-------------------------- netdev event handling --------------------------*/
... ... @@ -3494,6 +3544,8 @@
3494 3544  
3495 3545 write_lock_bh(&bond->lock);
3496 3546  
  3547 + bond->send_peer_notif = 0;
  3548 +
3497 3549 /* signal timers not to re-arm */
3498 3550 bond->kill_timers = 1;
3499 3551  
... ... @@ -4571,6 +4623,12 @@
4571 4623 use_carrier = 1;
4572 4624 }
4573 4625  
  4626 + if (num_peer_notif < 0 || num_peer_notif > 255) {
  4627 + pr_warning("Warning: num_grat_arp/num_unsol_na (%d) not in range 0-255 so it was reset to 1\n",
  4628 + num_peer_notif);
  4629 + num_peer_notif = 1;
  4630 + }
  4631 +
4574 4632 /* reset values for 802.3ad */
4575 4633 if (bond_mode == BOND_MODE_8023AD) {
4576 4634 if (!miimon) {
... ... @@ -4760,6 +4818,7 @@
4760 4818 params->mode = bond_mode;
4761 4819 params->xmit_policy = xmit_hashtype;
4762 4820 params->miimon = miimon;
  4821 + params->num_peer_notif = num_peer_notif;
4763 4822 params->arp_interval = arp_interval;
4764 4823 params->arp_validate = arp_validate_value;
4765 4824 params->updelay = updelay;
drivers/net/bonding/bond_sysfs.c
... ... @@ -869,6 +869,30 @@
869 869 bonding_show_ad_select, bonding_store_ad_select);
870 870  
871 871 /*
  872 + * Show and set the number of peer notifications to send after a failover event.
  873 + */
  874 +static ssize_t bonding_show_num_peer_notif(struct device *d,
  875 + struct device_attribute *attr,
  876 + char *buf)
  877 +{
  878 + struct bonding *bond = to_bond(d);
  879 + return sprintf(buf, "%d\n", bond->params.num_peer_notif);
  880 +}
  881 +
  882 +static ssize_t bonding_store_num_peer_notif(struct device *d,
  883 + struct device_attribute *attr,
  884 + const char *buf, size_t count)
  885 +{
  886 + struct bonding *bond = to_bond(d);
  887 + int err = kstrtou8(buf, 10, &bond->params.num_peer_notif);
  888 + return err ? err : count;
  889 +}
  890 +static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR,
  891 + bonding_show_num_peer_notif, bonding_store_num_peer_notif);
  892 +static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR,
  893 + bonding_show_num_peer_notif, bonding_store_num_peer_notif);
  894 +
  895 +/*
872 896 * Show and set the MII monitor interval. There are two tricky bits
873 897 * here. First, if MII monitoring is activated, then we must disable
874 898 * ARP monitoring. Second, if the timer isn't running, we must
... ... @@ -1566,6 +1590,8 @@
1566 1590 &dev_attr_lacp_rate.attr,
1567 1591 &dev_attr_ad_select.attr,
1568 1592 &dev_attr_xmit_hash_policy.attr,
  1593 + &dev_attr_num_grat_arp.attr,
  1594 + &dev_attr_num_unsol_na.attr,
1569 1595 &dev_attr_miimon.attr,
1570 1596 &dev_attr_primary.attr,
1571 1597 &dev_attr_primary_reselect.attr,
drivers/net/bonding/bonding.h
... ... @@ -24,8 +24,8 @@
24 24 #include "bond_3ad.h"
25 25 #include "bond_alb.h"
26 26  
27   -#define DRV_VERSION "3.7.0"
28   -#define DRV_RELDATE "June 2, 2010"
  27 +#define DRV_VERSION "3.7.1"
  28 +#define DRV_RELDATE "April 27, 2011"
29 29 #define DRV_NAME "bonding"
30 30 #define DRV_DESCRIPTION "Ethernet Channel Bonding Driver"
31 31  
... ... @@ -149,6 +149,7 @@
149 149 int mode;
150 150 int xmit_policy;
151 151 int miimon;
  152 + u8 num_peer_notif;
152 153 int arp_interval;
153 154 int arp_validate;
154 155 int use_carrier;
... ... @@ -231,6 +232,7 @@
231 232 rwlock_t lock;
232 233 rwlock_t curr_slave_lock;
233 234 s8 kill_timers;
  235 + u8 send_peer_notif;
234 236 s8 setup_by_slave;
235 237 s8 igmp_retrans;
236 238 #ifdef CONFIG_PROC_FS
... ... @@ -1203,7 +1203,6 @@
1203 1203 break;
1204 1204 /* fall through */
1205 1205 case NETDEV_NOTIFY_PEERS:
1206   - case NETDEV_BONDING_FAILOVER:
1207 1206 /* Send gratuitous ARP to notify of link change */
1208 1207 inetdev_send_gratuitous_arp(dev, in_dev);
1209 1208 break;
... ... @@ -1747,7 +1747,6 @@
1747 1747 fib6_run_gc(~0UL, net);
1748 1748 break;
1749 1749 case NETDEV_NOTIFY_PEERS:
1750   - case NETDEV_BONDING_FAILOVER:
1751 1750 ndisc_send_unsol_na(dev);
1752 1751 break;
1753 1752 default: