mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
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" <[email protected]> Cc: Alexey Kuznetsov <[email protected]> Cc: James Morris <[email protected]> Cc: Hideaki YOSHIFUJI <[email protected]> Cc: Patrick McHardy <[email protected]> Cc: Eric Dumazet <[email protected]> Cc: Pavel Emelyanov <[email protected]> Signed-off-by: Andrey Vagin <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
parent
ceaa1fef65
commit
93be6ce0e9
2 changed files with 10 additions and 0 deletions
|
|
@ -2714,6 +2714,12 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
|
|||
else
|
||||
err = -EINVAL;
|
||||
break;
|
||||
case TCP_TIMESTAMP:
|
||||
if (!tp->repair)
|
||||
err = -EPERM;
|
||||
else
|
||||
tp->tsoffset = val - tcp_time_stamp;
|
||||
break;
|
||||
default:
|
||||
err = -ENOPROTOOPT;
|
||||
break;
|
||||
|
|
@ -2962,6 +2968,9 @@ static int do_tcp_getsockopt(struct sock *sk, int level,
|
|||
case TCP_USER_TIMEOUT:
|
||||
val = jiffies_to_msecs(icsk->icsk_user_timeout);
|
||||
break;
|
||||
case TCP_TIMESTAMP:
|
||||
val = tcp_time_stamp + tp->tsoffset;
|
||||
break;
|
||||
default:
|
||||
return -ENOPROTOOPT;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue