public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
From: Stefano Brivio <sbrivio@redhat.com>
To: passt-dev@passt.top
Subject: [PATCH 07/24] udp: Drop _splice from recv, send, sendto static buffer names
Date: Fri, 25 Mar 2022 23:52:43 +0100	[thread overview]
Message-ID: <20220325225300.2803584-8-sbrivio@redhat.com> (raw)
In-Reply-To: <20220325225300.2803584-1-sbrivio@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 5041 bytes --]

It's already implied by the fact they don't have "l2" in their
names, and dropping it improves readability a bit.

Signed-off-by: Stefano Brivio <sbrivio(a)redhat.com>
---
 udp.c | 52 +++++++++++++++++++++++-----------------------------
 1 file changed, 23 insertions(+), 29 deletions(-)

diff --git a/udp.c b/udp.c
index ccce005..ce536a6 100644
--- a/udp.c
+++ b/udp.c
@@ -254,14 +254,14 @@ static struct mmsghdr	udp4_l2_mh_tap		[UDP_TAP_FRAMES_MEM];
 static struct mmsghdr	udp6_l2_mh_tap		[UDP_TAP_FRAMES_MEM];
 
 /* recvmmsg()/sendmmsg() data for "spliced" connections */
-static struct iovec	udp_splice_iov_recv	[UDP_SPLICE_FRAMES];
-static struct mmsghdr	udp_splice_mmh_recv	[UDP_SPLICE_FRAMES];
+static struct iovec	udp_iov_recv		[UDP_SPLICE_FRAMES];
+static struct mmsghdr	udp_mmh_recv		[UDP_SPLICE_FRAMES];
 
-static struct iovec	udp_splice_iov_send	[UDP_SPLICE_FRAMES];
-static struct mmsghdr	udp_splice_mmh_send	[UDP_SPLICE_FRAMES];
+static struct iovec	udp_iov_send		[UDP_SPLICE_FRAMES];
+static struct mmsghdr	udp_mmh_send		[UDP_SPLICE_FRAMES];
 
