aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Tuexen <tuexen@FreeBSD.org>2022-10-03 12:46:47 +0000
committerMichael Tuexen <tuexen@FreeBSD.org>2022-10-03 12:46:47 +0000
commit2515552e6216095c3fa61d93ee024bb8861e07c2 (patch)
tree769a9250fdae989b32c6310d19f0d1f22d9f2391
parentdcdba3460dd779a0180ec7769ab8cd47c932799e (diff)
downloadsrc-2515552e6216095c3fa61d93ee024bb8861e07c2.tar.gz
src-2515552e6216095c3fa61d93ee024bb8861e07c2.zip
tcp: improve handling of SYN-ACK segments in TIMEWAIT state
Only consider segments with the SYN bit set and the ACK bit cleared as "new connection attempts", which result in re-using a connection being in TIMEWAIT state. This results in consistent handling of SYN-ACK segments. Reviewed by: rscheff@ MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D36864
-rw-r--r--sys/netinet/tcp_timewait.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c
index ad97e2d3bed6..272734924384 100644
--- a/sys/netinet/tcp_timewait.c
+++ b/sys/netinet/tcp_timewait.c
@@ -464,13 +464,13 @@ tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th,
* are above the previous ones.
* Allow UDP port number changes in this case.
*/
- if ((thflags & TH_SYN) && SEQ_GT(th->th_seq, tw->rcv_nxt)) {
+ if (((thflags & (TH_SYN | TH_ACK)) == TH_SYN) &&
+ SEQ_GT(th->th_seq, tw->rcv_nxt)) {
/*
* In case we can't upgrade our lock just pretend we have
* lost this packet.
*/
- if (((thflags & (TH_SYN | TH_ACK)) == TH_SYN) &&
- INP_TRY_UPGRADE(inp) == 0)
+ if (INP_TRY_UPGRADE(inp) == 0)
goto drop;
tcp_twclose(tw, 0);
TCPSTAT_INC(tcps_tw_recycles);