Skip to content

Commit 92ef0fd

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

File tree

34 files changed

+132
-111
lines changed

34 files changed

+132
-111
lines changed

crypto/af_alg.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,8 @@ static int alg_setsockopt(struct socket *sock, int level, int optname,
407407
return err;
408408
}
409409

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)
411412
{
412413
struct alg_sock *ask = alg_sk(sk);
413414
const struct af_alg_type *type;
@@ -422,7 +423,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern)
422423
if (!type)
423424
goto unlock;
424425

425-
sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, kern);
426+
sk2 = sk_alloc(sock_net(sk), PF_ALG, GFP_KERNEL, &alg_proto, arg->kern);
426427
err = -ENOMEM;
427428
if (!sk2)
428429
goto unlock;
@@ -468,10 +469,10 @@ int af_alg_accept(struct sock *sk, struct socket *newsock, bool kern)
468469
}
469470
EXPORT_SYMBOL_GPL(af_alg_accept);
470471

471-
static int alg_accept(struct socket *sock, struct socket *newsock, int flags,
472-
bool kern)
472+
static int alg_accept(struct socket *sock, struct socket *newsock,
473+
struct proto_accept_arg *arg)
473474
{
474-
return af_alg_accept(sock->sk, newsock, kern);
475+
return af_alg_accept(sock->sk, newsock, arg);
475476
}
476477

477478
static const struct proto_ops alg_proto_ops = {

crypto/algif_hash.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ static int hash_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
223223
return err ?: len;
224224
}
225225

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)
228228
{
229229
struct sock *sk = sock->sk;
230230
struct alg_sock *ask = alg_sk(sk);
@@ -252,7 +252,7 @@ static int hash_accept(struct socket *sock, struct socket *newsock, int flags,
252252
if (err)
253253
goto out_free_state;
254254

255-
err = af_alg_accept(ask->parent, newsock, kern);
255+
err = af_alg_accept(ask->parent, newsock, arg);
256256
if (err)
257257
goto out_free_state;
258258

@@ -355,15 +355,15 @@ static int hash_recvmsg_nokey(struct socket *sock, struct msghdr *msg,
355355
}
356356

357357
static int hash_accept_nokey(struct socket *sock, struct socket *newsock,
358-
int flags, bool kern)
358+
struct proto_accept_arg *arg)
359359
{
360360
int err;
361361

362362
err = hash_check_key(sock);
363363
if (err)
364364
return err;
365365

366-
return hash_accept(sock, newsock, flags, kern);
366+
return hash_accept(sock, newsock, arg);
367367
}
368368

369369
static struct proto_ops algif_hash_ops_nokey = {

drivers/xen/pvcalls-back.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,10 @@ static void __pvcalls_back_accept(struct work_struct *work)
517517
{
518518
struct sockpass_mapping *mappass = container_of(
519519
work, struct sockpass_mapping, register_work);
520+
struct proto_accept_arg arg = {
521+
.flags = O_NONBLOCK,
522+
.kern = true,
523+
};
520524
struct sock_mapping *map;
521525
struct pvcalls_ioworker *iow;
522526
struct pvcalls_fedata *fedata;
@@ -548,7 +552,7 @@ static void __pvcalls_back_accept(struct work_struct *work)
548552
sock->type = mappass->sock->type;
549553
sock->ops = mappass->sock->ops;
550554

551-
ret = inet_accept(mappass->sock, sock, O_NONBLOCK, true);
555+
ret = inet_accept(mappass->sock, sock, &arg);
552556
if (ret == -EAGAIN) {
553557
sock_release(sock);
554558
return;

fs/ocfs2/cluster/tcp.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,6 +1784,9 @@ static int o2net_accept_one(struct socket *sock, int *more)
17841784
struct o2nm_node *node = NULL;
17851785
struct o2nm_node *local_node = NULL;
17861786
struct o2net_sock_container *sc = NULL;
1787+
struct proto_accept_arg arg = {
1788+
.flags = O_NONBLOCK,
1789+
};
17871790
struct o2net_node *nn;
17881791
unsigned int nofs_flag;
17891792

@@ -1802,7 +1805,7 @@ static int o2net_accept_one(struct socket *sock, int *more)
18021805

18031806
new_sock->type = sock->type;
18041807
new_sock->ops = sock->ops;
1805-
ret = sock->ops->accept(sock, new_sock, O_NONBLOCK, false);
1808+
ret = sock->ops->accept(sock, new_sock, &arg);
18061809
if (ret < 0)
18071810
goto out;
18081811

include/crypto/if_alg.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ int af_alg_unregister_type(const struct af_alg_type *type);
166166

167167
int af_alg_release(struct socket *sock);
168168
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);
170171

171172
void af_alg_free_sg(struct af_alg_sgl *sgl);
172173

include/linux/net.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ struct sockaddr;
153153
struct msghdr;
154154
struct module;
155155
struct sk_buff;
156+
struct proto_accept_arg;
156157
typedef int (*sk_read_actor_t)(read_descriptor_t *, struct sk_buff *,
157158
unsigned int, size_t);
158159
typedef int (*skb_read_actor_t)(struct sock *, struct sk_buff *);
@@ -171,7 +172,8 @@ struct proto_ops {
171172
int (*socketpair)(struct socket *sock1,
172173
struct socket *sock2);
173174
int (*accept) (struct socket *sock,
174-
struct socket *newsock, int flags, bool kern);
175+
struct socket *newsock,
176+
struct proto_accept_arg *arg);
175177
int (*getname) (struct socket *sock,
176178
struct sockaddr *addr,
177179
int peer);

include/net/inet_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ int __inet_stream_connect(struct socket *sock, struct sockaddr *uaddr,
2929
int addr_len, int flags, int is_sendmsg);
3030
int inet_dgram_connect(struct socket *sock, struct sockaddr *uaddr,
3131
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);
3434
void __inet_accept(struct socket *sock, struct socket *newsock,
3535
struct sock *newsk);
3636
int inet_send_prepare(struct sock *sk);

include/net/inet_connection_sock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ inet_csk_rto_backoff(const struct inet_connection_sock *icsk,
250250
return (unsigned long)min_t(u64, when, max_when);
251251
}
252252

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);
254254

255255
int inet_csk_get_port(struct sock *sk, unsigned short snum);
256256

include/net/sock.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,12 @@ static inline void sk_prot_clear_nulls(struct sock *sk, int size)
11941194
size - offsetof(struct sock, sk_node.pprev));
11951195
}
11961196

