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=202412 header.b=I38wTQRo; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id EE84F5A0272 for ; Fri, 24 Jan 2025 02:48:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202412; t=1737683304; bh=Rzl6/c1/b12AaG98hSV2DFbjyvMXA45QTZdeXUKuIA4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=I38wTQRoClFqjeVXzeA9jDdkqK7JVfVynATkfhI4K1ujiyJbHSnWYnNiIM3+Z84kB GjryY9mejnSalXY9fa4dfCDxCW4ipGLMNHomz0eSJXVkW5KVC5emqyfJJjabmBaaUQ p3XgU0BNC4Pe3zyp/uioKux4mW/5fMB1eacSL+eXX5hebtiKeV3z1ihdFmdginrAXH ah7aCadO6Ntcld5MvlWKJbv6JLBQPdlcS0JZLHhpG9OX5S912inbJmkwaBh9REq/5l bdRT344D8/Q2MltRZKmnE9+XQjX+zSTTrWy6EcBhx6bH6f5USJKq3gBAFn+IAn3v2X 8f95f3Gvb/z7Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4YfLLc62Swz4wj1; Fri, 24 Jan 2025 12:48:24 +1100 (AEDT) Date: Fri, 24 Jan 2025 12:48:24 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] netlink: Skip loopback interface while looking for a template Message-ID: References: <20250123080548.1410738-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="EZRt44pTzVZau+MM" Content-Disposition: inline In-Reply-To: <20250123080548.1410738-1-sbrivio@redhat.com> Message-ID-Hash: BJH2OIPVO3NYZUQ4Y75MCARP2DTHYFQD X-Message-ID-Hash: BJH2OIPVO3NYZUQ4Y75MCARP2DTHYFQD 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: --EZRt44pTzVZau+MM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jan 23, 2025 at 09:05:48AM +0100, Stefano Brivio wrote: > There might be reasons to have routes on the loopback interface, for > example Any-IP/AnyIP routes as implemented by Linux kernel commit > ab79ad14a2d5 ("ipv6: Implement Any-IP support for IPv6."). >=20 > If we use the loopback interface as a template, though, we'll pick > 'lo' (typically) as interface name for our tap interface, but we'll > already have an interface called 'lo' in the target namespace, and as > we TUNSETIFF on it, we'll fail with EINVAL, because it's not a tap > interface. >=20 > Skip the loopback interface while looking for a template interface or, > more accurately, skip the interface with index 1. >=20 > Strictly speaking, we should fetch interface flags via RTM_GETLINK > instead, and check for IFF_LOOPBACK, but interleaving that request > while we're iterating over routes is unnecessarily complicated. >=20 > Link: https://www.reddit.com/r/podman/comments/1i6pj7u/starting_pod_witho= ut_external_network/ > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > netlink.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/netlink.c b/netlink.c > index 0407692..37d8b5b 100644 > --- a/netlink.c > +++ b/netlink.c > @@ -297,6 +297,10 @@ unsigned int nl_get_ext_if(int s, sa_family_t af) > if (!thisifi) > continue; /* No interface for this route */ > =20 > + /* Skip 'lo': we should test IFF_LOOPBACK, but keep it simple */ > + if (thisifi =3D=3D 1) > + continue; > + > /* Skip routes to link-local addresses */ > if (af =3D=3D AF_INET && dst && > IN4_IS_PREFIX_LINKLOCAL(dst, rtm->rtm_dst_len)) --=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 --EZRt44pTzVZau+MM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmeS8WQACgkQzQJF27ox 2GeVNg//VcCIzWO5SaElSMnIxfbD/Fm4PmHhGpYvsZz7Lct24w12Bv6QIcLvUJcT He/Sa1TakMENTWrSq2510R9Z/nunz7iUWcwi1xEdAQ0rkyWrTRTQWR2rz1rwrIPq Q471WzsliW4Pr8GZBm2+CmIsXfxGIq9eT8nOm2CC/1srgDqWnR+Ujw6aVPzRSd94 Mv9NmoGfhVJtliRuzTyhIqm+pMf8JiCgKs3f0cJBWemp4KZwPk4aYiWYc/3g2ocd 5C4Oc93nAQohL5XhI5vOv1t2takomUvckz0F2cS90EoAkib+hkPZpXWowrzp/KOk tZg2L8+NQYOQNWcCh3BmLMmsteNalUVyBEuYDAw9w8bihZ5RdFwqPRMOKLFlJbVx wNgonlsw7/apKPxtaHAIcIq32Y1B4ixlVyMT7bxzbnxsN8Lc7jzkK6x1I8SFbGFa o8v3FuJlyNWMXctE8n5AZ+FGd4XSehsUwGyx9qtD1Fsw3jVNa4ZX49ai8Rwjt5Oz RjoehwSS+vOHSvJhzlZnEcvs5/c0uIEO8Yv9afQJcPDi9nzeNJzGyGgKY+lrufL3 dtar8SaXlm6uMZmZuP2ykKy0Yswx4rHmLzy5YInDJNrsTNb68EihG/efwVUvpYJe RiicsE8a1Izi67QpFoTvIiER8CpMrDyaiCQDRoTjhJcyz//FgI0= =yC1A -----END PGP SIGNATURE----- --EZRt44pTzVZau+MM--