Skip to content

Commit 22a3255

Browse files
JasonXingkuba-moo
authored andcommitted
tcp: rstreason: handle timewait cases in the receive path
There are two possible cases where TCP layer can send an RST. Since they happen in the same place, I think using one independent reason is enough to identify this special situation. Signed-off-by: Jason Xing <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f6d5e2c commit 22a3255

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

include/net/rstreason.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
FN(TCP_FLAGS) \
1616
FN(TCP_OLD_ACK) \
1717
FN(TCP_ABORT_ON_DATA) \
18+
FN(TCP_TIMEWAIT_SOCKET) \
1819
FN(MPTCP_RST_EUNSPEC) \
1920
FN(MPTCP_RST_EMPTCP) \
2021
FN(MPTCP_RST_ERESOURCE) \
@@ -72,6 +73,10 @@ enum sk_rst_reason {
7273
*/
7374
SK_RST_REASON_TCP_ABORT_ON_DATA,
7475

76+
/* Here start with the independent reasons */
77+
/** @SK_RST_REASON_TCP_TIMEWAIT_SOCKET: happen on the timewait socket */
78+
SK_RST_REASON_TCP_TIMEWAIT_SOCKET,
79+
7580
/* Copy from include/uapi/linux/mptcp.h.
7681
* These reset fields will not be changed since they adhere to
7782
* RFC 8684. So do not touch them. I'm going to list each definition

net/ipv4/tcp_ipv4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2427,7 +2427,7 @@ int tcp_v4_rcv(struct sk_buff *skb)
24272427
tcp_v4_timewait_ack(sk, skb);
24282428
break;
24292429
case TCP_TW_RST:
2430-
tcp_v4_send_reset(sk, skb, sk_rst_convert_drop_reason(drop_reason));
2430+
tcp_v4_send_reset(sk, skb, SK_RST_REASON_TCP_TIMEWAIT_SOCKET);
24312431
inet_twsk_deschedule_put(inet_twsk(sk));
24322432
goto discard_it;
24332433
case TCP_TW_SUCCESS:;

net/ipv6/tcp_ipv6.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1999,7 +1999,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb)
19991999
tcp_v6_timewait_ack(sk, skb);
20002000
break;
20012001
case TCP_TW_RST:
2002-
tcp_v6_send_reset(sk, skb, sk_rst_convert_drop_reason(drop_reason));
2002+
tcp_v6_send_reset(sk, skb, SK_RST_REASON_TCP_TIMEWAIT_SOCKET);
20032003
inet_twsk_deschedule_put(inet_twsk(sk));
20042004
goto discard_it;
20052005
case TCP_TW_SUCCESS:

0 commit comments

Comments
 (0)