mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 09:16:33 +00:00
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>
This commit is contained in:
parent
92ef0fd55a
commit
0645fbe760
@ -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,
|
||||
|
@ -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 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags)
|
||||
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)
|
||||
|
12
net/socket.c
12
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 @@ struct file *do_accept(struct file *file, unsigned file_flags,
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user