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=sSxhHfh5; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 7A7CB5A0625 for ; Thu, 15 Jan 2026 09:50:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1768467049; bh=I9TSYbVaa7EX+Ae0btbxvGLEMgUnkJdV1bvXy61RsLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sSxhHfh56WJdDZBERocys9raOkhlbqdF8nsyfOE8cBhKEPQkvjBIHo/tHr61rR1Yi X5mtaKkZ3ikLEP9s1gzH2+xA0map4RSItCw2nHW8nT9hw4U6AsU2Denc9rXIOBVhLs B9WAcb4wMREFxoTUekHe3o1hRNj7+U5nP8NIozEIzpTYHBYk8vTWJ2fXeuf+apYgAd 3oVlQmfxiPNuDRfqKLiGO1g/oEBx/FV07OAnkTkUjhmckQ2zTRSkR8dhCvOPaMZMRt eAur6dZwvAcXnatacSunpYwtHi949SSa02/XMBUPhm0Z1qCvrOOHOLOykcLbassldz rzEGBuJFAFbLQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dsGsj2YMQz4wM0; Thu, 15 Jan 2026 19:50:49 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v4 01/14] inany: Extend inany_ntop() to treat NULL as a fully unspecified address Date: Thu, 15 Jan 2026 19:50:32 +1100 Message-ID: <20260115085045.3309818-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115085045.3309818-1-david@gibson.dropbear.id.au> References: <20260115085045.3309818-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: H563MQMVZVTINPWO5RQY4MZ7EAGVXU36 X-Message-ID-Hash: H563MQMVZVTINPWO5RQY4MZ7EAGVXU36 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 , Laurent Vivier 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 Reviewed-by: Laurent Vivier --- 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