Skip to content

Commit 6d8c0da

Browse files
committed
testenv: Don't read interface MAC addresses until we need them
There is a slight delay after the interface is created where the MAC address can change. This will lead to the wrong neighbour entry being installed, so defer reading the MAC address until just before we need it. This seems to be enough to avoid the race. Fixes #159 (again). Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
1 parent f7a0a14 commit 6d8c0da

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

testenv/testenv.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,12 @@ setup()
240240
ip netns add "$NS"
241241
ip link add dev "$NS" type veth peer name veth0 netns "$NS"
242242

243-
OUTSIDE_MAC=$(iface_macaddr "$NS")
244-
INSIDE_MAC=$(iface_macaddr veth0 "$NS")
245-
246243
set_sysctls $NS
247244
ip link set dev "$NS" up
248245
ip addr add dev "$NS" "${OUTSIDE_IP6}/${IP6_PREFIX_SIZE}"
249246
ethtool -K "$NS" rxvlan off txvlan off
250247
# Prevent neighbour queries on the link
248+
INSIDE_MAC=$(iface_macaddr veth0 "$NS")
251249
ip neigh add "$INSIDE_IP6" lladdr "$INSIDE_MAC" dev "$NS" nud permanent
252250

253251
set_sysctls veth0 "$NS"
@@ -256,6 +254,7 @@ setup()
256254
ip -n "$NS" addr add dev veth0 "${INSIDE_IP6}/${IP6_PREFIX_SIZE}"
257255
ip netns exec "$NS" ethtool -K veth0 rxvlan off txvlan off
258256
# Prevent neighbour queries on the link
257+
OUTSIDE_MAC=$(iface_macaddr "$NS")
259258
ip -n "$NS" neigh add "$OUTSIDE_IP6" lladdr "$OUTSIDE_MAC" dev veth0 nud permanent
260259
# Add route for whole test subnet, to make it easier to communicate between
261260
# namespaces

0 commit comments

Comments
 (0)