tcp: Support skb PAWS drop reason when TIME-WAIT
Subsystems (3)
PATCH 1/1 tcp: Support skb PAWS drop reason when TIME-WAIT
When the server actively closes a connection and enters the TIME_WAIT state, if PAWS validation fails, the discarded skb previously lacked a corresponding reason identifier. This commit assigns the existing SKB_DROP_REASON_TCP_RFC7323_PAWS as the reason for such drops.
We use 'pwru' to capture drop reason.
Before this commit:
''''
./pwru 'port 9999'
2025/03/24 13:46:03 Listening for events..
TUPLE FUNC
172.31.75.115:12345->172.31.75.114:9999(tcp) sk_skb_reason_drop(SKB_DROP_REASON_NOT_SPECIFIED) '''
After this commit:
'''
./pwru 'port 9999'
2025/03/24 16:06:59 Listening for events..
TUPLE FUNC
172.31.75.115:12345->172.31.75.114:9999(tcp) sk_skb_reason_drop(SKB_DROP_REASON_TCP_RFC7323_PAWS) '''
---
My apologize.
I struggled for a long time to get packetdrill to fix the client port, but ultimately failed to do so, which is why I couldn't provide a packetdrill script.
Instead, I wrote my own program to trigger PAWS, which can be found at
https://github.com/mrpre/nettrigger/tree/main
--- include/net/tcp.h | 2 +- net/ipv4/tcp_ipv4.c | 2 +- net/ipv4/tcp_minisocks.c | 6 ++++-- net/ipv6/tcp_ipv6.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-)
include/net/tcp.h +1 -1
@@ -388,7 +388,7 @@ enum tcp_tw_status {enum tcp_tw_status tcp_timewait_state_process (struct inet_timewait_sock *tw,struct sk_buff *skb,const struct tcphdr *th, -u32 *tw_isn); +u32 *tw_isn,enum skb_drop_reason *drop_reason);struct sock *tcp_check_req (struct sock *sk,struct sk_buff *skb,struct request_sock *req,bool fastopen,bool *lost_race);
net/ipv4/tcp_ipv4.c +1 -1
@@ -2406,7 +2406,7 @@ int tcp_v4_rcv(struct sk_buff *skb)inet_twsk_put (inet_twsk (sk)); goto csum_error; } -switch (tcp_timewait_state_process (inet_twsk (sk), skb, th, &isn)) { +switch (tcp_timewait_state_process (inet_twsk (sk), skb, th, &isn, &drop_reason)) {case TCP_TW_SYN : { struct sock *sk2 = inet_lookup_listener(net, net->ipv4.tcp_death_row.hashinfo,
net/ipv4/tcp_minisocks.c +4 -2
@@ -97,7 +97,7 @@ static void twsk_rcv_nxt_update(struct tcp_timewait_sock *tcptw, u32 seq,*/ enum tcp_tw_status tcp_timewait_state_process (struct inet_timewait_sock *tw,struct sk_buff *skb, -const struct tcphdr *th,u32 *tw_isn) +const struct tcphdr *th,u32 *tw_isn,enum skb_drop_reason *drop_reason) {struct tcp_timewait_sock *tcptw =tcp_twsk ((struct sock *)tw);u32 rcv_nxt =READ_ONCE (tcptw->tw_rcv_nxt);
@@ -245,8 +245,10 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,return TCP_TW_SYN ; } -if (paws_reject) +if (paws_reject) { + *drop_reason =SKB_DROP_REASON_TCP_RFC7323_PAWS ;__NET_INC_STATS (twsk_net (tw),LINUX_MIB_PAWSESTABREJECTED ); + }if (!th->rst) {/* In this case we must reset the TIMEWAIT timer.
net/ipv6/tcp_ipv6.c +1 -1
@@ -1965,7 +1965,7 @@ INDIRECT_CALLABLE_SCOPE int tcp_v6_rcv(struct sk_buff *skb) goto csum_error; } -switch (tcp_timewait_state_process (inet_twsk (sk), skb, th, &isn)) { +switch (tcp_timewait_state_process (inet_twsk (sk), skb, th, &isn, &drop_reason)) {case TCP_TW_SYN : {struct sock *sk2;
Signature · 1 line
2.47.1
Jakub Kicinski
maintainerQuoted 6 lines · On Mon, 24 Mar 2025 21:18:05 +0800 Jiayuan Chen wrote:
When the server actively closes a connection and enters the
TIME_WAITstate, if PAWS validation fails, the discarded skb previously lacked a corresponding reason identifier. This commit assigns the existingSKB_DROP_REASON_TCP_RFC7323_PAWSas the reason for such drops.We use 'pwru' to capture drop reason.
This patch does not apply cleanly to net-next:
Applying: tcp: Support skb PAWS drop reason when TIME-WAIT
Using index info to reconstruct a base tree...
M include/net/tcp.h
M net/ipv4/tcp_ipv4.c
M net/ipv4/tcp_minisocks.c
M net/ipv6/tcp_ipv6.c
Falling back to patching base and 3-way merge...
Auto-merging net/ipv6/tcp_ipv6.c
CONFLICT (content): Merge conflict in net/ipv6/tcp_ipv6.c Auto-merging net/ipv4/tcp_minisocks.c
Auto-merging net/ipv4/tcp_ipv4.c
CONFLICT (content): Merge conflict in net/ipv4/tcp_ipv4.c Auto-merging include/net/tcp.h
Recorded preimage for 'net/ipv4/tcp_ipv4.c'
Recorded preimage for 'net/ipv6/tcp_ipv6.c'
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false" Patch failed at 0001 tcp: Support skb PAWS drop reason when TIME-WAIT
Signature · 1 line
pw-bot: cr