Commit 2a7c8d29 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

tcp: introduce tcp_clock_ms()

It delivers current TCP time stamp in ms unit, and is used
in place of confusing tcp_time_stamp_raw()

It is the same family than tcp_clock_ns() and tcp_clock_ms().

tcp_time_stamp_raw() will be replaced later for TSval
contexts with a more descriptive name.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 99d67955
...@@ -798,6 +798,11 @@ static inline u64 tcp_clock_us(void) ...@@ -798,6 +798,11 @@ static inline u64 tcp_clock_us(void)
return div_u64(tcp_clock_ns(), NSEC_PER_USEC); return div_u64(tcp_clock_ns(), NSEC_PER_USEC);
} }
static inline u64 tcp_clock_ms(void)
{
return div_u64(tcp_clock_ns(), NSEC_PER_MSEC);
}
/* This should only be used in contexts where tp->tcp_mstamp is up to date */ /* This should only be used in contexts where tp->tcp_mstamp is up to date */
static inline u32 tcp_time_stamp(const struct tcp_sock *tp) static inline u32 tcp_time_stamp(const struct tcp_sock *tp)
{ {
......
...@@ -3817,10 +3817,8 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info) ...@@ -3817,10 +3817,8 @@ void tcp_get_info(struct sock *sk, struct tcp_info *info)
info->tcpi_total_rto = tp->total_rto; info->tcpi_total_rto = tp->total_rto;
info->tcpi_total_rto_recoveries = tp->total_rto_recoveries; info->tcpi_total_rto_recoveries = tp->total_rto_recoveries;
info->tcpi_total_rto_time = tp->total_rto_time; info->tcpi_total_rto_time = tp->total_rto_time;
if (tp->rto_stamp) { if (tp->rto_stamp)
info->tcpi_total_rto_time += tcp_time_stamp_raw() - info->tcpi_total_rto_time += tcp_clock_ms() - tp->rto_stamp;
tp->rto_stamp;
}
unlock_sock_fast(sk, slow); unlock_sock_fast(sk, slow);
} }
......
...@@ -567,7 +567,7 @@ struct sock *tcp_create_openreq_child(const struct sock *sk, ...@@ -567,7 +567,7 @@ struct sock *tcp_create_openreq_child(const struct sock *sk,
USEC_PER_SEC / TCP_TS_HZ); USEC_PER_SEC / TCP_TS_HZ);
newtp->total_rto = req->num_timeout; newtp->total_rto = req->num_timeout;
newtp->total_rto_recoveries = 1; newtp->total_rto_recoveries = 1;
newtp->total_rto_time = tcp_time_stamp_raw() - newtp->total_rto_time = tcp_clock_ms() -
newtp->retrans_stamp; newtp->retrans_stamp;
} }
newtp->tsoffset = treq->ts_off; newtp->tsoffset = treq->ts_off;
......
...@@ -153,7 +153,7 @@ void synproxy_init_timestamp_cookie(const struct nf_synproxy_info *info, ...@@ -153,7 +153,7 @@ void synproxy_init_timestamp_cookie(const struct nf_synproxy_info *info,
struct synproxy_options *opts) struct synproxy_options *opts)
{ {
opts->tsecr = opts->tsval; opts->tsecr = opts->tsval;
opts->tsval = tcp_time_stamp_raw() & ~0x3f; opts->tsval = tcp_clock_ms() & ~0x3f;
if (opts->options & NF_SYNPROXY_OPT_WSCALE) { if (opts->options & NF_SYNPROXY_OPT_WSCALE) {
opts->tsval |= opts->wscale; opts->tsval |= opts->wscale;
......
...@@ -177,7 +177,7 @@ static __always_inline __u32 tcp_ns_to_ts(__u64 ns) ...@@ -177,7 +177,7 @@ static __always_inline __u32 tcp_ns_to_ts(__u64 ns)
return ns / (NSEC_PER_SEC / TCP_TS_HZ); return ns / (NSEC_PER_SEC / TCP_TS_HZ);
} }
static __always_inline __u32 tcp_time_stamp_raw(void) static __always_inline __u32 tcp_clock_ms(void)
{ {
return tcp_ns_to_ts(tcp_clock_ns()); return tcp_ns_to_ts(tcp_clock_ns());
} }
...@@ -274,7 +274,7 @@ static __always_inline bool tscookie_init(struct tcphdr *tcp_header, ...@@ -274,7 +274,7 @@ static __always_inline bool tscookie_init(struct tcphdr *tcp_header,
if (!loop_ctx.option_timestamp) if (!loop_ctx.option_timestamp)
return false; return false;
cookie = tcp_time_stamp_raw() & ~TSMASK; cookie = tcp_clock_ms() & ~TSMASK;
cookie |= loop_ctx.wscale & TS_OPT_WSCALE_MASK; cookie |= loop_ctx.wscale & TS_OPT_WSCALE_MASK;
if (loop_ctx.option_sack) if (loop_ctx.option_sack)
cookie |= TS_OPT_SACK; cookie |= TS_OPT_SACK;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment