diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-05-09 09:31:05 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-05-13 18:19:19 -0600 |
commit | 0645fbe760afcc5332c858d1cbf416bf77ef3c29 (patch) | |
tree | 98c6d89241b44bc3ce553580407268bbf2a78e25 | |
parent | 92ef0fd55ac80dfc2e4654edfe5d1ddfa6e070fe (diff) |
net: have do_accept() take a struct proto_accept_arg argument
In preparation for passing in more information via this API, change
do_accept() to take a proto_accept_arg struct pointer rather than just
the file flags separately.
No functional changes in this patch.
Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | include/linux/socket.h | 3 | ||||
-rw-r--r-- | io_uring/net.c | 6 | ||||
-rw-r--r-- | net/socket.c | 12 |
3 files changed, 11 insertions, 10 deletions
diff --git a/include/linux/socket.h b/include/linux/socket.h index 139c330ccf2c..89d16b90370b 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -16,6 +16,7 @@ struct cred; struct socket; struct sock; struct sk_buff; +struct proto_accept_arg; #define __sockaddr_check_size(size) \ BUILD_BUG_ON(((size) > sizeof(struct __kernel_sockaddr_storage))) @@ -433,7 +434,7 @@ extern int __sys_recvfrom(int fd, void __user *ubuf, size_t size, extern int __sys_sendto(int fd, void __user *buff, size_t len, unsigned int flags, struct sockaddr __user *addr, int addr_len); -extern struct file *do_accept(struct file *file, unsigned file_flags, +extern struct file *do_accept(struct file *file, struct proto_accept_arg *arg, struct sockaddr __user *upeer_sockaddr, int __user *upeer_addrlen, int flags); extern int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr, diff --git a/io_uring/net.c b/io_uring/net.c index 070dea9a4eda..d4d1fc93635c 100644 --- a/io_uring/net.c +++ b/io_uring/net.c @@ -1528,8 +1528,10 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags) { struct io_accept *accept = io_kiocb_to_cmd(req, struct io_accept); bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK; - unsigned int file_flags = force_nonblock ? O_NONBLOCK : 0; bool fixed = !!accept->file_slot; + struct proto_accept_arg arg = { + .flags = force_nonblock ? O_NONBLOCK : 0, + }; struct file *file; int ret, fd; @@ -1543,7 +1545,7 @@ retry: if (unlikely(fd < 0)) return fd; } - file = do_accept(req->file, file_flags, accept->addr, accept->addr_len, + file = do_accept(req->file, &arg, accept->addr, accept->addr_len, accept->flags); if (IS_ERR(file)) { if (!fixed) diff --git a/net/socket.c b/net/socket.c index 6ff5f21d9633..e416920e9399 100644 --- a/net/socket.c +++ b/net/socket.c @@ -1890,7 +1890,7 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog) return __sys_listen(fd, backlog); } -struct file *do_accept(struct file *file, unsigned file_flags, +struct file *do_accept(struct file *file, struct proto_accept_arg *arg, struct sockaddr __user *upeer_sockaddr, int __user *upeer_addrlen, int flags) { @@ -1898,9 +1898,6 @@ struct file *do_accept(struct file *file, unsigned file_flags, struct file *newfile; int err, len; struct sockaddr_storage address; - struct proto_accept_arg arg = { - .flags = file_flags, - }; const struct proto_ops *ops; sock = sock_from_file(file); @@ -1929,8 +1926,8 @@ struct file *do_accept(struct file *file, unsigned file_flags, if (err) goto out_fd; - arg.flags |= sock->file->f_flags; - err = ops->accept(sock, newsock, &arg); + arg->flags |= sock->file->f_flags; + err = ops->accept(sock, newsock, arg); if (err < 0) goto out_fd; @@ -1956,6 +1953,7 @@ out_fd: static int __sys_accept4_file(struct file *file, struct sockaddr __user *upeer_sockaddr, int __user *upeer_addrlen, int flags) { + struct proto_accept_arg arg = { }; struct file *newfile; int newfd; @@ -1969,7 +1967,7 @@ static int __sys_accept4_file(struct file *file, struct sockaddr __user *upeer_s if (unlikely(newfd < 0)) return newfd; - newfile = do_accept(file, 0, upeer_sockaddr, upeer_addrlen, + newfile = do_accept(file, &arg, upeer_sockaddr, upeer_addrlen, flags); if (IS_ERR(newfile)) { put_unused_fd(newfd); |