-static struct iovec	udp_splice_iov_sendto	[UDP_SPLICE_FRAMES];
-static struct mmsghdr	udp_splice_mmh_sendto	[UDP_SPLICE_FRAMES];
+static struct iovec	udp_iov_sendto		[UDP_SPLICE_FRAMES];
+static struct mmsghdr	udp_mmh_sendto		[UDP_SPLICE_FRAMES];
 
 /**
  * udp_remap_to_tap() - Set delta for port translation to/from guest/tap
@@ -552,14 +552,14 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref,
 				    uint32_t events, struct timespec *now)
 {
 	in_port_t src, dst = ref.r.p.udp.udp.port, send_dst = 0;
-	struct msghdr *mh = &udp_splice_mmh_recv[0].msg_hdr;
+	struct msghdr *mh = &udp_mmh_recv[0].msg_hdr;
 	struct sockaddr_storage *sa_s = mh->msg_name;
 	int s, v6 = ref.r.p.udp.udp.v6, n, i;
 
 	if (!(events & EPOLLIN))
 		return;
 
-	n = recvmmsg(ref.r.s, udp_splice_mmh_recv, UDP_SPLICE_FRAMES, 0, NULL);
+	n = recvmmsg(ref.r.s, udp_mmh_recv, UDP_SPLICE_FRAMES, 0, NULL);
 
 	if (n <= 0)
 		return;
@@ -619,19 +619,19 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref,
 	if (ref.r.p.udp.udp.splice == UDP_TO_NS ||
 	    ref.r.p.udp.udp.splice == UDP_TO_INIT) {
 		for (i = 0; i < n; i++) {
-			struct msghdr *mh_s = &udp_splice_mmh_send[i].msg_hdr;
+			struct msghdr *mh_s = &udp_mmh_send[i].msg_hdr;
 
-			mh_s->msg_iov->iov_len = udp_splice_mmh_recv[i].msg_len;
+			mh_s->msg_iov->iov_len = udp_mmh_recv[i].msg_len;
 		}
 
-		sendmmsg(s, udp_splice_mmh_send, n, MSG_NOSIGNAL);
+		sendmmsg(s, udp_mmh_send, n, MSG_NOSIGNAL);
 		return;
 	}
 
 	for (i = 0; i < n; i++) {
-		struct msghdr *mh_s = &udp_splice_mmh_sendto[i].msg_hdr;
+		struct msghdr *mh_s = &udp_mmh_sendto[i].msg_hdr;
 
-		mh_s->msg_iov->iov_len = udp_splice_mmh_recv[i].msg_len;
+		mh_s->msg_iov->iov_len = udp_mmh_recv[i].msg_len;
 	}
 
 	if (v6) {
@@ -652,7 +652,7 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref,
 		});
 	}
 
-	sendmmsg(s, udp_splice_mmh_sendto, n, MSG_NOSIGNAL);
+	sendmmsg(s, udp_mmh_sendto, n, MSG_NOSIGNAL);
 }
 
 /**
@@ -1097,7 +1097,7 @@ static void udp_splice_iov_init(void)
 	struct iovec *iov;
 	int i;
 
-	for (i = 0, h = udp_splice_mmh_recv; i < UDP_SPLICE_FRAMES; i++, h++) {
+	for (i = 0, h = udp_mmh_recv; i < UDP_SPLICE_FRAMES; i++, h++) {
 		struct msghdr *mh = &h->msg_hdr;
 
 		if (!i) {
@@ -1105,40 +1105,34 @@ static void udp_splice_iov_init(void)
 			mh->msg_namelen = sizeof(udp_splice_namebuf);
 		}
 
-		mh->msg_iov = &udp_splice_iov_recv[i];
+		mh->msg_iov = &udp_iov_recv[i];
 		mh->msg_iovlen = 1;
 	}
-	for (i = 0, iov = udp_splice_iov_recv; i < UDP_SPLICE_FRAMES;
-	     i++, iov++) {
+	for (i = 0, iov = udp_iov_recv; i < UDP_SPLICE_FRAMES; i++, iov++) {
 		iov->iov_base = udp_splice_buf[i];
 		iov->iov_len = sizeof(udp_splice_buf[i]);
 	}
 
-	for (i = 0, h = udp_splice_mmh_send; i < UDP_SPLICE_FRAMES; i++, h++) {
+	for (i = 0, h = udp_mmh_send; i < UDP_SPLICE_FRAMES; i++, h++) {
 		struct msghdr *mh = &h->msg_hdr;
 
-		mh->msg_iov = &udp_splice_iov_send[i];
+		mh->msg_iov = &udp_iov_send[i];
 		mh->msg_iovlen = 1;
 	}
-	for (i = 0, iov = udp_splice_iov_send; i < UDP_SPLICE_FRAMES;
-	     i++, iov++) {
+	for (i = 0, iov = udp_iov_send; i < UDP_SPLICE_FRAMES; i++, iov++)
 		iov->iov_base = udp_splice_buf[i];
-	}
 
-	for (i = 0, h = udp_splice_mmh_sendto; i < UDP_SPLICE_FRAMES;
-	     i++, h++) {
+	for (i = 0, h = udp_mmh_sendto; i < UDP_SPLICE_FRAMES; i++, h++) {
 		struct msghdr *mh = &h->msg_hdr;
 
 		mh->msg_name = &udp_splice_namebuf;
 		mh->msg_namelen = sizeof(udp_splice_namebuf);
 
-		mh->msg_iov = &udp_splice_iov_sendto[i];
+		mh->msg_iov = &udp_iov_sendto[i];
 		mh->msg_iovlen = 1;
 	}
-	for (i = 0, iov = udp_splice_iov_sendto; i < UDP_SPLICE_FRAMES;
-	     i++, iov++) {
+	for (i = 0, iov = udp_iov_sendto; i < UDP_SPLICE_FRAMES; i++, iov++)
 		iov->iov_base = udp_splice_buf[i];
-	}
 }
 
 /**
-- 
@@ -254,14 +254,14 @@ static struct mmsghdr	udp4_l2_mh_tap		[UDP_TAP_FRAMES_MEM];
 static struct mmsghdr	udp6_l2_mh_tap		[UDP_TAP_FRAMES_MEM];
 
 /* recvmmsg()/sendmmsg() data for "spliced" connections */
-static struct iovec	udp_splice_iov_recv	[UDP_SPLICE_FRAMES];
-static struct mmsghdr	udp_splice_mmh_recv	[UDP_SPLICE_FRAMES];
+static struct iovec	udp_iov_recv		[UDP_SPLICE_FRAMES];
+static struct mmsghdr	udp_mmh_recv		[UDP_SPLICE_FRAMES];
 
-static struct iovec	udp_splice_iov_send	[UDP_SPLICE_FRAMES];
-static struct mmsghdr	udp_splice_mmh_send	[UDP_SPLICE_FRAMES];
+static struct iovec	udp_iov_send		[UDP_SPLICE_FRAMES];
+static struct mmsghdr	udp_mmh_send		[UDP_SPLICE_FRAMES];
 
