From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 661725A027E for ; Thu, 22 Feb 2024 00:21:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1708557678; bh=YudBCbjr+Zg/OrcHZO3fOmYz2GS+5yQEnt1tmv0rB78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPspVCuyvLBKgCLjjBFKKSMxYvRLkww9HrjbO4rS4AiRIIw7T36xK95FH5DyowbSy gwmBnqqqFHXhG/7g4yif0orengjymZXcY5BFO2+NO6tN7EbQCxVVRlT/9+XPe60t4H ecjOyVlAmbzHppOK90bu91MLWllAIcQOj8Z92kknNWBS3zBu4MSqBC21niYebjp7Gv Dp6Ksd+5Io7QkjWScp5QcPrMkhhKas61WYdb7MIWx4PhGs+TuCq7udHhRn18CnLpiE yb2kanVhs+zASuKGQATE97Zudpf+WqrcqMhPAADgBLB9byYXulROrPAKuBBrCTY9Y6 0jXqI19FBC86w== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4TgC2Q1z2Bz4wcF; Thu, 22 Feb 2024 10:21:18 +1100 (AEDT) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 2/7] udp: Set pif in epoll reference for ephemeral host sockets Date: Thu, 22 Feb 2024 10:21:10 +1100 Message-ID: <20240221232115.1376333-3-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.43.2 In-Reply-To: <20240221232115.1376333-1-david@gibson.dropbear.id.au> References: <20240221232115.1376333-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: GK7ZEQZ3YSB2RYYAF7PDWQBLXLKPYTHG X-Message-ID-Hash: GK7ZEQZ3YSB2RYYAF7PDWQBLXLKPYTHG 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: The udp_epoll_ref contains a field for the pif to which the socket belongs. We fill this in for permanent sockets created with udp_sock_init() and for spliced sockets, however, we omit it for ephemeral sockets created for tap originated flows. This is a bug, although we currently get away with it, because we don't consult that field for such flows. Correctly fill it in. Signed-off-by: David Gibson --- udp.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/udp.c b/udp.c index d2f8027c..03a5936e 100644 --- a/udp.c +++ b/udp.c @@ -868,7 +868,10 @@ int udp_tap_handler(struct ctx *c, uint8_t pif, src, dst, udp_tap_map[V4][src].sock); if ((s = udp_tap_map[V4][src].sock) < 0) { struct in_addr bind_addr = IN4ADDR_ANY_INIT; - union udp_epoll_ref uref = { .port = src }; + union udp_epoll_ref uref = { + .port = src, + .pif = PIF_HOST, + }; const char *bind_if = NULL; if (!IN6_IS_ADDR_LOOPBACK(&s_in.sin_addr)) @@ -916,7 +919,11 @@ int udp_tap_handler(struct ctx *c, uint8_t pif, } if ((s = udp_tap_map[V6][src].sock) < 0) { - union udp_epoll_ref uref = { .v6 = 1, .port = src }; + union udp_epoll_ref uref = { + .v6 = 1, + .port = src, + .pif = PIF_HOST, + }; const char *bind_if = NULL; if (!IN6_IS_ADDR_LOOPBACK(&s_in6.sin6_addr)) -- 2.43.2