summaryrefslogtreecommitdiffstats
path: root/include/net
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2023-10-20 14:57:40 +0200
committerDavid S. Miller <davem@davemloft.net>2023-10-23 10:35:01 +0200
commit16cf6477741bdaa287d5e4531a1a503618a41a22 (patch)
tree8dc3a25443b1a4c83a54eb58b42e85ee24975ad8 /include/net
parenttcp: introduce tcp_clock_ms() (diff)
downloadlinux-16cf6477741bdaa287d5e4531a1a503618a41a22.tar.xz
linux-16cf6477741bdaa287d5e4531a1a503618a41a22.zip
tcp: replace tcp_time_stamp_raw()
In preparation of usec TCP TS support, remove tcp_time_stamp_raw() in favor of tcp_clock_ts() helper. This helper will return a suitable 32bit result to feed TS values, depending on a socket field. Also add tcp_tw_tsval() and tcp_rsk_tsval() helpers to factorize the details. We do not yet support usec timestamps. Signed-off-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/tcp.h25
1 files changed, 19 insertions, 6 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 3bdf1141f5a2..0534526a535d 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -803,6 +803,16 @@ static inline u64 tcp_clock_ms(void)
return div_u64(tcp_clock_ns(), NSEC_PER_MSEC);
}
+/* TCP Timestamp included in TS option (RFC 1323) can either use ms
+ * or usec resolution. Each socket carries a flag to select one or other
+ * resolution, as the route attribute could change anytime.
+ * Each flow must stick to initial resolution.
+ */
+static inline u32 tcp_clock_ts(bool usec_ts)
+{
+ return usec_ts ? tcp_clock_us() : tcp_clock_ms();
+}
+
/* 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)
{
@@ -820,12 +830,6 @@ static inline u64 tcp_ns_to_ts(u64 ns)
return div_u64(ns, NSEC_PER_SEC / TCP_TS_HZ);
}
-/* Could use tcp_clock_us() / 1000, but this version uses a single divide */
-static inline u32 tcp_time_stamp_raw(void)
-{
- return tcp_ns_to_ts(tcp_clock_ns());
-}
-
void tcp_mstamp_refresh(struct tcp_sock *tp);
static inline u32 tcp_stamp_us_delta(u64 t1, u64 t0)
@@ -844,6 +848,15 @@ static inline u64 tcp_skb_timestamp_us(const struct sk_buff *skb)
return div_u64(skb->skb_mstamp_ns, NSEC_PER_USEC);
}
+static inline u32 tcp_tw_tsval(const struct tcp_timewait_sock *tcptw)
+{
+ return tcp_clock_ts(false) + tcptw->tw_ts_offset;
+}
+
+static inline u32 tcp_rsk_tsval(const struct tcp_request_sock *treq)
+{
+ return tcp_clock_ts(false) + treq->ts_off;
+}
#define tcp_flag_byte(th) (((u_int8_t *)th)[13])