Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

io_uring/cmd_net: split ioctl code out of io_uring_cmd_sock()

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>

authored by

Asbjørn Sloth Tønnesen and committed by
Jens Axboe
bdb489ad 1f318b96

+17 -17
+17 -17
io_uring/cmd_net.c
··· 7 7 #include "uring_cmd.h" 8 8 #include "io_uring.h" 9 9 10 + static int io_uring_cmd_get_sock_ioctl(struct socket *sock, int op) 11 + { 12 + struct sock *sk = sock->sk; 13 + struct proto *prot = READ_ONCE(sk->sk_prot); 14 + int ret, arg = 0; 15 + 16 + if (!prot || !prot->ioctl) 17 + return -EOPNOTSUPP; 18 + 19 + ret = prot->ioctl(sk, op, &arg); 20 + if (ret) 21 + return ret; 22 + return arg; 23 + } 24 + 10 25 static inline int io_uring_cmd_getsockopt(struct socket *sock, 11 26 struct io_uring_cmd *cmd, 12 27 unsigned int issue_flags) ··· 171 156 int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags) 172 157 { 173 158 struct socket *sock = cmd->file->private_data; 174 - struct sock *sk = sock->sk; 175 - struct proto *prot = READ_ONCE(sk->sk_prot); 176 - int ret, arg = 0; 177 159 178 160 switch (cmd->cmd_op) { 179 161 case SOCKET_URING_OP_SIOCINQ: 180 - if (!prot || !prot->ioctl) 181 - return -EOPNOTSUPP; 182 - 183 - ret = prot->ioctl(sk, SIOCINQ, &arg); 184 - if (ret) 185 - return ret; 186 - return arg; 162 + return io_uring_cmd_get_sock_ioctl(sock, SIOCINQ); 187 163 case SOCKET_URING_OP_SIOCOUTQ: 188 - if (!prot || !prot->ioctl) 189 - return -EOPNOTSUPP; 190 - 191 - ret = prot->ioctl(sk, SIOCOUTQ, &arg); 192 - if (ret) 193 - return ret; 194 - return arg; 164 + return io_uring_cmd_get_sock_ioctl(sock, SIOCOUTQ); 195 165 case SOCKET_URING_OP_GETSOCKOPT: 196 166 return io_uring_cmd_getsockopt(sock, cmd, issue_flags); 197 167 case SOCKET_URING_OP_SETSOCKOPT: