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

net: change proto and proto_ops accept type

Rather than pass in flags, error pointer, and whether this is a kernel
invocation or not, add a struct proto_accept_arg struct as the argument.
This then holds all of these arguments, and prepares accept for being
able to pass back more information.

No functional changes in this patch.

Acked-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

+132 -111
+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 -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
+9 -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 + bool kern; 1201 + }; 1202 + 1197 1203 /* Networking protocol blocks we attach to sockets. 1198 1204 * socket layer -> transport layer interface 1199 1205 */ ··· 1214 1208 int addr_len); 1215 1209 int (*disconnect)(struct sock *sk, int flags); 1216 1210 1217 - struct sock * (*accept)(struct sock *sk, int flags, int *err, 1218 - bool kern); 1211 + struct sock * (*accept)(struct sock *sk, 1212 + struct proto_accept_arg *arg); 1219 1213 1220 1214 int (*ioctl)(struct sock *sk, int cmd, 1221 1215 int *karg); ··· 1810 1804 int sock_no_bind(struct socket *, struct sockaddr *, int); 1811 1805 int sock_no_connect(struct socket *, struct sockaddr *, int, int); 1812 1806 int sock_no_socketpair(struct socket *, struct socket *); 1813 - int sock_no_accept(struct socket *, struct socket *, int, bool); 1807 + int sock_no_accept(struct socket *, struct socket *, struct proto_accept_arg *); 1814 1808 int sock_no_getname(struct socket *, struct sockaddr *, int); 1815 1809 int sock_no_ioctl(struct socket *, unsigned int, unsigned long); 1816 1810 int sock_no_listen(struct socket *, int);
+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
··· 1186 1186 } 1187 1187 1188 1188 static int iso_sock_accept(struct socket *sock, struct socket *newsock, 1189 - int flags, bool kern) 1189 + struct proto_accept_arg *arg) 1190 1190 { 1191 1191 DEFINE_WAIT_FUNC(wait, woken_wake_function); 1192 1192 struct sock *sk = sock->sk, *ch; ··· 1195 1195 1196 1196 lock_sock(sk); 1197 1197 1198 - timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK); 1198 + timeo = sock_rcvtimeo(sk, arg->flags & O_NONBLOCK); 1199 1199 1200 1200 BT_DBG("sk %p timeo %ld", sk, timeo); 1201 1201
+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);
+3 -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; ··· 745 745 out_err: 746 746 newsk = NULL; 747 747 req = NULL; 748 - *err = error; 748 + arg->err = error; 749 749 goto out; 750 750 } 751 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
··· 3881 3881 } 3882 3882 3883 3883 static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, 3884 - int flags, bool kern) 3884 + struct proto_accept_arg *arg) 3885 3885 { 3886 3886 struct mptcp_sock *msk = mptcp_sk(sock->sk); 3887 3887 struct sock *ssk, *newsk; 3888 - int err; 3889 3888 3890 3889 pr_debug("msk=%p", msk); 3891 3890 ··· 3896 3897 return -EINVAL; 3897 3898 3898 3899 pr_debug("ssk=%p, listener=%p", ssk, mptcp_subflow_ctx(ssk)); 3899 - newsk = inet_csk_accept(ssk, flags, &err, kern); 3900 + newsk = inet_csk_accept(ssk, arg); 3900 3901 if (!newsk) 3901 - return err; 3902 + return arg->err; 3902 3903 3903 3904 pr_debug("newsk=%p, subflow is mptcp=%d", newsk, sk_is_mptcp(newsk)); 3904 3905 if (sk_is_mptcp(newsk)) { ··· 3919 3920 newsk = new_mptcp_sock; 3920 3921 MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_MPCAPABLEPASSIVEACK); 3921 3922 3922 - newsk->sk_kern_sock = kern; 3923 + newsk->sk_kern_sock = arg->kern; 3923 3924 lock_sock(newsk); 3924 3925 __inet_accept(sock, newsock, newsk); 3925 3926 ··· 3948 3949 } 3949 3950 } else { 3950 3951 tcpfallback: 3951 - newsk->sk_kern_sock = kern; 3952 + newsk->sk_kern_sock = arg->kern; 3952 3953 lock_sock(newsk); 3953 3954 __inet_accept(sock, newsock, newsk); 3954 3955 /* 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 -3
net/socket.c
··· 1898 1898 struct file *newfile; 1899 1899 int err, len; 1900 1900 struct sockaddr_storage address; 1901 + struct proto_accept_arg arg = { 1902 + .flags = file_flags, 1903 + }; 1901 1904 const struct proto_ops *ops; 1902 1905 1903 1906 sock = sock_from_file(file); ··· 1929 1926 if (err) 1930 1927 goto out_fd; 1931 1928 1932 - err = ops->accept(sock, newsock, sock->file->f_flags | file_flags, 1933 - false); 1929 + arg.flags |= sock->file->f_flags; 1930 + err = ops->accept(sock, newsock, &arg); 1934 1931 if (err < 0) 1935 1932 goto out_fd; 1936 1933 ··· 3583 3580 { 3584 3581 struct sock *sk = sock->sk; 3585 3582 const struct proto_ops *ops = READ_ONCE(sock->ops); 3583 + struct proto_accept_arg arg = { 3584 + .flags = flags, 3585 + .kern = true, 3586 + }; 3586 3587 int err; 3587 3588 3588 3589 err = sock_create_lite(sk->sk_family, sk->sk_type, sk->sk_protocol, ··· 3594 3587 if (err < 0) 3595 3588 goto done; 3596 3589 3597 - err = ops->accept(sock, *newsock, flags, true); 3590 + err = ops->accept(sock, *newsock, &arg); 3598 3591 if (err < 0) { 3599 3592 sock_release(*newsock); 3600 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;