netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] Fix SNMPv2 "ipOutNoRoutes" counter error
@ 2006-12-04  7:10 weidong
  2006-12-11  6:48 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: weidong @ 2006-12-04  7:10 UTC (permalink / raw)
  To: netdev

Hi All:
    When I tested linux kernel 2.6.18.3, and find that kernel statistics
about IPSTATS_MIB_OUTNOROUTES which exsits in file /proc/net/snmp
doesn't increase correctly.  The criteria conform to RFC2011:

  ipOutNoRoutes OBJECT-TYPE
    SYNTAX      Counter32
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION
            "The number of IP datagrams discarded because no route could
            be found to transmit them to their destination.  Note that
            this counter includes any packets counted in ipForwDatagrams
            which meet this `no-route' criterion.  Note that this
            includes any datagrams which a host cannot route because all
            of its default routers are down."
    ::= { ip 12 }

When a host received an IP packet, but the destination address is not
this host. The kernel just discards the IP packet but with no increment
for this counter.

When a router received an IP packet that this router can't forward due
to no route found. Kernel just simply invoke ip_error(), and send ICMP
packet. Also do nothing for this counter.

Signed-off-by: Wei Dong <weid@nanjing-fnst.com>

diff -ruN old/net/ipv4/icmp.c new/net/ipv4/icmp.c
--- old/net/ipv4/icmp.c	2006-09-20 00:42:06.000000000 -0300
+++ new/net/ipv4/icmp.c	2006-12-04 11:46:39.000000000 -0300
@@ -580,6 +580,9 @@
 		icmp_param.data_len = room;
 	icmp_param.head_len = sizeof(struct icmphdr);
 
+	if (code == ICMP_NET_UNREACH)
+		IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
+
 	icmp_push_reply(&icmp_param, &ipc, rt);
 ende:
 	ip_rt_put(rt);
diff -ruN old/net/ipv4/ip_input.c new/net/ipv4/ip_input.c
--- old/net/ipv4/ip_input.c	2006-09-20 00:42:06.000000000 -0300
+++ new/net/ipv4/ip_input.c	2006-11-29 11:15:52.000000000 -0300
@@ -340,8 +340,10 @@
 		int err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos,
 					 skb->dev);
 		if (unlikely(err)) {
-			if (err == -EHOSTUNREACH)
+			if (err == -EHOSTUNREACH) {
 				IP_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS);
+				IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
+			}
 			goto drop; 
 		}
 	}



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch] Fix SNMPv2 "ipOutNoRoutes" counter error
  2006-12-04  7:10 [patch] Fix SNMPv2 "ipOutNoRoutes" counter error weidong
@ 2006-12-11  6:48 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2006-12-11  6:48 UTC (permalink / raw)
  To: weid; +Cc: netdev

From: weidong <weid@nanjing-fnst.com>
Date: Tue, 05 Dec 2006 11:49:46 -0500

> Hi All:
>     When I tested linux kernel 2.6.18.3, and find that kernel statistics
> about IPSTATS_MIB_OUTNOROUTES which exsits in file /proc/net/snmp
> doesn't increase correctly.  The criteria conform to RFC2011:
> 
>   ipOutNoRoutes OBJECT-TYPE
>     SYNTAX      Counter32
>     MAX-ACCESS  read-only
>     STATUS      current
>     DESCRIPTION
>             "The number of IP datagrams discarded because no route could
>             be found to transmit them to their destination.  Note that
>             this counter includes any packets counted in ipForwDatagrams
>             which meet this `no-route' criterion.  Note that this
>             includes any datagrams which a host cannot route because all
>             of its default routers are down."
>     ::= { ip 12 }
> 
> When a host received an IP packet, but the destination address is not
> this host. The kernel just discards the IP packet but with no increment
> for this counter.
> 
> When a router received an IP packet that this router can't forward due
> to no route found. Kernel just simply invoke ip_error(), and send ICMP
> packet. Also do nothing for this counter.
> 
> Signed-off-by: Wei Dong <weid@nanjing-fnst.com>

Hosts which have forwarding disabled, are not forwarding and
therefore not routing in the sense being described here.

So bumping this counter when the ip_forward sysctl is "0" makes
no sense.

We are not even getting to the "output" path when the route lookup
fails in ip_rcv_finish().  This means this silly SNMP "output" route
failed counter will get bumped like crazy when promiscuous mode is
enabled on an interface, and that makes zero sense.

This patch, at least in it's current form, is not correct.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-12-11  6:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-04  7:10 [patch] Fix SNMPv2 "ipOutNoRoutes" counter error weidong
2006-12-11  6:48 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).