Skip to content

Commit f03f2e1

Browse files
edumazetdavem330
authored andcommitted
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: 4bdc3d6 ("tcp/dccp: fix behavior of stale SYN_RECV request sockets") Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ef84d8c commit f03f2e1

File tree

6 files changed

+13
-6
lines changed

6 files changed

+13
-6
lines changed

include/net/inet_connection_sock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk)
299299
}
300300

301301
void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req);
302+
void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req);
302303

303304
void inet_csk_destroy_sock(struct sock *sk);
304305
void inet_csk_prepare_forced_close(struct sock *sk);

net/dccp/ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ static int dccp_v4_rcv(struct sk_buff *skb)
828828
if (likely(sk->sk_state == DCCP_LISTEN)) {
829829
nsk = dccp_check_req(sk, skb, req);
830830
} else {
831-
inet_csk_reqsk_queue_drop(sk, req);
831+
inet_csk_reqsk_queue_drop_and_put(sk, req);
832832
goto lookup;
833833
}
834834
if (!nsk) {

net/dccp/ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ static int dccp_v6_rcv(struct sk_buff *skb)
686686
if (likely(sk->sk_state == DCCP_LISTEN)) {
687687
nsk = dccp_check_req(sk, skb, req);
688688
} else {
689-
inet_csk_reqsk_queue_drop(sk, req);
689+
inet_csk_reqsk_queue_drop_and_put(sk, req);
690690
goto lookup;
691691
}
692692
if (!nsk) {

net/ipv4/inet_connection_sock.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,13 @@ void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req)
546546
}
547547
EXPORT_SYMBOL(inet_csk_reqsk_queue_drop);
548548

549+
void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req)
550+
{
551+
inet_csk_reqsk_queue_drop(sk, req);
552+
reqsk_put(req);
553+
}
554+
EXPORT_SYMBOL(inet_csk_reqsk_queue_drop_and_put);
555+
549556
static void reqsk_timer_handler(unsigned long data)
550557
{
551558
struct request_sock *req = (struct request_sock *)data;
@@ -608,8 +615,7 @@ static void reqsk_timer_handler(unsigned long data)
608615
return;
609616
}
610617
drop:
611-
inet_csk_reqsk_queue_drop(sk_listener, req);
612-
reqsk_put(req);
618+
inet_csk_reqsk_queue_drop_and_put(sk_listener, req);
613619
}
614620

615621
static void reqsk_queue_hash_req(struct request_sock *req,

net/ipv4/tcp_ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
15911591
if (likely(sk->sk_state == TCP_LISTEN)) {
15921592
nsk = tcp_check_req(sk, skb, req, false);
15931593
} else {
1594-
inet_csk_reqsk_queue_drop(sk, req);
1594+
inet_csk_reqsk_queue_drop_and_put(sk, req);
15951595
goto lookup;
15961596
}
15971597
if (!nsk) {

net/ipv6/tcp_ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ static int tcp_v6_rcv(struct sk_buff *skb)
13861386
if (likely(sk->sk_state == TCP_LISTEN)) {
13871387
nsk = tcp_check_req(sk, skb, req, false);
13881388
} else {
1389-
inet_csk_reqsk_queue_drop(sk, req);
1389+
inet_csk_reqsk_queue_drop_and_put(sk, req);
13901390
goto lookup;
13911391
}
13921392
if (!nsk) {

0 commit comments

Comments
 (0)