Message ID | 20230808134049.1407498-5-leitao@debian.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | io_uring: Initial support for {s,g}etsockopt commands | expand |
Context | Check | Description |
---|---|---|
netdev/tree_selection | success | Guessing tree name failed - patch did not apply |
bpf/vmtest-bpf-PR | success | PR summary |
bpf/vmtest-bpf-VM_Test-1 | success | Logs for ShellCheck |
bpf/vmtest-bpf-VM_Test-2 | success | Logs for build for aarch64 with gcc |
bpf/vmtest-bpf-VM_Test-3 | pending | Logs for build for s390x with gcc |
bpf/vmtest-bpf-VM_Test-4 | success | Logs for build for x86_64 with gcc |
bpf/vmtest-bpf-VM_Test-5 | success | Logs for build for x86_64 with llvm-16 |
bpf/vmtest-bpf-VM_Test-6 | success | Logs for set-matrix |
Breno Leitao <leitao@debian.org> writes: > Add generic support for SOCKET_URING_OP_SETSOCKOPT, expanding the > current case, that just execute if level is SOL_SOCKET. > > This implementation basically calls sock->ops->setsockopt() with a > kernel allocated optval; > > Since the callback for ops->setsockopt() is already using sockptr_t, > then the callbacks are leveraged to be called directly, similarly to > __sys_setsockopt(). > > Signed-off-by: Breno Leitao <leitao@debian.org> > --- > io_uring/uring_cmd.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c > index 5404b788ca14..dbba005a7290 100644 > --- a/io_uring/uring_cmd.c > +++ b/io_uring/uring_cmd.c > @@ -205,10 +205,14 @@ static inline int io_uring_cmd_setsockopt(struct socket *sock, > if (err) > return err; > > - err = -EOPNOTSUPP; > if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) > err = sock_setsockopt(sock, level, optname, > USER_SOCKPTR(optval), optlen); > + else if (unlikely(!sock->ops->setsockopt)) > + err = -EOPNOTSUPP; > + else > + err = sock->ops->setsockopt(sock, level, optname, > + USER_SOCKPTR(koptval), optlen); Perhaps move this logic into a helper in net/ so io_uring doesn't need to know details of struct socket and there is no duplication of this code in __sys_getsockopt. > return err; > }
diff --git a/io_uring/uring_cmd.c b/io_uring/uring_cmd.c index 5404b788ca14..dbba005a7290 100644 --- a/io_uring/uring_cmd.c +++ b/io_uring/uring_cmd.c @@ -205,10 +205,14 @@ static inline int io_uring_cmd_setsockopt(struct socket *sock, if (err) return err; - err = -EOPNOTSUPP; if (level == SOL_SOCKET && !sock_use_custom_sol_socket(sock)) err = sock_setsockopt(sock, level, optname, USER_SOCKPTR(optval), optlen); + else if (unlikely(!sock->ops->setsockopt)) + err = -EOPNOTSUPP; + else + err = sock->ops->setsockopt(sock, level, optname, + USER_SOCKPTR(koptval), optlen); return err; }
Add generic support for SOCKET_URING_OP_SETSOCKOPT, expanding the current case, that just execute if level is SOL_SOCKET. This implementation basically calls sock->ops->setsockopt() with a kernel allocated optval; Since the callback for ops->setsockopt() is already using sockptr_t, then the callbacks are leveraged to be called directly, similarly to __sys_setsockopt(). Signed-off-by: Breno Leitao <leitao@debian.org> --- io_uring/uring_cmd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)