From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202410 header.b=aKJEqM1B; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id DC9FF5A026E for ; Fri, 18 Oct 2024 03:36:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1729215357; bh=JkYu3coJ7zrtjVJHQVDFpRebI+z4LRuyl6ompUIF9p0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aKJEqM1BmYdVyfbTIPMYYQJOnjRmCYLBAHQ9uVBVwWbO73OhA8yr54tNJKvhWtTB7 S12feWsnYUS/0c3y4NolKPgLm1S3QBLFI/8yelxuXjXTCwtTkug5ybrfb3kdykNL/y Xe2vsWJQOcR2AIe7K4xpn8yu0MuBSCsgYmlHwcTY3Dl4byhQgFeUYrRAqANS5Vl4Ot l1Kjk4HKuTlOsoCy87dOiN7XQBfFioxBQWWuWSGsll8mj6jugGCh0OM8Iy0Ac76W/q EH5zPgIOeKZ/gMpGmmQvaa2xWFj2DhEnWZwzfR1+/j8Z/2DrsEGq3HrTZA/+btvJGA CHgOPIXR/29XQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4XV6jT1kLrz4wnr; Fri, 18 Oct 2024 12:35:57 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v5 2/7] test: Explicitly wait for DAD to complete on SLAAC addresses Date: Fri, 18 Oct 2024 12:35:51 +1100 Message-ID: <20241018013556.1266295-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241018013556.1266295-1-david@gibson.dropbear.id.au> References: <20241018013556.1266295-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: FPVM64LHM62FMLHDOHCY56XC6VEU4MT3 X-Message-ID-Hash: FPVM64LHM62FMLHDOHCY56XC6VEU4MT3 X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 --- test/passt/ndp | 4 +++- test/pasta/ndp | 3 ++- test/two_guests/basic | 3 ++- 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]' -- 2.47.0