Skip to contentSkip to conversation

SNMPv2 tcpOutSegs counter error

PATCH In review Wei Yongjun 2 participants 2 messages Jul 6, 2006 – Jul 24, 2006

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

PATCH 1/1 SNMPv2 tcpOutSegs counter error

RFC2012 saied that tcpOutSegs should excluding those containing only retransmitted octets. But in my test, linux kernel increased the tcpOutSegs even if only retransmitted octets is send out. So I think this is a bug of kernel.

Refer to RFC2012, tcpOutSegs is defined as following:

tcpOutSegs OBJECT-TYPE

       SYNTAX      Counter32
       MAX-ACCESS  read-only
       STATUS      current

DESCRIPTION
"The total number of segments sent, including those on current connections but excluding those containing only retransmitted octets."
::= { tcp 11 }

Following is my patch:

net/ipv4/tcp_output.c +2 -1
@@ -462,7 +462,8 @@ static int tcp_transmit_skb(struct sock 
 	if (skb->len != tcp_header_size)
 		tcp_event_data_sent(tp, skb, sk);
 
-	TCP_INC_STATS(TCP_MIB_OUTSEGS);
+	if (!(tcb->sacked & TCPCB_LOST))
+		TCP_INC_STATS(TCP_MIB_OUTSEGS);
 
 	err = icsk->icsk_af_ops->queue_xmit(skb, 0);
 	if (likely(err <= 0))
maintainer
#1 lore raw

From: Wei Yongjun <[email protected]>
Date: Thu, 06 Jul 2006 04:01:18 -0400

net/ipv4/tcp_output.c static int tcp_transmit_skb(struct sock · line 466

Quoted 3 lines
net/ipv4/tcp_output.c +2 -1
-	TCP_INC_STATS(TCP_MIB_OUTSEGS);
+	if (!(tcb->sacked & TCPCB_LOST))
+		TCP_INC_STATS(TCP_MIB_OUTSEGS);

This test is not accurate enough. For example, timer based retransmits will not set the TCPCB_LOST bit.

I'm tempted to say to pass a flag to tcp_transmit_skb() which says whether it is a retransmit or not, but that function already takes way too many arguments.