Commit ceaa1fef65a7c2e017b260b879b310dd24888083
Committed by
David S. Miller
1 parent
d0023f820e
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
tcp: adding a per-socket timestamp offset
This functionality is used for restoring tcp sockets. A tcp timestamp depends on how long a system has been running, so it's differ for each host. The solution is to set a per-socket offset. A per-socket offset for a TIME_WAIT socket is inherited from a proper tcp socket. tcp_request_sock doesn't have a timestamp offset, because the repair mode for them are not implemented. Cc: "David S. Miller" <davem@davemloft.net> Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru> Cc: James Morris <jmorris@namei.org> Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org> Cc: Patrick McHardy <kaber@trash.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Showing 3 changed files with 7 additions and 0 deletions Side-by-side Diff
include/linux/tcp.h
... | ... | @@ -162,6 +162,8 @@ |
162 | 162 | u32 rcv_tstamp; /* timestamp of last received ACK (for keepalives) */ |
163 | 163 | u32 lsndtime; /* timestamp of last sent data packet (for restart window) */ |
164 | 164 | |
165 | + u32 tsoffset; /* timestamp offset */ | |
166 | + | |
165 | 167 | struct list_head tsq_node; /* anchor in tsq_tasklet.head list */ |
166 | 168 | unsigned long tsq_flags; |
167 | 169 | |
... | ... | @@ -353,6 +355,7 @@ |
353 | 355 | u32 tw_rcv_nxt; |
354 | 356 | u32 tw_snd_nxt; |
355 | 357 | u32 tw_rcv_wnd; |
358 | + u32 tw_ts_offset; | |
356 | 359 | u32 tw_ts_recent; |
357 | 360 | long tw_ts_recent_stamp; |
358 | 361 | #ifdef CONFIG_TCP_MD5SIG |
net/ipv4/tcp.c
net/ipv4/tcp_minisocks.c
... | ... | @@ -288,6 +288,7 @@ |
288 | 288 | tcptw->tw_rcv_wnd = tcp_receive_window(tp); |
289 | 289 | tcptw->tw_ts_recent = tp->rx_opt.ts_recent; |
290 | 290 | tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp; |
291 | + tcptw->tw_ts_offset = tp->tsoffset; | |
291 | 292 | |
292 | 293 | #if IS_ENABLED(CONFIG_IPV6) |
293 | 294 | if (tw->tw_family == PF_INET6) { |
... | ... | @@ -499,6 +500,7 @@ |
499 | 500 | newtp->rx_opt.ts_recent_stamp = 0; |
500 | 501 | newtp->tcp_header_len = sizeof(struct tcphdr); |
501 | 502 | } |
503 | + newtp->tsoffset = 0; | |
502 | 504 | #ifdef CONFIG_TCP_MD5SIG |
503 | 505 | newtp->md5sig_info = NULL; /*XXX*/ |
504 | 506 | if (newtp->af_specific->md5_lookup(sk, newsk)) |