summaryrefslogtreecommitdiffstats
path: root/net/ipv4/tcp.c
diff options
context:
space:
mode:
authorAndrey Vagin <avagin@openvz.org>2013-02-11 00:50:18 -0500
committerDavid S. Miller <davem@davemloft.net>2013-02-13 13:22:15 -0500
commit93be6ce0e91b6a94783e012b1857a347a5e6e9f2 (patch)
tree55b7f545fea634d5cde59e21de1470761b7190a7 /net/ipv4/tcp.c
parentceaa1fef65a7c2e017b260b879b310dd24888083 (diff)
tcp: set and get per-socket timestamp
A timestamp can be set, only if a socket is in the repair mode. This patch adds a new socket option TCP_TIMESTAMP, which allows to get and set current tcp times stamp. 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/ipv4/tcp.c')
-rw-r--r--net/ipv4/tcp.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 8a90bda96038..801b07b796f0 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2714,6 +2714,12 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
2714 else 2714 else
2715 err = -EINVAL; 2715 err = -EINVAL;
2716 break; 2716 break;
2717 case TCP_TIMESTAMP:
2718 if (!tp->repair)
2719 err = -EPERM;
2720 else
2721 tp->tsoffset = val - tcp_time_stamp;
2722 break;
2717 default: 2723 default:
2718 err = -ENOPROTOOPT; 2724 err = -ENOPROTOOPT;
2719 break; 2725 break;
@@ -2962,6 +2968,9 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
2962 case TCP_USER_TIMEOUT: 2968 case TCP_USER_TIMEOUT:
2963 val = jiffies_to_msecs(icsk->icsk_user_timeout); 2969 val = jiffies_to_msecs(icsk->icsk_user_timeout);
2964 break; 2970 break;
2971 case TCP_TIMESTAMP:
2972 val = tcp_time_stamp + tp->tsoffset;
2973 break;
2965 default: 2974 default:
2966 return -ENOPROTOOPT; 2975 return -ENOPROTOOPT;
2967 } 2976 }