Skip to content

Commit af77214

Browse files
edumazetdavem330
authored andcommitted
tcp: introduce TCP_PAWS_WRAP
tcp_paws_check() uses TCP_PAWS_24DAYS constant to detect if TCP TS values might have wrapped after a long idle period. This mechanism is described in RFC 7323 5.5 (Outdated Timestamps) TCP_PAWS_24DAYS value was based on the assumption of a clock of 1 Khz. As we want to adopt a 1 Mhz clock in the future, we reduce this constant. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3d44de9 commit af77214

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

include/net/tcp.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,12 @@ static_assert((1 << ATO_BITS) > TCP_DELACK_MAX);
166166
#define MAX_TCP_KEEPCNT 127
167167
#define MAX_TCP_SYNCNT 127
168168

169-
#define TCP_PAWS_24DAYS (60 * 60 * 24 * 24)
169+
/* Ensure that TCP PAWS checks are relaxed after ~2147 seconds
170+
* to avoid overflows. This assumes a clock smaller than 1 Mhz.
171+
* Default clock is 1 Khz, tcp_usec_ts uses 1 Mhz.
172+
*/
173+
#define TCP_PAWS_WRAP (INT_MAX / USEC_PER_SEC)
174+
170175
#define TCP_PAWS_MSL 60 /* Per-host timestamps are invalidated
171176
* after this time. It should be equal
172177
* (or greater than) TCP_TIMEWAIT_LEN
@@ -1619,7 +1624,7 @@ static inline bool tcp_paws_check(const struct tcp_options_received *rx_opt,
16191624
if ((s32)(rx_opt->ts_recent - rx_opt->rcv_tsval) <= paws_win)
16201625
return true;
16211626
if (unlikely(!time_before32(ktime_get_seconds(),
1622-
rx_opt->ts_recent_stamp + TCP_PAWS_24DAYS)))
1627+
rx_opt->ts_recent_stamp + TCP_PAWS_WRAP)))
16231628
return true;
16241629
/*
16251630
* Some OSes send SYN and SYNACK messages with tsval=0 tsecr=0,

0 commit comments

Comments
 (0)