From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 2D6425A030A for ; Wed, 05 Jun 2024 03:39:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1717551546; bh=qyAYUYB9l7vABHIQ/vKJ9AZbqerj81NQuh96gS+EKnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lkpLnaTB0kheoZ//BrzCI5Pnh2LPgNwGTPE0LQCcSpCLoo/sL0PUEuATnAYorLGMo UIfw/yO6ecNiV92wVxqeLW0nPwHfeWwv8ypPEGsi0wUzJ0JtWgl0b+yCqlab2tpRdg vM/Kw69muh/qVqogOExuF6Aus1VVTbSLMOIan9H1eNatQOOH/oEtF/mrro2doFMK5K m+oOTBBm+tJecAa3rHLnaHfjRDm82K1HVEHYoHtgzKN0MP6nNFm2uLQoBsWqDW/VVI nK6IV3/VK3QVVPk03/KaVO9OdxZk0eOB8uijcNmHyZYTiak0mHifYjjsnOiXWok5eI U2uHIKiH5ts+Q== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Vv99Q02CDz4x2d; Wed, 5 Jun 2024 11:39:06 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH 4/4] udp: Move management of udp[46]_localname into udp_splice_send() Date: Wed, 5 Jun 2024 11:39:03 +1000 Message-ID: <20240605013903.3694452-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240605013903.3694452-1-david@gibson.dropbear.id.au> References: <20240605013903.3694452-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: GUMKGECT35XNBCV75H6OZGI4TXDCCYD4 X-Message-ID-Hash: GUMKGECT35XNBCV75H6OZGI4TXDCCYD4 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: Mostly, udp_sock_handler() is independent of how the datagrams it processes will be forwarded (tap or splice). However, it also updates the msg_name fields for spliced sends, which doesn't really make sense here. Move it into udp_splice_send() which is all about spliced sends. This does potentially mean we'll update the field to the same value several times, but we're going to need this in future anyway: with the extensions the flow table allows, it might not be the same value each time after all. Signed-off-by: David Gibson --- udp.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/udp.c b/udp.c index 757c10ab..8bd00a87 100644 --- a/udp.c +++ b/udp.c @@ -522,9 +522,11 @@ static unsigned udp_splice_send(const struct ctx *c, size_t start, size_t n, if (uref.v6) { mmh_recv = udp6_l2_mh_sock; mmh_send = udp6_mh_splice; + udp6_localname.sin6_port = htons(dst); } else { mmh_recv = udp4_l2_mh_sock; mmh_send = udp4_mh_splice; + udp4_localname.sin_port = htons(dst); } do { @@ -788,13 +790,10 @@ void udp_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events, else if (ref.udp.pif == PIF_HOST) dstport += c->udp.fwd_in.f.delta[dstport]; - if (v6) { + if (v6) mmh_recv = udp6_l2_mh_sock; - udp6_localname.sin6_port = htons(dstport); - } else { + else mmh_recv = udp4_l2_mh_sock; - udp4_localname.sin_port = htons(dstport); - } n = recvmmsg(ref.fd, mmh_recv, n, 0, NULL); if (n <= 0) -- 2.45.1