Skip to contentSkip to conversation

SNMPv2 tcpOutSegs counter error

PATCH Wei Yongjun 2 participants 2 messages Aug 4, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This always correct except when do active open in tcp client, which will send a SYN, that segment will not be counted, even if it is not restrained. Maybe I can do following to fix this:

int tcp_connect(struct sock *sk)
...

+	tp->snd_nxt = tp->write_seq;
	TCP_SKB_CB(buff)->seq = tp->write_seq++;
	TCP_SKB_CB(buff)->end_seq = tp->write_seq;

- tp->snd_nxt = tp->write_seq;
- tp->pushed_seq = tp->write_seq;

	tcp_transmit_skb(sk, buff, 1, GFP_KERNEL);
+	tp->snd_nxt = tp->write_seq;
+	tp->pushed_seq = tp->write_seq;
	TCP_INC_STATS(TCP_MIB_ACTIVEOPENS);

Do you agree with me? If It is correctly, I will send this patch soon.

Quoted 23 lines · David Miller

From: Wei Yongjun <[email protected]>
Date: Thu, 03 Aug 2006 11:46:58 -0400

Quoted 2 lines

I modified my patch by add a flag to sacked when retransmit, and it work well.

This is the most timing critical code path of the TCP stack output packet processing, and you're adding a read-modify-write operation just to get some statistics correct.

Let's look for a cheaper test, perhaps something like:

if (!before(TCP_SKB_CB(skb)->seq, tp->snd_nxt))
TCP_INC_STATS(TCP_MIB_OUTSEGS);

Would that work?

It should, because tp->snd_nxt always advances on new data via update_send_head().
-
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#1 lore raw

From: Wei Yongjun <[email protected]>
Date: Fri, 04 Aug 2006 08:46:13 -0400

Quoted 17 lines

This always correct except when do active open in tcp client, which will send a SYN, that segment will not be counted, even if it is not restrained. Maybe I can do following to fix this:

int tcp_connect(struct sock *sk)
...

(quoted diff) +1 -0
+	tp->snd_nxt = tp->write_seq;
	TCP_SKB_CB(buff)->seq = tp->write_seq++;
	TCP_SKB_CB(buff)->end_seq = tp->write_seq;
(quoted diff) +0 -2
-	tp->snd_nxt = tp->write_seq;
-	tp->pushed_seq = tp->write_seq;
	tcp_transmit_skb(sk, buff, 1, GFP_KERNEL);
(quoted diff) +2 -0
+	tp->snd_nxt = tp->write_seq;
+	tp->pushed_seq = tp->write_seq;
	TCP_INC_STATS(TCP_MIB_ACTIVEOPENS);
Quoted 1 line

Do you agree with me? If It is correctly, I will send this patch soon.

This looks fine and should work.

Please add some comments in tcp_connect() explaining the ordering of assignments, so that a future developer does not break things by accident.

Thank you.