From e08a4e085d71397fa7c4bf5700054b65f617a78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= Date: Tue, 6 Oct 2020 17:13:44 +0200 Subject: [PATCH] lib/testenv: Don't get iface MAC address before we need it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Resolves a race condition where the MAC can change Signed-off-by: Toke Høiland-Jørgensen --- lib/testenv/testenv.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/testenv/testenv.sh b/lib/testenv/testenv.sh index af886dd..95c4d06 100755 --- a/lib/testenv/testenv.sh +++ b/lib/testenv/testenv.sh @@ -238,14 +238,12 @@ setup() ip netns add "$NS" ip link add dev "$NS" type veth peer name veth0 netns "$NS" - OUTSIDE_MAC=$(iface_macaddr "$NS") - INSIDE_MAC=$(iface_macaddr veth0 "$NS") - set_sysctls $NS ip link set dev "$NS" up ip addr add dev "$NS" "${OUTSIDE_IP6}/${IP6_PREFIX_SIZE}" ethtool -K "$NS" rxvlan off txvlan off # Prevent neighbour queries on the link + INSIDE_MAC=$(iface_macaddr veth0 "$NS") ip neigh add "$INSIDE_IP6" lladdr "$INSIDE_MAC" dev "$NS" nud permanent set_sysctls veth0 "$NS" @@ -254,6 +252,7 @@ setup() ip -n "$NS" addr add dev veth0 "${INSIDE_IP6}/${IP6_PREFIX_SIZE}" ip netns exec "$NS" ethtool -K veth0 rxvlan off txvlan off # Prevent neighbour queries on the link + OUTSIDE_MAC=$(iface_macaddr "$NS") ip -n "$NS" neigh add "$OUTSIDE_IP6" lladdr "$OUTSIDE_MAC" dev veth0 nud permanent # Add route for whole test subnet, to make it easier to communicate between # namespaces