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 6BE3E5A027F for ; Tue, 16 May 2023 06:06:56 +0200 (CEST) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4QL2k46JKpz4x3m; Tue, 16 May 2023 14:06:52 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1684210012; bh=mlQaUC5LTNf5q5KrPZ5jbYcUPV1vVBZDppuESPijF4M=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aM7pTQ07CpmNB6Y8J0bOrxGlKkzqXJstu3uwY69WQ1HRpYNIto74N8p0aFTE68JYe 6dsMKfumwa3rHULnEkBsV269wPwZEtQ48g76R0d9j79mcWtSzvaRv3Cyzy7lKDMLF1 wEq0XJnys2s5eqtki+m3kdxPbEZfxMxQ8tiQPE4c= Date: Tue, 16 May 2023 14:00:37 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 06/10] Revert "conf: Adjust netmask on mismatch between IPv4 address/netmask and gateway" Message-ID: References: <20230514181415.313420-1-sbrivio@redhat.com> <20230514181415.313420-7-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="+wo1shKCuKmUfkf5" Content-Disposition: inline In-Reply-To: <20230514181415.313420-7-sbrivio@redhat.com> Message-ID-Hash: L2OGEGPLKF5XTZL7MRFIPCYRCKC42AYI X-Message-ID-Hash: L2OGEGPLKF5XTZL7MRFIPCYRCKC42AYI 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, Callum Parsey , me@yawnt.com, lemmi@nerd2nerd.org 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: --+wo1shKCuKmUfkf5 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, May 14, 2023 at 08:14:11PM +0200, Stefano Brivio wrote: > This reverts commit 7656a6f8888237b9e23d63666e921528b6aaf950: now, by > default, we copy all the routes associated to the outbound interface > into the routing table of the container, so there's no need for this > horrible workaround anymore. >=20 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson This was never the right solution - even without the other considerations raised by this series we probably should have advertized an explicit host route to the gateway instead of mangling the netmask. > --- > conf.c | 25 +------------------------ > 1 file changed, 1 insertion(+), 24 deletions(-) >=20 > diff --git a/conf.c b/conf.c > index c2a745e..3a2fc2d 100644 > --- a/conf.c > +++ b/conf.c > @@ -634,9 +634,6 @@ static int conf_ip4_prefix(const char *arg) > static unsigned int conf_ip4(unsigned int ifi, > struct ip4_ctx *ip4, unsigned char *mac) > { > - in_addr_t addr, gw; > - int shift; > - > if (!ifi) > ifi =3D nl_get_ext_if(AF_INET); > =20 > @@ -651,10 +648,8 @@ static unsigned int conf_ip4(unsigned int ifi, > if (IN4_IS_ADDR_UNSPECIFIED(&ip4->addr)) > nl_addr(0, ifi, AF_INET, &ip4->addr, &ip4->prefix_len, NULL); > =20 > - addr =3D ntohl(ip4->addr.s_addr); > - gw =3D ntohl(ip4->gw.s_addr); > - > if (!ip4->prefix_len) { > + in_addr_t addr =3D ntohl(ip4->addr.s_addr); > if (IN_CLASSA(addr)) > ip4->prefix_len =3D (32 - IN_CLASSA_NSHIFT); > else if (IN_CLASSB(addr)) > @@ -665,24 +660,6 @@ static unsigned int conf_ip4(unsigned int ifi, > ip4->prefix_len =3D 32; > } > =20 > - /* We might get an address with a netmask that makes the default > - * gateway unreachable, and in that case we would fail to configure > - * the default route, with --config-net, or presumably a DHCP client > - * in the guest or container would face the same issue. > - * > - * The host might have another route, to the default gateway itself, > - * fixing the situation, but we only read default routes. > - * > - * Fix up the mask to allow reaching the default gateway from our > - * configured address, if needed, and only if we find a non-zero > - * mask that makes the gateway reachable. > - */ > - shift =3D 32 - ip4->prefix_len; > - while (shift < 32 && addr >> shift !=3D gw >> shift) > - shift++; > - if (shift < 32) > - ip4->prefix_len =3D 32 - shift; > - > memcpy(&ip4->addr_seen, &ip4->addr, sizeof(ip4->addr_seen)); > =20 > if (MAC_IS_ZERO(mac)) --=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 --+wo1shKCuKmUfkf5 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmRi/94ACgkQzQJF27ox 2Gekug//c1z+d7Y0zc1HXCHEiXIpVT6zsAI7qVaf06Rq4P8Ov6VKjVn0X113IdrA NrttxgiRgYJ1A9AHvHlcm/KnrXfSO7FVcjBIru2dHsmUwEweZvlMmTEwy4BxmnEv TD2D2zXsaohfmcGWcBy69UfaVpkyGiZ8RBYZiGvvNrjupz/KM3JFrIpl3rpS+nEt fU+O3LbtmmjSdqwmS3py1KJSXJvBnBXcI9itYoZBhK+LAR4DMxvEECLrAEwXDIhM QaitNMUmxesBjK5zFtayakhwWj2ZcoskK/GfKs8TBjHC/k5/wJBE9oGvq+JAiv1B pFWtbFhtKwE89Yc+ouUvleh0foi4zwxVkdXGMvdbk1e3EUkn1XJhElRPJ0+2Fabf dXInemx8xZacTDcJUWzte1TSRYCgfNq7pAmEwWbtCm2aoYA1DUF3JybqUUF4N2oZ UN6xWjPF21IYETWkIlv8SfhKvPWIrdTB28u9Gi4gnncHTxeM7MfbruyBRK9wbVZQ qQJhciUH0pFrw/+laZq7EtCCqAHODW+Og8pgv6pAzjTVPVHlps4+XjBB5BOzgmjN xTdYcPw/ROUpYgu6pW3PKKXJStyxeGxxx7wE63AMm7lJA33gmSKR1iHf2xLZQKb7 +kRljet0upHdGm95aztC5WkJeFZMao+SGVyxJUy9skx/gsVETiA= =XHZ5 -----END PGP SIGNATURE----- --+wo1shKCuKmUfkf5--