]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
io_uring/cmd_net: split ioctl code out of io_uring_cmd_sock()
authorAsbjørn Sloth Tønnesen <ast@fiberby.net>
Mon, 16 Feb 2026 16:03:53 +0000 (16:03 +0000)
committerJens Axboe <axboe@kernel.dk>
Mon, 9 Mar 2026 13:21:53 +0000 (07:21 -0600)
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>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/cmd_net.c

index 125a81c520a6cb7b71af677bba5c8de0ff64f44d..7cd411fc4f33eb50004544732759ee2ebd0c6c83 100644 (file)
@@ -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: