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=dypTzU1s; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id 4D4D95A0652 for ; Sun, 18 Jan 2026 23:16:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1768774582; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1IMdHNaaMicyNmM9LjMDkyKV8+guHbDpxdcRUX9ZwtA=; b=dypTzU1sLk19Cgd52kFzFsK8hK7d03JDarbNb3Mh4HFEM4+9wwm7weryWpUzE8/kDYotQA efRaVPFew6UF1L3f3d9A+3xIea5xAR/1Mv/3f6whs0A0hlDtk4ZE+7xIgyMqKtLC8p41GV u0EK0JU3egdfRwQGH8b0vmM0bPAc3eU= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-355-cXINrinmNl2e1fWPJSF5JA-1; Sun, 18 Jan 2026 17:16:20 -0500 X-MC-Unique: cXINrinmNl2e1fWPJSF5JA-1 X-Mimecast-MFC-AGG-ID: cXINrinmNl2e1fWPJSF5JA_1768774579 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3A6A5180044D; Sun, 18 Jan 2026 22:16:19 +0000 (UTC) Received: from jmaloy-thinkpadp16vgen1.rmtcaqc.csb (unknown [10.22.80.38]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 40C0719541B0; Sun, 18 Jan 2026 22:16:18 +0000 (UTC) From: Jon Maloy To: sbrivio@redhat.com, dgibson@redhat.com, david@gibson.dropbear.id.au, jmaloy@redhat.com, passt-dev@passt.top Subject: [PATCH v2 3/9] conf: Refactor conf_print() for multi-address support Date: Sun, 18 Jan 2026 17:16:06 -0500 Message-ID: <20260118221612.2115386-4-jmaloy@redhat.com> In-Reply-To: <20260118221612.2115386-1-jmaloy@redhat.com> References: <20260118221612.2115386-1-jmaloy@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: UFzhVMz8NCvOCSKDB6lgN4rNb411GIHPz0Kol26d7Pg_1768774579 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: KIWCT34WQE37VYYWEA2SI533U4722VCI X-Message-ID-Hash: KIWCT34WQE37VYYWEA2SI533U4722VCI X-MailFrom: jmaloy@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 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: 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))); 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:"); + 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; + 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))); + } + 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:"); -- 2.52.0