Fri, Oct 20, 2017 at 06:35:07AM CEST, lucien.xin@gmail.com wrote:
This patch to fix an events processing race issue when adding two ports into one team dev with ab mode with same_all hwaddr policy:
team0 original hwaddr: 00:00:00:00:00:0a port1 original hwaddr: 00:00:00:00:00:01 port2 original hwaddr: 00:00:00:00:00:02
There are two sockets in teamd: nl_cli.sock_event for ifinfo updates and nl_sock_event for ports/options changes. During adding two ports, the events on these two sockets could be:
nl_sock_event: [1] -- [2] --
[1]: port1 added event (added by enslaving port1) [2]: port2 added event (added by enslaving port2)
nl_cli.sock_event: [a1] -- [b0] -- [c1] -- [d2] -- [e2] -- [f1] --
[a1]: port1 ifinfo event (added by setting port1's master) [b0]: team0 ifinfo event (added by setting team0's hwaddr) [c1]: port1 ifinfo event (added by set port1's hwaddr) [d2]: port2 ifinfo event (added by set port2's master) [e2]: port2 ifinfo event (added by set port2's hwaddr) [f1]: port1 ifinfo event (added by set port1's hwaddr)
teamd can make sure the order for their processing is as above on the same socket, but not between two sockets. So if these events processing order is (monitoring team/ports' ifinfo, hwaddr, master):
[ 1]: team0->ifinfo = 00:00:00:00:00:0a team0->hwaddr = 00:00:00:00:00:01 port1->hwaddr = 00:00:00:00:00:0a [a1]: port1->ifinfo = 00:00:00:00:00:01 port1->master = team0 [ 2]: port2->ifinfo = 00:00:00:00:00:02 port2->hwaddr = 00:00:00:00:00:0a (team0->ifinfo is not updated, it's still 00:00:00:00:00:0a) [b0]: team0->ifinfo = 00:00:00:00:00:01 port1->hwaddr = 00:00:00:00:00:01 (port2->master is not yet set, port2->hwaddr couldn't be updated) [c1]: no changes [d2]: port2->ifinfo = 00:00:00:00:00:0a port2->master = team0 (too late !!!) [e2]: no changes [f1]: no changes
Then: team0 final hwaddr: 00:00:00:00:00:01 port1 final hwaddr: 00:00:00:00:00:01 port2 final hwaddr: 00:00:00:00:00:0a <----- issue
This patch is to add port_hwaddr_changed for ab runner, in [e2] where we set it's hwaddr with team0 (port2->hwaddr = 00:00:00:00:00:01) IF port2->hwaddr != team0->ifinfo.
I think the same issue also exists in lacp and lb mode for which I will fix them in another patches.
v1 -> v2: fix some typos in changelog and couple of style problems in codes
Reported-by: Jon Nikolakakis jnikolak@redhat.com Signed-off-by: Xin Long lucien.xin@gmail.com
Applied, thanks!