diff options
author | David S. Miller <davem@davemloft.net> | 2014-09-15 17:19:55 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-09-15 17:19:55 -0400 |
commit | 6cca9adb786184be21f30be0982e3ea0281f75cb (patch) | |
tree | 02f1d06b712e53d70a43ccb9f56ac05cffc2af0a | |
parent | 437024067ac1fbda7bb3a795e75922f9034672fb (diff) | |
parent | e0974585e74cc16446bc0690f0545b72aa2a3485 (diff) |
Merge branch 'bonding-cleanups'
Nikolay Aleksandrov says:
====================
bonding: style, comment and assertion changes
This is a small and simple patch-set that doesn't introduce (hopefully) any
functional changes, but only stylistic and semantic ones.
Patch 01 simply uses the already provided __rlb_next_rx_slave function inside
rlb_next_rx_slave(), thus removing the duplication of code.
Patch 02 changes all comments that I could find to netdev style, removes
some outdated ones and fixes a few more small cosmetic issues (new line
after declaration, braces around if; else and such)
Patch 03 removes one extra ASSERT_RTNL() because we already have it in the
parent function and consolidates two other ASSERT_RTNL()s to the function
that is exported and supposed to be called with RTNL anyway.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 5 | ||||
-rw-r--r-- | drivers/net/bonding/bond_alb.c | 86 | ||||
-rw-r--r-- | drivers/net/bonding/bond_debugfs.c | 4 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 205 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 1 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 3 |
6 files changed, 105 insertions, 199 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 2bb360f32a64..7e9e522fd476 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -297,15 +297,14 @@ static u16 __get_link_speed(struct port *port) | |||
297 | static u8 __get_duplex(struct port *port) | 297 | static u8 __get_duplex(struct port *port) |
298 | { | 298 | { |
299 | struct slave *slave = port->slave; | 299 | struct slave *slave = port->slave; |
300 | |||
301 | u8 retval; | 300 | u8 retval; |
302 | 301 | ||
303 | /* handling a special case: when the configuration starts with | 302 | /* handling a special case: when the configuration starts with |
304 | * link down, it sets the duplex to 0. | 303 | * link down, it sets the duplex to 0. |
305 | */ | 304 | */ |
306 | if (slave->link != BOND_LINK_UP) | 305 | if (slave->link != BOND_LINK_UP) { |
307 | retval = 0x0; | 306 | retval = 0x0; |
308 | else { | 307 | } else { |
309 | switch (slave->duplex) { | 308 | switch (slave->duplex) { |
310 | case DUPLEX_FULL: | 309 | case DUPLEX_FULL: |
311 | retval = 0x1; | 310 | retval = 0x1; |
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 85af961f1317..615f3bebd019 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -261,14 +261,15 @@ static struct slave *tlb_choose_channel(struct bonding *bond, u32 hash_index, | |||
261 | u32 skb_len) | 261 | u32 skb_len) |
262 | { | 262 | { |
263 | struct slave *tx_slave; | 263 | struct slave *tx_slave; |
264 | /* | 264 | |
265 | * We don't need to disable softirq here, becase | 265 | /* We don't need to disable softirq here, becase |
266 | * tlb_choose_channel() is only called by bond_alb_xmit() | 266 | * tlb_choose_channel() is only called by bond_alb_xmit() |
267 | * which already has softirq disabled. | 267 | * which already has softirq disabled. |
268 | */ | 268 | */ |
269 | spin_lock(&bond->mode_lock); | 269 | spin_lock(&bond->mode_lock); |
270 | tx_slave = __tlb_choose_channel(bond, hash_index, skb_len); | 270 | tx_slave = __tlb_choose_channel(bond, hash_index, skb_len); |
271 | spin_unlock(&bond->mode_lock); | 271 | spin_unlock(&bond->mode_lock); |
272 | |||
272 | return tx_slave; | 273 | return tx_slave; |
273 | } | 274 | } |
274 | 275 | ||
@@ -334,14 +335,15 @@ out: | |||
334 | return RX_HANDLER_ANOTHER; | 335 | return RX_HANDLER_ANOTHER; |
335 | } | 336 | } |
336 | 337 | ||
337 | static struct slave *rlb_next_rx_slave(struct bonding *bond) | 338 | /* Caller must hold rcu_read_lock() */ |
339 | static struct slave *__rlb_next_rx_slave(struct bonding *bond) | ||
338 | { | 340 | { |
339 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | 341 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); |
340 | struct slave *before = NULL, *rx_slave = NULL, *slave; | 342 | struct slave *before = NULL, *rx_slave = NULL, *slave; |
341 | struct list_head *iter; | 343 | struct list_head *iter; |
342 | bool found = false; | 344 | bool found = false; |
343 | 345 | ||
344 | bond_for_each_slave(bond, slave, iter) { | 346 | bond_for_each_slave_rcu(bond, slave, iter) { |
345 | if (!bond_slave_can_tx(slave)) | 347 | if (!bond_slave_can_tx(slave)) |
346 | continue; | 348 | continue; |
347 | if (!found) { | 349 | if (!found) { |
@@ -366,35 +368,16 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond) | |||
366 | return rx_slave; | 368 | return rx_slave; |
367 | } | 369 | } |
368 | 370 | ||
369 | /* Caller must hold rcu_read_lock() */ | 371 | /* Caller must hold RTNL, rcu_read_lock is obtained only to silence checkers */ |
370 | static struct slave *__rlb_next_rx_slave(struct bonding *bond) | 372 | static struct slave *rlb_next_rx_slave(struct bonding *bond) |
371 | { | 373 | { |
372 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | 374 | struct slave *rx_slave; |
373 | struct slave *before = NULL, *rx_slave = NULL, *slave; | ||
374 | struct list_head *iter; | ||
375 | bool found = false; | ||
376 | 375 | ||
377 | bond_for_each_slave_rcu(bond, slave, iter) { | 376 | ASSERT_RTNL(); |
378 | if (!bond_slave_can_tx(slave)) | ||
379 | continue; | ||
380 | if (!found) { | ||
381 | if (!before || before->speed < slave->speed) | ||
382 | before = slave; | ||
383 | } else { | ||
384 | if (!rx_slave || rx_slave->speed < slave->speed) | ||
385 | rx_slave = slave; | ||
386 | } | ||
387 | if (slave == bond_info->rx_slave) | ||
388 | found = true; | ||
389 | } | ||
390 | /* we didn't find anything after the current or we have something | ||
391 | * better before and up to the current slave | ||
392 | */ | ||
393 | if (!rx_slave || (before && rx_slave->speed < before->speed)) | ||
394 | rx_slave = before; | ||
395 | 377 | ||
396 | if (rx_slave) | 378 | rcu_read_lock(); |
397 | bond_info->rx_slave = rx_slave; | 379 | rx_slave = __rlb_next_rx_slave(bond); |
380 | rcu_read_unlock(); | ||
398 | 381 | ||
399 | return rx_slave; | 382 | return rx_slave; |
400 | } | 383 | } |
@@ -587,7 +570,7 @@ static void rlb_req_update_subnet_clients(struct bonding *bond, __be32 src_ip) | |||
587 | netdev_err(bond->dev, "found a client with no channel in the client's hash table\n"); | 570 | netdev_err(bond->dev, "found a client with no channel in the client's hash table\n"); |
588 | continue; | 571 | continue; |
589 | } | 572 | } |
590 | /*update all clients using this src_ip, that are not assigned | 573 | /* update all clients using this src_ip, that are not assigned |
591 | * to the team's address (curr_active_slave) and have a known | 574 | * to the team's address (curr_active_slave) and have a known |
592 | * unicast mac address. | 575 | * unicast mac address. |
593 | */ | 576 | */ |
@@ -713,9 +696,7 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond) | |||
713 | return NULL; | 696 | return NULL; |
714 | 697 | ||
715 | if (arp->op_code == htons(ARPOP_REPLY)) { | 698 | if (arp->op_code == htons(ARPOP_REPLY)) { |
716 | /* the arp must be sent on the selected | 699 | /* the arp must be sent on the selected rx channel */ |
717 | * rx channel | ||
718 | */ | ||
719 | tx_slave = rlb_choose_channel(skb, bond); | 700 | tx_slave = rlb_choose_channel(skb, bond); |
720 | if (tx_slave) | 701 | if (tx_slave) |
721 | ether_addr_copy(arp->mac_src, tx_slave->dev->dev_addr); | 702 | ether_addr_copy(arp->mac_src, tx_slave->dev->dev_addr); |
@@ -774,7 +755,7 @@ static void rlb_rebalance(struct bonding *bond) | |||
774 | spin_unlock_bh(&bond->mode_lock); | 755 | spin_unlock_bh(&bond->mode_lock); |
775 | } | 756 | } |
776 | 757 | ||
777 | /* Caller must hold rx_hashtbl lock */ | 758 | /* Caller must hold mode_lock */ |
778 | static void rlb_init_table_entry_dst(struct rlb_client_info *entry) | 759 | static void rlb_init_table_entry_dst(struct rlb_client_info *entry) |
779 | { | 760 | { |
780 | entry->used_next = RLB_NULL_INDEX; | 761 | entry->used_next = RLB_NULL_INDEX; |
@@ -862,8 +843,9 @@ static void rlb_src_link(struct bonding *bond, u32 ip_src_hash, u32 ip_dst_hash) | |||
862 | bond_info->rx_hashtbl[ip_src_hash].src_first = ip_dst_hash; | 843 | bond_info->rx_hashtbl[ip_src_hash].src_first = ip_dst_hash; |
863 | } | 844 | } |
864 | 845 | ||
865 | /* deletes all rx_hashtbl entries with arp->ip_src if their mac_src does | 846 | /* deletes all rx_hashtbl entries with arp->ip_src if their mac_src does |
866 | * not match arp->mac_src */ | 847 | * not match arp->mac_src |
848 | */ | ||
867 | static void rlb_purge_src_ip(struct bonding *bond, struct arp_pkt *arp) | 849 | static void rlb_purge_src_ip(struct bonding *bond, struct arp_pkt *arp) |
868 | { | 850 | { |
869 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | 851 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); |
@@ -1040,8 +1022,9 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[]) | |||
1040 | return 0; | 1022 | return 0; |
1041 | } | 1023 | } |
1042 | 1024 | ||
1043 | /* for rlb each slave must have a unique hw mac addresses so that */ | 1025 | /* for rlb each slave must have a unique hw mac addresses so that |
1044 | /* each slave will receive packets destined to a different mac */ | 1026 | * each slave will receive packets destined to a different mac |
1027 | */ | ||
1045 | memcpy(s_addr.sa_data, addr, dev->addr_len); | 1028 | memcpy(s_addr.sa_data, addr, dev->addr_len); |
1046 | s_addr.sa_family = dev->type; | 1029 | s_addr.sa_family = dev->type; |
1047 | if (dev_set_mac_address(dev, &s_addr)) { | 1030 | if (dev_set_mac_address(dev, &s_addr)) { |
@@ -1052,13 +1035,10 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[]) | |||
1052 | return 0; | 1035 | return 0; |
1053 | } | 1036 | } |
1054 | 1037 | ||
1055 | /* | 1038 | /* Swap MAC addresses between two slaves. |
1056 | * Swap MAC addresses between two slaves. | ||
1057 | * | 1039 | * |
1058 | * Called with RTNL held, and no other locks. | 1040 | * Called with RTNL held, and no other locks. |
1059 | * | ||
1060 | */ | 1041 | */ |
1061 | |||
1062 | static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2) | 1042 | static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2) |
1063 | { | 1043 | { |
1064 | u8 tmp_mac_addr[ETH_ALEN]; | 1044 | u8 tmp_mac_addr[ETH_ALEN]; |
@@ -1069,8 +1049,7 @@ static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2) | |||
1069 | 1049 | ||
1070 | } | 1050 | } |
1071 | 1051 | ||
1072 | /* | 1052 | /* Send learning packets after MAC address swap. |
1073 | * Send learning packets after MAC address swap. | ||
1074 | * | 1053 | * |
1075 | * Called with RTNL and no other locks | 1054 | * Called with RTNL and no other locks |
1076 | */ | 1055 | */ |
@@ -1143,7 +1122,6 @@ static void alb_change_hw_addr_on_detach(struct bonding *bond, struct slave *sla | |||
1143 | found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr); | 1122 | found_slave = bond_slave_has_mac(bond, slave->perm_hwaddr); |
1144 | 1123 | ||
1145 | if (found_slave) { | 1124 | if (found_slave) { |
1146 | /* locking: needs RTNL and nothing else */ | ||
1147 | alb_swap_mac_addr(slave, found_slave); | 1125 | alb_swap_mac_addr(slave, found_slave); |
1148 | alb_fasten_mac_swap(bond, slave, found_slave); | 1126 | alb_fasten_mac_swap(bond, slave, found_slave); |
1149 | } | 1127 | } |
@@ -1192,7 +1170,8 @@ static int alb_handle_addr_collision_on_attach(struct bonding *bond, struct slav | |||
1192 | return 0; | 1170 | return 0; |
1193 | 1171 | ||
1194 | /* Try setting slave mac to bond address and fall-through | 1172 | /* Try setting slave mac to bond address and fall-through |
1195 | to code handling that situation below... */ | 1173 | * to code handling that situation below... |
1174 | */ | ||
1196 | alb_set_slave_mac_addr(slave, bond->dev->dev_addr); | 1175 | alb_set_slave_mac_addr(slave, bond->dev->dev_addr); |
1197 | } | 1176 | } |
1198 | 1177 | ||
@@ -1300,7 +1279,6 @@ int bond_alb_initialize(struct bonding *bond, int rlb_enabled) | |||
1300 | 1279 | ||
1301 | if (rlb_enabled) { | 1280 | if (rlb_enabled) { |
1302 | bond->alb_info.rlb_enabled = 1; | 1281 | bond->alb_info.rlb_enabled = 1; |
1303 | /* initialize rlb */ | ||
1304 | res = rlb_initialize(bond); | 1282 | res = rlb_initialize(bond); |
1305 | if (res) { | 1283 | if (res) { |
1306 | tlb_deinitialize(bond); | 1284 | tlb_deinitialize(bond); |
@@ -1324,7 +1302,7 @@ void bond_alb_deinitialize(struct bonding *bond) | |||
1324 | } | 1302 | } |
1325 | 1303 | ||
1326 | static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, | 1304 | static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, |
1327 | struct slave *tx_slave) | 1305 | struct slave *tx_slave) |
1328 | { | 1306 | { |
1329 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | 1307 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); |
1330 | struct ethhdr *eth_data = eth_hdr(skb); | 1308 | struct ethhdr *eth_data = eth_hdr(skb); |
@@ -1572,13 +1550,11 @@ void bond_alb_monitor(struct work_struct *work) | |||
1572 | bond_info->tx_rebalance_counter = 0; | 1550 | bond_info->tx_rebalance_counter = 0; |
1573 | } | 1551 | } |
1574 | 1552 | ||
1575 | /* handle rlb stuff */ | ||
1576 | if (bond_info->rlb_enabled) { | 1553 | if (bond_info->rlb_enabled) { |
1577 | if (bond_info->primary_is_promisc && | 1554 | if (bond_info->primary_is_promisc && |
1578 | (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) { | 1555 | (++bond_info->rlb_promisc_timeout_counter >= RLB_PROMISC_TIMEOUT)) { |
1579 | 1556 | ||
1580 | /* | 1557 | /* dev_set_promiscuity requires rtnl and |
1581 | * dev_set_promiscuity requires rtnl and | ||
1582 | * nothing else. Avoid race with bond_close. | 1558 | * nothing else. Avoid race with bond_close. |
1583 | */ | 1559 | */ |
1584 | rcu_read_unlock(); | 1560 | rcu_read_unlock(); |
@@ -1648,8 +1624,7 @@ int bond_alb_init_slave(struct bonding *bond, struct slave *slave) | |||
1648 | return 0; | 1624 | return 0; |
1649 | } | 1625 | } |
1650 | 1626 | ||
1651 | /* | 1627 | /* Remove slave from tlb and rlb hash tables, and fix up MAC addresses |
1652 | * Remove slave from tlb and rlb hash tables, and fix up MAC addresses | ||
1653 | * if necessary. | 1628 | * if necessary. |
1654 | * | 1629 | * |
1655 | * Caller must hold RTNL and no other locks | 1630 | * Caller must hold RTNL and no other locks |
@@ -1736,8 +1711,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave | |||
1736 | if (!swap_slave) | 1711 | if (!swap_slave) |
1737 | swap_slave = bond_slave_has_mac(bond, bond->dev->dev_addr); | 1712 | swap_slave = bond_slave_has_mac(bond, bond->dev->dev_addr); |
1738 | 1713 | ||
1739 | /* | 1714 | /* Arrange for swap_slave and new_slave to temporarily be |
1740 | * Arrange for swap_slave and new_slave to temporarily be | ||
1741 | * ignored so we can mess with their MAC addresses without | 1715 | * ignored so we can mess with their MAC addresses without |
1742 | * fear of interference from transmit activity. | 1716 | * fear of interference from transmit activity. |
1743 | */ | 1717 | */ |
diff --git a/drivers/net/bonding/bond_debugfs.c b/drivers/net/bonding/bond_debugfs.c index 652f6c5d1bf7..8f99082f90eb 100644 --- a/drivers/net/bonding/bond_debugfs.c +++ b/drivers/net/bonding/bond_debugfs.c | |||
@@ -13,9 +13,7 @@ | |||
13 | 13 | ||
14 | static struct dentry *bonding_debug_root; | 14 | static struct dentry *bonding_debug_root; |
15 | 15 | ||
16 | /* | 16 | /* Show RLB hash table */ |
17 | * Show RLB hash table | ||
18 | */ | ||
19 | static int bond_debug_rlb_hash_show(struct seq_file *m, void *v) | 17 | static int bond_debug_rlb_hash_show(struct seq_file *m, void *v) |
20 | { | 18 | { |
21 | struct bonding *bond = m->private; | 19 | struct bonding *bond = m->private; |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 2d90a8b7f62e..5e7987bba583 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -253,8 +253,7 @@ void bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, | |||
253 | dev_queue_xmit(skb); | 253 | dev_queue_xmit(skb); |
254 | } | 254 | } |
255 | 255 | ||
256 | /* | 256 | /* In the following 2 functions, bond_vlan_rx_add_vid and bond_vlan_rx_kill_vid, |
257 | * In the following 2 functions, bond_vlan_rx_add_vid and bond_vlan_rx_kill_vid, | ||
258 | * We don't protect the slave list iteration with a lock because: | 257 | * We don't protect the slave list iteration with a lock because: |
259 | * a. This operation is performed in IOCTL context, | 258 | * a. This operation is performed in IOCTL context, |
260 | * b. The operation is protected by the RTNL semaphore in the 8021q code, | 259 | * b. The operation is protected by the RTNL semaphore in the 8021q code, |
@@ -326,8 +325,7 @@ static int bond_vlan_rx_kill_vid(struct net_device *bond_dev, | |||
326 | 325 | ||
327 | /*------------------------------- Link status -------------------------------*/ | 326 | /*------------------------------- Link status -------------------------------*/ |
328 | 327 | ||
329 | /* | 328 | /* Set the carrier state for the master according to the state of its |
330 | * Set the carrier state for the master according to the state of its | ||
331 | * slaves. If any slaves are up, the master is up. In 802.3ad mode, | 329 | * slaves. If any slaves are up, the master is up. In 802.3ad mode, |
332 | * do special 802.3ad magic. | 330 | * do special 802.3ad magic. |
333 | * | 331 | * |
@@ -362,8 +360,7 @@ down: | |||
362 | return 0; | 360 | return 0; |
363 | } | 361 | } |
364 | 362 | ||
365 | /* | 363 | /* Get link speed and duplex from the slave's base driver |
366 | * Get link speed and duplex from the slave's base driver | ||
367 | * using ethtool. If for some reason the call fails or the | 364 | * using ethtool. If for some reason the call fails or the |
368 | * values are invalid, set speed and duplex to -1, | 365 | * values are invalid, set speed and duplex to -1, |
369 | * and return. | 366 | * and return. |
@@ -416,8 +413,7 @@ const char *bond_slave_link_status(s8 link) | |||
416 | } | 413 | } |
417 | } | 414 | } |
418 | 415 | ||
419 | /* | 416 | /* if <dev> supports MII link status reporting, check its link status. |
420 | * if <dev> supports MII link status reporting, check its link status. | ||
421 | * | 417 | * |
422 | * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(), | 418 | * We either do MII/ETHTOOL ioctls, or check netif_carrier_ok(), |
423 | * depending upon the setting of the use_carrier parameter. | 419 | * depending upon the setting of the use_carrier parameter. |
@@ -454,14 +450,14 @@ static int bond_check_dev_link(struct bonding *bond, | |||
454 | /* Ethtool can't be used, fallback to MII ioctls. */ | 450 | /* Ethtool can't be used, fallback to MII ioctls. */ |
455 | ioctl = slave_ops->ndo_do_ioctl; | 451 | ioctl = slave_ops->ndo_do_ioctl; |
456 | if (ioctl) { | 452 | if (ioctl) { |
457 | /* TODO: set pointer to correct ioctl on a per team member */ | 453 | /* TODO: set pointer to correct ioctl on a per team member |
458 | /* bases to make this more efficient. that is, once */ | 454 | * bases to make this more efficient. that is, once |
459 | /* we determine the correct ioctl, we will always */ | 455 | * we determine the correct ioctl, we will always |
460 | /* call it and not the others for that team */ | 456 | * call it and not the others for that team |
461 | /* member. */ | 457 | * member. |
462 | 458 | */ | |
463 | /* | 459 | |
464 | * We cannot assume that SIOCGMIIPHY will also read a | 460 | /* We cannot assume that SIOCGMIIPHY will also read a |
465 | * register; not all network drivers (e.g., e100) | 461 | * register; not all network drivers (e.g., e100) |
466 | * support that. | 462 | * support that. |
467 | */ | 463 | */ |
@@ -476,8 +472,7 @@ static int bond_check_dev_link(struct bonding *bond, | |||
476 | } | 472 | } |
477 | } | 473 | } |
478 | 474 | ||
479 | /* | 475 | /* If reporting, report that either there's no dev->do_ioctl, |
480 | * If reporting, report that either there's no dev->do_ioctl, | ||
481 | * or both SIOCGMIIREG and get_link failed (meaning that we | 476 | * or both SIOCGMIIREG and get_link failed (meaning that we |
482 | * cannot report link status). If not reporting, pretend | 477 | * cannot report link status). If not reporting, pretend |
483 | * we're ok. | 478 | * we're ok. |
@@ -487,9 +482,7 @@ static int bond_check_dev_link(struct bonding *bond, | |||
487 | 482 | ||
488 | /*----------------------------- Multicast list ------------------------------*/ | 483 | /*----------------------------- Multicast list ------------------------------*/ |
489 | 484 | ||
490 | /* | 485 | /* Push the promiscuity flag down to appropriate slaves */ |
491 | * Push the promiscuity flag down to appropriate slaves | ||
492 | */ | ||
493 | static int bond_set_promiscuity(struct bonding *bond, int inc) | 486 | static int bond_set_promiscuity(struct bonding *bond, int inc) |
494 | { | 487 | { |
495 | struct list_head *iter; | 488 | struct list_head *iter; |
@@ -512,9 +505,7 @@ static int bond_set_promiscuity(struct bonding *bond, int inc) | |||
512 | return err; | 505 | return err; |
513 | } | 506 | } |
514 | 507 | ||
515 | /* | 508 | /* Push the allmulti flag down to all slaves */ |
516 | * Push the allmulti flag down to all slaves | ||
517 | */ | ||
518 | static int bond_set_allmulti(struct bonding *bond, int inc) | 509 | static int bond_set_allmulti(struct bonding *bond, int inc) |
519 | { | 510 | { |
520 | struct list_head *iter; | 511 | struct list_head *iter; |
@@ -537,8 +528,7 @@ static int bond_set_allmulti(struct bonding *bond, int inc) | |||
537 | return err; | 528 | return err; |
538 | } | 529 | } |
539 | 530 | ||
540 | /* | 531 | /* Retrieve the list of registered multicast addresses for the bonding |
541 | * Retrieve the list of registered multicast addresses for the bonding | ||
542 | * device and retransmit an IGMP JOIN request to the current active | 532 | * device and retransmit an IGMP JOIN request to the current active |
543 | * slave. | 533 | * slave. |
544 | */ | 534 | */ |
@@ -560,8 +550,7 @@ static void bond_resend_igmp_join_requests_delayed(struct work_struct *work) | |||
560 | rtnl_unlock(); | 550 | rtnl_unlock(); |
561 | } | 551 | } |
562 | 552 | ||
563 | /* Flush bond's hardware addresses from slave | 553 | /* Flush bond's hardware addresses from slave */ |
564 | */ | ||
565 | static void bond_hw_addr_flush(struct net_device *bond_dev, | 554 | static void bond_hw_addr_flush(struct net_device *bond_dev, |
566 | struct net_device *slave_dev) | 555 | struct net_device *slave_dev) |
567 | { | 556 | { |
@@ -588,8 +577,6 @@ static void bond_hw_addr_flush(struct net_device *bond_dev, | |||
588 | static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, | 577 | static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, |
589 | struct slave *old_active) | 578 | struct slave *old_active) |
590 | { | 579 | { |
591 | ASSERT_RTNL(); | ||
592 | |||
593 | if (old_active) { | 580 | if (old_active) { |
594 | if (bond->dev->flags & IFF_PROMISC) | 581 | if (bond->dev->flags & IFF_PROMISC) |
595 | dev_set_promiscuity(old_active->dev, -1); | 582 | dev_set_promiscuity(old_active->dev, -1); |
@@ -632,8 +619,7 @@ static void bond_set_dev_addr(struct net_device *bond_dev, | |||
632 | call_netdevice_notifiers(NETDEV_CHANGEADDR, bond_dev); | 619 | call_netdevice_notifiers(NETDEV_CHANGEADDR, bond_dev); |
633 | } | 620 | } |
634 | 621 | ||
635 | /* | 622 | /* bond_do_fail_over_mac |
636 | * bond_do_fail_over_mac | ||
637 | * | 623 | * |
638 | * Perform special MAC address swapping for fail_over_mac settings | 624 | * Perform special MAC address swapping for fail_over_mac settings |
639 | * | 625 | * |
@@ -653,8 +639,7 @@ static void bond_do_fail_over_mac(struct bonding *bond, | |||
653 | bond_set_dev_addr(bond->dev, new_active->dev); | 639 | bond_set_dev_addr(bond->dev, new_active->dev); |
654 | break; | 640 | break; |
655 | case BOND_FOM_FOLLOW: | 641 | case BOND_FOM_FOLLOW: |
656 | /* | 642 | /* if new_active && old_active, swap them |
657 | * if new_active && old_active, swap them | ||
658 | * if just old_active, do nothing (going to no active slave) | 643 | * if just old_active, do nothing (going to no active slave) |
659 | * if just new_active, set new_active to bond's MAC | 644 | * if just new_active, set new_active to bond's MAC |
660 | */ | 645 | */ |
@@ -863,7 +848,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | |||
863 | /* resend IGMP joins since active slave has changed or | 848 | /* resend IGMP joins since active slave has changed or |
864 | * all were sent on curr_active_slave. | 849 | * all were sent on curr_active_slave. |
865 | * resend only if bond is brought up with the affected | 850 | * resend only if bond is brought up with the affected |
866 | * bonding modes and the retransmission is enabled */ | 851 | * bonding modes and the retransmission is enabled |
852 | */ | ||
867 | if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) && | 853 | if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) && |
868 | ((bond_uses_primary(bond) && new_active) || | 854 | ((bond_uses_primary(bond) && new_active) || |
869 | BOND_MODE(bond) == BOND_MODE_ROUNDROBIN)) { | 855 | BOND_MODE(bond) == BOND_MODE_ROUNDROBIN)) { |
@@ -888,6 +874,8 @@ void bond_select_active_slave(struct bonding *bond) | |||
888 | struct slave *best_slave; | 874 | struct slave *best_slave; |
889 | int rv; | 875 | int rv; |
890 | 876 | ||
877 | ASSERT_RTNL(); | ||
878 | |||
891 | best_slave = bond_find_best_slave(bond); | 879 | best_slave = bond_find_best_slave(bond); |
892 | if (best_slave != rtnl_dereference(bond->curr_active_slave)) { | 880 | if (best_slave != rtnl_dereference(bond->curr_active_slave)) { |
893 | bond_change_active_slave(bond, best_slave); | 881 | bond_change_active_slave(bond, best_slave); |
@@ -1229,8 +1217,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1229 | slave_dev->name); | 1217 | slave_dev->name); |
1230 | } | 1218 | } |
1231 | 1219 | ||
1232 | /* | 1220 | /* Old ifenslave binaries are no longer supported. These can |
1233 | * Old ifenslave binaries are no longer supported. These can | ||
1234 | * be identified with moderate accuracy by the state of the slave: | 1221 | * be identified with moderate accuracy by the state of the slave: |
1235 | * the current ifenslave will set the interface down prior to | 1222 | * the current ifenslave will set the interface down prior to |
1236 | * enslaving it; the old ifenslave will not. | 1223 | * enslaving it; the old ifenslave will not. |
@@ -1302,7 +1289,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1302 | call_netdevice_notifiers(NETDEV_JOIN, slave_dev); | 1289 | call_netdevice_notifiers(NETDEV_JOIN, slave_dev); |
1303 | 1290 | ||
1304 | /* If this is the first slave, then we need to set the master's hardware | 1291 | /* If this is the first slave, then we need to set the master's hardware |
1305 | * address to be the same as the slave's. */ | 1292 | * address to be the same as the slave's. |
1293 | */ | ||
1306 | if (!bond_has_slaves(bond) && | 1294 | if (!bond_has_slaves(bond) && |
1307 | bond->dev->addr_assign_type == NET_ADDR_RANDOM) | 1295 | bond->dev->addr_assign_type == NET_ADDR_RANDOM) |
1308 | bond_set_dev_addr(bond->dev, slave_dev); | 1296 | bond_set_dev_addr(bond->dev, slave_dev); |
@@ -1315,8 +1303,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1315 | 1303 | ||
1316 | new_slave->bond = bond; | 1304 | new_slave->bond = bond; |
1317 | new_slave->dev = slave_dev; | 1305 | new_slave->dev = slave_dev; |
1318 | /* | 1306 | /* Set the new_slave's queue_id to be zero. Queue ID mapping |
1319 | * Set the new_slave's queue_id to be zero. Queue ID mapping | ||
1320 | * is set via sysfs or module option if desired. | 1307 | * is set via sysfs or module option if desired. |
1321 | */ | 1308 | */ |
1322 | new_slave->queue_id = 0; | 1309 | new_slave->queue_id = 0; |
@@ -1329,8 +1316,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1329 | goto err_free; | 1316 | goto err_free; |
1330 | } | 1317 | } |
1331 | 1318 | ||
1332 | /* | 1319 | /* Save slave's original ("permanent") mac address for modes |
1333 | * Save slave's original ("permanent") mac address for modes | ||
1334 | * that need it, and for restoring it upon release, and then | 1320 | * that need it, and for restoring it upon release, and then |
1335 | * set it to the master's address | 1321 | * set it to the master's address |
1336 | */ | 1322 | */ |
@@ -1338,8 +1324,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1338 | 1324 | ||
1339 | if (!bond->params.fail_over_mac || | 1325 | if (!bond->params.fail_over_mac || |
1340 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { | 1326 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1341 | /* | 1327 | /* Set slave to master's mac address. The application already |
1342 | * Set slave to master's mac address. The application already | ||
1343 | * set the master's mac address to that of the first slave | 1328 | * set the master's mac address to that of the first slave |
1344 | */ | 1329 | */ |
1345 | memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len); | 1330 | memcpy(addr.sa_data, bond_dev->dev_addr, bond_dev->addr_len); |
@@ -1425,8 +1410,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1425 | link_reporting = bond_check_dev_link(bond, slave_dev, 1); | 1410 | link_reporting = bond_check_dev_link(bond, slave_dev, 1); |
1426 | 1411 | ||
1427 | if ((link_reporting == -1) && !bond->params.arp_interval) { | 1412 | if ((link_reporting == -1) && !bond->params.arp_interval) { |
1428 | /* | 1413 | /* miimon is set but a bonded network driver |
1429 | * miimon is set but a bonded network driver | ||
1430 | * does not support ETHTOOL/MII and | 1414 | * does not support ETHTOOL/MII and |
1431 | * arp_interval is not set. Note: if | 1415 | * arp_interval is not set. Note: if |
1432 | * use_carrier is enabled, we will never go | 1416 | * use_carrier is enabled, we will never go |
@@ -1626,8 +1610,7 @@ err_undo_flags: | |||
1626 | return res; | 1610 | return res; |
1627 | } | 1611 | } |
1628 | 1612 | ||
1629 | /* | 1613 | /* Try to release the slave device <slave> from the bond device <master> |
1630 | * Try to release the slave device <slave> from the bond device <master> | ||
1631 | * It is legal to access curr_active_slave without a lock because all the function | 1614 | * It is legal to access curr_active_slave without a lock because all the function |
1632 | * is RTNL-locked. If "all" is true it means that the function is being called | 1615 | * is RTNL-locked. If "all" is true it means that the function is being called |
1633 | * while destroying a bond interface and all slaves are being released. | 1616 | * while destroying a bond interface and all slaves are being released. |
@@ -1713,8 +1696,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1713 | if (all) { | 1696 | if (all) { |
1714 | RCU_INIT_POINTER(bond->curr_active_slave, NULL); | 1697 | RCU_INIT_POINTER(bond->curr_active_slave, NULL); |
1715 | } else if (oldcurrent == slave) { | 1698 | } else if (oldcurrent == slave) { |
1716 | /* | 1699 | /* Note that we hold RTNL over this sequence, so there |
1717 | * Note that we hold RTNL over this sequence, so there | ||
1718 | * is no concern that another slave add/remove event | 1700 | * is no concern that another slave add/remove event |
1719 | * will interfere. | 1701 | * will interfere. |
1720 | */ | 1702 | */ |
@@ -1741,10 +1723,9 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1741 | netdev_info(bond_dev, "last VLAN challenged slave %s left bond %s - VLAN blocking is removed\n", | 1723 | netdev_info(bond_dev, "last VLAN challenged slave %s left bond %s - VLAN blocking is removed\n", |
1742 | slave_dev->name, bond_dev->name); | 1724 | slave_dev->name, bond_dev->name); |
1743 | 1725 | ||
1744 | /* must do this from outside any spinlocks */ | ||
1745 | vlan_vids_del_by_dev(slave_dev, bond_dev); | 1726 | vlan_vids_del_by_dev(slave_dev, bond_dev); |
1746 | 1727 | ||
1747 | /* If the mode uses primary, then this cases was handled above by | 1728 | /* If the mode uses primary, then this case was handled above by |
1748 | * bond_change_active_slave(..., NULL) | 1729 | * bond_change_active_slave(..., NULL) |
1749 | */ | 1730 | */ |
1750 | if (!bond_uses_primary(bond)) { | 1731 | if (!bond_uses_primary(bond)) { |
@@ -1784,7 +1765,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1784 | 1765 | ||
1785 | bond_free_slave(slave); | 1766 | bond_free_slave(slave); |
1786 | 1767 | ||
1787 | return 0; /* deletion OK */ | 1768 | return 0; |
1788 | } | 1769 | } |
1789 | 1770 | ||
1790 | /* A wrapper used because of ndo_del_link */ | 1771 | /* A wrapper used because of ndo_del_link */ |
@@ -1793,10 +1774,9 @@ int bond_release(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1793 | return __bond_release_one(bond_dev, slave_dev, false); | 1774 | return __bond_release_one(bond_dev, slave_dev, false); |
1794 | } | 1775 | } |
1795 | 1776 | ||
1796 | /* | 1777 | /* First release a slave and then destroy the bond if no more slaves are left. |
1797 | * First release a slave and then destroy the bond if no more slaves are left. | 1778 | * Must be under rtnl_lock when this function is called. |
1798 | * Must be under rtnl_lock when this function is called. | 1779 | */ |
1799 | */ | ||
1800 | static int bond_release_and_destroy(struct net_device *bond_dev, | 1780 | static int bond_release_and_destroy(struct net_device *bond_dev, |
1801 | struct net_device *slave_dev) | 1781 | struct net_device *slave_dev) |
1802 | { | 1782 | { |
@@ -1819,7 +1799,6 @@ static int bond_info_query(struct net_device *bond_dev, struct ifbond *info) | |||
1819 | 1799 | ||
1820 | info->bond_mode = BOND_MODE(bond); | 1800 | info->bond_mode = BOND_MODE(bond); |
1821 | info->miimon = bond->params.miimon; | 1801 | info->miimon = bond->params.miimon; |
1822 | |||
1823 | info->num_slaves = bond->slave_cnt; | 1802 | info->num_slaves = bond->slave_cnt; |
1824 | 1803 | ||
1825 | return 0; | 1804 | return 0; |
@@ -1882,9 +1861,7 @@ static int bond_miimon_inspect(struct bonding *bond) | |||
1882 | /*FALLTHRU*/ | 1861 | /*FALLTHRU*/ |
1883 | case BOND_LINK_FAIL: | 1862 | case BOND_LINK_FAIL: |
1884 | if (link_state) { | 1863 | if (link_state) { |
1885 | /* | 1864 | /* recovered before downdelay expired */ |
1886 | * recovered before downdelay expired | ||
1887 | */ | ||
1888 | slave->link = BOND_LINK_UP; | 1865 | slave->link = BOND_LINK_UP; |
1889 | slave->last_link_up = jiffies; | 1866 | slave->last_link_up = jiffies; |
1890 | netdev_info(bond->dev, "link status up again after %d ms for interface %s\n", | 1867 | netdev_info(bond->dev, "link status up again after %d ms for interface %s\n", |
@@ -2027,7 +2004,6 @@ static void bond_miimon_commit(struct bonding *bond) | |||
2027 | } | 2004 | } |
2028 | 2005 | ||
2029 | do_failover: | 2006 | do_failover: |
2030 | ASSERT_RTNL(); | ||
2031 | block_netpoll_tx(); | 2007 | block_netpoll_tx(); |
2032 | bond_select_active_slave(bond); | 2008 | bond_select_active_slave(bond); |
2033 | unblock_netpoll_tx(); | 2009 | unblock_netpoll_tx(); |
@@ -2036,8 +2012,7 @@ do_failover: | |||
2036 | bond_set_carrier(bond); | 2012 | bond_set_carrier(bond); |
2037 | } | 2013 | } |
2038 | 2014 | ||
2039 | /* | 2015 | /* bond_mii_monitor |
2040 | * bond_mii_monitor | ||
2041 | * | 2016 | * |
2042 | * Really a wrapper that splits the mii monitor into two phases: an | 2017 | * Really a wrapper that splits the mii monitor into two phases: an |
2043 | * inspection, then (if inspection indicates something needs to be done) | 2018 | * inspection, then (if inspection indicates something needs to be done) |
@@ -2109,8 +2084,7 @@ static bool bond_has_this_ip(struct bonding *bond, __be32 ip) | |||
2109 | return ret; | 2084 | return ret; |
2110 | } | 2085 | } |
2111 | 2086 | ||
2112 | /* | 2087 | /* We go to the (large) trouble of VLAN tagging ARP frames because |
2113 | * We go to the (large) trouble of VLAN tagging ARP frames because | ||
2114 | * switches in VLAN mode (especially if ports are configured as | 2088 | * switches in VLAN mode (especially if ports are configured as |
2115 | * "native" to a VLAN) might not pass non-tagged frames. | 2089 | * "native" to a VLAN) might not pass non-tagged frames. |
2116 | */ | 2090 | */ |
@@ -2337,8 +2311,7 @@ int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, | |||
2337 | 2311 | ||
2338 | curr_active_slave = rcu_dereference(bond->curr_active_slave); | 2312 | curr_active_slave = rcu_dereference(bond->curr_active_slave); |
2339 | 2313 | ||
2340 | /* | 2314 | /* Backup slaves won't see the ARP reply, but do come through |
2341 | * Backup slaves won't see the ARP reply, but do come through | ||
2342 | * here for each ARP probe (so we swap the sip/tip to validate | 2315 | * here for each ARP probe (so we swap the sip/tip to validate |
2343 | * the probe). In a "redundant switch, common router" type of | 2316 | * the probe). In a "redundant switch, common router" type of |
2344 | * configuration, the ARP probe will (hopefully) travel from | 2317 | * configuration, the ARP probe will (hopefully) travel from |
@@ -2378,8 +2351,7 @@ static bool bond_time_in_interval(struct bonding *bond, unsigned long last_act, | |||
2378 | last_act + mod * delta_in_ticks + delta_in_ticks/2); | 2351 | last_act + mod * delta_in_ticks + delta_in_ticks/2); |
2379 | } | 2352 | } |
2380 | 2353 | ||
2381 | /* | 2354 | /* This function is called regularly to monitor each slave's link |
2382 | * this function is called regularly to monitor each slave's link | ||
2383 | * ensuring that traffic is being sent and received when arp monitoring | 2355 | * ensuring that traffic is being sent and received when arp monitoring |
2384 | * is used in load-balancing mode. if the adapter has been dormant, then an | 2356 | * is used in load-balancing mode. if the adapter has been dormant, then an |
2385 | * arp is transmitted to generate traffic. see activebackup_arp_monitor for | 2357 | * arp is transmitted to generate traffic. see activebackup_arp_monitor for |
@@ -2488,8 +2460,7 @@ re_arm: | |||
2488 | msecs_to_jiffies(bond->params.arp_interval)); | 2460 | msecs_to_jiffies(bond->params.arp_interval)); |
2489 | } | 2461 | } |
2490 | 2462 | ||
2491 | /* | 2463 | /* Called to inspect slaves for active-backup mode ARP monitor link state |
2492 | * Called to inspect slaves for active-backup mode ARP monitor link state | ||
2493 | * changes. Sets new_link in slaves to specify what action should take | 2464 | * changes. Sets new_link in slaves to specify what action should take |
2494 | * place for the slave. Returns 0 if no changes are found, >0 if changes | 2465 | * place for the slave. Returns 0 if no changes are found, >0 if changes |
2495 | * to link states must be committed. | 2466 | * to link states must be committed. |
@@ -2515,16 +2486,14 @@ static int bond_ab_arp_inspect(struct bonding *bond) | |||
2515 | continue; | 2486 | continue; |
2516 | } | 2487 | } |
2517 | 2488 | ||
2518 | /* | 2489 | /* Give slaves 2*delta after being enslaved or made |
2519 | * Give slaves 2*delta after being enslaved or made | ||
2520 | * active. This avoids bouncing, as the last receive | 2490 | * active. This avoids bouncing, as the last receive |
2521 | * times need a full ARP monitor cycle to be updated. | 2491 | * times need a full ARP monitor cycle to be updated. |
2522 | */ | 2492 | */ |
2523 | if (bond_time_in_interval(bond, slave->last_link_up, 2)) | 2493 | if (bond_time_in_interval(bond, slave->last_link_up, 2)) |
2524 | continue; | 2494 | continue; |
2525 | 2495 | ||
2526 | /* | 2496 | /* Backup slave is down if: |
2527 | * Backup slave is down if: | ||
2528 | * - No current_arp_slave AND | 2497 | * - No current_arp_slave AND |
2529 | * - more than 3*delta since last receive AND | 2498 | * - more than 3*delta since last receive AND |
2530 | * - the bond has an IP address | 2499 | * - the bond has an IP address |
@@ -2543,8 +2512,7 @@ static int bond_ab_arp_inspect(struct bonding *bond) | |||
2543 | commit++; | 2512 | commit++; |
2544 | } | 2513 | } |
2545 | 2514 | ||
2546 | /* | 2515 | /* Active slave is down if: |
2547 | * Active slave is down if: | ||
2548 | * - more than 2*delta since transmitting OR | 2516 | * - more than 2*delta since transmitting OR |
2549 | * - (more than 2*delta since receive AND | 2517 | * - (more than 2*delta since receive AND |
2550 | * the bond has an IP address) | 2518 | * the bond has an IP address) |
@@ -2561,8 +2529,7 @@ static int bond_ab_arp_inspect(struct bonding *bond) | |||
2561 | return commit; | 2529 | return commit; |
2562 | } | 2530 | } |
2563 | 2531 | ||
2564 | /* | 2532 | /* Called to commit link state changes noted by inspection step of |
2565 | * Called to commit link state changes noted by inspection step of | ||
2566 | * active-backup mode ARP monitor. | 2533 | * active-backup mode ARP monitor. |
2567 | * | 2534 | * |
2568 | * Called with RTNL hold. | 2535 | * Called with RTNL hold. |
@@ -2630,7 +2597,6 @@ static void bond_ab_arp_commit(struct bonding *bond) | |||
2630 | } | 2597 | } |
2631 | 2598 | ||
2632 | do_failover: | 2599 | do_failover: |
2633 | ASSERT_RTNL(); | ||
2634 | block_netpoll_tx(); | 2600 | block_netpoll_tx(); |
2635 | bond_select_active_slave(bond); | 2601 | bond_select_active_slave(bond); |
2636 | unblock_netpoll_tx(); | 2602 | unblock_netpoll_tx(); |
@@ -2639,8 +2605,7 @@ do_failover: | |||
2639 | bond_set_carrier(bond); | 2605 | bond_set_carrier(bond); |
2640 | } | 2606 | } |
2641 | 2607 | ||
2642 | /* | 2608 | /* Send ARP probes for active-backup mode ARP monitor. |
2643 | * Send ARP probes for active-backup mode ARP monitor. | ||
2644 | * | 2609 | * |
2645 | * Called with rcu_read_lock held. | 2610 | * Called with rcu_read_lock held. |
2646 | */ | 2611 | */ |
@@ -2782,9 +2747,7 @@ re_arm: | |||
2782 | 2747 | ||
2783 | /*-------------------------- netdev event handling --------------------------*/ | 2748 | /*-------------------------- netdev event handling --------------------------*/ |
2784 | 2749 | ||
2785 | /* | 2750 | /* Change device name */ |
2786 | * Change device name | ||
2787 | */ | ||
2788 | static int bond_event_changename(struct bonding *bond) | 2751 | static int bond_event_changename(struct bonding *bond) |
2789 | { | 2752 | { |
2790 | bond_remove_proc_entry(bond); | 2753 | bond_remove_proc_entry(bond); |
@@ -2861,13 +2824,9 @@ static int bond_slave_netdev_event(unsigned long event, | |||
2861 | } | 2824 | } |
2862 | break; | 2825 | break; |
2863 | case NETDEV_DOWN: | 2826 | case NETDEV_DOWN: |
2864 | /* | ||
2865 | * ... Or is it this? | ||
2866 | */ | ||
2867 | break; | 2827 | break; |
2868 | case NETDEV_CHANGEMTU: | 2828 | case NETDEV_CHANGEMTU: |
2869 | /* | 2829 | /* TODO: Should slaves be allowed to |
2870 | * TODO: Should slaves be allowed to | ||
2871 | * independently alter their MTU? For | 2830 | * independently alter their MTU? For |
2872 | * an active-backup bond, slaves need | 2831 | * an active-backup bond, slaves need |
2873 | * not be the same type of device, so | 2832 | * not be the same type of device, so |
@@ -2916,8 +2875,7 @@ static int bond_slave_netdev_event(unsigned long event, | |||
2916 | return NOTIFY_DONE; | 2875 | return NOTIFY_DONE; |
2917 | } | 2876 | } |
2918 | 2877 | ||
2919 | /* | 2878 | /* bond_netdev_event: handle netdev notifier chain events. |
2920 | * bond_netdev_event: handle netdev notifier chain events. | ||
2921 | * | 2879 | * |
2922 | * This function receives events for the netdev chain. The caller (an | 2880 | * This function receives events for the netdev chain. The caller (an |
2923 | * ioctl handler calling blocking_notifier_call_chain) holds the necessary | 2881 | * ioctl handler calling blocking_notifier_call_chain) holds the necessary |
@@ -3187,8 +3145,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd | |||
3187 | mii->phy_id = 0; | 3145 | mii->phy_id = 0; |
3188 | /* Fall Through */ | 3146 | /* Fall Through */ |
3189 | case SIOCGMIIREG: | 3147 | case SIOCGMIIREG: |
3190 | /* | 3148 | /* We do this again just in case we were called by SIOCGMIIREG |
3191 | * We do this again just in case we were called by SIOCGMIIREG | ||
3192 | * instead of SIOCGMIIPHY. | 3149 | * instead of SIOCGMIIPHY. |
3193 | */ | 3150 | */ |
3194 | mii = if_mii(ifr); | 3151 | mii = if_mii(ifr); |
@@ -3229,7 +3186,6 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd | |||
3229 | 3186 | ||
3230 | return res; | 3187 | return res; |
3231 | default: | 3188 | default: |
3232 | /* Go on */ | ||
3233 | break; | 3189 | break; |
3234 | } | 3190 | } |
3235 | 3191 | ||
@@ -3291,7 +3247,6 @@ static void bond_set_rx_mode(struct net_device *bond_dev) | |||
3291 | struct list_head *iter; | 3247 | struct list_head *iter; |
3292 | struct slave *slave; | 3248 | struct slave *slave; |
3293 | 3249 | ||
3294 | |||
3295 | rcu_read_lock(); | 3250 | rcu_read_lock(); |
3296 | if (bond_uses_primary(bond)) { | 3251 | if (bond_uses_primary(bond)) { |
3297 | slave = rcu_dereference(bond->curr_active_slave); | 3252 | slave = rcu_dereference(bond->curr_active_slave); |
@@ -3329,8 +3284,7 @@ static int bond_neigh_init(struct neighbour *n) | |||
3329 | if (ret) | 3284 | if (ret) |
3330 | return ret; | 3285 | return ret; |
3331 | 3286 | ||
3332 | /* | 3287 | /* Assign slave's neigh_cleanup to neighbour in case cleanup is called |
3333 | * Assign slave's neigh_cleanup to neighbour in case cleanup is called | ||
3334 | * after the last slave has been detached. Assumes that all slaves | 3288 | * after the last slave has been detached. Assumes that all slaves |
3335 | * utilize the same neigh_cleanup (true at this writing as only user | 3289 | * utilize the same neigh_cleanup (true at this writing as only user |
3336 | * is ipoib). | 3290 | * is ipoib). |
@@ -3343,8 +3297,7 @@ static int bond_neigh_init(struct neighbour *n) | |||
3343 | return parms.neigh_setup(n); | 3297 | return parms.neigh_setup(n); |
3344 | } | 3298 | } |
3345 | 3299 | ||
3346 | /* | 3300 | /* The bonding ndo_neigh_setup is called at init time beofre any |
3347 | * The bonding ndo_neigh_setup is called at init time beofre any | ||
3348 | * slave exists. So we must declare proxy setup function which will | 3301 | * slave exists. So we must declare proxy setup function which will |
3349 | * be used at run time to resolve the actual slave neigh param setup. | 3302 | * be used at run time to resolve the actual slave neigh param setup. |
3350 | * | 3303 | * |
@@ -3362,9 +3315,7 @@ static int bond_neigh_setup(struct net_device *dev, | |||
3362 | return 0; | 3315 | return 0; |
3363 | } | 3316 | } |
3364 | 3317 | ||
3365 | /* | 3318 | /* Change the MTU of all of a master's slaves to match the master */ |
3366 | * Change the MTU of all of a master's slaves to match the master | ||
3367 | */ | ||
3368 | static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) | 3319 | static int bond_change_mtu(struct net_device *bond_dev, int new_mtu) |
3369 | { | 3320 | { |
3370 | struct bonding *bond = netdev_priv(bond_dev); | 3321 | struct bonding *bond = netdev_priv(bond_dev); |
@@ -3417,8 +3368,7 @@ unwind: | |||
3417 | return res; | 3368 | return res; |
3418 | } | 3369 | } |
3419 | 3370 | ||
3420 | /* | 3371 | /* Change HW address |
3421 | * Change HW address | ||
3422 | * | 3372 | * |
3423 | * Note that many devices must be down to change the HW address, and | 3373 | * Note that many devices must be down to change the HW address, and |
3424 | * downing the master releases all slaves. We can make bonds full of | 3374 | * downing the master releases all slaves. We can make bonds full of |
@@ -3588,8 +3538,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev | |||
3588 | return NETDEV_TX_OK; | 3538 | return NETDEV_TX_OK; |
3589 | } | 3539 | } |
3590 | 3540 | ||
3591 | /* | 3541 | /* In active-backup mode, we know that bond->curr_active_slave is always valid if |
3592 | * in active-backup mode, we know that bond->curr_active_slave is always valid if | ||
3593 | * the bond has a usable interface. | 3542 | * the bond has a usable interface. |
3594 | */ | 3543 | */ |
3595 | static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev) | 3544 | static int bond_xmit_activebackup(struct sk_buff *skb, struct net_device *bond_dev) |
@@ -3651,9 +3600,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) | |||
3651 | 3600 | ||
3652 | /*------------------------- Device initialization ---------------------------*/ | 3601 | /*------------------------- Device initialization ---------------------------*/ |
3653 | 3602 | ||
3654 | /* | 3603 | /* Lookup the slave that corresponds to a qid */ |
3655 | * Lookup the slave that corresponds to a qid | ||
3656 | */ | ||
3657 | static inline int bond_slave_override(struct bonding *bond, | 3604 | static inline int bond_slave_override(struct bonding *bond, |
3658 | struct sk_buff *skb) | 3605 | struct sk_buff *skb) |
3659 | { | 3606 | { |
@@ -3682,17 +3629,14 @@ static inline int bond_slave_override(struct bonding *bond, | |||
3682 | static u16 bond_select_queue(struct net_device *dev, struct sk_buff *skb, | 3629 | static u16 bond_select_queue(struct net_device *dev, struct sk_buff *skb, |
3683 | void *accel_priv, select_queue_fallback_t fallback) | 3630 | void *accel_priv, select_queue_fallback_t fallback) |
3684 | { | 3631 | { |
3685 | /* | 3632 | /* This helper function exists to help dev_pick_tx get the correct |
3686 | * This helper function exists to help dev_pick_tx get the correct | ||
3687 | * destination queue. Using a helper function skips a call to | 3633 | * destination queue. Using a helper function skips a call to |
3688 | * skb_tx_hash and will put the skbs in the queue we expect on their | 3634 | * skb_tx_hash and will put the skbs in the queue we expect on their |
3689 | * way down to the bonding driver. | 3635 | * way down to the bonding driver. |
3690 | */ | 3636 | */ |
3691 | u16 txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) : 0; | 3637 | u16 txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) : 0; |
3692 | 3638 | ||
3693 | /* | 3639 | /* Save the original txq to restore before passing to the driver */ |
3694 | * Save the original txq to restore before passing to the driver | ||
3695 | */ | ||
3696 | qdisc_skb_cb(skb)->slave_dev_queue_mapping = skb->queue_mapping; | 3640 | qdisc_skb_cb(skb)->slave_dev_queue_mapping = skb->queue_mapping; |
3697 | 3641 | ||
3698 | if (unlikely(txq >= dev->real_num_tx_queues)) { | 3642 | if (unlikely(txq >= dev->real_num_tx_queues)) { |
@@ -3740,8 +3684,7 @@ static netdev_tx_t bond_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3740 | struct bonding *bond = netdev_priv(dev); | 3684 | struct bonding *bond = netdev_priv(dev); |
3741 | netdev_tx_t ret = NETDEV_TX_OK; | 3685 | netdev_tx_t ret = NETDEV_TX_OK; |
3742 | 3686 | ||
3743 | /* | 3687 | /* If we risk deadlock from transmitting this in the |
3744 | * If we risk deadlock from transmitting this in the | ||
3745 | * netpoll path, tell netpoll to queue the frame for later tx | 3688 | * netpoll path, tell netpoll to queue the frame for later tx |
3746 | */ | 3689 | */ |
3747 | if (unlikely(is_netpoll_tx_blocked(dev))) | 3690 | if (unlikely(is_netpoll_tx_blocked(dev))) |
@@ -3865,8 +3808,7 @@ void bond_setup(struct net_device *bond_dev) | |||
3865 | bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT; | 3808 | bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT; |
3866 | bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); | 3809 | bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); |
3867 | 3810 | ||
3868 | /* don't acquire bond device's netif_tx_lock when | 3811 | /* don't acquire bond device's netif_tx_lock when transmitting */ |
3869 | * transmitting */ | ||
3870 | bond_dev->features |= NETIF_F_LLTX; | 3812 | bond_dev->features |= NETIF_F_LLTX; |
3871 | 3813 | ||
3872 | /* By default, we declare the bond to be fully | 3814 | /* By default, we declare the bond to be fully |
@@ -3889,10 +3831,9 @@ void bond_setup(struct net_device *bond_dev) | |||
3889 | bond_dev->features |= bond_dev->hw_features; | 3831 | bond_dev->features |= bond_dev->hw_features; |
3890 | } | 3832 | } |
3891 | 3833 | ||
3892 | /* | 3834 | /* Destroy a bonding device. |
3893 | * Destroy a bonding device. | 3835 | * Must be under rtnl_lock when this function is called. |
3894 | * Must be under rtnl_lock when this function is called. | 3836 | */ |
3895 | */ | ||
3896 | static void bond_uninit(struct net_device *bond_dev) | 3837 | static void bond_uninit(struct net_device *bond_dev) |
3897 | { | 3838 | { |
3898 | struct bonding *bond = netdev_priv(bond_dev); | 3839 | struct bonding *bond = netdev_priv(bond_dev); |
@@ -3920,9 +3861,7 @@ static int bond_check_params(struct bond_params *params) | |||
3920 | const struct bond_opt_value *valptr; | 3861 | const struct bond_opt_value *valptr; |
3921 | int arp_all_targets_value; | 3862 | int arp_all_targets_value; |
3922 | 3863 | ||
3923 | /* | 3864 | /* Convert string parameters. */ |
3924 | * Convert string parameters. | ||
3925 | */ | ||
3926 | if (mode) { | 3865 | if (mode) { |
3927 | bond_opt_initstr(&newval, mode); | 3866 | bond_opt_initstr(&newval, mode); |
3928 | valptr = bond_opt_parse(bond_opt_get(BOND_OPT_MODE), &newval); | 3867 | valptr = bond_opt_parse(bond_opt_get(BOND_OPT_MODE), &newval); |
@@ -4099,9 +4038,9 @@ static int bond_check_params(struct bond_params *params) | |||
4099 | 4038 | ||
4100 | for (arp_ip_count = 0, i = 0; | 4039 | for (arp_ip_count = 0, i = 0; |
4101 | (arp_ip_count < BOND_MAX_ARP_TARGETS) && arp_ip_target[i]; i++) { | 4040 | (arp_ip_count < BOND_MAX_ARP_TARGETS) && arp_ip_target[i]; i++) { |
4102 | /* not complete check, but should be good enough to | ||
4103 | catch mistakes */ | ||
4104 | __be32 ip; | 4041 | __be32 ip; |
4042 | |||
4043 | /* not a complete check, but good enough to catch mistakes */ | ||
4105 | if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || | 4044 | if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || |
4106 | !bond_is_ip_target_ok(ip)) { | 4045 | !bond_is_ip_target_ok(ip)) { |
4107 | pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", | 4046 | pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", |
@@ -4284,9 +4223,7 @@ static void bond_set_lockdep_class(struct net_device *dev) | |||
4284 | dev->qdisc_tx_busylock = &bonding_tx_busylock_key; | 4223 | dev->qdisc_tx_busylock = &bonding_tx_busylock_key; |
4285 | } | 4224 | } |
4286 | 4225 | ||
4287 | /* | 4226 | /* Called from registration process */ |
4288 | * Called from registration process | ||
4289 | */ | ||
4290 | static int bond_init(struct net_device *bond_dev) | 4227 | static int bond_init(struct net_device *bond_dev) |
4291 | { | 4228 | { |
4292 | struct bonding *bond = netdev_priv(bond_dev); | 4229 | struct bonding *bond = netdev_priv(bond_dev); |
@@ -4440,9 +4377,7 @@ static void __exit bonding_exit(void) | |||
4440 | unregister_pernet_subsys(&bond_net_ops); | 4377 | unregister_pernet_subsys(&bond_net_ops); |
4441 | 4378 | ||
4442 | #ifdef CONFIG_NET_POLL_CONTROLLER | 4379 | #ifdef CONFIG_NET_POLL_CONTROLLER |
4443 | /* | 4380 | /* Make sure we don't have an imbalance on our netpoll blocking */ |
4444 | * Make sure we don't have an imbalance on our netpoll blocking | ||
4445 | */ | ||
4446 | WARN_ON(atomic_read(&netpoll_block_tx)); | 4381 | WARN_ON(atomic_read(&netpoll_block_tx)); |
4447 | #endif | 4382 | #endif |
4448 | } | 4383 | } |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 5555517284db..8ffbafd500fd 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -91,7 +91,6 @@ static struct net_device *bond_get_by_name(struct bond_net *bn, const char *ifna | |||
91 | * creates and deletes entire bonds. | 91 | * creates and deletes entire bonds. |
92 | * | 92 | * |
93 | * The class parameter is ignored. | 93 | * The class parameter is ignored. |
94 | * | ||
95 | */ | 94 | */ |
96 | static ssize_t bonding_store_bonds(struct class *cls, | 95 | static ssize_t bonding_store_bonds(struct class *cls, |
97 | struct class_attribute *attr, | 96 | struct class_attribute *attr, |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 3aff1a815e89..6140bf0264a4 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -197,7 +197,8 @@ struct bonding { | |||
197 | struct slave *); | 197 | struct slave *); |
198 | /* mode_lock is used for mode-specific locking needs, currently used by: | 198 | /* mode_lock is used for mode-specific locking needs, currently used by: |
199 | * 3ad mode (4) - protect against running bond_3ad_unbind_slave() and | 199 | * 3ad mode (4) - protect against running bond_3ad_unbind_slave() and |
200 | * bond_3ad_state_machine_handler() concurrently. | 200 | * bond_3ad_state_machine_handler() concurrently and also |
201 | * the access to the state machine shared variables. | ||
201 | * TLB mode (5) - to sync the use and modifications of its hash table | 202 | * TLB mode (5) - to sync the use and modifications of its hash table |
202 | * ALB mode (6) - to sync the use and modifications of its hash table | 203 | * ALB mode (6) - to sync the use and modifications of its hash table |
203 | */ | 204 | */ |