public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] io_uring/net: wire up support for sk->sk_prot->uring_cmd() with SOCKET_URING_OP_PASSTHROUGH_FLAG
@ 2025-11-26 11:19 Stefan Metzmacher
  2025-11-26 22:19 ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Metzmacher @ 2025-11-26 11:19 UTC (permalink / raw)
  To: io-uring
  Cc: metze, Jens Axboe, David S . Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Kuniyuki Iwashima, Willem de Bruijn,
	netdev, linux-cifs, linux-kernel

This will allow network protocols to implement async operations
instead of using ioctl() syscalls.

By using the high bit there's more than enough room for generic
calls to be added, but also more than enough for protocols to
implement their own specific opcodes.

The IPPROTO_SMBDIRECT socket layer [1] I'm currently working on,
will use this in future in order to let Samba use efficient RDMA offload.

[1]
https://git.samba.org/?p=metze/linux/wip.git;a=shortlog;h=refs/heads/master-ipproto-smbdirect

Cc: Jens Axboe <axboe@kernel.dk>
Cc: David S. Miller <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Kuniyuki Iwashima <kuniyu@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Cc: io-uring@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: linux-cifs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Stefan Metzmacher <metze@samba.org>

---

This is based on for-6.19/io_uring + the 3
"Introduce getsockname io_uring_cmd" patches from
https://lore.kernel.org/io-uring/20251125211806.2673912-1-krisman@suse.de/
as the addition of SOCKET_URING_OP_GETSOCKNAME would
conflict with the addition of SOCKET_URING_OP_PASSTHROUGH_FLAG
---
 include/net/sock.h            | 4 ++++
 include/uapi/linux/io_uring.h | 7 +++++++
 io_uring/cmd_net.c            | 2 ++
 3 files changed, 13 insertions(+)

diff --git a/include/net/sock.h b/include/net/sock.h
index 60bcb13f045c..ffcee4792589 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -98,6 +98,7 @@ typedef struct {
 struct sock;
 struct proto;
 struct net;
+struct io_uring_cmd;
 
 typedef __u32 __bitwise __portpair;
 typedef __u64 __bitwise __addrpair;
@@ -1272,6 +1273,9 @@ struct proto {
 
 	int			(*ioctl)(struct sock *sk, int cmd,
 					 int *karg);
+	int			(*uring_cmd)(struct sock *sk,
+					struct io_uring_cmd *ioucmd,
+					unsigned int issue_flags);
 	int			(*init)(struct sock *sk);
 	void			(*destroy)(struct sock *sk);
 	void			(*shutdown)(struct sock *sk, int how);
diff --git a/include/uapi/linux/io_uring.h b/include/uapi/linux/io_uring.h
index b5b23c0d5283..62ce6cb7d145 100644
--- a/include/uapi/linux/io_uring.h
+++ b/include/uapi/linux/io_uring.h
@@ -1010,6 +1010,13 @@ enum io_uring_socket_op {
 	SOCKET_URING_OP_SETSOCKOPT,
 	SOCKET_URING_OP_TX_TIMESTAMP,
 	SOCKET_URING_OP_GETSOCKNAME,
+
+	/*
+	 * This lets the sk->sk_prot->uring_cmd()
+	 * handle it, giving it enough space for
+	 * custom opcodes.
+	 */
+	SOCKET_URING_OP_PASSTHROUGH_FLAG = 0x80000000
 };
 
 /*
diff --git a/io_uring/cmd_net.c b/io_uring/cmd_net.c
index 5d11caf5509c..964f1764fa67 100644
--- a/io_uring/cmd_net.c
+++ b/io_uring/cmd_net.c
@@ -182,6 +182,8 @@ int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags)
 	case SOCKET_URING_OP_GETSOCKNAME:
 		return io_uring_cmd_getsockname(sock, cmd, issue_flags);
 	default:
+		if (cmd->cmd_op & SOCKET_URING_OP_PASSTHROUGH_FLAG && prot->uring_cmd)
+			return prot->uring_cmd(sk, cmd, issue_flags);
 		return -EOPNOTSUPP;
 	}
 }
-- 
2.43.0


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

* Re: [PATCH] io_uring/net: wire up support for sk->sk_prot->uring_cmd() with SOCKET_URING_OP_PASSTHROUGH_FLAG
  2025-11-26 11:19 [PATCH] io_uring/net: wire up support for sk->sk_prot->uring_cmd() with SOCKET_URING_OP_PASSTHROUGH_FLAG Stefan Metzmacher
@ 2025-11-26 22:19 ` Jens Axboe
  2025-11-27 10:00   ` Stefan Metzmacher
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2025-11-26 22:19 UTC (permalink / raw)
  To: Stefan Metzmacher, io-uring
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Kuniyuki Iwashima, Willem de Bruijn, netdev,
	linux-cifs, linux-kernel

On 11/26/25 4:19 AM, Stefan Metzmacher wrote:
> This will allow network protocols to implement async operations
> instead of using ioctl() syscalls.
> 
> By using the high bit there's more than enough room for generic
> calls to be added, but also more than enough for protocols to
> implement their own specific opcodes.
> 
> The IPPROTO_SMBDIRECT socket layer [1] I'm currently working on,
> will use this in future in order to let Samba use efficient RDMA offload.

Patch looks fine to me, but I think it needs to be submitted with an
actual user of it too. If not, then it's just unused infrastructure...

> [1]
> https://git.samba.org/?p=metze/linux/wip.git;a=shortlog;h=refs/heads/master-ipproto-smbdirect

This looks interesting, however!

-- 
Jens Axboe


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

* Re: [PATCH] io_uring/net: wire up support for sk->sk_prot->uring_cmd() with SOCKET_URING_OP_PASSTHROUGH_FLAG
  2025-11-26 22:19 ` Jens Axboe
@ 2025-11-27 10:00   ` Stefan Metzmacher
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Metzmacher @ 2025-11-27 10:00 UTC (permalink / raw)
  To: Jens Axboe, io-uring
  Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Simon Horman, Kuniyuki Iwashima, Willem de Bruijn, netdev,
	linux-cifs, linux-kernel

Am 26.11.25 um 23:19 schrieb Jens Axboe:
> On 11/26/25 4:19 AM, Stefan Metzmacher wrote:
>> This will allow network protocols to implement async operations
>> instead of using ioctl() syscalls.
>>
>> By using the high bit there's more than enough room for generic
>> calls to be added, but also more than enough for protocols to
>> implement their own specific opcodes.
>>
>> The IPPROTO_SMBDIRECT socket layer [1] I'm currently working on,
>> will use this in future in order to let Samba use efficient RDMA offload.
> 
> Patch looks fine to me, but I think it needs to be submitted with an
> actual user of it too. If not, then it's just unused infrastructure...
> 
>> [1]
>> https://git.samba.org/?p=metze/linux/wip.git;a=shortlog;h=refs/heads/master-ipproto-smbdirect

Ok, thanks for the feedback, I'll resubmit once I'm ready to use it.

metze


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

end of thread, other threads:[~2025-11-27 10:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-26 11:19 [PATCH] io_uring/net: wire up support for sk->sk_prot->uring_cmd() with SOCKET_URING_OP_PASSTHROUGH_FLAG Stefan Metzmacher
2025-11-26 22:19 ` Jens Axboe
2025-11-27 10:00   ` Stefan Metzmacher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox