tcp/dccp: add inet_csk_reqsk_queue_drop_and_put() helper
authorEric Dumazet <edumazet@google.com>
Wed, 14 Oct 2015 18:16:27 +0000 (11:16 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 16 Oct 2015 07:52:18 +0000 (00:52 -0700)
Let's reduce the confusion about inet_csk_reqsk_queue_drop() :
In many cases we also need to release reference on request socket,
so add a helper to do this, reducing code size and complexity.

Fixes: 4bdc3d66147b ("tcp/dccp: fix behavior of stale SYN_RECV request sockets")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/inet_connection_sock.h
net/dccp/ipv4.c
net/dccp/ipv6.c
net/ipv4/inet_connection_sock.c
net/ipv4/tcp_ipv4.c
net/ipv6/tcp_ipv6.c

index fd645c49e71ef3e39d6452f054857b1b32176c9d..e84ea9f2498ffeba25c997ae8f2436b717ec5906 100644 (file)
@@ -299,6 +299,7 @@ static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk)
 }
 
 void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req);
+void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req);
 
 void inet_csk_destroy_sock(struct sock *sk);
 void inet_csk_prepare_forced_close(struct sock *sk);
index 644af510d932c0ff33ef15097ba4228c4e87027e..59bc180b02d8cb1dcc2e7c2681e2c86864bc4e63 100644 (file)
@@ -828,7 +828,7 @@ lookup:
                if (likely(sk->sk_state == DCCP_LISTEN)) {
                        nsk = dccp_check_req(sk, skb, req);
                } else {
-                       inet_csk_reqsk_queue_drop(sk, req);
+                       inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
                }
                if (!nsk) {
index 68831931b1fe63a46031fe3324f8a0546f330236..d9cc731f261974c80b405f461c2c4224154caa8f 100644 (file)
@@ -686,7 +686,7 @@ lookup:
                if (likely(sk->sk_state == DCCP_LISTEN)) {
                        nsk = dccp_check_req(sk, skb, req);
                } else {
-                       inet_csk_reqsk_queue_drop(sk, req);
+                       inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
                }
                if (!nsk) {
index ba9ec9a0d0ce5fad74a811ab82d4408594474893..b85c720956a996210dc070cdbeb05d20b6e773ee 100644 (file)
@@ -546,6 +546,13 @@ void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req)
 }
 EXPORT_SYMBOL(inet_csk_reqsk_queue_drop);
 
+void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req)
+{
+       inet_csk_reqsk_queue_drop(sk, req);
+       reqsk_put(req);
+}
+EXPORT_SYMBOL(inet_csk_reqsk_queue_drop_and_put);
+
 static void reqsk_timer_handler(unsigned long data)
 {
        struct request_sock *req = (struct request_sock *)data;
@@ -608,8 +615,7 @@ static void reqsk_timer_handler(unsigned long data)
                return;
        }
 drop:
-       inet_csk_reqsk_queue_drop(sk_listener, req);
-       reqsk_put(req);
+       inet_csk_reqsk_queue_drop_and_put(sk_listener, req);
 }
 
 static void reqsk_queue_hash_req(struct request_sock *req,
index aad2298de7adda3e2c32be9adbf2c1da8d5c75bd..9c68cf3762c4407b321635b7a1fb969468f86bf9 100644 (file)
@@ -1591,7 +1591,7 @@ process:
                if (likely(sk->sk_state == TCP_LISTEN)) {
                        nsk = tcp_check_req(sk, skb, req, false);
                } else {
-                       inet_csk_reqsk_queue_drop(sk, req);
+                       inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
                }
                if (!nsk) {
index 7ce1c57199d13ac4b5d20ab47a32471493322edd..acb06f86f3723f09722d0458232a0c56306db472 100644 (file)
@@ -1386,7 +1386,7 @@ process:
                if (likely(sk->sk_state == TCP_LISTEN)) {
                        nsk = tcp_check_req(sk, skb, req, false);
                } else {
-                       inet_csk_reqsk_queue_drop(sk, req);
+                       inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
                }
                if (!nsk) {