aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/net/tcp.h10
-rw-r--r--net/ipv4/tcp_input.c4
2 files changed, 11 insertions, 3 deletions
diff --git a/include/net/tcp.h b/include/net/tcp.h
index d6a45e2cd..60a984d70 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -1600,4 +1600,14 @@ struct tcp_request_sock_ops {
extern void tcp_v4_init(void);
extern void tcp_init(void);
+/* At how many jiffies into the future should the RTO fire? */
+static inline s32 tcp_rto_delta(const struct sock *sk)
+{
+ const struct sk_buff *skb = tcp_write_queue_head(sk);
+ const u32 rto = inet_csk(sk)->icsk_rto;
+ const u32 rto_time_stamp = TCP_SKB_CB(skb)->when + rto;
+
+ return (s32)(rto_time_stamp - tcp_time_stamp);
+}
+
#endif /* _TCP_H */
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 0f4556b17..dfa4511c5 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -3007,9 +3007,7 @@ void tcp_rearm_rto(struct sock *sk)
/* Offset the time elapsed after installing regular RTO */
if (icsk->icsk_pending == ICSK_TIME_EARLY_RETRANS ||
icsk->icsk_pending == ICSK_TIME_LOSS_PROBE) {
- struct sk_buff *skb = tcp_write_queue_head(sk);
- const u32 rto_time_stamp = TCP_SKB_CB(skb)->when + rto;
- s32 delta = (s32)(rto_time_stamp - tcp_time_stamp);
+ s32 delta = tcp_rto_delta(sk);
/* delta may not be positive if the socket is locked
* when the retrans timer fires and is rescheduled.
*/