diff options
author | Andrey Vagin <avagin@openvz.org> | 2013-02-11 00:50:17 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-02-13 13:22:15 -0500 |
commit | ceaa1fef65a7c2e017b260b879b310dd24888083 (patch) | |
tree | f511458ce6431cd4b5f5b46f4c633f73e49a3589 /net | |
parent | d0023f820e003857248d14f2213ac3930283f16c (diff) |
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>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/tcp.c | 2 | ||||
-rw-r--r-- | net/ipv4/tcp_minisocks.c | 2 |
2 files changed, 4 insertions, 0 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 2c7e5963c2ea..8a90bda96038 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
@@ -400,6 +400,8 @@ void tcp_init_sock(struct sock *sk) | |||
400 | tcp_enable_early_retrans(tp); | 400 | tcp_enable_early_retrans(tp); |
401 | icsk->icsk_ca_ops = &tcp_init_congestion_ops; | 401 | icsk->icsk_ca_ops = &tcp_init_congestion_ops; |
402 | 402 | ||
403 | tp->tsoffset = 0; | ||
404 | |||
403 | sk->sk_state = TCP_CLOSE; | 405 | sk->sk_state = TCP_CLOSE; |
404 | 406 | ||
405 | sk->sk_write_space = sk_stream_write_space; | 407 | sk->sk_write_space = sk_stream_write_space; |
diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c index f0409287b5f4..4dfc99f54f67 100644 --- a/net/ipv4/tcp_minisocks.c +++ b/net/ipv4/tcp_minisocks.c | |||
@@ -288,6 +288,7 @@ void tcp_time_wait(struct sock *sk, int state, int timeo) | |||
288 | tcptw->tw_rcv_wnd = tcp_receive_window(tp); | 288 | tcptw->tw_rcv_wnd = tcp_receive_window(tp); |
289 | tcptw->tw_ts_recent = tp->rx_opt.ts_recent; | 289 | tcptw->tw_ts_recent = tp->rx_opt.ts_recent; |
290 | tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp; | 290 | tcptw->tw_ts_recent_stamp = tp->rx_opt.ts_recent_stamp; |
291 | tcptw->tw_ts_offset = tp->tsoffset; | ||
291 | 292 | ||
292 | #if IS_ENABLED(CONFIG_IPV6) | 293 | #if IS_ENABLED(CONFIG_IPV6) |
293 | if (tw->tw_family == PF_INET6) { | 294 | if (tw->tw_family == PF_INET6) { |
@@ -499,6 +500,7 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req, | |||
499 | newtp->rx_opt.ts_recent_stamp = 0; | 500 | newtp->rx_opt.ts_recent_stamp = 0; |
500 | newtp->tcp_header_len = sizeof(struct tcphdr); | 501 | newtp->tcp_header_len = sizeof(struct tcphdr); |
501 | } | 502 | } |
503 | newtp->tsoffset = 0; | ||
502 | #ifdef CONFIG_TCP_MD5SIG | 504 | #ifdef CONFIG_TCP_MD5SIG |
503 | newtp->md5sig_info = NULL; /*XXX*/ | 505 | newtp->md5sig_info = NULL; /*XXX*/ |
504 | if (newtp->af_specific->md5_lookup(sk, newsk)) | 506 | if (newtp->af_specific->md5_lookup(sk, newsk)) |