From: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>
To: Jens Axboe <axboe@kernel.dk>
Cc: "Asbjørn Sloth Tønnesen" <ast@fiberby.net>,
"Breno Leitao" <leitao@debian.org>,
"Gabriel Krisman Bertazi" <krisman@suse.de>,
io-uring@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH] io_uring/cmd_net: split ioctl code out of io_uring_cmd_sock()
Date: Mon, 16 Feb 2026 10:27:53 +0000 [thread overview]
Message-ID: <20260216-io-uring-rfc@fiberby.net> (raw)
io_uring_cmd_sock() originally supported two ioctl-based cmd_op
operations. Over time, additional operations were added with tail calls
to their helpers.
This approach resulted in the new operations sharing an ioctl check
with the original operations.
io_uring_cmd_sock() now supports 6 operations, so let's move the
implementation of the original two into their own helper, reducing
io_uring_cmd_sock() to a simple dispatcher.
Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net>
---
This RFC patch is targeting for-next, and applies on top of this
patch for master:
[PATCH] io_uring/cmd_net: fix too strict requirement on ioctl
https://lore.kernel.org/r/20260216-io-uring-fix@fiberby.net
I plan to submit v1 once that patch propagates to uring/for-next.
io_uring/cmd_net.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/io_uring/cmd_net.c b/io_uring/cmd_net.c
index 57ddaf874611..56696c4baad1 100644
--- a/io_uring/cmd_net.c
+++ b/io_uring/cmd_net.c
@@ -7,6 +7,21 @@
#include "uring_cmd.h"
#include "io_uring.h"
+static int io_uring_cmd_get_sock_ioctl(struct socket *sock, int op)
+{
+ struct sock *sk = sock->sk;
+ struct proto *prot = READ_ONCE(sk->sk_prot);
+ int ret, arg = 0;
+
+ if (!prot || !prot->ioctl)
+ return -EOPNOTSUPP;
+
+ ret = prot->ioctl(sk, op, &arg);
+ if (ret)
+ return ret;
+ return arg;
+}
+
static inline int io_uring_cmd_getsockopt(struct socket *sock,
struct io_uring_cmd *cmd,
unsigned int issue_flags)
@@ -156,27 +171,12 @@ static int io_uring_cmd_getsockname(struct socket *sock,
int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags)
{
struct socket *sock = cmd->file->private_data;
- struct sock *sk = sock->sk;
- struct proto *prot = READ_ONCE(sk->sk_prot);
- int ret, arg = 0;
switch (cmd->cmd_op) {
case SOCKET_URING_OP_SIOCINQ:
- if (!prot || !prot->ioctl)
- return -EOPNOTSUPP;
-
- ret = prot->ioctl(sk, SIOCINQ, &arg);
- if (ret)
- return ret;
- return arg;
+ return io_uring_cmd_get_sock_ioctl(sock, SIOCINQ);
case SOCKET_URING_OP_SIOCOUTQ:
- if (!prot || !prot->ioctl)
- return -EOPNOTSUPP;
-
- ret = prot->ioctl(sk, SIOCOUTQ, &arg);
- if (ret)
- return ret;
- return arg;
+ return io_uring_cmd_get_sock_ioctl(sock, SIOCOUTQ);
case SOCKET_URING_OP_GETSOCKOPT:
return io_uring_cmd_getsockopt(sock, cmd, issue_flags);
case SOCKET_URING_OP_SETSOCKOPT:
--
2.51.0
reply other threads:[~2026-02-16 10:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20260216-io-uring-rfc@fiberby.net \
--to=ast@fiberby.net \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
--cc=krisman@suse.de \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.