tcp: update sacked after tracepoint in __tcp_retransmit_skb
authorPhilo Lu <lulie@linux.alibaba.com>
Sun, 21 Apr 2024 04:20:09 +0000 (12:20 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 25 Apr 2024 07:52:12 +0000 (08:52 +0100)
Marking TCP_SKB_CB(skb)->sacked with TCPCB_EVER_RETRANS after the
traceopint (trace_tcp_retransmit_skb), then we can get the
retransmission efficiency by counting skbs w/ and w/o TCPCB_EVER_RETRANS
mark in this tracepoint.

We have discussed to achieve this with BPF_SOCK_OPS in [0], and using
tracepoint is thought to be a better solution.

[0]
https://lore.kernel.org/all/20240417124622.35333-1-lulie@linux.alibaba.com/

Signed-off-by: Philo Lu <lulie@linux.alibaba.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/ipv4/tcp_output.c

index 99a1d88f7f47b9ef0334efe62f8fd34c0d693ced..ce59e4499b66dfd2fe00c255c11187e3c08c5806 100644 (file)
@@ -3418,11 +3418,6 @@ start:
                err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
        }
 
-       /* To avoid taking spuriously low RTT samples based on a timestamp
-        * for a transmit that never happened, always mark EVER_RETRANS
-        */
-       TCP_SKB_CB(skb)->sacked |= TCPCB_EVER_RETRANS;
-
        if (BPF_SOCK_OPS_TEST_FLAG(tp, BPF_SOCK_OPS_RETRANS_CB_FLAG))
                tcp_call_bpf_3arg(sk, BPF_SOCK_OPS_RETRANS_CB,
                                  TCP_SKB_CB(skb)->seq, segs, err);
@@ -3432,6 +3427,12 @@ start:
        } else if (err != -EBUSY) {
                NET_ADD_STATS(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL, segs);
        }
+
+       /* To avoid taking spuriously low RTT samples based on a timestamp
+        * for a transmit that never happened, always mark EVER_RETRANS
+        */
+       TCP_SKB_CB(skb)->sacked |= TCPCB_EVER_RETRANS;
+
        return err;
 }