mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] vsock: Fix SO_ZEROCOPY on accept()ed vsocks
@ 2025-12-29 19:43 Michal Luczaj
  2025-12-29 19:43 ` [PATCH net v2 1/2] vsock: Make accept()ed sockets use custom setsockopt() Michal Luczaj
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Michal Luczaj @ 2025-12-29 19:43 UTC (permalink / raw)
  To: Stefano Garzarella, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Arseniy Krasnov
  Cc: virtualization, netdev, linux-kernel, Michal Luczaj

vsock has its own handling of setsockopt(SO_ZEROCOPY). Which works just
fine unless socket comes from a call to accept(). Because
SOCK_CUSTOM_SOCKOPT flag is missing, attempting to set the option always
results in errno EOPNOTSUPP.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
Changes in v2:
- Fix: set socket flags in a consistent way [Stefano]
- Test: simplify sync by removing sync [Stefano]
- Link to v1: https://lore.kernel.org/r/20251223-vsock-child-sock-custom-sockopt-v1-0-4654a75d0f58@rbox.co

---
Michal Luczaj (2):
      vsock: Make accept()ed sockets use custom setsockopt()
      vsock/test: Test setting SO_ZEROCOPY on accept()ed socket

 net/vmw_vsock/af_vsock.c         |  4 ++++
 tools/testing/vsock/vsock_test.c | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+)
---
base-commit: 58fc7342b529803d3c221101102fe913df7adb83
change-id: 20251222-vsock-child-sock-custom-sockopt-23b779c30c8f

Best regards,
-- 
Michal Luczaj <mhal@rbox.co>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net v2 1/2] vsock: Make accept()ed sockets use custom setsockopt()
  2025-12-29 19:43 [PATCH net v2 0/2] vsock: Fix SO_ZEROCOPY on accept()ed vsocks Michal Luczaj
@ 2025-12-29 19:43 ` Michal Luczaj
  2025-12-29 19:43 ` [PATCH net v2 2/2] vsock/test: Test setting SO_ZEROCOPY on accept()ed socket Michal Luczaj
  2026-01-06  0:20 ` [PATCH net v2 0/2] vsock: Fix SO_ZEROCOPY on accept()ed vsocks patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Luczaj @ 2025-12-29 19:43 UTC (permalink / raw)
  To: Stefano Garzarella, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Arseniy Krasnov
  Cc: virtualization, netdev, linux-kernel, Michal Luczaj

SO_ZEROCOPY handling in vsock_connectible_setsockopt() does not get called
on accept()ed sockets due to a missing flag. Flip it.

