Skip to content

Commit 0645fbe

Browse files
committed
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>
1 parent 92ef0fd commit 0645fbe

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

include/linux/socket.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ struct cred;
1616
struct socket;
1717
struct sock;
1818
struct sk_buff;
19+
struct proto_accept_arg;
1920

2021
#define __sockaddr_check_size(size) \
2122
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,
433434
extern int __sys_sendto(int fd, void __user *buff, size_t len,
434435
unsigned int flags, struct sockaddr __user *addr,
435436
int addr_len);
436-
extern struct file *do_accept(struct file *file, unsigned file_flags,
437+
extern struct file *do_accept(struct file *file, struct proto_accept_arg *arg,
437438
struct sockaddr __user *upeer_sockaddr,
438439
int __user *upeer_addrlen, int flags);
439440
extern int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr,

io_uring/net.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,8 +1528,10 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags)
15281528
{
15291529
struct io_accept *accept = io_kiocb_to_cmd(req, struct io_accept);
15301530
bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
1531-
unsigned int file_flags = force_nonblock ? O_NONBLOCK : 0;
15321531
bool fixed = !!accept->file_slot;
1532+
struct proto_accept_arg arg = {
1533+
.flags = force_nonblock ? O_NONBLOCK : 0,
1534+
};
15331535
struct file *file;
15341536
int ret, fd;
15351537

@@ -1543,7 +1545,7 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags)
15431545
if (unlikely(fd < 0))
15441546
return fd;
15451547
}
1546-
file = do_accept(req->file, file_flags, accept->addr, accept->addr_len,
1548+
file = do_accept(req->file, &arg, accept->addr, accept->addr_len,
15471549
accept->flags);
15481550
if (IS_ERR(file)) {
15491551
if (!fixed)

net/socket.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,17 +1890,14 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
18901890
return __sys_listen(fd, backlog);
18911891
}
18921892

1893-
struct file *do_accept(struct file *file, unsigned file_flags,
1893+
struct file *do_accept(struct file *file, struct proto_accept_arg *arg,
18941894
struct sockaddr __user *upeer_sockaddr,
18951895
int __user *upeer_addrlen, int flags)
18961896
{
18971897
struct socket *sock, *newsock;
18981898
struct file *newfile;
18991899
int err, len;
19001900
struct sockaddr_storage address;
1901-
struct proto_accept_arg arg = {
1902-
.flags = file_flags,
1903-
};
19041901
const struct proto_ops *ops;
19051902

19061903
sock = sock_from_file(file);
@@ -1929,8 +1926,8 @@ struct file *do_accept(struct file *file, unsigned file_flags,
19291926
if (err)
19301927
goto out_fd;
19311928

1932-
arg.flags |= sock->file->f_flags;
1933-
err = ops->accept(sock, newsock, &arg);
1929+
arg->flags |= sock->file->f_flags;
1930+
err = ops->accept(sock, newsock, arg);
19341931
if (err < 0)
19351932
goto out_fd;
19361933

@@ -1956,6 +1953,7 @@ struct file *do_accept(struct file *file, unsigned file_flags,
19561953
static int __sys_accept4_file(struct file *file, struct sockaddr __user *upeer_sockaddr,
19571954
int __user *upeer_addrlen, int flags)
19581955
{
1956+
struct proto_accept_arg arg = { };
19591957
struct file *newfile;
19601958
int newfd;
19611959

@@ -1969,7 +1967,7 @@ static int __sys_accept4_file(struct file *file, struct sockaddr __user *upeer_s
19691967
if (unlikely(newfd < 0))
19701968
return newfd;
19711969

1972-
newfile = do_accept(file, 0, upeer_sockaddr, upeer_addrlen,
1970+
newfile = do_accept(file, &arg, upeer_sockaddr, upeer_addrlen,
19731971
flags);
19741972
if (IS_ERR(newfile)) {
19751973
put_unused_fd(newfd);

0 commit comments

Comments
 (0)