aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp_minisocks.c
diff options
context:
space:
mode:
authorSoheil Hassas Yeganeh <soheil@google.com>2017-03-15 16:30:45 -0400
committerDavid S. Miller <davem@davemloft.net>2017-03-16 23:33:56 -0400
commitd82bae12dc38d79a2b77473f5eb0612a3d69c55b (patch)
tree677ef02fce0b832e01c02c21f37fa7d653663104 /net/ipv4/tcp_minisocks.c
parent8b705f5241adb2d0b5d009abea5a865601666974 (diff)
tcp: remove per-destination timestamp cache
Commit 8a5bd45f6616 (tcp: randomize tcp timestamp offsets for each connection) randomizes TCP timestamps per connection. After this commit, there is no guarantee that the timestamps received from the same destination are monotonically increasing. As a result, the per-destination timestamp cache in TCP metrics (i.e., tcpm_ts in struct tcp_metrics_block) is broken and cannot be relied upon. Remove the per-destination timestamp cache and all related code paths. Note that this cache was already broken for caching timestamps of multiple machines behind a NAT sharing the same address. Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: Yuchung Cheng <ycheng@google.com> Cc: Lutz Vieweg <lvml@5t9.de> Cc: Florian Westphal <fw@strlen.de> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/tcp_minisocks.c')
-rw-r--r--net/ipv4/tcp_minisocks.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
index 7e16243cdb58..692f974e5abe 100644
--- a/net/ipv4/tcp_minisocks.c
+++ b/net/ipv4/tcp_minisocks.c
@@ -94,7 +94,6 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
94 struct tcp_options_received tmp_opt; 94 struct tcp_options_received tmp_opt;
95 struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw); 95 struct tcp_timewait_sock *tcptw = tcp_twsk((struct sock *)tw);
96 bool paws_reject = false; 96 bool paws_reject = false;
97 struct inet_timewait_death_row *tcp_death_row = &sock_net((struct sock*)tw)->ipv4.tcp_death_row;
98 97
99 tmp_opt.saw_tstamp = 0; 98 tmp_opt.saw_tstamp = 0;
100 if (th->doff > (sizeof(*th) >> 2) && tcptw->tw_ts_recent_stamp) { 99 if (th->doff > (sizeof(*th) >> 2) && tcptw->tw_ts_recent_stamp) {
@@ -149,12 +148,7 @@ tcp_timewait_state_process(struct inet_timewait_sock *tw, struct sk_buff *skb,
149 tcptw->tw_ts_recent = tmp_opt.rcv_tsval; 148 tcptw->tw_ts_recent = tmp_opt.rcv_tsval;
150 } 149 }
151 150
152 if (tcp_death_row->sysctl_tw_recycle && 151 inet_twsk_reschedule(tw, TCP_TIMEWAIT_LEN);
153 tcptw->tw_ts_recent_stamp &&
154 tcp_tw_remember_stamp(tw))
155 inet_twsk_reschedule(tw, tw->tw_timeout);
156 else
157 inet_twsk_reschedule(tw, TCP_TIMEWAIT_LEN);
158 return TCP_TW_ACK; 152 return TCP_TW_ACK;
159 } 153 }
160 154
@@ -259,12 +253,8 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
259 const struct inet_connection_sock *icsk = inet_csk(sk); 253 const struct inet_connection_sock *icsk = inet_csk(sk);
260 const struct tcp_sock *tp = tcp_sk(sk); 254 const struct tcp_sock *tp = tcp_sk(sk);
261 struct inet_timewait_sock *tw; 255 struct inet_timewait_sock *tw;
262 bool recycle_ok = false;
263 struct inet_timewait_death_row *tcp_death_row = &sock_net(sk)->ipv4.tcp_death_row; 256 struct inet_timewait_death_row *tcp_death_row = &sock_net(sk)->ipv4.tcp_death_row;
264 257
265 if (tcp_death_row->sysctl_tw_recycle && tp->rx_opt.ts_recent_stamp)
266 recycle_ok = tcp_remember_stamp(sk);
267
268 tw = inet_twsk_alloc(sk, tcp_death_row, state); 258 tw = inet_twsk_alloc(sk, tcp_death_row, state);
269 259
270 if (tw) { 260 if (tw) {
@@ -317,13 +307,9 @@ void tcp_time_wait(struct sock *sk, int state, int timeo)
317 if (timeo < rto) 307 if (timeo < rto)
318 timeo = rto; 308 timeo = rto;
319 309
320 if (recycle_ok) { 310 tw->tw_timeout = TCP_TIMEWAIT_LEN;
321 tw->tw_timeout = rto; 311 if (state == TCP_TIME_WAIT)
322 } else { 312 timeo = TCP_TIMEWAIT_LEN;
323 tw->tw_timeout = TCP_TIMEWAIT_LEN;
324 if (state == TCP_TIME_WAIT)
325 timeo = TCP_TIMEWAIT_LEN;
326 }
327 313
328 inet_twsk_schedule(tw, timeo); 314 inet_twsk_schedule(tw, timeo);
329 /* Linkage updates. */ 315 /* Linkage updates. */