Fixes: e0718bd82e27 ("vsock: enable setting SO_ZEROCOPY")
Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
 net/vmw_vsock/af_vsock.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index adcba1b7bf74..a3505a4dcee0 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1787,6 +1787,10 @@ static int vsock_accept(struct socket *sock, struct socket *newsock,
 		} else {
 			newsock->state = SS_CONNECTED;
 			sock_graft(connected, newsock);
+
+			set_bit(SOCK_CUSTOM_SOCKOPT,
+				&connected->sk_socket->flags);
+
 			if (vsock_msgzerocopy_allow(vconnected->transport))
 				set_bit(SOCK_SUPPORT_ZC,
 					&connected->sk_socket->flags);

-- 
2.52.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net v2 2/2] vsock/test: Test setting SO_ZEROCOPY on accept()ed socket
  2025-12-29 19:43 [PATCH net v2 0/2] vsock: Fix SO_ZEROCOPY on accept()ed vsocks Michal Luczaj
  2025-12-29 19:43 ` [PATCH net v2 1/2] vsock: Make accept()ed sockets use custom setsockopt() Michal Luczaj
@ 2025-12-29 19:43 ` Michal Luczaj
  2026-01-06  0:20 ` [PATCH net v2 0/2] vsock: Fix SO_ZEROCOPY on accept()ed vsocks patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Michal Luczaj @ 2025-12-29 19:43 UTC (permalink / raw)
  To: Stefano Garzarella, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Arseniy Krasnov
  Cc: virtualization, netdev, linux-kernel, Michal Luczaj

Make sure setsockopt(SOL_SOCKET, SO_ZEROCOPY) on an accept()ed socket is
handled by vsock's implementation.

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
 tools/testing/vsock/vsock_test.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c
index 9e1250790f33..bbe3723babdc 100644
--- a/tools/testing/vsock/vsock_test.c
+++ b/tools/testing/vsock/vsock_test.c
@@ -2192,6 +2192,33 @@ static void test_stream_nolinger_server(const struct test_opts *opts)
 	close(fd);
 }
 
+static void test_stream_accepted_setsockopt_client(const struct test_opts *opts)
+{
+	int fd;
+
+	fd = vsock_stream_connect(opts->peer_cid, opts->peer_port);
+	if (fd < 0) {
+		perror("connect");
+		exit(EXIT_FAILURE);
+	}
+
+	close(fd);
+}
+
+static void test_stream_accepted_setsockopt_server(const struct test_opts *opts)
+{
+	int fd;
+
+	fd = vsock_stream_accept(VMADDR_CID_ANY, opts->peer_port, NULL);
+	if (fd < 0) {
+		perror("accept");
+		exit(EXIT_FAILURE);
+	}
+
+	enable_so_zerocopy_check(fd);
+	close(fd);
+}
+
 static struct test_case test_cases[] = {
 	{
 		.name = "SOCK_STREAM connection reset",
@@ -2371,6 +2398,11 @@ static struct test_case test_cases[] = {
 		.run_client = test_seqpacket_unread_bytes_client,
 		.run_server = test_seqpacket_unread_bytes_server,
 	},
+	{
+		.name = "SOCK_STREAM accept()ed socket custom setsockopt()",
+		.run_client = test_stream_accepted_setsockopt_client,
+		.run_server = test_stream_accepted_setsockopt_server,
+	},
 	{},
 };
 

-- 
2.52.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v2 0/2] vsock: Fix SO_ZEROCOPY on accept()ed vsocks
  2025-12-29 19:43 [PATCH net v2 0/2] vsock: Fix SO_ZEROCOPY on accept()ed vsocks Michal Luczaj
  2025-12-29 19:43 ` [PATCH net v2 1/2] vsock: Make accept()ed sockets use custom setsockopt() Michal Luczaj
  2025-12-29 19:43 ` [PATCH net v2 2/2] vsock/test: Test setting SO_ZEROCOPY on accept()ed socket Michal Luczaj
@ 2026-01-06  0:20 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-06  0:20 UTC (permalink / raw)
  To: Michal Luczaj
  Cc: sgarzare, davem, edumazet, kuba, pabeni, horms, avkrasnov,
	virtualization, netdev, linux-kernel

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 29 Dec 2025 20:43:09 +0100 you wrote:
> vsock has its own handling of setsockopt(SO_ZEROCOPY). Which works just
> fine unless socket comes from a call to accept(). Because
> SOCK_CUSTOM_SOCKOPT flag is missing, attempting to set the option always
> results in errno EOPNOTSUPP.
> 
> Signed-off-by: Michal Luczaj <mhal@rbox.co>
> 
> [...]

Here is the summary with links:
  - [net,v2,1/2] vsock: Make accept()ed sockets use custom setsockopt()
    https://git.kernel.org/netdev/net/c/ce5e612dd411
  - [net,v2,2/2] vsock/test: Test setting SO_ZEROCOPY on accept()ed socket
    https://git.kernel.org/netdev/net/c/caa20e9e155b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-06  0:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-29 19:43 [PATCH net v2 0/2] vsock: Fix SO_ZEROCOPY on accept()ed vsocks Michal Luczaj
2025-12-29 19:43 ` [PATCH net v2 1/2] vsock: Make accept()ed sockets use custom setsockopt() Michal Luczaj
2025-12-29 19:43 ` [PATCH net v2 2/2] vsock/test: Test setting SO_ZEROCOPY on accept()ed socket Michal Luczaj
2026-01-06  0:20 ` [PATCH net v2 0/2] vsock: Fix SO_ZEROCOPY on accept()ed vsocks patchwork-bot+netdevbpf

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®