aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVeaceslav Falico <vfalico@gmail.com>2014-05-15 15:39:55 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-16 16:34:32 -0400
commit01844098ecd9564cd5f903e3ff6c1ea96355772d (patch)
tree4bf2bb8089248698ec1380d8c4e9cd018141466f
parentec0865a94991d1819d4f99866a2492af8df5c882 (diff)
bonding: create a macro for bond mode and use it
CC: Jay Vosburgh <j.vosburgh@gmail.com> CC: Andy Gospodarek <andy@greyhouse.net> Signed-off-by: Veaceslav Falico <vfalico@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/bonding/bond_alb.c4
-rw-r--r--drivers/net/bonding/bond_debugfs.c2
-rw-r--r--drivers/net/bonding/bond_main.c66
-rw-r--r--drivers/net/bonding/bond_netlink.c6
-rw-r--r--drivers/net/bonding/bond_procfs.c12
-rw-r--r--drivers/net/bonding/bond_sysfs.c14
-rw-r--r--drivers/net/bonding/bond_sysfs_slave.c2
-rw-r--r--drivers/net/bonding/bonding.h12
8 files changed, 60 insertions, 58 deletions
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 70de039dad2e..efacb0e98ed7 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -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 }
@@ -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 48bea62fb4d0..744c47111045 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) {
@@ -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
@@ -810,7 +810,7 @@ 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))
@@ -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);
@@ -877,7 +877,7 @@ void bond_change_active_slave(struct bonding *bond, struct slave *new_active)
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 ((bond_uses_primary(bond) && 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 }
@@ -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
@@ -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
@@ -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);
@@ -1615,7 +1615,7 @@ err_close:
1615 1615
1616err_restore_mac: 1616err_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",
@@ -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
@@ -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)
@@ -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);
@@ -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;
@@ -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))
@@ -3792,7 +3792,7 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev
3792 !bond_slave_override(bond, skb)) 3792 !bond_slave_override(bond, skb))
3793 return NETDEV_TX_OK; 3793 return NETDEV_TX_OK;
3794 3794
3795 switch (bond->params.mode) { 3795 switch (BOND_MODE(bond)) {
3796 case BOND_MODE_ROUNDROBIN: 3796 case BOND_MODE_ROUNDROBIN:
3797 return bond_xmit_roundrobin(skb, dev); 3797 return bond_xmit_roundrobin(skb, dev);
3798 case BOND_MODE_ACTIVEBACKUP: 3798 case BOND_MODE_ACTIVEBACKUP:
@@ -3810,7 +3810,7 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev
3810 default: 3810 default:
3811 /* Should never happen, mode already checked */ 3811 /* Should never happen, mode already checked */
3812 pr_err("%s: Error: Unknown bonding mode %d\n", 3812 pr_err("%s: Error: Unknown bonding mode %d\n",
3813 dev->name, bond->params.mode); 3813 dev->name, BOND_MODE(bond));
3814 WARN_ON_ONCE(1); 3814 WARN_ON_ONCE(1);
3815 dev_kfree_skb_any(skb); 3815 dev_kfree_skb_any(skb);
3816 return NETDEV_TX_OK; 3816 return NETDEV_TX_OK;
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_procfs.c b/drivers/net/bonding/bond_procfs.c
index 63a4a6f5ab14..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,8 +83,8 @@ 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",
@@ -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}
221static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, 221static 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 1a27c18be21c..bb663a4db137 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -70,6 +70,8 @@
70 set_fs(fs); \ 70 set_fs(fs); \
71 res; }) 71 res; })
72 72
73#define BOND_MODE(bond) ((bond)->params.mode)
74
73/* slave list primitives */ 75/* slave list primitives */
74#define bond_slave_list(bond) (&(bond)->dev->adj_list.lower) 76#define bond_slave_list(bond) (&(bond)->dev->adj_list.lower)
75 77
@@ -271,14 +273,14 @@ static inline struct bonding *bond_get_bond_by_slave(struct slave *slave)
271 273
272static inline bool bond_should_override_tx_queue(struct bonding *bond) 274static inline bool bond_should_override_tx_queue(struct bonding *bond)
273{ 275{
274 return bond->params.mode == BOND_MODE_ACTIVEBACKUP || 276 return BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP ||
275 bond->params.mode == BOND_MODE_ROUNDROBIN; 277 BOND_MODE(bond) == BOND_MODE_ROUNDROBIN;
276} 278}
277 279
278static inline bool bond_is_lb(const struct bonding *bond) 280static inline bool bond_is_lb(const struct bonding *bond)
279{ 281{
280 return bond->params.mode == BOND_MODE_TLB || 282 return BOND_MODE(bond) == BOND_MODE_TLB ||
281 bond->params.mode == BOND_MODE_ALB; 283 BOND_MODE(bond) == BOND_MODE_ALB;
282} 284}
283 285
284static inline bool bond_mode_uses_arp(int mode) 286static inline bool bond_mode_uses_arp(int mode)
@@ -295,7 +297,7 @@ static inline bool bond_mode_uses_primary(int mode)
295 297
296static inline bool bond_uses_primary(struct bonding *bond) 298static inline bool bond_uses_primary(struct bonding *bond)
297{ 299{
298 return bond_mode_uses_primary(bond->params.mode); 300 return bond_mode_uses_primary(BOND_MODE(bond));
299} 301}
300 302
301static inline void bond_set_active_slave(struct slave *slave) 303static inline void bond_set_active_slave(struct slave *slave)