mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Damato <joe@dama.to>
To: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: andrew+netdev@lunn.ch, willemb@google.com,
	linux-kselftest@vger.kernel.org, Joe Damato <joe@dama.to>,
	linux-kernel@vger.kernel.org
Subject: [PATCH net-next 3/5] selftests/net: psock_snd: unify on recvmsg()
Date: Tue, 28 Jul 2026 09:09:28 -0700	[thread overview]
Message-ID: <20260728160935.4128982-4-joe@dama.to> (raw)
In-Reply-To: <20260728160935.4128982-1-joe@dama.to>

Don't maintain two RX paths in do_rx(). Unify on recvmsg() and pass aux
data only when needed.

No functional change.

Signed-off-by: Joe Damato <joe@dama.to>
---
 tools/testing/selftests/net/psock_snd.c | 28 ++++++++++---------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/tools/testing/selftests/net/psock_snd.c b/tools/testing/selftests/net/psock_snd.c
index d506ea19491b..b2593daca603 100644
--- a/tools/testing/selftests/net/psock_snd.c
+++ b/tools/testing/selftests/net/psock_snd.c
@@ -314,25 +314,22 @@ static void do_rx(int fd, int expected_len, char *expected, bool is_psock)
 {
 	char cmsg_buf[1024] __attribute__((aligned(8))) = {};
 	bool aux = is_psock && cfg_aux_data;
-	struct msghdr msg = {};
-	struct iovec iov[1];
+	struct iovec iov = {
+		.iov_base = rbuf,
+		.iov_len = sizeof(rbuf),
+	};
+	struct msghdr msg = {
+		.msg_iov = &iov,
+		.msg_iovlen = 1,
+	};
 	int ret;
 
 	if (aux) {
-		iov[0].iov_base = rbuf;
-		iov[0].iov_len = sizeof(rbuf);
-
-		msg.msg_iov = iov;
-		msg.msg_iovlen = 1;
-
 		msg.msg_control = cmsg_buf;
 		msg.msg_controllen = sizeof(cmsg_buf);
-
-		ret = recvmsg(fd, &msg, 0);
-	} else {
-		ret = recv(fd, rbuf, sizeof(rbuf), 0);
 	}
 
+	ret = recvmsg(fd, &msg, 0);
 	if (ret == -1)
 		error(1, errno, "recv");
 	if (ret != expected_len)
@@ -341,11 +338,8 @@ static void do_rx(int fd, int expected_len, char *expected, bool is_psock)
 	if (memcmp(rbuf, expected, ret))
 		error(1, 0, "recv: data mismatch");
 
-	if (aux) {
-		struct cmsghdr *cmsg = CMSG_FIRSTHDR(&msg);
-
-		check_aux_data(cmsg, expected_len);
-	}
+	if (aux)
+		check_aux_data(CMSG_FIRSTHDR(&msg), expected_len);
 
 	fprintf(stderr, "rx: %u\n", ret);
 }
-- 
2.53.0-Meta


  parent reply	other threads:[~2026-07-28 16:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-28 16:09 [PATCH net-next 0/5] Add PACKET_IGNORE_OUTGOING selftest for packet sockets Joe Damato
2026-07-28 16:09 ` [PATCH net-next 1/5] selftests/net: psock: Generalize psock bind Joe Damato
2026-07-29  7:49   ` Willem de Bruijn
2026-07-28 16:09 ` [PATCH net-next 2/5] selftests/net: psock: Generalize stats check Joe Damato
2026-07-29  7:49   ` Willem de Bruijn
2026-07-28 16:09 ` Joe Damato [this message]
2026-07-29  7:50   ` [PATCH net-next 3/5] selftests/net: psock_snd: unify on recvmsg() Willem de Bruijn
2026-07-28 16:09 ` [PATCH net-next 4/5] selftests/net: psock_snd: Verify sll_pkttype Joe Damato
2026-07-29  7:50   ` Willem de Bruijn
2026-07-29  7:50   ` Willem de Bruijn
2026-07-28 16:09 ` [PATCH net-next 5/5] selftests/net: test PACKET_IGNORE_OUTGOING Joe Damato
2026-07-30  0:10 ` [PATCH net-next 0/5] Add PACKET_IGNORE_OUTGOING selftest for packet sockets patchwork-bot+netdevbpf

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=20260728160935.4128982-4-joe@dama.to \
    --to=joe@dama.to \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=shuah@kernel.org \
    --cc=willemb@google.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®