linux/drivers/net/bonding
Nithin Sujir 797a93647a bonding: Don't update slave->link until ready to commit
In the loadbalance arp monitoring scheme, when a slave link change is
detected, the slave->link is immediately updated and slave_state_changed
is set. Later down the function, the rtnl_lock is acquired and the
changes are committed, updating the bond link state.

However, the acquisition of the rtnl_lock can fail. The next time the
monitor runs, since slave->link is already updated, it determines that
link is unchanged. This results in the bond link state permanently out
of sync with the slave link.

This patch modifies bond_loadbalance_arp_mon() to handle link changes
identical to bond_ab_arp_{inspect/commit}(). The new link state is
maintained in slave->new_link until we're ready to commit at which point
it's copied into slave->link.

NOTE: miimon_{inspect/commit}() has a more complex state machine
requiring the use of the bond_{propose,commit}_link_state() functions
which maintains the intermediate state in slave->link_new_state. The arp
monitors don't require that.

Testing: This bug is very easy to reproduce with the following steps.
1. In a loop, toggle a slave link of a bond slave interface.
2. In a separate loop, do ifconfig up/down of an unrelated interface to
create contention for rtnl_lock.
Within a few iterations, the bond link goes out of sync with the slave
link.

Signed-off-by: Nithin Nayak Sujir <nsujir@tintri.com>
Cc: Mahesh Bandewar <maheshb@google.com>
Cc: Jay Vosburgh <jay.vosburgh@canonical.com>
Acked-by: Mahesh Bandewar <maheshb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2017-05-25 14:47:35 -04:00
..
bond_3ad.c bonding: fix accounting of active ports in 3ad 2017-05-22 12:05:39 -04:00
bond_alb.c bonding: attempt to better support longer hw addresses 2017-04-05 18:44:54 -07:00
bond_debugfs.c net: Move bonding headers under include/net 2014-11-10 13:27:49 -05:00
bond_main.c bonding: Don't update slave->link until ready to commit 2017-05-25 14:47:35 -04:00
bond_netlink.c bonding: check nla_put_be32 return value 2017-05-08 14:57:05 -04:00
bond_options.c sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h> 2017-03-02 08:42:32 +01:00
bond_procfs.c bonding: attempt to better support longer hw addresses 2017-04-05 18:44:54 -07:00
bond_sysfs_slave.c bonding: export slave's partner_oper_port_state via sysfs and netlink 2015-06-15 16:40:24 -07:00
bond_sysfs.c sched/headers: Prepare to move signal wakeup & sigpending methods from <linux/sched.h> into <linux/sched/signal.h> 2017-03-02 08:42:32 +01:00
bonding_priv.h net/bonding: Make DRV macros private 2015-04-26 22:59:53 -04:00
Makefile bonding: add sysfs /slave dir for bond slave devices. 2014-01-17 18:51:58 -08:00