From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 93E845A026D for ; Tue, 12 Dec 2023 00:06:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1702335984; bh=V+IDhhfunsb2W3DGhiCHPNPZXkQPxe3OloihCzcxx5k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IY6/4Myml1cJW1oZq9cgSD2IoPmZHqRyLWXhoaIr0eTfDuMnhBsMRsiS+hrgVN1qR 0XotS0laJro4KC/v74JKPO4iP+2+luAJb4us+CTjQi9+HmYhfM+PKJCNXvd+D1hj97 N+Pslxhwn1jdCuMJErbqTDPz+Uo+iAI7dOvRhpj8kDtWKnX3kvGGxAeeDTpRXi+ty/ wMGuXJwkNhWqiI0zSNHfhmJBpWOP/CJ2URK3npjSa5hydBrnZ4fMDEsHnrFTe52wb/ TuMpWL5Liu3up4L725iV6vCUCxJUCojbtSZnpG5BwEOKPXp9rYxIqsQR3PCTVl7eGy PE+NAI86KyJ2A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Spy6S06fDz4xNH; Tue, 12 Dec 2023 10:06:24 +1100 (AEDT) Date: Tue, 12 Dec 2023 09:28:08 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] test: Select first reported IPv6 address for guest/host comparison Message-ID: References: <20231208174932.3390897-1-sbrivio@redhat.com> <20231211100058.45a546b2@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="VvaqTVNBYFA9gLhW" Content-Disposition: inline In-Reply-To: <20231211100058.45a546b2@elisabeth> Message-ID-Hash: 2SSVWTUS6TS5APZCFDTAVYBMMZB3D2WQ X-Message-ID-Hash: 2SSVWTUS6TS5APZCFDTAVYBMMZB3D2WQ 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: passt-dev@passt.top, Jon Maloy 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: --VvaqTVNBYFA9gLhW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Dec 11, 2023 at 10:00:58AM +0100, Stefano Brivio wrote: > On Mon, 11 Dec 2023 13:05:20 +1100 > David Gibson wrote: >=20 > > On Fri, Dec 08, 2023 at 06:49:32PM +0100, Stefano Brivio wrote: > > > If we run passt nested (a guest connected via passt to a guest > > > connected via passt to the host), the first guest (L1) typically has > > > two IPv6 addresses: one formed from the prefix assigned via SLAAC, > > > and another one assigned via DHCPv6 (to match the address on the > > > host). =20 > >=20 > > Hmm... it can't be just that there are multible IPv6 addresses here > > that's the problem. I usually have multiple IPv6 unicast addresses on > > my laptop (one for the wifi, one for wired) and I already got that > > working. > >=20 > > Possibly it's that there are multiple addresses on the same interface? >=20 > Yes, the guest has a single interface and multiple addresses for it, > I'll change the commit message. >=20 > > But see below.. > >=20 > > > When we select addresses for comparison, in this case, we have > > > multiple global unicast addresses. Selecting the first reported one > > > on both host and guest is not entirely correct (in theory, the order > > > might differ), but works reasonably well. =20 > >=20 > > That approach seems good, in principle > >=20 > > > Use the trick from 5beef085978e ("test: Only select a single > > > interface or gateway in tests") to ask jq(1) for the first address > > > returned by the query. =20 > >=20 > > But that patch was selecting gateways, not local addresses, so I don't > > think the same syntax makes sense. > >=20 > > >=20 > > > Signed-off-by: Stefano Brivio > > > --- > > > test/passt/dhcp | 8 ++++---- > > > test/passt/ndp | 4 ++-- > > > test/pasta/dhcp | 8 ++++---- > > > test/pasta/ndp | 4 ++-- > > > test/two_guests/basic | 6 +++--- > > > 5 files changed, 15 insertions(+), 15 deletions(-) > > >=20 > > > diff --git a/test/passt/dhcp b/test/passt/dhcp > > > index 7272755..b428064 100644 > > > --- a/test/passt/dhcp > > > +++ b/test/passt/dhcp > > > @@ -22,8 +22,8 @@ check [ -n "__IFNAME__" ] > > > =20 > > > test DHCP: address > > > guest /sbin/dhclient -4 __IFNAME__ > > > -gout ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname =3D=3D "__= IFNAME__").addr_info[0].local' > > > -hout HOST_ADDR ip -j -4 addr show|jq -rM '.[] | select(.ifname =3D= =3D "__HOST_IFNAME__").addr_info[0].local' > > > +gout ADDR ip -j -4 addr show|jq -rM '[.[] | select(.ifname =3D=3D "_= _IFNAME__").addr_info[0].local] | .[0]' > > > +hout HOST_ADDR ip -j -4 addr show|jq -rM '[.[] | select(.ifname =3D= =3D "__HOST_IFNAME__").addr_info[0].local] | .[0]' =20 > >=20 > > I'm confused by this. The 'addr_info[0]' should already be selecting > > the first address from each interface, so the outer '.[0]' would only > > be doing something if multiple interfaces are selected, and I'm not > > quite sure why that would happen. > >=20 > > In fact, I suspect this one was right all along...=20 >=20 > Right, this doesn't make sense, I just went too far with the copy and > paste. Same as for the pasta/dhcp change below. There are actually no > issues with IPv4. I'll drop those. >=20 > > > check [ "__ADDR__" =3D "__HOST_ADDR__" ] > > > =20 > > > test DHCP: route > > > @@ -49,8 +49,8 @@ check [ "__SEARCH__" =3D "__HOST_SEARCH__" ] > > > =20 > > > test DHCPv6: address > > > guest /sbin/dhclient -6 __IFNAME__ > > > -gout ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname =3D=3D "_= _IFNAME__").addr_info[] | select(.prefixlen =3D=3D 128).local' > > > -hout HOST_ADDR6 ip -j -6 addr show|jq -rM '.[] | select(.ifname =3D= =3D "__HOST_IFNAME6__").addr_info[] | select(.scope =3D=3D "global").local' > > > +gout ADDR6 ip -j -6 addr show|jq -rM '[.[] | select(.ifname =3D=3D "= __IFNAME__").addr_info[] | select(.prefixlen =3D=3D 128).local] | .[0]' > > > +hout HOST_ADDR6 ip -j -6 addr show|jq -rM '[.[] | select(.ifname =3D= =3D > > > "__HOST_IFNAME6__").addr_info[] | select(.scope =3D=3D "global").loc= al] > > > | .[0]' =20 > >=20 > > ... but this one isn't, because it is .addr_info[]. Previously the > > second 'select' has picked out only one, but not in this situation. > > So here the change makes sense to me. >=20 > Here we want to use .addr_info[] because we want to filter further on > prefixlen or scope. But once we've done that, if we have two addresses, > we have to pick one. Yes, exactly. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --VvaqTVNBYFA9gLhW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmV3jMwACgkQzQJF27ox 2GfHUhAAifPKxPP9C3KA77iQfBQRmfsag1lsd/ad6CiNJN8bs4WlnlzooAy1Wu+I 2pT7SwDohHcSYCvwzLW7LgQfLOj+NR7rkieQ+uSnOUnYDBKo+D42dumtHgobqLwq nPGmjsrb9a0165I8HlsaSOq5wK0t6HV0i9tfF3Z8X58TTXxn0VDorBhlh/pTWh0z +YzeeMx7xoxVvjxxek+2J38ercc7BVd8KOc2YM6PZfGIVsWLWzuofzwD+wvcs3id mA/Eg4pvPXE3+8hxr7lwxJeKtC1iU1eCotU+TK38uQl4Djr/pCbEDjMozlACYJoE Uak4L+NDKkOMZxcZGOuZEi0xHQ2fUjQoPwGdohj/wFpcffeNA+1VhKNAmBBm5mc3 Z7MZr/+Xb2G64PxvDeFr2qnkX69f2g3famyh08lQN/OrB4OPDJT/lncOtGhP3q4B eZpMd8XB3dXdXFADA33KH3SANXy/mMgU2xo8j0bE3DbKfI251dxkAlTZw3DVuueO 3bqThGpfSCyb9Zy/DJ00v7NJZr2/UGTp7WC+s+Idyov03zg8Hxp557DSqrSB9wB3 5DhDScIHzJvAcKhH7tdndl1mAMb0sO4XLBG2lmsO2u8MxXbQqghdnGwe379aKrhg ikecpP+Wc11GLqsvbYVpCkluaVlp92i5DIbW6emkeGIMPox45L4= =Ep0f -----END PGP SIGNATURE----- --VvaqTVNBYFA9gLhW--