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=pIbwntEq; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id C7B375A065B for ; Fri, 16 Jan 2026 01:59:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202512; t=1768525168; bh=I9TSYbVaa7EX+Ae0btbxvGLEMgUnkJdV1bvXy61RsLQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pIbwntEq4tHRriXLZzz8NbECzR67xqM1Mu7Rnv/dUKNV7orFcSdIZq3aKOPMuFqin 9vZiOUNDjPZeW+Pqdw4B00fr+7wzOQnuPVEl38fvqyxGV6TmGXyTvRzZbzo59lax4k Epha/P7hqyxzQ+I4vUvw2mwixAyCUB6r4c91C4+1lfUxNt+7LQLfeRTHasgWWHDXBo UG9NRSwcvdv1j3yzn8cjEy0/1Z930p/+fjdTVnQz5956WcndQm4xMoN9bnIZ2gTyNG NC5iKdJh9ygs0/YNUwO5iUvGSn5KYqWZJxRBueXQlpU5rs8M2temIG1fMRsbQBbeUU VoZ3xaWsTuTvQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4dshMN4QX5z4wDJ; Fri, 16 Jan 2026 11:59:28 +1100 (AEDT) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH v5 01/14] inany: Extend inany_ntop() to treat NULL as a fully unspecified address Date: Fri, 16 Jan 2026 11:59:13 +1100 Message-ID: <20260116005926.616085-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260116005926.616085-1-david@gibson.dropbear.id.au> References: <20260116005926.616085-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: U7UQXO32YE6RRAMMXQO5WB57EJFRVDDL X-Message-ID-Hash: U7UQXO32YE6RRAMMXQO5WB57EJFRVDDL 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