Commit f03f2e15 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

tcp/dccp: add inet_csk_reqsk_queue_drop_and_put() helper

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: 4bdc3d66 ("tcp/dccp: fix behavior of stale SYN_RECV request sockets")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ef84d8ce
...@@ -299,6 +299,7 @@ static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk) ...@@ -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(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_destroy_sock(struct sock *sk);
void inet_csk_prepare_forced_close(struct sock *sk); void inet_csk_prepare_forced_close(struct sock *sk);
......
...@@ -828,7 +828,7 @@ static int dccp_v4_rcv(struct sk_buff *skb) ...@@ -828,7 +828,7 @@ static int dccp_v4_rcv(struct sk_buff *skb)
if (likely(sk->sk_state == DCCP_LISTEN)) { if (likely(sk->sk_state == DCCP_LISTEN)) {
nsk = dccp_check_req(sk, skb, req); nsk = dccp_check_req(sk, skb, req);
} else { } else {
inet_csk_reqsk_queue_drop(sk, req); inet_csk_reqsk_queue_drop_and_put(sk, req);
goto lookup; goto lookup;
} }
if (!nsk) { if (!nsk) {
......
...@@ -686,7 +686,7 @@ static int dccp_v6_rcv(struct sk_buff *skb) ...@@ -686,7 +686,7 @@ static int dccp_v6_rcv(struct sk_buff *skb)
if (likely(sk->sk_state == DCCP_LISTEN)) { if (likely(sk->sk_state == DCCP_LISTEN)) {
nsk = dccp_check_req(sk, skb, req); nsk = dccp_check_req(sk, skb, req);
} else { } else {
inet_csk_reqsk_queue_drop(sk, req); inet_csk_reqsk_queue_drop_and_put(sk, req);
goto lookup; goto lookup;
} }
if (!nsk) { if (!nsk) {
......
...@@ -546,6 +546,13 @@ void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req) ...@@ -546,6 +546,13 @@ void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req)
} }
EXPORT_SYMBOL(inet_csk_reqsk_queue_drop); 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) static void reqsk_timer_handler(unsigned long data)
{ {
struct request_sock *req = (struct request_sock *)data; struct request_sock *req = (struct request_sock *)data;
...@@ -608,8 +615,7 @@ static void reqsk_timer_handler(unsigned long data) ...@@ -608,8 +615,7 @@ static void reqsk_timer_handler(unsigned long data)
return; return;
} }
drop: drop:
inet_csk_reqsk_queue_drop(sk_listener, req); inet_csk_reqsk_queue_drop_and_put(sk_listener, req);
reqsk_put(req);
} }
static void reqsk_queue_hash_req(struct request_sock *req, static void reqsk_queue_hash_req(struct request_sock *req,
......
...@@ -1591,7 +1591,7 @@ int tcp_v4_rcv(struct sk_buff *skb) ...@@ -1591,7 +1591,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
if (likely(sk->sk_state == TCP_LISTEN)) { if (likely(sk->sk_state == TCP_LISTEN)) {
nsk = tcp_check_req(sk, skb, req, false); nsk = tcp_check_req(sk, skb, req, false);
} else { } else {
inet_csk_reqsk_queue_drop(sk, req); inet_csk_reqsk_queue_drop_and_put(sk, req);
goto lookup; goto lookup;
} }
if (!nsk) { if (!nsk) {
......
...@@ -1386,7 +1386,7 @@ static int tcp_v6_rcv(struct sk_buff *skb) ...@@ -1386,7 +1386,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
if (likely(sk->sk_state == TCP_LISTEN)) { if (likely(sk->sk_state == TCP_LISTEN)) {
nsk = tcp_check_req(sk, skb, req, false); nsk = tcp_check_req(sk, skb, req, false);
} else { } else {
inet_csk_reqsk_queue_drop(sk, req); inet_csk_reqsk_queue_drop_and_put(sk, req);
goto lookup; goto lookup;
} }
if (!nsk) { if (!nsk) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment