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=202510 header.b=MhSQuATQ; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id A69F25A061A for ; Fri, 05 Dec 2025 04:09:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202510; t=1764904182; bh=qzaa3J9Tl7ij+2kF9GvBtvRlN7WG32orky9ugi/Cih8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MhSQuATQv7evKlAtjDT3QhtCvJAM6jhLi5xJzatghS6sncm+BvHe4LQ8G1MtojECS lTJA0LsNv4TEVpbdYcmvi1PN/+vCl8/1VrvgYhazL/7zcTphMoppcyEhz+2lhpV+Si IA6rlkx9PVEVTwBPB67DerHVteA4v3okqYUjlzj0SyEHFwsQh8zn6AixJNhwf9tAuu 2t4Bcxq7nKWMqH5aU1fF4EUVqHeoL5A4u+CGPYY/Y7WOZbV1z7SadXQIMKVTuwyX4E cMTmPOj2uWDNRFS1SzszV5Ak4OlyfEG5w8VlcOnmue59LH9lZ3iLone8PAiSWIkViw LaFoLwfQ/cD5w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dMxF20CYSz4wHY; Fri, 05 Dec 2025 14:09:42 +1100 (AEDT) Date: Fri, 5 Dec 2025 14:01:15 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] conf: Separate local mode for each IP version, don't enable disabled IP version Message-ID: References: <20251205005126.2577347-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="+Z/e3GQJHGie78y/" Content-Disposition: inline In-Reply-To: <20251205005126.2577347-1-sbrivio@redhat.com> Message-ID-Hash: UZUYLC6B7IKJ65LVPUSMSRNC6NKXRLBN X-Message-ID-Hash: UZUYLC6B7IKJ65LVPUSMSRNC6NKXRLBN 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 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: --+Z/e3GQJHGie78y/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Dec 05, 2025 at 01:51:26AM +0100, Stefano Brivio wrote: > This fixes an issue and introduces a feature: >=20 > - in local mode, we accidentally ignored the -4 / --ipv4-only and > -6 / --ipv6-only command line options >=20 > - if no template interface is available for a given IP version, > instead of disabling that IP version, use local mode, separately, > for it >=20 > Link: https://bugs.passt.top/show_bug.cgi?id=3D129 > Link: https://bugs.passt.top/show_bug.cgi?id=3D128 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > conf.c | 19 +++++++++++-------- > passt.1 | 15 ++++++++------- > 2 files changed, 19 insertions(+), 15 deletions(-) >=20 > diff --git a/conf.c b/conf.c > index 02a4b65..fdc19e8 100644 > --- a/conf.c > +++ b/conf.c > @@ -1109,7 +1109,7 @@ static void conf_print(const struct ctx *c) > info("Template interface: %s%s%s%s%s", > c->ifi4 > 0 ? if_indextoname(c->ifi4, ifn) : "", > c->ifi4 > 0 ? " (IPv4)" : "", > - (c->ifi4 && c->ifi6) ? ", " : "", > + (c->ifi4 > 0 && c->ifi6 > 0) ? ", " : "", > c->ifi6 > 0 ? if_indextoname(c->ifi6, ifn) : "", > c->ifi6 > 0 ? " (IPv6)" : ""); > } > @@ -2001,20 +2001,23 @@ void conf(struct ctx *c, int argc, char **argv) > (*c->ip6.ifname_out && !c->ifi6)) > die("External interface not usable"); > =20 > + if (!c->ifi4 && !c->ifi6 && !*c->pasta_ifn) { > + strncpy(c->pasta_ifn, pasta_default_ifn, > + sizeof(c->pasta_ifn) - 1); > + } > =20 > - if (!c->ifi4 && !c->ifi6) { > - info("No external interface as template, switch to local mode"); > + if (!c->ifi4 && !v6_only) { > + info("IPv4: no external interface as template, use local mode"); > =20 > conf_ip4_local(&c->ip4); > c->ifi4 =3D -1; > + } > + > + if (!c->ifi6 && !v4_only) { > + info("IPv6: no external interface as template, use local mode"); > =20 > conf_ip6_local(&c->ip6); > c->ifi6 =3D -1; > - > - if (!*c->pasta_ifn) { > - strncpy(c->pasta_ifn, pasta_default_ifn, > - sizeof(c->pasta_ifn) - 1); > - } > } > =20 > if (c->ifi4 && !no_map_gw && > diff --git a/passt.1 b/passt.1 > index 0c17454..db0d662 100644 > --- a/passt.1 > +++ b/passt.1 > @@ -166,8 +166,8 @@ By default, assigned IPv4 and IPv6 addresses are take= n from the host interfaces > with the first default route, if any, for the corresponding IP version. = If no > default routes are available and there is any interface with any route f= or a > given IP version, the first of these interfaces will be chosen instead. = If no > -such interface exists, the link-local address 169.254.2.1 is assigned fo= r IPv4, > -and no additional address will be assigned for IPv6. > +such interface exists for a given IP version, the link-local address 169= =2E254.2.1 > +is assigned for IPv4, and no additional address will be assigned for IPv= 6. > =20 > .TP > .BR \-n ", " \-\-netmask " " \fImask > @@ -194,9 +194,9 @@ first default route, if any, for the corresponding IP= version. If the default > route is a multipath one, the gateway is the first nexthop router return= ed by > the kernel which has the highest weight in the set of paths. If no defau= lt > routes are available and there is just one interface with any route, that > -interface will be chosen instead. If no such interface exists, the link-= local > -address 169.254.2.2 is used for IPv4, and the link-local address fe80::1= is used > -for IPv6. > +interface will be chosen instead. If no such interface exists for a give= n IP > +version, the link-local address 169.254.2.2 is used for IPv4, and the li= nk-local > +address fe80::1 is used for IPv6. > =20 > Note: these addresses are also used as source address for packets direct= ed to > the guest or to the target namespace having a loopback or local source a= ddress, > @@ -1117,8 +1117,9 @@ throughput of TCP connections. > .SS Local mode for disconnected setups > =20 > If \fBpasst\fR and \fBpasta\fR fail to find a host interface with a conf= igured > -address, other than loopback addresses, they will, obviously, not attemp= t to > -source addresses or routes from the host. > +address for a given IP version, other than loopback addresses, they will, > +obviously, not attempt to source addresses or routes from the host, for = that > +IP version. > =20 > In this case, unless configured otherwise, they will assign the IPv4 lin= k-local > address 169.254.2.1 to the guest or target namespace, and no IPv6 addres= s. The > --=20 > 2.43.0 >=20 --=20 David Gibson (he or they) | 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 --+Z/e3GQJHGie78y/ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmkySvoACgkQzQJF27ox 2Gejhw//QV+e2rspC8+uzhiYUY4TaGqD5p2PcIYYtNwDqY6hKC9vKCbs4W4s2rxj FIyQZjPJIDrtwoKRFwANhirTl3ca4ENTQrMoWyIWrv9kMImodTrfPZHfwDlgNSB2 UkaUa4wpLVxmrVqpSwn6krUCCUJG/VSzRlOxUU7HXzrCzqnS1byIzD96QKIOk+zr F6p0bzUHlHziZ7dCeeEcWLazFSevuduuJL3H2nf4UQrs+pk9ug7HyKszrzoi4UWU G5OqP54KNNJZ6D3Xw8XkueytNr3yBxjSz342eLhIkVzKlim+hdqFJmZyxAKSv1pp uSMSucwyU32yUJKlfF1tq66iwOtiZiN0W9SVVl2Nwe/K3pYHer7YzVvqOCOjQ6gR RvpHEM5wkNGNRl8RPvUdrnK0EoI1g4PLE8QicfKapqIxNXI/3hIrqO0+QOJ5Z23f UV9KbOl1bTlFFnKeauXUadWtDt4QwCP8LF74eYA1e9YFk+1PLJS5q4+WLK3wxmCD r58/akgLHABUM80wIlXba4jBaqzOQY732K1uPKlyiIuHC+xqXJGSNSMhIaEW7gB2 zSBjGxrngrnvxIJeTbRHJudHiIS1idjMkY8JsT7L+rpMpT8TqdGMBzF+3svvzCqZ PEZNsAWdCmQIf4yl1X9qryzfNEnglaPEYkIKLgccyNhp9Vp93OI= =+EI1 -----END PGP SIGNATURE----- --+Z/e3GQJHGie78y/--