Skip to content

Commit f7a0a14

Browse files
committed
testenv: wait for interface addresses to settle during setup
When configuring IPv6 addresses on an interface, they can be marked as "tentative" until duplicate address detection (DAD) settles, which means ping won't work. We try to turn off DAD, but that doesn't always work either, depending on the global settings on the host; so add an explicit wait after interface config. Fixes #159. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
1 parent ffb8264 commit f7a0a14

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

testenv/testenv.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,21 @@ set_sysctls()
188188
done
189189
}
190190

191+
wait_for_dev()
192+
{
193+
local iface="$1"
194+
local in_ns="${2:-}"
195+
local retries=5 # max retries
196+
local nscmd=
197+
198+
[ -n "$in_ns" ] && nscmd="ip netns exec $in_ns"
199+
while [ "$retries" -gt "0" ]; do
200+
if ! $nscmd ip addr show dev $iface | grep -q tentative; then return 0; fi
201+
sleep 0.5
202+
retries=$((retries -1))
203+
done
204+
}
205+
191206
get_vlan_prefix()
192207
{
193208
# Split the IPv6 prefix, and add the VLAN ID to the upper byte of the fourth
@@ -285,7 +300,10 @@ setup()
285300

286301
echo -n "Setup environment '$NS' with peer ip ${INSIDE_IP6}"
287302
[ "$ENABLE_IPV4" -eq "1" ] && echo " and ${INSIDE_IP4}." || echo "."
303+
echo "Waiting for interface configuration to settle..."
288304
echo ""
305+
wait_for_dev "$NS" && wait_for_dev veth0 "$NS"
306+
289307
LEGACY_IP=0 USE_VLAN=0 run_ping -c 1
290308

291309
echo "$NS" > "$STATEDIR/current"

0 commit comments

Comments
 (0)