]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
tcp: add a common helper to debug the underlying issue
authorJason Xing <kernelxing@tencent.com>
Wed, 23 Oct 2024 08:14:51 +0000 (16:14 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 30 Oct 2024 13:26:55 +0000 (13:26 +0000)
Following the commit c8770db2d544 ("tcp: check skb is non-NULL
in tcp_rto_delta_us()"), we decided to add a helper so that it's
easier to get verbose warning on either cases.

Link: https://lore.kernel.org/all/5632e043-bdba-4d75-bc7e-bf58014492fd@redhat.com/
Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Jason Xing <kernelxing@tencent.com>
Cc: Neal Cardwell <ncardwell@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/tcp.h

index 739a9fb83d0cf588f833b1683cdab0c1c18a2851..8b8d94bb17461cc1a74752431106bb190668c8e2 100644 (file)
@@ -2430,6 +2430,19 @@ void tcp_plb_update_state(const struct sock *sk, struct tcp_plb_state *plb,
 void tcp_plb_check_rehash(struct sock *sk, struct tcp_plb_state *plb);
 void tcp_plb_update_state_upon_rto(struct sock *sk, struct tcp_plb_state *plb);
 
+static inline void tcp_warn_once(const struct sock *sk, bool cond, const char *str)
+{
+       WARN_ONCE(cond,
+                 "%sout:%u sacked:%u lost:%u retrans:%u tlp_high_seq:%u sk_state:%u ca_state:%u advmss:%u mss_cache:%u pmtu:%u\n",
+                 str,
+                 tcp_sk(sk)->packets_out, tcp_sk(sk)->sacked_out,
+                 tcp_sk(sk)->lost_out, tcp_sk(sk)->retrans_out,
+                 tcp_sk(sk)->tlp_high_seq, sk->sk_state,
+                 inet_csk(sk)->icsk_ca_state,
+                 tcp_sk(sk)->advmss, tcp_sk(sk)->mss_cache,
+                 inet_csk(sk)->icsk_pmtu_cookie);
+}
+
 /* At how many usecs into the future should the RTO fire? */
 static inline s64 tcp_rto_delta_us(const struct sock *sk)
 {
@@ -2441,17 +2454,7 @@ static inline s64 tcp_rto_delta_us(const struct sock *sk)
 
                return rto_time_stamp_us - tcp_sk(sk)->tcp_mstamp;
        } else {
-               WARN_ONCE(1,
-                       "rtx queue empty: "
-                       "out:%u sacked:%u lost:%u retrans:%u "
-                       "tlp_high_seq:%u sk_state:%u ca_state:%u "
-                       "advmss:%u mss_cache:%u pmtu:%u\n",
-                       tcp_sk(sk)->packets_out, tcp_sk(sk)->sacked_out,
-                       tcp_sk(sk)->lost_out, tcp_sk(sk)->retrans_out,
-                       tcp_sk(sk)->tlp_high_seq, sk->sk_state,
-                       inet_csk(sk)->icsk_ca_state,
-                       tcp_sk(sk)->advmss, tcp_sk(sk)->mss_cache,
-                       inet_csk(sk)->icsk_pmtu_cookie);
+               tcp_warn_once(sk, 1, "rtx queue empty: ");
                return jiffies_to_usecs(rto);
        }