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 Cc: David S. Miller Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Simon Horman Cc: Kuniyuki Iwashima Cc: Willem de Bruijn 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 --- 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