Skip to content

Commit 386c2b8

Browse files
JasonXingdavem330
authored andcommitted
tcp: add a common helper to debug the underlying issue
Following the commit c8770db ("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/[email protected]/ Suggested-by: Paolo Abeni <[email protected]> Signed-off-by: Jason Xing <[email protected]> Cc: Neal Cardwell <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2b1d193 commit 386c2b8

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

include/net/tcp.h

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,6 +2430,19 @@ void tcp_plb_update_state(const struct sock *sk, struct tcp_plb_state *plb,
24302430
void tcp_plb_check_rehash(struct sock *sk, struct tcp_plb_state *plb);
24312431
void tcp_plb_update_state_upon_rto(struct sock *sk, struct tcp_plb_state *plb);
24322432

2433+
static inline void tcp_warn_once(const struct sock *sk, bool cond, const char *str)
2434+
{
2435+
WARN_ONCE(cond,
2436+
"%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",
2437+
str,
2438+
tcp_sk(sk)->packets_out, tcp_sk(sk)->sacked_out,
2439+
tcp_sk(sk)->lost_out, tcp_sk(sk)->retrans_out,
2440+
tcp_sk(sk)->tlp_high_seq, sk->sk_state,
2441+
inet_csk(sk)->icsk_ca_state,
2442+
tcp_sk(sk)->advmss, tcp_sk(sk)->mss_cache,
2443+
inet_csk(sk)->icsk_pmtu_cookie);
2444+
}
2445+
24332446
/* At how many usecs into the future should the RTO fire? */
24342447
static inline s64 tcp_rto_delta_us(const struct sock *sk)
24352448
{
@@ -2441,17 +2454,7 @@ static inline s64 tcp_rto_delta_us(const struct sock *sk)
24412454

24422455
return rto_time_stamp_us - tcp_sk(sk)->tcp_mstamp;
24432456
} else {
2444-
WARN_ONCE(1,
2445-
"rtx queue empty: "
2446-
"out:%u sacked:%u lost:%u retrans:%u "
2447-
"tlp_high_seq:%u sk_state:%u ca_state:%u "
2448-
"advmss:%u mss_cache:%u pmtu:%u\n",
2449-
tcp_sk(sk)->packets_out, tcp_sk(sk)->sacked_out,
2450-
tcp_sk(sk)->lost_out, tcp_sk(sk)->retrans_out,
2451-
tcp_sk(sk)->tlp_high_seq, sk->sk_state,
2452-
inet_csk(sk)->icsk_ca_state,
2453-
tcp_sk(sk)->advmss, tcp_sk(sk)->mss_cache,
2454-
inet_csk(sk)->icsk_pmtu_cookie);
2457+
tcp_warn_once(sk, 1, "rtx queue empty: ");
24552458
return jiffies_to_usecs(rto);
24562459
}
24572460

0 commit comments

Comments
 (0)