Skip to content

Commit 7951e36

Browse files
committed
net: pass back whether socket was empty post accept
This adds an 'is_empty' argument to struct proto_accept_arg, which can be used to pass back information on whether or not the given socket has more connections to accept post the one just accepted. To utilize this information, the caller should initialize the 'is_empty' field to, eg, -1 and then check for 0/1 after the accept. If the field has been set, the caller knows whether there are more pending connections or not. If the field remains -1 after the accept call, the protocol doesn't support passing back this information. This patch wires it up for ipv4/6 TCP. Acked-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 0645fbe commit 7951e36

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

include/net/sock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,7 @@ static inline void sk_prot_clear_nulls(struct sock *sk, int size)
11971197
struct proto_accept_arg {
11981198
int flags;
11991199
int err;
1200+
int is_empty;
12001201
bool kern;
12011202
};
12021203

net/ipv4/inet_connection_sock.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,7 @@ struct sock *inet_csk_accept(struct sock *sk, struct proto_accept_arg *arg)
692692
goto out_err;
693693
}
694694
req = reqsk_queue_remove(queue, sk);
695+
arg->is_empty = reqsk_queue_empty(queue);
695696
newsk = req->sk;
696697

697698
if (sk->sk_protocol == IPPROTO_TCP &&

0 commit comments

Comments
 (0)