diff mbox series

[RFC,v5,09/17] vsock: enable SOCK_SUPPORT_ZC bit

Message ID 20230701063947.3422088-10-AVKrasnov@sberdevices.ru (mailing list archive)
State New, archived
Headers show
Series vsock: MSG_ZEROCOPY flag support | expand

Commit Message

Arseniy Krasnov July 1, 2023, 6:39 a.m. UTC
This bit is used by io_uring in case of zerocopy tx mode. io_uring code
checks, that socket has this feature. This patch sets it in two places:
1) For socket in 'connect()' call.
2) For new socket which is returned by 'accept()' call.

Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
---
 net/vmw_vsock/af_vsock.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Stefano Garzarella July 6, 2023, 4:55 p.m. UTC | #1
On Sat, Jul 01, 2023 at 09:39:39AM +0300, Arseniy Krasnov wrote:
>This bit is used by io_uring in case of zerocopy tx mode. io_uring code
>checks, that socket has this feature. This patch sets it in two places:
>1) For socket in 'connect()' call.
>2) For new socket which is returned by 'accept()' call.
>
>Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>---
> net/vmw_vsock/af_vsock.c | 6 ++++++
> 1 file changed, 6 insertions(+)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
>index 033006e1b5ad..da22ae0ef477 100644
>--- a/net/vmw_vsock/af_vsock.c
>+++ b/net/vmw_vsock/af_vsock.c
>@@ -1406,6 +1406,9 @@ static int vsock_connect(struct socket *sock, struct sockaddr *addr,
> 			goto out;
> 		}
>
>+		if (vsock_msgzerocopy_allow(transport))
>+			set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
>+
> 		err = vsock_auto_bind(vsk);
> 		if (err)
> 			goto out;
>@@ -1560,6 +1563,9 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags,
> 		} else {
> 			newsock->state = SS_CONNECTED;
> 			sock_graft(connected, newsock);
>+			if (vsock_msgzerocopy_allow(vconnected->transport))
>+				set_bit(SOCK_SUPPORT_ZC,
>+					&connected->sk_socket->flags);
> 		}
>
> 		release_sock(connected);
>-- 
>2.25.1
>
diff mbox series

Patch

diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
index 033006e1b5ad..da22ae0ef477 100644
--- a/net/vmw_vsock/af_vsock.c
+++ b/net/vmw_vsock/af_vsock.c
@@ -1406,6 +1406,9 @@  static int vsock_connect(struct socket *sock, struct sockaddr *addr,
 			goto out;
 		}
 
+		if (vsock_msgzerocopy_allow(transport))
+			set_bit(SOCK_SUPPORT_ZC, &sk->sk_socket->flags);
+
 		err = vsock_auto_bind(vsk);
 		if (err)
 			goto out;
@@ -1560,6 +1563,9 @@  static int vsock_accept(struct socket *sock, struct socket *newsock, int flags,
 		} else {
 			newsock->state = SS_CONNECTED;
 			sock_graft(connected, newsock);
+			if (vsock_msgzerocopy_allow(vconnected->transport))
+				set_bit(SOCK_SUPPORT_ZC,
+					&connected->sk_socket->flags);
 		}
 
 		release_sock(connected);