io_uring/cmd_net: split ioctl code out of io_uring_cmd_sock()
PATCH 1/1 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.
---
Jens, I'm used to net -> net-next taking a week, as it only happens through Linus' tree.
io_uring/cmd_net.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-)
io_uring/cmd_net.c +17 -17
@@ -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 :
base-commit: d7861b7cd05a4c02dfa8015048be6821a1af7c5a
Signature · 1 line
2.51.0
Jens Axboe
maintainerQuoted 11 lines · Asbjørn Sloth Tønnesen
io_uring_cmd_sock()originally supported two ioctl-basedcmd_opoperations. 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, reducingio_uring_cmd_sock()to a simple dispatcher.
Quoted 5 lines
Signed-off-by Asbjørn Sloth Tønnesen <[email protected]>---
Jens, I'm used to net -> net-next taking a week, as it only happens through Linus' tree.
Looks good to me - since this is just a cleanup, let's defer to 7.1. I'll kick that off in a week or so, at which point I'll pick this one up too.
Signature · 1 line
Jens Axboe
Quoted 15 lines · Jens Axboe
Quoted 14 lines · Asbjørn Sloth Tønnesen
io_uring_cmd_sock()originally supported two ioctl-basedcmd_opoperations. 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, reducingio_uring_cmd_sock()to a simple dispatcher.Signed-off-by Asbjørn Sloth Tønnesen <[email protected]>---
Quoted 6 lines
Quoted 2 lines
Jens, I'm used to net -> net-next taking a week, as it only happens through Linus' tree.
Looks good to me - since this is just a cleanup, let's defer to 7.1. I'll kick that off in a week or so, at which point I'll pick this one up too.
Thank you, and sorry for posting during the merge window, I always intended this for 7.1. I just took it as an invite that you merged into for-next right after committing my fix to io_uring-7.0, given what I wrote earlier in the RFC: "I plan to submit v1 once that patch propagates to for-next.". I wasn't expecting it to happen that quickly.
Jens Axboe
maintainerQuoted 23 lines · Asbj?rn Sloth T?nnesen
Quoted 15 lines · Jens Axboe
Quoted 14 lines · Asbj?rn Sloth T?nnesen
io_uring_cmd_sock()originally supported two ioctl-basedcmd_opoperations. 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, reducingio_uring_cmd_sock()to a simple dispatcher.Signed-off-by Asbj?rn Sloth T?nnesen <[email protected]>---
Quoted 6 lines
Quoted 2 lines
Jens, I'm used to net -> net-next taking a week, as it only happens through Linus' tree.
Looks good to me - since this is just a cleanup, let's defer to 7.1. I'll kick that off in a week or so, at which point I'll pick this one up too.
Quoted 5 lines
Thank you, and sorry for posting during the merge window, I always intended this for 7.1. I just took it as an invite that you merged into for-next right after committing my fix to io_uring-7.0, given what I wrote earlier in the RFC: "I plan to submit v1 once that patch propagates to for-next.". I wasn't expecting it to happen that quickly.
I do it a bit differently than netdev - my for-next is everything queued for this release, and the next. You don't need to resend patch headed for 7.1, unless I for some reason forget to merge it... But I tend to try and tag these things so I don't forget them. It's a bit easier post -rc1/2 time as the for-7.x/io_uring branch does exist already and it can just go straight there.
Signature · 1 line
Jens Axboe
Quoted 8 lines · Asbjørn Sloth Tønnesen
io_uring_cmd_sock()originally supported two ioctl-basedcmd_opoperations. 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.
[...]
Applied, thanks!
[1/1] io_uring/cmd_net: split ioctl code out of io_uring_cmd_sock()
commit: 4148bacb19a84ae2c420d13ad1f4d77981974ba8
Best regards,
Signature · 1 line
Jens Axboe