aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_main.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-05-29 06:31:03 -0400
committerDavid S. Miller <davem@davemloft.net>2008-05-29 06:31:03 -0400
commita5b17df04c4ad8f25fc598fce37fccb4b387c94c (patch)
tree2d0084f6db86362eb067b617ff8470f255ba37e7 /drivers/net/bonding/bond_main.c
parentb79eeeb9e48457579cb742cd02e162fcd673c4a3 (diff)
parentc03571a3e22b821e5be7bda7b166c4554770f489 (diff)
Merge branch 'upstream-next-davem' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6
Diffstat (limited to 'drivers/net/bonding/bond_main.c')
-rw-r--r--drivers/net/bonding/bond_main.c706
1 files changed, 424 insertions, 282 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 50a40e433154..5b4af3cc2a44 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -88,6 +88,7 @@
88#define BOND_LINK_ARP_INTERV 0 88#define BOND_LINK_ARP_INTERV 0
89 89
90static int max_bonds = BOND_DEFAULT_MAX_BONDS; 90static int max_bonds = BOND_DEFAULT_MAX_BONDS;
91static int num_grat_arp = 1;
91static int miimon = BOND_LINK_MON_INTERV; 92static int miimon = BOND_LINK_MON_INTERV;
92static int updelay = 0; 93static int updelay = 0;
93static int downdelay = 0; 94static int downdelay = 0;
@@ -99,11 +100,13 @@ static char *xmit_hash_policy = NULL;
99static int arp_interval = BOND_LINK_ARP_INTERV; 100static int arp_interval = BOND_LINK_ARP_INTERV;
100static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, }; 101static char *arp_ip_target[BOND_MAX_ARP_TARGETS] = { NULL, };
101static char *arp_validate = NULL; 102static char *arp_validate = NULL;
102static int fail_over_mac = 0; 103static char *fail_over_mac = NULL;
103struct bond_params bonding_defaults; 104struct bond_params bonding_defaults;
104 105
105module_param(max_bonds, int, 0); 106module_param(max_bonds, int, 0);
106MODULE_PARM_DESC(max_bonds, "Max number of bonded devices"); 107MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
108module_param(num_grat_arp, int, 0644);
109MODULE_PARM_DESC(num_grat_arp, "Number of gratuitous ARP packets to send on failover event");
107module_param(miimon, int, 0); 110module_param(miimon, int, 0);
108MODULE_PARM_DESC(miimon, "Link check interval in milliseconds"); 111MODULE_PARM_DESC(miimon, "Link check interval in milliseconds");
109module_param(updelay, int, 0); 112module_param(updelay, int, 0);
@@ -133,8 +136,8 @@ module_param_array(arp_ip_target, charp, NULL, 0);
133MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form"); 136MODULE_PARM_DESC(arp_ip_target, "arp targets in n.n.n.n form");
134module_param(arp_validate, charp, 0); 137module_param(arp_validate, charp, 0);
135MODULE_PARM_DESC(arp_validate, "validate src/dst of ARP probes: none (default), active, backup or all"); 138MODULE_PARM_DESC(arp_validate, "validate src/dst of ARP probes: none (default), active, backup or all");
136module_param(fail_over_mac, int, 0); 139module_param(fail_over_mac, charp, 0);
137MODULE_PARM_DESC(fail_over_mac, "For active-backup, do not set all slaves to the same MAC. 0 of off (default), 1 for on."); 140MODULE_PARM_DESC(fail_over_mac, "For active-backup, do not set all slaves to the same MAC. none (default), active or follow");
138 141
139/*----------------------------- Global variables ----------------------------*/ 142/*----------------------------- Global variables ----------------------------*/
140 143
@@ -187,6 +190,13 @@ struct bond_parm_tbl arp_validate_tbl[] = {
187{ NULL, -1}, 190{ NULL, -1},
188}; 191};
189 192
193struct bond_parm_tbl fail_over_mac_tbl[] = {
194{ "none", BOND_FOM_NONE},
195{ "active", BOND_FOM_ACTIVE},
196{ "follow", BOND_FOM_FOLLOW},
197{ NULL, -1},
198};
199
190/*-------------------------- Forward declarations ---------------------------*/ 200/*-------------------------- Forward declarations ---------------------------*/
191 201
192static void bond_send_gratuitous_arp(struct bonding *bond); 202static void bond_send_gratuitous_arp(struct bonding *bond);
@@ -261,14 +271,14 @@ static int bond_add_vlan(struct bonding *bond, unsigned short vlan_id)
261 */ 271 */
262static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id) 272static int bond_del_vlan(struct bonding *bond, unsigned short vlan_id)
263{ 273{
264 struct vlan_entry *vlan, *next; 274 struct vlan_entry *vlan;
265 int res = -ENODEV; 275 int res = -ENODEV;
266 276
267 dprintk("bond: %s, vlan id %d\n", bond->dev->name, vlan_id); 277 dprintk("bond: %s, vlan id %d\n", bond->dev->name, vlan_id);
268 278
269 write_lock_bh(&bond->lock); 279 write_lock_bh(&bond->lock);
270 280
271 list_for_each_entry_safe(vlan, next, &bond->vlan_list, vlan_list) { 281 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
272 if (vlan->vlan_id == vlan_id) { 282 if (vlan->vlan_id == vlan_id) {
273 list_del(&vlan->vlan_list); 283 list_del(&vlan->vlan_list);
274 284
@@ -970,6 +980,82 @@ static void bond_mc_swap(struct bonding *bond, struct slave *new_active, struct
970 } 980 }
971} 981}
972 982
983/*
984 * bond_do_fail_over_mac
985 *
986 * Perform special MAC address swapping for fail_over_mac settings
987 *
988 * Called with RTNL, bond->lock for read, curr_slave_lock for write_bh.
989 */
990static void bond_do_fail_over_mac(struct bonding *bond,
991 struct slave *new_active,
992 struct slave *old_active)
993{
994 u8 tmp_mac[ETH_ALEN];
995 struct sockaddr saddr;
996 int rv;
997
998 switch (bond->params.fail_over_mac) {
999 case BOND_FOM_ACTIVE:
1000 if (new_active)
1001 memcpy(bond->dev->dev_addr, new_active->dev->dev_addr,
1002 new_active->dev->addr_len);
1003 break;
1004 case BOND_FOM_FOLLOW:
1005 /*
1006 * if new_active && old_active, swap them
1007 * if just old_active, do nothing (going to no active slave)
1008 * if just new_active, set new_active to bond's MAC
1009 */
1010 if (!new_active)
1011 return;
1012
1013 write_unlock_bh(&bond->curr_slave_lock);
1014 read_unlock(&bond->lock);
1015
1016 if (old_active) {
1017 memcpy(tmp_mac, new_active->dev->dev_addr, ETH_ALEN);
1018 memcpy(saddr.sa_data, old_active->dev->dev_addr,
1019 ETH_ALEN);
1020 saddr.sa_family = new_active->dev->type;
1021 } else {
1022 memcpy(saddr.sa_data, bond->dev->dev_addr, ETH_ALEN);
1023 saddr.sa_family = bond->dev->type;
1024 }
1025
1026 rv = dev_set_mac_address(new_active->dev, &saddr);
1027 if (rv) {
1028 printk(KERN_ERR DRV_NAME
1029 ": %s: Error %d setting MAC of slave %s\n",
1030 bond->dev->name, -rv, new_active->dev->name);
1031 goto out;
1032 }
1033
1034 if (!old_active)
1035 goto out;
1036
1037 memcpy(saddr.sa_data, tmp_mac, ETH_ALEN);
1038 saddr.sa_family = old_active->dev->type;
1039
1040 rv = dev_set_mac_address(old_active->dev, &saddr);
1041 if (rv)
1042 printk(KERN_ERR DRV_NAME
1043 ": %s: Error %d setting MAC of slave %s\n",
1044 bond->dev->name, -rv, new_active->dev->name);
1045out:
1046 read_lock(&bond->lock);
1047 write_lock_bh(&bond->curr_slave_lock);
1048 break;
1049 default:
1050 printk(KERN_ERR DRV_NAME
1051 ": %s: bond_do_fail_over_mac impossible: bad policy %d\n",
1052 bond->dev->name, bond->params.fail_over_mac);
1053 break;
1054 }
1055
1056}
1057
1058
973/** 1059/**
974 * find_best_interface - select the best available slave to be the active one 1060 * find_best_interface - select the best available slave to be the active one
975 * @bond: our bonding struct 1061 * @bond: our bonding struct
@@ -1037,7 +1123,8 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
1037 * because it is apparently the best available slave we have, even though its 1123 * because it is apparently the best available slave we have, even though its
1038 * updelay hasn't timed out yet. 1124 * updelay hasn't timed out yet.
1039 * 1125 *
1040 * Warning: Caller must hold curr_slave_lock for writing. 1126 * If new_active is not NULL, caller must hold bond->lock for read and
1127 * curr_slave_lock for write_bh.
1041 */ 1128 */
1042void bond_change_active_slave(struct bonding *bond, struct slave *new_active) 1129void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1043{ 1130{
@@ -1048,6 +1135,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1048 } 1135 }
1049 1136
1050 if (new_active) { 1137 if (new_active) {
1138 new_active->jiffies = jiffies;
1139
1051 if (new_active->link == BOND_LINK_BACK) { 1140 if (new_active->link == BOND_LINK_BACK) {
1052 if (USES_PRIMARY(bond->params.mode)) { 1141 if (USES_PRIMARY(bond->params.mode)) {
1053 printk(KERN_INFO DRV_NAME 1142 printk(KERN_INFO DRV_NAME
@@ -1059,7 +1148,6 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1059 1148
1060 new_active->delay = 0; 1149 new_active->delay = 0;
1061 new_active->link = BOND_LINK_UP; 1150 new_active->link = BOND_LINK_UP;
1062 new_active->jiffies = jiffies;
1063 1151
1064 if (bond->params.mode == BOND_MODE_8023AD) { 1152 if (bond->params.mode == BOND_MODE_8023AD) {
1065 bond_3ad_handle_link_change(new_active, BOND_LINK_UP); 1153 bond_3ad_handle_link_change(new_active, BOND_LINK_UP);
@@ -1103,20 +1191,21 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1103 bond_set_slave_active_flags(new_active); 1191 bond_set_slave_active_flags(new_active);
1104 } 1192 }
1105 1193
1106 /* when bonding does not set the slave MAC address, the bond MAC
1107 * address is the one of the active slave.
1108 */
1109 if (new_active && bond->params.fail_over_mac) 1194 if (new_active && bond->params.fail_over_mac)
1110 memcpy(bond->dev->dev_addr, new_active->dev->dev_addr, 1195 bond_do_fail_over_mac(bond, new_active, old_active);
1111 new_active->dev->addr_len); 1196
1197 bond->send_grat_arp = bond->params.num_grat_arp;
1112 if (bond->curr_active_slave && 1198 if (bond->curr_active_slave &&
1113 test_bit(__LINK_STATE_LINKWATCH_PENDING, 1199 test_bit(__LINK_STATE_LINKWATCH_PENDING,
1114 &bond->curr_active_slave->dev->state)) { 1200 &bond->curr_active_slave->dev->state)) {
1115 dprintk("delaying gratuitous arp on %s\n", 1201 dprintk("delaying gratuitous arp on %s\n",
1116 bond->curr_active_slave->dev->name); 1202 bond->curr_active_slave->dev->name);
1117 bond->send_grat_arp = 1; 1203 } else {
1118 } else 1204 if (bond->send_grat_arp > 0) {
1119 bond_send_gratuitous_arp(bond); 1205 bond_send_gratuitous_arp(bond);
1206 bond->send_grat_arp--;
1207 }
1208 }
1120 } 1209 }
1121} 1210}
1122 1211
@@ -1129,7 +1218,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
1129 * - The primary_slave has got its link back. 1218 * - The primary_slave has got its link back.
1130 * - A slave has got its link back and there's no old curr_active_slave. 1219 * - A slave has got its link back and there's no old curr_active_slave.
1131 * 1220 *
1132 * Warning: Caller must hold curr_slave_lock for writing. 1221 * Caller must hold bond->lock for read and curr_slave_lock for write_bh.
1133 */ 1222 */
1134void bond_select_active_slave(struct bonding *bond) 1223void bond_select_active_slave(struct bonding *bond)
1135{ 1224{
@@ -1376,14 +1465,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1376 printk(KERN_WARNING DRV_NAME 1465 printk(KERN_WARNING DRV_NAME
1377 ": %s: Warning: The first slave device " 1466 ": %s: Warning: The first slave device "
1378 "specified does not support setting the MAC " 1467 "specified does not support setting the MAC "
1379 "address. Enabling the fail_over_mac option.", 1468 "address. Setting fail_over_mac to active.",
1380 bond_dev->name); 1469 bond_dev->name);
1381 bond->params.fail_over_mac = 1; 1470 bond->params.fail_over_mac = BOND_FOM_ACTIVE;
1382 } else if (!bond->params.fail_over_mac) { 1471 } else if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) {
1383 printk(KERN_ERR DRV_NAME 1472 printk(KERN_ERR DRV_NAME
1384 ": %s: Error: The slave device specified " 1473 ": %s: Error: The slave device specified "
1385 "does not support setting the MAC address, " 1474 "does not support setting the MAC address, "
1386 "but fail_over_mac is not enabled.\n" 1475 "but fail_over_mac is not set to active.\n"
1387 , bond_dev->name); 1476 , bond_dev->name);
1388 res = -EOPNOTSUPP; 1477 res = -EOPNOTSUPP;
1389 goto err_undo_flags; 1478 goto err_undo_flags;
@@ -1490,6 +1579,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1490 1579
1491 bond_compute_features(bond); 1580 bond_compute_features(bond);
1492 1581
1582 write_unlock_bh(&bond->lock);
1583
1584 read_lock(&bond->lock);
1585
1493 new_slave->last_arp_rx = jiffies; 1586 new_slave->last_arp_rx = jiffies;
1494 1587
1495 if (bond->params.miimon && !bond->params.use_carrier) { 1588 if (bond->params.miimon && !bond->params.use_carrier) {
@@ -1566,6 +1659,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1566 } 1659 }
1567 } 1660 }
1568 1661
1662 write_lock_bh(&bond->curr_slave_lock);
1663
1569 switch (bond->params.mode) { 1664 switch (bond->params.mode) {
1570 case BOND_MODE_ACTIVEBACKUP: 1665 case BOND_MODE_ACTIVEBACKUP:
1571 bond_set_slave_inactive_flags(new_slave); 1666 bond_set_slave_inactive_flags(new_slave);
@@ -1613,9 +1708,11 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1613 break; 1708 break;
1614 } /* switch(bond_mode) */ 1709 } /* switch(bond_mode) */
1615 1710
1711 write_unlock_bh(&bond->curr_slave_lock);
1712
1616 bond_set_carrier(bond); 1713 bond_set_carrier(bond);
1617 1714
1618 write_unlock_bh(&bond->lock); 1715 read_unlock(&bond->lock);
1619 1716
1620 res = bond_create_slave_symlinks(bond_dev, slave_dev); 1717 res = bond_create_slave_symlinks(bond_dev, slave_dev);
1621 if (res) 1718 if (res)
@@ -1639,6 +1736,10 @@ err_unset_master:
1639 1736
1640err_restore_mac: 1737err_restore_mac:
1641 if (!bond->params.fail_over_mac) { 1738 if (!bond->params.fail_over_mac) {
1739 /* XXX TODO - fom follow mode needs to change master's
1740 * MAC if this slave's MAC is in use by the bond, or at
1741 * least print a warning.
1742 */
1642 memcpy(addr.sa_data, new_slave->perm_hwaddr, ETH_ALEN); 1743 memcpy(addr.sa_data, new_slave->perm_hwaddr, ETH_ALEN);
1643 addr.sa_family = slave_dev->type; 1744 addr.sa_family = slave_dev->type;
1644 dev_set_mac_address(slave_dev, &addr); 1745 dev_set_mac_address(slave_dev, &addr);
@@ -1693,20 +1794,18 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1693 return -EINVAL; 1794 return -EINVAL;
1694 } 1795 }
1695 1796
1696 mac_addr_differ = memcmp(bond_dev->dev_addr, 1797 if (!bond->params.fail_over_mac) {
1697 slave->perm_hwaddr, 1798 mac_addr_differ = memcmp(bond_dev->dev_addr, slave->perm_hwaddr,
1698 ETH_ALEN); 1799 ETH_ALEN);
1699 if (!mac_addr_differ && (bond->slave_cnt > 1)) { 1800 if (!mac_addr_differ && (bond->slave_cnt > 1))
1700 printk(KERN_WARNING DRV_NAME 1801 printk(KERN_WARNING DRV_NAME
1701 ": %s: Warning: the permanent HWaddr of %s - " 1802 ": %s: Warning: the permanent HWaddr of %s - "
1702 "%s - is still in use by %s. " 1803 "%s - is still in use by %s. "
1703 "Set the HWaddr of %s to a different address " 1804 "Set the HWaddr of %s to a different address "
1704 "to avoid conflicts.\n", 1805 "to avoid conflicts.\n",
1705 bond_dev->name, 1806 bond_dev->name, slave_dev->name,
1706 slave_dev->name, 1807 print_mac(mac, slave->perm_hwaddr),
1707 print_mac(mac, slave->perm_hwaddr), 1808 bond_dev->name, slave_dev->name);
1708 bond_dev->name,
1709 slave_dev->name);
1710 } 1809 }
1711 1810
1712 /* Inform AD package of unbinding of slave. */ 1811 /* Inform AD package of unbinding of slave. */
@@ -1833,7 +1932,7 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev)
1833 /* close slave before restoring its mac address */ 1932 /* close slave before restoring its mac address */
1834 dev_close(slave_dev); 1933 dev_close(slave_dev);
1835 1934
1836 if (!bond->params.fail_over_mac) { 1935 if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) {
1837 /* restore original ("permanent") mac address */ 1936 /* restore original ("permanent") mac address */
1838 memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN); 1937 memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
1839 addr.sa_family = slave_dev->type; 1938 addr.sa_family = slave_dev->type;
@@ -2144,7 +2243,7 @@ static int __bond_mii_monitor(struct bonding *bond, int have_locks)
2144 dprintk("sending delayed gratuitous arp on on %s\n", 2243 dprintk("sending delayed gratuitous arp on on %s\n",
2145 bond->curr_active_slave->dev->name); 2244 bond->curr_active_slave->dev->name);
2146 bond_send_gratuitous_arp(bond); 2245 bond_send_gratuitous_arp(bond);
2147 bond->send_grat_arp = 0; 2246 bond->send_grat_arp--;
2148 } 2247 }
2149 } 2248 }
2150 read_lock(&bond->curr_slave_lock); 2249 read_lock(&bond->curr_slave_lock);
@@ -2397,7 +2496,7 @@ void bond_mii_monitor(struct work_struct *work)
2397 read_lock(&bond->lock); 2496 read_lock(&bond->lock);
2398 } 2497 }
2399 2498
2400 delay = ((bond->params.miimon * HZ) / 1000) ? : 1; 2499 delay = msecs_to_jiffies(bond->params.miimon);
2401 read_unlock(&bond->lock); 2500 read_unlock(&bond->lock);
2402 queue_delayed_work(bond->wq, &bond->mii_work, delay); 2501 queue_delayed_work(bond->wq, &bond->mii_work, delay);
2403} 2502}
@@ -2426,37 +2525,14 @@ out:
2426 return addr; 2525 return addr;
2427} 2526}
2428 2527
2429static int bond_has_ip(struct bonding *bond)
2430{
2431 struct vlan_entry *vlan, *vlan_next;
2432
2433 if (bond->master_ip)
2434 return 1;
2435
2436 if (list_empty(&bond->vlan_list))
2437 return 0;
2438
2439 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list,
2440 vlan_list) {
2441 if (vlan->vlan_ip)
2442 return 1;
2443 }
2444
2445 return 0;
2446}
2447
2448static int bond_has_this_ip(struct bonding *bond, __be32 ip) 2528static int bond_has_this_ip(struct bonding *bond, __be32 ip)
2449{ 2529{
2450 struct vlan_entry *vlan, *vlan_next; 2530 struct vlan_entry *vlan;
2451 2531
2452 if (ip == bond->master_ip) 2532 if (ip == bond->master_ip)
2453 return 1; 2533 return 1;
2454 2534
2455 if (list_empty(&bond->vlan_list)) 2535 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
2456 return 0;
2457
2458 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list,
2459 vlan_list) {
2460 if (ip == vlan->vlan_ip) 2536 if (ip == vlan->vlan_ip)
2461 return 1; 2537 return 1;
2462 } 2538 }
@@ -2498,7 +2574,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2498{ 2574{
2499 int i, vlan_id, rv; 2575 int i, vlan_id, rv;
2500 __be32 *targets = bond->params.arp_targets; 2576 __be32 *targets = bond->params.arp_targets;
2501 struct vlan_entry *vlan, *vlan_next; 2577 struct vlan_entry *vlan;
2502 struct net_device *vlan_dev; 2578 struct net_device *vlan_dev;
2503 struct flowi fl; 2579 struct flowi fl;
2504 struct rtable *rt; 2580 struct rtable *rt;
@@ -2545,8 +2621,7 @@ static void bond_arp_send_all(struct bonding *bond, struct slave *slave)
2545 } 2621 }
2546 2622
2547 vlan_id = 0; 2623 vlan_id = 0;
2548 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list, 2624 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
2549 vlan_list) {
2550 vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id); 2625 vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id);
2551 if (vlan_dev == rt->u.dst.dev) { 2626 if (vlan_dev == rt->u.dst.dev) {
2552 vlan_id = vlan->vlan_id; 2627 vlan_id = vlan->vlan_id;
@@ -2707,7 +2782,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2707 2782
2708 read_lock(&bond->lock); 2783 read_lock(&bond->lock);
2709 2784
2710 delta_in_ticks = (bond->params.arp_interval * HZ) / 1000; 2785 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
2711 2786
2712 if (bond->kill_timers) { 2787 if (bond->kill_timers) {
2713 goto out; 2788 goto out;
@@ -2764,8 +2839,7 @@ void bond_loadbalance_arp_mon(struct work_struct *work)
2764 * if we don't know our ip yet 2839 * if we don't know our ip yet
2765 */ 2840 */
2766 if (time_after_eq(jiffies, slave->dev->trans_start + 2*delta_in_ticks) || 2841 if (time_after_eq(jiffies, slave->dev->trans_start + 2*delta_in_ticks) ||
2767 (time_after_eq(jiffies, slave->dev->last_rx + 2*delta_in_ticks) && 2842 (time_after_eq(jiffies, slave->dev->last_rx + 2*delta_in_ticks))) {
2768 bond_has_ip(bond))) {
2769 2843
2770 slave->link = BOND_LINK_DOWN; 2844 slave->link = BOND_LINK_DOWN;
2771 slave->state = BOND_STATE_BACKUP; 2845 slave->state = BOND_STATE_BACKUP;
@@ -2813,246 +2887,299 @@ out:
2813} 2887}
2814 2888
2815/* 2889/*
2816 * When using arp monitoring in active-backup mode, this function is 2890 * Called to inspect slaves for active-backup mode ARP monitor link state
2817 * called to determine if any backup slaves have went down or a new 2891 * changes. Sets new_link in slaves to specify what action should take
2818 * current slave needs to be found. 2892 * place for the slave. Returns 0 if no changes are found, >0 if changes
2819 * The backup slaves never generate traffic, they are considered up by merely 2893 * to link states must be committed.
2820 * receiving traffic. If the current slave goes down, each backup slave will 2894 *
2821 * be given the opportunity to tx/rx an arp before being taken down - this 2895 * Called with bond->lock held for read.
2822 * prevents all slaves from being taken down due to the current slave not
2823 * sending any traffic for the backups to receive. The arps are not necessarily
2824 * necessary, any tx and rx traffic will keep the current slave up. While any
2825 * rx traffic will keep the backup slaves up, the current slave is responsible
2826 * for generating traffic to keep them up regardless of any other traffic they
2827 * may have received.
2828 * see loadbalance_arp_monitor for arp monitoring in load balancing mode
2829 */ 2896 */
2830void bond_activebackup_arp_mon(struct work_struct *work) 2897static int bond_ab_arp_inspect(struct bonding *bond, int delta_in_ticks)
2831{ 2898{
2832 struct bonding *bond = container_of(work, struct bonding,
2833 arp_work.work);
2834 struct slave *slave; 2899 struct slave *slave;
2835 int delta_in_ticks; 2900 int i, commit = 0;
2836 int i;
2837 2901
2838 read_lock(&bond->lock); 2902 bond_for_each_slave(bond, slave, i) {
2903 slave->new_link = BOND_LINK_NOCHANGE;
2839 2904
2840 delta_in_ticks = (bond->params.arp_interval * HZ) / 1000; 2905 if (slave->link != BOND_LINK_UP) {
2906 if (time_before_eq(jiffies, slave_last_rx(bond, slave) +
2907 delta_in_ticks)) {
2908 slave->new_link = BOND_LINK_UP;
2909 commit++;
2910 }
2841 2911
2842 if (bond->kill_timers) { 2912 continue;
2843 goto out; 2913 }
2844 }
2845 2914
2846 if (bond->slave_cnt == 0) { 2915 /*
2847 goto re_arm; 2916 * Give slaves 2*delta after being enslaved or made
2917 * active. This avoids bouncing, as the last receive
2918 * times need a full ARP monitor cycle to be updated.
2919 */
2920 if (!time_after_eq(jiffies, slave->jiffies +
2921 2 * delta_in_ticks))
2922 continue;
2923
2924 /*
2925 * Backup slave is down if:
2926 * - No current_arp_slave AND
2927 * - more than 3*delta since last receive AND
2928 * - the bond has an IP address
2929 *
2930 * Note: a non-null current_arp_slave indicates
2931 * the curr_active_slave went down and we are
2932 * searching for a new one; under this condition
2933 * we only take the curr_active_slave down - this
2934 * gives each slave a chance to tx/rx traffic
2935 * before being taken out
2936 */
2937 if (slave->state == BOND_STATE_BACKUP &&
2938 !bond->current_arp_slave &&
2939 time_after(jiffies, slave_last_rx(bond, slave) +
2940 3 * delta_in_ticks)) {
2941 slave->new_link = BOND_LINK_DOWN;
2942 commit++;
2943 }
2944
2945 /*
2946 * Active slave is down if:
2947 * - more than 2*delta since transmitting OR
2948 * - (more than 2*delta since receive AND
2949 * the bond has an IP address)
2950 */
2951 if ((slave->state == BOND_STATE_ACTIVE) &&
2952 (time_after_eq(jiffies, slave->dev->trans_start +
2953 2 * delta_in_ticks) ||
2954 (time_after_eq(jiffies, slave_last_rx(bond, slave)
2955 + 2 * delta_in_ticks)))) {
2956 slave->new_link = BOND_LINK_DOWN;
2957 commit++;
2958 }
2848 } 2959 }
2849 2960
2850 /* determine if any slave has come up or any backup slave has 2961 read_lock(&bond->curr_slave_lock);
2851 * gone down 2962
2852 * TODO: what about up/down delay in arp mode? it wasn't here before 2963 /*
2853 * so it can wait 2964 * Trigger a commit if the primary option setting has changed.
2854 */ 2965 */
2855 bond_for_each_slave(bond, slave, i) { 2966 if (bond->primary_slave &&
2856 if (slave->link != BOND_LINK_UP) { 2967 (bond->primary_slave != bond->curr_active_slave) &&
2857 if (time_before_eq(jiffies, 2968 (bond->primary_slave->link == BOND_LINK_UP))
2858 slave_last_rx(bond, slave) + delta_in_ticks)) { 2969 commit++;
2859 2970
2860 slave->link = BOND_LINK_UP; 2971 read_unlock(&bond->curr_slave_lock);
2861 2972
2862 write_lock_bh(&bond->curr_slave_lock); 2973 return commit;
2974}
2863 2975
2864 if ((!bond->curr_active_slave) && 2976/*
2865 time_before_eq(jiffies, slave->dev->trans_start + delta_in_ticks)) { 2977 * Called to commit link state changes noted by inspection step of
2866 bond_change_active_slave(bond, slave); 2978 * active-backup mode ARP monitor.
2867 bond->current_arp_slave = NULL; 2979 *
2868 } else if (bond->curr_active_slave != slave) { 2980 * Called with RTNL and bond->lock for read.
2869 /* this slave has just come up but we 2981 */
2870 * already have a current slave; this 2982static void bond_ab_arp_commit(struct bonding *bond, int delta_in_ticks)
2871 * can also happen if bond_enslave adds 2983{
2872 * a new slave that is up while we are 2984 struct slave *slave;
2873 * searching for a new slave 2985 int i;
2874 */
2875 bond_set_slave_inactive_flags(slave);
2876 bond->current_arp_slave = NULL;
2877 }
2878 2986
2879 bond_set_carrier(bond); 2987 bond_for_each_slave(bond, slave, i) {
2988 switch (slave->new_link) {
2989 case BOND_LINK_NOCHANGE:
2990 continue;
2880 2991
2881 if (slave == bond->curr_active_slave) { 2992 case BOND_LINK_UP:
2882 printk(KERN_INFO DRV_NAME 2993 write_lock_bh(&bond->curr_slave_lock);
2883 ": %s: %s is up and now the "
2884 "active interface\n",
2885 bond->dev->name,
2886 slave->dev->name);
2887 netif_carrier_on(bond->dev);
2888 } else {
2889 printk(KERN_INFO DRV_NAME
2890 ": %s: backup interface %s is "
2891 "now up\n",
2892 bond->dev->name,
2893 slave->dev->name);
2894 }
2895 2994
2896 write_unlock_bh(&bond->curr_slave_lock); 2995 if (!bond->curr_active_slave &&
2897 } 2996 time_before_eq(jiffies, slave->dev->trans_start +
2898 } else { 2997 delta_in_ticks)) {
2899 read_lock(&bond->curr_slave_lock); 2998 slave->link = BOND_LINK_UP;
2999 bond_change_active_slave(bond, slave);
3000 bond->current_arp_slave = NULL;
2900 3001
2901 if ((slave != bond->curr_active_slave) && 3002 printk(KERN_INFO DRV_NAME
2902 (!bond->current_arp_slave) && 3003 ": %s: %s is up and now the "
2903 (time_after_eq(jiffies, slave_last_rx(bond, slave) + 3*delta_in_ticks) && 3004 "active interface\n",
2904 bond_has_ip(bond))) { 3005 bond->dev->name, slave->dev->name);
2905 /* a backup slave has gone down; three times 3006
2906 * the delta allows the current slave to be 3007 } else if (bond->curr_active_slave != slave) {
2907 * taken out before the backup slave. 3008 /* this slave has just come up but we
2908 * note: a non-null current_arp_slave indicates 3009 * already have a current slave; this can
2909 * the curr_active_slave went down and we are 3010 * also happen if bond_enslave adds a new
2910 * searching for a new one; under this 3011 * slave that is up while we are searching
2911 * condition we only take the curr_active_slave 3012 * for a new slave
2912 * down - this gives each slave a chance to
2913 * tx/rx traffic before being taken out
2914 */ 3013 */
3014 slave->link = BOND_LINK_UP;
3015 bond_set_slave_inactive_flags(slave);
3016 bond->current_arp_slave = NULL;
2915 3017
2916 read_unlock(&bond->curr_slave_lock); 3018 printk(KERN_INFO DRV_NAME
3019 ": %s: backup interface %s is now up\n",
3020 bond->dev->name, slave->dev->name);
3021 }
2917 3022
2918 slave->link = BOND_LINK_DOWN; 3023 write_unlock_bh(&bond->curr_slave_lock);
2919 3024
2920 if (slave->link_failure_count < UINT_MAX) { 3025 break;
2921 slave->link_failure_count++; 3026
2922 } 3027 case BOND_LINK_DOWN:
3028 if (slave->link_failure_count < UINT_MAX)
3029 slave->link_failure_count++;
3030
3031 slave->link = BOND_LINK_DOWN;
3032
3033 if (slave == bond->curr_active_slave) {
3034 printk(KERN_INFO DRV_NAME
3035 ": %s: link status down for active "
3036 "interface %s, disabling it\n",
3037 bond->dev->name, slave->dev->name);
2923 3038
2924 bond_set_slave_inactive_flags(slave); 3039 bond_set_slave_inactive_flags(slave);
2925 3040
3041 write_lock_bh(&bond->curr_slave_lock);
3042
3043 bond_select_active_slave(bond);
3044 if (bond->curr_active_slave)
3045 bond->curr_active_slave->jiffies =
3046 jiffies;
3047
3048 write_unlock_bh(&bond->curr_slave_lock);
3049
3050 bond->current_arp_slave = NULL;
3051
3052 } else if (slave->state == BOND_STATE_BACKUP) {
2926 printk(KERN_INFO DRV_NAME 3053 printk(KERN_INFO DRV_NAME
2927 ": %s: backup interface %s is now down\n", 3054 ": %s: backup interface %s is now down\n",
2928 bond->dev->name, 3055 bond->dev->name, slave->dev->name);
2929 slave->dev->name); 3056
2930 } else { 3057 bond_set_slave_inactive_flags(slave);
2931 read_unlock(&bond->curr_slave_lock);
2932 } 3058 }
3059 break;
3060
3061 default:
3062 printk(KERN_ERR DRV_NAME
3063 ": %s: impossible: new_link %d on slave %s\n",
3064 bond->dev->name, slave->new_link,
3065 slave->dev->name);
2933 } 3066 }
2934 } 3067 }
2935 3068
2936 read_lock(&bond->curr_slave_lock); 3069 /*
2937 slave = bond->curr_active_slave; 3070 * No race with changes to primary via sysfs, as we hold rtnl.
2938 read_unlock(&bond->curr_slave_lock); 3071 */
2939 3072 if (bond->primary_slave &&
2940 if (slave) { 3073 (bond->primary_slave != bond->curr_active_slave) &&
2941 /* if we have sent traffic in the past 2*arp_intervals but 3074 (bond->primary_slave->link == BOND_LINK_UP)) {
2942 * haven't xmit and rx traffic in that time interval, select 3075 write_lock_bh(&bond->curr_slave_lock);
2943 * a different slave. slave->jiffies is only updated when 3076 bond_change_active_slave(bond, bond->primary_slave);
2944 * a slave first becomes the curr_active_slave - not necessarily 3077 write_unlock_bh(&bond->curr_slave_lock);
2945 * after every arp; this ensures the slave has a full 2*delta 3078 }
2946 * before being taken out. if a primary is being used, check
2947 * if it is up and needs to take over as the curr_active_slave
2948 */
2949 if ((time_after_eq(jiffies, slave->dev->trans_start + 2*delta_in_ticks) ||
2950 (time_after_eq(jiffies, slave_last_rx(bond, slave) + 2*delta_in_ticks) &&
2951 bond_has_ip(bond))) &&
2952 time_after_eq(jiffies, slave->jiffies + 2*delta_in_ticks)) {
2953 3079
2954 slave->link = BOND_LINK_DOWN; 3080 bond_set_carrier(bond);
3081}
2955 3082
2956 if (slave->link_failure_count < UINT_MAX) { 3083/*
2957 slave->link_failure_count++; 3084 * Send ARP probes for active-backup mode ARP monitor.
2958 } 3085 *
3086 * Called with bond->lock held for read.
3087 */
3088static void bond_ab_arp_probe(struct bonding *bond)
3089{
3090 struct slave *slave;
3091 int i;
2959 3092
2960 printk(KERN_INFO DRV_NAME 3093 read_lock(&bond->curr_slave_lock);
2961 ": %s: link status down for active interface "
2962 "%s, disabling it\n",
2963 bond->dev->name,
2964 slave->dev->name);
2965 3094
2966 write_lock_bh(&bond->curr_slave_lock); 3095 if (bond->current_arp_slave && bond->curr_active_slave)
3096 printk("PROBE: c_arp %s && cas %s BAD\n",
3097 bond->current_arp_slave->dev->name,
3098 bond->curr_active_slave->dev->name);
2967 3099
2968 bond_select_active_slave(bond); 3100 if (bond->curr_active_slave) {
2969 slave = bond->curr_active_slave; 3101 bond_arp_send_all(bond, bond->curr_active_slave);
3102 read_unlock(&bond->curr_slave_lock);
3103 return;
3104 }
2970 3105
2971 write_unlock_bh(&bond->curr_slave_lock); 3106 read_unlock(&bond->curr_slave_lock);
2972 3107
2973 bond->current_arp_slave = slave; 3108 /* if we don't have a curr_active_slave, search for the next available
3109 * backup slave from the current_arp_slave and make it the candidate
3110 * for becoming the curr_active_slave
3111 */
2974 3112
2975 if (slave) { 3113 if (!bond->current_arp_slave) {
2976 slave->jiffies = jiffies; 3114 bond->current_arp_slave = bond->first_slave;
2977 } 3115 if (!bond->current_arp_slave)
2978 } else if ((bond->primary_slave) && 3116 return;
2979 (bond->primary_slave != slave) && 3117 }
2980 (bond->primary_slave->link == BOND_LINK_UP)) {
2981 /* at this point, slave is the curr_active_slave */
2982 printk(KERN_INFO DRV_NAME
2983 ": %s: changing from interface %s to primary "
2984 "interface %s\n",
2985 bond->dev->name,
2986 slave->dev->name,
2987 bond->primary_slave->dev->name);
2988 3118
2989 /* primary is up so switch to it */ 3119 bond_set_slave_inactive_flags(bond->current_arp_slave);
2990 write_lock_bh(&bond->curr_slave_lock);
2991 bond_change_active_slave(bond, bond->primary_slave);
2992 write_unlock_bh(&bond->curr_slave_lock);
2993 3120
2994 slave = bond->primary_slave; 3121 /* search for next candidate */
3122 bond_for_each_slave_from(bond, slave, i, bond->current_arp_slave->next) {
3123 if (IS_UP(slave->dev)) {
3124 slave->link = BOND_LINK_BACK;
3125 bond_set_slave_active_flags(slave);
3126 bond_arp_send_all(bond, slave);
2995 slave->jiffies = jiffies; 3127 slave->jiffies = jiffies;
2996 } else { 3128 bond->current_arp_slave = slave;
2997 bond->current_arp_slave = NULL; 3129 break;
2998 } 3130 }
2999 3131
3000 /* the current slave must tx an arp to ensure backup slaves 3132 /* if the link state is up at this point, we
3001 * rx traffic 3133 * mark it down - this can happen if we have
3134 * simultaneous link failures and
3135 * reselect_active_interface doesn't make this
3136 * one the current slave so it is still marked
3137 * up when it is actually down
3002 */ 3138 */
3003 if (slave && bond_has_ip(bond)) { 3139 if (slave->link == BOND_LINK_UP) {
3004 bond_arp_send_all(bond, slave); 3140 slave->link = BOND_LINK_DOWN;
3141 if (slave->link_failure_count < UINT_MAX)
3142 slave->link_failure_count++;
3143
3144 bond_set_slave_inactive_flags(slave);
3145
3146 printk(KERN_INFO DRV_NAME
3147 ": %s: backup interface %s is now down.\n",
3148 bond->dev->name, slave->dev->name);
3005 } 3149 }
3006 } 3150 }
3151}
3007 3152
3008 /* if we don't have a curr_active_slave, search for the next available 3153void bond_activebackup_arp_mon(struct work_struct *work)
3009 * backup slave from the current_arp_slave and make it the candidate 3154{
3010 * for becoming the curr_active_slave 3155 struct bonding *bond = container_of(work, struct bonding,
3011 */ 3156 arp_work.work);
3012 if (!slave) { 3157 int delta_in_ticks;
3013 if (!bond->current_arp_slave) {
3014 bond->current_arp_slave = bond->first_slave;
3015 }
3016 3158
3017 if (bond->current_arp_slave) { 3159 read_lock(&bond->lock);
3018 bond_set_slave_inactive_flags(bond->current_arp_slave);
3019 3160
3020 /* search for next candidate */ 3161 if (bond->kill_timers)
3021 bond_for_each_slave_from(bond, slave, i, bond->current_arp_slave->next) { 3162 goto out;
3022 if (IS_UP(slave->dev)) {
3023 slave->link = BOND_LINK_BACK;
3024 bond_set_slave_active_flags(slave);
3025 bond_arp_send_all(bond, slave);
3026 slave->jiffies = jiffies;
3027 bond->current_arp_slave = slave;
3028 break;
3029 }
3030 3163
3031 /* if the link state is up at this point, we 3164 delta_in_ticks = msecs_to_jiffies(bond->params.arp_interval);
3032 * mark it down - this can happen if we have
3033 * simultaneous link failures and
3034 * reselect_active_interface doesn't make this
3035 * one the current slave so it is still marked
3036 * up when it is actually down
3037 */
3038 if (slave->link == BOND_LINK_UP) {
3039 slave->link = BOND_LINK_DOWN;
3040 if (slave->link_failure_count < UINT_MAX) {
3041 slave->link_failure_count++;
3042 }
3043 3165
3044 bond_set_slave_inactive_flags(slave); 3166 if (bond->slave_cnt == 0)
3167 goto re_arm;
3045 3168
3046 printk(KERN_INFO DRV_NAME 3169 if (bond_ab_arp_inspect(bond, delta_in_ticks)) {
3047 ": %s: backup interface %s is " 3170 read_unlock(&bond->lock);
3048 "now down.\n", 3171 rtnl_lock();
3049 bond->dev->name, 3172 read_lock(&bond->lock);
3050 slave->dev->name); 3173
3051 } 3174 bond_ab_arp_commit(bond, delta_in_ticks);
3052 } 3175
3053 } 3176 read_unlock(&bond->lock);
3177 rtnl_unlock();
3178 read_lock(&bond->lock);
3054 } 3179 }
3055 3180
3181 bond_ab_arp_probe(bond);
3182
3056re_arm: 3183re_arm:
3057 if (bond->params.arp_interval) { 3184 if (bond->params.arp_interval) {
3058 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks); 3185 queue_delayed_work(bond->wq, &bond->arp_work, delta_in_ticks);
@@ -3128,7 +3255,8 @@ static void bond_info_show_master(struct seq_file *seq)
3128 3255
3129 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP && 3256 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP &&
3130 bond->params.fail_over_mac) 3257 bond->params.fail_over_mac)
3131 seq_printf(seq, " (fail_over_mac)"); 3258 seq_printf(seq, " (fail_over_mac %s)",
3259 fail_over_mac_tbl[bond->params.fail_over_mac].modename);
3132 3260
3133 seq_printf(seq, "\n"); 3261 seq_printf(seq, "\n");
3134 3262
@@ -3500,13 +3628,13 @@ static int bond_inetaddr_event(struct notifier_block *this, unsigned long event,
3500{ 3628{
3501 struct in_ifaddr *ifa = ptr; 3629 struct in_ifaddr *ifa = ptr;
3502 struct net_device *vlan_dev, *event_dev = ifa->ifa_dev->dev; 3630 struct net_device *vlan_dev, *event_dev = ifa->ifa_dev->dev;
3503 struct bonding *bond, *bond_next; 3631 struct bonding *bond;
3504 struct vlan_entry *vlan, *vlan_next; 3632 struct vlan_entry *vlan;
3505 3633
3506 if (dev_net(ifa->ifa_dev->dev) != &init_net) 3634 if (dev_net(ifa->ifa_dev->dev) != &init_net)
3507 return NOTIFY_DONE; 3635 return NOTIFY_DONE;
3508 3636
3509 list_for_each_entry_safe(bond, bond_next, &bond_dev_list, bond_list) { 3637 list_for_each_entry(bond, &bond_dev_list, bond_list) {
3510 if (bond->dev == event_dev) { 3638 if (bond->dev == event_dev) {
3511 switch (event) { 3639 switch (event) {
3512 case NETDEV_UP: 3640 case NETDEV_UP:
@@ -3520,11 +3648,7 @@ static int bond_inetaddr_event(struct notifier_block *this, unsigned long event,
3520 } 3648 }
3521 } 3649 }
3522 3650
3523 if (list_empty(&bond->vlan_list)) 3651 list_for_each_entry(vlan, &bond->vlan_list, vlan_list) {
3524 continue;
3525
3526 list_for_each_entry_safe(vlan, vlan_next, &bond->vlan_list,
3527 vlan_list) {
3528 vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id); 3652 vlan_dev = vlan_group_get_device(bond->vlgrp, vlan->vlan_id);
3529 if (vlan_dev == event_dev) { 3653 if (vlan_dev == event_dev) {
3530 switch (event) { 3654 switch (event) {
@@ -4060,10 +4184,10 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
4060 dprintk("bond=%p, name=%s\n", bond, (bond_dev ? bond_dev->name : "None")); 4184 dprintk("bond=%p, name=%s\n", bond, (bond_dev ? bond_dev->name : "None"));
4061 4185
4062 /* 4186 /*
4063 * If fail_over_mac is enabled, do nothing and return success. 4187 * If fail_over_mac is set to active, do nothing and return
4064 * Returning an error causes ifenslave to fail. 4188 * success. Returning an error causes ifenslave to fail.
4065 */ 4189 */
4066 if (bond->params.fail_over_mac) 4190 if (bond->params.fail_over_mac == BOND_FOM_ACTIVE)
4067 return 0; 4191 return 0;
4068 4192
4069 if (!is_valid_ether_addr(sa->sa_data)) { 4193 if (!is_valid_ether_addr(sa->sa_data)) {
@@ -4568,7 +4692,7 @@ int bond_parse_parm(const char *buf, struct bond_parm_tbl *tbl)
4568 4692
4569static int bond_check_params(struct bond_params *params) 4693static int bond_check_params(struct bond_params *params)
4570{ 4694{
4571 int arp_validate_value; 4695 int arp_validate_value, fail_over_mac_value;
4572 4696
4573 /* 4697 /*
4574 * Convert string parameters. 4698 * Convert string parameters.
@@ -4658,6 +4782,13 @@ static int bond_check_params(struct bond_params *params)
4658 use_carrier = 1; 4782 use_carrier = 1;
4659 } 4783 }
4660 4784
4785 if (num_grat_arp < 0 || num_grat_arp > 255) {
4786 printk(KERN_WARNING DRV_NAME
4787 ": Warning: num_grat_arp (%d) not in range 0-255 so it "
4788 "was reset to 1 \n", num_grat_arp);
4789 num_grat_arp = 1;
4790 }
4791
4661 /* reset values for 802.3ad */ 4792 /* reset values for 802.3ad */
4662 if (bond_mode == BOND_MODE_8023AD) { 4793 if (bond_mode == BOND_MODE_8023AD) {
4663 if (!miimon) { 4794 if (!miimon) {
@@ -4836,15 +4967,29 @@ static int bond_check_params(struct bond_params *params)
4836 primary = NULL; 4967 primary = NULL;
4837 } 4968 }
4838 4969
4839 if (fail_over_mac && (bond_mode != BOND_MODE_ACTIVEBACKUP)) 4970 if (fail_over_mac) {
4840 printk(KERN_WARNING DRV_NAME 4971 fail_over_mac_value = bond_parse_parm(fail_over_mac,
4841 ": Warning: fail_over_mac only affects " 4972 fail_over_mac_tbl);
4842 "active-backup mode.\n"); 4973 if (fail_over_mac_value == -1) {
4974 printk(KERN_ERR DRV_NAME
4975 ": Error: invalid fail_over_mac \"%s\"\n",
4976 arp_validate == NULL ? "NULL" : arp_validate);
4977 return -EINVAL;
4978 }
4979
4980 if (bond_mode != BOND_MODE_ACTIVEBACKUP)
4981 printk(KERN_WARNING DRV_NAME
4982 ": Warning: fail_over_mac only affects "
4983 "active-backup mode.\n");
4984 } else {
4985 fail_over_mac_value = BOND_FOM_NONE;
4986 }
4843 4987
4844 /* fill params struct with the proper values */ 4988 /* fill params struct with the proper values */
4845 params->mode = bond_mode; 4989 params->mode = bond_mode;
4846 params->xmit_policy = xmit_hashtype; 4990 params->xmit_policy = xmit_hashtype;
4847 params->miimon = miimon; 4991 params->miimon = miimon;
4992 params->num_grat_arp = num_grat_arp;
4848 params->arp_interval = arp_interval; 4993 params->arp_interval = arp_interval;
4849 params->arp_validate = arp_validate_value; 4994 params->arp_validate = arp_validate_value;
4850 params->updelay = updelay; 4995 params->updelay = updelay;
@@ -4852,7 +4997,7 @@ static int bond_check_params(struct bond_params *params)
4852 params->use_carrier = use_carrier; 4997 params->use_carrier = use_carrier;
4853 params->lacp_fast = lacp_fast; 4998 params->lacp_fast = lacp_fast;
4854 params->primary[0] = 0; 4999 params->primary[0] = 0;
4855 params->fail_over_mac = fail_over_mac; 5000 params->fail_over_mac = fail_over_mac_value;
4856 5001
4857 if (primary) { 5002 if (primary) {
4858 strncpy(params->primary, primary, IFNAMSIZ); 5003 strncpy(params->primary, primary, IFNAMSIZ);
@@ -4871,10 +5016,10 @@ static struct lock_class_key bonding_netdev_xmit_lock_key;
4871 * Caller must NOT hold rtnl_lock; we need to release it here before we 5016 * Caller must NOT hold rtnl_lock; we need to release it here before we
4872 * set up our sysfs entries. 5017 * set up our sysfs entries.
4873 */ 5018 */
4874int bond_create(char *name, struct bond_params *params, struct bonding **newbond) 5019int bond_create(char *name, struct bond_params *params)
4875{ 5020{
4876 struct net_device *bond_dev; 5021 struct net_device *bond_dev;
4877 struct bonding *bond, *nxt; 5022 struct bonding *bond;
4878 int res; 5023 int res;
4879 5024
4880 rtnl_lock(); 5025 rtnl_lock();
@@ -4882,7 +5027,7 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond
4882 5027
4883 /* Check to see if the bond already exists. */ 5028 /* Check to see if the bond already exists. */
4884 if (name) { 5029 if (name) {
4885 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) 5030 list_for_each_entry(bond, &bond_dev_list, bond_list)
4886 if (strnicmp(bond->dev->name, name, IFNAMSIZ) == 0) { 5031 if (strnicmp(bond->dev->name, name, IFNAMSIZ) == 0) {
4887 printk(KERN_ERR DRV_NAME 5032 printk(KERN_ERR DRV_NAME
4888 ": cannot add bond %s; it already exists\n", 5033 ": cannot add bond %s; it already exists\n",
@@ -4925,9 +5070,6 @@ int bond_create(char *name, struct bond_params *params, struct bonding **newbond
4925 5070
4926 lockdep_set_class(&bond_dev->_xmit_lock, &bonding_netdev_xmit_lock_key); 5071 lockdep_set_class(&bond_dev->_xmit_lock, &bonding_netdev_xmit_lock_key);
4927 5072
4928 if (newbond)
4929 *newbond = bond_dev->priv;
4930
4931 netif_carrier_off(bond_dev); 5073 netif_carrier_off(bond_dev);
4932 5074
4933 up_write(&bonding_rwsem); 5075 up_write(&bonding_rwsem);
@@ -4957,7 +5099,7 @@ static int __init bonding_init(void)
4957{ 5099{
4958 int i; 5100 int i;
4959 int res; 5101 int res;
4960 struct bonding *bond, *nxt; 5102 struct bonding *bond;
4961 5103
4962 printk(KERN_INFO "%s", version); 5104 printk(KERN_INFO "%s", version);
4963 5105
@@ -4973,7 +5115,7 @@ static int __init bonding_init(void)
4973 init_rwsem(&bonding_rwsem); 5115 init_rwsem(&bonding_rwsem);
4974 5116
4975 for (i = 0; i < max_bonds; i++) { 5117 for (i = 0; i < max_bonds; i++) {
4976 res = bond_create(NULL, &bonding_defaults, NULL); 5118 res = bond_create(NULL, &bonding_defaults);
4977 if (res) 5119 if (res)
4978 goto err; 5120 goto err;
4979 } 5121 }
@@ -4987,7 +5129,7 @@ static int __init bonding_init(void)
4987 5129
4988 goto out; 5130 goto out;
4989err: 5131err:
4990 list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) { 5132 list_for_each_entry(bond, &bond_dev_list, bond_list) {
4991 bond_work_cancel_all(bond); 5133 bond_work_cancel_all(bond);
4992 destroy_workqueue(bond->wq); 5134 destroy_workqueue(bond->wq);
4993 } 5135 }