From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 9404D5A026E for ; Fri, 5 Apr 2024 06:59:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1712293144; bh=iFxEd9n+jkipB5aUA0Lrcg7xadzXuTfsVlUywdLPQTk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pSjMe8BvD5QnxEQu5R5E/jgKxYyIzmoCMpAlnJ2Qjvf33/aKy7n7eHE4mgWYn8p88 fQsNUcvE0TDfw0//G3bmRYVt72iliHXoqQ8JCagDRMSp5Cx0nEmCfRvYPOln7jAFd/ 9ewNTLKU66GEvwlgRHdYH0CrHF6+yN8rMAgpzTYP7+XqS1QfKEAw5h9MYsDsL4fNdn rwyJYag1ctZlLeqdeue1oHol5Vd+Sd99h8yhy9DvPU/ku1Pe51jCU+cAqUU/NvzPU7 855bs5Yb2FVk9/DLBqq/LMHTvdYwloVBax0707hum6cRcadvotR9/6Sb54EO/rkqKd iJ52lIrnvccDw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4V9mVJ3zTnz4wyp; Fri, 5 Apr 2024 15:59:04 +1100 (AEDT) Date: Fri, 5 Apr 2024 15:15:51 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2] netlink: Adjust interface index inside copied nexthop objects too Message-ID: References: <20240404163755.3243560-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="AKlHIld2X0LP/Qv0" Content-Disposition: inline In-Reply-To: <20240404163755.3243560-1-sbrivio@redhat.com> Message-ID-Hash: X75AESPYO55AIR3PZSPQ5U6VGI4724R6 X-Message-ID-Hash: X75AESPYO55AIR3PZSPQ5U6VGI4724R6 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: --AKlHIld2X0LP/Qv0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Apr 04, 2024 at 06:37:55PM +0200, Stefano Brivio wrote: > As pasta duplicates host routes into the target namespaces, interface > indices might not match, so we go through RTA_OIF attributes and fix > them up to match the identifier in the namespace. >=20 > But RTA_OIF is not the ony attribute specifying interfaces for routes: > multipath routes use RTA_MULTIPATH attributes with nexthop objects, > which contain in turn interface indices. Fix them up as well. >=20 > If we don't, and we have at least two host interfaces, and the host > interface we use as template isn't the first one (hence the > mismatching indices), we'll fail to insert multipath routes with > nexthop objects, and ultimately refuse to start as the kernel > unexpectedly gives us ENODEV. >=20 > Link: https://github.com/containers/podman/issues/22192 > Signed-off-by: Stefano Brivio > --- > v2: s/interfaces/interface/ in comment Reviewed-by: David Gibson >=20 > netlink.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) >=20 > diff --git a/netlink.c b/netlink.c > index 9b3dba2..59e9e33 100644 > --- a/netlink.c > +++ b/netlink.c > @@ -546,12 +546,19 @@ int nl_route_dup(int s_src, unsigned int ifi_src, > =20 > for (rta =3D RTM_RTA(rtm), na =3D RTM_PAYLOAD(nh); RTA_OK(rta, na); > rta =3D RTA_NEXT(rta, na)) { > + /* RTA_OIF and RTA_MULTIPATH attributes carry the > + * identifier of a host interface. Change them to match > + * the corresponding identifier in the target namespace. > + */ > if (rta->rta_type =3D=3D RTA_OIF) { > - /* The host obviously list's the host interface > - * id here, we need to change it to the > - * namespace's interface id > - */ > *(unsigned int *)RTA_DATA(rta) =3D ifi_dst; > + } else if (rta->rta_type =3D=3D RTA_MULTIPATH) { > + struct rtnexthop *rtnh; > + > + for (rtnh =3D (struct rtnexthop *)RTA_DATA(rta); > + RTNH_OK(rtnh, RTA_PAYLOAD(rta)); > + rtnh =3D RTNH_NEXT(rtnh)) > + rtnh->rtnh_ifindex =3D ifi_dst; > } else if (rta->rta_type =3D=3D RTA_PREFSRC) { > /* Host routes might include a preferred source > * address, which must be one of the host's --=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 --AKlHIld2X0LP/Qv0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmYPeuoACgkQzQJF27ox 2GcE8A/+O+jl/l5vQp2P/kF7vPqzpqankluahouj0B39Wk8Shmapzd6goOAYIJs5 bpTbMuTtftc6LzgSNXGZtH+AYA1Va3DHQGmu4U9/3lujzKSQ8J/NG5UxsEguygfJ Xq2rTrEC+i2RA+KJS1ThGYTIrCjhnuFP5C5SEl1NERC4W3R4azgpZOPGYyz7qj4o 3sMhQTxGx8myCfZ4ZNt8i2riM4ck18MUO3EG4nZLCAux3rrjpTU+d9CQhh5Z5wcJ v8qdUqfNYiGOdwudHRWVxtD4u4lKoUpYACwAW/uzseRzBUaGRKtihyHzbp6xFi6l rbcnUeNiaPkG9B+O9oxEw8/b9uYmR70WHNUaX3W87i8VyDFJrCZ2Th/hXgZXPk+V 8UGnsFL1AaLncnPzeeR9eSb0xS2AucgKoY4NaAjHch6CNddfyBXFmkIjRMgu2OgX QjCtjSOtUbaHA/EyaR2IplBLjqAXOiQy713An40cIkYPI9JK2/84md2s91/0jbFL Rb2p+Zsgg2Em5UyVEW9Min17GTdI6jmQ0CXHRu6E3WIG1sIQOHSDOZDA39fYag0F 4eF3my5YTYRpfwCIZUqBcrlVOVBhVixr221lSN6p83/Ta2C5JhsMRZel1gX/CE6n XeqGhQzj/kA1y38vy1FVo2ee/LWpRu7GSMHUUtfxemunmtqzlDA= =E28g -----END PGP SIGNATURE----- --AKlHIld2X0LP/Qv0--