Skip to content

Commit 623df48

Browse files
nealcardwelldavem330
authored andcommitted
tcp: extract code to compute SYNACK RTT
In preparation for adding another spot where we compute the SYNACK RTT, extract this code so that it can be shared. Signed-off-by: Neal Cardwell <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent de46584 commit 623df48

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

include/net/tcp.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,15 @@ static inline void tcp_openreq_init(struct request_sock *req,
11371137
ireq->loc_port = tcp_hdr(skb)->dest;
11381138
}
11391139

1140+
/* Compute time elapsed between SYNACK and the ACK completing 3WHS */
1141+
static inline void tcp_synack_rtt_meas(struct sock *sk,
1142+
struct request_sock *req)
1143+
{
1144+
if (tcp_rsk(req)->snt_synack)
1145+
tcp_valid_rtt_meas(sk,
1146+
tcp_time_stamp - tcp_rsk(req)->snt_synack);
1147+
}
1148+
11401149
extern void tcp_enter_memory_pressure(struct sock *sk);
11411150

11421151
static inline int keepalive_intvl_when(const struct tcp_sock *tp)

net/ipv4/tcp_ipv4.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,9 +1733,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
17331733
newtp->advmss = tcp_sk(sk)->rx_opt.user_mss;
17341734

17351735
tcp_initialize_rcv_mss(newsk);
1736-
if (tcp_rsk(req)->snt_synack)
1737-
tcp_valid_rtt_meas(newsk,
1738-
tcp_time_stamp - tcp_rsk(req)->snt_synack);
1736+
tcp_synack_rtt_meas(newsk, req);
17391737
newtp->total_retrans = req->retrans;
17401738

17411739
#ifdef CONFIG_TCP_MD5SIG

net/ipv6/tcp_ipv6.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1348,9 +1348,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
13481348
newtp->advmss = tcp_sk(sk)->rx_opt.user_mss;
13491349

13501350
tcp_initialize_rcv_mss(newsk);
1351-
if (tcp_rsk(req)->snt_synack)
1352-
tcp_valid_rtt_meas(newsk,
1353-
tcp_time_stamp - tcp_rsk(req)->snt_synack);
1351+
tcp_synack_rtt_meas(newsk, req);
13541352
newtp->total_retrans = req->retrans;
13551353

13561354
newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6;

0 commit comments

Comments
 (0)