-static struct iovec	udp_splice_iov_sendto	[UDP_SPLICE_FRAMES];
-static struct mmsghdr	udp_splice_mmh_sendto	[UDP_SPLICE_FRAMES];
+static struct iovec	udp_iov_sendto		[UDP_SPLICE_FRAMES];
+static struct mmsghdr	udp_mmh_sendto		[UDP_SPLICE_FRAMES];
 
 /**
  * udp_remap_to_tap() - Set delta for port translation to/from guest/tap
@@ -552,14 +552,14 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref,
 				    uint32_t events, struct timespec *now)
 {
 	in_port_t src, dst = ref.r.p.udp.udp.port, send_dst = 0;
-	struct msghdr *mh = &udp_splice_mmh_recv[0].msg_hdr;
+	struct msghdr *mh = &udp_mmh_recv[0].msg_hdr;
 	struct sockaddr_storage *sa_s = mh->msg_name;
 	int s, v6 = ref.r.p.udp.udp.v6, n, i;
 
 	if (!(events & EPOLLIN))
 		return;
 
-	n = recvmmsg(ref.r.s, udp_splice_mmh_recv, UDP_SPLICE_FRAMES, 0, NULL);
+	n = recvmmsg(ref.r.s, udp_mmh_recv, UDP_SPLICE_FRAMES, 0, NULL);
 
 	if (n <= 0)
 		return;
@@ -619,19 +619,19 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref,
 	if (ref.r.p.udp.udp.splice == UDP_TO_NS ||
 	    ref.r.p.udp.udp.splice == UDP_TO_INIT) {
 		for (i = 0; i < n; i++) {
-			struct msghdr *mh_s = &udp_splice_mmh_send[i].msg_hdr;
+			struct msghdr *mh_s = &udp_mmh_send[i].msg_hdr;
 
-			mh_s->msg_iov->iov_len = udp_splice_mmh_recv[i].msg_len;
+			mh_s->msg_iov->iov_len = udp_mmh_recv[i].msg_len;
 		}
 
-		sendmmsg(s, udp_splice_mmh_send, n, MSG_NOSIGNAL);
+		sendmmsg(s, udp_mmh_send, n, MSG_NOSIGNAL);
 		return;
 	}
 
 	for (i = 0; i < n; i++) {
-		struct msghdr *mh_s = &udp_splice_mmh_sendto[i].msg_hdr;
+		struct msghdr *mh_s = &udp_mmh_sendto[i].msg_hdr;
 
-		mh_s->msg_iov->iov_len = udp_splice_mmh_recv[i].msg_len;
+		mh_s->msg_iov->iov_len = udp_mmh_recv[i].msg_len;
 	}
 
 	if (v6) {
@@ -652,7 +652,7 @@ static void udp_sock_handler_splice(struct ctx *c, union epoll_ref ref,
 		});
 	}
 
-	sendmmsg(s, udp_splice_mmh_sendto, n, MSG_NOSIGNAL);
+	sendmmsg(s, udp_mmh_sendto, n, MSG_NOSIGNAL);
 }
 
 /**
@@ -1097,7 +1097,7 @@ static void udp_splice_iov_init(void)
 	struct iovec *iov;
 	int i;
 
-	for (i = 0, h = udp_splice_mmh_recv; i < UDP_SPLICE_FRAMES; i++, h++) {
+	for (i = 0, h = udp_mmh_recv; i < UDP_SPLICE_FRAMES; i++, h++) {
 		struct msghdr *mh = &h->msg_hdr;
 
 		if (!i) {
@@ -1105,40 +1105,34 @@ static void udp_splice_iov_init(void)
 			mh->msg_namelen = sizeof(udp_splice_namebuf);
 		}
 
-		mh->msg_iov = &udp_splice_iov_recv[i];
+		mh->msg_iov = &udp_iov_recv[i];
 		mh->msg_iovlen = 1;
 	}
-	for (i = 0, iov = udp_splice_iov_recv; i < UDP_SPLICE_FRAMES;
-	     i++, iov++) {
+	for (i = 0, iov = udp_iov_recv; i < UDP_SPLICE_FRAMES; i++, iov++) {
 		iov->iov_base = udp_splice_buf[i];
 		iov->iov_len = sizeof(udp_splice_buf[i]);
 	}
 
-	for (i = 0, h = udp_splice_mmh_send; i < UDP_SPLICE_FRAMES; i++, h++) {
+	for (i = 0, h = udp_mmh_send; i < UDP_SPLICE_FRAMES; i++, h++) {
 		struct msghdr *mh = &h->msg_hdr;
 
-		mh->msg_iov = &udp_splice_iov_send[i];
+		mh->msg_iov = &udp_iov_send[i];
 		mh->msg_iovlen = 1;
 	}
-	for (i = 0, iov = udp_splice_iov_send; i < UDP_SPLICE_FRAMES;
-	     i++, iov++) {
+	for (i = 0, iov = udp_iov_send; i < UDP_SPLICE_FRAMES; i++, iov++)
 		iov->iov_base = udp_splice_buf[i];
-	}
 
-	for (i = 0, h = udp_splice_mmh_sendto; i < UDP_SPLICE_FRAMES;
-	     i++, h++) {
+	for (i = 0, h = udp_mmh_sendto; i < UDP_SPLICE_FRAMES; i++, h++) {
 		struct msghdr *mh = &h->msg_hdr;
 
 		mh->msg_name = &udp_splice_namebuf;
 		mh->msg_namelen = sizeof(udp_splice_namebuf);
 
-		mh->msg_iov = &udp_splice_iov_sendto[i];
+		mh->msg_iov = &udp_iov_sendto[i];
 		mh->msg_iovlen = 1;
 	}
-	for (i = 0, iov = udp_splice_iov_sendto; i < UDP_SPLICE_FRAMES;
-	     i++, iov++) {
+	for (i = 0, iov = udp_iov_sendto; i < UDP_SPLICE_FRAMES; i++, iov++)
 		iov->iov_base = udp_splice_buf[i];
-	}
 }
 
 /**
-- 
2.35.1


  parent reply	other threads:[~2022-03-25 22:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-25 22:52 [PATCH 00/24] Boundary-checked "packets", TCP timerfd timeouts, assorted fixes Stefano Brivio
2022-03-25 22:52 ` [PATCH 01/24] conf, util, tap: Implement --trace option for extra verbose logging Stefano Brivio
2022-03-25 22:52 ` [PATCH 02/24] pcap: Fix mistake in printed string Stefano Brivio
2022-03-25 22:52 ` [PATCH 03/24] util: Drop CHECK_SET_MIN_MAX{,_PROTO_FD} macros Stefano Brivio
2022-03-25 22:52 ` [PATCH 04/24] util: Use standard int types Stefano Brivio
2022-03-25 22:52 ` [PATCH 05/24] tcp: Refactor to use events instead of states, split out spliced implementation Stefano Brivio
2022-03-25 22:52 ` [PATCH 06/24] test/lib/video: Fill in href attributes of video shortcuts Stefano Brivio
2022-03-25 22:52 ` Stefano Brivio [this message]
2022-03-25 22:52 ` [PATCH 08/24] udp: Split buffer queueing/writing parts of udp_sock_handler() Stefano Brivio
2022-03-25 22:52 ` [PATCH 09/24] dhcpv6, tap, tcp: Use IN6_ARE_ADDR_EQUAL instead of open-coded memcmp() Stefano Brivio
2022-03-25 22:52 ` [PATCH 10/24] udp: Use flags for local, loopback, and configured unicast binds Stefano Brivio
2022-03-25 22:52 ` [PATCH 11/24] Makefile: Enable a few hardening flags Stefano Brivio
2022-03-25 22:52 ` [PATCH 12/24] test: Add asciinema(1) as requirement for CI in README Stefano Brivio
2022-03-25 22:52 ` [PATCH 13/24] test, seccomp, Makefile: Switch to valgrind runs for passt functional tests Stefano Brivio
2022-03-25 22:52 ` [PATCH 14/24] tcp, udp, util: Enforce 24-bit limit on socket numbers Stefano Brivio
2022-03-25 22:52 ` [PATCH 15/24] tcp: Rework timers to use timerfd instead of periodic bitmap scan Stefano Brivio
2022-03-25 22:52 ` [PATCH 16/24] tcp_splice: Close sockets right away on high number of open files Stefano Brivio
2022-03-25 22:52 ` [PATCH 17/24] test/perf: Work-around for virtio_net hang before long streams from guest Stefano Brivio
2022-03-25 22:52 ` [PATCH 18/24] README: Avoid "here" links Stefano Brivio
2022-03-25 22:52 ` [PATCH 19/24] README: Update Interfaces and Availability sections Stefano Brivio
2022-03-25 22:52 ` [PATCH 20/24] tcp: Fit struct tcp_conn into a single 64-byte cacheline Stefano Brivio
2022-03-25 22:52 ` [PATCH 21/24] dhcp: Minimum option length implied by RFC 951 is 60 bytes, not 62 Stefano Brivio
2022-03-25 22:52 ` [PATCH 22/24] tcp, tcp_splice: Use less awkward syntax to swap in/out sockets from pools Stefano Brivio
2022-03-25 22:52 ` [PATCH 23/24] util: Fix function declaration style of write_pidfile() Stefano Brivio
2022-03-25 22:53 ` [PATCH 24/24] treewide: Packet abstraction with mandatory boundary checks Stefano Brivio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220325225300.2803584-8-sbrivio@redhat.com \
    --to=sbrivio@redhat.com \
    --cc=passt-dev@passt.top \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).