Skip to content

Commit d30b56c

Browse files
committed
Merge branch 'tcp-warn-once'
Jason Xing says: ==================== tcp: add tcp_warn_once() common helper Paolo Abeni suggested we can introduce a new helper to cover more cases in the future for better debug. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 2b1d193 + 668d663 commit d30b56c

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

include/net/tcp.h

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2430,6 +2430,20 @@ 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+
"%scwn:%u 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",
2437+
str,
2438+
tcp_snd_cwnd(tcp_sk(sk)),
2439+
tcp_sk(sk)->packets_out, tcp_sk(sk)->sacked_out,
2440+
tcp_sk(sk)->lost_out, tcp_sk(sk)->retrans_out,
2441+
tcp_sk(sk)->tlp_high_seq, sk->sk_state,
2442+
inet_csk(sk)->icsk_ca_state,
2443+
tcp_sk(sk)->advmss, tcp_sk(sk)->mss_cache,
2444+
inet_csk(sk)->icsk_pmtu_cookie);
2445+
}
2446+
24332447
/* At how many usecs into the future should the RTO fire? */
24342448
static inline s64 tcp_rto_delta_us(const struct sock *sk)
24352449
{
@@ -2441,17 +2455,7 @@ static inline s64 tcp_rto_delta_us(const struct sock *sk)
24412455

24422456
return rto_time_stamp_us - tcp_sk(sk)->tcp_mstamp;
24432457
} 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);
2458+
tcp_warn_once(sk, 1, "rtx queue empty: ");
24552459
return jiffies_to_usecs(rto);
24562460
}
24572461

net/ipv4/tcp_output.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,9 +2954,7 @@ void tcp_send_loss_probe(struct sock *sk)
29542954
}
29552955
skb = skb_rb_last(&sk->tcp_rtx_queue);
29562956
if (unlikely(!skb)) {
2957-
WARN_ONCE(tp->packets_out,
2958-
"invalid inflight: %u state %u cwnd %u mss %d\n",
2959-
tp->packets_out, sk->sk_state, tcp_snd_cwnd(tp), mss);
2957+
tcp_warn_once(sk, tp->packets_out, "invalid inflight: ");
29602958
smp_store_release(&inet_csk(sk)->icsk_pending, 0);
29612959
return;
29622960
}

0 commit comments

Comments
 (0)