Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'net-accept-more-20240515' of git://git.kernel.dk/linux

Pull more io_uring updates from Jens Axboe:
"This adds support for IORING_CQE_F_SOCK_NONEMPTY for io_uring accept
requests.

This is very similar to previous work that enabled the same hint for
doing receives on sockets. By far the majority of the work here is
refactoring to enable the networking side to pass back whether or not
the socket had more pending requests after accepting the current one,
the last patch just wires it up for io_uring.

Not only does this enable applications to know whether there are more
connections to accept right now, it also enables smarter logic for
io_uring multishot accept on whether to retry immediately or wait for
a poll trigger"

* tag 'net-accept-more-20240515' of git://git.kernel.dk/linux:
io_uring/net: wire up IORING_CQE_F_SOCK_NONEMPTY for accept
net: pass back whether socket was empty post accept
net: have do_accept() take a struct proto_accept_arg argument
net: change proto and proto_ops accept type

+156 -120
+6 -5
crypto/af_alg.c
··· 407 407 return err; 408 408 } 409 409 410 - int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern) 410 + int af_alg_accept(struct sock *sk, struct socket *newsock, 411 + struct proto_accept_arg *arg) 411 412 { 412 413 struct alg_sock *ask = alg_sk(sk); 413 414 const struct af_alg_type *type; ··· 423 422 if (!type) 424 423 goto unlock; 425 424 426 - sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, kern); 425 + sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, arg->kern); 427 426 err = -ENOMEM; 428 427 if (!sk2) 429 428 goto unlock; ··· 469 468 } 470 469 EXPORT_SYMBOL_GPL(af_alg_accept); 471 470 472 - static int alg_accept(struct socket *sock, struct socket *newsock, int flags, 473 - bool kern) 471 + static int alg_accept(struct socket *sock, struct socket *newsock, 472 + struct proto_accept_arg *arg) 474 473 { 475 - return af_alg_accept(sock->sk, newsock, kern); 474 + return af_alg_accept(sock->sk, newsock, arg); 476 475 } 477 476 478 477 static const struct proto_ops alg_proto_ops = {
+5 -5
crypto/algif_hash.c
··· 223 223 return err ?: len; 224 224 } 225 225 226 - static int hash_accept(struct socket *sock, struct socket *newsock, int flags, 227 - bool kern) 226 + static int hash_accept(struct socket *sock, struct socket *newsock, 227 + struct proto_accept_arg *arg) 228 228 { 229 229 struct sock *sk = sock->sk; 230 230 struct alg_sock *ask = alg_sk(sk); ··· 252 252 if (err) 253 253 goto out_free_state; 254 254 255 - err = af_alg_accept(ask->parent, newsock, kern); 255 + err = af_alg_accept(ask->parent, newsock, arg); 256 256 if (err) 257 257 goto out_free_state; 258 258 ··· 355 355 } 356 356 357 357 static int hash_accept_nokey(struct socket *sock, struct socket *newsock, 358 - int flags, bool kern) 358 + struct proto_accept_arg *arg) 359 359 { 360 360 int err; 361 361 ··· 363 363 if (err) 364 364 return err; 365 365 366 - return hash_accept(sock, newsock, flags, kern); 366 + return hash_accept(sock, newsock, arg); 367 367 } 368 368 369 369 static struct proto_ops algif_hash_ops_nokey = {
+5 -1
drivers/xen/pvcalls-back.c
··· 517 517 { 518 518 struct sockpass_mapping *mappass = container_of( 519 519 work, struct sockpass_mapping, register_work); 520 + struct proto_accept_arg arg = { 521 + .flags = O_NONBLOCK, 522 + .kern = true, 523 + }; 520 524 struct sock_mapping *map; 521 525 struct pvcalls_ioworker *iow; 522 526 struct pvcalls_fedata *fedata; ··· 552 548 sock->type = mappass->sock->type; 553 549 sock->ops = mappass->sock->ops; 554 550 555 - ret = inet_accept(mappass->sock, sock, O_NONBLOCK, true); 551 + ret = inet_accept(mappass->sock, sock, &arg); 556 552 if (ret == -EAGAIN) { 557 553 sock_release(sock); 558 554 return;
+4 -1
fs/ocfs2/cluster/tcp.c
··· 1784 1784 struct o2nm_node *node = NULL; 1785 1785 struct o2nm_node *local_node = NULL; 1786 1786 struct o2net_sock_container *sc = NULL; 1787 + struct proto_accept_arg arg = { 1788 + .flags = O_NONBLOCK, 1789 + }; 1787 1790 struct o2net_node *nn; 1788 1791 unsigned int nofs_flag; 1789 1792 ··· 1805 1802 1806 1803 new_sock->type = sock->type; 1807 1804 new_sock->ops = sock->ops; 1808 - ret = sock->ops->accept(sock, new_sock, O_NONBLOCK, false); 1805 + ret = sock->ops->accept(sock, new_sock, &arg); 1809 1806 if (ret < 0) 1810 1807 goto out; 1811 1808
+2 -1
include/crypto/if_alg.h
··· 166 166 167 167 int af_alg_release(struct socket *sock); 168 168 void af_alg_release_parent(struct sock *sk); 169 - int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern); 169 + int af_alg_accept(struct sock *sk, struct socket *newsock, 170 + struct proto_accept_arg *arg); 170 171 171 172 void af_alg_free_sg(struct af_alg_sgl *sgl); 172 173
+3 -1
include/linux/net.h
··· 153 153 struct msghdr; 154 154 struct module; 155 155 struct sk_buff; 156 + struct proto_accept_arg; 156 157 typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *, 157 158 unsigned int, size_t); 158 159 typedef int (*skb_read_actor_t)(struct sock *, struct sk_buff *); ··· 172 171 int (*socketpair)(struct socket *sock1, 173 172 struct socket *sock2); 174 173 int (*accept) (struct socket *sock, 175 - struct socket *newsock, int flags, bool kern); 174 + struct socket *newsock, 175 + struct proto_accept_arg *arg); 176 176 int (*getname) (struct socket *sock, 177 177 struct sockaddr *addr, 178 178 int peer);
+2 -1
include/linux/socket.h
··· 16 16 struct socket; 17 17 struct sock; 18 18 struct sk_buff; 19 + struct proto_accept_arg; 19 20 20 21 #define __sockaddr_check_size(size) \ 21 22 BUILD_BUG_ON(((size) > sizeof(struct __kernel_sockaddr_storage))) ··· 434 433 extern int __sys_sendto(int fd, void __user *buff, size_t len, 435 434 unsigned int flags, struct sockaddr __user *addr, 436 435 int addr_len); 437 - extern struct file *do_accept(struct file *file, unsigned file_flags, 436 + extern struct file *do_accept(struct file *file, struct proto_accept_arg *arg, 438 437 struct sockaddr __user *upeer_sockaddr, 439 438 int __user *upeer_addrlen, int flags); 440 439 extern int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr,
+2 -2
include/net/inet_common.h
··· 29 29 int addr_len, int flags, int is_sendmsg); 30 30 int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr, 31 31 int addr_len, int flags); 32 - int inet_accept(struct socket *sock, struct socket *newsock, int flags, 33 - bool kern); 32 + int inet_accept(struct socket *sock, struct socket *newsock, 33 + struct proto_accept_arg *arg); 34 34 void __inet_accept(struct socket *sock, struct socket *newsock, 35 35 struct sock *newsk); 36 36 int inet_send_prepare(struct sock *sk);
+1 -1
include/net/inet_connection_sock.h
··· 250 250 return (unsigned long)min_t(u64, when, max_when); 251 251 } 252 252 253 - struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern); 253 + struct sock *inet_csk_accept(struct sock *sk, struct proto_accept_arg *arg); 254 254 255 255 int inet_csk_get_port(struct sock *sk, unsigned short snum); 256 256
+10 -3
include/net/sock.h
··· 1194 1194 size - offsetof(struct sock, sk_node.pprev)); 1195 1195 } 1196 1196 1197 + struct proto_accept_arg { 1198 + int flags; 1199 + int err; 1200 + int is_empty; 1201 + bool kern; 1202 + }; 1203 + 1197 1204 /* Networking protocol blocks we attach to sockets. 1198 1205 * socket layer -> transport layer interface 1199 1206 */ ··· 1215 1208 int addr_len); 1216 1209 int (*disconnect)(struct sock *sk, int flags); 1217 1210 1218 - struct sock * (*accept)(struct sock *sk, int flags, int *err, 1219 - bool kern); 1211 + struct sock * (*accept)(struct sock *sk, 1212 + struct proto_accept_arg *arg); 1220 1213 1221 1214 int (*ioctl)(struct sock *sk, int cmd, 1222 1215 int *karg); ··· 1811 1804 int sock_no_bind(struct socket *, struct sockaddr *, int); 1812 1805 int sock_no_connect(struct socket *, struct sockaddr *, int, int); 1813 1806 int sock_no_socketpair(struct socket *, struct socket *); 1814 - int sock_no_accept(struct socket *, struct socket *, int, bool); 1807 + int sock_no_accept(struct socket *, struct socket *, struct proto_accept_arg *); 1815 1808 int sock_no_getname(struct socket *, struct sockaddr *, int); 1816 1809 int sock_no_ioctl(struct socket *, unsigned int, unsigned long); 1817 1810 int sock_no_listen(struct socket *, int);
+20 -6
io_uring/net.c
··· 1528 1528 { 1529 1529 struct io_accept *accept = io_kiocb_to_cmd(req, struct io_accept); 1530 1530 bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK; 1531 - unsigned int file_flags = force_nonblock ? O_NONBLOCK : 0; 1532 1531 bool fixed = !!accept->file_slot; 1532 + struct proto_accept_arg arg = { 1533 + .flags = force_nonblock ? O_NONBLOCK : 0, 1534 + }; 1533 1535 struct file *file; 1536 + unsigned cflags; 1534 1537 int ret, fd; 1535 1538 1536 1539 if (!(req->flags & REQ_F_POLLED) && ··· 1546 1543 if (unlikely(fd < 0)) 1547 1544 return fd; 1548 1545 } 1549 - file = do_accept(req->file, file_flags, accept->addr, accept->addr_len, 1546 + arg.err = 0; 1547 + arg.is_empty = -1; 1548 + file = do_accept(req->file, &arg, accept->addr, accept->addr_len, 1550 1549 accept->flags); 1551 1550 if (IS_ERR(file)) { 1552 1551 if (!fixed) ··· 1576 1571 accept->file_slot); 1577 1572 } 1578 1573 1574 + cflags = 0; 1575 + if (!arg.is_empty) 1576 + cflags |= IORING_CQE_F_SOCK_NONEMPTY; 1577 + 1579 1578 if (!(req->flags & REQ_F_APOLL_MULTISHOT)) { 1580 - io_req_set_res(req, ret, 0); 1579 + io_req_set_res(req, ret, cflags); 1581 1580 return IOU_OK; 1582 1581 } 1583 1582 1584 1583 if (ret < 0) 1585 1584 return ret; 1586 - if (io_req_post_cqe(req, ret, IORING_CQE_F_MORE)) 1587 - goto retry; 1585 + if (io_req_post_cqe(req, ret, cflags | IORING_CQE_F_MORE)) { 1586 + if (cflags & IORING_CQE_F_SOCK_NONEMPTY || arg.is_empty == -1) 1587 + goto retry; 1588 + if (issue_flags & IO_URING_F_MULTISHOT) 1589 + return IOU_ISSUE_SKIP_COMPLETE; 1590 + return -EAGAIN; 1591 + } 1588 1592 1589 - io_req_set_res(req, ret, 0); 1593 + io_req_set_res(req, ret, cflags); 1590 1594 return IOU_STOP_MULTISHOT; 1591 1595 } 1592 1596
+4 -4
net/atm/svc.c
··· 324 324 return error; 325 325 } 326 326 327 - static int svc_accept(struct socket *sock, struct socket *newsock, int flags, 328 - bool kern) 327 + static int svc_accept(struct socket *sock, struct socket *newsock, 328 + struct proto_accept_arg *arg) 329 329 { 330 330 struct sock *sk = sock->sk; 331 331 struct sk_buff *skb; ··· 336 336 337 337 lock_sock(sk); 338 338 339 - error = svc_create(sock_net(sk), newsock, 0, kern); 339 + error = svc_create(sock_net(sk), newsock, 0, arg->kern); 340 340 if (error) 341 341 goto out; 342 342 ··· 355 355 error = -sk->sk_err; 356 356 break; 357 357 } 358 - if (flags & O_NONBLOCK) { 358 + if (arg->flags & O_NONBLOCK) { 359 359 error = -EAGAIN; 360 360 break; 361 361 }
+3 -3
net/ax25/af_ax25.c
··· 1373 1373 return err; 1374 1374 } 1375 1375 1376 - static int ax25_accept(struct socket *sock, struct socket *newsock, int flags, 1377 - bool kern) 1376 + static int ax25_accept(struct socket *sock, struct socket *newsock, 1377 + struct proto_accept_arg *arg) 1378 1378 { 1379 1379 struct sk_buff *skb; 1380 1380 struct sock *newsk; ··· 1409 1409 if (skb) 1410 1410 break; 1411 1411 1412 - if (flags & O_NONBLOCK) { 1412 + if (arg->flags & O_NONBLOCK) { 1413 1413 err = -EWOULDBLOCK; 1414 1414 break; 1415 1415 }
+2 -2
net/bluetooth/iso.c
··· 1159 1159 } 1160 1160 1161 1161 static int iso_sock_accept(struct socket *sock, struct socket *newsock, 1162 - int flags, bool kern) 1162 + struct proto_accept_arg *arg) 1163 1163 { 1164 1164 DEFINE_WAIT_FUNC(wait, woken_wake_function); 1165 1165 struct sock *sk = sock->sk, *ch; ··· 1168 1168 1169 1169 lock_sock(sk); 1170 1170 1171 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 1171 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 1172 1172 1173 1173 BT_DBG("sk %p timeo %ld", sk, timeo); 1174 1174
+2 -2
net/bluetooth/l2cap_sock.c
··· 327 327 } 328 328 329 329 static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, 330 - int flags, bool kern) 330 + struct proto_accept_arg *arg) 331 331 { 332 332 DEFINE_WAIT_FUNC(wait, woken_wake_function); 333 333 struct sock *sk = sock->sk, *nsk; ··· 336 336 337 337 lock_sock_nested(sk, L2CAP_NESTING_PARENT); 338 338 339 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 339 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 340 340 341 341 BT_DBG("sk %p timeo %ld", sk, timeo); 342 342
+3 -3
net/bluetooth/rfcomm/sock.c
··· 468 468 return err; 469 469 } 470 470 471 - static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int flags, 472 - bool kern) 471 + static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, 472 + struct proto_accept_arg *arg) 473 473 { 474 474 DEFINE_WAIT_FUNC(wait, woken_wake_function); 475 475 struct sock *sk = sock->sk, *nsk; ··· 483 483 goto done; 484 484 } 485 485 486 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 486 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 487 487 488 488 BT_DBG("sk %p timeo %ld", sk, timeo); 489 489
+2 -2
net/bluetooth/sco.c
··· 647 647 } 648 648 649 649 static int sco_sock_accept(struct socket *sock, struct socket *newsock, 650 - int flags, bool kern) 650 + struct proto_accept_arg *arg) 651 651 { 652 652 DEFINE_WAIT_FUNC(wait, woken_wake_function); 653 653 struct sock *sk = sock->sk, *ch; ··· 656 656 657 657 lock_sock(sk); 658 658 659 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 659 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 660 660 661 661 BT_DBG("sk %p timeo %ld", sk, timeo); 662 662
+2 -2
net/core/sock.c
··· 3241 3241 } 3242 3242 EXPORT_SYMBOL(sock_no_socketpair); 3243 3243 3244 - int sock_no_accept(struct socket *sock, struct socket *newsock, int flags, 3245 - bool kern) 3244 + int sock_no_accept(struct socket *sock, struct socket *newsock, 3245 + struct proto_accept_arg *arg) 3246 3246 { 3247 3247 return -EOPNOTSUPP; 3248 3248 }
+5 -5
net/ipv4/af_inet.c
··· 771 771 * Accept a pending connection. The TCP layer now gives BSD semantics. 772 772 */ 773 773 774 - int inet_accept(struct socket *sock, struct socket *newsock, int flags, 775 - bool kern) 774 + int inet_accept(struct socket *sock, struct socket *newsock, 775 + struct proto_accept_arg *arg) 776 776 { 777 777 struct sock *sk1 = sock->sk, *sk2; 778 - int err = -EINVAL; 779 778 780 779 /* IPV6_ADDRFORM can change sk->sk_prot under us. */ 781 - sk2 = READ_ONCE(sk1->sk_prot)->accept(sk1, flags, &err, kern); 780 + arg->err = -EINVAL; 781 + sk2 = READ_ONCE(sk1->sk_prot)->accept(sk1, arg); 782 782 if (!sk2) 783 - return err; 783 + return arg->err; 784 784 785 785 lock_sock(sk2); 786 786 __inet_accept(sock, newsock, sk2);
+4 -3
net/ipv4/inet_connection_sock.c
··· 661 661 /* 662 662 * This will accept the next outstanding connection. 663 663 */ 664 - struct sock *inet_csk_accept(struct sock *sk, int flags, int *err, bool kern) 664 + struct sock *inet_csk_accept(struct sock *sk, struct proto_accept_arg *arg) 665 665 { 666 666 struct inet_connection_sock *icsk = inet_csk(sk); 667 667 struct request_sock_queue *queue = &icsk->icsk_accept_queue; ··· 680 680 681 681 /* Find already established connection */ 682 682 if (reqsk_queue_empty(queue)) { 683 - long timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 683 + long timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 684 684 685 685 /* If this is a non blocking socket don't sleep */ 686 686 error = -EAGAIN; ··· 692 692 goto out_err; 693 693 } 694 694 req = reqsk_queue_remove(queue, sk); 695 + arg->is_empty = reqsk_queue_empty(queue); 695 696 newsk = req->sk; 696 697 697 698 if (sk->sk_protocol == IPPROTO_TCP && ··· 746 745 out_err: 747 746 newsk = NULL; 748 747 req = NULL; 749 - *err = error; 748 + arg->err = error; 750 749 goto out; 751 750 } 752 751 EXPORT_SYMBOL(inet_csk_accept);
+2 -2
net/iucv/af_iucv.c
··· 795 795 796 796 /* Accept a pending connection */ 797 797 static int iucv_sock_accept(struct socket *sock, struct socket *newsock, 798 - int flags, bool kern) 798 + struct proto_accept_arg *arg) 799 799 { 800 800 DECLARE_WAITQUEUE(wait, current); 801 801 struct sock *sk = sock->sk, *nsk; ··· 809 809 goto done; 810 810 } 811 811 812 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 812 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 813 813 814 814 /* Wait for an incoming connection */ 815 815 add_wait_queue_exclusive(sk_sleep(sk), &wait);
+3 -4
net/llc/af_llc.c
··· 688 688 * llc_ui_accept - accept a new incoming connection. 689 689 * @sock: Socket which connections arrive on. 690 690 * @newsock: Socket to move incoming connection to. 691 - * @flags: User specified operational flags. 692 - * @kern: If the socket is kernel internal 691 + * @arg: User specified arguments 693 692 * 694 693 * Accept a new incoming connection. 695 694 * Returns 0 upon success, negative otherwise. 696 695 */ 697 - static int llc_ui_accept(struct socket *sock, struct socket *newsock, int flags, 698 - bool kern) 696 + static int llc_ui_accept(struct socket *sock, struct socket *newsock, 697 + struct proto_accept_arg *arg) 699 698 { 700 699 struct sock *sk = sock->sk, *newsk; 701 700 struct llc_sock *llc, *newllc;
+5 -6
net/mptcp/protocol.c
··· 3882 3882 } 3883 3883 3884 3884 static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, 3885 - int flags, bool kern) 3885 + struct proto_accept_arg *arg) 3886 3886 { 3887 3887 struct mptcp_sock *msk = mptcp_sk(sock->sk); 3888 3888 struct sock *ssk, *newsk; 3889 - int err; 3890 3889 3891 3890 pr_debug("msk=%p", msk); 3892 3891 ··· 3897 3898 return -EINVAL; 3898 3899 3899 3900 pr_debug("ssk=%p, listener=%p", ssk, mptcp_subflow_ctx(ssk)); 3900 - newsk = inet_csk_accept(ssk, flags, &err, kern); 3901 + newsk = inet_csk_accept(ssk, arg); 3901 3902 if (!newsk) 3902 - return err; 3903 + return arg->err; 3903 3904 3904 3905 pr_debug("newsk=%p, subflow is mptcp=%d", newsk, sk_is_mptcp(newsk)); 3905 3906 if (sk_is_mptcp(newsk)) { ··· 3920 3921 newsk = new_mptcp_sock; 3921 3922 MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPCAPABLEPASSIVEACK); 3922 3923 3923 - newsk->sk_kern_sock = kern; 3924 + newsk->sk_kern_sock = arg->kern; 3924 3925 lock_sock(newsk); 3925 3926 __inet_accept(sock, newsock, newsk); 3926 3927 ··· 3949 3950 } 3950 3951 } else { 3951 3952 tcpfallback: 3952 - newsk->sk_kern_sock = kern; 3953 + newsk->sk_kern_sock = arg->kern; 3953 3954 lock_sock(newsk); 3954 3955 __inet_accept(sock, newsock, newsk); 3955 3956 /* we are being invoked after accepting a non-mp-capable
+3 -3
net/netrom/af_netrom.c
··· 772 772 return err; 773 773 } 774 774 775 - static int nr_accept(struct socket *sock, struct socket *newsock, int flags, 776 - bool kern) 775 + static int nr_accept(struct socket *sock, struct socket *newsock, 776 + struct proto_accept_arg *arg) 777 777 { 778 778 struct sk_buff *skb; 779 779 struct sock *newsk; ··· 805 805 if (skb) 806 806 break; 807 807 808 - if (flags & O_NONBLOCK) { 808 + if (arg->flags & O_NONBLOCK) { 809 809 err = -EWOULDBLOCK; 810 810 break; 811 811 }
+2 -2
net/nfc/llcp_sock.c
··· 447 447 } 448 448 449 449 static int llcp_sock_accept(struct socket *sock, struct socket *newsock, 450 - int flags, bool kern) 450 + struct proto_accept_arg *arg) 451 451 { 452 452 DECLARE_WAITQUEUE(wait, current); 453 453 struct sock *sk = sock->sk, *new_sk; ··· 463 463 goto error; 464 464 } 465 465 466 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 466 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 467 467 468 468 /* Wait for an incoming connection. */ 469 469 add_wait_queue_exclusive(sk_sleep(sk), &wait);
+6 -6
net/phonet/pep.c
··· 759 759 sock_put(sk); 760 760 } 761 761 762 - static struct sock *pep_sock_accept(struct sock *sk, int flags, int *errp, 763 - bool kern) 762 + static struct sock *pep_sock_accept(struct sock *sk, 763 + struct proto_accept_arg *arg) 764 764 { 765 765 struct pep_sock *pn = pep_sk(sk), *newpn; 766 766 struct sock *newsk = NULL; ··· 772 772 u8 pipe_handle, enabled, n_sb; 773 773 u8 aligned = 0; 774 774 775 - skb = skb_recv_datagram(sk, (flags & O_NONBLOCK) ? MSG_DONTWAIT : 0, 776 - errp); 775 + skb = skb_recv_datagram(sk, (arg->flags & O_NONBLOCK) ? MSG_DONTWAIT : 0, 776 + &arg->err); 777 777 if (!skb) 778 778 return NULL; 779 779 ··· 836 836 837 837 /* Create a new to-be-accepted sock */ 838 838 newsk = sk_alloc(sock_net(sk), PF_PHONET, GFP_KERNEL, sk->sk_prot, 839 - kern); 839 + arg->kern); 840 840 if (!newsk) { 841 841 pep_reject_conn(sk, skb, PN_PIPE_ERR_OVERLOAD, GFP_KERNEL); 842 842 err = -ENOBUFS; ··· 878 878 drop: 879 879 release_sock(sk); 880 880 kfree_skb(skb); 881 - *errp = err; 881 + arg->err = err; 882 882 return newsk; 883 883 } 884 884
+3 -4
net/phonet/socket.c
··· 292 292 } 293 293 294 294 static int pn_socket_accept(struct socket *sock, struct socket *newsock, 295 - int flags, bool kern) 295 + struct proto_accept_arg *arg) 296 296 { 297 297 struct sock *sk = sock->sk; 298 298 struct sock *newsk; 299 - int err; 300 299 301 300 if (unlikely(sk->sk_state != TCP_LISTEN)) 302 301 return -EINVAL; 303 302 304 - newsk = sk->sk_prot->accept(sk, flags, &err, kern); 303 + newsk = sk->sk_prot->accept(sk, arg); 305 304 if (!newsk) 306 - return err; 305 + return arg->err; 307 306 308 307 lock_sock(newsk); 309 308 sock_graft(newsk, newsock);
+5 -1
net/rds/tcp_listen.c
··· 105 105 int conn_state; 106 106 struct rds_conn_path *cp; 107 107 struct in6_addr *my_addr, *peer_addr; 108 + struct proto_accept_arg arg = { 109 + .flags = O_NONBLOCK, 110 + .kern = true, 111 + }; 108 112 #if !IS_ENABLED(CONFIG_IPV6) 109 113 struct in6_addr saddr, daddr; 110 114 #endif ··· 123 119 if (ret) 124 120 goto out; 125 121 126 - ret = sock->ops->accept(sock, new_sock, O_NONBLOCK, true); 122 + ret = sock->ops->accept(sock, new_sock, &arg); 127 123 if (ret < 0) 128 124 goto out; 129 125
+3 -3
net/rose/af_rose.c
··· 919 919 return err; 920 920 } 921 921 922 - static int rose_accept(struct socket *sock, struct socket *newsock, int flags, 923 - bool kern) 922 + static int rose_accept(struct socket *sock, struct socket *newsock, 923 + struct proto_accept_arg *arg) 924 924 { 925 925 struct sk_buff *skb; 926 926 struct sock *newsk; ··· 953 953 if (skb) 954 954 break; 955 955 956 - if (flags & O_NONBLOCK) { 956 + if (arg->flags & O_NONBLOCK) { 957 957 err = -EWOULDBLOCK; 958 958 break; 959 959 }
+4 -4
net/sctp/socket.c
··· 4847 4847 * descriptor will be returned from accept() to represent the newly 4848 4848 * formed association. 4849 4849 */ 4850 - static struct sock *sctp_accept(struct sock *sk, int flags, int *err, bool kern) 4850 + static struct sock *sctp_accept(struct sock *sk, struct proto_accept_arg *arg) 4851 4851 { 4852 4852 struct sctp_sock *sp; 4853 4853 struct sctp_endpoint *ep; ··· 4871 4871 goto out; 4872 4872 } 4873 4873 4874 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 4874 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 4875 4875 4876 4876 error = sctp_wait_for_accept(sk, timeo); 4877 4877 if (error) ··· 4882 4882 */ 4883 4883 asoc = list_entry(ep->asocs.next, struct sctp_association, asocs); 4884 4884 4885 - newsk = sp->pf->create_accept_sk(sk, asoc, kern); 4885 + newsk = sp->pf->create_accept_sk(sk, asoc, arg->kern); 4886 4886 if (!newsk) { 4887 4887 error = -ENOMEM; 4888 4888 goto out; ··· 4899 4899 4900 4900 out: 4901 4901 release_sock(sk); 4902 - *err = error; 4902 + arg->err = error; 4903 4903 return newsk; 4904 4904 } 4905 4905
+3 -3
net/smc/af_smc.c
··· 2689 2689 } 2690 2690 2691 2691 static int smc_accept(struct socket *sock, struct socket *new_sock, 2692 - int flags, bool kern) 2692 + struct proto_accept_arg *arg) 2693 2693 { 2694 2694 struct sock *sk = sock->sk, *nsk; 2695 2695 DECLARE_WAITQUEUE(wait, current); ··· 2708 2708 } 2709 2709 2710 2710 /* Wait for an incoming connection */ 2711 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 2711 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 2712 2712 add_wait_queue_exclusive(sk_sleep(sk), &wait); 2713 2713 while (!(nsk = smc_accept_dequeue(sk, new_sock))) { 2714 2714 set_current_state(TASK_INTERRUPTIBLE); ··· 2735 2735 if (rc) 2736 2736 goto out; 2737 2737 2738 - if (lsmc->sockopt_defer_accept && !(flags & O_NONBLOCK)) { 2738 + if (lsmc->sockopt_defer_accept && !(arg->flags & O_NONBLOCK)) { 2739 2739 /* wait till data arrives on the socket */ 2740 2740 timeo = msecs_to_jiffies(lsmc->sockopt_defer_accept * 2741 2741 MSEC_PER_SEC);
+10 -5
net/socket.c
··· 1890 1890 return __sys_listen(fd, backlog); 1891 1891 } 1892 1892 1893 - struct file *do_accept(struct file *file, unsigned file_flags, 1893 + struct file *do_accept(struct file *file, struct proto_accept_arg *arg, 1894 1894 struct sockaddr __user *upeer_sockaddr, 1895 1895 int __user *upeer_addrlen, int flags) 1896 1896 { ··· 1926 1926 if (err) 1927 1927 goto out_fd; 1928 1928 1929 - err = ops->accept(sock, newsock, sock->file->f_flags | file_flags, 1930 - false); 1929 + arg->flags |= sock->file->f_flags; 1930 + err = ops->accept(sock, newsock, arg); 1931 1931 if (err < 0) 1932 1932 goto out_fd; 1933 1933 ··· 1953 1953 static int __sys_accept4_file(struct file *file, struct sockaddr __user *upeer_sockaddr, 1954 1954 int __user *upeer_addrlen, int flags) 1955 1955 { 1956 + struct proto_accept_arg arg = { }; 1956 1957 struct file *newfile; 1957 1958 int newfd; 1958 1959 ··· 1967 1966 if (unlikely(newfd < 0)) 1968 1967 return newfd; 1969 1968 1970 - newfile = do_accept(file, 0, upeer_sockaddr, upeer_addrlen, 1969 + newfile = do_accept(file, &arg, upeer_sockaddr, upeer_addrlen, 1971 1970 flags); 1972 1971 if (IS_ERR(newfile)) { 1973 1972 put_unused_fd(newfd); ··· 3581 3580 { 3582 3581 struct sock *sk = sock->sk; 3583 3582 const struct proto_ops *ops = READ_ONCE(sock->ops); 3583 + struct proto_accept_arg arg = { 3584 + .flags = flags, 3585 + .kern = true, 3586 + }; 3584 3587 int err; 3585 3588 3586 3589 err = sock_create_lite(sk->sk_family, sk->sk_type, sk->sk_protocol, ··· 3592 3587 if (err < 0) 3593 3588 goto done; 3594 3589 3595 - err = ops->accept(sock, *newsock, flags, true); 3590 + err = ops->accept(sock, *newsock, &arg); 3596 3591 if (err < 0) { 3597 3592 sock_release(*newsock); 3598 3593 *newsock = NULL;
+5 -8
net/tipc/socket.c
··· 146 146 static void tipc_write_space(struct sock *sk); 147 147 static void tipc_sock_destruct(struct sock *sk); 148 148 static int tipc_release(struct socket *sock); 149 - static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, 150 - bool kern); 151 149 static void tipc_sk_timeout(struct timer_list *t); 152 150 static int tipc_sk_publish(struct tipc_sock *tsk, struct tipc_uaddr *ua); 153 151 static int tipc_sk_withdraw(struct tipc_sock *tsk, struct tipc_uaddr *ua); ··· 2709 2711 * tipc_accept - wait for connection request 2710 2712 * @sock: listening socket 2711 2713 * @new_sock: new socket that is to be connected 2712 - * @flags: file-related flags associated with socket 2713 - * @kern: caused by kernel or by userspace? 2714 + * @arg: arguments for accept 2714 2715 * 2715 2716 * Return: 0 on success, errno otherwise 2716 2717 */ 2717 - static int tipc_accept(struct socket *sock, struct socket *new_sock, int flags, 2718 - bool kern) 2718 + static int tipc_accept(struct socket *sock, struct socket *new_sock, 2719 + struct proto_accept_arg *arg) 2719 2720 { 2720 2721 struct sock *new_sk, *sk = sock->sk; 2721 2722 struct tipc_sock *new_tsock; ··· 2730 2733 res = -EINVAL; 2731 2734 goto exit; 2732 2735 } 2733 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 2736 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 2734 2737 res = tipc_wait_for_accept(sock, timeo); 2735 2738 if (res) 2736 2739 goto exit; 2737 2740 2738 2741 buf = skb_peek(&sk->sk_receive_queue); 2739 2742 2740 - res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, kern); 2743 + res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, arg->kern); 2741 2744 if (res) 2742 2745 goto exit; 2743 2746 security_sk_clone(sock->sk, new_sock->sk);
+10 -11
net/unix/af_unix.c
··· 755 755 static int unix_stream_connect(struct socket *, struct sockaddr *, 756 756 int addr_len, int flags); 757 757 static int unix_socketpair(struct socket *, struct socket *); 758 - static int unix_accept(struct socket *, struct socket *, int, bool); 758 + static int unix_accept(struct socket *, struct socket *, struct proto_accept_arg *arg); 759 759 static int unix_getname(struct socket *, struct sockaddr *, int); 760 760 static __poll_t unix_poll(struct file *, struct socket *, poll_table *); 761 761 static __poll_t unix_dgram_poll(struct file *, struct socket *, ··· 1689 1689 set_bit(SOCK_PASSSEC, &new->flags); 1690 1690 } 1691 1691 1692 - static int unix_accept(struct socket *sock, struct socket *newsock, int flags, 1693 - bool kern) 1692 + static int unix_accept(struct socket *sock, struct socket *newsock, 1693 + struct proto_accept_arg *arg) 1694 1694 { 1695 1695 struct sock *sk = sock->sk; 1696 1696 struct sk_buff *skb; 1697 1697 struct sock *tsk; 1698 - int err; 1699 1698 1700 - err = -EOPNOTSUPP; 1699 + arg->err = -EOPNOTSUPP; 1701 1700 if (sock->type != SOCK_STREAM && sock->type != SOCK_SEQPACKET) 1702 1701 goto out; 1703 1702 1704 - err = -EINVAL; 1703 + arg->err = -EINVAL; 1705 1704 if (sk->sk_state != TCP_LISTEN) 1706 1705 goto out; 1707 1706 ··· 1708 1709 * so that no locks are necessary. 1709 1710 */ 1710 1711 1711 - skb = skb_recv_datagram(sk, (flags & O_NONBLOCK) ? MSG_DONTWAIT : 0, 1712 - &err); 1712 + skb = skb_recv_datagram(sk, (arg->flags & O_NONBLOCK) ? MSG_DONTWAIT : 0, 1713 + &arg->err); 1713 1714 if (!skb) { 1714 1715 /* This means receive shutdown. */ 1715 - if (err == 0) 1716 - err = -EINVAL; 1716 + if (arg->err == 0) 1717 + arg->err = -EINVAL; 1717 1718 goto out; 1718 1719 } 1719 1720 ··· 1731 1732 return 0; 1732 1733 1733 1734 out: 1734 - return err; 1735 + return arg->err; 1735 1736 } 1736 1737 1737 1738
+3 -3
net/vmw_vsock/af_vsock.c
··· 1500 1500 return err; 1501 1501 } 1502 1502 1503 - static int vsock_accept(struct socket *sock, struct socket *newsock, int flags, 1504 - bool kern) 1503 + static int vsock_accept(struct socket *sock, struct socket *newsock, 1504 + struct proto_accept_arg *arg) 1505 1505 { 1506 1506 struct sock *listener; 1507 1507 int err; ··· 1528 1528 /* Wait for children sockets to appear; these are the new sockets 1529 1529 * created upon connection establishment. 1530 1530 */ 1531 - timeout = sock_rcvtimeo(listener, flags & O_NONBLOCK); 1531 + timeout = sock_rcvtimeo(listener, arg->flags & O_NONBLOCK); 1532 1532 prepare_to_wait(sk_sleep(listener), &wait, TASK_INTERRUPTIBLE); 1533 1533 1534 1534 while ((connected = vsock_dequeue_accept(listener)) == NULL &&
+2 -2
net/x25/af_x25.c
··· 871 871 return rc; 872 872 } 873 873 874 - static int x25_accept(struct socket *sock, struct socket *newsock, int flags, 875 - bool kern) 874 + static int x25_accept(struct socket *sock, struct socket *newsock, 875 + struct proto_accept_arg *arg) 876 876 { 877 877 struct sock *sk = sock->sk; 878 878 struct sock *newsk;