Re: [PATCH 2/2] tcp: add ability to set a timestamp offset (v2)

Pavel Emelyanov
2013-01-23T15:26:46Z

> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index 086ceda..23f93d4 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2704,6 +2704,10 @@ static int do_tcp_setsockopt(struct sock *sk, int level,
> else
> err = -EINVAL;
> break;
> + case TCP_TIMESTAMP:
> + tp->tsoffset = 0;
> + tp->tsoffset = val - tcp_time_stamp(tp);

I believe we should check that the socket state is TCP_CLOSE.
Otherwise tcp_time_stamp() readers might be surprised while
reading the value.

> + break;
> default:
> err = -ENOPROTOOPT;
> break;