From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id B84175A0271 for ; Thu, 7 Dec 2023 15:31:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1701959502; bh=KFQA/2bZHyjh7EkEVbcwkadzWavI73gOqMwxVEkDJ/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cdrJF8jaeZ9pswUxPf/WSt5t2zIlQIooybSuqTYcccemWaAcZcq8dNPd2VE4GvvC8 Uo5R/tRf/8DeBT34VpQglL0GGmruWeiKs0NbgDtpz/De/ukX8jAx4i1M3GgOG7ItmU HsAfA5Yu12ktuVYRoMJfaEnribf0NWrqPs0YnCrTWPErQiny0HsBdVyLatbp2ULUks Ml+MVbaciTHSUFOFz/M3lRcMj1PgrcnrlidHZBv3wAyOk3ODpAWbPcMZOjJUgvFTRS LhV/zOC5kItFiz0QIwQDhxapIHmsiiM+5c+joN18IS5s+b8F1q17z74CSpu8kGyjfF Jzt69zHg0kNwA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SmGtQ1747z4x2N; Fri, 8 Dec 2023 01:31:42 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 1/8] tcp: Fix address type for tcp_sock_init_af() Date: Fri, 8 Dec 2023 01:31:33 +1100 Message-ID: <20231207143140.1851378-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231207143140.1851378-1-david@gibson.dropbear.id.au> References: <20231207143140.1851378-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: CORSRPYQ367YUB6I3ZAONF2MQNZMT3SK X-Message-ID-Hash: CORSRPYQ367YUB6I3ZAONF2MQNZMT3SK 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: This takes a struct in_addr * (i.e. an IPv4 address), although it's explicitly supposed to handle IPv6 as well. Both its caller and sock_l4() which it calls use a void * for the address, which can be either an in_addr or an in6_addr. We get away with this, because we don't do anything with the pointer other than transfer it from the caller to sock_l4(), but it's misleading. And quite possibly technically UB, because C is like that. Signed-off-by: David Gibson --- tcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcp.c b/tcp.c index f506cfd..bda95b2 100644 --- a/tcp.c +++ b/tcp.c @@ -2905,7 +2905,7 @@ void tcp_sock_handler(struct ctx *c, union epoll_ref ref, uint32_t events) * Return: fd for the new listening socket, negative error code on failure */ static int tcp_sock_init_af(const struct ctx *c, int af, in_port_t port, - const struct in_addr *addr, const char *ifname) + const void *addr, const char *ifname) { union tcp_listen_epoll_ref tref = { .port = port + c->tcp.fwd_in.delta[port], -- 2.43.0