From: Jason Xing Check the tsflags first to see if the socket timestamping is enabled. If so, then try to fetch the last skb from either write queue or retransmission queue. Signed-off-by: Yushan Zhou Signed-off-by: Jason Xing --- net/ipv4/tcp.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 169c3fff4f6d..c603b90057f6 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -484,13 +484,14 @@ void tcp_init_sock(struct sock *sk) static void tcp_tx_timestamp(struct sock *sk, struct sockcm_cookie *sockc) { - struct sk_buff *skb = tcp_write_queue_tail(sk); u32 tsflags = sockc->tsflags; + struct sk_buff *skb; - if (unlikely(!skb)) - skb = skb_rb_last(&sk->tcp_rtx_queue); + if (!tsflags) + return; - if (tsflags && skb) { + skb = tcp_write_queue_tail(sk) ? : skb_rb_last(&sk->tcp_rtx_queue); + if (skb) { struct skb_shared_info *shinfo = skb_shinfo(skb); struct tcp_skb_cb *tcb = TCP_SKB_CB(skb); -- 2.41.3