From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202512 header.b=pVfVDMcS; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id D7A735A0624 for ; Mon, 19 Jan 2026 09:24:56 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1768811092; bh=Y53gaqnoO7vTPL9wY2BQqWgQv1qIC1tMghwminmLYOg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pVfVDMcSjXQAh1wUYdqCaI84OvH75cDXgrsLmVqgoBDh6EhE3lA9/ED6Cuh1Yw0i8 ZkgjTVvnOeSXcyky3O1W7malNRk6vMM437HxlhX2HppSGGYKsqGSSB8xZ+f7CjP9Ck 6RCyhR433sWNG5V2XQfXtbRSjMkIdXVY8mWOa2f9nvwERDr9aRrlT0d96wAperiNuG 1MYwxZkdHZI1FWsS7mHSWoGAkGcUr7Pq/ONOha7hHDcRahP2LeyyxDQpztYn5qkgMG ozj4794F4yXJC4MaAFwc8OgcgZyK60W1S4univZkLiuSI7vCIunARgE6N6pqaY5SUR gatIDSWejBSzQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dvk5w51dkz4wB8; Mon, 19 Jan 2026 19:24:52 +1100 (AEDT) Date: Mon, 19 Jan 2026 18:25:59 +1100 From: David Gibson To: Jon Maloy Subject: Re: [PATCH v2 3/9] conf: Refactor conf_print() for multi-address support Message-ID: References: <20260118221612.2115386-1-jmaloy@redhat.com> <20260118221612.2115386-4-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="vY4hdkREe/MWJM32" Content-Disposition: inline In-Reply-To: <20260118221612.2115386-4-jmaloy@redhat.com> Message-ID-Hash: EAG3N5K4PLPVPTTEAJZIAXYABA6QPIQV X-Message-ID-Hash: EAG3N5K4PLPVPTTEAJZIAXYABA6QPIQV 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: sbrivio@redhat.com, dgibson@redhat.com, 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: --vY4hdkREe/MWJM32 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jan 18, 2026 at 05:16:06PM -0500, Jon Maloy wrote: > As a preparation for multiple address support, we refactor the > conf_print() function to handle this properly. >=20 > Signed-off-by: Jon Maloy > --- > conf.c | 78 +++++++++++++++++++++++++++++++++------------------------- > 1 file changed, 45 insertions(+), 33 deletions(-) >=20 > 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))); > =20 > if (!c->no_dhcp) { > - uint32_t mask; > - > - mask =3D 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 =3D 0; i < c->ip4.addr_count; i++) { > + const struct inany_addr_entry *e; > + uint32_t mask; > + > + e =3D &c->ip4.addrs[i]; > + if (!(e->flags & INANY_ADDR_CONFIGURED) && > + c->ip4.addr_count > 1) > + continue; This doesn't seem right - addresses taken from the host will also be used for DHCP. > + > + mask =3D htonl(0xffffffff << (32 - e->prefix_len)); > + > + info("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; > + } > } > =20 > for (i =3D 0; !IN4_IS_ADDR_UNSPECIFIED(&c->ip4.dns[i]); i++) { > @@ -1230,30 +1238,34 @@ static void conf_print(const struct ctx *c) > } > =20 > if (c->ifi6) { > + bool do_slaac =3D !c->no_ndp || !c->no_dhcpv6; > + > 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))); > =20 > - 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 =3D 0; i < c->ip6.addr_count; i++) { > + info(" assign: %s", > + inet_ntop(AF_INET6, &c->ip6.addrs[i].addr.a6, > + buf6, sizeof(buf6))); There's an inany_ntop()... if you're going to use inany_ntop() for IPv6 only addresses you might at least use the helper functions already implemented for it. > + } > + 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 =3D 0; !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns[i]); i++) { > if (!i) > info("DNS:"); > --=20 > 2.52.0 >=20 --=20 David Gibson (he or they) | 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 --vY4hdkREe/MWJM32 Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmlt3IYACgkQzQJF27ox 2Ge9vg/+ILsAKrjCT2ZfYECkfRNuFEVguDD98B2ianxDnTIE0eHUsdZ9Q4EcFN/B T8hMGun8uvcJRF1vX1erOMkQx0AqAwRly5uQSBkOUmNnKRH6SUZ+6A3Qod3HUTA8 GnK+9RkM6hLdSUzlKS1XeLlrlcR9PqGJLKbWB/8YdbuqaTm0MnlGv/GZfpdD2Jhx R+v86iFX144RArH1O1P/XtPGo1OMbqG4P/8y3LXDJ3xrR2etMRiTPu25D0xMElqw 7alSngrn7K8GeVA4tMMCOVMKJA9gslJOEQ9v7nJf0YL7e/gk0PcHGEtdsTcsl+Py ntUr99e47ST5rT584FdgiEgRLJVVRdbTRBk0hzg0vs7YUgEl/BspsbW3mD4eX+1i OGiQwVXW9Nhp+Up55fWWvAWFjAoksoWzHYVQZ2KVpbDMvQnIIXExfzN/9n7ZWcMv Q/P1AtX7LYrublActMG04wy3lbLjBl4r5l/AbjOiaUJa/jVtIUwTF5W1r8P7bTPG ZB3eZyxjTtpI5f670RNNlLgaJdEY1jeoN3rLvSoQD74BRSWYnKw4+kDc7GJdUyML kKlQ6QpRQewccui5hbr9MTO1fGQ9EXbpdFBcM4VE59er4Js+/Imzu9k+JnPMaYsk NiuByduFUhdhdjZ4d7ZAmJtNyjbQs5jTufXh8Nq3Br7z1s7ptt4= =jXqj -----END PGP SIGNATURE----- --vY4hdkREe/MWJM32--