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=R92W6bT8; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id D06925A0652 for ; Thu, 08 Jan 2026 03:29:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1767839390; bh=6uyh3TE7+5a1Ov9vrJb5KCb99aOpQRLDyhwD7RfODfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=R92W6bT8vhlUZ5bYK581gSTIBysTNKoQGqX2HiPxcvhlU+Jdl8OhQ4e/KUL+Fo0Xm 2cbYvq5DUTu1s8Up0eYmpSXoATVN5ky7BUN/GkKWk9uiCr8LG3DvJOetbwC4hUzWeK dYgYkWaHg6B/x+mRAXGmHN0NfQm8Qgv0aYnqWBwOB6hT3gzQ+eLvzWpfqRWmUqHVQC NL71v10PCMqW/gd3igAbevva0N1zxtTdI1VLhqHM/pTGcxhmvUPEaCiADe/We/3mCh UWAembk3Z9978osmitKz4kTwwUcU18t1bskJypTQY/BTBtdaAn/pj2sOg2ORXZrQWC oFQ4NRBVcDNWQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dmplL2vR9z4wR8; Thu, 08 Jan 2026 13:29:50 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v3 01/14] inany: Extend inany_ntop() to treat NULL as a fully unspecified address Date: Thu, 8 Jan 2026 13:29:35 +1100 Message-ID: <20260108022948.2657573-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260108022948.2657573-1-david@gibson.dropbear.id.au> References: <20260108022948.2657573-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: BRI23YTJTPUSUVLZNN7JKZP2IPL2KPG7 X-Message-ID-Hash: BRI23YTJTPUSUVLZNN7JKZP2IPL2KPG7 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: David Gibson 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: In a number of places we're using a convention that a NULL inany represents a dual-stack unspecified address, that is one which includes both 0.0.0.0 and ::. Extend inany_ntop() to handle that convention, representing it as "*". Signed-off-by: David Gibson --- inany.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/inany.c b/inany.c index 7680439d..87a4d8b6 100644 --- a/inany.c +++ b/inany.c @@ -22,7 +22,7 @@ const union inany_addr inany_loopback4 = INANY_INIT4(IN4ADDR_LOOPBACK_INIT); const union inany_addr inany_any4 = INANY_INIT4(IN4ADDR_ANY_INIT); /** inany_ntop - Convert an IPv[46] address to text format - * @src: IPv[46] address + * @src: IPv[46] address (NULL for unspecified) * @dst: output buffer, minimum INANY_ADDRSTRLEN bytes * @size: size of buffer at @dst * @@ -30,9 +30,12 @@ const union inany_addr inany_any4 = INANY_INIT4(IN4ADDR_ANY_INIT); */ const char *inany_ntop(const union inany_addr *src, char *dst, socklen_t size) { - const struct in_addr *v4 = inany_v4(src); + const struct in_addr *v4; + + if (!src) + return strncpy(dst, "*", size); - if (v4) + if ((v4 = inany_v4(src))) return inet_ntop(AF_INET, v4, dst, size); return inet_ntop(AF_INET6, &src->a6, dst, size); -- 2.52.0