Skip to content

Commit 25429d7

Browse files
Florian Westphaldavem330
authored andcommitted
tcp: allow to turn tcp timestamp randomization off
Eric says: "By looking at tcpdump, and TS val of xmit packets of multiple flows, we can deduct the relative qdisc delays (think of fq pacing). This should work even if we have one flow per remote peer." Having random per flow (or host) offsets doesn't allow that anymore so add a way to turn this off. Suggested-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Florian Westphal <fw@strlen.de> Acked-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 95a22ca commit 25429d7

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Documentation/networking/ip-sysctl.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -610,8 +610,13 @@ tcp_syn_retries - INTEGER
610610
with the current initial RTO of 1second. With this the final timeout
611611
for an active TCP connection attempt will happen after 127seconds.
612612

613-
tcp_timestamps - BOOLEAN
614-
Enable timestamps as defined in RFC1323.
613+
tcp_timestamps - INTEGER
614+
Enable timestamps as defined in RFC1323.
615+
0: Disabled.
616+
1: Enable timestamps as defined in RFC1323 and use random offset for
617+
each connection rather than only using the current time.
618+
2: Like 1, but without random offsets.
619+
Default: 1
615620

616621
tcp_min_tso_segs - INTEGER
617622
Minimal number of segments per TSO frame.

net/core/secure_seq.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <net/secure_seq.h>
1313

1414
#if IS_ENABLED(CONFIG_IPV6) || IS_ENABLED(CONFIG_INET)
15+
#include <net/tcp.h>
1516
#define NET_SECRET_SIZE (MD5_MESSAGE_BYTES / 4)
1617

1718
static u32 net_secret[NET_SECRET_SIZE] ____cacheline_aligned;
@@ -58,7 +59,7 @@ u32 secure_tcpv6_sequence_number(const __be32 *saddr, const __be32 *daddr,
5859

5960
md5_transform(hash, secret);
6061

61-
*tsoff = hash[1];
62+
*tsoff = sysctl_tcp_timestamps == 1 ? hash[1] : 0;
6263
return seq_scale(hash[0]);
6364
}
6465
EXPORT_SYMBOL(secure_tcpv6_sequence_number);
@@ -100,7 +101,7 @@ u32 secure_tcp_sequence_number(__be32 saddr, __be32 daddr,
100101

101102
md5_transform(hash, net_secret);
102103

103-
*tsoff = hash[1];
104+
*tsoff = sysctl_tcp_timestamps == 1 ? hash[1] : 0;
104105
return seq_scale(hash[0]);
105106
}
106107

net/ipv4/tcp_input.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ int sysctl_tcp_dsack __read_mostly = 1;
8585
int sysctl_tcp_app_win __read_mostly = 31;
8686
int sysctl_tcp_adv_win_scale __read_mostly = 1;
8787
EXPORT_SYMBOL(sysctl_tcp_adv_win_scale);
88+
EXPORT_SYMBOL(sysctl_tcp_timestamps);
8889

8990
/* rfc5961 challenge ack rate limiting */
9091
int sysctl_tcp_challenge_ack_limit = 1000;

0 commit comments

Comments
 (0)