Some SNMP stuff - tcpInErrs and tcpOutRsts

David Woodhouse (D.W.Woodhouse@nortel.co.uk)
Wed, 27 Aug 1997 14:42:19 +0100


This patch keeps the MIB-II stats mentioned above. InErrs is incremented when
a tcp packet with a bad checksum is received - are there other places where it
should be done? Also, an I right in thinking that packets with bad checksums
should be counted as in tcpInSegs, so it should be incremented _before_
rejecting a packet?

diff -u --recursive linux-orig/include/net/snmp.h linux-2.1.51-3/include/net/sn
mp.h
--- linux-orig/include/net/snmp.h Sun Nov 3 09:04:42 1996
+++ linux-2.1.51-3/include/net/snmp.h Wed Aug 27 13:46:27 1997
@@ -113,6 +113,8 @@
unsigned long TcpInSegs;
unsigned long TcpOutSegs;
unsigned long TcpRetransSegs;
+ unsigned long TcpInErrs;
+ unsigned long TcpOutRsts;
};

struct udp_mib
diff -u --recursive linux-orig/net/ipv4/proc.c linux-2.1.51-3/net/ipv4/proc.c
--- linux-orig/net/ipv4/proc.c Thu Jul 31 21:09:18 1997
+++ linux-2.1.51-3/net/ipv4/proc.c Wed Aug 27 13:50:48 1997
@@ -240,14 +240,15 @@
icmp_statistics.IcmpOutAddrMasks, icmp_statistics.IcmpOutAddrMaskReps);

len += sprintf (buffer + len,
- "Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens
AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs\n"
- "Tcp: %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
+ "Tcp: RtoAlgorithm RtoMin RtoMax MaxConn ActiveOpens PassiveOpens
AttemptFails EstabResets CurrEstab InSegs OutSegs RetransSegs InErrs OutRsts\n"
+ "Tcp: %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
tcp_statistics.TcpRtoAlgorithm, tcp_statistics.TcpRtoMin,
tcp_statistics.TcpRtoMax, tcp_statistics.TcpMaxConn,
tcp_statistics.TcpActiveOpens, tcp_statistics.TcpPassiveOpens,
tcp_statistics.TcpAttemptFails, tcp_statistics.TcpEstabResets,
tcp_statistics.TcpCurrEstab, tcp_statistics.TcpInSegs,
- tcp_statistics.TcpOutSegs, tcp_statistics.TcpRetransSegs);
+ tcp_statistics.TcpOutSegs, tcp_statistics.TcpRetransSegs,
+ tcp_statistics.TcpInErrs, tcp_statistics.TcpOutRsts);

len += sprintf (buffer + len,
"Udp: InDatagrams NoPorts InErrors OutDatagrams\nUdp: %lu %lu %lu %lu\n",
diff -u --recursive linux-orig/net/ipv4/tcp_ipv4.c
linux-2.1.51-3/net/ipv4/tcp_ipv4.c
--- linux-orig/net/ipv4/tcp_ipv4.c Wed Aug 27 13:42:32 1997
+++ linux-2.1.51-3/net/ipv4/tcp_ipv4.c Wed Aug 27 14:00:03 1997
@@ -802,6 +802,7 @@
/* FIXME: should this carry an options packet? */
ip_queue_xmit(skb1);
tcp_statistics.TcpOutSegs++;
+ tcp_statistics.TcpOutRsts++;
}

#ifdef CONFIG_IP_TRANSPARENT_PROXY
@@ -1320,6 +1321,9 @@
/* Pull up the IP header. */
skb_pull(skb, skb->h.raw-skb->data);

+ /* Count it even if it's bad */
+ tcp_statistics.TcpInSegs++;
+
/* Try to use the device checksum if provided. */
switch (skb->ip_summed) {
case CHECKSUM_NONE:
@@ -1330,13 +1334,12 @@
printk(KERN_DEBUG "TCPv4 bad checksum from %08x:%04x to %08x:%04x,
len=%d/%d/%d\n",
saddr, ntohs(th->source), daddr,
ntohs(th->dest), len, skb->len, ntohs(iph->tot_len));
+ tcp_statistics.TcpInErrs++;
goto discard_it;
}
default:
/* CHECKSUM_UNNECESSARY */
};
-
- tcp_statistics.TcpInSegs++;

#ifdef CONFIG_IP_TRANSPARENT_PROXY
if (IPCB(skb)->redirport)
diff -u --recursive linux-orig/net/ipv6/tcp_ipv6.c
linux-2.1.51-3/net/ipv6/tcp_ipv6.c
--- linux-orig/net/ipv6/tcp_ipv6.c Thu Jul 31 21:09:18 1997
+++ linux-2.1.51-3/net/ipv6/tcp_ipv6.c Wed Aug 27 14:01:07 1997
@@ -1019,6 +1019,7 @@

ip6_xmit(NULL, buff, &fl, NULL);
tcp_statistics.TcpOutSegs++;
+ tcp_statistics.TcpOutRsts++;
}

struct sock *tcp_v6_check_req(struct sock *sk, struct sk_buff *skb)
@@ -1105,6 +1106,12 @@
skb_pull(skb, skb->h.raw - skb->data);

/*
+ * Count it even if it's bad.
+ */
+
+ tcp_statistics.TcpInSegs++;
+
+ /*
* Try to use the device checksum if provided.
*/

@@ -1114,13 +1121,12 @@
case CHECKSUM_HW:
if (tcp_v6_check(th,len,saddr,daddr,skb->csum)) {
printk(KERN_DEBUG "tcp csum failed\n");
+ tcp_statistics.TcpInErrs++;
goto discard_it;
}
default:
/* CHECKSUM_UNNECESSARY */
};
-
- tcp_statistics.TcpInSegs++;

sk = __tcp_v6_lookup(th, saddr, th->source, daddr, th->dest);

-- 
David Woodhouse,	CB3 9AN		http://dwmw2.robinson.cam.ac.uk/
	dwmw2@cam.ac.uk 		 Tel: 0976 658355        
	D.W.Woodhouse@nortel.co.uk	 Tel: 01279 402332