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

tcp: add tcp_rtt_tsopt_us()

Before adding usec TS support, add tcp_rtt_tsopt_us() helper
to factorize code.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9d0c00f5
...@@ -693,6 +693,21 @@ static inline void tcp_rcv_rtt_measure(struct tcp_sock *tp) ...@@ -693,6 +693,21 @@ static inline void tcp_rcv_rtt_measure(struct tcp_sock *tp)
tp->rcv_rtt_est.time = tp->tcp_mstamp; tp->rcv_rtt_est.time = tp->tcp_mstamp;
} }
static s32 tcp_rtt_tsopt_us(const struct tcp_sock *tp)
{
u32 delta, delta_us;
delta = tcp_time_stamp_ts(tp) - tp->rx_opt.rcv_tsecr;
if (likely(delta < INT_MAX / (USEC_PER_SEC / TCP_TS_HZ))) {
if (!delta)
delta = 1;
delta_us = delta * (USEC_PER_SEC / TCP_TS_HZ);
return delta_us;
}
return -1;
}
static inline void tcp_rcv_rtt_measure_ts(struct sock *sk, static inline void tcp_rcv_rtt_measure_ts(struct sock *sk,
const struct sk_buff *skb) const struct sk_buff *skb)
{ {
...@@ -704,15 +719,10 @@ static inline void tcp_rcv_rtt_measure_ts(struct sock *sk, ...@@ -704,15 +719,10 @@ static inline void tcp_rcv_rtt_measure_ts(struct sock *sk,
if (TCP_SKB_CB(skb)->end_seq - if (TCP_SKB_CB(skb)->end_seq -
TCP_SKB_CB(skb)->seq >= inet_csk(sk)->icsk_ack.rcv_mss) { TCP_SKB_CB(skb)->seq >= inet_csk(sk)->icsk_ack.rcv_mss) {
u32 delta = tcp_time_stamp_ts(tp) - tp->rx_opt.rcv_tsecr; s32 delta = tcp_rtt_tsopt_us(tp);
u32 delta_us;
if (delta >= 0)
if (likely(delta < INT_MAX / (USEC_PER_SEC / TCP_TS_HZ))) { tcp_rcv_rtt_update(tp, delta, 0);
if (!delta)
delta = 1;
delta_us = delta * (USEC_PER_SEC / TCP_TS_HZ);
tcp_rcv_rtt_update(tp, delta_us, 0);
}
} }
} }
...@@ -3146,17 +3156,10 @@ static bool tcp_ack_update_rtt(struct sock *sk, const int flag, ...@@ -3146,17 +3156,10 @@ static bool tcp_ack_update_rtt(struct sock *sk, const int flag,
* left edge of the send window. * left edge of the send window.
* See draft-ietf-tcplw-high-performance-00, section 3.3. * See draft-ietf-tcplw-high-performance-00, section 3.3.
*/ */
if (seq_rtt_us < 0 && tp->rx_opt.saw_tstamp && tp->rx_opt.rcv_tsecr && if (seq_rtt_us < 0 && tp->rx_opt.saw_tstamp &&
flag & FLAG_ACKED) { tp->rx_opt.rcv_tsecr && flag & FLAG_ACKED)
u32 delta = tcp_time_stamp_ts(tp) - tp->rx_opt.rcv_tsecr; seq_rtt_us = ca_rtt_us = tcp_rtt_tsopt_us(tp);
if (likely(delta < INT_MAX / (USEC_PER_SEC / TCP_TS_HZ))) {
if (!delta)
delta = 1;
seq_rtt_us = delta * (USEC_PER_SEC / TCP_TS_HZ);
ca_rtt_us = seq_rtt_us;
}
}
rs->rtt_us = ca_rtt_us; /* RTT of last (S)ACKed packet (or -1) */ rs->rtt_us = ca_rtt_us; /* RTT of last (S)ACKed packet (or -1) */
if (seq_rtt_us < 0) if (seq_rtt_us < 0)
return false; return false;
......
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