Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tcp: do not expire TCP fastopen cookies

TCP metric cache expires entries after one hour.

This probably make sense for TCP RTT/RTTVAR/CWND, but not
for TCP fastopen cookies.

Its better to try previous cookie. If it appears to be obsolete,
server will send us new cookie anyway.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
efeaa555 13f85203

+9 -6
+9 -6
net/ipv4/tcp_metrics.c
··· 96 96 97 97 static DEFINE_SPINLOCK(tcp_metrics_lock); 98 98 99 - static void tcpm_suck_dst(struct tcp_metrics_block *tm, struct dst_entry *dst) 99 + static void tcpm_suck_dst(struct tcp_metrics_block *tm, struct dst_entry *dst, 100 + bool fastopen_clear) 100 101 { 101 102 u32 val; 102 103 ··· 123 122 tm->tcpm_vals[TCP_METRIC_REORDERING] = dst_metric_raw(dst, RTAX_REORDERING); 124 123 tm->tcpm_ts = 0; 125 124 tm->tcpm_ts_stamp = 0; 126 - tm->tcpm_fastopen.mss = 0; 127 - tm->tcpm_fastopen.syn_loss = 0; 128 - tm->tcpm_fastopen.cookie.len = 0; 125 + if (fastopen_clear) { 126 + tm->tcpm_fastopen.mss = 0; 127 + tm->tcpm_fastopen.syn_loss = 0; 128 + tm->tcpm_fastopen.cookie.len = 0; 129 + } 129 130 } 130 131 131 132 static struct tcp_metrics_block *tcpm_new(struct dst_entry *dst, ··· 157 154 } 158 155 tm->tcpm_addr = *addr; 159 156 160 - tcpm_suck_dst(tm, dst); 157 + tcpm_suck_dst(tm, dst, true); 161 158 162 159 if (likely(!reclaim)) { 163 160 tm->tcpm_next = net->ipv4.tcp_metrics_hash[hash].chain; ··· 174 171 static void tcpm_check_stamp(struct tcp_metrics_block *tm, struct dst_entry *dst) 175 172 { 176 173 if (tm && unlikely(time_after(jiffies, tm->tcpm_stamp + TCP_METRICS_TIMEOUT))) 177 - tcpm_suck_dst(tm, dst); 174 + tcpm_suck_dst(tm, dst, false); 178 175 } 179 176 180 177 #define TCP_METRICS_RECLAIM_DEPTH 5