From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=FojTHnGD; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTPS id 2DDC85A0652 for ; Wed, 21 Jan 2026 14:02:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769000535; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W/kAyyCRbvcd2/Ao6q1rmTljEz04SzoHghWeFeu+u+8=; b=FojTHnGD9n6vEHVujsxGRYkj+gigfc7/Xg0rkuKfk/ACy9isJf7z1RCiqSDogDuqlLHyqM EZQYIGx+ep2QBwwqsavaQh61atBqgLYn+IaZy2dTfGmtok7zwDCEGKu+0X/MX9HqCxt8LS By2B9oeFPemuuREofQKYGRuTVw/tKyw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-96-QBGsWUoZOp2k0usSPjMcoA-1; Wed, 21 Jan 2026 08:02:13 -0500 X-MC-Unique: QBGsWUoZOp2k0usSPjMcoA-1 X-Mimecast-MFC-AGG-ID: QBGsWUoZOp2k0usSPjMcoA_1769000532 Received: by mail-wm1-f69.google.com with SMTP id 5b1f17b1804b1-47ee8808ffbso48597665e9.2 for ; Wed, 21 Jan 2026 05:02:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769000532; x=1769605332; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=W/kAyyCRbvcd2/Ao6q1rmTljEz04SzoHghWeFeu+u+8=; b=FiBdgYPsXLU5/gPWdQyHfNsNIeCT4qHEiQ4AbSWqrcMPTiPt6lldsfAlfG5INXCjSX PNyNSdW9o8degqXt/7Dun4Zvcj+aOb+JhjqywMAxXOkeWJPZwZbVsYBR2CAWWT9Fn+jt hbNyu7Fmlis20VSsHCtaLFyz+8h+YjfEIq3ICg/cNV8VbPYZyy33l1ZeywQxSbyFfD0v wrtoOjupgQCYboy3R6DE11MB6FqkMDgvoGp2kqYHFOLuNeH2qeRdR6yczqG5Jme//IJe deyBlLvhUyE9dIToBQnuMOCaW0BNcShZ34VeCND4pFwMwHDPliO7ek6GFm5nOh1RMBYS L/4Q== X-Forwarded-Encrypted: i=1; AJvYcCVp5CzJL8l83qbJQTTM5eeAybXaBWGyhxm6H/YPMsrqtilrfec0SblWRKF8XqVLIvLuu31ou+LXPYk=@passt.top X-Gm-Message-State: AOJu0YygX0VYMEynHMYtK26E3oyVjX0vXcSd4ab7mbRmDrQnnT89TmCl HwAY311HXCjsJqaMwN9+icDvzw0L0KlXI6myoCSWwOYAJ4OEbIW3rwkDcubrxI1yGDqdfam6vgQ 8GUACyHR1x6OR2kmChwCuHMTlwMCPsRLBJI4jkGgRpnBuzJiA6HqpWg== X-Gm-Gg: AZuq6aLNsSrNr+0hvLQw5jVHlyPMF1/6vCboyHNFFPWOxP+B5tOLl0B4Y/f99O/bJX0 VX73S3SjNI/jzGJFs8mfB0BCtvJ++HliVWEM7Tw81YV9YIJWRl2kAVx09TpW6NnN7u7ZhTxovq8 EXq+44MWXlps6LuRE5YdJB60PVHc7snojpTTGE0HHf+POrox3I8i9xtMNZMT9yXuZnBG/WCBeyC iviAoWzPnfP4PposHW2+4Sh09B5/Ry994aWceli0TyCDswk2qZ73R95irUyEg2V+deBJ/TIhtwB HiM5fzFh63vVNWTR/5z7cZvNaXyiz8D33Fh+Xer/7ayvpfL+LG4AzFWtlDW3v6nOTPEcuM+s3yq jGfIv6/MaoCtS3nDLaOUP X-Received: by 2002:a05:600c:a305:b0:480:2521:4d92 with SMTP id 5b1f17b1804b1-4802521516emr178133155e9.24.1769000532312; Wed, 21 Jan 2026 05:02:12 -0800 (PST) X-Received: by 2002:a05:600c:a305:b0:480:2521:4d92 with SMTP id 5b1f17b1804b1-4802521516emr178132555e9.24.1769000531864; Wed, 21 Jan 2026 05:02:11 -0800 (PST) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [2a10:fc81:a806:d6a9::1]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48042bf6be2sm21500515e9.5.2026.01.21.05.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jan 2026 05:02:11 -0800 (PST) Date: Wed, 21 Jan 2026 14:02:09 +0100 From: Stefano Brivio To: Jon Maloy Subject: Re: [PATCH v2 3/9] conf: Refactor conf_print() for multi-address support Message-ID: <20260121140209.60214f05@elisabeth> In-Reply-To: <20260118221612.2115386-4-jmaloy@redhat.com> References: <20260118221612.2115386-1-jmaloy@redhat.com> <20260118221612.2115386-4-jmaloy@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 9MS9_MZDiYU2uN4XWG_ImRPK84veHU25Rwe1Dz-sJvo_1769000532 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: 7I7YACKBY5KHQ4DVCIK6KQHRIDNPAS3I X-Message-ID-Hash: 7I7YACKBY5KHQ4DVCIK6KQHRIDNPAS3I X-MailFrom: sbrivio@redhat.com 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: dgibson@redhat.com, david@gibson.dropbear.id.au, 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: On Sun, 18 Jan 2026 17:16:06 -0500 Jon Maloy wrote: > As a preparation for multiple address support, we refactor the > conf_print() function to handle this properly. > > Signed-off-by: Jon Maloy > --- > conf.c | 78 +++++++++++++++++++++++++++++++++------------------------- > 1 file changed, 45 insertions(+), 33 deletions(-) > > diff --git a/conf.c b/conf.c > index 9fc5dca..3ecd1a0 100644 > --- a/conf.c > +++ b/conf.c > @@ -1199,20 +1199,28 @@ static void conf_print(const struct ctx *c) > buf4, sizeof(buf4))); > I didn't really check why that starts being reported now, but, with this patch, cppcheck now says that: conf.c:1167:31: style: The scope of the variable 'ifn' can be reduced. [variableScope] char bufmac[ETH_ADDRSTRLEN], ifn[IFNAMSIZ]; ^ > if (!c->no_dhcp) { > - uint32_t mask; > - > - mask = htonl(0xffffffff << > - (32 - c->ip4.addrs[0].prefix_len)); > - > - info("DHCP:"); > - info(" assign: %s", > - inet_ntop(AF_INET, inany_v4(&c->ip4.addrs[0].addr), > - buf4, sizeof(buf4))); > - info(" mask: %s", > - inet_ntop(AF_INET, &mask, buf4, sizeof(buf4))); > - info(" router: %s", > - inet_ntop(AF_INET, &c->ip4.guest_gw, > - buf4, sizeof(buf4))); > + for (i = 0; i < c->ip4.addr_count; i++) { > + const struct inany_addr_entry *e; > + uint32_t mask; > + > + e = &c->ip4.addrs[i]; > + if (!(e->flags & INANY_ADDR_CONFIGURED) && > + c->ip4.addr_count > 1) > + continue; > + > + mask = htonl(0xffffffff << (32 - e->prefix_len)); > + > + info("DHCP:"); Should this really be in a loop? We'll assign a single address via DHCP. > + info(" assign: %s", > + inet_ntop(AF_INET, inany_v4(&e->addr), > + buf4, sizeof(buf4))); > + info(" mask: %s", > + inet_ntop(AF_INET, &mask, buf4, sizeof(buf4))); > + info(" router: %s", > + inet_ntop(AF_INET, &c->ip4.guest_gw, > + buf4, sizeof(buf4))); > + break; > + } > } > > for (i = 0; !IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns[i]); i++) { > @@ -1230,30 +1238,34 @@ static void conf_print(const struct ctx *c) > } > > if (c->ifi6) { > + bool do_slaac = !c->no_ndp || !c->no_dhcpv6; We can enable DHCPv6 and disable SLAAC though. The "SL" in SLAAC stands for "stateless", DHCPv6 is stateful. We can enable both, one, or none. The 'dns6' label was meant to avoid a variable like this one and another block, maybe it would be more practical to keep it. > + > if (!IN6_IS_ADDR_UNSPECIFIED(&c->ip6.map_host_loopback)) > info(" NAT to host ::1: %s", > inet_ntop(AF_INET6, &c->ip6.map_host_loopback, > buf6, sizeof(buf6))); > > - if (!c->no_ndp && !c->no_dhcpv6) > - info("NDP/DHCPv6:"); > - else if (!c->no_dhcpv6) > - info("DHCPv6:"); > - else if (!c->no_ndp) > - info("NDP:"); > - else > - goto dns6; > - > - info(" assign: %s", > - inet_ntop(AF_INET6, &c->ip6.addrs[0].addr.a6, > - buf6, sizeof(buf6))); > - info(" router: %s", > - inet_ntop(AF_INET6, &c->ip6.guest_gw, buf6, sizeof(buf6))); > - info(" our link-local: %s", > - inet_ntop(AF_INET6, &c->ip6.our_tap_ll, > - buf6, sizeof(buf6))); > - > -dns6: > + if (do_slaac) { > + if (!c->no_ndp && !c->no_dhcpv6) > + info("NDP/DHCPv6:"); > + else if (!c->no_dhcpv6) > + info("DHCPv6:"); > + else > + info("NDP:"); > + > + for (i = 0; i < c->ip6.addr_count; i++) { > + info(" assign: %s", > + inet_ntop(AF_INET6, &c->ip6.addrs[i].addr.a6, > + buf6, sizeof(buf6))); I don't see a matching change for neither NDP nor DHCPv6, so we shouldn't really print more than one address (at least until this point). > + } > + info(" router: %s", > + inet_ntop(AF_INET6, &c->ip6.guest_gw, > + buf6, sizeof(buf6))); > + info(" our link-local: %s", > + inet_ntop(AF_INET6, &c->ip6.our_tap_ll, > + buf6, sizeof(buf6))); > + } > + > for (i = 0; !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns[i]); i++) { > if (!i) > info("DNS:"); I reviewed up to 5/9 so far, no further comments until then. -- Stefano