From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by passt.top (Postfix, from userid 1000) id 095F15A0269; Wed, 9 Nov 2022 18:38:33 +0100 (CET) From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] conf: Fix mask calculation from prefix_len in conf_print() Date: Wed, 9 Nov 2022 18:38:33 +0100 Message-Id: <20221109173833.3356429-1-sbrivio@redhat.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: 5A2QKQQC7IPI54LNOE3J5MEQMF6JXMBB X-Message-ID-Hash: 5A2QKQQC7IPI54LNOE3J5MEQMF6JXMBB X-MailFrom: sbrivio@passt.top 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: David Gibson , 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: Reported-by: Paul Holzinger Fixes: dd09cceaee21 ("Minor improvements to IPv4 netmask handling") Signed-off-by: Stefano Brivio --- conf.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) if (c->ifi4) { if (!c->no_dhcp) { - uint32_t mask = htonl(0xffffffff << c->ip4.prefix_len); + uint32_t mask; + + mask = htonl(0xffffffff << (32 - c->ip4.prefix_len)); + info("DHCP:"); info(" assign: %s", inet_ntop(AF_INET, &c->ip4.addr, buf4, sizeof(buf4))); -- 2.35.1