From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZF3psxey; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id F3C745A0008 for ; Mon, 07 Apr 2025 23:49:37 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744062577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6jZCaqK6u/jb04LHU9tftqYgRMSqu+jJse0o7tnPsAE=; b=ZF3psxey4eO/Ynz+/rgP22CAGVlZKIR1mUur07On3LP18iU4Ausu48LYA4F63MxvE0l1OZ O976k1Joui+wkOmo1KH7Tk+Qukd7FhqGWjrThSOhbChOFY6hA3XcuKoOD1+ZAvf/1moec5 0/TMZOYgCdBVSbzsy5U/BBPEKAi50UQ= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-247-ShV4TzaoNXOrqbmdiUq-Gg-1; Mon, 07 Apr 2025 17:49:34 -0400 X-MC-Unique: ShV4TzaoNXOrqbmdiUq-Gg-1 X-Mimecast-MFC-AGG-ID: ShV4TzaoNXOrqbmdiUq-Gg_1744062574 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-39131851046so2137033f8f.0 for ; Mon, 07 Apr 2025 14:49:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744062573; x=1744667373; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=6jZCaqK6u/jb04LHU9tftqYgRMSqu+jJse0o7tnPsAE=; b=dUeTO8Xv8c2EWfBSiCmM47ciJWRizL6EhIsffPJUy+ruUCp1H/h+m+zQtzM21y4AmZ w93OvJXHRmHK+9ByXaO0wqJInoaIJxzWTu8jx4vDZ/dDMs+9zaxTGNl/M2hyePJ5jrhx 3/FENQik2lcUbFIKykZIAOUupW6/uhypzsuRGrrLPcPtGNI04hd4VAD2nlcHYGGQkbZy 1SiUj837uPSlxiF6oxg3Hssq3ovGfKyIPuArkJSUD5XWVuEKQmFlhtmFfMjvbESJixuF xisCMftaw/oNLxoRLC7tvtA4nLcRsfhNZWfOqwrSeZC6d6IBCQZqvXCV1HGrfAamH9MH A6VQ== X-Gm-Message-State: AOJu0Yz3NfExqV0Pfx4gJ0YUepwuh20aWA5lHcsqGPOQhqpQmOwygCBA dLG/a9acseRDF8gAos5n7+pDHutDRj6xr5J16K49k+pZ+21jFfJAOHSp3VW8+x6Uhx0NiJt+Xyi dsl4MlWnjkR36DNSXTJT+zE/NNyC7yFZwhvnBRVNbEDO4+FZpBxhmOly5rQ== X-Gm-Gg: ASbGncs0GQK1dksQ4l+sjW/2MdIl9TOQgEhFisSmIn/BYiGYTEfae5Q3olyH1FlRiGI lmTTY9WG/tlfgEO3qliZGCv5/HJ4ccFOmvY/hgLmYc6p3ShLimex/1TL+sNkSMLHuWd/jLJ88Mk PNuR82cZgUXHzpz56zHdZtnI4jG4ekGCtgtcsn/DQYvxCX86IMvmfYkMno7xNDs/+uDaJsts3RC iv5UTAQxi2KAVgOiymPToCEDETTnYAPeryxk/MqS50CjIVnQkSPc1fN/t7cqhbhHPXXBZ2kcpwM 1bJOTlucULxm4KhU6SeTcvI/EadlUjdcTYnw6jHQtPLX X-Received: by 2002:a05:6000:186e:b0:391:304f:34e7 with SMTP id ffacd0b85a97d-39d0de61c1amr12684080f8f.44.1744062573416; Mon, 07 Apr 2025 14:49:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMF8xufQTFF+2/avu5CBQBXJpU9wO7qnM7XHRv1MxvSOJi8DG3RshFBKFD/m4pjYgWc+ITFQ== X-Received: by 2002:a05:6000:186e:b0:391:304f:34e7 with SMTP id ffacd0b85a97d-39d0de61c1amr12684070f8f.44.1744062573032; Mon, 07 Apr 2025 14:49:33 -0700 (PDT) Received: from maya.myfinge.rs (ifcgrfdd.trafficplex.cloud. [176.103.220.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43ec163107csm147571785e9.3.2025.04.07.14.49.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Apr 2025 14:49:32 -0700 (PDT) Date: Mon, 7 Apr 2025 23:49:31 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 11/12] udp: Fold udp_splice_prepare and udp_splice_send into udp_sock_to_sock Message-ID: <20250407234931.2cca7fae@elisabeth> In-Reply-To: <20250404101542.3729316-12-david@gibson.dropbear.id.au> References: <20250404101542.3729316-1-david@gibson.dropbear.id.au> <20250404101542.3729316-12-david@gibson.dropbear.id.au> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.49; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: wm7xaZiZpL3s2YNmds9ATC9ziELvvoierk6sv-xAvng_1744062574 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: EWNSQYLGDKNUH5RNRJDU3RXTBSUJC6ZV X-Message-ID-Hash: EWNSQYLGDKNUH5RNRJDU3RXTBSUJC6ZV X-MailFrom: sbrivio@redhat.com 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: passt-dev@passt.top 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: On Fri, 4 Apr 2025 21:15:41 +1100 David Gibson wrote: > udp_splice() prepare and udp_splice_send() are both quite simple functions > that now have only one caller: udp_sock_to_sock(). Fold them both into > that caller. > > Signed-off-by: David Gibson > --- > udp.c | 53 +++++++++++++---------------------------------------- > 1 file changed, 13 insertions(+), 40 deletions(-) > > diff --git a/udp.c b/udp.c > index 22e74b48..7c8b7a2c 100644 > --- a/udp.c > +++ b/udp.c > @@ -250,43 +250,6 @@ static void udp_iov_init(const struct ctx *c) > udp_iov_init_one(c, i); > } > > -/** > - * udp_splice_prepare() - Prepare one datagram for splicing > - * @mmh: Receiving mmsghdr array > - * @idx: Index of the datagram to prepare > - */ > -static void udp_splice_prepare(struct mmsghdr *mmh, unsigned idx) > -{ > - udp_mh_splice[idx].msg_hdr.msg_iov->iov_len = mmh[idx].msg_len; > -} > - > -/** > - * udp_splice_send() - Send a batch of datagrams from socket to socket > - * @c: Execution context > - * @start: Index of batch's first datagram in udp[46]_l2_buf > - * @n: Number of datagrams in batch > - * @src: Source port for datagram (target side) > - * @dst: Destination port for datagrams (target side) > - * @ref: epoll reference for origin socket > - * @now: Timestamp > - * > - * #syscalls sendmmsg In theory this should have been moved to udp_sock_to_sock(), even though we already enable sendmmsg() in the comment of udp_tap_handler(), so this is not strictly needed, but... added back on merge. > - */ > -static void udp_splice_send(const struct ctx *c, size_t start, size_t n, > - flow_sidx_t tosidx) > -{ > - const struct flowside *toside = flowside_at_sidx(tosidx); > - const struct udp_flow *uflow = udp_at_sidx(tosidx); > - uint8_t topif = pif_at_sidx(tosidx); > - int s = uflow->s[tosidx.sidei]; > - socklen_t sl; > - > - pif_sockaddr(c, &udp_splice_to, &sl, topif, > - &toside->eaddr, toside->eport); > - > - sendmmsg(s, udp_mh_splice + start, n, MSG_NOSIGNAL); > -} > - > /** > * udp_update_hdr4() - Update headers for one IPv4 datagram > * @ip4h: Pre-filled IPv4 header (except for tot_len and saddr) > @@ -683,15 +646,25 @@ static int udp_sock_recv(const struct ctx *c, int s, struct mmsghdr *mmh, int n) > static void udp_sock_to_sock(const struct ctx *c, int from_s, int n, > flow_sidx_t tosidx) > { > + const struct flowside *toside = flowside_at_sidx(tosidx); > + const struct udp_flow *uflow = udp_at_sidx(tosidx); > + uint8_t topif = pif_at_sidx(tosidx); > + int to_s = uflow->s[tosidx.sidei]; > + socklen_t sl; > int i; > > if ((n = udp_sock_recv(c, from_s, udp_mh_recv, n)) <= 0) > return; > > - for (i = 0; i < n; i++) > - udp_splice_prepare(udp_mh_recv, i); > + for (i = 0; i < n; i++) { > + udp_mh_splice[i].msg_hdr.msg_iov->iov_len > + = udp_mh_recv[i].msg_len; > + } > + > + pif_sockaddr(c, &udp_splice_to, &sl, topif, > + &toside->eaddr, toside->eport); > > - udp_splice_send(c, 0, n, tosidx); > + sendmmsg(to_s, udp_mh_splice, n, MSG_NOSIGNAL); > } > > /** -- Stefano