aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-10-18 12:35:51 +1100
committerStefano Brivio <sbrivio@redhat.com>2024-10-18 20:27:47 +0200
commit75b9c0feb0b54b040a8c49f160cfc2defe28c045 (patch)
treec68865fbe5db3cad75a933f0b550c715119e8530
parentf9d677bff6af48b50f3655224e8b0eb8820d3e89 (diff)
downloadpasst-75b9c0feb0b54b040a8c49f160cfc2defe28c045.tar
passt-75b9c0feb0b54b040a8c49f160cfc2defe28c045.tar.gz
passt-75b9c0feb0b54b040a8c49f160cfc2defe28c045.tar.bz2
passt-75b9c0feb0b54b040a8c49f160cfc2defe28c045.tar.lz
passt-75b9c0feb0b54b040a8c49f160cfc2defe28c045.tar.xz
passt-75b9c0feb0b54b040a8c49f160cfc2defe28c045.tar.zst
passt-75b9c0feb0b54b040a8c49f160cfc2defe28c045.zip
test: Explicitly wait for DAD to complete on SLAAC addresses
Getting a SLAAC address takes a little while because the kernel must complete Duplicate Address Detection (DAD) before marking the address as ready. In several places we have an explicit 'sleep 2' to wait for that to complete. Fixed length delays are never a great idea, although this one is pretty solid. Still, it would be better to explicitly wait for DAD to complete in case of long delays (which might happen on slow emulated hosts, or with heavy load), and to speed the tests up if DAD completes quicker. Replace the fixed sleeps with a loop waiting for DAD to complete. We do this by looping waiting for all tentative addresses to disappear. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--test/passt/ndp4
-rw-r--r--test/pasta/ndp3
-rw-r--r--test/two_guests/basic3
3 files changed, 7 insertions, 3 deletions
diff --git a/test/passt/ndp b/test/passt/ndp
index 6bf8af3..f54b8ce 100644
--- a/test/passt/ndp
+++ b/test/passt/ndp
@@ -16,7 +16,9 @@ htools ip jq sipcalc grep cut
test Interface name
gout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
-guest ip link set dev __IFNAME__ up && sleep 2
+guest ip link set dev __IFNAME__ up
+# Wait for DAD to complete
+guest while ip -j -6 addr show tentative | jq -e '.[].addr_info'; do sleep 0.1; done
hout HOST_IFNAME6 ip -j -6 route show|jq -rM '[.[] | select(.dst == "default").dev] | .[0]'
check [ -n "__IFNAME__" ]
diff --git a/test/pasta/ndp b/test/pasta/ndp
index d45ff7b..c59627f 100644
--- a/test/pasta/ndp
+++ b/test/pasta/ndp
@@ -18,7 +18,8 @@ test Interface name
nsout IFNAME ip -j link show | jq -rM '.[] | select(.link_type == "ether").ifname'
check [ -n "__IFNAME__" ]
ns ip link set dev __IFNAME__ up
-sleep 2
+# Wait for DAD to complete
+ns while ip -j -6 addr show tentative | jq -e '.[].addr_info'; do sleep 0.1; done
test SLAAC: prefix
nsout ADDR6 ip -j -6 addr show|jq -rM '[.[] | select(.ifname == "__IFNAME__").addr_info[] | select(.scope == "global" and .prefixlen == 64).local] | .[0]'
diff --git a/test/two_guests/basic b/test/two_guests/basic
index 4d49e85..ac50ff8 100644
--- a/test/two_guests/basic
+++ b/test/two_guests/basic
@@ -36,7 +36,8 @@ check [ "__ADDR2__" = "__HOST_ADDR__" ]
test DHCPv6: addresses
# Link is up now, wait for DAD to complete
-sleep 2
+guest1 while ip -j -6 addr show tentative | jq -e '.[].addr_info'; do sleep 0.1; done
+guest2 while ip -j -6 addr show tentative | jq -e '.[].addr_info'; do sleep 0.1; done
guest1 /sbin/dhclient -6 __IFNAME1__
guest2 /sbin/dhclient -6 __IFNAME2__
g1out ADDR1_6 ip -j -6 addr show|jq -rM '[.[] | select(.ifname == "__IFNAME1__").addr_info[] | select(.prefixlen == 128).local] | .[0]'