From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 0D4925A0050 for ; Fri, 14 Jun 2024 03:51:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1718329872; bh=T6nT5Ol4vb03ZvxBL4ypqkRfcFvMC5Z5bQMveRhAYiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AvqF568HpG+C2fnl7LhpLnywG4G2dW5T9HrrdJYJAAwxvAckZ+8vy9+CEvlRF/NU/ I/LHZ/zQ3SpxetptMUgItp2YBRwhRWSkLijBOommcDeVKgRvEDJGJ+m9n1rZbUwUDi /bZshfoZb1QCiS1uKqNkQEIv5LztxnBYudpXy8+Ly2XezIyG56VCvnRFbj23oxoaYU wLndaQxHbhq0deOEjigk7EyCDoGHiJoBKKh60GfoiZUqJ3tbEQqhNUCSxjx4RzFkLV up66RMGCM0JlBChsFidU+CbGNcYnGX3DjkMzNWcida3PBNeiLXiv8Biwf0hYbQmCNm dASA/BnLgDdjQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4W0j1D2q8Nz4wcl; Fri, 14 Jun 2024 11:51:12 +1000 (AEST) From: David Gibson To: Stefano Brivio , passt-dev@passt.top Subject: [PATCH v2 4/4] udp: Move management of udp[46]_localname into udp_splice_send() Date: Fri, 14 Jun 2024 11:51:08 +1000 Message-ID: <20240614015108.2761502-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240614015108.2761502-1-david@gibson.dropbear.id.au> References: <20240614015108.2761502-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: PAC76COXN3P4SNRUZGNKBVUVREXUBD6Q X-Message-ID-Hash: PAC76COXN3P4SNRUZGNKBVUVREXUBD6Q 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 3bedfce3..e79ca938 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 { @@ -796,13 +798,10 @@ void udp_buf_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t eve 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.2