diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-12 17:27:40 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-06-12 17:27:40 -0400 |
commit | f9da455b93f6ba076935b4ef4589f61e529ae046 (patch) | |
tree | 3c4e69ce1ba1d6bf65915b97a76ca2172105b278 /drivers/net/bonding | |
parent | 0e04c641b199435f3779454055f6a7de258ecdfc (diff) | |
parent | e5eca6d41f53db48edd8cf88a3f59d2c30227f8e (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next
Pull networking updates from David Miller:
1) Seccomp BPF filters can now be JIT'd, from Alexei Starovoitov.
2) Multiqueue support in xen-netback and xen-netfront, from Andrew J
Benniston.
3) Allow tweaking of aggregation settings in cdc_ncm driver, from Bjørn
Mork.
4) BPF now has a "random" opcode, from Chema Gonzalez.
5) Add more BPF documentation and improve test framework, from Daniel
Borkmann.
6) Support TCP fastopen over ipv6, from Daniel Lee.
7) Add software TSO helper functions and use them to support software
TSO in mvneta and mv643xx_eth drivers. From Ezequiel Garcia.
8) Support software TSO in fec driver too, from Nimrod Andy.
9) Add Broadcom SYSTEMPORT driver, from Florian Fainelli.
10) Handle broadcasts more gracefully over macvlan when there are large
numbers of interfaces configured, from Herbert Xu.
11) Allow more control over fwmark used for non-socket based responses,
from Lorenzo Colitti.
12) Do TCP congestion window limiting based upon measurements, from Neal
Cardwell.
13) Support busy polling in SCTP, from Neal Horman.
14) Allow RSS key to be configured via ethtool, from Venkata Duvvuru.
15) Bridge promisc mode handling improvements from Vlad Yasevich.
16) Don't use inetpeer entries to implement ID generation any more, it
performs poorly, from Eric Dumazet.
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1522 commits)
rtnetlink: fix userspace API breakage for iproute2 < v3.9.0
tcp: fixing TLP's FIN recovery
net: fec: Add software TSO support
net: fec: Add Scatter/gather support
net: fec: Increase buffer descriptor entry number
net: fec: Factorize feature setting
net: fec: Enable IP header hardware checksum
net: fec: Factorize the .xmit transmit function
bridge: fix compile error when compiling without IPv6 support
bridge: fix smatch warning / potential null pointer dereference
via-rhine: fix full-duplex with autoneg disable
bnx2x: Enlarge the dorq threshold for VFs
bnx2x: Check for UNDI in uncommon branch
bnx2x: Fix 1G-baseT link
bnx2x: Fix link for KR with swapped polarity lane
sctp: Fix sk_ack_backlog wrap-around problem
net/core: Add VF link state control policy
net/fsl: xgmac_mdio is dependent on OF_MDIO
net/fsl: Make xgmac_mdio read error message useful
net_sched: drr: warn when qdisc is not work conserving
...
Diffstat (limited to 'drivers/net/bonding')
-rw-r--r-- | drivers/net/bonding/bond_3ad.c | 62 | ||||
-rw-r--r-- | drivers/net/bonding/bond_alb.c | 153 | ||||
-rw-r--r-- | drivers/net/bonding/bond_alb.h | 1 | ||||
-rw-r--r-- | drivers/net/bonding/bond_debugfs.c | 2 | ||||
-rw-r--r-- | drivers/net/bonding/bond_main.c | 218 | ||||
-rw-r--r-- | drivers/net/bonding/bond_netlink.c | 8 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.c | 66 | ||||
-rw-r--r-- | drivers/net/bonding/bond_options.h | 2 | ||||
-rw-r--r-- | drivers/net/bonding/bond_procfs.c | 16 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs.c | 567 | ||||
-rw-r--r-- | drivers/net/bonding/bond_sysfs_slave.c | 4 | ||||
-rw-r--r-- | drivers/net/bonding/bonding.h | 143 |
12 files changed, 512 insertions, 730 deletions
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index b667a51ed215..0dfeaf5da3f2 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -157,7 +157,7 @@ static inline struct aggregator *__get_first_agg(struct port *port) | |||
157 | 157 | ||
158 | rcu_read_lock(); | 158 | rcu_read_lock(); |
159 | first_slave = bond_first_slave_rcu(bond); | 159 | first_slave = bond_first_slave_rcu(bond); |
160 | agg = first_slave ? &(SLAVE_AD_INFO(first_slave).aggregator) : NULL; | 160 | agg = first_slave ? &(SLAVE_AD_INFO(first_slave)->aggregator) : NULL; |
161 | rcu_read_unlock(); | 161 | rcu_read_unlock(); |
162 | 162 | ||
163 | return agg; | 163 | return agg; |
@@ -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 | ||
@@ -241,7 +241,7 @@ static inline int __check_agg_selection_timer(struct port *port) | |||
241 | */ | 241 | */ |
242 | static inline void __get_state_machine_lock(struct port *port) | 242 | static inline void __get_state_machine_lock(struct port *port) |
243 | { | 243 | { |
244 | spin_lock_bh(&(SLAVE_AD_INFO(port->slave).state_machine_lock)); | 244 | spin_lock_bh(&(SLAVE_AD_INFO(port->slave)->state_machine_lock)); |
245 | } | 245 | } |
246 | 246 | ||
247 | /** | 247 | /** |
@@ -250,7 +250,7 @@ static inline void __get_state_machine_lock(struct port *port) | |||
250 | */ | 250 | */ |
251 | static inline void __release_state_machine_lock(struct port *port) | 251 | static inline void __release_state_machine_lock(struct port *port) |
252 | { | 252 | { |
253 | spin_unlock_bh(&(SLAVE_AD_INFO(port->slave).state_machine_lock)); | 253 | spin_unlock_bh(&(SLAVE_AD_INFO(port->slave)->state_machine_lock)); |
254 | } | 254 | } |
255 | 255 | ||
256 | /** | 256 | /** |
@@ -350,7 +350,7 @@ static u8 __get_duplex(struct port *port) | |||
350 | static inline void __initialize_port_locks(struct slave *slave) | 350 | static inline void __initialize_port_locks(struct slave *slave) |
351 | { | 351 | { |
352 | /* make sure it isn't called twice */ | 352 | /* make sure it isn't called twice */ |
353 | spin_lock_init(&(SLAVE_AD_INFO(slave).state_machine_lock)); | 353 | spin_lock_init(&(SLAVE_AD_INFO(slave)->state_machine_lock)); |
354 | } | 354 | } |
355 | 355 | ||
356 | /* Conversions */ | 356 | /* Conversions */ |
@@ -688,8 +688,8 @@ static struct aggregator *__get_active_agg(struct aggregator *aggregator) | |||
688 | struct slave *slave; | 688 | struct slave *slave; |
689 | 689 | ||
690 | bond_for_each_slave_rcu(bond, slave, iter) | 690 | bond_for_each_slave_rcu(bond, slave, iter) |
691 | if (SLAVE_AD_INFO(slave).aggregator.is_active) | 691 | if (SLAVE_AD_INFO(slave)->aggregator.is_active) |
692 | return &(SLAVE_AD_INFO(slave).aggregator); | 692 | return &(SLAVE_AD_INFO(slave)->aggregator); |
693 | 693 | ||
694 | return NULL; | 694 | return NULL; |
695 | } | 695 | } |
@@ -1293,7 +1293,7 @@ static void ad_port_selection_logic(struct port *port) | |||
1293 | } | 1293 | } |
1294 | /* search on all aggregators for a suitable aggregator for this port */ | 1294 | /* search on all aggregators for a suitable aggregator for this port */ |
1295 | bond_for_each_slave(bond, slave, iter) { | 1295 | bond_for_each_slave(bond, slave, iter) { |
1296 | aggregator = &(SLAVE_AD_INFO(slave).aggregator); | 1296 | aggregator = &(SLAVE_AD_INFO(slave)->aggregator); |
1297 | 1297 | ||
1298 | /* keep a free aggregator for later use(if needed) */ | 1298 | /* keep a free aggregator for later use(if needed) */ |
1299 | if (!aggregator->lag_ports) { | 1299 | if (!aggregator->lag_ports) { |
@@ -1504,7 +1504,7 @@ static void ad_agg_selection_logic(struct aggregator *agg) | |||
1504 | best = (active && agg_device_up(active)) ? active : NULL; | 1504 | best = (active && agg_device_up(active)) ? active : NULL; |
1505 | 1505 | ||
1506 | bond_for_each_slave_rcu(bond, slave, iter) { | 1506 | bond_for_each_slave_rcu(bond, slave, iter) { |
1507 | agg = &(SLAVE_AD_INFO(slave).aggregator); | 1507 | agg = &(SLAVE_AD_INFO(slave)->aggregator); |
1508 | 1508 | ||
1509 | agg->is_active = 0; | 1509 | agg->is_active = 0; |
1510 | 1510 | ||
@@ -1549,7 +1549,7 @@ static void ad_agg_selection_logic(struct aggregator *agg) | |||
1549 | best->slave ? best->slave->dev->name : "NULL"); | 1549 | best->slave ? best->slave->dev->name : "NULL"); |
1550 | 1550 | ||
1551 | bond_for_each_slave_rcu(bond, slave, iter) { | 1551 | bond_for_each_slave_rcu(bond, slave, iter) { |
1552 | agg = &(SLAVE_AD_INFO(slave).aggregator); | 1552 | agg = &(SLAVE_AD_INFO(slave)->aggregator); |
1553 | 1553 | ||
1554 | pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", | 1554 | pr_debug("Agg=%d; P=%d; a k=%d; p k=%d; Ind=%d; Act=%d\n", |
1555 | agg->aggregator_identifier, agg->num_of_ports, | 1555 | agg->aggregator_identifier, agg->num_of_ports, |
@@ -1840,16 +1840,16 @@ void bond_3ad_bind_slave(struct slave *slave) | |||
1840 | struct aggregator *aggregator; | 1840 | struct aggregator *aggregator; |
1841 | 1841 | ||
1842 | /* check that the slave has not been initialized yet. */ | 1842 | /* check that the slave has not been initialized yet. */ |
1843 | if (SLAVE_AD_INFO(slave).port.slave != slave) { | 1843 | if (SLAVE_AD_INFO(slave)->port.slave != slave) { |
1844 | 1844 | ||
1845 | /* port initialization */ | 1845 | /* port initialization */ |
1846 | port = &(SLAVE_AD_INFO(slave).port); | 1846 | port = &(SLAVE_AD_INFO(slave)->port); |
1847 | 1847 | ||
1848 | ad_initialize_port(port, bond->params.lacp_fast); | 1848 | ad_initialize_port(port, bond->params.lacp_fast); |
1849 | 1849 | ||
1850 | __initialize_port_locks(slave); | 1850 | __initialize_port_locks(slave); |
1851 | port->slave = slave; | 1851 | port->slave = slave; |
1852 | port->actor_port_number = SLAVE_AD_INFO(slave).id; | 1852 | port->actor_port_number = SLAVE_AD_INFO(slave)->id; |
1853 | /* key is determined according to the link speed, duplex and user key(which | 1853 | /* key is determined according to the link speed, duplex and user key(which |
1854 | * is yet not supported) | 1854 | * is yet not supported) |
1855 | */ | 1855 | */ |
@@ -1874,7 +1874,7 @@ void bond_3ad_bind_slave(struct slave *slave) | |||
1874 | __disable_port(port); | 1874 | __disable_port(port); |
1875 | 1875 | ||
1876 | /* aggregator initialization */ | 1876 | /* aggregator initialization */ |
1877 | aggregator = &(SLAVE_AD_INFO(slave).aggregator); | 1877 | aggregator = &(SLAVE_AD_INFO(slave)->aggregator); |
1878 | 1878 | ||
1879 | ad_initialize_agg(aggregator); | 1879 | ad_initialize_agg(aggregator); |
1880 | 1880 | ||
@@ -1903,8 +1903,8 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
1903 | struct slave *slave_iter; | 1903 | struct slave *slave_iter; |
1904 | struct list_head *iter; | 1904 | struct list_head *iter; |
1905 | 1905 | ||
1906 | aggregator = &(SLAVE_AD_INFO(slave).aggregator); | 1906 | aggregator = &(SLAVE_AD_INFO(slave)->aggregator); |
1907 | port = &(SLAVE_AD_INFO(slave).port); | 1907 | port = &(SLAVE_AD_INFO(slave)->port); |
1908 | 1908 | ||
1909 | /* if slave is null, the whole port is not initialized */ | 1909 | /* if slave is null, the whole port is not initialized */ |
1910 | if (!port->slave) { | 1910 | if (!port->slave) { |
@@ -1932,7 +1932,7 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
1932 | (aggregator->lag_ports->next_port_in_aggregator)) { | 1932 | (aggregator->lag_ports->next_port_in_aggregator)) { |
1933 | /* find new aggregator for the related port(s) */ | 1933 | /* find new aggregator for the related port(s) */ |
1934 | bond_for_each_slave(bond, slave_iter, iter) { | 1934 | bond_for_each_slave(bond, slave_iter, iter) { |
1935 | new_aggregator = &(SLAVE_AD_INFO(slave_iter).aggregator); | 1935 | new_aggregator = &(SLAVE_AD_INFO(slave_iter)->aggregator); |
1936 | /* if the new aggregator is empty, or it is | 1936 | /* if the new aggregator is empty, or it is |
1937 | * connected to our port only | 1937 | * connected to our port only |
1938 | */ | 1938 | */ |
@@ -2010,7 +2010,7 @@ void bond_3ad_unbind_slave(struct slave *slave) | |||
2010 | 2010 | ||
2011 | /* find the aggregator that this port is connected to */ | 2011 | /* find the aggregator that this port is connected to */ |
2012 | bond_for_each_slave(bond, slave_iter, iter) { | 2012 | bond_for_each_slave(bond, slave_iter, iter) { |
2013 | temp_aggregator = &(SLAVE_AD_INFO(slave_iter).aggregator); | 2013 | temp_aggregator = &(SLAVE_AD_INFO(slave_iter)->aggregator); |
2014 | prev_port = NULL; | 2014 | prev_port = NULL; |
2015 | /* search the port in the aggregator's related ports */ | 2015 | /* search the port in the aggregator's related ports */ |
2016 | for (temp_port = temp_aggregator->lag_ports; temp_port; | 2016 | for (temp_port = temp_aggregator->lag_ports; temp_port; |
@@ -2076,7 +2076,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work) | |||
2076 | if (BOND_AD_INFO(bond).agg_select_timer && | 2076 | if (BOND_AD_INFO(bond).agg_select_timer && |
2077 | !(--BOND_AD_INFO(bond).agg_select_timer)) { | 2077 | !(--BOND_AD_INFO(bond).agg_select_timer)) { |
2078 | slave = bond_first_slave_rcu(bond); | 2078 | slave = bond_first_slave_rcu(bond); |
2079 | port = slave ? &(SLAVE_AD_INFO(slave).port) : NULL; | 2079 | port = slave ? &(SLAVE_AD_INFO(slave)->port) : NULL; |
2080 | 2080 | ||
2081 | /* select the active aggregator for the bond */ | 2081 | /* select the active aggregator for the bond */ |
2082 | if (port) { | 2082 | if (port) { |
@@ -2094,7 +2094,7 @@ void bond_3ad_state_machine_handler(struct work_struct *work) | |||
2094 | 2094 | ||
2095 | /* for each port run the state machines */ | 2095 | /* for each port run the state machines */ |
2096 | bond_for_each_slave_rcu(bond, slave, iter) { | 2096 | bond_for_each_slave_rcu(bond, slave, iter) { |
2097 | port = &(SLAVE_AD_INFO(slave).port); | 2097 | port = &(SLAVE_AD_INFO(slave)->port); |
2098 | if (!port->slave) { | 2098 | if (!port->slave) { |
2099 | pr_warn_ratelimited("%s: Warning: Found an uninitialized port\n", | 2099 | pr_warn_ratelimited("%s: Warning: Found an uninitialized port\n", |
2100 | bond->dev->name); | 2100 | bond->dev->name); |
@@ -2155,7 +2155,7 @@ static int bond_3ad_rx_indication(struct lacpdu *lacpdu, struct slave *slave, | |||
2155 | 2155 | ||
2156 | if (length >= sizeof(struct lacpdu)) { | 2156 | if (length >= sizeof(struct lacpdu)) { |
2157 | 2157 | ||
2158 | port = &(SLAVE_AD_INFO(slave).port); | 2158 | port = &(SLAVE_AD_INFO(slave)->port); |
2159 | 2159 | ||
2160 | if (!port->slave) { | 2160 | if (!port->slave) { |
2161 | pr_warn_ratelimited("%s: Warning: port of slave %s is uninitialized\n", | 2161 | pr_warn_ratelimited("%s: Warning: port of slave %s is uninitialized\n", |
@@ -2212,7 +2212,7 @@ void bond_3ad_adapter_speed_changed(struct slave *slave) | |||
2212 | { | 2212 | { |
2213 | struct port *port; | 2213 | struct port *port; |
2214 | 2214 | ||
2215 | port = &(SLAVE_AD_INFO(slave).port); | 2215 | port = &(SLAVE_AD_INFO(slave)->port); |
2216 | 2216 | ||
2217 | /* if slave is null, the whole port is not initialized */ | 2217 | /* if slave is null, the whole port is not initialized */ |
2218 | if (!port->slave) { | 2218 | if (!port->slave) { |
@@ -2245,7 +2245,7 @@ void bond_3ad_adapter_duplex_changed(struct slave *slave) | |||
2245 | { | 2245 | { |
2246 | struct port *port; | 2246 | struct port *port; |
2247 | 2247 | ||
2248 | port = &(SLAVE_AD_INFO(slave).port); | 2248 | port = &(SLAVE_AD_INFO(slave)->port); |
2249 | 2249 | ||
2250 | /* if slave is null, the whole port is not initialized */ | 2250 | /* if slave is null, the whole port is not initialized */ |
2251 | if (!port->slave) { | 2251 | if (!port->slave) { |
@@ -2279,7 +2279,7 @@ void bond_3ad_handle_link_change(struct slave *slave, char link) | |||
2279 | { | 2279 | { |
2280 | struct port *port; | 2280 | struct port *port; |
2281 | 2281 | ||
2282 | port = &(SLAVE_AD_INFO(slave).port); | 2282 | port = &(SLAVE_AD_INFO(slave)->port); |
2283 | 2283 | ||
2284 | /* if slave is null, the whole port is not initialized */ | 2284 | /* if slave is null, the whole port is not initialized */ |
2285 | if (!port->slave) { | 2285 | if (!port->slave) { |
@@ -2347,7 +2347,7 @@ int bond_3ad_set_carrier(struct bonding *bond) | |||
2347 | ret = 0; | 2347 | ret = 0; |
2348 | goto out; | 2348 | goto out; |
2349 | } | 2349 | } |
2350 | active = __get_active_agg(&(SLAVE_AD_INFO(first_slave).aggregator)); | 2350 | active = __get_active_agg(&(SLAVE_AD_INFO(first_slave)->aggregator)); |
2351 | if (active) { | 2351 | if (active) { |
2352 | /* are enough slaves available to consider link up? */ | 2352 | /* are enough slaves available to consider link up? */ |
2353 | if (active->num_of_ports < bond->params.min_links) { | 2353 | if (active->num_of_ports < bond->params.min_links) { |
@@ -2384,7 +2384,7 @@ int __bond_3ad_get_active_agg_info(struct bonding *bond, | |||
2384 | struct port *port; | 2384 | struct port *port; |
2385 | 2385 | ||
2386 | bond_for_each_slave_rcu(bond, slave, iter) { | 2386 | bond_for_each_slave_rcu(bond, slave, iter) { |
2387 | port = &(SLAVE_AD_INFO(slave).port); | 2387 | port = &(SLAVE_AD_INFO(slave)->port); |
2388 | if (port->aggregator && port->aggregator->is_active) { | 2388 | if (port->aggregator && port->aggregator->is_active) { |
2389 | aggregator = port->aggregator; | 2389 | aggregator = port->aggregator; |
2390 | break; | 2390 | break; |
@@ -2440,22 +2440,22 @@ int bond_3ad_xmit_xor(struct sk_buff *skb, struct net_device *dev) | |||
2440 | goto err_free; | 2440 | goto err_free; |
2441 | } | 2441 | } |
2442 | 2442 | ||
2443 | slave_agg_no = bond_xmit_hash(bond, skb, slaves_in_agg); | 2443 | slave_agg_no = bond_xmit_hash(bond, skb) % slaves_in_agg; |
2444 | first_ok_slave = NULL; | 2444 | first_ok_slave = NULL; |
2445 | 2445 | ||
2446 | bond_for_each_slave_rcu(bond, slave, iter) { | 2446 | bond_for_each_slave_rcu(bond, slave, iter) { |
2447 | agg = SLAVE_AD_INFO(slave).port.aggregator; | 2447 | agg = SLAVE_AD_INFO(slave)->port.aggregator; |
2448 | if (!agg || agg->aggregator_identifier != agg_id) | 2448 | if (!agg || agg->aggregator_identifier != agg_id) |
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 | } |
@@ -2522,7 +2522,7 @@ void bond_3ad_update_lacp_rate(struct bonding *bond) | |||
2522 | 2522 | ||
2523 | lacp_fast = bond->params.lacp_fast; | 2523 | lacp_fast = bond->params.lacp_fast; |
2524 | bond_for_each_slave(bond, slave, iter) { | 2524 | bond_for_each_slave(bond, slave, iter) { |
2525 | port = &(SLAVE_AD_INFO(slave).port); | 2525 | port = &(SLAVE_AD_INFO(slave)->port); |
2526 | __get_state_machine_lock(port); | 2526 | __get_state_machine_lock(port); |
2527 | if (lacp_fast) | 2527 | if (lacp_fast) |
2528 | port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT; | 2528 | port->actor_oper_port_state |= AD_STATE_LACP_TIMEOUT; |
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 93580a47cc54..76c0dade233f 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -229,7 +229,7 @@ static struct slave *tlb_get_least_loaded_slave(struct bonding *bond) | |||
229 | 229 | ||
230 | /* Find the slave with the largest gap */ | 230 | /* Find the slave with the largest gap */ |
231 | bond_for_each_slave_rcu(bond, slave, iter) { | 231 | bond_for_each_slave_rcu(bond, slave, iter) { |
232 | if (SLAVE_IS_OK(slave)) { | 232 | if (bond_slave_can_tx(slave)) { |
233 | long long gap = compute_gap(slave); | 233 | long long gap = compute_gap(slave); |
234 | 234 | ||
235 | if (max_gap < gap) { | 235 | if (max_gap < gap) { |
@@ -384,7 +384,7 @@ static struct slave *rlb_next_rx_slave(struct bonding *bond) | |||
384 | bool found = false; | 384 | bool found = false; |
385 | 385 | ||
386 | bond_for_each_slave(bond, slave, iter) { | 386 | bond_for_each_slave(bond, slave, iter) { |
387 | if (!SLAVE_IS_OK(slave)) | 387 | if (!bond_slave_can_tx(slave)) |
388 | continue; | 388 | continue; |
389 | if (!found) { | 389 | if (!found) { |
390 | if (!before || before->speed < slave->speed) | 390 | if (!before || before->speed < slave->speed) |
@@ -417,7 +417,7 @@ static struct slave *__rlb_next_rx_slave(struct bonding *bond) | |||
417 | bool found = false; | 417 | bool found = false; |
418 | 418 | ||
419 | bond_for_each_slave_rcu(bond, slave, iter) { | 419 | bond_for_each_slave_rcu(bond, slave, iter) { |
420 | if (!SLAVE_IS_OK(slave)) | 420 | if (!bond_slave_can_tx(slave)) |
421 | continue; | 421 | continue; |
422 | if (!found) { | 422 | if (!found) { |
423 | if (!before || before->speed < slave->speed) | 423 | if (!before || before->speed < slave->speed) |
@@ -755,7 +755,7 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond) | |||
755 | /* Don't modify or load balance ARPs that do not originate locally | 755 | /* Don't modify or load balance ARPs that do not originate locally |
756 | * (e.g.,arrive via a bridge). | 756 | * (e.g.,arrive via a bridge). |
757 | */ | 757 | */ |
758 | if (!bond_slave_has_mac_rcu(bond, arp->mac_src)) | 758 | if (!bond_slave_has_mac_rx(bond, arp->mac_src)) |
759 | return NULL; | 759 | return NULL; |
760 | 760 | ||
761 | if (arp->op_code == htons(ARPOP_REPLY)) { | 761 | if (arp->op_code == htons(ARPOP_REPLY)) { |
@@ -1039,11 +1039,14 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[], | |||
1039 | struct bonding *bond = bond_get_bond_by_slave(slave); | 1039 | struct bonding *bond = bond_get_bond_by_slave(slave); |
1040 | struct net_device *upper; | 1040 | struct net_device *upper; |
1041 | struct list_head *iter; | 1041 | struct list_head *iter; |
1042 | struct bond_vlan_tag tags[BOND_MAX_VLAN_ENCAP]; | ||
1042 | 1043 | ||
1043 | /* send untagged */ | 1044 | /* send untagged */ |
1044 | alb_send_lp_vid(slave, mac_addr, 0, 0); | 1045 | alb_send_lp_vid(slave, mac_addr, 0, 0); |
1045 | 1046 | ||
1046 | /* loop through vlans and send one packet for each */ | 1047 | /* loop through all devices and see if we need to send a packet |
1048 | * for that device. | ||
1049 | */ | ||
1047 | rcu_read_lock(); | 1050 | rcu_read_lock(); |
1048 | netdev_for_each_all_upper_dev_rcu(bond->dev, upper, iter) { | 1051 | netdev_for_each_all_upper_dev_rcu(bond->dev, upper, iter) { |
1049 | if (is_vlan_dev(upper) && vlan_get_encap_level(upper) == 0) { | 1052 | if (is_vlan_dev(upper) && vlan_get_encap_level(upper) == 0) { |
@@ -1059,6 +1062,16 @@ static void alb_send_learning_packets(struct slave *slave, u8 mac_addr[], | |||
1059 | vlan_dev_vlan_id(upper)); | 1062 | vlan_dev_vlan_id(upper)); |
1060 | } | 1063 | } |
1061 | } | 1064 | } |
1065 | |||
1066 | /* If this is a macvlan device, then only send updates | ||
1067 | * when strict_match is turned off. | ||
1068 | */ | ||
1069 | if (netif_is_macvlan(upper) && !strict_match) { | ||
1070 | memset(tags, 0, sizeof(tags)); | ||
1071 | bond_verify_device_path(bond->dev, upper, tags); | ||
1072 | alb_send_lp_vid(slave, upper->dev_addr, | ||
1073 | tags[0].vlan_proto, tags[0].vlan_id); | ||
1074 | } | ||
1062 | } | 1075 | } |
1063 | rcu_read_unlock(); | 1076 | rcu_read_unlock(); |
1064 | } | 1077 | } |
@@ -1068,7 +1081,7 @@ static int alb_set_slave_mac_addr(struct slave *slave, u8 addr[]) | |||
1068 | struct net_device *dev = slave->dev; | 1081 | struct net_device *dev = slave->dev; |
1069 | struct sockaddr s_addr; | 1082 | struct sockaddr s_addr; |
1070 | 1083 | ||
1071 | if (slave->bond->params.mode == BOND_MODE_TLB) { | 1084 | if (BOND_MODE(slave->bond) == BOND_MODE_TLB) { |
1072 | memcpy(dev->dev_addr, addr, dev->addr_len); | 1085 | memcpy(dev->dev_addr, addr, dev->addr_len); |
1073 | return 0; | 1086 | return 0; |
1074 | } | 1087 | } |
@@ -1111,13 +1124,13 @@ static void alb_swap_mac_addr(struct slave *slave1, struct slave *slave2) | |||
1111 | static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, | 1124 | static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, |
1112 | struct slave *slave2) | 1125 | struct slave *slave2) |
1113 | { | 1126 | { |
1114 | int slaves_state_differ = (SLAVE_IS_OK(slave1) != SLAVE_IS_OK(slave2)); | 1127 | int slaves_state_differ = (bond_slave_can_tx(slave1) != bond_slave_can_tx(slave2)); |
1115 | struct slave *disabled_slave = NULL; | 1128 | struct slave *disabled_slave = NULL; |
1116 | 1129 | ||
1117 | ASSERT_RTNL(); | 1130 | ASSERT_RTNL(); |
1118 | 1131 | ||
1119 | /* fasten the change in the switch */ | 1132 | /* fasten the change in the switch */ |
1120 | if (SLAVE_IS_OK(slave1)) { | 1133 | if (bond_slave_can_tx(slave1)) { |
1121 | alb_send_learning_packets(slave1, slave1->dev->dev_addr, false); | 1134 | alb_send_learning_packets(slave1, slave1->dev->dev_addr, false); |
1122 | if (bond->alb_info.rlb_enabled) { | 1135 | if (bond->alb_info.rlb_enabled) { |
1123 | /* inform the clients that the mac address | 1136 | /* inform the clients that the mac address |
@@ -1129,7 +1142,7 @@ static void alb_fasten_mac_swap(struct bonding *bond, struct slave *slave1, | |||
1129 | disabled_slave = slave1; | 1142 | disabled_slave = slave1; |
1130 | } | 1143 | } |
1131 | 1144 | ||
1132 | if (SLAVE_IS_OK(slave2)) { | 1145 | if (bond_slave_can_tx(slave2)) { |
1133 | alb_send_learning_packets(slave2, slave2->dev->dev_addr, false); | 1146 | alb_send_learning_packets(slave2, slave2->dev->dev_addr, false); |
1134 | if (bond->alb_info.rlb_enabled) { | 1147 | if (bond->alb_info.rlb_enabled) { |
1135 | /* inform the clients that the mac address | 1148 | /* inform the clients that the mac address |
@@ -1358,6 +1371,77 @@ void bond_alb_deinitialize(struct bonding *bond) | |||
1358 | rlb_deinitialize(bond); | 1371 | rlb_deinitialize(bond); |
1359 | } | 1372 | } |
1360 | 1373 | ||
1374 | static int bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond, | ||
1375 | struct slave *tx_slave) | ||
1376 | { | ||
1377 | struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond)); | ||
1378 | struct ethhdr *eth_data = eth_hdr(skb); | ||
1379 | |||
1380 | if (!tx_slave) { | ||
1381 | /* unbalanced or unassigned, send through primary */ | ||
1382 | tx_slave = rcu_dereference(bond->curr_active_slave); | ||
1383 | if (bond->params.tlb_dynamic_lb) | ||
1384 | bond_info->unbalanced_load += skb->len; | ||
1385 | } | ||
1386 | |||
1387 | if (tx_slave && bond_slave_can_tx(tx_slave)) { | ||
1388 | if (tx_slave != rcu_dereference(bond->curr_active_slave)) { | ||
1389 | ether_addr_copy(eth_data->h_source, | ||
1390 | tx_slave->dev->dev_addr); | ||
1391 | } | ||
1392 | |||
1393 | bond_dev_queue_xmit(bond, skb, tx_slave->dev); | ||
1394 | goto out; | ||
1395 | } | ||
1396 | |||
1397 | if (tx_slave && bond->params.tlb_dynamic_lb) { | ||
1398 | _lock_tx_hashtbl(bond); | ||
1399 | __tlb_clear_slave(bond, tx_slave, 0); | ||
1400 | _unlock_tx_hashtbl(bond); | ||
1401 | } | ||
1402 | |||
1403 | /* no suitable interface, frame not sent */ | ||
1404 | dev_kfree_skb_any(skb); | ||
1405 | out: | ||
1406 | return NETDEV_TX_OK; | ||
1407 | } | ||
1408 | |||
1409 | int bond_tlb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | ||
1410 | { | ||
1411 | struct bonding *bond = netdev_priv(bond_dev); | ||
1412 | struct ethhdr *eth_data; | ||
1413 | struct slave *tx_slave = NULL; | ||
1414 | u32 hash_index; | ||
1415 | |||
1416 | skb_reset_mac_header(skb); | ||
1417 | eth_data = eth_hdr(skb); | ||
1418 | |||
1419 | /* Do not TX balance any multicast or broadcast */ | ||
1420 | if (!is_multicast_ether_addr(eth_data->h_dest)) { | ||
1421 | switch (skb->protocol) { | ||
1422 | case htons(ETH_P_IP): | ||
1423 | case htons(ETH_P_IPX): | ||
1424 | /* In case of IPX, it will falback to L2 hash */ | ||
1425 | case htons(ETH_P_IPV6): | ||
1426 | hash_index = bond_xmit_hash(bond, skb); | ||
1427 | if (bond->params.tlb_dynamic_lb) { | ||
1428 | tx_slave = tlb_choose_channel(bond, | ||
1429 | hash_index & 0xFF, | ||
1430 | skb->len); | ||
1431 | } else { | ||
1432 | struct list_head *iter; | ||
1433 | int idx = hash_index % bond->slave_cnt; | ||
1434 | |||
1435 | bond_for_each_slave_rcu(bond, tx_slave, iter) | ||
1436 | if (--idx < 0) | ||
1437 | break; | ||
1438 | } | ||
1439 | break; | ||
1440 | } | ||
1441 | } | ||
1442 | return bond_do_alb_xmit(skb, bond, tx_slave); | ||
1443 | } | ||
1444 | |||
1361 | int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | 1445 | int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) |
1362 | { | 1446 | { |
1363 | struct bonding *bond = netdev_priv(bond_dev); | 1447 | struct bonding *bond = netdev_priv(bond_dev); |
@@ -1366,7 +1450,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1366 | struct slave *tx_slave = NULL; | 1450 | struct slave *tx_slave = NULL; |
1367 | static const __be32 ip_bcast = htonl(0xffffffff); | 1451 | static const __be32 ip_bcast = htonl(0xffffffff); |
1368 | int hash_size = 0; | 1452 | int hash_size = 0; |
1369 | int do_tx_balance = 1; | 1453 | bool do_tx_balance = true; |
1370 | u32 hash_index = 0; | 1454 | u32 hash_index = 0; |
1371 | const u8 *hash_start = NULL; | 1455 | const u8 *hash_start = NULL; |
1372 | struct ipv6hdr *ip6hdr; | 1456 | struct ipv6hdr *ip6hdr; |
@@ -1381,7 +1465,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1381 | if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast) || | 1465 | if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast) || |
1382 | (iph->daddr == ip_bcast) || | 1466 | (iph->daddr == ip_bcast) || |
1383 | (iph->protocol == IPPROTO_IGMP)) { | 1467 | (iph->protocol == IPPROTO_IGMP)) { |
1384 | do_tx_balance = 0; | 1468 | do_tx_balance = false; |
1385 | break; | 1469 | break; |
1386 | } | 1470 | } |
1387 | hash_start = (char *)&(iph->daddr); | 1471 | hash_start = (char *)&(iph->daddr); |
@@ -1393,7 +1477,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1393 | * that here just in case. | 1477 | * that here just in case. |
1394 | */ | 1478 | */ |
1395 | if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast)) { | 1479 | if (ether_addr_equal_64bits(eth_data->h_dest, mac_bcast)) { |
1396 | do_tx_balance = 0; | 1480 | do_tx_balance = false; |
1397 | break; | 1481 | break; |
1398 | } | 1482 | } |
1399 | 1483 | ||
@@ -1401,7 +1485,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1401 | * broadcasts in IPv4. | 1485 | * broadcasts in IPv4. |
1402 | */ | 1486 | */ |
1403 | if (ether_addr_equal_64bits(eth_data->h_dest, mac_v6_allmcast)) { | 1487 | if (ether_addr_equal_64bits(eth_data->h_dest, mac_v6_allmcast)) { |
1404 | do_tx_balance = 0; | 1488 | do_tx_balance = false; |
1405 | break; | 1489 | break; |
1406 | } | 1490 | } |
1407 | 1491 | ||
@@ -1411,7 +1495,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1411 | */ | 1495 | */ |
1412 | ip6hdr = ipv6_hdr(skb); | 1496 | ip6hdr = ipv6_hdr(skb); |
1413 | if (ipv6_addr_any(&ip6hdr->saddr)) { | 1497 | if (ipv6_addr_any(&ip6hdr->saddr)) { |
1414 | do_tx_balance = 0; | 1498 | do_tx_balance = false; |
1415 | break; | 1499 | break; |
1416 | } | 1500 | } |
1417 | 1501 | ||
@@ -1421,7 +1505,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1421 | case ETH_P_IPX: | 1505 | case ETH_P_IPX: |
1422 | if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) { | 1506 | if (ipx_hdr(skb)->ipx_checksum != IPX_NO_CHECKSUM) { |
1423 | /* something is wrong with this packet */ | 1507 | /* something is wrong with this packet */ |
1424 | do_tx_balance = 0; | 1508 | do_tx_balance = false; |
1425 | break; | 1509 | break; |
1426 | } | 1510 | } |
1427 | 1511 | ||
@@ -1430,7 +1514,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1430 | * this family since it has an "ARP" like | 1514 | * this family since it has an "ARP" like |
1431 | * mechanism | 1515 | * mechanism |
1432 | */ | 1516 | */ |
1433 | do_tx_balance = 0; | 1517 | do_tx_balance = false; |
1434 | break; | 1518 | break; |
1435 | } | 1519 | } |
1436 | 1520 | ||
@@ -1438,12 +1522,12 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1438 | hash_size = ETH_ALEN; | 1522 | hash_size = ETH_ALEN; |
1439 | break; | 1523 | break; |
1440 | case ETH_P_ARP: | 1524 | case ETH_P_ARP: |
1441 | do_tx_balance = 0; | 1525 | do_tx_balance = false; |
1442 | if (bond_info->rlb_enabled) | 1526 | if (bond_info->rlb_enabled) |
1443 | tx_slave = rlb_arp_xmit(skb, bond); | 1527 | tx_slave = rlb_arp_xmit(skb, bond); |
1444 | break; | 1528 | break; |
1445 | default: | 1529 | default: |
1446 | do_tx_balance = 0; | 1530 | do_tx_balance = false; |
1447 | break; | 1531 | break; |
1448 | } | 1532 | } |
1449 | 1533 | ||
@@ -1452,32 +1536,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev) | |||
1452 | tx_slave = tlb_choose_channel(bond, hash_index, skb->len); | 1536 | tx_slave = tlb_choose_channel(bond, hash_index, skb->len); |
1453 | } | 1537 | } |
1454 | 1538 | ||
1455 | if (!tx_slave) { | 1539 | return bond_do_alb_xmit(skb, bond, tx_slave); |
1456 | /* unbalanced or unassigned, send through primary */ | ||
1457 | tx_slave = rcu_dereference(bond->curr_active_slave); | ||
1458 | bond_info->unbalanced_load += skb->len; | ||
1459 | } | ||
1460 | |||
1461 | if (tx_slave && SLAVE_IS_OK(tx_slave)) { | ||
1462 | if (tx_slave != rcu_dereference(bond->curr_active_slave)) { | ||
1463 | ether_addr_copy(eth_data->h_source, | ||
1464 | tx_slave->dev->dev_addr); | ||
1465 | } | ||
1466 | |||
1467 | bond_dev_queue_xmit(bond, skb, tx_slave->dev); | ||
1468 | goto out; | ||
1469 | } | ||
1470 | |||
1471 | if (tx_slave) { | ||
1472 | _lock_tx_hashtbl(bond); | ||
1473 | __tlb_clear_slave(bond, tx_slave, 0); | ||
1474 | _unlock_tx_hashtbl(bond); | ||
1475 | } | ||
1476 | |||
1477 | /* no suitable interface, frame not sent */ | ||
1478 | dev_kfree_skb_any(skb); | ||
1479 | out: | ||
1480 | return NETDEV_TX_OK; | ||
1481 | } | 1540 | } |
1482 | 1541 | ||
1483 | void bond_alb_monitor(struct work_struct *work) | 1542 | void bond_alb_monitor(struct work_struct *work) |
@@ -1514,8 +1573,10 @@ void bond_alb_monitor(struct work_struct *work) | |||
1514 | /* If updating current_active, use all currently | 1573 | /* If updating current_active, use all currently |
1515 | * user mac addreses (!strict_match). Otherwise, only | 1574 | * user mac addreses (!strict_match). Otherwise, only |
1516 | * use mac of the slave device. | 1575 | * use mac of the slave device. |
1576 | * In RLB mode, we always use strict matches. | ||
1517 | */ | 1577 | */ |
1518 | strict_match = (slave != bond->curr_active_slave); | 1578 | strict_match = (slave != bond->curr_active_slave || |
1579 | bond_info->rlb_enabled); | ||
1519 | alb_send_learning_packets(slave, slave->dev->dev_addr, | 1580 | alb_send_learning_packets(slave, slave->dev->dev_addr, |
1520 | strict_match); | 1581 | strict_match); |
1521 | } | 1582 | } |
@@ -1719,7 +1780,7 @@ void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave | |||
1719 | /* in TLB mode, the slave might flip down/up with the old dev_addr, | 1780 | /* in TLB mode, the slave might flip down/up with the old dev_addr, |
1720 | * and thus filter bond->dev_addr's packets, so force bond's mac | 1781 | * and thus filter bond->dev_addr's packets, so force bond's mac |
1721 | */ | 1782 | */ |
1722 | if (bond->params.mode == BOND_MODE_TLB) { | 1783 | if (BOND_MODE(bond) == BOND_MODE_TLB) { |
1723 | struct sockaddr sa; | 1784 | struct sockaddr sa; |
1724 | u8 tmp_addr[ETH_ALEN]; | 1785 | u8 tmp_addr[ETH_ALEN]; |
1725 | 1786 | ||
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h index e09dd4bfafff..5fc76c01636c 100644 --- a/drivers/net/bonding/bond_alb.h +++ b/drivers/net/bonding/bond_alb.h | |||
@@ -175,6 +175,7 @@ void bond_alb_deinit_slave(struct bonding *bond, struct slave *slave); | |||
175 | void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link); | 175 | void bond_alb_handle_link_change(struct bonding *bond, struct slave *slave, char link); |
176 | void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave); | 176 | void bond_alb_handle_active_change(struct bonding *bond, struct slave *new_slave); |
177 | int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev); | 177 | int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev); |
178 | int bond_tlb_xmit(struct sk_buff *skb, struct net_device *bond_dev); | ||
178 | void bond_alb_monitor(struct work_struct *); | 179 | void bond_alb_monitor(struct work_struct *); |
179 | int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr); | 180 | int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr); |
180 | void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id); | 181 | void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id); |
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 d3a67896d435..04f35f960cb8 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 | ||
@@ -1038,6 +1038,7 @@ static void bond_compute_features(struct bonding *bond) | |||
1038 | 1038 | ||
1039 | if (!bond_has_slaves(bond)) | 1039 | if (!bond_has_slaves(bond)) |
1040 | goto done; | 1040 | goto done; |
1041 | vlan_features &= NETIF_F_ALL_FOR_ALL; | ||
1041 | 1042 | ||
1042 | bond_for_each_slave(bond, slave, iter) { | 1043 | bond_for_each_slave(bond, slave, iter) { |
1043 | vlan_features = netdev_increment_features(vlan_features, | 1044 | vlan_features = netdev_increment_features(vlan_features, |
@@ -1084,7 +1085,7 @@ static bool bond_should_deliver_exact_match(struct sk_buff *skb, | |||
1084 | struct bonding *bond) | 1085 | struct bonding *bond) |
1085 | { | 1086 | { |
1086 | if (bond_is_slave_inactive(slave)) { | 1087 | if (bond_is_slave_inactive(slave)) { |
1087 | if (bond->params.mode == BOND_MODE_ALB && | 1088 | if (BOND_MODE(bond) == BOND_MODE_ALB && |
1088 | skb->pkt_type != PACKET_BROADCAST && | 1089 | skb->pkt_type != PACKET_BROADCAST && |
1089 | skb->pkt_type != PACKET_MULTICAST) | 1090 | skb->pkt_type != PACKET_MULTICAST) |
1090 | return false; | 1091 | return false; |
@@ -1126,7 +1127,7 @@ static rx_handler_result_t bond_handle_frame(struct sk_buff **pskb) | |||
1126 | 1127 | ||
1127 | skb->dev = bond->dev; | 1128 | skb->dev = bond->dev; |
1128 | 1129 | ||
1129 | if (bond->params.mode == BOND_MODE_ALB && | 1130 | if (BOND_MODE(bond) == BOND_MODE_ALB && |
1130 | bond->dev->priv_flags & IFF_BRIDGE_PORT && | 1131 | bond->dev->priv_flags & IFF_BRIDGE_PORT && |
1131 | skb->pkt_type == PACKET_HOST) { | 1132 | skb->pkt_type == PACKET_HOST) { |
1132 | 1133 | ||
@@ -1163,6 +1164,35 @@ static void bond_upper_dev_unlink(struct net_device *bond_dev, | |||
1163 | rtmsg_ifinfo(RTM_NEWLINK, slave_dev, IFF_SLAVE, GFP_KERNEL); | 1164 | rtmsg_ifinfo(RTM_NEWLINK, slave_dev, IFF_SLAVE, GFP_KERNEL); |
1164 | } | 1165 | } |
1165 | 1166 | ||
1167 | static struct slave *bond_alloc_slave(struct bonding *bond) | ||
1168 | { | ||
1169 | struct slave *slave = NULL; | ||
1170 | |||
1171 | slave = kzalloc(sizeof(struct slave), GFP_KERNEL); | ||
1172 | if (!slave) | ||
1173 | return NULL; | ||
1174 | |||
1175 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { | ||
1176 | SLAVE_AD_INFO(slave) = kzalloc(sizeof(struct ad_slave_info), | ||
1177 | GFP_KERNEL); | ||
1178 | if (!SLAVE_AD_INFO(slave)) { | ||
1179 | kfree(slave); | ||
1180 | return NULL; | ||
1181 | } | ||
1182 | } | ||
1183 | return slave; | ||
1184 | } | ||
1185 | |||
1186 | static void bond_free_slave(struct slave *slave) | ||
1187 | { | ||
1188 | struct bonding *bond = bond_get_bond_by_slave(slave); | ||
1189 | |||
1190 | if (BOND_MODE(bond) == BOND_MODE_8023AD) | ||
1191 | kfree(SLAVE_AD_INFO(slave)); | ||
1192 | |||
1193 | kfree(slave); | ||
1194 | } | ||
1195 | |||
1166 | /* enslave device <slave> to bond device <master> */ | 1196 | /* enslave device <slave> to bond device <master> */ |
1167 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | 1197 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) |
1168 | { | 1198 | { |
@@ -1269,7 +1299,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1269 | if (!bond_has_slaves(bond)) { | 1299 | if (!bond_has_slaves(bond)) { |
1270 | pr_warn("%s: Warning: The first slave device specified does not support setting the MAC address\n", | 1300 | pr_warn("%s: Warning: The first slave device specified does not support setting the MAC address\n", |
1271 | bond_dev->name); | 1301 | bond_dev->name); |
1272 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) { | 1302 | if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) { |
1273 | bond->params.fail_over_mac = BOND_FOM_ACTIVE; | 1303 | bond->params.fail_over_mac = BOND_FOM_ACTIVE; |
1274 | pr_warn("%s: Setting fail_over_mac to active for active-backup mode\n", | 1304 | pr_warn("%s: Setting fail_over_mac to active for active-backup mode\n", |
1275 | bond_dev->name); | 1305 | bond_dev->name); |
@@ -1290,11 +1320,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1290 | bond->dev->addr_assign_type == NET_ADDR_RANDOM) | 1320 | bond->dev->addr_assign_type == NET_ADDR_RANDOM) |
1291 | bond_set_dev_addr(bond->dev, slave_dev); | 1321 | bond_set_dev_addr(bond->dev, slave_dev); |
1292 | 1322 | ||
1293 | new_slave = kzalloc(sizeof(struct slave), GFP_KERNEL); | 1323 | new_slave = bond_alloc_slave(bond); |
1294 | if (!new_slave) { | 1324 | if (!new_slave) { |
1295 | res = -ENOMEM; | 1325 | res = -ENOMEM; |
1296 | goto err_undo_flags; | 1326 | goto err_undo_flags; |
1297 | } | 1327 | } |
1328 | |||
1329 | new_slave->bond = bond; | ||
1330 | new_slave->dev = slave_dev; | ||
1298 | /* | 1331 | /* |
1299 | * Set the new_slave's queue_id to be zero. Queue ID mapping | 1332 | * Set the new_slave's queue_id to be zero. Queue ID mapping |
1300 | * is set via sysfs or module option if desired. | 1333 | * is set via sysfs or module option if desired. |
@@ -1317,7 +1350,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1317 | ether_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr); | 1350 | ether_addr_copy(new_slave->perm_hwaddr, slave_dev->dev_addr); |
1318 | 1351 | ||
1319 | if (!bond->params.fail_over_mac || | 1352 | if (!bond->params.fail_over_mac || |
1320 | bond->params.mode != BOND_MODE_ACTIVEBACKUP) { | 1353 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1321 | /* | 1354 | /* |
1322 | * Set slave to master's mac address. The application already | 1355 | * Set slave to master's mac address. The application already |
1323 | * set the master's mac address to that of the first slave | 1356 | * set the master's mac address to that of the first slave |
@@ -1338,8 +1371,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1338 | goto err_restore_mac; | 1371 | goto err_restore_mac; |
1339 | } | 1372 | } |
1340 | 1373 | ||
1341 | new_slave->bond = bond; | ||
1342 | new_slave->dev = slave_dev; | ||
1343 | slave_dev->priv_flags |= IFF_BONDING; | 1374 | slave_dev->priv_flags |= IFF_BONDING; |
1344 | 1375 | ||
1345 | if (bond_is_lb(bond)) { | 1376 | if (bond_is_lb(bond)) { |
@@ -1351,10 +1382,10 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1351 | goto err_close; | 1382 | goto err_close; |
1352 | } | 1383 | } |
1353 | 1384 | ||
1354 | /* If the mode USES_PRIMARY, then the following is handled by | 1385 | /* If the mode uses primary, then the following is handled by |
1355 | * bond_change_active_slave(). | 1386 | * bond_change_active_slave(). |
1356 | */ | 1387 | */ |
1357 | if (!USES_PRIMARY(bond->params.mode)) { | 1388 | if (!bond_uses_primary(bond)) { |
1358 | /* set promiscuity level to new slave */ | 1389 | /* set promiscuity level to new slave */ |
1359 | if (bond_dev->flags & IFF_PROMISC) { | 1390 | if (bond_dev->flags & IFF_PROMISC) { |
1360 | res = dev_set_promiscuity(slave_dev, 1); | 1391 | res = dev_set_promiscuity(slave_dev, 1); |
@@ -1377,7 +1408,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1377 | netif_addr_unlock_bh(bond_dev); | 1408 | netif_addr_unlock_bh(bond_dev); |
1378 | } | 1409 | } |
1379 | 1410 | ||
1380 | if (bond->params.mode == BOND_MODE_8023AD) { | 1411 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
1381 | /* add lacpdu mc addr to mc list */ | 1412 | /* add lacpdu mc addr to mc list */ |
1382 | u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; | 1413 | u8 lacpdu_multicast[ETH_ALEN] = MULTICAST_LACPDU_ADDR; |
1383 | 1414 | ||
@@ -1450,7 +1481,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1450 | new_slave->link == BOND_LINK_DOWN ? "DOWN" : | 1481 | new_slave->link == BOND_LINK_DOWN ? "DOWN" : |
1451 | (new_slave->link == BOND_LINK_UP ? "UP" : "BACK")); | 1482 | (new_slave->link == BOND_LINK_UP ? "UP" : "BACK")); |
1452 | 1483 | ||
1453 | if (USES_PRIMARY(bond->params.mode) && bond->params.primary[0]) { | 1484 | if (bond_uses_primary(bond) && bond->params.primary[0]) { |
1454 | /* if there is a primary slave, remember it */ | 1485 | /* if there is a primary slave, remember it */ |
1455 | if (strcmp(bond->params.primary, new_slave->dev->name) == 0) { | 1486 | if (strcmp(bond->params.primary, new_slave->dev->name) == 0) { |
1456 | bond->primary_slave = new_slave; | 1487 | bond->primary_slave = new_slave; |
@@ -1458,7 +1489,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1458 | } | 1489 | } |
1459 | } | 1490 | } |
1460 | 1491 | ||
1461 | switch (bond->params.mode) { | 1492 | switch (BOND_MODE(bond)) { |
1462 | case BOND_MODE_ACTIVEBACKUP: | 1493 | case BOND_MODE_ACTIVEBACKUP: |
1463 | bond_set_slave_inactive_flags(new_slave, | 1494 | bond_set_slave_inactive_flags(new_slave, |
1464 | BOND_SLAVE_NOTIFY_NOW); | 1495 | BOND_SLAVE_NOTIFY_NOW); |
@@ -1471,14 +1502,14 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1471 | bond_set_slave_inactive_flags(new_slave, BOND_SLAVE_NOTIFY_NOW); | 1502 | bond_set_slave_inactive_flags(new_slave, BOND_SLAVE_NOTIFY_NOW); |
1472 | /* if this is the first slave */ | 1503 | /* if this is the first slave */ |
1473 | if (!prev_slave) { | 1504 | if (!prev_slave) { |
1474 | SLAVE_AD_INFO(new_slave).id = 1; | 1505 | SLAVE_AD_INFO(new_slave)->id = 1; |
1475 | /* Initialize AD with the number of times that the AD timer is called in 1 second | 1506 | /* Initialize AD with the number of times that the AD timer is called in 1 second |
1476 | * can be called only after the mac address of the bond is set | 1507 | * can be called only after the mac address of the bond is set |
1477 | */ | 1508 | */ |
1478 | bond_3ad_initialize(bond, 1000/AD_TIMER_INTERVAL); | 1509 | bond_3ad_initialize(bond, 1000/AD_TIMER_INTERVAL); |
1479 | } else { | 1510 | } else { |
1480 | SLAVE_AD_INFO(new_slave).id = | 1511 | SLAVE_AD_INFO(new_slave)->id = |
1481 | SLAVE_AD_INFO(prev_slave).id + 1; | 1512 | SLAVE_AD_INFO(prev_slave)->id + 1; |
1482 | } | 1513 | } |
1483 | 1514 | ||
1484 | bond_3ad_bind_slave(new_slave); | 1515 | bond_3ad_bind_slave(new_slave); |
@@ -1539,7 +1570,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev) | |||
1539 | bond_compute_features(bond); | 1570 | bond_compute_features(bond); |
1540 | bond_set_carrier(bond); | 1571 | bond_set_carrier(bond); |
1541 | 1572 | ||
1542 | if (USES_PRIMARY(bond->params.mode)) { | 1573 | if (bond_uses_primary(bond)) { |
1543 | block_netpoll_tx(); | 1574 | block_netpoll_tx(); |
1544 | write_lock_bh(&bond->curr_slave_lock); | 1575 | write_lock_bh(&bond->curr_slave_lock); |
1545 | bond_select_active_slave(bond); | 1576 | bond_select_active_slave(bond); |
@@ -1563,7 +1594,7 @@ err_unregister: | |||
1563 | netdev_rx_handler_unregister(slave_dev); | 1594 | netdev_rx_handler_unregister(slave_dev); |
1564 | 1595 | ||
1565 | err_detach: | 1596 | err_detach: |
1566 | if (!USES_PRIMARY(bond->params.mode)) | 1597 | if (!bond_uses_primary(bond)) |
1567 | bond_hw_addr_flush(bond_dev, slave_dev); | 1598 | bond_hw_addr_flush(bond_dev, slave_dev); |
1568 | 1599 | ||
1569 | vlan_vids_del_by_dev(slave_dev, bond_dev); | 1600 | vlan_vids_del_by_dev(slave_dev, bond_dev); |
@@ -1585,7 +1616,7 @@ err_close: | |||
1585 | 1616 | ||
1586 | err_restore_mac: | 1617 | err_restore_mac: |
1587 | if (!bond->params.fail_over_mac || | 1618 | if (!bond->params.fail_over_mac || |
1588 | bond->params.mode != BOND_MODE_ACTIVEBACKUP) { | 1619 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1589 | /* XXX TODO - fom follow mode needs to change master's | 1620 | /* XXX TODO - fom follow mode needs to change master's |
1590 | * MAC if this slave's MAC is in use by the bond, or at | 1621 | * MAC if this slave's MAC is in use by the bond, or at |
1591 | * least print a warning. | 1622 | * least print a warning. |
@@ -1599,7 +1630,7 @@ err_restore_mtu: | |||
1599 | dev_set_mtu(slave_dev, new_slave->original_mtu); | 1630 | dev_set_mtu(slave_dev, new_slave->original_mtu); |
1600 | 1631 | ||
1601 | err_free: | 1632 | err_free: |
1602 | kfree(new_slave); | 1633 | bond_free_slave(new_slave); |
1603 | 1634 | ||
1604 | err_undo_flags: | 1635 | err_undo_flags: |
1605 | /* Enslave of first slave has failed and we need to fix master's mac */ | 1636 | /* Enslave of first slave has failed and we need to fix master's mac */ |
@@ -1661,7 +1692,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1661 | write_lock_bh(&bond->lock); | 1692 | write_lock_bh(&bond->lock); |
1662 | 1693 | ||
1663 | /* Inform AD package of unbinding of slave. */ | 1694 | /* Inform AD package of unbinding of slave. */ |
1664 | if (bond->params.mode == BOND_MODE_8023AD) | 1695 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
1665 | bond_3ad_unbind_slave(slave); | 1696 | bond_3ad_unbind_slave(slave); |
1666 | 1697 | ||
1667 | write_unlock_bh(&bond->lock); | 1698 | write_unlock_bh(&bond->lock); |
@@ -1676,7 +1707,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1676 | bond->current_arp_slave = NULL; | 1707 | bond->current_arp_slave = NULL; |
1677 | 1708 | ||
1678 | if (!all && (!bond->params.fail_over_mac || | 1709 | if (!all && (!bond->params.fail_over_mac || |
1679 | bond->params.mode != BOND_MODE_ACTIVEBACKUP)) { | 1710 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP)) { |
1680 | if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && | 1711 | if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && |
1681 | bond_has_slaves(bond)) | 1712 | bond_has_slaves(bond)) |
1682 | 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", | 1713 | 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", |
@@ -1748,10 +1779,10 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1748 | /* must do this from outside any spinlocks */ | 1779 | /* must do this from outside any spinlocks */ |
1749 | vlan_vids_del_by_dev(slave_dev, bond_dev); | 1780 | vlan_vids_del_by_dev(slave_dev, bond_dev); |
1750 | 1781 | ||
1751 | /* If the mode USES_PRIMARY, then this cases was handled above by | 1782 | /* If the mode uses primary, then this cases was handled above by |
1752 | * bond_change_active_slave(..., NULL) | 1783 | * bond_change_active_slave(..., NULL) |
1753 | */ | 1784 | */ |
1754 | if (!USES_PRIMARY(bond->params.mode)) { | 1785 | if (!bond_uses_primary(bond)) { |
1755 | /* unset promiscuity level from slave | 1786 | /* unset promiscuity level from slave |
1756 | * NOTE: The NETDEV_CHANGEADDR call above may change the value | 1787 | * NOTE: The NETDEV_CHANGEADDR call above may change the value |
1757 | * of the IFF_PROMISC flag in the bond_dev, but we need the | 1788 | * of the IFF_PROMISC flag in the bond_dev, but we need the |
@@ -1775,7 +1806,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1775 | dev_close(slave_dev); | 1806 | dev_close(slave_dev); |
1776 | 1807 | ||
1777 | if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || | 1808 | if (bond->params.fail_over_mac != BOND_FOM_ACTIVE || |
1778 | bond->params.mode != BOND_MODE_ACTIVEBACKUP) { | 1809 | BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1779 | /* restore original ("permanent") mac address */ | 1810 | /* restore original ("permanent") mac address */ |
1780 | ether_addr_copy(addr.sa_data, slave->perm_hwaddr); | 1811 | ether_addr_copy(addr.sa_data, slave->perm_hwaddr); |
1781 | addr.sa_family = slave_dev->type; | 1812 | addr.sa_family = slave_dev->type; |
@@ -1786,7 +1817,7 @@ static int __bond_release_one(struct net_device *bond_dev, | |||
1786 | 1817 | ||
1787 | slave_dev->priv_flags &= ~IFF_BONDING; | 1818 | slave_dev->priv_flags &= ~IFF_BONDING; |
1788 | 1819 | ||
1789 | kfree(slave); | 1820 | bond_free_slave(slave); |
1790 | 1821 | ||
1791 | return 0; /* deletion OK */ | 1822 | return 0; /* deletion OK */ |
1792 | } | 1823 | } |
@@ -1821,7 +1852,7 @@ static int bond_info_query(struct net_device *bond_dev, struct ifbond *info) | |||
1821 | { | 1852 | { |
1822 | struct bonding *bond = netdev_priv(bond_dev); | 1853 | struct bonding *bond = netdev_priv(bond_dev); |
1823 | 1854 | ||
1824 | info->bond_mode = bond->params.mode; | 1855 | info->bond_mode = BOND_MODE(bond); |
1825 | info->miimon = bond->params.miimon; | 1856 | info->miimon = bond->params.miimon; |
1826 | 1857 | ||
1827 | info->num_slaves = bond->slave_cnt; | 1858 | info->num_slaves = bond->slave_cnt; |
@@ -1877,7 +1908,7 @@ static int bond_miimon_inspect(struct bonding *bond) | |||
1877 | if (slave->delay) { | 1908 | if (slave->delay) { |
1878 | pr_info("%s: link status down for %sinterface %s, disabling it in %d ms\n", | 1909 | pr_info("%s: link status down for %sinterface %s, disabling it in %d ms\n", |
1879 | bond->dev->name, | 1910 | bond->dev->name, |
1880 | (bond->params.mode == | 1911 | (BOND_MODE(bond) == |
1881 | BOND_MODE_ACTIVEBACKUP) ? | 1912 | BOND_MODE_ACTIVEBACKUP) ? |
1882 | (bond_is_active_slave(slave) ? | 1913 | (bond_is_active_slave(slave) ? |
1883 | "active " : "backup ") : "", | 1914 | "active " : "backup ") : "", |
@@ -1968,10 +1999,10 @@ static void bond_miimon_commit(struct bonding *bond) | |||
1968 | slave->link = BOND_LINK_UP; | 1999 | slave->link = BOND_LINK_UP; |
1969 | slave->last_link_up = jiffies; | 2000 | slave->last_link_up = jiffies; |
1970 | 2001 | ||
1971 | if (bond->params.mode == BOND_MODE_8023AD) { | 2002 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
1972 | /* prevent it from being the active one */ | 2003 | /* prevent it from being the active one */ |
1973 | bond_set_backup_slave(slave); | 2004 | bond_set_backup_slave(slave); |
1974 | } else if (bond->params.mode != BOND_MODE_ACTIVEBACKUP) { | 2005 | } else if (BOND_MODE(bond) != BOND_MODE_ACTIVEBACKUP) { |
1975 | /* make it immediately active */ | 2006 | /* make it immediately active */ |
1976 | bond_set_active_slave(slave); | 2007 | bond_set_active_slave(slave); |
1977 | } else if (slave != bond->primary_slave) { | 2008 | } else if (slave != bond->primary_slave) { |
@@ -1985,7 +2016,7 @@ static void bond_miimon_commit(struct bonding *bond) | |||
1985 | slave->duplex ? "full" : "half"); | 2016 | slave->duplex ? "full" : "half"); |
1986 | 2017 | ||
1987 | /* notify ad that the link status has changed */ | 2018 | /* notify ad that the link status has changed */ |
1988 | if (bond->params.mode == BOND_MODE_8023AD) | 2019 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
1989 | bond_3ad_handle_link_change(slave, BOND_LINK_UP); | 2020 | bond_3ad_handle_link_change(slave, BOND_LINK_UP); |
1990 | 2021 | ||
1991 | if (bond_is_lb(bond)) | 2022 | if (bond_is_lb(bond)) |
@@ -2004,15 +2035,15 @@ static void bond_miimon_commit(struct bonding *bond) | |||
2004 | 2035 | ||
2005 | slave->link = BOND_LINK_DOWN; | 2036 | slave->link = BOND_LINK_DOWN; |
2006 | 2037 | ||
2007 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP || | 2038 | if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP || |
2008 | bond->params.mode == BOND_MODE_8023AD) | 2039 | BOND_MODE(bond) == BOND_MODE_8023AD) |
2009 | bond_set_slave_inactive_flags(slave, | 2040 | bond_set_slave_inactive_flags(slave, |
2010 | BOND_SLAVE_NOTIFY_NOW); | 2041 | BOND_SLAVE_NOTIFY_NOW); |
2011 | 2042 | ||
2012 | pr_info("%s: link status definitely down for interface %s, disabling it\n", | 2043 | pr_info("%s: link status definitely down for interface %s, disabling it\n", |
2013 | bond->dev->name, slave->dev->name); | 2044 | bond->dev->name, slave->dev->name); |
2014 | 2045 | ||
2015 | if (bond->params.mode == BOND_MODE_8023AD) | 2046 | if (BOND_MODE(bond) == BOND_MODE_8023AD) |
2016 | bond_3ad_handle_link_change(slave, | 2047 | bond_3ad_handle_link_change(slave, |
2017 | BOND_LINK_DOWN); | 2048 | BOND_LINK_DOWN); |
2018 | 2049 | ||
@@ -2175,9 +2206,9 @@ static void bond_arp_send(struct net_device *slave_dev, int arp_op, | |||
2175 | * When the path is validated, collect any vlan information in the | 2206 | * When the path is validated, collect any vlan information in the |
2176 | * path. | 2207 | * path. |
2177 | */ | 2208 | */ |
2178 | static bool bond_verify_device_path(struct net_device *start_dev, | 2209 | bool bond_verify_device_path(struct net_device *start_dev, |
2179 | struct net_device *end_dev, | 2210 | struct net_device *end_dev, |
2180 | struct bond_vlan_tag *tags) | 2211 | struct bond_vlan_tag *tags) |
2181 | { | 2212 | { |
2182 | struct net_device *upper; | 2213 | struct net_device *upper; |
2183 | struct list_head *iter; | 2214 | struct list_head *iter; |
@@ -2287,8 +2318,8 @@ int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, | |||
2287 | int alen, is_arp = skb->protocol == __cpu_to_be16(ETH_P_ARP); | 2318 | int alen, is_arp = skb->protocol == __cpu_to_be16(ETH_P_ARP); |
2288 | 2319 | ||
2289 | if (!slave_do_arp_validate(bond, slave)) { | 2320 | if (!slave_do_arp_validate(bond, slave)) { |
2290 | if ((slave_do_arp_validate_only(bond, slave) && is_arp) || | 2321 | if ((slave_do_arp_validate_only(bond) && is_arp) || |
2291 | !slave_do_arp_validate_only(bond, slave)) | 2322 | !slave_do_arp_validate_only(bond)) |
2292 | slave->last_rx = jiffies; | 2323 | slave->last_rx = jiffies; |
2293 | return RX_HANDLER_ANOTHER; | 2324 | return RX_HANDLER_ANOTHER; |
2294 | } else if (!is_arp) { | 2325 | } else if (!is_arp) { |
@@ -2456,7 +2487,7 @@ static void bond_loadbalance_arp_mon(struct work_struct *work) | |||
2456 | * do - all replies will be rx'ed on same link causing slaves | 2487 | * do - all replies will be rx'ed on same link causing slaves |
2457 | * to be unstable during low/no traffic periods | 2488 | * to be unstable during low/no traffic periods |
2458 | */ | 2489 | */ |
2459 | if (IS_UP(slave->dev)) | 2490 | if (bond_slave_is_up(slave)) |
2460 | bond_arp_send_all(bond, slave); | 2491 | bond_arp_send_all(bond, slave); |
2461 | } | 2492 | } |
2462 | 2493 | ||
@@ -2678,10 +2709,10 @@ static bool bond_ab_arp_probe(struct bonding *bond) | |||
2678 | bond_set_slave_inactive_flags(curr_arp_slave, BOND_SLAVE_NOTIFY_LATER); | 2709 | bond_set_slave_inactive_flags(curr_arp_slave, BOND_SLAVE_NOTIFY_LATER); |
2679 | 2710 | ||
2680 | bond_for_each_slave_rcu(bond, slave, iter) { | 2711 | bond_for_each_slave_rcu(bond, slave, iter) { |
2681 | if (!found && !before && IS_UP(slave->dev)) | 2712 | if (!found && !before && bond_slave_is_up(slave)) |
2682 | before = slave; | 2713 | before = slave; |
2683 | 2714 | ||
2684 | if (found && !new_slave && IS_UP(slave->dev)) | 2715 | if (found && !new_slave && bond_slave_is_up(slave)) |
2685 | new_slave = slave; | 2716 | new_slave = slave; |
2686 | /* if the link state is up at this point, we | 2717 | /* if the link state is up at this point, we |
2687 | * mark it down - this can happen if we have | 2718 | * mark it down - this can happen if we have |
@@ -2690,7 +2721,7 @@ static bool bond_ab_arp_probe(struct bonding *bond) | |||
2690 | * one the current slave so it is still marked | 2721 | * one the current slave so it is still marked |
2691 | * up when it is actually down | 2722 | * up when it is actually down |
2692 | */ | 2723 | */ |
2693 | if (!IS_UP(slave->dev) && slave->link == BOND_LINK_UP) { | 2724 | if (!bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { |
2694 | slave->link = BOND_LINK_DOWN; | 2725 | slave->link = BOND_LINK_DOWN; |
2695 | if (slave->link_failure_count < UINT_MAX) | 2726 | if (slave->link_failure_count < UINT_MAX) |
2696 | slave->link_failure_count++; | 2727 | slave->link_failure_count++; |
@@ -2853,7 +2884,7 @@ static int bond_slave_netdev_event(unsigned long event, | |||
2853 | 2884 | ||
2854 | bond_update_speed_duplex(slave); | 2885 | bond_update_speed_duplex(slave); |
2855 | 2886 | ||
2856 | if (bond->params.mode == BOND_MODE_8023AD) { | 2887 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
2857 | if (old_speed != slave->speed) | 2888 | if (old_speed != slave->speed) |
2858 | bond_3ad_adapter_speed_changed(slave); | 2889 | bond_3ad_adapter_speed_changed(slave); |
2859 | if (old_duplex != slave->duplex) | 2890 | if (old_duplex != slave->duplex) |
@@ -2881,7 +2912,7 @@ static int bond_slave_netdev_event(unsigned long event, | |||
2881 | break; | 2912 | break; |
2882 | case NETDEV_CHANGENAME: | 2913 | case NETDEV_CHANGENAME: |
2883 | /* we don't care if we don't have primary set */ | 2914 | /* we don't care if we don't have primary set */ |
2884 | if (!USES_PRIMARY(bond->params.mode) || | 2915 | if (!bond_uses_primary(bond) || |
2885 | !bond->params.primary[0]) | 2916 | !bond->params.primary[0]) |
2886 | break; | 2917 | break; |
2887 | 2918 | ||
@@ -3011,20 +3042,18 @@ static bool bond_flow_dissect(struct bonding *bond, struct sk_buff *skb, | |||
3011 | * bond_xmit_hash - generate a hash value based on the xmit policy | 3042 | * bond_xmit_hash - generate a hash value based on the xmit policy |
3012 | * @bond: bonding device | 3043 | * @bond: bonding device |
3013 | * @skb: buffer to use for headers | 3044 | * @skb: buffer to use for headers |
3014 | * @count: modulo value | ||
3015 | * | 3045 | * |
3016 | * This function will extract the necessary headers from the skb buffer and use | 3046 | * This function will extract the necessary headers from the skb buffer and use |
3017 | * them to generate a hash based on the xmit_policy set in the bonding device | 3047 | * them to generate a hash based on the xmit_policy set in the bonding device |
3018 | * which will be reduced modulo count before returning. | ||
3019 | */ | 3048 | */ |
3020 | int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count) | 3049 | u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb) |
3021 | { | 3050 | { |
3022 | struct flow_keys flow; | 3051 | struct flow_keys flow; |
3023 | u32 hash; | 3052 | u32 hash; |
3024 | 3053 | ||
3025 | if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 || | 3054 | if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER2 || |
3026 | !bond_flow_dissect(bond, skb, &flow)) | 3055 | !bond_flow_dissect(bond, skb, &flow)) |
3027 | return bond_eth_hash(skb) % count; | 3056 | return bond_eth_hash(skb); |
3028 | 3057 | ||
3029 | if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23 || | 3058 | if (bond->params.xmit_policy == BOND_XMIT_POLICY_LAYER23 || |
3030 | bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP23) | 3059 | bond->params.xmit_policy == BOND_XMIT_POLICY_ENCAP23) |
@@ -3035,7 +3064,7 @@ int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count) | |||
3035 | hash ^= (hash >> 16); | 3064 | hash ^= (hash >> 16); |
3036 | hash ^= (hash >> 8); | 3065 | hash ^= (hash >> 8); |
3037 | 3066 | ||
3038 | return hash % count; | 3067 | return hash; |
3039 | } | 3068 | } |
3040 | 3069 | ||
3041 | /*-------------------------- Device entry points ----------------------------*/ | 3070 | /*-------------------------- Device entry points ----------------------------*/ |
@@ -3046,7 +3075,7 @@ static void bond_work_init_all(struct bonding *bond) | |||
3046 | bond_resend_igmp_join_requests_delayed); | 3075 | bond_resend_igmp_join_requests_delayed); |
3047 | INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); | 3076 | INIT_DELAYED_WORK(&bond->alb_work, bond_alb_monitor); |
3048 | INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); | 3077 | INIT_DELAYED_WORK(&bond->mii_work, bond_mii_monitor); |
3049 | if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) | 3078 | if (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) |
3050 | INIT_DELAYED_WORK(&bond->arp_work, bond_activebackup_arp_mon); | 3079 | INIT_DELAYED_WORK(&bond->arp_work, bond_activebackup_arp_mon); |
3051 | else | 3080 | else |
3052 | INIT_DELAYED_WORK(&bond->arp_work, bond_loadbalance_arp_mon); | 3081 | INIT_DELAYED_WORK(&bond->arp_work, bond_loadbalance_arp_mon); |
@@ -3073,7 +3102,7 @@ static int bond_open(struct net_device *bond_dev) | |||
3073 | if (bond_has_slaves(bond)) { | 3102 | if (bond_has_slaves(bond)) { |
3074 | read_lock(&bond->curr_slave_lock); | 3103 | read_lock(&bond->curr_slave_lock); |
3075 | bond_for_each_slave(bond, slave, iter) { | 3104 | bond_for_each_slave(bond, slave, iter) { |
3076 | if (USES_PRIMARY(bond->params.mode) | 3105 | if (bond_uses_primary(bond) |
3077 | && (slave != bond->curr_active_slave)) { | 3106 | && (slave != bond->curr_active_slave)) { |
3078 | bond_set_slave_inactive_flags(slave, | 3107 | bond_set_slave_inactive_flags(slave, |
3079 | BOND_SLAVE_NOTIFY_NOW); | 3108 | BOND_SLAVE_NOTIFY_NOW); |
@@ -3092,9 +3121,10 @@ static int bond_open(struct net_device *bond_dev) | |||
3092 | /* bond_alb_initialize must be called before the timer | 3121 | /* bond_alb_initialize must be called before the timer |
3093 | * is started. | 3122 | * is started. |
3094 | */ | 3123 | */ |
3095 | if (bond_alb_initialize(bond, (bond->params.mode == BOND_MODE_ALB))) | 3124 | if (bond_alb_initialize(bond, (BOND_MODE(bond) == BOND_MODE_ALB))) |
3096 | return -ENOMEM; | 3125 | return -ENOMEM; |
3097 | queue_delayed_work(bond->wq, &bond->alb_work, 0); | 3126 | if (bond->params.tlb_dynamic_lb) |
3127 | queue_delayed_work(bond->wq, &bond->alb_work, 0); | ||
3098 | } | 3128 | } |
3099 | 3129 | ||
3100 | if (bond->params.miimon) /* link check interval, in milliseconds. */ | 3130 | if (bond->params.miimon) /* link check interval, in milliseconds. */ |
@@ -3105,7 +3135,7 @@ static int bond_open(struct net_device *bond_dev) | |||
3105 | bond->recv_probe = bond_arp_rcv; | 3135 | bond->recv_probe = bond_arp_rcv; |
3106 | } | 3136 | } |
3107 | 3137 | ||
3108 | if (bond->params.mode == BOND_MODE_8023AD) { | 3138 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
3109 | queue_delayed_work(bond->wq, &bond->ad_work, 0); | 3139 | queue_delayed_work(bond->wq, &bond->ad_work, 0); |
3110 | /* register to receive LACPDUs */ | 3140 | /* register to receive LACPDUs */ |
3111 | bond->recv_probe = bond_3ad_lacpdu_recv; | 3141 | bond->recv_probe = bond_3ad_lacpdu_recv; |
@@ -3310,7 +3340,7 @@ static void bond_set_rx_mode(struct net_device *bond_dev) | |||
3310 | 3340 | ||
3311 | 3341 | ||
3312 | rcu_read_lock(); | 3342 | rcu_read_lock(); |
3313 | if (USES_PRIMARY(bond->params.mode)) { | 3343 | if (bond_uses_primary(bond)) { |
3314 | slave = rcu_dereference(bond->curr_active_slave); | 3344 | slave = rcu_dereference(bond->curr_active_slave); |
3315 | if (slave) { | 3345 | if (slave) { |
3316 | dev_uc_sync(slave->dev, bond_dev); | 3346 | dev_uc_sync(slave->dev, bond_dev); |
@@ -3464,7 +3494,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) | |||
3464 | struct list_head *iter; | 3494 | struct list_head *iter; |
3465 | int res = 0; | 3495 | int res = 0; |
3466 | 3496 | ||
3467 | if (bond->params.mode == BOND_MODE_ALB) | 3497 | if (BOND_MODE(bond) == BOND_MODE_ALB) |
3468 | return bond_alb_set_mac_address(bond_dev, addr); | 3498 | return bond_alb_set_mac_address(bond_dev, addr); |
3469 | 3499 | ||
3470 | 3500 | ||
@@ -3475,7 +3505,7 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr) | |||
3475 | * Returning an error causes ifenslave to fail. | 3505 | * Returning an error causes ifenslave to fail. |
3476 | */ | 3506 | */ |
3477 | if (bond->params.fail_over_mac && | 3507 | if (bond->params.fail_over_mac && |
3478 | bond->params.mode == BOND_MODE_ACTIVEBACKUP) | 3508 | BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) |
3479 | return 0; | 3509 | return 0; |
3480 | 3510 | ||
3481 | if (!is_valid_ether_addr(sa->sa_data)) | 3511 | if (!is_valid_ether_addr(sa->sa_data)) |
@@ -3555,7 +3585,7 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl | |||
3555 | /* Here we start from the slave with slave_id */ | 3585 | /* Here we start from the slave with slave_id */ |
3556 | bond_for_each_slave_rcu(bond, slave, iter) { | 3586 | bond_for_each_slave_rcu(bond, slave, iter) { |
3557 | if (--i < 0) { | 3587 | if (--i < 0) { |
3558 | if (slave_can_tx(slave)) { | 3588 | if (bond_slave_can_tx(slave)) { |
3559 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3589 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3560 | return; | 3590 | return; |
3561 | } | 3591 | } |
@@ -3567,7 +3597,7 @@ static void bond_xmit_slave_id(struct bonding *bond, struct sk_buff *skb, int sl | |||
3567 | bond_for_each_slave_rcu(bond, slave, iter) { | 3597 | bond_for_each_slave_rcu(bond, slave, iter) { |
3568 | if (--i < 0) | 3598 | if (--i < 0) |
3569 | break; | 3599 | break; |
3570 | if (slave_can_tx(slave)) { | 3600 | if (bond_slave_can_tx(slave)) { |
3571 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3601 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3572 | return; | 3602 | return; |
3573 | } | 3603 | } |
@@ -3624,7 +3654,7 @@ static int bond_xmit_roundrobin(struct sk_buff *skb, struct net_device *bond_dev | |||
3624 | */ | 3654 | */ |
3625 | if (iph->protocol == IPPROTO_IGMP && skb->protocol == htons(ETH_P_IP)) { | 3655 | if (iph->protocol == IPPROTO_IGMP && skb->protocol == htons(ETH_P_IP)) { |
3626 | slave = rcu_dereference(bond->curr_active_slave); | 3656 | slave = rcu_dereference(bond->curr_active_slave); |
3627 | if (slave && slave_can_tx(slave)) | 3657 | if (slave && bond_slave_can_tx(slave)) |
3628 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3658 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3629 | else | 3659 | else |
3630 | bond_xmit_slave_id(bond, skb, 0); | 3660 | bond_xmit_slave_id(bond, skb, 0); |
@@ -3662,7 +3692,7 @@ static int bond_xmit_xor(struct sk_buff *skb, struct net_device *bond_dev) | |||
3662 | { | 3692 | { |
3663 | struct bonding *bond = netdev_priv(bond_dev); | 3693 | struct bonding *bond = netdev_priv(bond_dev); |
3664 | 3694 | ||
3665 | bond_xmit_slave_id(bond, skb, bond_xmit_hash(bond, skb, bond->slave_cnt)); | 3695 | bond_xmit_slave_id(bond, skb, bond_xmit_hash(bond, skb) % bond->slave_cnt); |
3666 | 3696 | ||
3667 | return NETDEV_TX_OK; | 3697 | return NETDEV_TX_OK; |
3668 | } | 3698 | } |
@@ -3677,7 +3707,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) | |||
3677 | bond_for_each_slave_rcu(bond, slave, iter) { | 3707 | bond_for_each_slave_rcu(bond, slave, iter) { |
3678 | if (bond_is_last_slave(bond, slave)) | 3708 | if (bond_is_last_slave(bond, slave)) |
3679 | break; | 3709 | break; |
3680 | if (IS_UP(slave->dev) && slave->link == BOND_LINK_UP) { | 3710 | if (bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) { |
3681 | struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); | 3711 | struct sk_buff *skb2 = skb_clone(skb, GFP_ATOMIC); |
3682 | 3712 | ||
3683 | if (!skb2) { | 3713 | if (!skb2) { |
@@ -3689,7 +3719,7 @@ static int bond_xmit_broadcast(struct sk_buff *skb, struct net_device *bond_dev) | |||
3689 | bond_dev_queue_xmit(bond, skb2, slave->dev); | 3719 | bond_dev_queue_xmit(bond, skb2, slave->dev); |
3690 | } | 3720 | } |
3691 | } | 3721 | } |
3692 | if (slave && IS_UP(slave->dev) && slave->link == BOND_LINK_UP) | 3722 | if (slave && bond_slave_is_up(slave) && slave->link == BOND_LINK_UP) |
3693 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3723 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3694 | else | 3724 | else |
3695 | dev_kfree_skb_any(skb); | 3725 | dev_kfree_skb_any(skb); |
@@ -3714,7 +3744,7 @@ static inline int bond_slave_override(struct bonding *bond, | |||
3714 | /* Find out if any slaves have the same mapping as this skb. */ | 3744 | /* Find out if any slaves have the same mapping as this skb. */ |
3715 | bond_for_each_slave_rcu(bond, slave, iter) { | 3745 | bond_for_each_slave_rcu(bond, slave, iter) { |
3716 | if (slave->queue_id == skb->queue_mapping) { | 3746 | if (slave->queue_id == skb->queue_mapping) { |
3717 | if (slave_can_tx(slave)) { | 3747 | if (bond_slave_can_tx(slave)) { |
3718 | bond_dev_queue_xmit(bond, skb, slave->dev); | 3748 | bond_dev_queue_xmit(bond, skb, slave->dev); |
3719 | return 0; | 3749 | return 0; |
3720 | } | 3750 | } |
@@ -3755,12 +3785,11 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev | |||
3755 | { | 3785 | { |
3756 | struct bonding *bond = netdev_priv(dev); | 3786 | struct bonding *bond = netdev_priv(dev); |
3757 | 3787 | ||
3758 | if (TX_QUEUE_OVERRIDE(bond->params.mode)) { | 3788 | if (bond_should_override_tx_queue(bond) && |
3759 | if (!bond_slave_override(bond, skb)) | 3789 | !bond_slave_override(bond, skb)) |
3760 | return NETDEV_TX_OK; | 3790 | return NETDEV_TX_OK; |
3761 | } | ||
3762 | 3791 | ||
3763 | switch (bond->params.mode) { | 3792 | switch (BOND_MODE(bond)) { |
3764 | case BOND_MODE_ROUNDROBIN: | 3793 | case BOND_MODE_ROUNDROBIN: |
3765 | return bond_xmit_roundrobin(skb, dev); | 3794 | return bond_xmit_roundrobin(skb, dev); |
3766 | case BOND_MODE_ACTIVEBACKUP: | 3795 | case BOND_MODE_ACTIVEBACKUP: |
@@ -3772,12 +3801,13 @@ static netdev_tx_t __bond_start_xmit(struct sk_buff *skb, struct net_device *dev | |||
3772 | case BOND_MODE_8023AD: | 3801 | case BOND_MODE_8023AD: |
3773 | return bond_3ad_xmit_xor(skb, dev); | 3802 | return bond_3ad_xmit_xor(skb, dev); |
3774 | case BOND_MODE_ALB: | 3803 | case BOND_MODE_ALB: |
3775 | case BOND_MODE_TLB: | ||
3776 | return bond_alb_xmit(skb, dev); | 3804 | return bond_alb_xmit(skb, dev); |
3805 | case BOND_MODE_TLB: | ||
3806 | return bond_tlb_xmit(skb, dev); | ||
3777 | default: | 3807 | default: |
3778 | /* Should never happen, mode already checked */ | 3808 | /* Should never happen, mode already checked */ |
3779 | pr_err("%s: Error: Unknown bonding mode %d\n", | 3809 | pr_err("%s: Error: Unknown bonding mode %d\n", |
3780 | dev->name, bond->params.mode); | 3810 | dev->name, BOND_MODE(bond)); |
3781 | WARN_ON_ONCE(1); | 3811 | WARN_ON_ONCE(1); |
3782 | dev_kfree_skb_any(skb); | 3812 | dev_kfree_skb_any(skb); |
3783 | return NETDEV_TX_OK; | 3813 | return NETDEV_TX_OK; |
@@ -3817,14 +3847,14 @@ static int bond_ethtool_get_settings(struct net_device *bond_dev, | |||
3817 | ecmd->duplex = DUPLEX_UNKNOWN; | 3847 | ecmd->duplex = DUPLEX_UNKNOWN; |
3818 | ecmd->port = PORT_OTHER; | 3848 | ecmd->port = PORT_OTHER; |
3819 | 3849 | ||
3820 | /* Since SLAVE_IS_OK returns false for all inactive or down slaves, we | 3850 | /* Since bond_slave_can_tx returns false for all inactive or down slaves, we |
3821 | * do not need to check mode. Though link speed might not represent | 3851 | * do not need to check mode. Though link speed might not represent |
3822 | * the true receive or transmit bandwidth (not all modes are symmetric) | 3852 | * the true receive or transmit bandwidth (not all modes are symmetric) |
3823 | * this is an accurate maximum. | 3853 | * this is an accurate maximum. |
3824 | */ | 3854 | */ |
3825 | read_lock(&bond->lock); | 3855 | read_lock(&bond->lock); |
3826 | bond_for_each_slave(bond, slave, iter) { | 3856 | bond_for_each_slave(bond, slave, iter) { |
3827 | if (SLAVE_IS_OK(slave)) { | 3857 | if (bond_slave_can_tx(slave)) { |
3828 | if (slave->speed != SPEED_UNKNOWN) | 3858 | if (slave->speed != SPEED_UNKNOWN) |
3829 | speed += slave->speed; | 3859 | speed += slave->speed; |
3830 | if (ecmd->duplex == DUPLEX_UNKNOWN && | 3860 | if (ecmd->duplex == DUPLEX_UNKNOWN && |
@@ -3915,7 +3945,7 @@ void bond_setup(struct net_device *bond_dev) | |||
3915 | /* Initialize the device options */ | 3945 | /* Initialize the device options */ |
3916 | bond_dev->tx_queue_len = 0; | 3946 | bond_dev->tx_queue_len = 0; |
3917 | bond_dev->flags |= IFF_MASTER|IFF_MULTICAST; | 3947 | bond_dev->flags |= IFF_MASTER|IFF_MULTICAST; |
3918 | bond_dev->priv_flags |= IFF_BONDING; | 3948 | bond_dev->priv_flags |= IFF_BONDING | IFF_UNICAST_FLT; |
3919 | bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); | 3949 | bond_dev->priv_flags &= ~(IFF_XMIT_DST_RELEASE | IFF_TX_SKB_SHARING); |
3920 | 3950 | ||
3921 | /* At first, we block adding VLANs. That's the only way to | 3951 | /* At first, we block adding VLANs. That's the only way to |
@@ -3994,7 +4024,8 @@ static int bond_check_params(struct bond_params *params) | |||
3994 | 4024 | ||
3995 | if (xmit_hash_policy) { | 4025 | if (xmit_hash_policy) { |
3996 | if ((bond_mode != BOND_MODE_XOR) && | 4026 | if ((bond_mode != BOND_MODE_XOR) && |
3997 | (bond_mode != BOND_MODE_8023AD)) { | 4027 | (bond_mode != BOND_MODE_8023AD) && |
4028 | (bond_mode != BOND_MODE_TLB)) { | ||
3998 | pr_info("xmit_hash_policy param is irrelevant in mode %s\n", | 4029 | pr_info("xmit_hash_policy param is irrelevant in mode %s\n", |
3999 | bond_mode_name(bond_mode)); | 4030 | bond_mode_name(bond_mode)); |
4000 | } else { | 4031 | } else { |
@@ -4079,7 +4110,7 @@ static int bond_check_params(struct bond_params *params) | |||
4079 | } | 4110 | } |
4080 | 4111 | ||
4081 | /* reset values for 802.3ad/TLB/ALB */ | 4112 | /* reset values for 802.3ad/TLB/ALB */ |
4082 | if (BOND_NO_USES_ARP(bond_mode)) { | 4113 | if (!bond_mode_uses_arp(bond_mode)) { |
4083 | if (!miimon) { | 4114 | if (!miimon) { |
4084 | 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"); | 4115 | 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"); |
4085 | pr_warn("Forcing miimon to 100msec\n"); | 4116 | pr_warn("Forcing miimon to 100msec\n"); |
@@ -4161,7 +4192,7 @@ static int bond_check_params(struct bond_params *params) | |||
4161 | catch mistakes */ | 4192 | catch mistakes */ |
4162 | __be32 ip; | 4193 | __be32 ip; |
4163 | if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || | 4194 | if (!in4_pton(arp_ip_target[i], -1, (u8 *)&ip, -1, NULL) || |
4164 | IS_IP_TARGET_UNUSABLE_ADDRESS(ip)) { | 4195 | !bond_is_ip_target_ok(ip)) { |
4165 | pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", | 4196 | pr_warn("Warning: bad arp_ip_target module parameter (%s), ARP monitoring will not be performed\n", |
4166 | arp_ip_target[i]); | 4197 | arp_ip_target[i]); |
4167 | arp_interval = 0; | 4198 | arp_interval = 0; |
@@ -4234,7 +4265,7 @@ static int bond_check_params(struct bond_params *params) | |||
4234 | 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"); | 4265 | 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"); |
4235 | } | 4266 | } |
4236 | 4267 | ||
4237 | if (primary && !USES_PRIMARY(bond_mode)) { | 4268 | if (primary && !bond_mode_uses_primary(bond_mode)) { |
4238 | /* currently, using a primary only makes sense | 4269 | /* currently, using a primary only makes sense |
4239 | * in active backup, TLB or ALB modes | 4270 | * in active backup, TLB or ALB modes |
4240 | */ | 4271 | */ |
@@ -4300,6 +4331,7 @@ static int bond_check_params(struct bond_params *params) | |||
4300 | params->min_links = min_links; | 4331 | params->min_links = min_links; |
4301 | params->lp_interval = lp_interval; | 4332 | params->lp_interval = lp_interval; |
4302 | params->packets_per_slave = packets_per_slave; | 4333 | params->packets_per_slave = packets_per_slave; |
4334 | params->tlb_dynamic_lb = 1; /* Default value */ | ||
4303 | if (packets_per_slave > 0) { | 4335 | if (packets_per_slave > 0) { |
4304 | params->reciprocal_packets_per_slave = | 4336 | params->reciprocal_packets_per_slave = |
4305 | reciprocal_value(packets_per_slave); | 4337 | reciprocal_value(packets_per_slave); |
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c index f847e165d252..5ab3c1847e67 100644 --- a/drivers/net/bonding/bond_netlink.c +++ b/drivers/net/bonding/bond_netlink.c | |||
@@ -56,10 +56,10 @@ 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; |
63 | if (agg) | 63 | if (agg) |
64 | if (nla_put_u16(skb, IFLA_BOND_SLAVE_AD_AGGREGATOR_ID, | 64 | if (nla_put_u16(skb, IFLA_BOND_SLAVE_AD_AGGREGATOR_ID, |
65 | agg->aggregator_identifier)) | 65 | agg->aggregator_identifier)) |
@@ -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 832070298446..540e0167bf24 100644 --- a/drivers/net/bonding/bond_options.c +++ b/drivers/net/bonding/bond_options.c | |||
@@ -70,6 +70,8 @@ static int bond_option_mode_set(struct bonding *bond, | |||
70 | const struct bond_opt_value *newval); | 70 | const struct bond_opt_value *newval); |
71 | static int bond_option_slaves_set(struct bonding *bond, | 71 | static int bond_option_slaves_set(struct bonding *bond, |
72 | const struct bond_opt_value *newval); | 72 | const struct bond_opt_value *newval); |
73 | static int bond_option_tlb_dynamic_lb_set(struct bonding *bond, | ||
74 | const struct bond_opt_value *newval); | ||
73 | 75 | ||
74 | 76 | ||
75 | static const struct bond_opt_value bond_mode_tbl[] = { | 77 | static const struct bond_opt_value bond_mode_tbl[] = { |
@@ -180,6 +182,12 @@ static const struct bond_opt_value bond_lp_interval_tbl[] = { | |||
180 | { NULL, -1, 0}, | 182 | { NULL, -1, 0}, |
181 | }; | 183 | }; |
182 | 184 | ||
185 | static const struct bond_opt_value bond_tlb_dynamic_lb_tbl[] = { | ||
186 | { "off", 0, 0}, | ||
187 | { "on", 1, BOND_VALFLAG_DEFAULT}, | ||
188 | { NULL, -1, 0} | ||
189 | }; | ||
190 | |||
183 | static const struct bond_option bond_opts[] = { | 191 | static const struct bond_option bond_opts[] = { |
184 | [BOND_OPT_MODE] = { | 192 | [BOND_OPT_MODE] = { |
185 | .id = BOND_OPT_MODE, | 193 | .id = BOND_OPT_MODE, |
@@ -200,7 +208,7 @@ static const struct bond_option bond_opts[] = { | |||
200 | [BOND_OPT_XMIT_HASH] = { | 208 | [BOND_OPT_XMIT_HASH] = { |
201 | .id = BOND_OPT_XMIT_HASH, | 209 | .id = BOND_OPT_XMIT_HASH, |
202 | .name = "xmit_hash_policy", | 210 | .name = "xmit_hash_policy", |
203 | .desc = "balance-xor and 802.3ad hashing method", | 211 | .desc = "balance-xor, 802.3ad, and tlb hashing method", |
204 | .values = bond_xmit_hashtype_tbl, | 212 | .values = bond_xmit_hashtype_tbl, |
205 | .set = bond_option_xmit_hash_policy_set | 213 | .set = bond_option_xmit_hash_policy_set |
206 | }, | 214 | }, |
@@ -365,9 +373,33 @@ static const struct bond_option bond_opts[] = { | |||
365 | .flags = BOND_OPTFLAG_RAWVAL, | 373 | .flags = BOND_OPTFLAG_RAWVAL, |
366 | .set = bond_option_slaves_set | 374 | .set = bond_option_slaves_set |
367 | }, | 375 | }, |
376 | [BOND_OPT_TLB_DYNAMIC_LB] = { | ||
377 | .id = BOND_OPT_TLB_DYNAMIC_LB, | ||
378 | .name = "tlb_dynamic_lb", | ||
379 | .desc = "Enable dynamic flow shuffling", | ||
380 | .unsuppmodes = BOND_MODE_ALL_EX(BIT(BOND_MODE_TLB)), | ||
381 | .values = bond_tlb_dynamic_lb_tbl, | ||
382 | .flags = BOND_OPTFLAG_IFDOWN, | ||
383 | .set = bond_option_tlb_dynamic_lb_set, | ||
384 | }, | ||
368 | { } | 385 | { } |
369 | }; | 386 | }; |
370 | 387 | ||
388 | /* Searches for an option by name */ | ||
389 | const struct bond_option *bond_opt_get_by_name(const char *name) | ||
390 | { | ||
391 | const struct bond_option *opt; | ||
392 | int option; | ||
393 | |||
394 | for (option = 0; option < BOND_OPT_LAST; option++) { | ||
395 | opt = bond_opt_get(option); | ||
396 | if (opt && !strcmp(opt->name, name)) | ||
397 | return opt; | ||
398 | } | ||
399 | |||
400 | return NULL; | ||
401 | } | ||
402 | |||
371 | /* Searches for a value in opt's values[] table */ | 403 | /* Searches for a value in opt's values[] table */ |
372 | const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val) | 404 | const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val) |
373 | { | 405 | { |
@@ -641,7 +673,7 @@ const struct bond_option *bond_opt_get(unsigned int option) | |||
641 | 673 | ||
642 | int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newval) | 674 | int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newval) |
643 | { | 675 | { |
644 | if (BOND_NO_USES_ARP(newval->value) && bond->params.arp_interval) { | 676 | if (!bond_mode_uses_arp(newval->value) && bond->params.arp_interval) { |
645 | pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n", | 677 | pr_info("%s: %s mode is incompatible with arp monitoring, start mii monitoring\n", |
646 | bond->dev->name, newval->string); | 678 | bond->dev->name, newval->string); |
647 | /* disable arp monitoring */ | 679 | /* disable arp monitoring */ |
@@ -662,7 +694,7 @@ int bond_option_mode_set(struct bonding *bond, const struct bond_opt_value *newv | |||
662 | static struct net_device *__bond_option_active_slave_get(struct bonding *bond, | 694 | static struct net_device *__bond_option_active_slave_get(struct bonding *bond, |
663 | struct slave *slave) | 695 | struct slave *slave) |
664 | { | 696 | { |
665 | return USES_PRIMARY(bond->params.mode) && slave ? slave->dev : NULL; | 697 | return bond_uses_primary(bond) && slave ? slave->dev : NULL; |
666 | } | 698 | } |
667 | 699 | ||
668 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond) | 700 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond) |
@@ -727,7 +759,7 @@ static int bond_option_active_slave_set(struct bonding *bond, | |||
727 | bond->dev->name, new_active->dev->name); | 759 | bond->dev->name, new_active->dev->name); |
728 | } else { | 760 | } else { |
729 | if (old_active && (new_active->link == BOND_LINK_UP) && | 761 | if (old_active && (new_active->link == BOND_LINK_UP) && |
730 | IS_UP(new_active->dev)) { | 762 | bond_slave_is_up(new_active)) { |
731 | pr_info("%s: Setting %s as active slave\n", | 763 | pr_info("%s: Setting %s as active slave\n", |
732 | bond->dev->name, new_active->dev->name); | 764 | bond->dev->name, new_active->dev->name); |
733 | bond_change_active_slave(bond, new_active); | 765 | bond_change_active_slave(bond, new_active); |
@@ -746,6 +778,10 @@ static int bond_option_active_slave_set(struct bonding *bond, | |||
746 | return ret; | 778 | return ret; |
747 | } | 779 | } |
748 | 780 | ||
781 | /* There are two tricky bits here. First, if MII monitoring is activated, then | ||
782 | * we must disable ARP monitoring. Second, if the timer isn't running, we must | ||
783 | * start it. | ||
784 | */ | ||
749 | static int bond_option_miimon_set(struct bonding *bond, | 785 | static int bond_option_miimon_set(struct bonding *bond, |
750 | const struct bond_opt_value *newval) | 786 | const struct bond_opt_value *newval) |
751 | { | 787 | { |
@@ -784,6 +820,10 @@ static int bond_option_miimon_set(struct bonding *bond, | |||
784 | return 0; | 820 | return 0; |
785 | } | 821 | } |
786 | 822 | ||
823 | /* Set up and down delays. These must be multiples of the | ||
824 | * MII monitoring value, and are stored internally as the multiplier. | ||
825 | * Thus, we must translate to MS for the real world. | ||
826 | */ | ||
787 | static int bond_option_updelay_set(struct bonding *bond, | 827 | static int bond_option_updelay_set(struct bonding *bond, |
788 | const struct bond_opt_value *newval) | 828 | const struct bond_opt_value *newval) |
789 | { | 829 | { |
@@ -842,6 +882,10 @@ static int bond_option_use_carrier_set(struct bonding *bond, | |||
842 | return 0; | 882 | return 0; |
843 | } | 883 | } |
844 | 884 | ||
885 | /* There are two tricky bits here. First, if ARP monitoring is activated, then | ||
886 | * we must disable MII monitoring. Second, if the ARP timer isn't running, | ||
887 | * we must start it. | ||
888 | */ | ||
845 | static int bond_option_arp_interval_set(struct bonding *bond, | 889 | static int bond_option_arp_interval_set(struct bonding *bond, |
846 | const struct bond_opt_value *newval) | 890 | const struct bond_opt_value *newval) |
847 | { | 891 | { |
@@ -899,7 +943,7 @@ static int _bond_option_arp_ip_target_add(struct bonding *bond, __be32 target) | |||
899 | __be32 *targets = bond->params.arp_targets; | 943 | __be32 *targets = bond->params.arp_targets; |
900 | int ind; | 944 | int ind; |
901 | 945 | ||
902 | if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) { | 946 | if (!bond_is_ip_target_ok(target)) { |
903 | pr_err("%s: invalid ARP target %pI4 specified for addition\n", | 947 | pr_err("%s: invalid ARP target %pI4 specified for addition\n", |
904 | bond->dev->name, &target); | 948 | bond->dev->name, &target); |
905 | return -EINVAL; | 949 | return -EINVAL; |
@@ -944,7 +988,7 @@ static int bond_option_arp_ip_target_rem(struct bonding *bond, __be32 target) | |||
944 | unsigned long *targets_rx; | 988 | unsigned long *targets_rx; |
945 | int ind, i; | 989 | int ind, i; |
946 | 990 | ||
947 | if (IS_IP_TARGET_UNUSABLE_ADDRESS(target)) { | 991 | if (!bond_is_ip_target_ok(target)) { |
948 | pr_err("%s: invalid ARP target %pI4 specified for removal\n", | 992 | pr_err("%s: invalid ARP target %pI4 specified for removal\n", |
949 | bond->dev->name, &target); | 993 | bond->dev->name, &target); |
950 | return -EINVAL; | 994 | return -EINVAL; |
@@ -1338,3 +1382,13 @@ err_no_cmd: | |||
1338 | ret = -EPERM; | 1382 | ret = -EPERM; |
1339 | goto out; | 1383 | goto out; |
1340 | } | 1384 | } |
1385 | |||
1386 | static int bond_option_tlb_dynamic_lb_set(struct bonding *bond, | ||
1387 | const struct bond_opt_value *newval) | ||
1388 | { | ||
1389 | pr_info("%s: Setting dynamic-lb to %s (%llu)\n", | ||
1390 | bond->dev->name, newval->string, newval->value); | ||
1391 | bond->params.tlb_dynamic_lb = newval->value; | ||
1392 | |||
1393 | return 0; | ||
1394 | } | ||
diff --git a/drivers/net/bonding/bond_options.h b/drivers/net/bonding/bond_options.h index 12be9e1bfb0c..17ded5b29176 100644 --- a/drivers/net/bonding/bond_options.h +++ b/drivers/net/bonding/bond_options.h | |||
@@ -62,6 +62,7 @@ enum { | |||
62 | BOND_OPT_RESEND_IGMP, | 62 | BOND_OPT_RESEND_IGMP, |
63 | BOND_OPT_LP_INTERVAL, | 63 | BOND_OPT_LP_INTERVAL, |
64 | BOND_OPT_SLAVES, | 64 | BOND_OPT_SLAVES, |
65 | BOND_OPT_TLB_DYNAMIC_LB, | ||
65 | BOND_OPT_LAST | 66 | BOND_OPT_LAST |
66 | }; | 67 | }; |
67 | 68 | ||
@@ -104,6 +105,7 @@ int bond_opt_tryset_rtnl(struct bonding *bond, unsigned int option, char *buf); | |||
104 | const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, | 105 | const struct bond_opt_value *bond_opt_parse(const struct bond_option *opt, |
105 | struct bond_opt_value *val); | 106 | struct bond_opt_value *val); |
106 | const struct bond_option *bond_opt_get(unsigned int option); | 107 | const struct bond_option *bond_opt_get(unsigned int option); |
108 | const struct bond_option *bond_opt_get_by_name(const char *name); | ||
107 | const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val); | 109 | const struct bond_opt_value *bond_opt_get_val(unsigned int option, u64 val); |
108 | 110 | ||
109 | /* This helper is used to initialize a bond_opt_value structure for parameter | 111 | /* This helper is used to initialize a bond_opt_value structure for parameter |
diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c index 013fdd0f45e9..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,9 +188,9 @@ 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 | ||
195 | if (agg) | 195 | if (agg) |
196 | seq_printf(seq, "Aggregator ID: %d\n", | 196 | seq_printf(seq, "Aggregator ID: %d\n", |
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 5f6babcfc26e..daed52f68ce1 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c | |||
@@ -45,8 +45,7 @@ | |||
45 | #define to_dev(obj) container_of(obj, struct device, kobj) | 45 | #define to_dev(obj) container_of(obj, struct device, kobj) |
46 | #define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd)))) | 46 | #define to_bond(cd) ((struct bonding *)(netdev_priv(to_net_dev(cd)))) |
47 | 47 | ||
48 | /* | 48 | /* "show" function for the bond_masters attribute. |
49 | * "show" function for the bond_masters attribute. | ||
50 | * The class parameter is ignored. | 49 | * The class parameter is ignored. |
51 | */ | 50 | */ |
52 | static ssize_t bonding_show_bonds(struct class *cls, | 51 | static ssize_t bonding_show_bonds(struct class *cls, |
@@ -88,14 +87,12 @@ static struct net_device *bond_get_by_name(struct bond_net *bn, const char *ifna | |||
88 | return NULL; | 87 | return NULL; |
89 | } | 88 | } |
90 | 89 | ||
91 | /* | 90 | /* "store" function for the bond_masters attribute. This is what |
92 | * "store" function for the bond_masters attribute. This is what | ||
93 | * creates and deletes entire bonds. | 91 | * creates and deletes entire bonds. |
94 | * | 92 | * |
95 | * The class parameter is ignored. | 93 | * The class parameter is ignored. |
96 | * | 94 | * |
97 | */ | 95 | */ |
98 | |||
99 | static ssize_t bonding_store_bonds(struct class *cls, | 96 | static ssize_t bonding_store_bonds(struct class *cls, |
100 | struct class_attribute *attr, | 97 | struct class_attribute *attr, |
101 | const char *buffer, size_t count) | 98 | const char *buffer, size_t count) |
@@ -158,9 +155,26 @@ static const struct class_attribute class_attr_bonding_masters = { | |||
158 | .store = bonding_store_bonds, | 155 | .store = bonding_store_bonds, |
159 | }; | 156 | }; |
160 | 157 | ||
161 | /* | 158 | /* Generic "store" method for bonding sysfs option setting */ |
162 | * Show the slaves in the current bond. | 159 | static ssize_t bonding_sysfs_store_option(struct device *d, |
163 | */ | 160 | struct device_attribute *attr, |
161 | const char *buffer, size_t count) | ||
162 | { | ||
163 | struct bonding *bond = to_bond(d); | ||
164 | const struct bond_option *opt; | ||
165 | int ret; | ||
166 | |||
167 | opt = bond_opt_get_by_name(attr->attr.name); | ||
168 | if (WARN_ON(!opt)) | ||
169 | return -ENOENT; | ||
170 | ret = bond_opt_tryset_rtnl(bond, opt->id, (char *)buffer); | ||
171 | if (!ret) | ||
172 | ret = count; | ||
173 | |||
174 | return ret; | ||
175 | } | ||
176 | |||
177 | /* Show the slaves in the current bond. */ | ||
164 | static ssize_t bonding_show_slaves(struct device *d, | 178 | static ssize_t bonding_show_slaves(struct device *d, |
165 | struct device_attribute *attr, char *buf) | 179 | struct device_attribute *attr, char *buf) |
166 | { | 180 | { |
@@ -190,62 +204,24 @@ static ssize_t bonding_show_slaves(struct device *d, | |||
190 | 204 | ||
191 | return res; | 205 | return res; |
192 | } | 206 | } |
193 | |||
194 | /* | ||
195 | * Set the slaves in the current bond. | ||
196 | * This is supposed to be only thin wrapper for bond_enslave and bond_release. | ||
197 | * All hard work should be done there. | ||
198 | */ | ||
199 | static ssize_t bonding_store_slaves(struct device *d, | ||
200 | struct device_attribute *attr, | ||
201 | const char *buffer, size_t count) | ||
202 | { | ||
203 | struct bonding *bond = to_bond(d); | ||
204 | int ret; | ||
205 | |||
206 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_SLAVES, (char *)buffer); | ||
207 | if (!ret) | ||
208 | ret = count; | ||
209 | |||
210 | return ret; | ||
211 | } | ||
212 | static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, | 207 | static DEVICE_ATTR(slaves, S_IRUGO | S_IWUSR, bonding_show_slaves, |
213 | bonding_store_slaves); | 208 | bonding_sysfs_store_option); |
214 | 209 | ||
215 | /* | 210 | /* Show the bonding mode. */ |
216 | * Show and set the bonding mode. The bond interface must be down to | ||
217 | * change the mode. | ||
218 | */ | ||
219 | static ssize_t bonding_show_mode(struct device *d, | 211 | static ssize_t bonding_show_mode(struct device *d, |
220 | struct device_attribute *attr, char *buf) | 212 | struct device_attribute *attr, char *buf) |
221 | { | 213 | { |
222 | struct bonding *bond = to_bond(d); | 214 | struct bonding *bond = to_bond(d); |
223 | const struct bond_opt_value *val; | 215 | const struct bond_opt_value *val; |
224 | 216 | ||
225 | val = bond_opt_get_val(BOND_OPT_MODE, bond->params.mode); | 217 | val = bond_opt_get_val(BOND_OPT_MODE, BOND_MODE(bond)); |
226 | 218 | ||
227 | return sprintf(buf, "%s %d\n", val->string, bond->params.mode); | 219 | return sprintf(buf, "%s %d\n", val->string, BOND_MODE(bond)); |
228 | } | ||
229 | |||
230 | static ssize_t bonding_store_mode(struct device *d, | ||
231 | struct device_attribute *attr, | ||
232 | const char *buf, size_t count) | ||
233 | { | ||
234 | struct bonding *bond = to_bond(d); | ||
235 | int ret; | ||
236 | |||
237 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_MODE, (char *)buf); | ||
238 | if (!ret) | ||
239 | ret = count; | ||
240 | |||
241 | return ret; | ||
242 | } | 220 | } |
243 | static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, | 221 | static DEVICE_ATTR(mode, S_IRUGO | S_IWUSR, |
244 | bonding_show_mode, bonding_store_mode); | 222 | bonding_show_mode, bonding_sysfs_store_option); |
245 | 223 | ||
246 | /* | 224 | /* Show the bonding transmit hash method. */ |
247 | * Show and set the bonding transmit hash method. | ||
248 | */ | ||
249 | static ssize_t bonding_show_xmit_hash(struct device *d, | 225 | static ssize_t bonding_show_xmit_hash(struct device *d, |
250 | struct device_attribute *attr, | 226 | struct device_attribute *attr, |
251 | char *buf) | 227 | char *buf) |
@@ -257,26 +233,10 @@ static ssize_t bonding_show_xmit_hash(struct device *d, | |||
257 | 233 | ||
258 | return sprintf(buf, "%s %d\n", val->string, bond->params.xmit_policy); | 234 | return sprintf(buf, "%s %d\n", val->string, bond->params.xmit_policy); |
259 | } | 235 | } |
260 | |||
261 | static ssize_t bonding_store_xmit_hash(struct device *d, | ||
262 | struct device_attribute *attr, | ||
263 | const char *buf, size_t count) | ||
264 | { | ||
265 | struct bonding *bond = to_bond(d); | ||
266 | int ret; | ||
267 | |||
268 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_XMIT_HASH, (char *)buf); | ||
269 | if (!ret) | ||
270 | ret = count; | ||
271 | |||
272 | return ret; | ||
273 | } | ||
274 | static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, | 236 | static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR, |
275 | bonding_show_xmit_hash, bonding_store_xmit_hash); | 237 | bonding_show_xmit_hash, bonding_sysfs_store_option); |
276 | 238 | ||
277 | /* | 239 | /* Show arp_validate. */ |
278 | * Show and set arp_validate. | ||
279 | */ | ||
280 | static ssize_t bonding_show_arp_validate(struct device *d, | 240 | static ssize_t bonding_show_arp_validate(struct device *d, |
281 | struct device_attribute *attr, | 241 | struct device_attribute *attr, |
282 | char *buf) | 242 | char *buf) |
@@ -289,26 +249,10 @@ static ssize_t bonding_show_arp_validate(struct device *d, | |||
289 | 249 | ||
290 | return sprintf(buf, "%s %d\n", val->string, bond->params.arp_validate); | 250 | return sprintf(buf, "%s %d\n", val->string, bond->params.arp_validate); |
291 | } | 251 | } |
292 | |||
293 | static ssize_t bonding_store_arp_validate(struct device *d, | ||
294 | struct device_attribute *attr, | ||
295 | const char *buf, size_t count) | ||
296 | { | ||
297 | struct bonding *bond = to_bond(d); | ||
298 | int ret; | ||
299 | |||
300 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ARP_VALIDATE, (char *)buf); | ||
301 | if (!ret) | ||
302 | ret = count; | ||
303 | |||
304 | return ret; | ||
305 | } | ||
306 | |||
307 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, | 252 | static DEVICE_ATTR(arp_validate, S_IRUGO | S_IWUSR, bonding_show_arp_validate, |
308 | bonding_store_arp_validate); | 253 | bonding_sysfs_store_option); |
309 | /* | 254 | |
310 | * Show and set arp_all_targets. | 255 | /* Show arp_all_targets. */ |
311 | */ | ||
312 | static ssize_t bonding_show_arp_all_targets(struct device *d, | 256 | static ssize_t bonding_show_arp_all_targets(struct device *d, |
313 | struct device_attribute *attr, | 257 | struct device_attribute *attr, |
314 | char *buf) | 258 | char *buf) |
@@ -321,28 +265,10 @@ static ssize_t bonding_show_arp_all_targets(struct device *d, | |||
321 | return sprintf(buf, "%s %d\n", | 265 | return sprintf(buf, "%s %d\n", |
322 | val->string, bond->params.arp_all_targets); | 266 | val->string, bond->params.arp_all_targets); |
323 | } | 267 | } |
324 | |||
325 | static ssize_t bonding_store_arp_all_targets(struct device *d, | ||
326 | struct device_attribute *attr, | ||
327 | const char *buf, size_t count) | ||
328 | { | ||
329 | struct bonding *bond = to_bond(d); | ||
330 | int ret; | ||
331 | |||
332 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ARP_ALL_TARGETS, (char *)buf); | ||
333 | if (!ret) | ||
334 | ret = count; | ||
335 | |||
336 | return ret; | ||
337 | } | ||
338 | |||
339 | static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR, | 268 | static DEVICE_ATTR(arp_all_targets, S_IRUGO | S_IWUSR, |
340 | bonding_show_arp_all_targets, bonding_store_arp_all_targets); | 269 | bonding_show_arp_all_targets, bonding_sysfs_store_option); |
341 | 270 | ||
342 | /* | 271 | /* Show fail_over_mac. */ |
343 | * Show and store fail_over_mac. User only allowed to change the | ||
344 | * value when there are no slaves. | ||
345 | */ | ||
346 | static ssize_t bonding_show_fail_over_mac(struct device *d, | 272 | static ssize_t bonding_show_fail_over_mac(struct device *d, |
347 | struct device_attribute *attr, | 273 | struct device_attribute *attr, |
348 | char *buf) | 274 | char *buf) |
@@ -355,30 +281,10 @@ static ssize_t bonding_show_fail_over_mac(struct device *d, | |||
355 | 281 | ||
356 | return sprintf(buf, "%s %d\n", val->string, bond->params.fail_over_mac); | 282 | return sprintf(buf, "%s %d\n", val->string, bond->params.fail_over_mac); |
357 | } | 283 | } |
358 | |||
359 | static ssize_t bonding_store_fail_over_mac(struct device *d, | ||
360 | struct device_attribute *attr, | ||
361 | const char *buf, size_t count) | ||
362 | { | ||
363 | struct bonding *bond = to_bond(d); | ||
364 | int ret; | ||
365 | |||
366 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_FAIL_OVER_MAC, (char *)buf); | ||
367 | if (!ret) | ||
368 | ret = count; | ||
369 | |||
370 | return ret; | ||
371 | } | ||
372 | |||
373 | static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, | 284 | static DEVICE_ATTR(fail_over_mac, S_IRUGO | S_IWUSR, |
374 | bonding_show_fail_over_mac, bonding_store_fail_over_mac); | 285 | bonding_show_fail_over_mac, bonding_sysfs_store_option); |
375 | 286 | ||
376 | /* | 287 | /* Show the arp timer interval. */ |
377 | * Show and set the arp timer interval. There are two tricky bits | ||
378 | * here. First, if ARP monitoring is activated, then we must disable | ||
379 | * MII monitoring. Second, if the ARP timer isn't running, we must | ||
380 | * start it. | ||
381 | */ | ||
382 | static ssize_t bonding_show_arp_interval(struct device *d, | 288 | static ssize_t bonding_show_arp_interval(struct device *d, |
383 | struct device_attribute *attr, | 289 | struct device_attribute *attr, |
384 | char *buf) | 290 | char *buf) |
@@ -387,26 +293,10 @@ static ssize_t bonding_show_arp_interval(struct device *d, | |||
387 | 293 | ||
388 | return sprintf(buf, "%d\n", bond->params.arp_interval); | 294 | return sprintf(buf, "%d\n", bond->params.arp_interval); |
389 | } | 295 | } |
390 | |||
391 | static ssize_t bonding_store_arp_interval(struct device *d, | ||
392 | struct device_attribute *attr, | ||
393 | const char *buf, size_t count) | ||
394 | { | ||
395 | struct bonding *bond = to_bond(d); | ||
396 | int ret; | ||
397 | |||
398 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ARP_INTERVAL, (char *)buf); | ||
399 | if (!ret) | ||
400 | ret = count; | ||
401 | |||
402 | return ret; | ||
403 | } | ||
404 | static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR, | 296 | static DEVICE_ATTR(arp_interval, S_IRUGO | S_IWUSR, |
405 | bonding_show_arp_interval, bonding_store_arp_interval); | 297 | bonding_show_arp_interval, bonding_sysfs_store_option); |
406 | 298 | ||
407 | /* | 299 | /* Show the arp targets. */ |
408 | * Show and set the arp targets. | ||
409 | */ | ||
410 | static ssize_t bonding_show_arp_targets(struct device *d, | 300 | static ssize_t bonding_show_arp_targets(struct device *d, |
411 | struct device_attribute *attr, | 301 | struct device_attribute *attr, |
412 | char *buf) | 302 | char *buf) |
@@ -424,27 +314,10 @@ static ssize_t bonding_show_arp_targets(struct device *d, | |||
424 | 314 | ||
425 | return res; | 315 | return res; |
426 | } | 316 | } |
317 | static DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR, | ||
318 | bonding_show_arp_targets, bonding_sysfs_store_option); | ||
427 | 319 | ||
428 | static ssize_t bonding_store_arp_targets(struct device *d, | 320 | /* Show the up and down delays. */ |
429 | struct device_attribute *attr, | ||
430 | const char *buf, size_t count) | ||
431 | { | ||
432 | struct bonding *bond = to_bond(d); | ||
433 | int ret; | ||
434 | |||
435 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ARP_TARGETS, (char *)buf); | ||
436 | if (!ret) | ||
437 | ret = count; | ||
438 | |||
439 | return ret; | ||
440 | } | ||
441 | static DEVICE_ATTR(arp_ip_target, S_IRUGO | S_IWUSR , bonding_show_arp_targets, bonding_store_arp_targets); | ||
442 | |||
443 | /* | ||
444 | * Show and set the up and down delays. These must be multiples of the | ||
445 | * MII monitoring value, and are stored internally as the multiplier. | ||
446 | * Thus, we must translate to MS for the real world. | ||
447 | */ | ||
448 | static ssize_t bonding_show_downdelay(struct device *d, | 321 | static ssize_t bonding_show_downdelay(struct device *d, |
449 | struct device_attribute *attr, | 322 | struct device_attribute *attr, |
450 | char *buf) | 323 | char *buf) |
@@ -453,22 +326,8 @@ static ssize_t bonding_show_downdelay(struct device *d, | |||
453 | 326 | ||
454 | return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon); | 327 | return sprintf(buf, "%d\n", bond->params.downdelay * bond->params.miimon); |
455 | } | 328 | } |
456 | |||
457 | static ssize_t bonding_store_downdelay(struct device *d, | ||
458 | struct device_attribute *attr, | ||
459 | const char *buf, size_t count) | ||
460 | { | ||
461 | struct bonding *bond = to_bond(d); | ||
462 | int ret; | ||
463 | |||
464 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_DOWNDELAY, (char *)buf); | ||
465 | if (!ret) | ||
466 | ret = count; | ||
467 | |||
468 | return ret; | ||
469 | } | ||
470 | static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR, | 329 | static DEVICE_ATTR(downdelay, S_IRUGO | S_IWUSR, |
471 | bonding_show_downdelay, bonding_store_downdelay); | 330 | bonding_show_downdelay, bonding_sysfs_store_option); |
472 | 331 | ||
473 | static ssize_t bonding_show_updelay(struct device *d, | 332 | static ssize_t bonding_show_updelay(struct device *d, |
474 | struct device_attribute *attr, | 333 | struct device_attribute *attr, |
@@ -479,27 +338,10 @@ static ssize_t bonding_show_updelay(struct device *d, | |||
479 | return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon); | 338 | return sprintf(buf, "%d\n", bond->params.updelay * bond->params.miimon); |
480 | 339 | ||
481 | } | 340 | } |
482 | |||
483 | static ssize_t bonding_store_updelay(struct device *d, | ||
484 | struct device_attribute *attr, | ||
485 | const char *buf, size_t count) | ||
486 | { | ||
487 | struct bonding *bond = to_bond(d); | ||
488 | int ret; | ||
489 | |||
490 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_UPDELAY, (char *)buf); | ||
491 | if (!ret) | ||
492 | ret = count; | ||
493 | |||
494 | return ret; | ||
495 | } | ||
496 | static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR, | 341 | static DEVICE_ATTR(updelay, S_IRUGO | S_IWUSR, |
497 | bonding_show_updelay, bonding_store_updelay); | 342 | bonding_show_updelay, bonding_sysfs_store_option); |
498 | 343 | ||
499 | /* | 344 | /* Show the LACP interval. */ |
500 | * Show and set the LACP interval. Interface must be down, and the mode | ||
501 | * must be set to 802.3ad mode. | ||
502 | */ | ||
503 | static ssize_t bonding_show_lacp(struct device *d, | 345 | static ssize_t bonding_show_lacp(struct device *d, |
504 | struct device_attribute *attr, | 346 | struct device_attribute *attr, |
505 | char *buf) | 347 | char *buf) |
@@ -511,22 +353,8 @@ static ssize_t bonding_show_lacp(struct device *d, | |||
511 | 353 | ||
512 | return sprintf(buf, "%s %d\n", val->string, bond->params.lacp_fast); | 354 | return sprintf(buf, "%s %d\n", val->string, bond->params.lacp_fast); |
513 | } | 355 | } |
514 | |||
515 | static ssize_t bonding_store_lacp(struct device *d, | ||
516 | struct device_attribute *attr, | ||
517 | const char *buf, size_t count) | ||
518 | { | ||
519 | struct bonding *bond = to_bond(d); | ||
520 | int ret; | ||
521 | |||
522 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_LACP_RATE, (char *)buf); | ||
523 | if (!ret) | ||
524 | ret = count; | ||
525 | |||
526 | return ret; | ||
527 | } | ||
528 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, | 356 | static DEVICE_ATTR(lacp_rate, S_IRUGO | S_IWUSR, |
529 | bonding_show_lacp, bonding_store_lacp); | 357 | bonding_show_lacp, bonding_sysfs_store_option); |
530 | 358 | ||
531 | static ssize_t bonding_show_min_links(struct device *d, | 359 | static ssize_t bonding_show_min_links(struct device *d, |
532 | struct device_attribute *attr, | 360 | struct device_attribute *attr, |
@@ -536,22 +364,8 @@ static ssize_t bonding_show_min_links(struct device *d, | |||
536 | 364 | ||
537 | return sprintf(buf, "%u\n", bond->params.min_links); | 365 | return sprintf(buf, "%u\n", bond->params.min_links); |
538 | } | 366 | } |
539 | |||
540 | static ssize_t bonding_store_min_links(struct device *d, | ||
541 | struct device_attribute *attr, | ||
542 | const char *buf, size_t count) | ||
543 | { | ||
544 | struct bonding *bond = to_bond(d); | ||
545 | int ret; | ||
546 | |||
547 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_MINLINKS, (char *)buf); | ||
548 | if (!ret) | ||
549 | ret = count; | ||
550 | |||
551 | return ret; | ||
552 | } | ||
553 | static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR, | 367 | static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR, |
554 | bonding_show_min_links, bonding_store_min_links); | 368 | bonding_show_min_links, bonding_sysfs_store_option); |
555 | 369 | ||
556 | static ssize_t bonding_show_ad_select(struct device *d, | 370 | static ssize_t bonding_show_ad_select(struct device *d, |
557 | struct device_attribute *attr, | 371 | struct device_attribute *attr, |
@@ -564,27 +378,10 @@ static ssize_t bonding_show_ad_select(struct device *d, | |||
564 | 378 | ||
565 | return sprintf(buf, "%s %d\n", val->string, bond->params.ad_select); | 379 | return sprintf(buf, "%s %d\n", val->string, bond->params.ad_select); |
566 | } | 380 | } |
567 | |||
568 | |||
569 | static ssize_t bonding_store_ad_select(struct device *d, | ||
570 | struct device_attribute *attr, | ||
571 | const char *buf, size_t count) | ||
572 | { | ||
573 | struct bonding *bond = to_bond(d); | ||
574 | int ret; | ||
575 | |||
576 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_AD_SELECT, (char *)buf); | ||
577 | if (!ret) | ||
578 | ret = count; | ||
579 | |||
580 | return ret; | ||
581 | } | ||
582 | static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, | 381 | static DEVICE_ATTR(ad_select, S_IRUGO | S_IWUSR, |
583 | bonding_show_ad_select, bonding_store_ad_select); | 382 | bonding_show_ad_select, bonding_sysfs_store_option); |
584 | 383 | ||
585 | /* | 384 | /* Show and set the number of peer notifications to send after a failover event. */ |
586 | * Show and set the number of peer notifications to send after a failover event. | ||
587 | */ | ||
588 | static ssize_t bonding_show_num_peer_notif(struct device *d, | 385 | static ssize_t bonding_show_num_peer_notif(struct device *d, |
589 | struct device_attribute *attr, | 386 | struct device_attribute *attr, |
590 | char *buf) | 387 | char *buf) |
@@ -611,12 +408,7 @@ static DEVICE_ATTR(num_grat_arp, S_IRUGO | S_IWUSR, | |||
611 | static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, | 408 | static DEVICE_ATTR(num_unsol_na, S_IRUGO | S_IWUSR, |
612 | bonding_show_num_peer_notif, bonding_store_num_peer_notif); | 409 | bonding_show_num_peer_notif, bonding_store_num_peer_notif); |
613 | 410 | ||
614 | /* | 411 | /* Show the MII monitor interval. */ |
615 | * Show and set the MII monitor interval. There are two tricky bits | ||
616 | * here. First, if MII monitoring is activated, then we must disable | ||
617 | * ARP monitoring. Second, if the timer isn't running, we must | ||
618 | * start it. | ||
619 | */ | ||
620 | static ssize_t bonding_show_miimon(struct device *d, | 412 | static ssize_t bonding_show_miimon(struct device *d, |
621 | struct device_attribute *attr, | 413 | struct device_attribute *attr, |
622 | char *buf) | 414 | char *buf) |
@@ -625,30 +417,10 @@ static ssize_t bonding_show_miimon(struct device *d, | |||
625 | 417 | ||
626 | return sprintf(buf, "%d\n", bond->params.miimon); | 418 | return sprintf(buf, "%d\n", bond->params.miimon); |
627 | } | 419 | } |
628 | |||
629 | static ssize_t bonding_store_miimon(struct device *d, | ||
630 | struct device_attribute *attr, | ||
631 | const char *buf, size_t count) | ||
632 | { | ||
633 | struct bonding *bond = to_bond(d); | ||
634 | int ret; | ||
635 | |||
636 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_MIIMON, (char *)buf); | ||
637 | if (!ret) | ||
638 | ret = count; | ||
639 | |||
640 | return ret; | ||
641 | } | ||
642 | static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, | 420 | static DEVICE_ATTR(miimon, S_IRUGO | S_IWUSR, |
643 | bonding_show_miimon, bonding_store_miimon); | 421 | bonding_show_miimon, bonding_sysfs_store_option); |
644 | 422 | ||
645 | /* | 423 | /* Show the primary slave. */ |
646 | * Show and set the primary slave. The store function is much | ||
647 | * simpler than bonding_store_slaves function because it only needs to | ||
648 | * handle one interface name. | ||
649 | * The bond must be a mode that supports a primary for this be | ||
650 | * set. | ||
651 | */ | ||
652 | static ssize_t bonding_show_primary(struct device *d, | 424 | static ssize_t bonding_show_primary(struct device *d, |
653 | struct device_attribute *attr, | 425 | struct device_attribute *attr, |
654 | char *buf) | 426 | char *buf) |
@@ -661,26 +433,10 @@ static ssize_t bonding_show_primary(struct device *d, | |||
661 | 433 | ||
662 | return count; | 434 | return count; |
663 | } | 435 | } |
664 | |||
665 | static ssize_t bonding_store_primary(struct device *d, | ||
666 | struct device_attribute *attr, | ||
667 | const char *buf, size_t count) | ||
668 | { | ||
669 | struct bonding *bond = to_bond(d); | ||
670 | int ret; | ||
671 | |||
672 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_PRIMARY, (char *)buf); | ||
673 | if (!ret) | ||
674 | ret = count; | ||
675 | |||
676 | return ret; | ||
677 | } | ||
678 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, | 436 | static DEVICE_ATTR(primary, S_IRUGO | S_IWUSR, |
679 | bonding_show_primary, bonding_store_primary); | 437 | bonding_show_primary, bonding_sysfs_store_option); |
680 | 438 | ||
681 | /* | 439 | /* Show the primary_reselect flag. */ |
682 | * Show and set the primary_reselect flag. | ||
683 | */ | ||
684 | static ssize_t bonding_show_primary_reselect(struct device *d, | 440 | static ssize_t bonding_show_primary_reselect(struct device *d, |
685 | struct device_attribute *attr, | 441 | struct device_attribute *attr, |
686 | char *buf) | 442 | char *buf) |
@@ -694,28 +450,10 @@ static ssize_t bonding_show_primary_reselect(struct device *d, | |||
694 | return sprintf(buf, "%s %d\n", | 450 | return sprintf(buf, "%s %d\n", |
695 | val->string, bond->params.primary_reselect); | 451 | val->string, bond->params.primary_reselect); |
696 | } | 452 | } |
697 | |||
698 | static ssize_t bonding_store_primary_reselect(struct device *d, | ||
699 | struct device_attribute *attr, | ||
700 | const char *buf, size_t count) | ||
701 | { | ||
702 | struct bonding *bond = to_bond(d); | ||
703 | int ret; | ||
704 | |||
705 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_PRIMARY_RESELECT, | ||
706 | (char *)buf); | ||
707 | if (!ret) | ||
708 | ret = count; | ||
709 | |||
710 | return ret; | ||
711 | } | ||
712 | static DEVICE_ATTR(primary_reselect, S_IRUGO | S_IWUSR, | 453 | static DEVICE_ATTR(primary_reselect, S_IRUGO | S_IWUSR, |
713 | bonding_show_primary_reselect, | 454 | bonding_show_primary_reselect, bonding_sysfs_store_option); |
714 | bonding_store_primary_reselect); | ||
715 | 455 | ||
716 | /* | 456 | /* Show the use_carrier flag. */ |
717 | * Show and set the use_carrier flag. | ||
718 | */ | ||
719 | static ssize_t bonding_show_carrier(struct device *d, | 457 | static ssize_t bonding_show_carrier(struct device *d, |
720 | struct device_attribute *attr, | 458 | struct device_attribute *attr, |
721 | char *buf) | 459 | char *buf) |
@@ -724,27 +462,11 @@ static ssize_t bonding_show_carrier(struct device *d, | |||
724 | 462 | ||
725 | return sprintf(buf, "%d\n", bond->params.use_carrier); | 463 | return sprintf(buf, "%d\n", bond->params.use_carrier); |
726 | } | 464 | } |
727 | |||
728 | static ssize_t bonding_store_carrier(struct device *d, | ||
729 | struct device_attribute *attr, | ||
730 | const char *buf, size_t count) | ||
731 | { | ||
732 | struct bonding *bond = to_bond(d); | ||
733 | int ret; | ||
734 | |||
735 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_USE_CARRIER, (char *)buf); | ||
736 | if (!ret) | ||
737 | ret = count; | ||
738 | |||
739 | return ret; | ||
740 | } | ||
741 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, | 465 | static DEVICE_ATTR(use_carrier, S_IRUGO | S_IWUSR, |
742 | bonding_show_carrier, bonding_store_carrier); | 466 | bonding_show_carrier, bonding_sysfs_store_option); |
743 | 467 | ||
744 | 468 | ||
745 | /* | 469 | /* Show currently active_slave. */ |
746 | * Show and set currently active_slave. | ||
747 | */ | ||
748 | static ssize_t bonding_show_active_slave(struct device *d, | 470 | static ssize_t bonding_show_active_slave(struct device *d, |
749 | struct device_attribute *attr, | 471 | struct device_attribute *attr, |
750 | char *buf) | 472 | char *buf) |
@@ -761,27 +483,10 @@ static ssize_t bonding_show_active_slave(struct device *d, | |||
761 | 483 | ||
762 | return count; | 484 | return count; |
763 | } | 485 | } |
764 | |||
765 | static ssize_t bonding_store_active_slave(struct device *d, | ||
766 | struct device_attribute *attr, | ||
767 | const char *buf, size_t count) | ||
768 | { | ||
769 | struct bonding *bond = to_bond(d); | ||
770 | int ret; | ||
771 | |||
772 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ACTIVE_SLAVE, (char *)buf); | ||
773 | if (!ret) | ||
774 | ret = count; | ||
775 | |||
776 | return ret; | ||
777 | } | ||
778 | static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, | 486 | static DEVICE_ATTR(active_slave, S_IRUGO | S_IWUSR, |
779 | bonding_show_active_slave, bonding_store_active_slave); | 487 | bonding_show_active_slave, bonding_sysfs_store_option); |
780 | |||
781 | 488 | ||
782 | /* | 489 | /* Show link status of the bond interface. */ |
783 | * Show link status of the bond interface. | ||
784 | */ | ||
785 | static ssize_t bonding_show_mii_status(struct device *d, | 490 | static ssize_t bonding_show_mii_status(struct device *d, |
786 | struct device_attribute *attr, | 491 | struct device_attribute *attr, |
787 | char *buf) | 492 | char *buf) |
@@ -792,9 +497,7 @@ static ssize_t bonding_show_mii_status(struct device *d, | |||
792 | } | 497 | } |
793 | static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); | 498 | static DEVICE_ATTR(mii_status, S_IRUGO, bonding_show_mii_status, NULL); |
794 | 499 | ||
795 | /* | 500 | /* Show current 802.3ad aggregator ID. */ |
796 | * Show current 802.3ad aggregator ID. | ||
797 | */ | ||
798 | static ssize_t bonding_show_ad_aggregator(struct device *d, | 501 | static ssize_t bonding_show_ad_aggregator(struct device *d, |
799 | struct device_attribute *attr, | 502 | struct device_attribute *attr, |
800 | char *buf) | 503 | char *buf) |
@@ -802,7 +505,7 @@ static ssize_t bonding_show_ad_aggregator(struct device *d, | |||
802 | int count = 0; | 505 | int count = 0; |
803 | struct bonding *bond = to_bond(d); | 506 | struct bonding *bond = to_bond(d); |
804 | 507 | ||
805 | if (bond->params.mode == BOND_MODE_8023AD) { | 508 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
806 | struct ad_info ad_info; | 509 | struct ad_info ad_info; |
807 | count = sprintf(buf, "%d\n", | 510 | count = sprintf(buf, "%d\n", |
808 | bond_3ad_get_active_agg_info(bond, &ad_info) | 511 | bond_3ad_get_active_agg_info(bond, &ad_info) |
@@ -814,9 +517,7 @@ static ssize_t bonding_show_ad_aggregator(struct device *d, | |||
814 | static DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL); | 517 | static DEVICE_ATTR(ad_aggregator, S_IRUGO, bonding_show_ad_aggregator, NULL); |
815 | 518 | ||
816 | 519 | ||
817 | /* | 520 | /* Show number of active 802.3ad ports. */ |
818 | * Show number of active 802.3ad ports. | ||
819 | */ | ||
820 | static ssize_t bonding_show_ad_num_ports(struct device *d, | 521 | static ssize_t bonding_show_ad_num_ports(struct device *d, |
821 | struct device_attribute *attr, | 522 | struct device_attribute *attr, |
822 | char *buf) | 523 | char *buf) |
@@ -824,7 +525,7 @@ static ssize_t bonding_show_ad_num_ports(struct device *d, | |||
824 | int count = 0; | 525 | int count = 0; |
825 | struct bonding *bond = to_bond(d); | 526 | struct bonding *bond = to_bond(d); |
826 | 527 | ||
827 | if (bond->params.mode == BOND_MODE_8023AD) { | 528 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
828 | struct ad_info ad_info; | 529 | struct ad_info ad_info; |
829 | count = sprintf(buf, "%d\n", | 530 | count = sprintf(buf, "%d\n", |
830 | bond_3ad_get_active_agg_info(bond, &ad_info) | 531 | bond_3ad_get_active_agg_info(bond, &ad_info) |
@@ -836,9 +537,7 @@ static ssize_t bonding_show_ad_num_ports(struct device *d, | |||
836 | static DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL); | 537 | static DEVICE_ATTR(ad_num_ports, S_IRUGO, bonding_show_ad_num_ports, NULL); |
837 | 538 | ||
838 | 539 | ||
839 | /* | 540 | /* Show current 802.3ad actor key. */ |
840 | * Show current 802.3ad actor key. | ||
841 | */ | ||
842 | static ssize_t bonding_show_ad_actor_key(struct device *d, | 541 | static ssize_t bonding_show_ad_actor_key(struct device *d, |
843 | struct device_attribute *attr, | 542 | struct device_attribute *attr, |
844 | char *buf) | 543 | char *buf) |
@@ -846,7 +545,7 @@ static ssize_t bonding_show_ad_actor_key(struct device *d, | |||
846 | int count = 0; | 545 | int count = 0; |
847 | struct bonding *bond = to_bond(d); | 546 | struct bonding *bond = to_bond(d); |
848 | 547 | ||
849 | if (bond->params.mode == BOND_MODE_8023AD) { | 548 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
850 | struct ad_info ad_info; | 549 | struct ad_info ad_info; |
851 | count = sprintf(buf, "%d\n", | 550 | count = sprintf(buf, "%d\n", |
852 | bond_3ad_get_active_agg_info(bond, &ad_info) | 551 | bond_3ad_get_active_agg_info(bond, &ad_info) |
@@ -858,9 +557,7 @@ static ssize_t bonding_show_ad_actor_key(struct device *d, | |||
858 | static DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL); | 557 | static DEVICE_ATTR(ad_actor_key, S_IRUGO, bonding_show_ad_actor_key, NULL); |
859 | 558 | ||
860 | 559 | ||
861 | /* | 560 | /* Show current 802.3ad partner key. */ |
862 | * Show current 802.3ad partner key. | ||
863 | */ | ||
864 | static ssize_t bonding_show_ad_partner_key(struct device *d, | 561 | static ssize_t bonding_show_ad_partner_key(struct device *d, |
865 | struct device_attribute *attr, | 562 | struct device_attribute *attr, |
866 | char *buf) | 563 | char *buf) |
@@ -868,7 +565,7 @@ static ssize_t bonding_show_ad_partner_key(struct device *d, | |||
868 | int count = 0; | 565 | int count = 0; |
869 | struct bonding *bond = to_bond(d); | 566 | struct bonding *bond = to_bond(d); |
870 | 567 | ||
871 | if (bond->params.mode == BOND_MODE_8023AD) { | 568 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
872 | struct ad_info ad_info; | 569 | struct ad_info ad_info; |
873 | count = sprintf(buf, "%d\n", | 570 | count = sprintf(buf, "%d\n", |
874 | bond_3ad_get_active_agg_info(bond, &ad_info) | 571 | bond_3ad_get_active_agg_info(bond, &ad_info) |
@@ -880,9 +577,7 @@ static ssize_t bonding_show_ad_partner_key(struct device *d, | |||
880 | static DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL); | 577 | static DEVICE_ATTR(ad_partner_key, S_IRUGO, bonding_show_ad_partner_key, NULL); |
881 | 578 | ||
882 | 579 | ||
883 | /* | 580 | /* Show current 802.3ad partner mac. */ |
884 | * Show current 802.3ad partner mac. | ||
885 | */ | ||
886 | static ssize_t bonding_show_ad_partner_mac(struct device *d, | 581 | static ssize_t bonding_show_ad_partner_mac(struct device *d, |
887 | struct device_attribute *attr, | 582 | struct device_attribute *attr, |
888 | char *buf) | 583 | char *buf) |
@@ -890,7 +585,7 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d, | |||
890 | int count = 0; | 585 | int count = 0; |
891 | struct bonding *bond = to_bond(d); | 586 | struct bonding *bond = to_bond(d); |
892 | 587 | ||
893 | if (bond->params.mode == BOND_MODE_8023AD) { | 588 | if (BOND_MODE(bond) == BOND_MODE_8023AD) { |
894 | struct ad_info ad_info; | 589 | struct ad_info ad_info; |
895 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) | 590 | if (!bond_3ad_get_active_agg_info(bond, &ad_info)) |
896 | count = sprintf(buf, "%pM\n", ad_info.partner_system); | 591 | count = sprintf(buf, "%pM\n", ad_info.partner_system); |
@@ -900,9 +595,7 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d, | |||
900 | } | 595 | } |
901 | static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); | 596 | static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL); |
902 | 597 | ||
903 | /* | 598 | /* Show the queue_ids of the slaves in the current bond. */ |
904 | * Show the queue_ids of the slaves in the current bond. | ||
905 | */ | ||
906 | static ssize_t bonding_show_queue_id(struct device *d, | 599 | static ssize_t bonding_show_queue_id(struct device *d, |
907 | struct device_attribute *attr, | 600 | struct device_attribute *attr, |
908 | char *buf) | 601 | char *buf) |
@@ -933,31 +626,11 @@ static ssize_t bonding_show_queue_id(struct device *d, | |||
933 | 626 | ||
934 | return res; | 627 | return res; |
935 | } | 628 | } |
936 | |||
937 | /* | ||
938 | * Set the queue_ids of the slaves in the current bond. The bond | ||
939 | * interface must be enslaved for this to work. | ||
940 | */ | ||
941 | static ssize_t bonding_store_queue_id(struct device *d, | ||
942 | struct device_attribute *attr, | ||
943 | const char *buffer, size_t count) | ||
944 | { | ||
945 | struct bonding *bond = to_bond(d); | ||
946 | int ret; | ||
947 | |||
948 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_QUEUE_ID, (char *)buffer); | ||
949 | if (!ret) | ||
950 | ret = count; | ||
951 | |||
952 | return ret; | ||
953 | } | ||
954 | static DEVICE_ATTR(queue_id, S_IRUGO | S_IWUSR, bonding_show_queue_id, | 629 | static DEVICE_ATTR(queue_id, S_IRUGO | S_IWUSR, bonding_show_queue_id, |
955 | bonding_store_queue_id); | 630 | bonding_sysfs_store_option); |
956 | 631 | ||
957 | 632 | ||
958 | /* | 633 | /* Show the all_slaves_active flag. */ |
959 | * Show and set the all_slaves_active flag. | ||
960 | */ | ||
961 | static ssize_t bonding_show_slaves_active(struct device *d, | 634 | static ssize_t bonding_show_slaves_active(struct device *d, |
962 | struct device_attribute *attr, | 635 | struct device_attribute *attr, |
963 | char *buf) | 636 | char *buf) |
@@ -966,27 +639,10 @@ static ssize_t bonding_show_slaves_active(struct device *d, | |||
966 | 639 | ||
967 | return sprintf(buf, "%d\n", bond->params.all_slaves_active); | 640 | return sprintf(buf, "%d\n", bond->params.all_slaves_active); |
968 | } | 641 | } |
969 | |||
970 | static ssize_t bonding_store_slaves_active(struct device *d, | ||
971 | struct device_attribute *attr, | ||
972 | const char *buf, size_t count) | ||
973 | { | ||
974 | struct bonding *bond = to_bond(d); | ||
975 | int ret; | ||
976 | |||
977 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_ALL_SLAVES_ACTIVE, | ||
978 | (char *)buf); | ||
979 | if (!ret) | ||
980 | ret = count; | ||
981 | |||
982 | return ret; | ||
983 | } | ||
984 | static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR, | 642 | static DEVICE_ATTR(all_slaves_active, S_IRUGO | S_IWUSR, |
985 | bonding_show_slaves_active, bonding_store_slaves_active); | 643 | bonding_show_slaves_active, bonding_sysfs_store_option); |
986 | 644 | ||
987 | /* | 645 | /* Show the number of IGMP membership reports to send on link failure */ |
988 | * Show and set the number of IGMP membership reports to send on link failure | ||
989 | */ | ||
990 | static ssize_t bonding_show_resend_igmp(struct device *d, | 646 | static ssize_t bonding_show_resend_igmp(struct device *d, |
991 | struct device_attribute *attr, | 647 | struct device_attribute *attr, |
992 | char *buf) | 648 | char *buf) |
@@ -995,23 +651,8 @@ static ssize_t bonding_show_resend_igmp(struct device *d, | |||
995 | 651 | ||
996 | return sprintf(buf, "%d\n", bond->params.resend_igmp); | 652 | return sprintf(buf, "%d\n", bond->params.resend_igmp); |
997 | } | 653 | } |
998 | |||
999 | static ssize_t bonding_store_resend_igmp(struct device *d, | ||
1000 | struct device_attribute *attr, | ||
1001 | const char *buf, size_t count) | ||
1002 | { | ||
1003 | struct bonding *bond = to_bond(d); | ||
1004 | int ret; | ||
1005 | |||
1006 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_RESEND_IGMP, (char *)buf); | ||
1007 | if (!ret) | ||
1008 | ret = count; | ||
1009 | |||
1010 | return ret; | ||
1011 | } | ||
1012 | |||
1013 | static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR, | 654 | static DEVICE_ATTR(resend_igmp, S_IRUGO | S_IWUSR, |
1014 | bonding_show_resend_igmp, bonding_store_resend_igmp); | 655 | bonding_show_resend_igmp, bonding_sysfs_store_option); |
1015 | 656 | ||
1016 | 657 | ||
1017 | static ssize_t bonding_show_lp_interval(struct device *d, | 658 | static ssize_t bonding_show_lp_interval(struct device *d, |
@@ -1019,25 +660,21 @@ static ssize_t bonding_show_lp_interval(struct device *d, | |||
1019 | char *buf) | 660 | char *buf) |
1020 | { | 661 | { |
1021 | struct bonding *bond = to_bond(d); | 662 | struct bonding *bond = to_bond(d); |
663 | |||
1022 | return sprintf(buf, "%d\n", bond->params.lp_interval); | 664 | return sprintf(buf, "%d\n", bond->params.lp_interval); |
1023 | } | 665 | } |
666 | static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR, | ||
667 | bonding_show_lp_interval, bonding_sysfs_store_option); | ||
1024 | 668 | ||
1025 | static ssize_t bonding_store_lp_interval(struct device *d, | 669 | static ssize_t bonding_show_tlb_dynamic_lb(struct device *d, |
1026 | struct device_attribute *attr, | 670 | struct device_attribute *attr, |
1027 | const char *buf, size_t count) | 671 | char *buf) |
1028 | { | 672 | { |
1029 | struct bonding *bond = to_bond(d); | 673 | struct bonding *bond = to_bond(d); |
1030 | int ret; | 674 | return sprintf(buf, "%d\n", bond->params.tlb_dynamic_lb); |
1031 | |||
1032 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_LP_INTERVAL, (char *)buf); | ||
1033 | if (!ret) | ||
1034 | ret = count; | ||
1035 | |||
1036 | return ret; | ||
1037 | } | 675 | } |
1038 | 676 | static DEVICE_ATTR(tlb_dynamic_lb, S_IRUGO | S_IWUSR, | |
1039 | static DEVICE_ATTR(lp_interval, S_IRUGO | S_IWUSR, | 677 | bonding_show_tlb_dynamic_lb, bonding_sysfs_store_option); |
1040 | bonding_show_lp_interval, bonding_store_lp_interval); | ||
1041 | 678 | ||
1042 | static ssize_t bonding_show_packets_per_slave(struct device *d, | 679 | static ssize_t bonding_show_packets_per_slave(struct device *d, |
1043 | struct device_attribute *attr, | 680 | struct device_attribute *attr, |
@@ -1045,27 +682,11 @@ static ssize_t bonding_show_packets_per_slave(struct device *d, | |||
1045 | { | 682 | { |
1046 | struct bonding *bond = to_bond(d); | 683 | struct bonding *bond = to_bond(d); |
1047 | unsigned int packets_per_slave = bond->params.packets_per_slave; | 684 | unsigned int packets_per_slave = bond->params.packets_per_slave; |
1048 | return sprintf(buf, "%u\n", packets_per_slave); | ||
1049 | } | ||
1050 | |||
1051 | static ssize_t bonding_store_packets_per_slave(struct device *d, | ||
1052 | struct device_attribute *attr, | ||
1053 | const char *buf, size_t count) | ||
1054 | { | ||
1055 | struct bonding *bond = to_bond(d); | ||
1056 | int ret; | ||
1057 | 685 | ||
1058 | ret = bond_opt_tryset_rtnl(bond, BOND_OPT_PACKETS_PER_SLAVE, | 686 | return sprintf(buf, "%u\n", packets_per_slave); |
1059 | (char *)buf); | ||
1060 | if (!ret) | ||
1061 | ret = count; | ||
1062 | |||
1063 | return ret; | ||
1064 | } | 687 | } |
1065 | |||
1066 | static DEVICE_ATTR(packets_per_slave, S_IRUGO | S_IWUSR, | 688 | static DEVICE_ATTR(packets_per_slave, S_IRUGO | S_IWUSR, |
1067 | bonding_show_packets_per_slave, | 689 | bonding_show_packets_per_slave, bonding_sysfs_store_option); |
1068 | bonding_store_packets_per_slave); | ||
1069 | 690 | ||
1070 | static struct attribute *per_bond_attrs[] = { | 691 | static struct attribute *per_bond_attrs[] = { |
1071 | &dev_attr_slaves.attr, | 692 | &dev_attr_slaves.attr, |
@@ -1099,6 +720,7 @@ static struct attribute *per_bond_attrs[] = { | |||
1099 | &dev_attr_min_links.attr, | 720 | &dev_attr_min_links.attr, |
1100 | &dev_attr_lp_interval.attr, | 721 | &dev_attr_lp_interval.attr, |
1101 | &dev_attr_packets_per_slave.attr, | 722 | &dev_attr_packets_per_slave.attr, |
723 | &dev_attr_tlb_dynamic_lb.attr, | ||
1102 | NULL, | 724 | NULL, |
1103 | }; | 725 | }; |
1104 | 726 | ||
@@ -1107,8 +729,7 @@ static struct attribute_group bonding_group = { | |||
1107 | .attrs = per_bond_attrs, | 729 | .attrs = per_bond_attrs, |
1108 | }; | 730 | }; |
1109 | 731 | ||
1110 | /* | 732 | /* Initialize sysfs. This sets up the bonding_masters file in |
1111 | * Initialize sysfs. This sets up the bonding_masters file in | ||
1112 | * /sys/class/net. | 733 | * /sys/class/net. |
1113 | */ | 734 | */ |
1114 | int bond_create_sysfs(struct bond_net *bn) | 735 | int bond_create_sysfs(struct bond_net *bn) |
@@ -1120,8 +741,7 @@ int bond_create_sysfs(struct bond_net *bn) | |||
1120 | 741 | ||
1121 | ret = netdev_class_create_file_ns(&bn->class_attr_bonding_masters, | 742 | ret = netdev_class_create_file_ns(&bn->class_attr_bonding_masters, |
1122 | bn->net); | 743 | bn->net); |
1123 | /* | 744 | /* Permit multiple loads of the module by ignoring failures to |
1124 | * Permit multiple loads of the module by ignoring failures to | ||
1125 | * create the bonding_masters sysfs file. Bonding devices | 745 | * create the bonding_masters sysfs file. Bonding devices |
1126 | * created by second or subsequent loads of the module will | 746 | * created by second or subsequent loads of the module will |
1127 | * not be listed in, or controllable by, bonding_masters, but | 747 | * not be listed in, or controllable by, bonding_masters, but |
@@ -1144,16 +764,13 @@ int bond_create_sysfs(struct bond_net *bn) | |||
1144 | 764 | ||
1145 | } | 765 | } |
1146 | 766 | ||
1147 | /* | 767 | /* Remove /sys/class/net/bonding_masters. */ |
1148 | * Remove /sys/class/net/bonding_masters. | ||
1149 | */ | ||
1150 | void bond_destroy_sysfs(struct bond_net *bn) | 768 | void bond_destroy_sysfs(struct bond_net *bn) |
1151 | { | 769 | { |
1152 | netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, bn->net); | 770 | netdev_class_remove_file_ns(&bn->class_attr_bonding_masters, bn->net); |
1153 | } | 771 | } |
1154 | 772 | ||
1155 | /* | 773 | /* Initialize sysfs for each bond. This sets up and registers |
1156 | * Initialize sysfs for each bond. This sets up and registers | ||
1157 | * the 'bondctl' directory for each individual bond under /sys/class/net. | 774 | * the 'bondctl' directory for each individual bond under /sys/class/net. |
1158 | */ | 775 | */ |
1159 | void bond_prepare_sysfs_group(struct bonding *bond) | 776 | void bond_prepare_sysfs_group(struct bonding *bond) |
diff --git a/drivers/net/bonding/bond_sysfs_slave.c b/drivers/net/bonding/bond_sysfs_slave.c index 2e4eec5450c8..198677f58ce0 100644 --- a/drivers/net/bonding/bond_sysfs_slave.c +++ b/drivers/net/bonding/bond_sysfs_slave.c | |||
@@ -69,8 +69,8 @@ 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", |
76 | agg->aggregator_identifier); | 76 | agg->aggregator_identifier); |
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h index 00bea320e3b5..0b4d9cde0b05 100644 --- a/drivers/net/bonding/bonding.h +++ b/drivers/net/bonding/bonding.h | |||
@@ -41,42 +41,6 @@ | |||
41 | 41 | ||
42 | #define BOND_DEFAULT_MIIMON 100 | 42 | #define BOND_DEFAULT_MIIMON 100 |
43 | 43 | ||
44 | #define IS_UP(dev) \ | ||
45 | ((((dev)->flags & IFF_UP) == IFF_UP) && \ | ||
46 | netif_running(dev) && \ | ||
47 | netif_carrier_ok(dev)) | ||
48 | |||
49 | /* | ||
50 | * Checks whether slave is ready for transmit. | ||
51 | */ | ||
52 | #define SLAVE_IS_OK(slave) \ | ||
53 | (((slave)->dev->flags & IFF_UP) && \ | ||
54 | netif_running((slave)->dev) && \ | ||
55 | ((slave)->link == BOND_LINK_UP) && \ | ||
56 | bond_is_active_slave(slave)) | ||
57 | |||
58 | |||
59 | #define USES_PRIMARY(mode) \ | ||
60 | (((mode) == BOND_MODE_ACTIVEBACKUP) || \ | ||
61 | ((mode) == BOND_MODE_TLB) || \ | ||
62 | ((mode) == BOND_MODE_ALB)) | ||
63 | |||
64 | #define BOND_NO_USES_ARP(mode) \ | ||
65 | (((mode) == BOND_MODE_8023AD) || \ | ||
66 | ((mode) == BOND_MODE_TLB) || \ | ||
67 | ((mode) == BOND_MODE_ALB)) | ||
68 | |||
69 | #define TX_QUEUE_OVERRIDE(mode) \ | ||
70 | (((mode) == BOND_MODE_ACTIVEBACKUP) || \ | ||
71 | ((mode) == BOND_MODE_ROUNDROBIN)) | ||
72 | |||
73 | #define BOND_MODE_IS_LB(mode) \ | ||
74 | (((mode) == BOND_MODE_TLB) || \ | ||
75 | ((mode) == BOND_MODE_ALB)) | ||
76 | |||
77 | #define IS_IP_TARGET_UNUSABLE_ADDRESS(a) \ | ||
78 | ((htonl(INADDR_BROADCAST) == a) || \ | ||
79 | ipv4_is_zeronet(a)) | ||
80 | /* | 44 | /* |
81 | * Less bad way to call ioctl from within the kernel; this needs to be | 45 | * Less bad way to call ioctl from within the kernel; this needs to be |
82 | * done some other way to get the call out of interrupt context. | 46 | * done some other way to get the call out of interrupt context. |
@@ -90,6 +54,8 @@ | |||
90 | set_fs(fs); \ | 54 | set_fs(fs); \ |
91 | res; }) | 55 | res; }) |
92 | 56 | ||
57 | #define BOND_MODE(bond) ((bond)->params.mode) | ||
58 | |||
93 | /* slave list primitives */ | 59 | /* slave list primitives */ |
94 | #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower) | 60 | #define bond_slave_list(bond) (&(bond)->dev->adj_list.lower) |
95 | 61 | ||
@@ -175,6 +141,7 @@ struct bond_params { | |||
175 | int resend_igmp; | 141 | int resend_igmp; |
176 | int lp_interval; | 142 | int lp_interval; |
177 | int packets_per_slave; | 143 | int packets_per_slave; |
144 | int tlb_dynamic_lb; | ||
178 | struct reciprocal_value reciprocal_packets_per_slave; | 145 | struct reciprocal_value reciprocal_packets_per_slave; |
179 | }; | 146 | }; |
180 | 147 | ||
@@ -183,8 +150,6 @@ struct bond_parm_tbl { | |||
183 | int mode; | 150 | int mode; |
184 | }; | 151 | }; |
185 | 152 | ||
186 | #define BOND_MAX_MODENAME_LEN 20 | ||
187 | |||
188 | struct slave { | 153 | struct slave { |
189 | struct net_device *dev; /* first - useful for panic debug */ | 154 | struct net_device *dev; /* first - useful for panic debug */ |
190 | struct bonding *bond; /* our master */ | 155 | struct bonding *bond; /* our master */ |
@@ -205,7 +170,7 @@ struct slave { | |||
205 | u32 speed; | 170 | u32 speed; |
206 | u16 queue_id; | 171 | u16 queue_id; |
207 | u8 perm_hwaddr[ETH_ALEN]; | 172 | u8 perm_hwaddr[ETH_ALEN]; |
208 | struct ad_slave_info ad_info; /* HUGE - better to dynamically alloc */ | 173 | struct ad_slave_info *ad_info; |
209 | struct tlb_slave_info tlb_info; | 174 | struct tlb_slave_info tlb_info; |
210 | #ifdef CONFIG_NET_POLL_CONTROLLER | 175 | #ifdef CONFIG_NET_POLL_CONTROLLER |
211 | struct netpoll *np; | 176 | struct netpoll *np; |
@@ -285,14 +250,41 @@ static inline struct slave *bond_get_slave_by_dev(struct bonding *bond, | |||
285 | 250 | ||
286 | static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) | 251 | static inline struct bonding *bond_get_bond_by_slave(struct slave *slave) |
287 | { | 252 | { |
288 | if (!slave || !slave->bond) | ||
289 | return NULL; | ||
290 | return slave->bond; | 253 | return slave->bond; |
291 | } | 254 | } |
292 | 255 | ||
256 | static inline bool bond_should_override_tx_queue(struct bonding *bond) | ||
257 | { | ||
258 | return BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP || | ||
259 | BOND_MODE(bond) == BOND_MODE_ROUNDROBIN; | ||
260 | } | ||
261 | |||
293 | static inline bool bond_is_lb(const struct bonding *bond) | 262 | static inline bool bond_is_lb(const struct bonding *bond) |
294 | { | 263 | { |
295 | return BOND_MODE_IS_LB(bond->params.mode); | 264 | return BOND_MODE(bond) == BOND_MODE_TLB || |
265 | BOND_MODE(bond) == BOND_MODE_ALB; | ||
266 | } | ||
267 | |||
268 | static inline bool bond_mode_uses_arp(int mode) | ||
269 | { | ||
270 | return mode != BOND_MODE_8023AD && mode != BOND_MODE_TLB && | ||
271 | mode != BOND_MODE_ALB; | ||
272 | } | ||
273 | |||
274 | static inline bool bond_mode_uses_primary(int mode) | ||
275 | { | ||
276 | return mode == BOND_MODE_ACTIVEBACKUP || mode == BOND_MODE_TLB || | ||
277 | mode == BOND_MODE_ALB; | ||
278 | } | ||
279 | |||
280 | static inline bool bond_uses_primary(struct bonding *bond) | ||
281 | { | ||
282 | return bond_mode_uses_primary(BOND_MODE(bond)); | ||
283 | } | ||
284 | |||
285 | static inline bool bond_slave_is_up(struct slave *slave) | ||
286 | { | ||
287 | return netif_running(slave->dev) && netif_carrier_ok(slave->dev); | ||
296 | } | 288 | } |
297 | 289 | ||
298 | static inline void bond_set_active_slave(struct slave *slave) | 290 | static inline void bond_set_active_slave(struct slave *slave) |
@@ -365,6 +357,12 @@ static inline bool bond_is_active_slave(struct slave *slave) | |||
365 | return !bond_slave_state(slave); | 357 | return !bond_slave_state(slave); |
366 | } | 358 | } |
367 | 359 | ||
360 | static inline bool bond_slave_can_tx(struct slave *slave) | ||
361 | { | ||
362 | return bond_slave_is_up(slave) && slave->link == BOND_LINK_UP && | ||
363 | bond_is_active_slave(slave); | ||
364 | } | ||
365 | |||
368 | #define BOND_PRI_RESELECT_ALWAYS 0 | 366 | #define BOND_PRI_RESELECT_ALWAYS 0 |
369 | #define BOND_PRI_RESELECT_BETTER 1 | 367 | #define BOND_PRI_RESELECT_BETTER 1 |
370 | #define BOND_PRI_RESELECT_FAILURE 2 | 368 | #define BOND_PRI_RESELECT_FAILURE 2 |
@@ -396,12 +394,16 @@ static inline int slave_do_arp_validate(struct bonding *bond, | |||
396 | return bond->params.arp_validate & (1 << bond_slave_state(slave)); | 394 | return bond->params.arp_validate & (1 << bond_slave_state(slave)); |
397 | } | 395 | } |
398 | 396 | ||
399 | static inline int slave_do_arp_validate_only(struct bonding *bond, | 397 | static inline int slave_do_arp_validate_only(struct bonding *bond) |
400 | struct slave *slave) | ||
401 | { | 398 | { |
402 | return bond->params.arp_validate & BOND_ARP_FILTER; | 399 | return bond->params.arp_validate & BOND_ARP_FILTER; |
403 | } | 400 | } |
404 | 401 | ||
402 | static inline int bond_is_ip_target_ok(__be32 addr) | ||
403 | { | ||
404 | return !ipv4_is_lbcast(addr) && !ipv4_is_zeronet(addr); | ||
405 | } | ||
406 | |||
405 | /* Get the oldest arp which we've received on this slave for bond's | 407 | /* Get the oldest arp which we've received on this slave for bond's |
406 | * arp_targets. | 408 | * arp_targets. |
407 | */ | 409 | */ |
@@ -479,16 +481,14 @@ static inline __be32 bond_confirm_addr(struct net_device *dev, __be32 dst, __be3 | |||
479 | return addr; | 481 | return addr; |
480 | } | 482 | } |
481 | 483 | ||
482 | static inline bool slave_can_tx(struct slave *slave) | 484 | struct bond_net { |
483 | { | 485 | struct net *net; /* Associated network namespace */ |
484 | if (IS_UP(slave->dev) && slave->link == BOND_LINK_UP && | 486 | struct list_head dev_list; |
485 | bond_is_active_slave(slave)) | 487 | #ifdef CONFIG_PROC_FS |
486 | return true; | 488 | struct proc_dir_entry *proc_dir; |
487 | else | 489 | #endif |
488 | return false; | 490 | struct class_attribute class_attr_bonding_masters; |
489 | } | 491 | }; |
490 | |||
491 | struct bond_net; | ||
492 | 492 | ||
493 | int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, struct slave *slave); | 493 | int bond_arp_rcv(const struct sk_buff *skb, struct bonding *bond, struct slave *slave); |
494 | void bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); | 494 | void bond_dev_queue_xmit(struct bonding *bond, struct sk_buff *skb, struct net_device *slave_dev); |
@@ -500,7 +500,7 @@ int bond_sysfs_slave_add(struct slave *slave); | |||
500 | void bond_sysfs_slave_del(struct slave *slave); | 500 | void bond_sysfs_slave_del(struct slave *slave); |
501 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); | 501 | int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev); |
502 | int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); | 502 | int bond_release(struct net_device *bond_dev, struct net_device *slave_dev); |
503 | int bond_xmit_hash(struct bonding *bond, struct sk_buff *skb, int count); | 503 | u32 bond_xmit_hash(struct bonding *bond, struct sk_buff *skb); |
504 | void bond_select_active_slave(struct bonding *bond); | 504 | void bond_select_active_slave(struct bonding *bond); |
505 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active); | 505 | void bond_change_active_slave(struct bonding *bond, struct slave *new_active); |
506 | void bond_create_debugfs(void); | 506 | void bond_create_debugfs(void); |
@@ -516,15 +516,9 @@ void bond_netlink_fini(void); | |||
516 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); | 516 | struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond); |
517 | struct net_device *bond_option_active_slave_get(struct bonding *bond); | 517 | struct net_device *bond_option_active_slave_get(struct bonding *bond); |
518 | const char *bond_slave_link_status(s8 link); | 518 | const char *bond_slave_link_status(s8 link); |
519 | 519 | bool bond_verify_device_path(struct net_device *start_dev, | |
520 | struct bond_net { | 520 | struct net_device *end_dev, |
521 | struct net * net; /* Associated network namespace */ | 521 | struct bond_vlan_tag *tags); |
522 | struct list_head dev_list; | ||
523 | #ifdef CONFIG_PROC_FS | ||
524 | struct proc_dir_entry * proc_dir; | ||
525 | #endif | ||
526 | struct class_attribute class_attr_bonding_masters; | ||
527 | }; | ||
528 | 522 | ||
529 | #ifdef CONFIG_PROC_FS | 523 | #ifdef CONFIG_PROC_FS |
530 | void bond_create_proc_entry(struct bonding *bond); | 524 | void bond_create_proc_entry(struct bonding *bond); |
@@ -576,6 +570,27 @@ static inline struct slave *bond_slave_has_mac_rcu(struct bonding *bond, | |||
576 | return NULL; | 570 | return NULL; |
577 | } | 571 | } |
578 | 572 | ||
573 | /* Caller must hold rcu_read_lock() for read */ | ||
574 | static inline bool bond_slave_has_mac_rx(struct bonding *bond, const u8 *mac) | ||
575 | { | ||
576 | struct list_head *iter; | ||
577 | struct slave *tmp; | ||
578 | struct netdev_hw_addr *ha; | ||
579 | |||
580 | bond_for_each_slave_rcu(bond, tmp, iter) | ||
581 | if (ether_addr_equal_64bits(mac, tmp->dev->dev_addr)) | ||
582 | return true; | ||
583 | |||
584 | if (netdev_uc_empty(bond->dev)) | ||
585 | return false; | ||
586 | |||
587 | netdev_for_each_uc_addr(ha, bond->dev) | ||
588 | if (ether_addr_equal_64bits(mac, ha->addr)) | ||
589 | return true; | ||
590 | |||
591 | return false; | ||
592 | } | ||
593 | |||
579 | /* Check if the ip is present in arp ip list, or first free slot if ip == 0 | 594 | /* Check if the ip is present in arp ip list, or first free slot if ip == 0 |
580 | * Returns -1 if not found, index if found | 595 | * Returns -1 if not found, index if found |
581 | */ | 596 | */ |