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 34B6C5A0265 for ; Thu, 10 Nov 2022 01:24:14 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4N72dQ3T5mz4xZG; Thu, 10 Nov 2022 11:24:10 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1668039850; bh=QikiQZaDd9RMmEsd6ud0fs/v1Brfdc5qb2GmYIDMjEY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EQCnYf4vPkSwXMeRTDVm/HkGYpJjEVYQFMxacQR9WmHWGANW5raEsoCBg8NAaFnu9 Ei2UEBHV2FdM7XJPJdRzxYlfnqiGU7Ce+Gtp61FlI/Mb0+IjFRjBVePVOcGD9nm5GA zJeKGAWB7l0oucjDz+u4/+RWguGYacEEfIEOAPZ4= Date: Thu, 10 Nov 2022 11:14:58 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH] conf: Fix mask calculation from prefix_len in conf_print() Message-ID: References: <20221109173833.3356429-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xOBn4EIil+nnigs7" Content-Disposition: inline In-Reply-To: <20221109173833.3356429-1-sbrivio@redhat.com> Message-ID-Hash: VACRQT4DG3UB727NCLI42CPSILNAHB5S X-Message-ID-Hash: VACRQT4DG3UB727NCLI42CPSILNAHB5S 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, Paul Holzinger X-Mailman-Version: 3.3.3 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: --xOBn4EIil+nnigs7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 09, 2022 at 06:38:33PM +0100, Stefano Brivio wrote: > Reported-by: Paul Holzinger > Fixes: dd09cceaee21 ("Minor improvements to IPv4 netmask handling") > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > conf.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/conf.c b/conf.c > index bfecdff..1adcf83 100644 > --- a/conf.c > +++ b/conf.c > @@ -884,7 +884,10 @@ static void conf_print(const struct ctx *c) > =20 > if (c->ifi4) { > if (!c->no_dhcp) { > - uint32_t mask =3D htonl(0xffffffff << c->ip4.prefix_len); > + uint32_t mask; > + > + mask =3D htonl(0xffffffff << (32 - c->ip4.prefix_len)); > + > info("DHCP:"); > info(" assign: %s", > inet_ntop(AF_INET, &c->ip4.addr, buf4, sizeof(buf4))); --=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 --xOBn4EIil+nnigs7 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoULxWu4/Ws0dB+XtgypY4gEwYSIFAmNsQnAACgkQgypY4gEw YSIFWRAAktercKTNNpmZsqzFqwIeb0yP840Pd2xWIet4ejwMvB+vhTW5WsH/4q++ KJJu/z+dSOA/sqrmF5xBVi2k5pnBAtRNjVztE8sgUkz3/+/czCSPa/fwIjRLafaL jmLru2Km1tqavN0bB5MQvTH/oh45lY1QzNzpa97uOZby7Stl78/zoaDi+2dGIs3j krcGfXmIE7UiIdnx1sA5G57mY1PCc2RpIeCFZUuRXB7U59npvohoLHFAR83FLxkZ GmgzeCVgBFCDFtemExCBQW1YMBTE7LyUk4iMrNQ2CV2wwYnJ8UbXdxnU510l9KEw Sj6JwryfbbzURAUfqZHdfzPP3nLjCDnEJ0OxHys7WIs77rab5uGIRovpkHgRNFJS Cfzuyx+TtW7CCcNDoZx0ELibZd3ai8niKpfMF7xXv326B/j/WnNr5+aiTkBInVae X7idESjsB1bHb2CLmcI8JC49QCrjiEF2zE5EE0jpD4YCewch6BGQXcFHpk+1z1Xw RHi5bfxbSGkdkEgFdlHe0XGSfuKDucmq/zkb6nlRYsBBigdwGQVDBSQiyhggN3Zi fN4bSr0NSIl7EJTL75AijAtjlN+8kOKtsP1dbhk4/i/vTZTfWBnXSNNCyUoSQRdv Wuu/QcepbNcgDDPP/+CHgk8GIKcMKZxBdjrNZywMuSDeeK0sZ7E= =HDoj -----END PGP SIGNATURE----- --xOBn4EIil+nnigs7--