2005-04-17 02:20:36 +04:00
/*
* Bond several ethernet interfaces into a Cisco , running ' Etherchannel ' .
*
* Portions are ( c ) Copyright 1995 Simon " Guru Aleph-Null " Janes
* NCM : Network and Communications Management , Inc .
*
* BUT , I ' m the one who modified it for ethernet , so :
* ( c ) Copyright 1999 , Thomas Davis , tadavis @ lbl . gov
*
* This software may be used and distributed according to the terms
* of the GNU Public License , incorporated herein by reference .
*
*/
2014-11-10 21:27:49 +03:00
# ifndef _NET_BONDING_H
# define _NET_BONDING_H
2005-04-17 02:20:36 +04:00
# include <linux/timer.h>
# include <linux/proc_fs.h>
# include <linux/if_bonding.h>
2010-10-13 20:01:50 +04:00
# include <linux/cpumask.h>
bonding: send IPv6 neighbor advertisement on failover
This patch adds better IPv6 failover support for bonding devices,
especially when in active-backup mode and there are only IPv6 addresses
configured, as reported by Alex Sidorenko.
- Creates a new file, net/drivers/bonding/bond_ipv6.c, for the
IPv6-specific routines. Both regular bonds and VLANs over bonds
are supported.
- Adds a new tunable, num_unsol_na, to limit the number of unsolicited
IPv6 Neighbor Advertisements that are sent on a failover event.
Default is 1.
- Creates two new IPv6 neighbor discovery functions:
ndisc_build_skb()
ndisc_send_skb()
These were required to support VLANs since we have to be able to
add the VLAN id to the skb since ndisc_send_na() and friends
shouldn't be asked to do this. These two routines are basically
__ndisc_send() split into two pieces, in a slightly different order.
- Updates Documentation/networking/bonding.txt and bumps the rev of bond
support to 3.4.0.
On failover, this new code will generate one packet:
- An unsolicited IPv6 Neighbor Advertisement, which helps the switch
learn that the address has moved to the new slave.
Testing has shown that sending just the NA results in pretty good
behavior when in active-back mode, I saw no lost ping packets for example.
Signed-off-by: Brian Haley <brian.haley@hp.com>
Signed-off-by: Jay Vosburgh <fubar@us.ibm.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
2008-11-05 04:51:14 +03:00
# include <linux/in6.h>
2011-02-18 02:43:32 +03:00
# include <linux/netpoll.h>
2012-03-22 20:14:29 +04:00
# include <linux/inetdevice.h>
2012-11-28 03:57:04 +04:00
# include <linux/etherdevice.h>
reciprocal_divide: update/correction of the algorithm
Jakub Zawadzki noticed that some divisions by reciprocal_divide()
were not correct [1][2], which he could also show with BPF code
after divisions are transformed into reciprocal_value() for runtime
invariance which can be passed to reciprocal_divide() later on;
reverse in BPF dump ended up with a different, off-by-one K in
some situations.
This has been fixed by Eric Dumazet in commit aee636c4809fa5
("bpf: do not use reciprocal divide"). This follow-up patch
improves reciprocal_value() and reciprocal_divide() to work in
all cases by using Granlund and Montgomery method, so that also
future use is safe and without any non-obvious side-effects.
Known problems with the old implementation were that division by 1
always returned 0 and some off-by-ones when the dividend and divisor
where very large. This seemed to not be problematic with its
current users, as far as we can tell. Eric Dumazet checked for
the slab usage, we cannot surely say so in the case of flex_array.
Still, in order to fix that, we propose an extension from the
original implementation from commit 6a2d7a955d8d resp. [3][4],
by using the algorithm proposed in "Division by Invariant Integers
Using Multiplication" [5], Torbjörn Granlund and Peter L.
Montgomery, that is, pseudocode for q = n/d where q, n, d is in
u32 universe:
1) Initialization:
int l = ceil(log_2 d)
uword m' = floor((1<<32)*((1<<l)-d)/d)+1
int sh_1 = min(l,1)
int sh_2 = max(l-1,0)
2) For q = n/d, all uword:
uword t = (n*m')>>32
q = (t+((n-t)>>sh_1))>>sh_2
The assembler implementation from Agner Fog [6] also helped a lot
while implementing. We have tested the implementation on x86_64,
ppc64, i686, s390x; on x86_64/haswell we're still half the latency
compared to normal divide.
Joint work with Daniel Borkmann.
[1] http://www.wireshark.org/~darkjames/reciprocal-buggy.c
[2] http://www.wireshark.org/~darkjames/set-and-dump-filter-k-bug.c
[3] https://gmplib.org/~tege/division-paper.pdf
[4] http://homepage.cs.uiowa.edu/~jones/bcd/divide.html
[5] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.1.2556
[6] http://www.agner.org/optimize/asmlib.zip
Reported-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Austin S Hemmelgarn <ahferroin7@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: Jesse Gross <jesse@nicira.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Andy Gospodarek <andy@greyhouse.net>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-01-22 05:29:41 +04:00
# include <linux/reciprocal_div.h>
2014-09-29 06:34:37 +04:00
# include <linux/if_link.h>
reciprocal_divide: update/correction of the algorithm
Jakub Zawadzki noticed that some divisions by reciprocal_divide()
were not correct [1][2], which he could also show with BPF code
after divisions are transformed into reciprocal_value() for runtime
invariance which can be passed to reciprocal_divide() later on;
reverse in BPF dump ended up with a different, off-by-one K in
some situations.
This has been fixed by Eric Dumazet in commit aee636c4809fa5
("bpf: do not use reciprocal divide"). This follow-up patch
improves reciprocal_value() and reciprocal_divide() to work in
all cases by using Granlund and Montgomery method, so that also
future use is safe and without any non-obvious side-effects.
Known problems with the old implementation were that division by 1
always returned 0 and some off-by-ones when the dividend and divisor
where very large. This seemed to not be problematic with its
current users, as far as we can tell. Eric Dumazet checked for
the slab usage, we cannot surely say so in the case of flex_array.
Still, in order to fix that, we propose an extension from the
original implementation from commit 6a2d7a955d8d resp. [3][4],
by using the algorithm proposed in "Division by Invariant Integers
Using Multiplication" [5], Torbjörn Granlund and Peter L.
Montgomery, that is, pseudocode for q = n/d where q, n, d is in
u32 universe:
1) Initialization:
int l = ceil(log_2 d)
uword m' = floor((1<<32)*((1<<l)-d)/d)+1
int sh_1 = min(l,1)
int sh_2 = max(l-1,0)
2) For q = n/d, all uword:
uword t = (n*m')>>32
q = (t+((n-t)>>sh_1))>>sh_2
The assembler implementation from Agner Fog [6] also helped a lot
while implementing. We have tested the implementation on x86_64,
ppc64, i686, s390x; on x86_64/haswell we're still half the latency
compared to normal divide.
Joint work with Daniel Borkmann.
[1] http://www.wireshark.org/~darkjames/reciprocal-buggy.c
[2] http://www.wireshark.org/~darkjames/set-and-dump-filter-k-bug.c
[3] https://gmplib.org/~tege/division-paper.pdf
[4] http://homepage.cs.uiowa.edu/~jones/bcd/divide.html
[5] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.1.2556
[6] http://www.agner.org/optimize/asmlib.zip
Reported-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Austin S Hemmelgarn <ahferroin7@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: Jesse Gross <jesse@nicira.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Andy Gospodarek <andy@greyhouse.net>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-01-22 05:29:41 +04:00
2014-11-10 21:27:49 +03:00
# include <net/bond_3ad.h>
# include <net/bond_alb.h>
# include <net/bond_options.h>
2005-04-17 02:20:36 +04:00
# define BOND_MAX_ARP_TARGETS 16
bonding: disable arp and enable mii monitoring when bond change to no uses arp mode
Because the ARP monitoring is not support for 802.3ad, but I still
could change the mode to 802.3ad from ab mode while ARP monitoring
is running, it is incorrect.
So add a check for 802.3ad in bonding_store_mode to fix the problem,
and make a new macro BOND_NO_USES_ARP() to simplify the code.
v2: according to the Dan Williams's suggestion, bond mode is the most
important bond option, it should override any of the other sub-options.
So when the mode is changed, the conficting values should be cleared
or reset, otherwise the user has to duplicate more operations to modify
the logic. I disable the arp and enable mii monitoring when the bond mode
is changed to AB, TB and 8023AD if the arp interval is true.
v3: according to the Nik's suggestion, the default value of miimon should need
a name, there is several place to use it, and the bond_store_arp_interval()
could use micro BOND_NO_USES_ARP to make the code more simpify.
Suggested-by: Dan Williams <dcbw@redhat.com>
Suggested-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Reviewed-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-11-22 18:28:43 +04:00
# define BOND_DEFAULT_MIIMON 100
2016-06-30 17:13:41 +03:00
# ifndef __long_aligned
# define __long_aligned __attribute__((aligned((sizeof(long)))))
# endif
2005-04-17 02:20:36 +04:00
2019-06-07 17:59:28 +03:00
# define slave_info(bond_dev, slave_dev, fmt, ...) \
netdev_info ( bond_dev , " (slave %s): " fmt , ( slave_dev ) - > name , # # __VA_ARGS__ )
# define slave_warn(bond_dev, slave_dev, fmt, ...) \
netdev_warn ( bond_dev , " (slave %s): " fmt , ( slave_dev ) - > name , # # __VA_ARGS__ )
# define slave_dbg(bond_dev, slave_dev, fmt, ...) \
netdev_dbg ( bond_dev , " (slave %s): " fmt , ( slave_dev ) - > name , # # __VA_ARGS__ )
# define slave_err(bond_dev, slave_dev, fmt, ...) \
netdev_err ( bond_dev , " (slave %s): " fmt , ( slave_dev ) - > name , # # __VA_ARGS__ )
2014-05-15 23:39:55 +04:00
# define BOND_MODE(bond) ((bond)->params.mode)
2013-08-01 18:54:47 +04:00
/* slave list primitives */
2013-09-25 11:20:24 +04:00
# define bond_slave_list(bond) (&(bond)->dev->adj_list.lower)
# define bond_has_slaves(bond) !list_empty(bond_slave_list(bond))
2013-09-25 11:20:21 +04:00
2013-08-01 18:54:47 +04:00
/* IMPORTANT: bond_first/last_slave can return NULL in case of an empty list */
# define bond_first_slave(bond) \
2013-09-25 11:20:24 +04:00
( bond_has_slaves ( bond ) ? \
netdev_adjacent_get_private ( bond_slave_list ( bond ) - > next ) : \
NULL )
2013-08-01 18:54:47 +04:00
# define bond_last_slave(bond) \
2013-09-25 11:20:24 +04:00
( bond_has_slaves ( bond ) ? \
netdev_adjacent_get_private ( bond_slave_list ( bond ) - > prev ) : \
NULL )
2013-08-01 18:54:47 +04:00
2013-12-13 06:19:55 +04:00
/* Caller must have rcu_read_lock */
# define bond_first_slave_rcu(bond) \
netdev_lower_get_first_private_rcu ( bond - > dev )
2013-09-25 11:20:24 +04:00
# define bond_is_first_slave(bond, pos) (pos == bond_first_slave(bond))
# define bond_is_last_slave(bond, pos) (pos == bond_last_slave(bond))
2013-08-01 18:54:47 +04:00
2005-04-17 02:20:36 +04:00
/**
2013-08-01 18:54:47 +04:00
* bond_for_each_slave - iterate over all slaves
* @ bond : the bond holding this list
* @ pos : current slave
2013-09-25 11:20:14 +04:00
* @ iter : list_head * iterator
2005-04-17 02:20:36 +04:00
*
2014-09-10 01:17:03 +04:00
* Caller must hold RTNL
2005-04-17 02:20:36 +04:00
*/
2013-09-25 11:20:14 +04:00
# define bond_for_each_slave(bond, pos, iter) \
netdev_for_each_lower_private ( ( bond ) - > dev , pos , iter )
2005-04-17 02:20:36 +04:00
bonding: initial RCU conversion
This patch does the initial bonding conversion to RCU. After it the
following modes are protected by RCU alone: roundrobin, active-backup,
broadcast and xor. Modes ALB/TLB and 3ad still acquire bond->lock for
reading, and will be dealt with later. curr_active_slave needs to be
dereferenced via rcu in the converted modes because the only thing
protecting the slave after this patch is rcu_read_lock, so we need the
proper barrier for weakly ordered archs and to make sure we don't have
stale pointer. It's not tagged with __rcu yet because there's still work
to be done to remove the curr_slave_lock, so sparse will complain when
rcu_assign_pointer and rcu_dereference are used, but the alternative to use
rcu_dereference_protected would've created much bigger code churn which is
more difficult to test and review. That will be converted in time.
1. Active-backup mode
1.1 Perf recording while doing iperf -P 4
- old bonding: iperf spent 0.55% in bonding, system spent 0.29% CPU
in bonding
- new bonding: iperf spent 0.29% in bonding, system spent 0.15% CPU
in bonding
1.2. Bandwidth measurements
- old bonding: 16.1 gbps consistently
- new bonding: 17.5 gbps consistently
2. Round-robin mode
2.1 Perf recording while doing iperf -P 4
- old bonding: iperf spent 0.51% in bonding, system spent 0.24% CPU
in bonding
- new bonding: iperf spent 0.16% in bonding, system spent 0.11% CPU
in bonding
2.2 Bandwidth measurements
- old bonding: 8 gbps (variable due to packet reorderings)
- new bonding: 10 gbps (variable due to packet reorderings)
Of course the latency has improved in all converted modes, and moreover
while
doing enslave/release (since it doesn't affect tx anymore).
Also I've stress tested all modes doing enslave/release in a loop while
transmitting traffic.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-08-01 18:54:51 +04:00
/* Caller must have rcu_read_lock */
2013-09-25 11:20:14 +04:00
# define bond_for_each_slave_rcu(bond, pos, iter) \
netdev_for_each_lower_private_rcu ( ( bond ) - > dev , pos , iter )
bonding: initial RCU conversion
This patch does the initial bonding conversion to RCU. After it the
following modes are protected by RCU alone: roundrobin, active-backup,
broadcast and xor. Modes ALB/TLB and 3ad still acquire bond->lock for
reading, and will be dealt with later. curr_active_slave needs to be
dereferenced via rcu in the converted modes because the only thing
protecting the slave after this patch is rcu_read_lock, so we need the
proper barrier for weakly ordered archs and to make sure we don't have
stale pointer. It's not tagged with __rcu yet because there's still work
to be done to remove the curr_slave_lock, so sparse will complain when
rcu_assign_pointer and rcu_dereference are used, but the alternative to use
rcu_dereference_protected would've created much bigger code churn which is
more difficult to test and review. That will be converted in time.
1. Active-backup mode
1.1 Perf recording while doing iperf -P 4
- old bonding: iperf spent 0.55% in bonding, system spent 0.29% CPU
in bonding
- new bonding: iperf spent 0.29% in bonding, system spent 0.15% CPU
in bonding
1.2. Bandwidth measurements
- old bonding: 16.1 gbps consistently
- new bonding: 17.5 gbps consistently
2. Round-robin mode
2.1 Perf recording while doing iperf -P 4
- old bonding: iperf spent 0.51% in bonding, system spent 0.24% CPU
in bonding
- new bonding: iperf spent 0.16% in bonding, system spent 0.11% CPU
in bonding
2.2 Bandwidth measurements
- old bonding: 8 gbps (variable due to packet reorderings)
- new bonding: 10 gbps (variable due to packet reorderings)
Of course the latency has improved in all converted modes, and moreover
while
doing enslave/release (since it doesn't affect tx anymore).
Also I've stress tested all modes doing enslave/release in a loop while
transmitting traffic.
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-08-01 18:54:51 +04:00
2010-10-13 20:01:50 +04:00
# ifdef CONFIG_NET_POLL_CONTROLLER
net: Convert netpoll blocking api in bonding driver to be a counter
A while back I made some changes to enable netpoll in the bonding driver. Among
them was a per-cpu flag that indicated we were in a path that held locks which
could cause the netpoll path to block in during tx, and as such the tx path
should queue the frame for later use. This appears to have given rise to a
regression. If one of those paths on which we hold the per-cpu flag yields the
cpu, its possible for us to come back on a different cpu, leading to us clearing
a different flag than we set. This results in odd netpoll drops, and BUG
backtraces appearing in the log, as we check to make sure that we only clear set
bits, and only set clear bits. I had though briefly about changing the
offending paths so that they wouldn't sleep, but looking at my origional work
more closely, it doesn't appear that a per-cpu flag is warranted. We alrady
gate the checking of this flag on IFF_IN_NETPOLL, so we don't hit this in the
normal tx case anyway. And practically speaking, the normal use case for
netpoll is to only have one client anyway, so we're not going to erroneously
queue netpoll frames when its actually safe to do so. As such, lets just
convert that per-cpu flag to an atomic counter. It fixes the rescheduling bugs,
is equivalent from a performance perspective and actually eliminates some code
in the process.
Tested by the reporter and myself, successfully
Reported-by: Liang Zheng <lzheng@redhat.com>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-12-06 12:05:50 +03:00
extern atomic_t netpoll_block_tx ;
2010-10-13 20:01:50 +04:00
static inline void block_netpoll_tx ( void )
{
net: Convert netpoll blocking api in bonding driver to be a counter
A while back I made some changes to enable netpoll in the bonding driver. Among
them was a per-cpu flag that indicated we were in a path that held locks which
could cause the netpoll path to block in during tx, and as such the tx path
should queue the frame for later use. This appears to have given rise to a
regression. If one of those paths on which we hold the per-cpu flag yields the
cpu, its possible for us to come back on a different cpu, leading to us clearing
a different flag than we set. This results in odd netpoll drops, and BUG
backtraces appearing in the log, as we check to make sure that we only clear set
bits, and only set clear bits. I had though briefly about changing the
offending paths so that they wouldn't sleep, but looking at my origional work
more closely, it doesn't appear that a per-cpu flag is warranted. We alrady
gate the checking of this flag on IFF_IN_NETPOLL, so we don't hit this in the
normal tx case anyway. And practically speaking, the normal use case for
netpoll is to only have one client anyway, so we're not going to erroneously
queue netpoll frames when its actually safe to do so. As such, lets just
convert that per-cpu flag to an atomic counter. It fixes the rescheduling bugs,
is equivalent from a performance perspective and actually eliminates some code
in the process.
Tested by the reporter and myself, successfully
Reported-by: Liang Zheng <lzheng@redhat.com>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-12-06 12:05:50 +03:00
atomic_inc ( & netpoll_block_tx ) ;
2010-10-13 20:01:50 +04:00
}
static inline void unblock_netpoll_tx ( void )
{
net: Convert netpoll blocking api in bonding driver to be a counter
A while back I made some changes to enable netpoll in the bonding driver. Among
them was a per-cpu flag that indicated we were in a path that held locks which
could cause the netpoll path to block in during tx, and as such the tx path
should queue the frame for later use. This appears to have given rise to a
regression. If one of those paths on which we hold the per-cpu flag yields the
cpu, its possible for us to come back on a different cpu, leading to us clearing
a different flag than we set. This results in odd netpoll drops, and BUG
backtraces appearing in the log, as we check to make sure that we only clear set
bits, and only set clear bits. I had though briefly about changing the
offending paths so that they wouldn't sleep, but looking at my origional work
more closely, it doesn't appear that a per-cpu flag is warranted. We alrady
gate the checking of this flag on IFF_IN_NETPOLL, so we don't hit this in the
normal tx case anyway. And practically speaking, the normal use case for
netpoll is to only have one client anyway, so we're not going to erroneously
queue netpoll frames when its actually safe to do so. As such, lets just
convert that per-cpu flag to an atomic counter. It fixes the rescheduling bugs,
is equivalent from a performance perspective and actually eliminates some code
in the process.
Tested by the reporter and myself, successfully
Reported-by: Liang Zheng <lzheng@redhat.com>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-12-06 12:05:50 +03:00
atomic_dec ( & netpoll_block_tx ) ;
2010-10-13 20:01:50 +04:00
}
static inline int is_netpoll_tx_blocked ( struct net_device * dev )
{
2011-02-18 02:43:33 +03:00
if ( unlikely ( netpoll_tx_running ( dev ) ) )
net: Convert netpoll blocking api in bonding driver to be a counter
A while back I made some changes to enable netpoll in the bonding driver. Among
them was a per-cpu flag that indicated we were in a path that held locks which
could cause the netpoll path to block in during tx, and as such the tx path
should queue the frame for later use. This appears to have given rise to a
regression. If one of those paths on which we hold the per-cpu flag yields the
cpu, its possible for us to come back on a different cpu, leading to us clearing
a different flag than we set. This results in odd netpoll drops, and BUG
backtraces appearing in the log, as we check to make sure that we only clear set
bits, and only set clear bits. I had though briefly about changing the
offending paths so that they wouldn't sleep, but looking at my origional work
more closely, it doesn't appear that a per-cpu flag is warranted. We alrady
gate the checking of this flag on IFF_IN_NETPOLL, so we don't hit this in the
normal tx case anyway. And practically speaking, the normal use case for
netpoll is to only have one client anyway, so we're not going to erroneously
queue netpoll frames when its actually safe to do so. As such, lets just
convert that per-cpu flag to an atomic counter. It fixes the rescheduling bugs,
is equivalent from a performance perspective and actually eliminates some code
in the process.
Tested by the reporter and myself, successfully
Reported-by: Liang Zheng <lzheng@redhat.com>
CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: David S. Miller <davem@davemloft.net>
Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2010-12-06 12:05:50 +03:00
return atomic_read ( & netpoll_block_tx ) ;
2010-10-13 20:01:50 +04:00
return 0 ;
}
# else
# define block_netpoll_tx()
# define unblock_netpoll_tx()
# define is_netpoll_tx_blocked(dev) (0)
# endif
2005-04-17 02:20:36 +04:00
struct bond_params {
int mode ;
2005-06-27 01:54:11 +04:00
int xmit_policy ;
2005-04-17 02:20:36 +04:00
int miimon ;
2011-04-26 19:25:52 +04:00
u8 num_peer_notif ;
2005-04-17 02:20:36 +04:00
int arp_interval ;
2006-09-23 08:54:53 +04:00
int arp_validate ;
bonding: add an option to fail when any of arp_ip_target is inaccessible
Currently, we fail only when all of the ips in arp_ip_target are gone.
However, in some situations we might need to fail if even one host from
arp_ip_target becomes unavailable.
All situations, obviously, rely on the idea that we need *completely*
functional network, with all interfaces/addresses working correctly.
One real world example might be:
vlans on top on bond (hybrid port). If bond and vlans have ips assigned
and we have their peers monitored via arp_ip_target - in case of switch
misconfiguration (trunk/access port), slave driver malfunction or
tagged/untagged traffic dropped on the way - we will be able to switch
to another slave.
Though any other configuration needs that if we need to have access to all
arp_ip_targets.
This patch adds this possibility by adding a new parameter -
arp_all_targets (both as a module parameter and as a sysfs knob). It can be
set to:
0 or any (the default) - which works exactly as it's working now -
the slave is up if any of the arp_ip_targets are up.
1 or all - the slave is up if all of the arp_ip_targets are up.
This parameter can be changed on the fly (via sysfs), and requires the mode
to be active-backup and arp_validate to be enabled (it obeys the
arp_validate config on which slaves to validate).
Internally it's done through:
1) Add target_last_arp_rx[BOND_MAX_ARP_TARGETS] array to slave struct. It's
an array of jiffies, meaning that slave->target_last_arp_rx[i] is the
last time we've received arp from bond->params.arp_targets[i] on this
slave.
2) If we successfully validate an arp from bond->params.arp_targets[i] in
bond_validate_arp() - update the slave->target_last_arp_rx[i] with the
current jiffies value.
3) When getting slave's last_rx via slave_last_rx(), we return the oldest
time when we've received an arp from any address in
bond->params.arp_targets[].
If the value of arp_all_targets == 0 - we still work the same way as
before.
Also, update the documentation to reflect the new parameter.
v3->v4:
Kill the forgotten rtnl_unlock(), rephrase the documentation part to be
more clear, don't fail setting arp_all_targets if arp_validate is not set -
it has no effect anyway but can be easier to set up. Also, print a warning
if the last arp_ip_target is removed while the arp_interval is on, but not
the arp_validate.
v2->v3:
Use _bh spinlock, remove useless rtnl_lock() and use jiffies for new
arp_ip_target last arp, instead of slave_last_rx(). On bond_enslave(),
use the same initialization value for target_last_arp_rx[] as is used
for the default last_arp_rx, to avoid useless interface flaps.
Also, instead of failing to remove the last arp_ip_target just print a
warning - otherwise it might break existing scripts.
v1->v2:
Correctly handle adding/removing hosts in arp_ip_target - we need to
shift/initialize all slave's target_last_arp_rx. Also, don't fail module
loading on arp_all_targets misconfiguration, just disable it, and some
minor style fixes.
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-24 13:49:34 +04:00
int arp_all_targets ;
2005-04-17 02:20:36 +04:00
int use_carrier ;
2007-10-10 06:57:24 +04:00
int fail_over_mac ;
2005-04-17 02:20:36 +04:00
int updelay ;
int downdelay ;
bonding: add an option to specify a delay between peer notifications
Currently, gratuitous ARP/ND packets are sent every `miimon'
milliseconds. This commit allows a user to specify a custom delay
through a new option, `peer_notif_delay'.
Like for `updelay' and `downdelay', this delay should be a multiple of
`miimon' to avoid managing an additional work queue. The configuration
logic is copied from `updelay' and `downdelay'. However, the default
value cannot be set using a module parameter: Netlink or sysfs should
be used to configure this feature.
When setting `miimon' to 100 and `peer_notif_delay' to 500, we can
observe the 500 ms delay is respected:
20:30:19.354693 ARP, Request who-has 203.0.113.10 tell 203.0.113.10, length 28
20:30:19.874892 ARP, Request who-has 203.0.113.10 tell 203.0.113.10, length 28
20:30:20.394919 ARP, Request who-has 203.0.113.10 tell 203.0.113.10, length 28
20:30:20.914963 ARP, Request who-has 203.0.113.10 tell 203.0.113.10, length 28
In bond_mii_monitor(), I have tried to keep the lock logic readable.
The change is due to the fact we cannot rely on a notification to
lower the value of `bond->send_peer_notif' as `NETDEV_NOTIFY_PEERS' is
only triggered once every N times, while we need to decrement the
counter each time.
iproute2 also needs to be updated to be able to specify this new
attribute through `ip link'.
Signed-off-by: Vincent Bernat <vincent@bernat.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-07-02 20:43:54 +03:00
int peer_notif_delay ;
2005-04-17 02:20:36 +04:00
int lacp_fast ;
2011-06-22 13:54:39 +04:00
unsigned int min_links ;
2008-11-05 04:51:16 +03:00
int ad_select ;
2005-04-17 02:20:36 +04:00
char primary [ IFNAMSIZ ] ;
2009-09-25 07:28:09 +04:00
int primary_reselect ;
2007-08-23 04:06:58 +04:00
__be32 arp_targets [ BOND_MAX_ARP_TARGETS ] ;
2010-06-02 12:40:18 +04:00
int tx_queues ;
2010-06-02 12:39:21 +04:00
int all_slaves_active ;
2010-10-05 18:23:59 +04:00
int resend_igmp ;
2013-09-13 19:05:33 +04:00
int lp_interval ;
2013-11-05 16:51:41 +04:00
int packets_per_slave ;
2014-04-23 03:30:22 +04:00
int tlb_dynamic_lb ;
reciprocal_divide: update/correction of the algorithm
Jakub Zawadzki noticed that some divisions by reciprocal_divide()
were not correct [1][2], which he could also show with BPF code
after divisions are transformed into reciprocal_value() for runtime
invariance which can be passed to reciprocal_divide() later on;
reverse in BPF dump ended up with a different, off-by-one K in
some situations.
This has been fixed by Eric Dumazet in commit aee636c4809fa5
("bpf: do not use reciprocal divide"). This follow-up patch
improves reciprocal_value() and reciprocal_divide() to work in
all cases by using Granlund and Montgomery method, so that also
future use is safe and without any non-obvious side-effects.
Known problems with the old implementation were that division by 1
always returned 0 and some off-by-ones when the dividend and divisor
where very large. This seemed to not be problematic with its
current users, as far as we can tell. Eric Dumazet checked for
the slab usage, we cannot surely say so in the case of flex_array.
Still, in order to fix that, we propose an extension from the
original implementation from commit 6a2d7a955d8d resp. [3][4],
by using the algorithm proposed in "Division by Invariant Integers
Using Multiplication" [5], Torbjörn Granlund and Peter L.
Montgomery, that is, pseudocode for q = n/d where q, n, d is in
u32 universe:
1) Initialization:
int l = ceil(log_2 d)
uword m' = floor((1<<32)*((1<<l)-d)/d)+1
int sh_1 = min(l,1)
int sh_2 = max(l-1,0)
2) For q = n/d, all uword:
uword t = (n*m')>>32
q = (t+((n-t)>>sh_1))>>sh_2
The assembler implementation from Agner Fog [6] also helped a lot
while implementing. We have tested the implementation on x86_64,
ppc64, i686, s390x; on x86_64/haswell we're still half the latency
compared to normal divide.
Joint work with Daniel Borkmann.
[1] http://www.wireshark.org/~darkjames/reciprocal-buggy.c
[2] http://www.wireshark.org/~darkjames/set-and-dump-filter-k-bug.c
[3] https://gmplib.org/~tege/division-paper.pdf
[4] http://homepage.cs.uiowa.edu/~jones/bcd/divide.html
[5] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.1.2556
[6] http://www.agner.org/optimize/asmlib.zip
Reported-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Austin S Hemmelgarn <ahferroin7@gmail.com>
Cc: linux-kernel@vger.kernel.org
Cc: Jesse Gross <jesse@nicira.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Matt Mackall <mpm@selenic.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christoph Lameter <cl@linux-foundation.org>
Cc: Andy Gospodarek <andy@greyhouse.net>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-01-22 05:29:41 +04:00
struct reciprocal_value reciprocal_packets_per_slave ;
2015-05-09 10:01:55 +03:00
u16 ad_actor_sys_prio ;
2015-05-09 10:01:57 +03:00
u16 ad_user_port_key ;
2016-06-30 17:13:41 +03:00
/* 2 bytes of padding : see ether_addr_equal_64bits() */
u8 ad_actor_system [ ETH_ALEN + 2 ] ;
2005-04-17 02:20:36 +04:00
} ;
2005-11-09 21:35:44 +03:00
struct bond_parm_tbl {
char * modename ;
int mode ;
} ;
2005-04-17 02:20:36 +04:00
struct slave {
2005-11-09 21:36:50 +03:00
struct net_device * dev ; /* first - useful for panic debug */
2011-03-22 05:38:12 +03:00
struct bonding * bond ; /* our master */
2006-09-23 08:52:51 +04:00
int delay ;
2014-02-18 10:48:46 +04:00
/* all three in jiffies */
unsigned long last_link_up ;
2014-02-18 10:48:47 +04:00
unsigned long last_rx ;
bonding: add an option to fail when any of arp_ip_target is inaccessible
Currently, we fail only when all of the ips in arp_ip_target are gone.
However, in some situations we might need to fail if even one host from
arp_ip_target becomes unavailable.
All situations, obviously, rely on the idea that we need *completely*
functional network, with all interfaces/addresses working correctly.
One real world example might be:
vlans on top on bond (hybrid port). If bond and vlans have ips assigned
and we have their peers monitored via arp_ip_target - in case of switch
misconfiguration (trunk/access port), slave driver malfunction or
tagged/untagged traffic dropped on the way - we will be able to switch
to another slave.
Though any other configuration needs that if we need to have access to all
arp_ip_targets.
This patch adds this possibility by adding a new parameter -
arp_all_targets (both as a module parameter and as a sysfs knob). It can be
set to:
0 or any (the default) - which works exactly as it's working now -
the slave is up if any of the arp_ip_targets are up.
1 or all - the slave is up if all of the arp_ip_targets are up.
This parameter can be changed on the fly (via sysfs), and requires the mode
to be active-backup and arp_validate to be enabled (it obeys the
arp_validate config on which slaves to validate).
Internally it's done through:
1) Add target_last_arp_rx[BOND_MAX_ARP_TARGETS] array to slave struct. It's
an array of jiffies, meaning that slave->target_last_arp_rx[i] is the
last time we've received arp from bond->params.arp_targets[i] on this
slave.
2) If we successfully validate an arp from bond->params.arp_targets[i] in
bond_validate_arp() - update the slave->target_last_arp_rx[i] with the
current jiffies value.
3) When getting slave's last_rx via slave_last_rx(), we return the oldest
time when we've received an arp from any address in
bond->params.arp_targets[].
If the value of arp_all_targets == 0 - we still work the same way as
before.
Also, update the documentation to reflect the new parameter.
v3->v4:
Kill the forgotten rtnl_unlock(), rephrase the documentation part to be
more clear, don't fail setting arp_all_targets if arp_validate is not set -
it has no effect anyway but can be easier to set up. Also, print a warning
if the last arp_ip_target is removed while the arp_interval is on, but not
the arp_validate.
v2->v3:
Use _bh spinlock, remove useless rtnl_lock() and use jiffies for new
arp_ip_target last arp, instead of slave_last_rx(). On bond_enslave(),
use the same initialization value for target_last_arp_rx[] as is used
for the default last_arp_rx, to avoid useless interface flaps.
Also, instead of failing to remove the last arp_ip_target just print a
warning - otherwise it might break existing scripts.
v1->v2:
Correctly handle adding/removing hosts in arp_ip_target - we need to
shift/initialize all slave's target_last_arp_rx. Also, don't fail module
loading on arp_all_targets misconfiguration, just disable it, and some
minor style fixes.
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-24 13:49:34 +04:00
unsigned long target_last_arp_rx [ BOND_MAX_ARP_TARGETS ] ;
2017-03-27 21:37:30 +03:00
s8 link ; /* one of BOND_LINK_XXXX */
s8 link_new_state ; /* one of BOND_LINK_XXXX */
2011-03-16 11:46:43 +03:00
u8 backup : 1 , /* indicates backup slave. Value corresponds with
BOND_STATE_ACTIVE and BOND_STATE_BACKUP */
bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c for 802.3ad mode
The problem was introduced by the commit 1d3ee88ae0d
(bonding: add netlink attributes to slave link dev).
The bond_set_active_slave() and bond_set_backup_slave()
will use rtmsg_ifinfo to send slave's states, so these
two functions should be called in RTNL.
In 802.3ad mode, acquiring RTNL for the __enable_port and
__disable_port cases is difficult, as those calls generally
already hold the state machine lock, and cannot unconditionally
call rtnl_lock because either they already hold RTNL (for calls
via bond_3ad_unbind_slave) or due to the potential for deadlock
with bond_3ad_adapter_speed_changed, bond_3ad_adapter_duplex_changed,
bond_3ad_link_change, or bond_3ad_update_lacp_rate. All four of
those are called with RTNL held, and acquire the state machine lock
second. The calling contexts for __enable_port and __disable_port
already hold the state machine lock, and may or may not need RTNL.
According to the Jay's opinion, I don't think it is a problem that
the slave don't send notify message synchronously when the status
changed, normally the state machine is running every 100 ms, send
the notify message at the end of the state machine if the slave's
state changed should be better.
I fix the problem through these steps:
1). add a new function bond_set_slave_state() which could change
the slave's state and call rtmsg_ifinfo() according to the input
parameters called notify.
2). Add a new slave parameter which called should_notify, if the slave's state
changed and don't notify yet, the parameter will be set to 1, and then if
the slave's state changed again, the param will be set to 0, it indicate that
the slave's state has been restored, no need to notify any one.
3). the __enable_port and __disable_port should not call rtmsg_ifinfo
in the state machine lock, any change in the state of slave could
set a flag in the slave, it will indicated that an rtmsg_ifinfo
should be called at the end of the state machine.
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-26 07:05:22 +04:00
inactive : 1 , /* indicates inactive slave */
2015-12-03 14:12:19 +03:00
should_notify : 1 , /* indicates whether the state changed */
should_notify_link : 1 ; /* indicates whether the link changed */
2011-04-13 19:22:31 +04:00
u8 duplex ;
2007-10-10 06:43:41 +04:00
u32 original_mtu ;
2005-04-17 02:20:36 +04:00
u32 link_failure_count ;
2011-04-13 19:22:31 +04:00
u32 speed ;
2010-06-02 12:40:18 +04:00
u16 queue_id ;
bonding: attempt to better support longer hw addresses
People are using bonding over Infiniband IPoIB connections, and who knows
what else. Infiniband has a hardware address length of 20 octets
(INFINIBAND_ALEN), and the network core defines a MAX_ADDR_LEN of 32.
Various places in the bonding code are currently hard-wired to 6 octets
(ETH_ALEN), such as the 3ad code, which I've left untouched here. Besides,
only alb is currently possible on Infiniband links right now anyway, due
to commit 1533e7731522, so the alb code is where most of the changes are.
One major component of this change is the addition of a bond_hw_addr_copy
function that takes a length argument, instead of using ether_addr_copy
everywhere that hardware addresses need to be copied about. The other
major component of this change is converting the bonding code from using
struct sockaddr for address storage to struct sockaddr_storage, as the
former has an address storage space of only 14, while the latter is 128
minus a few, which is necessary to support bonding over device with up to
MAX_ADDR_LEN octet hardware addresses. Additionally, this probably fixes
up some memory corruption issues with the current code, where it's
possible to write an infiniband hardware address into a sockaddr declared
on the stack.
Lightly tested on a dual mlx4 IPoIB setup, which properly shows a 20-octet
hardware address now:
$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: mlx4_ib0 (primary_reselect always)
Currently Active Slave: mlx4_ib0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 100
Down Delay (ms): 100
Slave Interface: mlx4_ib0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr:
80:00:02:08:fe:80:00:00:00:00:00:00:e4:1d:2d:03:00:1d:67:01
Slave queue ID: 0
Slave Interface: mlx4_ib1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr:
80:00:02:09:fe:80:00:00:00:00:00:01:e4:1d:2d:03:00:1d:67:02
Slave queue ID: 0
Also tested with a standard 1Gbps NIC bonding setup (with a mix of
e1000 and e1000e cards), running LNST's bonding tests.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Veaceslav Falico <vfalico@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-04-05 00:32:42 +03:00
u8 perm_hwaddr [ MAX_ADDR_LEN ] ;
2014-05-12 11:08:43 +04:00
struct ad_slave_info * ad_info ;
2005-04-17 02:20:36 +04:00
struct tlb_slave_info tlb_info ;
2011-02-18 02:43:32 +03:00
# ifdef CONFIG_NET_POLL_CONTROLLER
struct netpoll * np ;
# endif
2018-09-25 00:40:11 +03:00
struct delayed_work notify_work ;
2014-01-17 10:57:49 +04:00
struct kobject kobj ;
2014-09-29 06:34:37 +04:00
struct rtnl_link_stats64 slave_stats ;
2005-04-17 02:20:36 +04:00
} ;
2014-10-05 04:45:01 +04:00
struct bond_up_slave {
unsigned int count ;
struct rcu_head rcu ;
2020-02-28 16:56:29 +03:00
struct slave * arr [ ] ;
2014-10-05 04:45:01 +04:00
} ;
2008-05-18 08:10:13 +04:00
/*
* Link pseudo - state only used internally by monitors
*/
# define BOND_LINK_NOCHANGE -1
2005-04-17 02:20:36 +04:00
/*
* Here are the locking policies for the two bonding locks :
2014-09-12 00:49:24 +04:00
* Get rcu_read_lock when reading or RTNL when writing slave list .
2005-04-17 02:20:36 +04:00
*/
struct bonding {
2005-11-09 21:36:50 +03:00
struct net_device * dev ; /* first - useful for panic debug */
2014-07-15 17:56:55 +04:00
struct slave __rcu * curr_active_slave ;
2014-07-15 17:56:56 +04:00
struct slave __rcu * current_arp_slave ;
2014-09-10 01:17:00 +04:00
struct slave __rcu * primary_slave ;
2014-10-05 04:45:01 +04:00
struct bond_up_slave __rcu * slave_arr ; /* Array of usable slaves */
2009-09-25 07:28:09 +04:00
bool force_primary ;
2005-04-17 02:20:36 +04:00
s32 slave_cnt ; /* never change this value outside the attach/detach wrappers */
2012-06-11 23:23:07 +04:00
int ( * recv_probe ) ( const struct sk_buff * , struct bonding * ,
struct slave * ) ;
2014-09-12 00:49:28 +04:00
/* mode_lock is used for mode-specific locking needs, currently used by:
* 3 ad mode ( 4 ) - protect against running bond_3ad_unbind_slave ( ) and
2014-09-15 19:19:34 +04:00
* bond_3ad_state_machine_handler ( ) concurrently and also
* the access to the state machine shared variables .
2014-09-12 00:49:28 +04:00
* TLB mode ( 5 ) - to sync the use and modifications of its hash table
* ALB mode ( 6 ) - to sync the use and modifications of its hash table
*/
2014-09-12 00:49:25 +04:00
spinlock_t mode_lock ;
2016-03-18 03:23:36 +03:00
spinlock_t stats_lock ;
2011-04-26 19:25:52 +04:00
u8 send_peer_notif ;
2013-06-12 02:07:02 +04:00
u8 igmp_retrans ;
2005-04-17 02:20:36 +04:00
# ifdef CONFIG_PROC_FS
struct proc_dir_entry * proc_entry ;
char proc_file_name [ IFNAMSIZ ] ;
# endif /* CONFIG_PROC_FS */
struct list_head bond_list ;
2013-11-05 16:51:41 +04:00
u32 rr_tx_counter ;
2005-04-17 02:20:36 +04:00
struct ad_bond_info ad_info ;
struct alb_bond_info alb_info ;
struct bond_params params ;
2007-10-18 04:37:45 +04:00
struct workqueue_struct * wq ;
struct delayed_work mii_work ;
struct delayed_work arp_work ;
struct delayed_work alb_work ;
struct delayed_work ad_work ;
2010-10-05 18:23:57 +04:00
struct delayed_work mcast_work ;
2014-10-05 04:45:01 +04:00
struct delayed_work slave_arr_work ;
2010-12-09 18:17:13 +03:00
# ifdef CONFIG_DEBUG_FS
2012-08-22 14:11:26 +04:00
/* debugging support via debugfs */
2010-12-09 18:17:13 +03:00
struct dentry * debug_dir ;
# endif /* CONFIG_DEBUG_FS */
2014-09-29 06:34:37 +04:00
struct rtnl_link_stats64 bond_stats ;
2005-04-17 02:20:36 +04:00
} ;
2011-03-12 06:14:35 +03:00
# define bond_slave_get_rcu(dev) \
( ( struct slave * ) rcu_dereference ( dev - > rx_handler_data ) )
2013-01-04 02:49:01 +04:00
# define bond_slave_get_rtnl(dev) \
( ( struct slave * ) rtnl_dereference ( dev - > rx_handler_data ) )
2015-02-03 17:48:31 +03:00
void bond_queue_slave_event ( struct slave * slave ) ;
2015-12-03 14:12:20 +03:00
void bond_lower_state_changed ( struct slave * slave ) ;
2015-02-03 17:48:31 +03:00
bonding: support QinQ for bond arp interval
The bond send arp request to indicate that the slave is active, and if the bond dev
is a vlan dev, it will set the vlan tag in skb to notice the vlan group, but the
bond could only send a skb with 802.1q proto, not support for QinQ.
So add outer tag for lower vlan tag and inner tag for upper vlan tag to support QinQ,
The new skb will be consist of two vlan tag just like this:
dst mac | src mac | outer vlan tag | inner vlan tag | data | .....
If We don't need QinQ, the inner vlan tag could be set to 0 and use outer vlan tag
as a normal vlan group.
Using "ip link" to configure the bond for QinQ and add test log:
ip link add link bond0 bond0.20 type vlan proto 802.1ad id 20
ip link add link bond0.20 bond0.20.200 type vlan proto 802.1q id 200
ifconfig bond0.20 11.11.20.36/24
ifconfig bond0.20.200 11.11.200.36/24
echo +11.11.200.37 > /sys/class/net/bond0/bonding/arp_ip_target
90:e2:ba:07:4a:5c (oui Unknown) > Broadcast, ethertype 802.1Q-QinQ (0x88a8),length 50: vlan 20, p 0,ethertype 802.1Q, vlan 200, p 0, ethertype ARP, Ethernet (len 6), IPv4 (len 4), Request who-has 11.11.200.37 tell 11.11.200.36, length 28
90:e2:ba:06:f9:86 (oui Unknown) > 90:e2:ba:07:4a:5c (oui Unknown), ethertype 802.1Q-QinQ (0x88a8), length 50: vlan 20, p 0, ethertype 802.1Q, vlan 200, p 0, ethertype ARP, Ethernet (len 6), IPv4 (len 4), Reply 11.11.200.37 is-at 90:e2:ba:06:f9:86 (oui Unknown), length 28
v1->v2: remove the comment "TODO: QinQ?".
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-03-25 13:44:43 +04:00
struct bond_vlan_tag {
__be16 vlan_proto ;
unsigned short vlan_id ;
} ;
2005-04-17 02:20:36 +04:00
/**
* Returns NULL if the net_device does not belong to any of the bond ' s slaves
*
* Caller must hold bond lock for read
*/
2011-02-23 10:40:33 +03:00
static inline struct slave * bond_get_slave_by_dev ( struct bonding * bond ,
struct net_device * slave_dev )
2005-04-17 02:20:36 +04:00
{
2013-09-25 11:20:11 +04:00
return netdev_lower_dev_get_private ( bond - > dev , slave_dev ) ;
2005-04-17 02:20:36 +04:00
}
2006-01-06 09:45:42 +03:00
static inline struct bonding * bond_get_bond_by_slave ( struct slave * slave )
2005-04-17 02:20:36 +04:00
{
2013-01-04 02:49:01 +04:00
return slave - > bond ;
2005-04-17 02:20:36 +04:00
}
2014-05-15 23:39:52 +04:00
static inline bool bond_should_override_tx_queue ( struct bonding * bond )
{
2014-05-15 23:39:55 +04:00
return BOND_MODE ( bond ) = = BOND_MODE_ACTIVEBACKUP | |
BOND_MODE ( bond ) = = BOND_MODE_ROUNDROBIN ;
2014-05-15 23:39:52 +04:00
}
2008-12-10 10:07:13 +03:00
static inline bool bond_is_lb ( const struct bonding * bond )
{
2014-05-15 23:39:55 +04:00
return BOND_MODE ( bond ) = = BOND_MODE_TLB | |
BOND_MODE ( bond ) = = BOND_MODE_ALB ;
2008-12-10 10:07:13 +03:00
}
2017-08-10 07:41:44 +03:00
static inline bool bond_needs_speed_duplex ( const struct bonding * bond )
{
return BOND_MODE ( bond ) = = BOND_MODE_8023AD | | bond_is_lb ( bond ) ;
}
2014-07-16 22:10:36 +04:00
static inline bool bond_is_nondyn_tlb ( const struct bonding * bond )
{
2018-05-14 21:48:09 +03:00
return ( bond_is_lb ( bond ) & & bond - > params . tlb_dynamic_lb = = 0 ) ;
}
static inline bool bond_mode_can_use_xmit_hash ( const struct bonding * bond )
{
return ( BOND_MODE ( bond ) = = BOND_MODE_8023AD | |
BOND_MODE ( bond ) = = BOND_MODE_XOR | |
BOND_MODE ( bond ) = = BOND_MODE_TLB | |
BOND_MODE ( bond ) = = BOND_MODE_ALB ) ;
2014-07-16 22:10:36 +04:00
}
2014-10-05 04:44:44 +04:00
static inline bool bond_mode_uses_xmit_hash ( const struct bonding * bond )
{
return ( BOND_MODE ( bond ) = = BOND_MODE_8023AD | |
BOND_MODE ( bond ) = = BOND_MODE_XOR | |
bond_is_nondyn_tlb ( bond ) ) ;
}
2014-05-15 23:39:53 +04:00
static inline bool bond_mode_uses_arp ( int mode )
{
return mode ! = BOND_MODE_8023AD & & mode ! = BOND_MODE_TLB & &
mode ! = BOND_MODE_ALB ;
}
2014-05-15 23:39:54 +04:00
static inline bool bond_mode_uses_primary ( int mode )
{
return mode = = BOND_MODE_ACTIVEBACKUP | | mode = = BOND_MODE_TLB | |
mode = = BOND_MODE_ALB ;
}
static inline bool bond_uses_primary ( struct bonding * bond )
{
2014-05-15 23:39:55 +04:00
return bond_mode_uses_primary ( BOND_MODE ( bond ) ) ;
2014-05-15 23:39:54 +04:00
}
2015-07-30 18:33:24 +03:00
static inline struct net_device * bond_option_active_slave_get_rcu ( struct bonding * bond )
{
struct slave * slave = rcu_dereference ( bond - > curr_active_slave ) ;
return bond_uses_primary ( bond ) & & slave ? slave - > dev : NULL ;
}
2014-05-15 23:39:57 +04:00
static inline bool bond_slave_is_up ( struct slave * slave )
{
return netif_running ( slave - > dev ) & & netif_carrier_ok ( slave - > dev ) ;
}
2011-03-12 06:14:37 +03:00
static inline void bond_set_active_slave ( struct slave * slave )
{
2014-01-17 10:57:56 +04:00
if ( slave - > backup ) {
slave - > backup = 0 ;
2015-02-03 17:48:31 +03:00
bond_queue_slave_event ( slave ) ;
2015-12-03 14:12:20 +03:00
bond_lower_state_changed ( slave ) ;
2014-01-17 10:57:56 +04:00
}
2011-03-12 06:14:37 +03:00
}
static inline void bond_set_backup_slave ( struct slave * slave )
{
2014-01-17 10:57:56 +04:00
if ( ! slave - > backup ) {
slave - > backup = 1 ;
2015-02-03 17:48:31 +03:00
bond_queue_slave_event ( slave ) ;
2015-12-03 14:12:20 +03:00
bond_lower_state_changed ( slave ) ;
2014-01-17 10:57:56 +04:00
}
2011-03-12 06:14:37 +03:00
}
bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c for 802.3ad mode
The problem was introduced by the commit 1d3ee88ae0d
(bonding: add netlink attributes to slave link dev).
The bond_set_active_slave() and bond_set_backup_slave()
will use rtmsg_ifinfo to send slave's states, so these
two functions should be called in RTNL.
In 802.3ad mode, acquiring RTNL for the __enable_port and
__disable_port cases is difficult, as those calls generally
already hold the state machine lock, and cannot unconditionally
call rtnl_lock because either they already hold RTNL (for calls
via bond_3ad_unbind_slave) or due to the potential for deadlock
with bond_3ad_adapter_speed_changed, bond_3ad_adapter_duplex_changed,
bond_3ad_link_change, or bond_3ad_update_lacp_rate. All four of
those are called with RTNL held, and acquire the state machine lock
second. The calling contexts for __enable_port and __disable_port
already hold the state machine lock, and may or may not need RTNL.
According to the Jay's opinion, I don't think it is a problem that
the slave don't send notify message synchronously when the status
changed, normally the state machine is running every 100 ms, send
the notify message at the end of the state machine if the slave's
state changed should be better.
I fix the problem through these steps:
1). add a new function bond_set_slave_state() which could change
the slave's state and call rtmsg_ifinfo() according to the input
parameters called notify.
2). Add a new slave parameter which called should_notify, if the slave's state
changed and don't notify yet, the parameter will be set to 1, and then if
the slave's state changed again, the param will be set to 0, it indicate that
the slave's state has been restored, no need to notify any one.
3). the __enable_port and __disable_port should not call rtmsg_ifinfo
in the state machine lock, any change in the state of slave could
set a flag in the slave, it will indicated that an rtmsg_ifinfo
should be called at the end of the state machine.
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-26 07:05:22 +04:00
static inline void bond_set_slave_state ( struct slave * slave ,
int slave_state , bool notify )
{
if ( slave - > backup = = slave_state )
return ;
slave - > backup = slave_state ;
if ( notify ) {
2015-12-03 14:12:20 +03:00
bond_lower_state_changed ( slave ) ;
2015-02-03 17:48:31 +03:00
bond_queue_slave_event ( slave ) ;
bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c for 802.3ad mode
The problem was introduced by the commit 1d3ee88ae0d
(bonding: add netlink attributes to slave link dev).
The bond_set_active_slave() and bond_set_backup_slave()
will use rtmsg_ifinfo to send slave's states, so these
two functions should be called in RTNL.
In 802.3ad mode, acquiring RTNL for the __enable_port and
__disable_port cases is difficult, as those calls generally
already hold the state machine lock, and cannot unconditionally
call rtnl_lock because either they already hold RTNL (for calls
via bond_3ad_unbind_slave) or due to the potential for deadlock
with bond_3ad_adapter_speed_changed, bond_3ad_adapter_duplex_changed,
bond_3ad_link_change, or bond_3ad_update_lacp_rate. All four of
those are called with RTNL held, and acquire the state machine lock
second. The calling contexts for __enable_port and __disable_port
already hold the state machine lock, and may or may not need RTNL.
According to the Jay's opinion, I don't think it is a problem that
the slave don't send notify message synchronously when the status
changed, normally the state machine is running every 100 ms, send
the notify message at the end of the state machine if the slave's
state changed should be better.
I fix the problem through these steps:
1). add a new function bond_set_slave_state() which could change
the slave's state and call rtmsg_ifinfo() according to the input
parameters called notify.
2). Add a new slave parameter which called should_notify, if the slave's state
changed and don't notify yet, the parameter will be set to 1, and then if
the slave's state changed again, the param will be set to 0, it indicate that
the slave's state has been restored, no need to notify any one.
3). the __enable_port and __disable_port should not call rtmsg_ifinfo
in the state machine lock, any change in the state of slave could
set a flag in the slave, it will indicated that an rtmsg_ifinfo
should be called at the end of the state machine.
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-26 07:05:22 +04:00
slave - > should_notify = 0 ;
} else {
if ( slave - > should_notify )
slave - > should_notify = 0 ;
else
slave - > should_notify = 1 ;
}
}
2014-01-28 07:48:53 +04:00
static inline void bond_slave_state_change ( struct bonding * bond )
{
struct list_head * iter ;
struct slave * tmp ;
bond_for_each_slave ( bond , tmp , iter ) {
if ( tmp - > link = = BOND_LINK_UP )
bond_set_active_slave ( tmp ) ;
else if ( tmp - > link = = BOND_LINK_DOWN )
bond_set_backup_slave ( tmp ) ;
}
}
2014-02-26 07:05:23 +04:00
static inline void bond_slave_state_notify ( struct bonding * bond )
{
struct list_head * iter ;
struct slave * tmp ;
bond_for_each_slave ( bond , tmp , iter ) {
if ( tmp - > should_notify ) {
2015-12-03 14:12:20 +03:00
bond_lower_state_changed ( tmp ) ;
2014-02-26 07:05:23 +04:00
tmp - > should_notify = 0 ;
}
}
}
2011-03-12 06:14:37 +03:00
static inline int bond_slave_state ( struct slave * slave )
{
return slave - > backup ;
}
static inline bool bond_is_active_slave ( struct slave * slave )
{
return ! bond_slave_state ( slave ) ;
}
2014-05-15 23:39:58 +04:00
static inline bool bond_slave_can_tx ( struct slave * slave )
{
return bond_slave_is_up ( slave ) & & slave - > link = = BOND_LINK_UP & &
bond_is_active_slave ( slave ) ;
}
net: Add lag.h, net_lag_port_dev_txable()
LAG devices (team or bond) recognize for each one of their slave devices
whether LAG traffic is going to be sent through that device. Bond calls
such devices "active", team calls them "txable". When this state
changes, a NETDEV_CHANGELOWERSTATE notification is distributed, together
with a netdev_notifier_changelowerstate_info structure that for LAG
devices includes a tx_enabled flag that refers to the new state. The
notification thus makes it possible to react to the changes in txability
in drivers.
However there's no way to query txability from the outside on demand.
That is problematic namely for mlxsw, which when resolving ERSPAN packet
path, may encounter a LAG device, and needs to determine which of the
slaves it should choose.
To that end, introduce a new function, net_lag_port_dev_txable(), which
determines whether a given slave device is "active" or
"txable" (depending on the flavor of the LAG device). That function then
dispatches to per-LAG-flavor helpers, bond_is_active_slave_dev() resp.
team_port_dev_txable().
Because there currently is no good place where net_lag_port_dev_txable()
should be added, introduce a new header file, lag.h, which should from
now on hold any logic common to both team and bond. (But keep
netif_is_lag_master() together with the rest of netif_is_*_master()
functions).
Signed-off-by: Petr Machata <petrm@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-07-10 10:02:58 +03:00
static inline bool bond_is_active_slave_dev ( const struct net_device * slave_dev )
{
struct slave * slave ;
bool active ;
rcu_read_lock ( ) ;
slave = bond_slave_get_rcu ( slave_dev ) ;
active = bond_is_active_slave ( slave ) ;
rcu_read_unlock ( ) ;
return active ;
}
bonding: attempt to better support longer hw addresses
People are using bonding over Infiniband IPoIB connections, and who knows
what else. Infiniband has a hardware address length of 20 octets
(INFINIBAND_ALEN), and the network core defines a MAX_ADDR_LEN of 32.
Various places in the bonding code are currently hard-wired to 6 octets
(ETH_ALEN), such as the 3ad code, which I've left untouched here. Besides,
only alb is currently possible on Infiniband links right now anyway, due
to commit 1533e7731522, so the alb code is where most of the changes are.
One major component of this change is the addition of a bond_hw_addr_copy
function that takes a length argument, instead of using ether_addr_copy
everywhere that hardware addresses need to be copied about. The other
major component of this change is converting the bonding code from using
struct sockaddr for address storage to struct sockaddr_storage, as the
former has an address storage space of only 14, while the latter is 128
minus a few, which is necessary to support bonding over device with up to
MAX_ADDR_LEN octet hardware addresses. Additionally, this probably fixes
up some memory corruption issues with the current code, where it's
possible to write an infiniband hardware address into a sockaddr declared
on the stack.
Lightly tested on a dual mlx4 IPoIB setup, which properly shows a 20-octet
hardware address now:
$ cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: mlx4_ib0 (primary_reselect always)
Currently Active Slave: mlx4_ib0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 100
Down Delay (ms): 100
Slave Interface: mlx4_ib0
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr:
80:00:02:08:fe:80:00:00:00:00:00:00:e4:1d:2d:03:00:1d:67:01
Slave queue ID: 0
Slave Interface: mlx4_ib1
MII Status: up
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr:
80:00:02:09:fe:80:00:00:00:00:00:01:e4:1d:2d:03:00:1d:67:02
Slave queue ID: 0
Also tested with a standard 1Gbps NIC bonding setup (with a mix of
e1000 and e1000e cards), running LNST's bonding tests.
CC: Jay Vosburgh <j.vosburgh@gmail.com>
CC: Veaceslav Falico <vfalico@gmail.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: netdev@vger.kernel.org
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-04-05 00:32:42 +03:00
static inline void bond_hw_addr_copy ( u8 * dst , const u8 * src , unsigned int len )
{
if ( len = = ETH_ALEN ) {
ether_addr_copy ( dst , src ) ;
return ;
}
memcpy ( dst , src , len ) ;
}
2009-09-25 07:28:09 +04:00
# define BOND_PRI_RESELECT_ALWAYS 0
# define BOND_PRI_RESELECT_BETTER 1
# define BOND_PRI_RESELECT_FAILURE 2
2008-05-18 08:10:14 +04:00
# define BOND_FOM_NONE 0
# define BOND_FOM_ACTIVE 1
# define BOND_FOM_FOLLOW 2
bonding: add an option to fail when any of arp_ip_target is inaccessible
Currently, we fail only when all of the ips in arp_ip_target are gone.
However, in some situations we might need to fail if even one host from
arp_ip_target becomes unavailable.
All situations, obviously, rely on the idea that we need *completely*
functional network, with all interfaces/addresses working correctly.
One real world example might be:
vlans on top on bond (hybrid port). If bond and vlans have ips assigned
and we have their peers monitored via arp_ip_target - in case of switch
misconfiguration (trunk/access port), slave driver malfunction or
tagged/untagged traffic dropped on the way - we will be able to switch
to another slave.
Though any other configuration needs that if we need to have access to all
arp_ip_targets.
This patch adds this possibility by adding a new parameter -
arp_all_targets (both as a module parameter and as a sysfs knob). It can be
set to:
0 or any (the default) - which works exactly as it's working now -
the slave is up if any of the arp_ip_targets are up.
1 or all - the slave is up if all of the arp_ip_targets are up.
This parameter can be changed on the fly (via sysfs), and requires the mode
to be active-backup and arp_validate to be enabled (it obeys the
arp_validate config on which slaves to validate).
Internally it's done through:
1) Add target_last_arp_rx[BOND_MAX_ARP_TARGETS] array to slave struct. It's
an array of jiffies, meaning that slave->target_last_arp_rx[i] is the
last time we've received arp from bond->params.arp_targets[i] on this
slave.
2) If we successfully validate an arp from bond->params.arp_targets[i] in
bond_validate_arp() - update the slave->target_last_arp_rx[i] with the
current jiffies value.
3) When getting slave's last_rx via slave_last_rx(), we return the oldest
time when we've received an arp from any address in
bond->params.arp_targets[].
If the value of arp_all_targets == 0 - we still work the same way as
before.
Also, update the documentation to reflect the new parameter.
v3->v4:
Kill the forgotten rtnl_unlock(), rephrase the documentation part to be
more clear, don't fail setting arp_all_targets if arp_validate is not set -
it has no effect anyway but can be easier to set up. Also, print a warning
if the last arp_ip_target is removed while the arp_interval is on, but not
the arp_validate.
v2->v3:
Use _bh spinlock, remove useless rtnl_lock() and use jiffies for new
arp_ip_target last arp, instead of slave_last_rx(). On bond_enslave(),
use the same initialization value for target_last_arp_rx[] as is used
for the default last_arp_rx, to avoid useless interface flaps.
Also, instead of failing to remove the last arp_ip_target just print a
warning - otherwise it might break existing scripts.
v1->v2:
Correctly handle adding/removing hosts in arp_ip_target - we need to
shift/initialize all slave's target_last_arp_rx. Also, don't fail module
loading on arp_all_targets misconfiguration, just disable it, and some
minor style fixes.
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-24 13:49:34 +04:00
# define BOND_ARP_TARGETS_ANY 0
# define BOND_ARP_TARGETS_ALL 1
2006-09-23 08:54:53 +04:00
# define BOND_ARP_VALIDATE_NONE 0
# define BOND_ARP_VALIDATE_ACTIVE (1 << BOND_STATE_ACTIVE)
# define BOND_ARP_VALIDATE_BACKUP (1 << BOND_STATE_BACKUP)
# define BOND_ARP_VALIDATE_ALL (BOND_ARP_VALIDATE_ACTIVE | \
BOND_ARP_VALIDATE_BACKUP )
2014-02-18 10:48:40 +04:00
# define BOND_ARP_FILTER (BOND_ARP_VALIDATE_ALL + 1)
# define BOND_ARP_FILTER_ACTIVE (BOND_ARP_VALIDATE_ACTIVE | \
BOND_ARP_FILTER )
# define BOND_ARP_FILTER_BACKUP (BOND_ARP_VALIDATE_BACKUP | \
BOND_ARP_FILTER )
2006-09-23 08:54:53 +04:00
bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c for 802.3ad mode
The problem was introduced by the commit 1d3ee88ae0d
(bonding: add netlink attributes to slave link dev).
The bond_set_active_slave() and bond_set_backup_slave()
will use rtmsg_ifinfo to send slave's states, so these
two functions should be called in RTNL.
In 802.3ad mode, acquiring RTNL for the __enable_port and
__disable_port cases is difficult, as those calls generally
already hold the state machine lock, and cannot unconditionally
call rtnl_lock because either they already hold RTNL (for calls
via bond_3ad_unbind_slave) or due to the potential for deadlock
with bond_3ad_adapter_speed_changed, bond_3ad_adapter_duplex_changed,
bond_3ad_link_change, or bond_3ad_update_lacp_rate. All four of
those are called with RTNL held, and acquire the state machine lock
second. The calling contexts for __enable_port and __disable_port
already hold the state machine lock, and may or may not need RTNL.
According to the Jay's opinion, I don't think it is a problem that
the slave don't send notify message synchronously when the status
changed, normally the state machine is running every 100 ms, send
the notify message at the end of the state machine if the slave's
state changed should be better.
I fix the problem through these steps:
1). add a new function bond_set_slave_state() which could change
the slave's state and call rtmsg_ifinfo() according to the input
parameters called notify.
2). Add a new slave parameter which called should_notify, if the slave's state
changed and don't notify yet, the parameter will be set to 1, and then if
the slave's state changed again, the param will be set to 0, it indicate that
the slave's state has been restored, no need to notify any one.
3). the __enable_port and __disable_port should not call rtmsg_ifinfo
in the state machine lock, any change in the state of slave could
set a flag in the slave, it will indicated that an rtmsg_ifinfo
should be called at the end of the state machine.
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-26 07:05:22 +04:00
# define BOND_SLAVE_NOTIFY_NOW true
# define BOND_SLAVE_NOTIFY_LATER false
2006-12-12 19:24:39 +03:00
static inline int slave_do_arp_validate ( struct bonding * bond ,
struct slave * slave )
2006-09-23 08:54:53 +04:00
{
2011-03-12 06:14:37 +03:00
return bond - > params . arp_validate & ( 1 < < bond_slave_state ( slave ) ) ;
2006-09-23 08:54:53 +04:00
}
2014-05-07 18:10:20 +04:00
static inline int slave_do_arp_validate_only ( struct bonding * bond )
2014-02-18 10:48:40 +04:00
{
return bond - > params . arp_validate & BOND_ARP_FILTER ;
}
2014-05-15 23:39:56 +04:00
static inline int bond_is_ip_target_ok ( __be32 addr )
{
return ! ipv4_is_lbcast ( addr ) & & ! ipv4_is_zeronet ( addr ) ;
}
bonding: add an option to fail when any of arp_ip_target is inaccessible
Currently, we fail only when all of the ips in arp_ip_target are gone.
However, in some situations we might need to fail if even one host from
arp_ip_target becomes unavailable.
All situations, obviously, rely on the idea that we need *completely*
functional network, with all interfaces/addresses working correctly.
One real world example might be:
vlans on top on bond (hybrid port). If bond and vlans have ips assigned
and we have their peers monitored via arp_ip_target - in case of switch
misconfiguration (trunk/access port), slave driver malfunction or
tagged/untagged traffic dropped on the way - we will be able to switch
to another slave.
Though any other configuration needs that if we need to have access to all
arp_ip_targets.
This patch adds this possibility by adding a new parameter -
arp_all_targets (both as a module parameter and as a sysfs knob). It can be
set to:
0 or any (the default) - which works exactly as it's working now -
the slave is up if any of the arp_ip_targets are up.
1 or all - the slave is up if all of the arp_ip_targets are up.
This parameter can be changed on the fly (via sysfs), and requires the mode
to be active-backup and arp_validate to be enabled (it obeys the
arp_validate config on which slaves to validate).
Internally it's done through:
1) Add target_last_arp_rx[BOND_MAX_ARP_TARGETS] array to slave struct. It's
an array of jiffies, meaning that slave->target_last_arp_rx[i] is the
last time we've received arp from bond->params.arp_targets[i] on this
slave.
2) If we successfully validate an arp from bond->params.arp_targets[i] in
bond_validate_arp() - update the slave->target_last_arp_rx[i] with the
current jiffies value.
3) When getting slave's last_rx via slave_last_rx(), we return the oldest
time when we've received an arp from any address in
bond->params.arp_targets[].
If the value of arp_all_targets == 0 - we still work the same way as
before.
Also, update the documentation to reflect the new parameter.
v3->v4:
Kill the forgotten rtnl_unlock(), rephrase the documentation part to be
more clear, don't fail setting arp_all_targets if arp_validate is not set -
it has no effect anyway but can be easier to set up. Also, print a warning
if the last arp_ip_target is removed while the arp_interval is on, but not
the arp_validate.
v2->v3:
Use _bh spinlock, remove useless rtnl_lock() and use jiffies for new
arp_ip_target last arp, instead of slave_last_rx(). On bond_enslave(),
use the same initialization value for target_last_arp_rx[] as is used
for the default last_arp_rx, to avoid useless interface flaps.
Also, instead of failing to remove the last arp_ip_target just print a
warning - otherwise it might break existing scripts.
v1->v2:
Correctly handle adding/removing hosts in arp_ip_target - we need to
shift/initialize all slave's target_last_arp_rx. Also, don't fail module
loading on arp_all_targets misconfiguration, just disable it, and some
minor style fixes.
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-24 13:49:34 +04:00
/* Get the oldest arp which we've received on this slave for bond's
* arp_targets .
*/
static inline unsigned long slave_oldest_target_arp_rx ( struct bonding * bond ,
struct slave * slave )
{
int i = 1 ;
unsigned long ret = slave - > target_last_arp_rx [ 0 ] ;
for ( ; ( i < BOND_MAX_ARP_TARGETS ) & & bond - > params . arp_targets [ i ] ; i + + )
if ( time_before ( slave - > target_last_arp_rx [ i ] , ret ) )
ret = slave - > target_last_arp_rx [ i ] ;
return ret ;
}
2006-12-12 19:24:39 +03:00
static inline unsigned long slave_last_rx ( struct bonding * bond ,
2007-01-29 23:08:38 +03:00
struct slave * slave )
2006-09-23 08:54:53 +04:00
{
2014-02-18 10:48:43 +04:00
if ( bond - > params . arp_all_targets = = BOND_ARP_TARGETS_ALL )
return slave_oldest_target_arp_rx ( bond , slave ) ;
2006-09-23 08:54:53 +04:00
2014-02-18 10:48:47 +04:00
return slave - > last_rx ;
2006-09-23 08:54:53 +04:00
}
2011-02-18 02:43:32 +03:00
# ifdef CONFIG_NET_POLL_CONTROLLER
static inline void bond_netpoll_send_skb ( const struct slave * slave ,
struct sk_buff * skb )
{
struct netpoll * np = slave - > np ;
if ( np )
netpoll_send_skb ( np , skb ) ;
}
# else
static inline void bond_netpoll_send_skb ( const struct slave * slave ,
struct sk_buff * skb )
{
}
# endif
bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c for 802.3ad mode
The problem was introduced by the commit 1d3ee88ae0d
(bonding: add netlink attributes to slave link dev).
The bond_set_active_slave() and bond_set_backup_slave()
will use rtmsg_ifinfo to send slave's states, so these
two functions should be called in RTNL.
In 802.3ad mode, acquiring RTNL for the __enable_port and
__disable_port cases is difficult, as those calls generally
already hold the state machine lock, and cannot unconditionally
call rtnl_lock because either they already hold RTNL (for calls
via bond_3ad_unbind_slave) or due to the potential for deadlock
with bond_3ad_adapter_speed_changed, bond_3ad_adapter_duplex_changed,
bond_3ad_link_change, or bond_3ad_update_lacp_rate. All four of
those are called with RTNL held, and acquire the state machine lock
second. The calling contexts for __enable_port and __disable_port
already hold the state machine lock, and may or may not need RTNL.
According to the Jay's opinion, I don't think it is a problem that
the slave don't send notify message synchronously when the status
changed, normally the state machine is running every 100 ms, send
the notify message at the end of the state machine if the slave's
state changed should be better.
I fix the problem through these steps:
1). add a new function bond_set_slave_state() which could change
the slave's state and call rtmsg_ifinfo() according to the input
parameters called notify.
2). Add a new slave parameter which called should_notify, if the slave's state
changed and don't notify yet, the parameter will be set to 1, and then if
the slave's state changed again, the param will be set to 0, it indicate that
the slave's state has been restored, no need to notify any one.
3). the __enable_port and __disable_port should not call rtmsg_ifinfo
in the state machine lock, any change in the state of slave could
set a flag in the slave, it will indicated that an rtmsg_ifinfo
should be called at the end of the state machine.
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-26 07:05:22 +04:00
static inline void bond_set_slave_inactive_flags ( struct slave * slave ,
bool notify )
2005-04-17 02:20:36 +04:00
{
2013-01-04 02:49:01 +04:00
if ( ! bond_is_lb ( slave - > bond ) )
bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c for 802.3ad mode
The problem was introduced by the commit 1d3ee88ae0d
(bonding: add netlink attributes to slave link dev).
The bond_set_active_slave() and bond_set_backup_slave()
will use rtmsg_ifinfo to send slave's states, so these
two functions should be called in RTNL.
In 802.3ad mode, acquiring RTNL for the __enable_port and
__disable_port cases is difficult, as those calls generally
already hold the state machine lock, and cannot unconditionally
call rtnl_lock because either they already hold RTNL (for calls
via bond_3ad_unbind_slave) or due to the potential for deadlock
with bond_3ad_adapter_speed_changed, bond_3ad_adapter_duplex_changed,
bond_3ad_link_change, or bond_3ad_update_lacp_rate. All four of
those are called with RTNL held, and acquire the state machine lock
second. The calling contexts for __enable_port and __disable_port
already hold the state machine lock, and may or may not need RTNL.
According to the Jay's opinion, I don't think it is a problem that
the slave don't send notify message synchronously when the status
changed, normally the state machine is running every 100 ms, send
the notify message at the end of the state machine if the slave's
state changed should be better.
I fix the problem through these steps:
1). add a new function bond_set_slave_state() which could change
the slave's state and call rtmsg_ifinfo() according to the input
parameters called notify.
2). Add a new slave parameter which called should_notify, if the slave's state
changed and don't notify yet, the parameter will be set to 1, and then if
the slave's state changed again, the param will be set to 0, it indicate that
the slave's state has been restored, no need to notify any one.
3). the __enable_port and __disable_port should not call rtmsg_ifinfo
in the state machine lock, any change in the state of slave could
set a flag in the slave, it will indicated that an rtmsg_ifinfo
should be called at the end of the state machine.
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-26 07:05:22 +04:00
bond_set_slave_state ( slave , BOND_STATE_BACKUP , notify ) ;
2013-01-04 02:49:01 +04:00
if ( ! slave - > bond - > params . all_slaves_active )
2011-03-16 11:46:43 +03:00
slave - > inactive = 1 ;
2005-04-17 02:20:36 +04:00
}
bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c for 802.3ad mode
The problem was introduced by the commit 1d3ee88ae0d
(bonding: add netlink attributes to slave link dev).
The bond_set_active_slave() and bond_set_backup_slave()
will use rtmsg_ifinfo to send slave's states, so these
two functions should be called in RTNL.
In 802.3ad mode, acquiring RTNL for the __enable_port and
__disable_port cases is difficult, as those calls generally
already hold the state machine lock, and cannot unconditionally
call rtnl_lock because either they already hold RTNL (for calls
via bond_3ad_unbind_slave) or due to the potential for deadlock
with bond_3ad_adapter_speed_changed, bond_3ad_adapter_duplex_changed,
bond_3ad_link_change, or bond_3ad_update_lacp_rate. All four of
those are called with RTNL held, and acquire the state machine lock
second. The calling contexts for __enable_port and __disable_port
already hold the state machine lock, and may or may not need RTNL.
According to the Jay's opinion, I don't think it is a problem that
the slave don't send notify message synchronously when the status
changed, normally the state machine is running every 100 ms, send
the notify message at the end of the state machine if the slave's
state changed should be better.
I fix the problem through these steps:
1). add a new function bond_set_slave_state() which could change
the slave's state and call rtmsg_ifinfo() according to the input
parameters called notify.
2). Add a new slave parameter which called should_notify, if the slave's state
changed and don't notify yet, the parameter will be set to 1, and then if
the slave's state changed again, the param will be set to 0, it indicate that
the slave's state has been restored, no need to notify any one.
3). the __enable_port and __disable_port should not call rtmsg_ifinfo
in the state machine lock, any change in the state of slave could
set a flag in the slave, it will indicated that an rtmsg_ifinfo
should be called at the end of the state machine.
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-26 07:05:22 +04:00
static inline void bond_set_slave_active_flags ( struct slave * slave ,
bool notify )
2005-04-17 02:20:36 +04:00
{
bonding: Fix RTNL: assertion failed at net/core/rtnetlink.c for 802.3ad mode
The problem was introduced by the commit 1d3ee88ae0d
(bonding: add netlink attributes to slave link dev).
The bond_set_active_slave() and bond_set_backup_slave()
will use rtmsg_ifinfo to send slave's states, so these
two functions should be called in RTNL.
In 802.3ad mode, acquiring RTNL for the __enable_port and
__disable_port cases is difficult, as those calls generally
already hold the state machine lock, and cannot unconditionally
call rtnl_lock because either they already hold RTNL (for calls
via bond_3ad_unbind_slave) or due to the potential for deadlock
with bond_3ad_adapter_speed_changed, bond_3ad_adapter_duplex_changed,
bond_3ad_link_change, or bond_3ad_update_lacp_rate. All four of
those are called with RTNL held, and acquire the state machine lock
second. The calling contexts for __enable_port and __disable_port
already hold the state machine lock, and may or may not need RTNL.
According to the Jay's opinion, I don't think it is a problem that
the slave don't send notify message synchronously when the status
changed, normally the state machine is running every 100 ms, send
the notify message at the end of the state machine if the slave's
state changed should be better.
I fix the problem through these steps:
1). add a new function bond_set_slave_state() which could change
the slave's state and call rtmsg_ifinfo() according to the input
parameters called notify.
2). Add a new slave parameter which called should_notify, if the slave's state
changed and don't notify yet, the parameter will be set to 1, and then if
the slave's state changed again, the param will be set to 0, it indicate that
the slave's state has been restored, no need to notify any one.
3). the __enable_port and __disable_port should not call rtmsg_ifinfo
in the state machine lock, any change in the state of slave could
set a flag in the slave, it will indicated that an rtmsg_ifinfo
should be called at the end of the state machine.
Cc: Jay Vosburgh <fubar@us.ibm.com>
Cc: Veaceslav Falico <vfalico@redhat.com>
Cc: Andy Gospodarek <andy@greyhouse.net>
Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2014-02-26 07:05:22 +04:00
bond_set_slave_state ( slave , BOND_STATE_ACTIVE , notify ) ;
2011-03-16 11:46:43 +03:00
slave - > inactive = 0 ;
}
static inline bool bond_is_slave_inactive ( struct slave * slave )
{
return slave - > inactive ;
2005-04-17 02:20:36 +04:00
}
2017-03-27 21:37:30 +03:00
static inline void bond_propose_link_state ( struct slave * slave , int state )
{
slave - > link_new_state = state ;
}
static inline void bond_commit_link_state ( struct slave * slave , bool notify )
2015-02-03 17:48:30 +03:00
{
2019-11-02 07:56:42 +03:00
if ( slave - > link_new_state = = BOND_LINK_NOCHANGE )
2015-12-03 14:12:19 +03:00
return ;
2017-03-27 21:37:30 +03:00
slave - > link = slave - > link_new_state ;
2015-12-03 14:12:19 +03:00
if ( notify ) {
bond_queue_slave_event ( slave ) ;
2015-12-03 14:12:20 +03:00
bond_lower_state_changed ( slave ) ;
2015-12-03 14:12:19 +03:00
slave - > should_notify_link = 0 ;
} else {
if ( slave - > should_notify_link )
slave - > should_notify_link = 0 ;
else
slave - > should_notify_link = 1 ;
}
}
2017-03-27 21:37:30 +03:00
static inline void bond_set_slave_link_state ( struct slave * slave , int state ,
bool notify )
{
bond_propose_link_state ( slave , state ) ;
bond_commit_link_state ( slave , notify ) ;
}
2015-12-03 14:12:19 +03:00
static inline void bond_slave_link_notify ( struct bonding * bond )
{
struct list_head * iter ;
struct slave * tmp ;
bond_for_each_slave ( bond , tmp , iter ) {
if ( tmp - > should_notify_link ) {
bond_queue_slave_event ( tmp ) ;
2015-12-03 14:12:20 +03:00
bond_lower_state_changed ( tmp ) ;
2015-12-03 14:12:19 +03:00
tmp - > should_notify_link = 0 ;
}
}
2015-02-03 17:48:30 +03:00
}
2012-03-22 20:14:29 +04:00
static inline __be32 bond_confirm_addr ( struct net_device * dev , __be32 dst , __be32 local )
{
struct in_device * in_dev ;
__be32 addr = 0 ;
rcu_read_lock ( ) ;
in_dev = __in_dev_get_rcu ( dev ) ;
if ( in_dev )
2013-12-10 18:02:40 +04:00
addr = inet_confirm_addr ( dev_net ( dev ) , in_dev , dst , local ,
RT_SCOPE_HOST ) ;
2012-03-22 20:14:29 +04:00
rcu_read_unlock ( ) ;
return addr ;
}
2014-05-07 18:10:19 +04:00
struct bond_net {
struct net * net ; /* Associated network namespace */
struct list_head dev_list ;
# ifdef CONFIG_PROC_FS
struct proc_dir_entry * proc_dir ;
# endif
struct class_attribute class_attr_bonding_masters ;
} ;
2011-10-13 01:56:25 +04:00
2013-09-07 02:00:26 +04:00
int bond_arp_rcv ( const struct sk_buff * skb , struct bonding * bond , struct slave * slave ) ;
2014-01-02 05:13:09 +04:00
void bond_dev_queue_xmit ( struct bonding * bond , struct sk_buff * skb , struct net_device * slave_dev ) ;
2009-10-29 17:18:26 +03:00
int bond_create ( struct net * net , const char * name ) ;
2011-10-13 01:56:25 +04:00
int bond_create_sysfs ( struct bond_net * net ) ;
void bond_destroy_sysfs ( struct bond_net * net ) ;
2009-10-29 17:18:22 +03:00
void bond_prepare_sysfs_group ( struct bonding * bond ) ;
2014-01-17 10:57:49 +04:00
int bond_sysfs_slave_add ( struct slave * slave ) ;
void bond_sysfs_slave_del ( struct slave * slave ) ;
2017-10-05 03:48:46 +03:00
int bond_enslave ( struct net_device * bond_dev , struct net_device * slave_dev ,
struct netlink_ext_ack * extack ) ;
2005-11-09 21:35:51 +03:00
int bond_release ( struct net_device * bond_dev , struct net_device * slave_dev ) ;
2014-04-23 03:30:15 +04:00
u32 bond_xmit_hash ( struct bonding * bond , struct sk_buff * skb ) ;
2015-01-26 09:16:57 +03:00
int bond_set_carrier ( struct bonding * bond ) ;
2005-11-09 21:35:51 +03:00
void bond_select_active_slave ( struct bonding * bond ) ;
void bond_change_active_slave ( struct bonding * bond , struct slave * new_active ) ;
2010-12-09 18:17:13 +03:00
void bond_create_debugfs ( void ) ;
void bond_destroy_debugfs ( void ) ;
void bond_debug_register ( struct bonding * bond ) ;
void bond_debug_unregister ( struct bonding * bond ) ;
void bond_debug_reregister ( struct bonding * bond ) ;
2011-04-13 19:22:29 +04:00
const char * bond_mode_name ( int mode ) ;
2013-10-18 19:43:33 +04:00
void bond_setup ( struct net_device * bond_dev ) ;
unsigned int bond_get_num_tx_queues ( void ) ;
int bond_netlink_init ( void ) ;
void bond_netlink_fini ( void ) ;
2013-10-18 19:43:37 +04:00
struct net_device * bond_option_active_slave_get_rcu ( struct bonding * bond ) ;
2014-01-17 10:57:49 +04:00
const char * bond_slave_link_status ( s8 link ) ;
2014-07-17 19:02:23 +04:00
struct bond_vlan_tag * bond_verify_device_path ( struct net_device * start_dev ,
struct net_device * end_dev ,
int level ) ;
2014-10-05 04:45:01 +04:00
int bond_update_slave_arr ( struct bonding * bond , struct slave * skipslave ) ;
void bond_slave_arr_work_rearm ( struct bonding * bond , unsigned long delay ) ;
2017-04-20 22:49:24 +03:00
void bond_work_init_all ( struct bonding * bond ) ;
2005-04-17 02:20:36 +04:00
2011-03-07 00:58:46 +03:00
# ifdef CONFIG_PROC_FS
void bond_create_proc_entry ( struct bonding * bond ) ;
void bond_remove_proc_entry ( struct bonding * bond ) ;
void bond_create_proc_dir ( struct bond_net * bn ) ;
void bond_destroy_proc_dir ( struct bond_net * bn ) ;
# else
static inline void bond_create_proc_entry ( struct bonding * bond )
{
}
static inline void bond_remove_proc_entry ( struct bonding * bond )
{
}
static inline void bond_create_proc_dir ( struct bond_net * bn )
{
}
static inline void bond_destroy_proc_dir ( struct bond_net * bn )
{
}
# endif
2012-11-28 03:57:04 +04:00
static inline struct slave * bond_slave_has_mac ( struct bonding * bond ,
const u8 * mac )
{
2013-09-25 11:20:14 +04:00
struct list_head * iter ;
2012-11-28 03:57:04 +04:00
struct slave * tmp ;
2013-09-25 11:20:14 +04:00
bond_for_each_slave ( bond , tmp , iter )
2012-11-28 03:57:04 +04:00
if ( ether_addr_equal_64bits ( mac , tmp - > dev - > dev_addr ) )
return tmp ;
return NULL ;
}
2011-03-07 00:58:46 +03:00
2013-10-15 12:28:39 +04:00
/* Caller must hold rcu_read_lock() for read */
static inline struct slave * bond_slave_has_mac_rcu ( struct bonding * bond ,
const u8 * mac )
{
struct list_head * iter ;
struct slave * tmp ;
bond_for_each_slave_rcu ( bond , tmp , iter )
if ( ether_addr_equal_64bits ( mac , tmp - > dev - > dev_addr ) )
return tmp ;
return NULL ;
}
2014-06-05 00:23:38 +04:00
/* Caller must hold rcu_read_lock() for read */
static inline bool bond_slave_has_mac_rx ( struct bonding * bond , const u8 * mac )
{
struct list_head * iter ;
struct slave * tmp ;
struct netdev_hw_addr * ha ;
bond_for_each_slave_rcu ( bond , tmp , iter )
if ( ether_addr_equal_64bits ( mac , tmp - > dev - > dev_addr ) )
return true ;
if ( netdev_uc_empty ( bond - > dev ) )
return false ;
netdev_for_each_uc_addr ( ha , bond - > dev )
if ( ether_addr_equal_64bits ( mac , ha - > addr ) )
return true ;
return false ;
}
2013-06-24 13:49:29 +04:00
/* Check if the ip is present in arp ip list, or first free slot if ip == 0
* Returns - 1 if not found , index if found
*/
static inline int bond_get_targets_ip ( __be32 * targets , __be32 ip )
{
int i ;
for ( i = 0 ; i < BOND_MAX_ARP_TARGETS ; i + + )
if ( targets [ i ] = = ip )
return i ;
else if ( targets [ i ] = = 0 )
break ;
return - 1 ;
}
2008-09-14 19:56:12 +04:00
/* exported from bond_main.c */
netns: make struct pernet_operations::id unsigned int
Make struct pernet_operations::id unsigned.
There are 2 reasons to do so:
1)
This field is really an index into an zero based array and
thus is unsigned entity. Using negative value is out-of-bound
access by definition.
2)
On x86_64 unsigned 32-bit data which are mixed with pointers
via array indexing or offsets added or subtracted to pointers
are preffered to signed 32-bit data.
"int" being used as an array index needs to be sign-extended
to 64-bit before being used.
void f(long *p, int i)
{
g(p[i]);
}
roughly translates to
movsx rsi, esi
mov rdi, [rsi+...]
call g
MOVSX is 3 byte instruction which isn't necessary if the variable is
unsigned because x86_64 is zero extending by default.
Now, there is net_generic() function which, you guessed it right, uses
"int" as an array index:
static inline void *net_generic(const struct net *net, int id)
{
...
ptr = ng->ptr[id - 1];
...
}
And this function is used a lot, so those sign extensions add up.
Patch snipes ~1730 bytes on allyesconfig kernel (without all junk
messing with code generation):
add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)
Unfortunately some functions actually grow bigger.
This is a semmingly random artefact of code generation with register
allocator being used differently. gcc decides that some variable
needs to live in new r8+ registers and every access now requires REX
prefix. Or it is shifted into r12, so [r12+0] addressing mode has to be
used which is longer than [r8]
However, overall balance is in negative direction:
add/remove: 0/0 grow/shrink: 70/598 up/down: 396/-2126 (-1730)
function old new delta
nfsd4_lock 3886 3959 +73
tipc_link_build_proto_msg 1096 1140 +44
mac80211_hwsim_new_radio 2776 2808 +32
tipc_mon_rcv 1032 1058 +26
svcauth_gss_legacy_init 1413 1429 +16
tipc_bcbase_select_primary 379 392 +13
nfsd4_exchange_id 1247 1260 +13
nfsd4_setclientid_confirm 782 793 +11
...
put_client_renew_locked 494 480 -14
ip_set_sockfn_get 730 716 -14
geneve_sock_add 829 813 -16
nfsd4_sequence_done 721 703 -18
nlmclnt_lookup_host 708 686 -22
nfsd4_lockt 1085 1063 -22
nfs_get_client 1077 1050 -27
tcf_bpf_init 1106 1076 -30
nfsd4_encode_fattr 5997 5930 -67
Total: Before=154856051, After=154854321, chg -0.00%
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-11-17 04:58:21 +03:00
extern unsigned int bond_net_id ;
2008-12-10 10:10:38 +03:00
extern const struct bond_parm_tbl bond_lacp_tbl [ ] ;
extern const struct bond_parm_tbl xmit_hashtype_tbl [ ] ;
extern const struct bond_parm_tbl arp_validate_tbl [ ] ;
bonding: add an option to fail when any of arp_ip_target is inaccessible
Currently, we fail only when all of the ips in arp_ip_target are gone.
However, in some situations we might need to fail if even one host from
arp_ip_target becomes unavailable.
All situations, obviously, rely on the idea that we need *completely*
functional network, with all interfaces/addresses working correctly.
One real world example might be:
vlans on top on bond (hybrid port). If bond and vlans have ips assigned
and we have their peers monitored via arp_ip_target - in case of switch
misconfiguration (trunk/access port), slave driver malfunction or
tagged/untagged traffic dropped on the way - we will be able to switch
to another slave.
Though any other configuration needs that if we need to have access to all
arp_ip_targets.
This patch adds this possibility by adding a new parameter -
arp_all_targets (both as a module parameter and as a sysfs knob). It can be
set to:
0 or any (the default) - which works exactly as it's working now -
the slave is up if any of the arp_ip_targets are up.
1 or all - the slave is up if all of the arp_ip_targets are up.
This parameter can be changed on the fly (via sysfs), and requires the mode
to be active-backup and arp_validate to be enabled (it obeys the
arp_validate config on which slaves to validate).
Internally it's done through:
1) Add target_last_arp_rx[BOND_MAX_ARP_TARGETS] array to slave struct. It's
an array of jiffies, meaning that slave->target_last_arp_rx[i] is the
last time we've received arp from bond->params.arp_targets[i] on this
slave.
2) If we successfully validate an arp from bond->params.arp_targets[i] in
bond_validate_arp() - update the slave->target_last_arp_rx[i] with the
current jiffies value.
3) When getting slave's last_rx via slave_last_rx(), we return the oldest
time when we've received an arp from any address in
bond->params.arp_targets[].
If the value of arp_all_targets == 0 - we still work the same way as
before.
Also, update the documentation to reflect the new parameter.
v3->v4:
Kill the forgotten rtnl_unlock(), rephrase the documentation part to be
more clear, don't fail setting arp_all_targets if arp_validate is not set -
it has no effect anyway but can be easier to set up. Also, print a warning
if the last arp_ip_target is removed while the arp_interval is on, but not
the arp_validate.
v2->v3:
Use _bh spinlock, remove useless rtnl_lock() and use jiffies for new
arp_ip_target last arp, instead of slave_last_rx(). On bond_enslave(),
use the same initialization value for target_last_arp_rx[] as is used
for the default last_arp_rx, to avoid useless interface flaps.
Also, instead of failing to remove the last arp_ip_target just print a
warning - otherwise it might break existing scripts.
v1->v2:
Correctly handle adding/removing hosts in arp_ip_target - we need to
shift/initialize all slave's target_last_arp_rx. Also, don't fail module
loading on arp_all_targets misconfiguration, just disable it, and some
minor style fixes.
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2013-06-24 13:49:34 +04:00
extern const struct bond_parm_tbl arp_all_targets_tbl [ ] ;
2008-12-10 10:10:38 +03:00
extern const struct bond_parm_tbl fail_over_mac_tbl [ ] ;
2009-09-25 07:28:09 +04:00
extern const struct bond_parm_tbl pri_reselect_tbl [ ] ;
2008-12-26 10:58:57 +03:00
extern struct bond_parm_tbl ad_select_tbl [ ] ;
2013-10-18 19:43:33 +04:00
/* exported from bond_netlink.c */
extern struct rtnl_link_ops bond_link_ops ;
2014-10-31 21:47:54 +03:00
static inline void bond_tx_drop ( struct net_device * dev , struct sk_buff * skb )
{
atomic_long_inc ( & dev - > tx_dropped ) ;
dev_kfree_skb_any ( skb ) ;
}
2014-11-10 21:27:49 +03:00
# endif /* _NET_BONDING_H */