Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tcp_retransmit statistics Error In higher than 4.7 of kernel version #214

Closed
jundizhou opened this issue May 10, 2022 · 1 comment
Closed
Labels
area/collector Issues or PRs related to agent metric collector area/probe Issues or PRs related to agent probe bug Something isn't working

Comments

@jundizhou
Copy link
Collaborator

jundizhou commented May 10, 2022

Describe the bug
tcp_retransmit statistics Error In higher than 4.7 of kernel version

Higher than 4.7 source code

int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)
{
	struct tcp_sock *tp = tcp_sk(sk);
	int err = __tcp_retransmit_skb(sk, skb, segs);

	if (err == 0) {
#if FASTRETRANS_DEBUG > 0
		if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS) {
			net_dbg_ratelimited("retrans_out leaked\n");
		}
#endif
		TCP_SKB_CB(skb)->sacked |= TCPCB_RETRANS;
		tp->retrans_out += tcp_skb_pcount(skb);

		/* Save stamp of the first retransmit. */
		if (!tp->retrans_stamp)
			tp->retrans_stamp = tcp_skb_timestamp(skb);

	}

	if (tp->undo_retrans < 0)
		tp->undo_retrans = 0;
	tp->undo_retrans += tcp_skb_pcount(skb);
	return err;
}

Lower than 4.7 source code

int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb)
{
	struct tcp_sock *tp = tcp_sk(sk);
	int err = __tcp_retransmit_skb(sk, skb);

	if (err == 0) {
		/* Update global TCP statistics. */
		TCP_INC_STATS(sock_net(sk), TCP_MIB_RETRANSSEGS);

		tp->total_retrans++;

#if FASTRETRANS_DEBUG > 0
		if (TCP_SKB_CB(skb)->sacked & TCPCB_SACKED_RETRANS) {
			net_dbg_ratelimited("retrans_out leaked\n");
		}
#endif
		if (!tp->retrans_out)
			tp->lost_retrans_low = tp->snd_nxt;
		TCP_SKB_CB(skb)->sacked |= TCPCB_RETRANS;
		tp->retrans_out += tcp_skb_pcount(skb);

		/* Save stamp of the first retransmit. */
		if (!tp->retrans_stamp)
			tp->retrans_stamp = TCP_SKB_CB(skb)->when;

		tp->undo_retrans += tcp_skb_pcount(skb);

		/* snd_nxt is stored to detect loss of retransmitted segment,
		 * see tcp_input.c tcp_sacktag_write_queue().
		 */
		TCP_SKB_CB(skb)->ack_seq = tp->snd_nxt;
	}
	return err;
}

Why the bug
In higher than 4.7, SEGS parameter represents the number of packet losses, which should be counted instead of 1

@jundizhou jundizhou added bug Something isn't working area/probe Issues or PRs related to agent probe area/collector Issues or PRs related to agent metric collector labels May 10, 2022
@jundizhou jundizhou changed the title tcp_retransmit tatistics Error In higher than 4.7 of kernel version tcp_retransmit statistics Error In higher than 4.7 of kernel version May 10, 2022
@dxsup
Copy link
Member

dxsup commented Feb 24, 2023

Closed via #450

@dxsup dxsup closed this as completed Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/collector Issues or PRs related to agent metric collector area/probe Issues or PRs related to agent probe bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants