From: Eric Dumazet Date: Fri, 18 Dec 2015 00:14:11 +0000 (-0800) Subject: tcp: diag: add support for request sockets to tcp_abort() X-Git-Tag: firefly_0821_release~2958^2~45 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=13e7d45b6ac023bb0547221382d1e63395076bda;p=firefly-linux-kernel-4.4.55.git tcp: diag: add support for request sockets to tcp_abort() 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. [cherry-pick of net-next 07f6f4a31e5a8dee67960fc07bb0b37c5f879d4d] Change-Id: I8ec6b2e6ec24f330a69595abf1d5469ace79b3fd Signed-off-by: Eric Dumazet Cc: Lorenzo Colitti Tested-by: Lorenzo Colitti Signed-off-by: David S. Miller --- diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index ac38ffd357d5..5c63da3ae48e 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3100,6 +3100,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; }