public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Stefan Metzmacher <metze@samba.org>
To: io-uring@vger.kernel.org
Cc: metze@samba.org, Jens Axboe <axboe@kernel.dk>,
	"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>,
	Kuniyuki Iwashima <kuniyu@google.com>,
	Willem de Bruijn <willemb@google.com>,
	netdev@vger.kernel.org, linux-cifs@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] io_uring/net: wire up support for sk->sk_prot->uring_cmd() with SOCKET_URING_OP_PASSTHROUGH_FLAG
Date: Wed, 26 Nov 2025 12:19:31 +0100	[thread overview]
Message-ID: <20251126111931.1788970-1-metze@samba.org> (raw)

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


             reply	other threads:[~2025-11-26 11:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26 11:19 Stefan Metzmacher [this message]
2025-11-26 22:19 ` [PATCH] io_uring/net: wire up support for sk->sk_prot->uring_cmd() with SOCKET_URING_OP_PASSTHROUGH_FLAG Jens Axboe
2025-11-27 10:00   ` Stefan Metzmacher

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=20251126111931.1788970-1-metze@samba.org \
    --to=metze@samba.org \
    --cc=axboe@kernel.dk \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=io-uring@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@google.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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