tcp: diag: add support for request sockets to tcp_abort()
authorEric Dumazet <edumazet@google.com>
Fri, 18 Dec 2015 00:14:11 +0000 (16:14 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Dec 2015 21:06:39 +0000 (16:06 -0500)
Adding support for SYN_RECV request sockets to tcp_abort()
is quite easy after our tcp listener rewrite.

Note that we also need to better handle listeners, or we might
leak not yet accepted children, because of a missing
inet_csk_listen_stop() call.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Lorenzo Colitti <lorenzo@google.com>
Tested-by: Lorenzo Colitti <lorenzo@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp.c

index 2c0e340518d2a1902248973d918aa58f59027eb8..cc7aaa507abf424699f6c6a26f7780ceecdf43ed 100644 (file)
@@ -3083,6 +3083,15 @@ EXPORT_SYMBOL_GPL(tcp_done);
 int tcp_abort(struct sock *sk, int err)
 {
        if (!sk_fullsock(sk)) {
+               if (sk->sk_state == TCP_NEW_SYN_RECV) {
+                       struct request_sock *req = inet_reqsk(sk);
+
+                       local_bh_disable();
+                       inet_csk_reqsk_queue_drop_and_put(req->rsk_listener,
+                                                         req);
+                       local_bh_enable();
+                       return 0;
+               }
                sock_gen_put(sk);
                return -EOPNOTSUPP;
        }