1197+
struct proto_accept_arg {
1198+
int flags;
1199+
int err;
1200+
bool kern;
1201+
};
1202+
11971203
/* Networking protocol blocks we attach to sockets.
11981204
* socket layer -> transport layer interface
11991205
*/
@@ -1208,8 +1214,8 @@ struct proto {
12081214
int addr_len);
12091215
int (*disconnect)(struct sock *sk, int flags);
12101216

1211-
struct sock * (*accept)(struct sock *sk, int flags, int *err,
1212-
bool kern);
1217+
struct sock * (*accept)(struct sock *sk,
1218+
struct proto_accept_arg *arg);
12131219

12141220
int (*ioctl)(struct sock *sk, int cmd,
12151221
int *karg);
@@ -1804,7 +1810,7 @@ int sock_cmsg_send(struct sock *sk, struct msghdr *msg,
18041810
int sock_no_bind(struct socket *, struct sockaddr *, int);
18051811
int sock_no_connect(struct socket *, struct sockaddr *, int, int);
18061812
int sock_no_socketpair(struct socket *, struct socket *);
1807-
int sock_no_accept(struct socket *, struct socket *, int, bool);
1813+
int sock_no_accept(struct socket *, struct socket *, struct proto_accept_arg *);
18081814
int sock_no_getname(struct socket *, struct sockaddr *, int);
18091815
int sock_no_ioctl(struct socket *, unsigned int, unsigned long);
18101816
int sock_no_listen(struct socket *, int);

net/atm/svc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,8 @@ static int svc_listen(struct socket *sock, int backlog)
324324
return error;
325325
}
326326

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)
329329
{
330330
struct sock *sk = sock->sk;
331331
struct sk_buff *skb;
@@ -336,7 +336,7 @@ static int svc_accept(struct socket *sock, struct socket *newsock, int flags,
336336

337337
lock_sock(sk);
338338

339-
error = svc_create(sock_net(sk), newsock, 0, kern);
339+
error = svc_create(sock_net(sk), newsock, 0, arg->kern);
340340
if (error)
341341
goto out;
342342

@@ -355,7 +355,7 @@ static int svc_accept(struct socket *sock, struct socket *newsock, int flags,
355355
error = -sk->sk_err;
356356
break;
357357
}
358-
if (flags & O_NONBLOCK) {
358+
if (arg->flags & O_NONBLOCK) {
359359
error = -EAGAIN;
360360
break;
361361
}

0 commit comments

Comments
 (0)