diff options
author | David S. Miller <davem@davemloft.net> | 2014-05-16 16:34:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-16 16:34:43 -0400 |
commit | bd508065749fcaa99f6eca927530d0d7e019224f (patch) | |
tree | c6ad54191e3ed0afc12f62cd5f546189058ec096 | |
parent | 31ff6aa5c86f7564f0dd97c5b3e1404cad238d00 (diff) | |
parent | 8557cd74ca8af9a71ae19d445e33d92bd50a6dc5 (diff) |
Merge branch 'bonding-next'
Veaceslav Falico says:
====================
bonding: simple macro cleanup
Trivial patchset that converts most of the bonding's macros into inline
functions. It introduces only one macro, BOND_MODE(), which is just
bond->params.mode, better to write/understand/remember.
The only real change is the removal of IFF_UP verification, which always
came in pair with && netif_running(), and is though useless, as it's always
IFF_UP when LINK_STATE_RUNNING.
v2->v3: fix 3/9 to actually invert bond_mode_uses_arp() and add
bond_uses_arp() alongside bond_mode_uses_arp()
v1->v2: use inlined functions instead of macros.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 6 | ||||
-rw-r--r-- | drivers/net/bonding/bond_alb.c | 18 | ||||
-rw-r--r-- | drivers/net/bonding/bond_debugfs.c | 2 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 143 | ||||
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 6 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 10 | ||||
-rw-r--r-- | drivers/net/bonding/bond_procfs.c | 14 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 14 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs_slave.c | 2 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 89 |
10 files changed, 150 insertions, 154 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index 24faddddf11e..0dfeaf5da3f2 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -192,7 +192,7 @@ static inline void __enable_port(struct port *port) | |||
192 | { | 192 | { |
193 | struct slave *slave = port->slave; | 193 | struct slave *slave = port->slave; |
194 | 194 | ||
195 | if ((slave->link == BOND_LINK_UP) && IS_UP(slave->dev)) | 195 | if ((slave->link == BOND_LINK_UP) && bond_slave_is_up(slave)) |
196 | bond_set_slave_active_flags(slave, BOND_SLAVE_NOTIFY_LATER); | 196 | bond_set_slave_active_flags(slave, BOND_SLAVE_NOTIFY_LATER); |
197 | } | 197 | } |
198 | 198 | ||
@@ -2449,13 +2449,13 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2449 | continue; | 2449 | continue; |
2450 | 2450 | ||
2451 | if (slave_agg_no >= 0) { | 2451 | if (slave_agg_no >= 0) { |
2452 | if (!first_ok_slave && SLAVE_IS_OK(slave)) | 2452 | if (!first_ok_slave && bond_slave_can_tx(slave)) |
2453 | first_ok_slave = slave; | 2453 | first_ok_slave = slave; |
2454 | slave_agg_no--; | 2454 | slave_agg_no--; |
2455 | continue; | 2455 | continue; |
2456 | } | 2456 | } |
2457 | 2457 | ||
2458 | if (SLAVE_IS_OK(slave)) { | 2458 | if (bond_slave_can_tx(slave)) { |
2459 | bond_dev_queue_xmit(bond, skb, slave->dev); | 2459 | bond_dev_queue_xmit(bond, skb, slave->dev); |
2460 | goto out; | 2460 | goto out; |
2461 | } | 2461 | } |
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 70de039dad2e..03e0bcade234 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -228,7 +228,7 @@ static struct slave *tlb_get_least_loaded_slave(struct bonding *bond) | |||
228 | 228 | ||
229 | /* Find the slave with the largest gap */ | 229 | /* Find the slave with the largest gap */ |
230 | bond_for_each_slave_rcu(bond, slave, iter) { | 230 | bond_for_each_slave_rcu(bond, slave, iter) { |
231 | if (SLAVE_IS_OK(slave)) { | 231 | if (bond_slave_can_tx(slave)) { |
232 | long long gap = compute_gap(slave); | 232 | long long gap = compute_gap(slave); |
233 | 233 | ||
234 | if (max_gap < gap) { | 234 | if (max_gap < gap) { |
@@ -383,7 +383,7 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond) | |||
383 | bool found = false; | 383 | bool found = false; |
384 | 384 | ||
385 | bond_for_each_slave(bond, slave, iter) { | 385 | bond_for_each_slave(bond, slave, iter) { |
386 | if (!SLAVE_IS_OK(slave)) | 386 | if (!bond_slave_can_tx(slave)) |
387 | continue; | 387 | continue; |
388 | if (!found) { | 388 | if (!found) { |
389 | if (!before || before->speed < slave->speed) | 389 | if (!before || before->speed < slave->speed) |
@@ -416,7 +416,7 @@ static struct slave *__rlb_next_rx_slave(struct bonding *bond) | |||
416 | bool found = false; | 416 | bool found = false; |
417 | 417 | ||
418 | bond_for_each_slave_rcu(bond, slave, iter) { | 418 | bond_for_each_slave_rcu(bond, slave, iter) { |
419 | if (!SLAVE_IS_OK(slave)) | 419 | if (!bond_slave_can_tx(slave)) |
420 | continue; | 420 | continue; |
421 | if (!found) { | 421 | if (!found) { |
422 | if (!before || before->speed < slave->speed) | 422 | if (!before || before->speed < slave->speed) |
@@ -1057,7 +1057,7 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[]) | |||
1057 | struct net_device *dev = slave->dev; | 1057 | struct net_device *dev = slave->dev; |
1058 | struct sockaddr s_addr; | 1058 | struct sockaddr s_addr; |
1059 | 1059 | ||
1060 | if (slave->bond->params.mode == BOND_MODE_TLB) { | 1060 | if (BOND_MODE(slave->bond) == BOND_MODE_TLB) { |
1061 | memcpy(dev->dev_addr, addr, dev->addr_len); | 1061 | memcpy(dev->dev_addr, addr, dev->addr_len); |
1062 | return 0; | 1062 | return 0; |
1063 | } | 1063 | } |
@@ -1100,13 +1100,13 @@ static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2) | |||
1100 | static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, | 1100 | static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, |
1101 | struct slave *slave2) | 1101 | struct slave *slave2) |
1102 | { | 1102 | { |
1103 | int slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2)); | 1103 | int slaves_state_differ = (bond_slave_can_tx(slave1) != bond_slave_can_tx(slave2)); |
1104 | struct slave *disabled_slave = NULL; | 1104 | struct slave *disabled_slave = NULL; |
1105 | 1105 | ||
1106 | ASSERT_RTNL(); | 1106 | ASSERT_RTNL(); |
1107 | 1107 | ||
1108 | /* fasten the change in the switch */ | 1108 | /* fasten the change in the switch */ |
1109 | if (SLAVE_IS_OK(slave1)) { | 1109 | if (bond_slave_can_tx(slave1)) { |
1110 | alb_send_learning_packets(slave1, slave1->dev->dev_addr); | 1110 | alb_send_learning_packets(slave1, slave1->dev->dev_addr); |
1111 | if (bond->alb_info.rlb_enabled) { | 1111 | if (bond->alb_info.rlb_enabled) { |
1112 | /* inform the clients that the mac address | 1112 | /* inform the clients that the mac address |
@@ -1118,7 +1118,7 @@ static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, | |||
1118 | disabled_slave = slave1; | 1118 | disabled_slave = slave1; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | if (SLAVE_IS_OK(slave2)) { | 1121 | if (bond_slave_can_tx(slave2)) { |
1122 | alb_send_learning_packets(slave2, slave2->dev->dev_addr); | 1122 | alb_send_learning_packets(slave2, slave2->dev->dev_addr); |
1123 | if (bond->alb_info.rlb_enabled) { | 1123 | if (bond->alb_info.rlb_enabled) { |
1124 | /* inform the clients that the mac address | 1124 | /* inform the clients that the mac address |
@@ -1360,7 +1360,7 @@ static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, | |||
1360 | bond_info->unbalanced_load += skb->len; | 1360 | bond_info->unbalanced_load += skb->len; |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | if (tx_slave && SLAVE_IS_OK(tx_slave)) { | 1363 | if (tx_slave && bond_slave_can_tx(tx_slave)) { |
1364 | if (tx_slave != rcu_dereference(bond->curr_active_slave)) { | 1364 | if (tx_slave != rcu_dereference(bond->curr_active_slave)) { |
1365 | ether_addr_copy(eth_data->h_source, | 1365 | ether_addr_copy(eth_data->h_source, |
1366 | tx_slave->dev->dev_addr); | 1366 | tx_slave->dev->dev_addr); |
@@ -1745,7 +1745,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave | |||
1745 | /* in TLB mode, the slave might flip down/up with the old dev_addr, | 1745 | /* in TLB mode, the slave might flip down/up with the old dev_addr, |
1746 | * and thus filter bond->dev_addr's packets, so force bond's mac | 1746 | * and thus filter bond->dev_addr's packets, so force bond's mac |
1747 | */ | 1747 | */ |
1748 | if (bond->params.mode == BOND_MODE_TLB) { | 1748 | if (BOND_MODE(bond) == BOND_MODE_TLB) { |
1749 | struct sockaddr sa; | 1749 | struct sockaddr sa; |
1750 | u8 tmp_addr[ETH_ALEN]; | 1750 | u8 tmp_addr[ETH_ALEN]; |
1751 | 1751 | ||
diff --git a/drivers/net/bonding/bond_debugfs.c b/drivers/net/bonding/bond_debugfs.c index 2d3f7fa541ff..658e761c4568 100644 --- a/drivers/net/bonding/bond_debugfs.c +++ b/drivers/net/bonding/bond_debugfs.c | |||
@@ -23,7 +23,7 @@ static int bond_debug_rlb_hash_show(struct seq_file *m, void *v) | |||
23 | struct rlb_client_info *client_info; | 23 | struct rlb_client_info *client_info; |
24 | u32 hash_index; | 24 | u32 hash_index; |
25 | 25 | ||
26 | if (bond->params.mode != BOND_MODE_ALB) | 26 | if (BOND_MODE(bond) != BOND_MODE_ALB) |
27 | return 0; | 27 | return 0; |
28 | 28 | ||
29 | seq_printf(m, "SourceIP DestinationIP " | 29 | seq_printf(m, "SourceIP DestinationIP " |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 90ebed6b3df6..712320532105 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -343,7 +343,7 @@ static int bond_set_carrier(struct bonding *bond) | |||
343 | if (!bond_has_slaves(bond)) | 343 | if (!bond_has_slaves(bond)) |
344 | goto down; | 344 | goto down; |
345 | 345 | ||
346 | if (bond->params.mode == BOND_MODE_8023AD) | 346 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
347 | return bond_3ad_set_carrier(bond); | 347 | return bond_3ad_set_carrier(bond); |
348 | 348 | ||
349 | bond_for_each_slave(bond, slave, iter) { | 349 | bond_for_each_slave(bond, slave, iter) { |
@@ -497,7 +497,7 @@ static int bond_set_promiscuity(struct bonding *bond, int inc) | |||
497 | struct list_head *iter; | 497 | struct list_head *iter; |
498 | int err = 0; | 498 | int err = 0; |
499 | 499 | ||
500 | if (USES_PRIMARY(bond->params.mode)) { | 500 | if (bond_uses_primary(bond)) { |
501 | /* write lock already acquired */ | 501 | /* write lock already acquired */ |
502 | if (bond->curr_active_slave) { | 502 | if (bond->curr_active_slave) { |
503 | err = dev_set_promiscuity(bond->curr_active_slave->dev, | 503 | err = dev_set_promiscuity(bond->curr_active_slave->dev, |
@@ -523,7 +523,7 @@ static int bond_set_allmulti(struct bonding *bond, int inc) | |||
523 | struct list_head *iter; | 523 | struct list_head *iter; |
524 | int err = 0; | 524 | int err = 0; |
525 | 525 | ||
526 | if (USES_PRIMARY(bond->params.mode)) { | 526 | if (bond_uses_primary(bond)) { |
527 | /* write lock already acquired */ | 527 | /* write lock already acquired */ |
528 | if (bond->curr_active_slave) { | 528 | if (bond->curr_active_slave) { |
529 | err = dev_set_allmulti(bond->curr_active_slave->dev, | 529 | err = dev_set_allmulti(bond->curr_active_slave->dev, |
@@ -574,7 +574,7 @@ static void bond_hw_addr_flush(struct net_device *bond_dev, | |||
574 | dev_uc_unsync(slave_dev, bond_dev); | 574 | dev_uc_unsync(slave_dev, bond_dev); |
575 | dev_mc_unsync(slave_dev, bond_dev); | 575 | dev_mc_unsync(slave_dev, bond_dev); |
576 | 576 | ||
577 | if (bond->params.mode == BOND_MODE_8023AD) { | 577 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
578 | /* del lacpdu mc addr from mc list */ | 578 | /* del lacpdu mc addr from mc list */ |
579 | u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; | 579 | u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; |
580 | 580 | ||
@@ -585,8 +585,8 @@ static void bond_hw_addr_flush(struct net_device *bond_dev, | |||
585 | /*--------------------------- Active slave change ---------------------------*/ | 585 | /*--------------------------- Active slave change ---------------------------*/ |
586 | 586 | ||
587 | /* Update the hardware address list and promisc/allmulti for the new and | 587 | /* Update the hardware address list and promisc/allmulti for the new and |
588 | * old active slaves (if any). Modes that are !USES_PRIMARY keep all | 588 | * old active slaves (if any). Modes that are not using primary keep all |
589 | * slaves up date at all times; only the USES_PRIMARY modes need to call | 589 | * slaves up date at all times; only the modes that use primary need to call |
590 | * this function to swap these settings during a failover. | 590 | * this function to swap these settings during a failover. |
591 | */ | 591 | */ |
592 | static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, | 592 | static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active, |
@@ -747,7 +747,7 @@ static struct slave *bond_find_best_slave(struct bonding *bond) | |||
747 | bond_for_each_slave(bond, slave, iter) { | 747 | bond_for_each_slave(bond, slave, iter) { |
748 | if (slave->link == BOND_LINK_UP) | 748 | if (slave->link == BOND_LINK_UP) |
749 | return slave; | 749 | return slave; |
750 | if (slave->link == BOND_LINK_BACK && IS_UP(slave->dev) && | 750 | if (slave->link == BOND_LINK_BACK && bond_slave_is_up(slave) && |
751 | slave->delay < mintime) { | 751 | slave->delay < mintime) { |
752 | mintime = slave->delay; | 752 | mintime = slave->delay; |
753 | bestslave = slave; | 753 | bestslave = slave; |
@@ -801,7 +801,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | |||
801 | new_active->last_link_up = jiffies; | 801 | new_active->last_link_up = jiffies; |
802 | 802 | ||
803 | if (new_active->link == BOND_LINK_BACK) { | 803 | if (new_active->link == BOND_LINK_BACK) { |
804 | if (USES_PRIMARY(bond->params.mode)) { | 804 | if (bond_uses_primary(bond)) { |
805 | pr_info("%s: making interface %s the new active one %d ms earlier\n", | 805 | pr_info("%s: making interface %s the new active one %d ms earlier\n", |
806 | bond->dev->name, new_active->dev->name, | 806 | bond->dev->name, new_active->dev->name, |
807 | (bond->params.updelay - new_active->delay) * bond->params.miimon); | 807 | (bond->params.updelay - new_active->delay) * bond->params.miimon); |
@@ -810,20 +810,20 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | |||
810 | new_active->delay = 0; | 810 | new_active->delay = 0; |
811 | new_active->link = BOND_LINK_UP; | 811 | new_active->link = BOND_LINK_UP; |
812 | 812 | ||
813 | if (bond->params.mode == BOND_MODE_8023AD) | 813 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
814 | bond_3ad_handle_link_change(new_active, BOND_LINK_UP); | 814 | bond_3ad_handle_link_change(new_active, BOND_LINK_UP); |
815 | 815 | ||
816 | if (bond_is_lb(bond)) | 816 | if (bond_is_lb(bond)) |
817 | bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP); | 817 | bond_alb_handle_link_change(bond, new_active, BOND_LINK_UP); |
818 | } else { | 818 | } else { |
819 | if (USES_PRIMARY(bond->params.mode)) { | 819 | if (bond_uses_primary(bond)) { |
820 | pr_info("%s: making interface %s the new active one\n", | 820 | pr_info("%s: making interface %s the new active one\n", |
821 | bond->dev->name, new_active->dev->name); | 821 | bond->dev->name, new_active->dev->name); |
822 | } | 822 | } |
823 | } | 823 | } |
824 | } | 824 | } |
825 | 825 | ||
826 | if (USES_PRIMARY(bond->params.mode)) | 826 | if (bond_uses_primary(bond)) |
827 | bond_hw_addr_swap(bond, new_active, old_active); | 827 | bond_hw_addr_swap(bond, new_active, old_active); |
828 | 828 | ||
829 | if (bond_is_lb(bond)) { | 829 | if (bond_is_lb(bond)) { |
@@ -838,7 +838,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | |||
838 | rcu_assign_pointer(bond->curr_active_slave, new_active); | 838 | rcu_assign_pointer(bond->curr_active_slave, new_active); |
839 | } | 839 | } |
840 | 840 | ||
841 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { | 841 | if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) { |
842 | if (old_active) | 842 | if (old_active) |
843 | bond_set_slave_inactive_flags(old_active, | 843 | bond_set_slave_inactive_flags(old_active, |
844 | BOND_SLAVE_NOTIFY_NOW); | 844 | BOND_SLAVE_NOTIFY_NOW); |
@@ -876,8 +876,8 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active) | |||
876 | * resend only if bond is brought up with the affected | 876 | * resend only if bond is brought up with the affected |
877 | * bonding modes and the retransmission is enabled */ | 877 | * bonding modes and the retransmission is enabled */ |
878 | if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) && | 878 | if (netif_running(bond->dev) && (bond->params.resend_igmp > 0) && |
879 | ((USES_PRIMARY(bond->params.mode) && new_active) || | 879 | ((bond_uses_primary(bond) && new_active) || |
880 | bond->params.mode == BOND_MODE_ROUNDROBIN)) { | 880 | BOND_MODE(bond) == BOND_MODE_ROUNDROBIN)) { |
881 | bond->igmp_retrans = bond->params.resend_igmp; | 881 | bond->igmp_retrans = bond->params.resend_igmp; |
882 | queue_delayed_work(bond->wq, &bond->mcast_work, 1); | 882 | queue_delayed_work(bond->wq, &bond->mcast_work, 1); |
883 | } | 883 | } |
@@ -958,7 +958,7 @@ static void bond_netpoll_cleanup(struct net_device *bond_dev) | |||
958 | struct slave *slave; | 958 | struct slave *slave; |
959 | 959 | ||
960 | bond_for_each_slave(bond, slave, iter) | 960 | bond_for_each_slave(bond, slave, iter) |
961 | if (IS_UP(slave->dev)) | 961 | if (bond_slave_is_up(slave)) |
962 | slave_disable_netpoll(slave); | 962 | slave_disable_netpoll(slave); |
963 | } | 963 | } |
964 | 964 | ||
@@ -1084,7 +1084,7 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, | |||
1084 | struct bonding *bond) | 1084 | struct bonding *bond) |
1085 | { | 1085 | { |
1086 | if (bond_is_slave_inactive(slave)) { | 1086 | if (bond_is_slave_inactive(slave)) { |
1087 | if (bond->params.mode == BOND_MODE_ALB && | 1087 | if (BOND_MODE(bond) == BOND_MODE_ALB && |
1088 | skb->pkt_type != PACKET_BROADCAST && | 1088 | skb->pkt_type != PACKET_BROADCAST && |
1089 | skb->pkt_type != PACKET_MULTICAST) | 1089 | skb->pkt_type != PACKET_MULTICAST) |
1090 | return false; | 1090 | return false; |
@@ -1126,7 +1126,7 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb) | |||
1126 | 1126 | ||
1127 | skb->dev = bond->dev; | 1127 | skb->dev = bond->dev; |
1128 | 1128 | ||
1129 | if (bond->params.mode == BOND_MODE_ALB && | 1129 | if (BOND_MODE(bond) == BOND_MODE_ALB && |
1130 | bond->dev->priv_flags & IFF_BRIDGE_PORT && | 1130 | bond->dev->priv_flags & IFF_BRIDGE_PORT && |
1131 | skb->pkt_type == PACKET_HOST) { | 1131 | skb->pkt_type == PACKET_HOST) { |
1132 | 1132 | ||
@@ -1171,7 +1171,7 @@ static struct slave *bond_alloc_slave(struct bonding *bond) | |||
1171 | if (!slave) | 1171 | if (!slave) |
1172 | return NULL; | 1172 | return NULL; |
1173 | 1173 | ||
1174 | if (bond->params.mode == BOND_MODE_8023AD) { | 1174 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
1175 | SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info), | 1175 | SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info), |
1176 | GFP_KERNEL); | 1176 | GFP_KERNEL); |
1177 | if (!SLAVE_AD_INFO(slave)) { | 1177 | if (!SLAVE_AD_INFO(slave)) { |
@@ -1186,7 +1186,7 @@ static void bond_free_slave(struct slave *slave) | |||
1186 | { | 1186 | { |
1187 | struct bonding *bond = bond_get_bond_by_slave(slave); | 1187 | struct bonding *bond = bond_get_bond_by_slave(slave); |
1188 | 1188 | ||
1189 | if (bond->params.mode == BOND_MODE_8023AD) | 1189 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
1190 | kfree(SLAVE_AD_INFO(slave)); | 1190 | kfree(SLAVE_AD_INFO(slave)); |
1191 | 1191 | ||
1192 | kfree(slave); | 1192 | kfree(slave); |
@@ -1298,7 +1298,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1298 | if (!bond_has_slaves(bond)) { | 1298 | if (!bond_has_slaves(bond)) { |
1299 | pr_warn("%s: Warning: The first slave device specified does not support setting the MAC address\n", | 1299 | pr_warn("%s: Warning: The first slave device specified does not support setting the MAC address\n", |
1300 | bond_dev->name); | 1300 | bond_dev->name); |
1301 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { | 1301 | if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) { |
1302 | bond->params.fail_over_mac = BOND_FOM_ACTIVE; | 1302 | bond->params.fail_over_mac = BOND_FOM_ACTIVE; |
1303 | pr_warn("%s: Setting fail_over_mac to active for active-backup mode\n", | 1303 | pr_warn("%s: Setting fail_over_mac to active for active-backup mode\n", |
1304 | bond_dev->name); | 1304 | bond_dev->name); |
@@ -1347,7 +1347,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1347 | ether_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr); | 1347 | ether_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr); |
1348 | 1348 | ||
1349 | if (!bond->params.fail_over_mac || | 1349 | if (!bond->params.fail_over_mac || |
1350 | bond->params.mode != BOND_MODE_ACTIVEBACKUP) { | 1350 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1351 | /* | 1351 | /* |
1352 | * Set slave to master's mac address. The application already | 1352 | * Set slave to master's mac address. The application already |
1353 | * set the master's mac address to that of the first slave | 1353 | * set the master's mac address to that of the first slave |
@@ -1381,10 +1381,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1381 | goto err_close; | 1381 | goto err_close; |
1382 | } | 1382 | } |
1383 | 1383 | ||
1384 | /* If the mode USES_PRIMARY, then the following is handled by | 1384 | /* If the mode uses primary, then the following is handled by |
1385 | * bond_change_active_slave(). | 1385 | * bond_change_active_slave(). |
1386 | */ | 1386 | */ |
1387 | if (!USES_PRIMARY(bond->params.mode)) { | 1387 | if (!bond_uses_primary(bond)) { |
1388 | /* set promiscuity level to new slave */ | 1388 | /* set promiscuity level to new slave */ |
1389 | if (bond_dev->flags & IFF_PROMISC) { | 1389 | if (bond_dev->flags & IFF_PROMISC) { |
1390 | res = dev_set_promiscuity(slave_dev, 1); | 1390 | res = dev_set_promiscuity(slave_dev, 1); |
@@ -1407,7 +1407,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1407 | netif_addr_unlock_bh(bond_dev); | 1407 | netif_addr_unlock_bh(bond_dev); |
1408 | } | 1408 | } |
1409 | 1409 | ||
1410 | if (bond->params.mode == BOND_MODE_8023AD) { | 1410 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
1411 | /* add lacpdu mc addr to mc list */ | 1411 | /* add lacpdu mc addr to mc list */ |
1412 | u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; | 1412 | u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; |
1413 | 1413 | ||
@@ -1480,7 +1480,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1480 | new_slave->link == BOND_LINK_DOWN ? "DOWN" : | 1480 | new_slave->link == BOND_LINK_DOWN ? "DOWN" : |
1481 | (new_slave->link == BOND_LINK_UP ? "UP" : "BACK")); | 1481 | (new_slave->link == BOND_LINK_UP ? "UP" : "BACK")); |
1482 | 1482 | ||
1483 | if (USES_PRIMARY(bond->params.mode) && bond->params.primary[0]) { | 1483 | if (bond_uses_primary(bond) && bond->params.primary[0]) { |
1484 | /* if there is a primary slave, remember it */ | 1484 | /* if there is a primary slave, remember it */ |
1485 | if (strcmp(bond->params.primary, new_slave->dev->name) == 0) { | 1485 | if (strcmp(bond->params.primary, new_slave->dev->name) == 0) { |
1486 | bond->primary_slave = new_slave; | 1486 | bond->primary_slave = new_slave; |
@@ -1488,7 +1488,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1488 | } | 1488 | } |
1489 | } | 1489 | } |
1490 | 1490 | ||
1491 | switch (bond->params.mode) { | 1491 | switch (BOND_MODE(bond)) { |
1492 | case BOND_MODE_ACTIVEBACKUP: | 1492 | case BOND_MODE_ACTIVEBACKUP: |
1493 | bond_set_slave_inactive_flags(new_slave, | 1493 | bond_set_slave_inactive_flags(new_slave, |
1494 | BOND_SLAVE_NOTIFY_NOW); | 1494 | BOND_SLAVE_NOTIFY_NOW); |
@@ -1569,7 +1569,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1569 | bond_compute_features(bond); | 1569 | bond_compute_features(bond); |
1570 | bond_set_carrier(bond); | 1570 | bond_set_carrier(bond); |
1571 | 1571 | ||
1572 | if (USES_PRIMARY(bond->params.mode)) { | 1572 | if (bond_uses_primary(bond)) { |
1573 | block_netpoll_tx(); | 1573 | block_netpoll_tx(); |
1574 | write_lock_bh(&bond->curr_slave_lock); | 1574 | write_lock_bh(&bond->curr_slave_lock); |
1575 | bond_select_active_slave(bond); | 1575 | bond_select_active_slave(bond); |
@@ -1593,7 +1593,7 @@ err_unregister: | |||
1593 | netdev_rx_handler_unregister(slave_dev); | 1593 | netdev_rx_handler_unregister(slave_dev); |
1594 | 1594 | ||
1595 | err_detach: | 1595 | err_detach: |
1596 | if (!USES_PRIMARY(bond->params.mode)) | 1596 | if (!bond_uses_primary(bond)) |
1597 | bond_hw_addr_flush(bond_dev, slave_dev); | 1597 | bond_hw_addr_flush(bond_dev, slave_dev); |
1598 | 1598 | ||
1599 | vlan_vids_del_by_dev(slave_dev, bond_dev); | 1599 | vlan_vids_del_by_dev(slave_dev, bond_dev); |
@@ -1615,7 +1615,7 @@ err_close: | |||
1615 | 1615 | ||
1616 | err_restore_mac: | 1616 | err_restore_mac: |
1617 | if (!bond->params.fail_over_mac || | 1617 | if (!bond->params.fail_over_mac || |
1618 | bond->params.mode != BOND_MODE_ACTIVEBACKUP) { | 1618 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1619 | /* XXX TODO - fom follow mode needs to change master's | 1619 | /* XXX TODO - fom follow mode needs to change master's |
1620 | * MAC if this slave's MAC is in use by the bond, or at | 1620 | * MAC if this slave's MAC is in use by the bond, or at |
1621 | * least print a warning. | 1621 | * least print a warning. |
@@ -1691,7 +1691,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1691 | write_lock_bh(&bond->lock); | 1691 | write_lock_bh(&bond->lock); |
1692 | 1692 | ||
1693 | /* Inform AD package of unbinding of slave. */ | 1693 | /* Inform AD package of unbinding of slave. */ |
1694 | if (bond->params.mode == BOND_MODE_8023AD) | 1694 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
1695 | bond_3ad_unbind_slave(slave); | 1695 | bond_3ad_unbind_slave(slave); |
1696 | 1696 | ||
1697 | write_unlock_bh(&bond->lock); | 1697 | write_unlock_bh(&bond->lock); |
@@ -1706,7 +1706,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1706 | bond->current_arp_slave = NULL; | 1706 | bond->current_arp_slave = NULL; |
1707 | 1707 | ||
1708 | if (!all && (!bond->params.fail_over_mac || | 1708 | if (!all && (!bond->params.fail_over_mac || |
1709 | bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { | 1709 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP)) { |
1710 | if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && | 1710 | if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && |
1711 | bond_has_slaves(bond)) | 1711 | bond_has_slaves(bond)) |
1712 | pr_warn("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s - set the HWaddr of %s to a different address to avoid conflicts\n", | 1712 | pr_warn("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s - set the HWaddr of %s to a different address to avoid conflicts\n", |
@@ -1778,10 +1778,10 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1778 | /* must do this from outside any spinlocks */ | 1778 | /* must do this from outside any spinlocks */ |
1779 | vlan_vids_del_by_dev(slave_dev, bond_dev); | 1779 | vlan_vids_del_by_dev(slave_dev, bond_dev); |
1780 | 1780 | ||
1781 | /* If the mode USES_PRIMARY, then this cases was handled above by | 1781 | /* If the mode uses primary, then this cases was handled above by |
1782 | * bond_change_active_slave(..., NULL) | 1782 | * bond_change_active_slave(..., NULL) |
1783 | */ | 1783 | */ |
1784 | if (!USES_PRIMARY(bond->params.mode)) { | 1784 | if (!bond_uses_primary(bond)) { |
1785 | /* unset promiscuity level from slave | 1785 | /* unset promiscuity level from slave |
1786 | * NOTE: The NETDEV_CHANGEADDR call above may change the value | 1786 | * NOTE: The NETDEV_CHANGEADDR call above may change the value |
1787 | * of the IFF_PROMISC flag in the bond_dev, but we need the | 1787 | * of the IFF_PROMISC flag in the bond_dev, but we need the |
@@ -1805,7 +1805,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1805 | dev_close(slave_dev); | 1805 | dev_close(slave_dev); |
1806 | 1806 | ||
1807 | if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || | 1807 | if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || |
1808 | bond->params.mode != BOND_MODE_ACTIVEBACKUP) { | 1808 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1809 | /* restore original ("permanent") mac address */ | 1809 | /* restore original ("permanent") mac address */ |
1810 | ether_addr_copy(addr.sa_data, slave->perm_hwaddr); | 1810 | ether_addr_copy(addr.sa_data, slave->perm_hwaddr); |
1811 | addr.sa_family = slave_dev->type; | 1811 | addr.sa_family = slave_dev->type; |
@@ -1851,7 +1851,7 @@ static int bond_info_query(struct net_device *bond_dev, struct ifbond *info) | |||
1851 | { | 1851 | { |
1852 | struct bonding *bond = netdev_priv(bond_dev); | 1852 | struct bonding *bond = netdev_priv(bond_dev); |
1853 | 1853 | ||
1854 | info->bond_mode = bond->params.mode; | 1854 | info->bond_mode = BOND_MODE(bond); |
1855 | info->miimon = bond->params.miimon; | 1855 | info->miimon = bond->params.miimon; |
1856 | 1856 | ||
1857 | info->num_slaves = bond->slave_cnt; | 1857 | info->num_slaves = bond->slave_cnt; |
@@ -1907,7 +1907,7 @@ static int bond_miimon_inspect(struct bonding *bond) | |||
1907 | if (slave->delay) { | 1907 | if (slave->delay) { |
1908 | pr_info("%s: link status down for %sinterface %s, disabling it in %d ms\n", | 1908 | pr_info("%s: link status down for %sinterface %s, disabling it in %d ms\n", |
1909 | bond->dev->name, | 1909 | bond->dev->name, |
1910 | (bond->params.mode == | 1910 | (BOND_MODE(bond) == |
1911 | BOND_MODE_ACTIVEBACKUP) ? | 1911 | BOND_MODE_ACTIVEBACKUP) ? |
1912 | (bond_is_active_slave(slave) ? | 1912 | (bond_is_active_slave(slave) ? |
1913 | "active " : "backup ") : "", | 1913 | "active " : "backup ") : "", |
@@ -1998,10 +1998,10 @@ static void bond_miimon_commit(struct bonding *bond) | |||
1998 | slave->link = BOND_LINK_UP; | 1998 | slave->link = BOND_LINK_UP; |
1999 | slave->last_link_up = jiffies; | 1999 | slave->last_link_up = jiffies; |
2000 | 2000 | ||
2001 | if (bond->params.mode == BOND_MODE_8023AD) { | 2001 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
2002 | /* prevent it from being the active one */ | 2002 | /* prevent it from being the active one */ |
2003 | bond_set_backup_slave(slave); | 2003 | bond_set_backup_slave(slave); |
2004 | } else if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) { | 2004 | } else if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
2005 | /* make it immediately active */ | 2005 | /* make it immediately active */ |
2006 | bond_set_active_slave(slave); | 2006 | bond_set_active_slave(slave); |
2007 | } else if (slave != bond->primary_slave) { | 2007 | } else if (slave != bond->primary_slave) { |
@@ -2015,7 +2015,7 @@ static void bond_miimon_commit(struct bonding *bond) | |||
2015 | slave->duplex ? "full" : "half"); | 2015 | slave->duplex ? "full" : "half"); |
2016 | 2016 | ||
2017 | /* notify ad that the link status has changed */ | 2017 | /* notify ad that the link status has changed */ |
2018 | if (bond->params.mode == BOND_MODE_8023AD) | 2018 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
2019 | bond_3ad_handle_link_change(slave, BOND_LINK_UP); | 2019 | bond_3ad_handle_link_change(slave, BOND_LINK_UP); |
2020 | 2020 | ||
2021 | if (bond_is_lb(bond)) | 2021 | if (bond_is_lb(bond)) |
@@ -2034,15 +2034,15 @@ static void bond_miimon_commit(struct bonding *bond) | |||
2034 | 2034 | ||
2035 | slave->link = BOND_LINK_DOWN; | 2035 | slave->link = BOND_LINK_DOWN; |
2036 | 2036 | ||
2037 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP || | 2037 | if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP || |
2038 | bond->params.mode == BOND_MODE_8023AD) | 2038 | BOND_MODE(bond) == BOND_MODE_8023AD) |
2039 | bond_set_slave_inactive_flags(slave, | 2039 | bond_set_slave_inactive_flags(slave, |
2040 | BOND_SLAVE_NOTIFY_NOW); | 2040 | BOND_SLAVE_NOTIFY_NOW); |
2041 | 2041 | ||
2042 | pr_info("%s: link status definitely down for interface %s, disabling it\n", | 2042 | pr_info("%s: link status definitely down for interface %s, disabling it\n", |
2043 | bond->dev->name, slave->dev->name); | 2043 | bond->dev->name, slave->dev->name); |
2044 | 2044 | ||
2045 | if (bond->params.mode == BOND_MODE_8023AD) | 2045 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
2046 | bond_3ad_handle_link_change(slave, | 2046 | bond_3ad_handle_link_change(slave, |
2047 | BOND_LINK_DOWN); | 2047 | BOND_LINK_DOWN); |
2048 | 2048 | ||
@@ -2490,7 +2490,7 @@ static void bond_loadbalance_arp_mon(struct work_struct *work) | |||
2490 | * do - all replies will be rx'ed on same link causing slaves | 2490 | * do - all replies will be rx'ed on same link causing slaves |
2491 | * to be unstable during low/no traffic periods | 2491 | * to be unstable during low/no traffic periods |
2492 | */ | 2492 | */ |
2493 | if (IS_UP(slave->dev)) | 2493 | if (bond_slave_is_up(slave)) |
2494 | bond_arp_send_all(bond, slave); | 2494 | bond_arp_send_all(bond, slave); |
2495 | } | 2495 | } |
2496 | 2496 | ||
@@ -2712,10 +2712,10 @@ static bool bond_ab_arp_probe(struct bonding *bond) | |||
2712 | bond_set_slave_inactive_flags(curr_arp_slave, BOND_SLAVE_NOTIFY_LATER); | 2712 | bond_set_slave_inactive_flags(curr_arp_slave, BOND_SLAVE_NOTIFY_LATER); |
2713 | 2713 | ||
2714 | bond_for_each_slave_rcu(bond, slave, iter) { | 2714 | bond_for_each_slave_rcu(bond, slave, iter) { |
2715 | if (!found && !before && IS_UP(slave->dev)) | 2715 | if (!found && !before && bond_slave_is_up(slave)) |
2716 | before = slave; | 2716 | before = slave; |
2717 | 2717 | ||
2718 | if (found && !new_slave && IS_UP(slave->dev)) | 2718 | if (found && !new_slave && bond_slave_is_up(slave)) |
2719 | new_slave = slave; | 2719 | new_slave = slave; |
2720 | /* if the link state is up at this point, we | 2720 | /* if the link state is up at this point, we |
2721 | * mark it down - this can happen if we have | 2721 | * mark it down - this can happen if we have |
@@ -2724,7 +2724,7 @@ static bool bond_ab_arp_probe(struct bonding *bond) | |||
2724 | * one the current slave so it is still marked | 2724 | * one the current slave so it is still marked |
2725 | * up when it is actually down | 2725 | * up when it is actually down |
2726 | */ | 2726 | */ |
2727 | if (!IS_UP(slave->dev) && slave->link == BOND_LINK_UP) { | 2727 | if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { |
2728 | slave->link = BOND_LINK_DOWN; | 2728 | slave->link = BOND_LINK_DOWN; |
2729 | if (slave->link_failure_count < UINT_MAX) | 2729 | if (slave->link_failure_count < UINT_MAX) |
2730 | slave->link_failure_count++; | 2730 | slave->link_failure_count++; |
@@ -2887,7 +2887,7 @@ static int bond_slave_netdev_event(unsigned long event, | |||
2887 | 2887 | ||
2888 | bond_update_speed_duplex(slave); | 2888 | bond_update_speed_duplex(slave); |
2889 | 2889 | ||
2890 | if (bond->params.mode == BOND_MODE_8023AD) { | 2890 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
2891 | if (old_speed != slave->speed) | 2891 | if (old_speed != slave->speed) |
2892 | bond_3ad_adapter_speed_changed(slave); | 2892 | bond_3ad_adapter_speed_changed(slave); |
2893 | if (old_duplex != slave->duplex) | 2893 | if (old_duplex != slave->duplex) |
@@ -2915,7 +2915,7 @@ static int bond_slave_netdev_event(unsigned long event, | |||
2915 | break; | 2915 | break; |
2916 | case NETDEV_CHANGENAME: | 2916 | case NETDEV_CHANGENAME: |
2917 | /* we don't care if we don't have primary set */ | 2917 | /* we don't care if we don't have primary set */ |
2918 | if (!USES_PRIMARY(bond->params.mode) || | 2918 | if (!bond_uses_primary(bond) || |
2919 | !bond->params.primary[0]) | 2919 | !bond->params.primary[0]) |
2920 | break; | 2920 | break; |
2921 | 2921 | ||
@@ -3078,7 +3078,7 @@ static void bond_work_init_all(struct bonding *bond) | |||
3078 | bond_resend_igmp_join_requests_delayed); | 3078 | bond_resend_igmp_join_requests_delayed); |
3079 | INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); | 3079 | INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); |
3080 | INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); | 3080 | INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); |
3081 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) | 3081 | if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) |
3082 | INIT_DELAYED_WORK(&bond->arp_work, bond_activebackup_arp_mon); | 3082 | INIT_DELAYED_WORK(&bond->arp_work, bond_activebackup_arp_mon); |
3083 | else | 3083 | else |
3084 | INIT_DELAYED_WORK(&bond->arp_work, bond_loadbalance_arp_mon); | 3084 | INIT_DELAYED_WORK(&bond->arp_work, bond_loadbalance_arp_mon); |
@@ -3105,7 +3105,7 @@ static int bond_open(struct net_device *bond_dev) | |||
3105 | if (bond_has_slaves(bond)) { | 3105 | if (bond_has_slaves(bond)) { |
3106 | read_lock(&bond->curr_slave_lock); | 3106 | read_lock(&bond->curr_slave_lock); |
3107 | bond_for_each_slave(bond, slave, iter) { | 3107 | bond_for_each_slave(bond, slave, iter) { |
3108 | if (USES_PRIMARY(bond->params.mode) | 3108 | if (bond_uses_primary(bond) |
3109 | && (slave != bond->curr_active_slave)) { | 3109 | && (slave != bond->curr_active_slave)) { |
3110 | bond_set_slave_inactive_flags(slave, | 3110 | bond_set_slave_inactive_flags(slave, |
3111 | BOND_SLAVE_NOTIFY_NOW); | 3111 | BOND_SLAVE_NOTIFY_NOW); |
@@ -3124,7 +3124,7 @@ static int bond_open(struct net_device *bond_dev) | |||
3124 | /* bond_alb_initialize must be called before the timer | 3124 | /* bond_alb_initialize must be called before the timer |
3125 | * is started. | 3125 | * is started. |
3126 | */ | 3126 | */ |
3127 | if (bond_alb_initialize(bond, (bond->params.mode == BOND_MODE_ALB))) | 3127 | if (bond_alb_initialize(bond, (BOND_MODE(bond) == BOND_MODE_ALB))) |
3128 | return -ENOMEM; | 3128 | return -ENOMEM; |
3129 | if (bond->params.tlb_dynamic_lb) | 3129 | if (bond->params.tlb_dynamic_lb) |
3130 | queue_delayed_work(bond->wq, &bond->alb_work, 0); | 3130 | queue_delayed_work(bond->wq, &bond->alb_work, 0); |
@@ -3138,7 +3138,7 @@ static int bond_open(struct net_device *bond_dev) | |||
3138 | bond->recv_probe = bond_arp_rcv; | 3138 | bond->recv_probe = bond_arp_rcv; |
3139 | } | 3139 | } |
3140 | 3140 | ||
3141 | if (bond->params.mode == BOND_MODE_8023AD) { | 3141 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
3142 | queue_delayed_work(bond->wq, &bond->ad_work, 0); | 3142 | queue_delayed_work(bond->wq, &bond->ad_work, 0); |
3143 | /* register to receive LACPDUs */ | 3143 | /* register to receive LACPDUs */ |
3144 | bond->recv_probe = bond_3ad_lacpdu_recv; | 3144 | bond->recv_probe = bond_3ad_lacpdu_recv; |
@@ -3343,7 +3343,7 @@ static void bond_set_rx_mode(struct net_device *bond_dev) | |||
3343 | 3343 | ||
3344 | 3344 | ||
3345 | rcu_read_lock(); | 3345 | rcu_read_lock(); |
3346 | if (USES_PRIMARY(bond->params.mode)) { | 3346 | if (bond_uses_primary(bond)) { |
3347 | slave = rcu_dereference(bond->curr_active_slave); | 3347 | slave = rcu_dereference(bond->curr_active_slave); |
3348 | if (slave) { | 3348 | if (slave) { |
3349 | dev_uc_sync(slave->dev, bond_dev); | 3349 | dev_uc_sync(slave->dev, bond_dev); |
@@ -3497,7 +3497,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) | |||
3497 | struct list_head *iter; | 3497 | struct list_head *iter; |
3498 | int res = 0; | 3498 | int res = 0; |
3499 | 3499 | ||
3500 | if (bond->params.mode == BOND_MODE_ALB) | 3500 | if (BOND_MODE(bond) == BOND_MODE_ALB) |
3501 | return bond_alb_set_mac_address(bond_dev, addr); | 3501 | return bond_alb_set_mac_address(bond_dev, addr); |
3502 | 3502 | ||
3503 | 3503 | ||
@@ -3508,7 +3508,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) | |||
3508 | * Returning an error causes ifenslave to fail. | 3508 | * Returning an error causes ifenslave to fail. |
3509 | */ | 3509 | */ |
3510 | if (bond->params.fail_over_mac && | 3510 | if (bond->params.fail_over_mac && |
3511 | bond->params.mode == BOND_MODE_ACTIVEBACKUP) | 3511 | BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) |
3512 | return 0; | 3512 | return 0; |
3513 | 3513 | ||
3514 | if (!is_valid_ether_addr(sa->sa_data)) | 3514 | if (!is_valid_ether_addr(sa->sa_data)) |
@@ -3588,7 +3588,7 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl | |||
3588 | /* Here we start from the slave with slave_id */ | 3588 | /* Here we start from the slave with slave_id */ |
3589 | bond_for_each_slave_rcu(bond, slave, iter) { | 3589 | bond_for_each_slave_rcu(bond, slave, iter) { |
3590 | if (--i < 0) { | 3590 | if (--i < 0) { |
3591 | if (slave_can_tx(slave)) { | 3591 | if (bond_slave_can_tx(slave)) { |
3592 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3592 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3593 | return; | 3593 | return; |
3594 | } | 3594 | } |
@@ -3600,7 +3600,7 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl | |||
3600 | bond_for_each_slave_rcu(bond, slave, iter) { | 3600 | bond_for_each_slave_rcu(bond, slave, iter) { |
3601 | if (--i < 0) | 3601 | if (--i < 0) |
3602 | break; | 3602 | break; |
3603 | if (slave_can_tx(slave)) { | 3603 | if (bond_slave_can_tx(slave)) { |
3604 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3604 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3605 | return; | 3605 | return; |
3606 | } | 3606 | } |
@@ -3657,7 +3657,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev | |||
3657 | */ | 3657 | */ |
3658 | if (iph->protocol == IPPROTO_IGMP && skb->protocol == htons(ETH_P_IP)) { | 3658 | if (iph->protocol == IPPROTO_IGMP && skb->protocol == htons(ETH_P_IP)) { |
3659 | slave = rcu_dereference(bond->curr_active_slave); | 3659 | slave = rcu_dereference(bond->curr_active_slave); |
3660 | if (slave && slave_can_tx(slave)) | 3660 | if (slave && bond_slave_can_tx(slave)) |
3661 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3661 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3662 | else | 3662 | else |
3663 | bond_xmit_slave_id(bond, skb, 0); | 3663 | bond_xmit_slave_id(bond, skb, 0); |
@@ -3710,7 +3710,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) | |||
3710 | bond_for_each_slave_rcu(bond, slave, iter) { | 3710 | bond_for_each_slave_rcu(bond, slave, iter) { |
3711 | if (bond_is_last_slave(bond, slave)) | 3711 | if (bond_is_last_slave(bond, slave)) |
3712 | break; | 3712 | break; |
3713 | if (IS_UP(slave->dev) && slave->link == BOND_LINK_UP) { | 3713 | if (bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { |
3714 | struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); | 3714 | struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); |
3715 | 3715 | ||
3716 | if (!skb2) { | 3716 | if (!skb2) { |
@@ -3722,7 +3722,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) | |||
3722 | bond_dev_queue_xmit(bond, skb2, slave->dev); | 3722 | bond_dev_queue_xmit(bond, skb2, slave->dev); |
3723 | } | 3723 | } |
3724 | } | 3724 | } |
3725 | if (slave && IS_UP(slave->dev) && slave->link == BOND_LINK_UP) | 3725 | if (slave && bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) |
3726 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3726 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3727 | else | 3727 | else |
3728 | dev_kfree_skb_any(skb); | 3728 | dev_kfree_skb_any(skb); |
@@ -3747,7 +3747,7 @@ static inline int bond_slave_override(struct bonding *bond, | |||
3747 | /* Find out if any slaves have the same mapping as this skb. */ | 3747 | /* Find out if any slaves have the same mapping as this skb. */ |
3748 | bond_for_each_slave_rcu(bond, slave, iter) { | 3748 | bond_for_each_slave_rcu(bond, slave, iter) { |
3749 | if (slave->queue_id == skb->queue_mapping) { | 3749 | if (slave->queue_id == skb->queue_mapping) { |
3750 | if (slave_can_tx(slave)) { | 3750 | if (bond_slave_can_tx(slave)) { |
3751 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3751 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3752 | return 0; | 3752 | return 0; |
3753 | } | 3753 | } |
@@ -3788,12 +3788,11 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev | |||
3788 | { | 3788 | { |
3789 | struct bonding *bond = netdev_priv(dev); | 3789 | struct bonding *bond = netdev_priv(dev); |
3790 | 3790 | ||
3791 | if (TX_QUEUE_OVERRIDE(bond->params.mode)) { | 3791 | if (bond_should_override_tx_queue(bond) && |
3792 | if (!bond_slave_override(bond, skb)) | 3792 | !bond_slave_override(bond, skb)) |
3793 | return NETDEV_TX_OK; | 3793 | return NETDEV_TX_OK; |
3794 | } | ||
3795 | 3794 | ||
3796 | switch (bond->params.mode) { | 3795 | switch (BOND_MODE(bond)) { |
3797 | case BOND_MODE_ROUNDROBIN: | 3796 | case BOND_MODE_ROUNDROBIN: |
3798 | return bond_xmit_roundrobin(skb, dev); | 3797 | return bond_xmit_roundrobin(skb, dev); |
3799 | case BOND_MODE_ACTIVEBACKUP: | 3798 | case BOND_MODE_ACTIVEBACKUP: |
@@ -3811,7 +3810,7 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev | |||
3811 | default: | 3810 | default: |
3812 | /* Should never happen, mode already checked */ | 3811 | /* Should never happen, mode already checked */ |
3813 | pr_err("%s: Error: Unknown bonding mode %d\n", | 3812 | pr_err("%s: Error: Unknown bonding mode %d\n", |
3814 | dev->name, bond->params.mode); | 3813 | dev->name, BOND_MODE(bond)); |
3815 | WARN_ON_ONCE(1); | 3814 | WARN_ON_ONCE(1); |
3816 | dev_kfree_skb_any(skb); | 3815 | dev_kfree_skb_any(skb); |
3817 | return NETDEV_TX_OK; | 3816 | return NETDEV_TX_OK; |
@@ -3851,14 +3850,14 @@ static int bond_ethtool_get_settings(struct net_device *bond_dev, | |||
3851 | ecmd->duplex = DUPLEX_UNKNOWN; | 3850 | ecmd->duplex = DUPLEX_UNKNOWN; |
3852 | ecmd->port = PORT_OTHER; | 3851 | ecmd->port = PORT_OTHER; |
3853 | 3852 | ||
3854 | /* Since SLAVE_IS_OK returns false for all inactive or down slaves, we | 3853 | /* Since bond_slave_can_tx returns false for all inactive or down slaves, we |
3855 | * do not need to check mode. Though link speed might not represent | 3854 | * do not need to check mode. Though link speed might not represent |
3856 | * the true receive or transmit bandwidth (not all modes are symmetric) | 3855 | * the true receive or transmit bandwidth (not all modes are symmetric) |
3857 | * this is an accurate maximum. | 3856 | * this is an accurate maximum. |
3858 | */ | 3857 | */ |
3859 | read_lock(&bond->lock); | 3858 | read_lock(&bond->lock); |
3860 | bond_for_each_slave(bond, slave, iter) { | 3859 | bond_for_each_slave(bond, slave, iter) { |
3861 | if (SLAVE_IS_OK(slave)) { | 3860 | if (bond_slave_can_tx(slave)) { |
3862 | if (slave->speed != SPEED_UNKNOWN) | 3861 | if (slave->speed != SPEED_UNKNOWN) |
3863 | speed += slave->speed; | 3862 | speed += slave->speed; |
3864 | if (ecmd->duplex == DUPLEX_UNKNOWN && | 3863 | if (ecmd->duplex == DUPLEX_UNKNOWN && |
@@ -4114,7 +4113,7 @@ static int bond_check_params(struct bond_params *params) | |||
4114 | } | 4113 | } |
4115 | 4114 | ||
4116 | /* reset values for 802.3ad/TLB/ALB */ | 4115 | /* reset values for 802.3ad/TLB/ALB */ |
4117 | if (BOND_NO_USES_ARP(bond_mode)) { | 4116 | if (!bond_mode_uses_arp(bond_mode)) { |
4118 | if (!miimon) { | 4117 | if (!miimon) { |
4119 | pr_warn("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed and duplex which are essential for 802.3ad operation\n"); | 4118 | pr_warn("Warning: miimon must be specified, otherwise bonding will not detect link failure, speed and duplex which are essential for 802.3ad operation\n"); |
4120 | pr_warn("Forcing miimon to 100msec\n"); | 4119 | pr_warn("Forcing miimon to 100msec\n"); |
@@ -4196,7 +4195,7 @@ static int bond_check_params(struct bond_params *params) | |||
4196 | catch mistakes */ | 4195 | catch mistakes */ |
4197 | __be32 ip; | 4196 | __be32 ip; |
4198 | if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || | 4197 | if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || |
4199 | IS_IP_TARGET_UNUSABLE_ADDRESS(ip)) { | 4198 | !bond_is_ip_target_ok(ip)) { |
4200 | pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", | 4199 | pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", |
4201 | arp_ip_target[i]); | 4200 | arp_ip_target[i]); |
4202 | arp_interval = 0; | 4201 | arp_interval = 0; |
@@ -4269,7 +4268,7 @@ static int bond_check_params(struct bond_params *params) | |||
4269 | pr_debug("Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details\n"); | 4268 | pr_debug("Warning: either miimon or arp_interval and arp_ip_target module parameters must be specified, otherwise bonding will not detect link failures! see bonding.txt for details\n"); |
4270 | } | 4269 | } |
4271 | 4270 | ||
4272 | if (primary && !USES_PRIMARY(bond_mode)) { | 4271 | if (primary && !bond_mode_uses_primary(bond_mode)) { |
4273 | /* currently, using a primary only makes sense | 4272 | /* currently, using a primary only makes sense |
4274 | * in active backup, TLB or ALB modes | 4273 | * in active backup, TLB or ALB modes |
4275 | */ | 4274 | */ |
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index 0d06e751dff2..5ab3c1847e67 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
@@ -56,7 +56,7 @@ static int bond_fill_slave_info(struct sk_buff *skb, | |||
56 | if (nla_put_u16(skb, IFLA_BOND_SLAVE_QUEUE_ID, slave->queue_id)) | 56 | if (nla_put_u16(skb, IFLA_BOND_SLAVE_QUEUE_ID, slave->queue_id)) |
57 | goto nla_put_failure; | 57 | goto nla_put_failure; |
58 | 58 | ||
59 | if (slave->bond->params.mode == BOND_MODE_8023AD) { | 59 | if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) { |
60 | const struct aggregator *agg; | 60 | const struct aggregator *agg; |
61 | 61 | ||
62 | agg = SLAVE_AD_INFO(slave)->port.aggregator; | 62 | agg = SLAVE_AD_INFO(slave)->port.aggregator; |
@@ -407,7 +407,7 @@ static int bond_fill_info(struct sk_buff *skb, | |||
407 | unsigned int packets_per_slave; | 407 | unsigned int packets_per_slave; |
408 | int i, targets_added; | 408 | int i, targets_added; |
409 | 409 | ||
410 | if (nla_put_u8(skb, IFLA_BOND_MODE, bond->params.mode)) | 410 | if (nla_put_u8(skb, IFLA_BOND_MODE, BOND_MODE(bond))) |
411 | goto nla_put_failure; | 411 | goto nla_put_failure; |
412 | 412 | ||
413 | if (slave_dev && | 413 | if (slave_dev && |
@@ -505,7 +505,7 @@ static int bond_fill_info(struct sk_buff *skb, | |||
505 | bond->params.ad_select)) | 505 | bond->params.ad_select)) |
506 | goto nla_put_failure; | 506 | goto nla_put_failure; |
507 | 507 | ||
508 | if (bond->params.mode == BOND_MODE_8023AD) { | 508 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
509 | struct ad_info info; | 509 | struct ad_info info; |
510 | 510 | ||
511 | if (!bond_3ad_get_active_agg_info(bond, &info)) { | 511 | if (!bond_3ad_get_active_agg_info(bond, &info)) { |
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c index 6dc49da106d6..94094b3d5a3e 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -672,7 +672,7 @@ const struct bond_option *bond_opt_get(unsigned int option) | |||
672 | 672 | ||
673 | int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newval) | 673 | int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newval) |
674 | { | 674 | { |
675 | if (BOND_NO_USES_ARP(newval->value) && bond->params.arp_interval) { | 675 | if (!bond_mode_uses_arp(newval->value) && bond->params.arp_interval) { |
676 | pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n", | 676 | pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n", |
677 | bond->dev->name, newval->string); | 677 | bond->dev->name, newval->string); |
678 | /* disable arp monitoring */ | 678 | /* disable arp monitoring */ |
@@ -693,7 +693,7 @@ int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newv | |||
693 | static struct net_device *__bond_option_active_slave_get(struct bonding *bond, | 693 | static struct net_device *__bond_option_active_slave_get(struct bonding *bond, |
694 | struct slave *slave) | 694 | struct slave *slave) |
695 | { | 695 | { |
696 | return USES_PRIMARY(bond->params.mode) && slave ? slave->dev : NULL; | 696 | return bond_uses_primary(bond) && slave ? slave->dev : NULL; |
697 | } | 697 | } |
698 | 698 | ||
699 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond) | 699 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond) |
@@ -758,7 +758,7 @@ static int bond_option_active_slave_set(struct bonding *bond, | |||
758 | bond->dev->name, new_active->dev->name); | 758 | bond->dev->name, new_active->dev->name); |
759 | } else { | 759 | } else { |
760 | if (old_active && (new_active->link == BOND_LINK_UP) && | 760 | if (old_active && (new_active->link == BOND_LINK_UP) && |
761 | IS_UP(new_active->dev)) { | 761 | bond_slave_is_up(new_active)) { |
762 | pr_info("%s: Setting %s as active slave\n", | 762 | pr_info("%s: Setting %s as active slave\n", |
763 | bond->dev->name, new_active->dev->name); | 763 | bond->dev->name, new_active->dev->name); |
764 | bond_change_active_slave(bond, new_active); | 764 | bond_change_active_slave(bond, new_active); |
@@ -942,7 +942,7 @@ static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) | |||
942 | __be32 *targets = bond->params.arp_targets; | 942 | __be32 *targets = bond->params.arp_targets; |
943 | int ind; | 943 | int ind; |
944 | 944 | ||
945 | if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) { | 945 | if (!bond_is_ip_target_ok(target)) { |
946 | pr_err("%s: invalid ARP target %pI4 specified for addition\n", | 946 | pr_err("%s: invalid ARP target %pI4 specified for addition\n", |
947 | bond->dev->name, &target); | 947 | bond->dev->name, &target); |
948 | return -EINVAL; | 948 | return -EINVAL; |
@@ -987,7 +987,7 @@ static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) | |||
987 | unsigned long *targets_rx; | 987 | unsigned long *targets_rx; |
988 | int ind, i; | 988 | int ind, i; |
989 | 989 | ||
990 | if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) { | 990 | if (!bond_is_ip_target_ok(target)) { |
991 | pr_err("%s: invalid ARP target %pI4 specified for removal\n", | 991 | pr_err("%s: invalid ARP target %pI4 specified for removal\n", |
992 | bond->dev->name, &target); | 992 | bond->dev->name, &target); |
993 | return -EINVAL; | 993 | return -EINVAL; |
diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c index 6a261c85fd5d..b215b479bb3a 100644 --- a/drivers/net/bonding/bond_procfs.c +++ b/drivers/net/bonding/bond_procfs.c | |||
@@ -72,9 +72,9 @@ static void bond_info_show_master(struct seq_file *seq) | |||
72 | curr = rcu_dereference(bond->curr_active_slave); | 72 | curr = rcu_dereference(bond->curr_active_slave); |
73 | 73 | ||
74 | seq_printf(seq, "Bonding Mode: %s", | 74 | seq_printf(seq, "Bonding Mode: %s", |
75 | bond_mode_name(bond->params.mode)); | 75 | bond_mode_name(BOND_MODE(bond))); |
76 | 76 | ||
77 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP && | 77 | if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP && |
78 | bond->params.fail_over_mac) { | 78 | bond->params.fail_over_mac) { |
79 | optval = bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC, | 79 | optval = bond_opt_get_val(BOND_OPT_FAIL_OVER_MAC, |
80 | bond->params.fail_over_mac); | 80 | bond->params.fail_over_mac); |
@@ -83,15 +83,15 @@ static void bond_info_show_master(struct seq_file *seq) | |||
83 | 83 | ||
84 | seq_printf(seq, "\n"); | 84 | seq_printf(seq, "\n"); |
85 | 85 | ||
86 | if (bond->params.mode == BOND_MODE_XOR || | 86 | if (BOND_MODE(bond) == BOND_MODE_XOR || |
87 | bond->params.mode == BOND_MODE_8023AD) { | 87 | BOND_MODE(bond) == BOND_MODE_8023AD) { |
88 | optval = bond_opt_get_val(BOND_OPT_XMIT_HASH, | 88 | optval = bond_opt_get_val(BOND_OPT_XMIT_HASH, |
89 | bond->params.xmit_policy); | 89 | bond->params.xmit_policy); |
90 | seq_printf(seq, "Transmit Hash Policy: %s (%d)\n", | 90 | seq_printf(seq, "Transmit Hash Policy: %s (%d)\n", |
91 | optval->string, bond->params.xmit_policy); | 91 | optval->string, bond->params.xmit_policy); |
92 | } | 92 | } |
93 | 93 | ||
94 | if (USES_PRIMARY(bond->params.mode)) { | 94 | if (bond_uses_primary(bond)) { |
95 | seq_printf(seq, "Primary Slave: %s", | 95 | seq_printf(seq, "Primary Slave: %s", |
96 | (bond->primary_slave) ? | 96 | (bond->primary_slave) ? |
97 | bond->primary_slave->dev->name : "None"); | 97 | bond->primary_slave->dev->name : "None"); |
@@ -134,7 +134,7 @@ static void bond_info_show_master(struct seq_file *seq) | |||
134 | seq_printf(seq, "\n"); | 134 | seq_printf(seq, "\n"); |
135 | } | 135 | } |
136 | 136 | ||
137 | if (bond->params.mode == BOND_MODE_8023AD) { | 137 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
138 | struct ad_info ad_info; | 138 | struct ad_info ad_info; |
139 | 139 | ||
140 | seq_puts(seq, "\n802.3ad info\n"); | 140 | seq_puts(seq, "\n802.3ad info\n"); |
@@ -188,7 +188,7 @@ static void bond_info_show_slave(struct seq_file *seq, | |||
188 | 188 | ||
189 | seq_printf(seq, "Permanent HW addr: %pM\n", slave->perm_hwaddr); | 189 | seq_printf(seq, "Permanent HW addr: %pM\n", slave->perm_hwaddr); |
190 | 190 | ||
191 | if (bond->params.mode == BOND_MODE_8023AD) { | 191 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
192 | const struct aggregator *agg | 192 | const struct aggregator *agg |
193 | = SLAVE_AD_INFO(slave)->port.aggregator; | 193 | = SLAVE_AD_INFO(slave)->port.aggregator; |
194 | 194 | ||
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 39c4d8d61074..daed52f68ce1 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -214,9 +214,9 @@ static ssize_t bonding_show_mode(struct device *d, | |||
214 | struct bonding *bond = to_bond(d); | 214 | struct bonding *bond = to_bond(d); |
215 | const struct bond_opt_value *val; | 215 | const struct bond_opt_value *val; |
216 | 216 | ||
217 | val = bond_opt_get_val(BOND_OPT_MODE, bond->params.mode); | 217 | val = bond_opt_get_val(BOND_OPT_MODE, BOND_MODE(bond)); |
218 | 218 | ||
219 | return sprintf(buf, "%s %d\n", val->string, bond->params.mode); | 219 | return sprintf(buf, "%s %d\n", val->string, BOND_MODE(bond)); |
220 | } | 220 | } |
221 | static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, | 221 | static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, |
222 | bonding_show_mode, bonding_sysfs_store_option); | 222 | bonding_show_mode, bonding_sysfs_store_option); |
@@ -505,7 +505,7 @@ static ssize_t bonding_show_ad_aggregator(struct device *d, | |||
505 | int count = 0; | 505 | int count = 0; |
506 | struct bonding *bond = to_bond(d); | 506 | struct bonding *bond = to_bond(d); |
507 | 507 | ||
508 | if (bond->params.mode == BOND_MODE_8023AD) { | 508 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
509 | struct ad_info ad_info; | 509 | struct ad_info ad_info; |
510 | count = sprintf(buf, "%d\n", | 510 | count = sprintf(buf, "%d\n", |
511 | bond_3ad_get_active_agg_info(bond, &ad_info) | 511 | bond_3ad_get_active_agg_info(bond, &ad_info) |
@@ -525,7 +525,7 @@ static ssize_t bonding_show_ad_num_ports(struct device *d, | |||
525 | int count = 0; | 525 | int count = 0; |
526 | struct bonding *bond = to_bond(d); | 526 | struct bonding *bond = to_bond(d); |
527 | 527 | ||
528 | if (bond->params.mode == BOND_MODE_8023AD) { | 528 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
529 | struct ad_info ad_info; | 529 | struct ad_info ad_info; |
530 | count = sprintf(buf, "%d\n", | 530 | count = sprintf(buf, "%d\n", |
531 | bond_3ad_get_active_agg_info(bond, &ad_info) | 531 | bond_3ad_get_active_agg_info(bond, &ad_info) |
@@ -545,7 +545,7 @@ static ssize_t bonding_show_ad_actor_key(struct device *d, | |||
545 | int count = 0; | 545 | int count = 0; |
546 | struct bonding *bond = to_bond(d); | 546 | struct bonding *bond = to_bond(d); |
547 | 547 | ||
548 | if (bond->params.mode == BOND_MODE_8023AD) { | 548 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
549 | struct ad_info ad_info; | 549 | struct ad_info ad_info; |
550 | count = sprintf(buf, "%d\n", | 550 | count = sprintf(buf, "%d\n", |
551 | bond_3ad_get_active_agg_info(bond, &ad_info) | 551 | bond_3ad_get_active_agg_info(bond, &ad_info) |
@@ -565,7 +565,7 @@ static ssize_t bonding_show_ad_partner_key(struct device *d, | |||
565 | int count = 0; | 565 | int count = 0; |
566 | struct bonding *bond = to_bond(d); | 566 | struct bonding *bond = to_bond(d); |
567 | 567 | ||
568 | if (bond->params.mode == BOND_MODE_8023AD) { | 568 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
569 | struct ad_info ad_info; | 569 | struct ad_info ad_info; |
570 | count = sprintf(buf, "%d\n", | 570 | count = sprintf(buf, "%d\n", |
571 | bond_3ad_get_active_agg_info(bond, &ad_info) | 571 | bond_3ad_get_active_agg_info(bond, &ad_info) |
@@ -585,7 +585,7 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d, | |||
585 | int count = 0; | 585 | int count = 0; |
586 | struct bonding *bond = to_bond(d); | 586 | struct bonding *bond = to_bond(d); |
587 | 587 | ||
588 | if (bond->params.mode == BOND_MODE_8023AD) { | 588 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
589 | struct ad_info ad_info; | 589 | struct ad_info ad_info; |
590 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) | 590 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) |
591 | count = sprintf(buf, "%pM\n", ad_info.partner_system); | 591 | count = sprintf(buf, "%pM\n", ad_info.partner_system); |
diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c index 89bc3b3313c7..198677f58ce0 100644 --- a/drivers/net/bonding/bond_sysfs_slave.c +++ b/drivers/net/bonding/bond_sysfs_slave.c | |||
@@ -69,7 +69,7 @@ static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf) | |||
69 | { | 69 | { |
70 | const struct aggregator *agg; | 70 | const struct aggregator *agg; |
71 | 71 | ||
72 | if (slave->bond->params.mode == BOND_MODE_8023AD) { | 72 | if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) { |
73 | agg = SLAVE_AD_INFO(slave)->port.aggregator; | 73 | agg = SLAVE_AD_INFO(slave)->port.aggregator; |
74 | if (agg) | 74 | if (agg) |
75 | return sprintf(buf, "%d\n", | 75 | return sprintf(buf, "%d\n", |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index c51c433bc96e..44334b3d3b88 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -40,42 +40,6 @@ | |||
40 | 40 | ||
41 | #define BOND_DEFAULT_MIIMON 100 | 41 | #define BOND_DEFAULT_MIIMON 100 |
42 | 42 | ||
43 | #define IS_UP(dev) \ | ||
44 | ((((dev)->flags & IFF_UP) == IFF_UP) && \ | ||
45 | netif_running(dev) && \ | ||
46 | netif_carrier_ok(dev)) | ||
47 | |||
48 | /* | ||
49 | * Checks whether slave is ready for transmit. | ||
50 | */ | ||
51 | #define SLAVE_IS_OK(slave) \ | ||
52 | (((slave)->dev->flags & IFF_UP) && \ | ||
53 | netif_running((slave)->dev) && \ | ||
54 | ((slave)->link == BOND_LINK_UP) && \ | ||
55 | bond_is_active_slave(slave)) | ||
56 | |||
57 | |||
58 | #define USES_PRIMARY(mode) \ | ||
59 | (((mode) == BOND_MODE_ACTIVEBACKUP) || \ | ||
60 | ((mode) == BOND_MODE_TLB) || \ | ||
61 | ((mode) == BOND_MODE_ALB)) | ||
62 | |||
63 | #define BOND_NO_USES_ARP(mode) \ | ||
64 | (((mode) == BOND_MODE_8023AD) || \ | ||
65 | ((mode) == BOND_MODE_TLB) || \ | ||
66 | ((mode) == BOND_MODE_ALB)) | ||
67 | |||
68 | #define TX_QUEUE_OVERRIDE(mode) \ | ||
69 | (((mode) == BOND_MODE_ACTIVEBACKUP) || \ | ||
70 | ((mode) == BOND_MODE_ROUNDROBIN)) | ||
71 | |||
72 | #define BOND_MODE_IS_LB(mode) \ | ||
73 | (((mode) == BOND_MODE_TLB) || \ | ||
74 | ((mode) == BOND_MODE_ALB)) | ||
75 | |||
76 | #define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \ | ||
77 | ((htonl(INADDR_BROADCAST) == a) || \ | ||
78 | ipv4_is_zeronet(a)) | ||
79 | /* | 43 | /* |
80 | * Less bad way to call ioctl from within the kernel; this needs to be | 44 | * Less bad way to call ioctl from within the kernel; this needs to be |
81 | * done some other way to get the call out of interrupt context. | 45 | * done some other way to get the call out of interrupt context. |
@@ -89,6 +53,8 @@ | |||
89 | set_fs(fs); \ | 53 | set_fs(fs); \ |
90 | res; }) | 54 | res; }) |
91 | 55 | ||
56 | #define BOND_MODE(bond) ((bond)->params.mode) | ||
57 | |||
92 | /* slave list primitives */ | 58 | /* slave list primitives */ |
93 | #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower) | 59 | #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower) |
94 | 60 | ||
@@ -288,9 +254,38 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) | |||
288 | return slave->bond; | 254 | return slave->bond; |
289 | } | 255 | } |
290 | 256 | ||
257 | static inline bool bond_should_override_tx_queue(struct bonding *bond) | ||
258 | { | ||
259 | return BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP || | ||
260 | BOND_MODE(bond) == BOND_MODE_ROUNDROBIN; | ||
261 | } | ||
262 | |||
291 | static inline bool bond_is_lb(const struct bonding *bond) | 263 | static inline bool bond_is_lb(const struct bonding *bond) |
292 | { | 264 | { |
293 | return BOND_MODE_IS_LB(bond->params.mode); | 265 | return BOND_MODE(bond) == BOND_MODE_TLB || |
266 | BOND_MODE(bond) == BOND_MODE_ALB; | ||
267 | } | ||
268 | |||
269 | static inline bool bond_mode_uses_arp(int mode) | ||
270 | { | ||
271 | return mode != BOND_MODE_8023AD && mode != BOND_MODE_TLB && | ||
272 | mode != BOND_MODE_ALB; | ||
273 | } | ||
274 | |||
275 | static inline bool bond_mode_uses_primary(int mode) | ||
276 | { | ||
277 | return mode == BOND_MODE_ACTIVEBACKUP || mode == BOND_MODE_TLB || | ||
278 | mode == BOND_MODE_ALB; | ||
279 | } | ||
280 | |||
281 | static inline bool bond_uses_primary(struct bonding *bond) | ||
282 | { | ||
283 | return bond_mode_uses_primary(BOND_MODE(bond)); | ||
284 | } | ||
285 | |||
286 | static inline bool bond_slave_is_up(struct slave *slave) | ||
287 | { | ||
288 | return netif_running(slave->dev) && netif_carrier_ok(slave->dev); | ||
294 | } | 289 | } |
295 | 290 | ||
296 | static inline void bond_set_active_slave(struct slave *slave) | 291 | static inline void bond_set_active_slave(struct slave *slave) |
@@ -363,6 +358,12 @@ static inline bool bond_is_active_slave(struct slave *slave) | |||
363 | return !bond_slave_state(slave); | 358 | return !bond_slave_state(slave); |
364 | } | 359 | } |
365 | 360 | ||
361 | static inline bool bond_slave_can_tx(struct slave *slave) | ||
362 | { | ||
363 | return bond_slave_is_up(slave) && slave->link == BOND_LINK_UP && | ||
364 | bond_is_active_slave(slave); | ||
365 | } | ||
366 | |||
366 | #define BOND_PRI_RESELECT_ALWAYS 0 | 367 | #define BOND_PRI_RESELECT_ALWAYS 0 |
367 | #define BOND_PRI_RESELECT_BETTER 1 | 368 | #define BOND_PRI_RESELECT_BETTER 1 |
368 | #define BOND_PRI_RESELECT_FAILURE 2 | 369 | #define BOND_PRI_RESELECT_FAILURE 2 |
@@ -399,6 +400,11 @@ static inline int slave_do_arp_validate_only(struct bonding *bond) | |||
399 | return bond->params.arp_validate & BOND_ARP_FILTER; | 400 | return bond->params.arp_validate & BOND_ARP_FILTER; |
400 | } | 401 | } |
401 | 402 | ||
403 | static inline int bond_is_ip_target_ok(__be32 addr) | ||
404 | { | ||
405 | return !ipv4_is_lbcast(addr) && !ipv4_is_zeronet(addr); | ||
406 | } | ||
407 | |||
402 | /* Get the oldest arp which we've received on this slave for bond's | 408 | /* Get the oldest arp which we've received on this slave for bond's |
403 | * arp_targets. | 409 | * arp_targets. |
404 | */ | 410 | */ |
@@ -476,15 +482,6 @@ static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be3 | |||
476 | return addr; | 482 | return addr; |
477 | } | 483 | } |
478 | 484 | ||
479 | static inline bool slave_can_tx(struct slave *slave) | ||
480 | { | ||
481 | if (IS_UP(slave->dev) && slave->link == BOND_LINK_UP && | ||
482 | bond_is_active_slave(slave)) | ||
483 | return true; | ||
484 | else | ||
485 | return false; | ||
486 | } | ||
487 | |||
488 | struct bond_net { | 485 | struct bond_net { |
489 | struct net *net; /* Associated network namespace */ | 486 | struct net *net; /* Associated network namespace */ |
490 | struct list_head dev_list; | 487 | struct list_head dev_list; |