netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.4.35.3] Fix the "InAddrErrors" increasing problem
@ 2007-10-22  6:07 Gui Jianfeng
  2007-10-22  6:16 ` David Miller
  2007-10-22  6:28 ` Krishna Kumar2
  0 siblings, 2 replies; 6+ messages in thread
From: Gui Jianfeng @ 2007-10-22  6:07 UTC (permalink / raw)
  To: netdev; +Cc: davem

Hi,
When kernel receives a package with a wrong destination ipv4 address, it can't increase "InAddrErrors" number correctly.
InAddrErrors is located in /proc/net/snmp.

This is a patch for fixing this problem.

Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
---
diff -Narup linux-2.4.35.3/net/ipv4/ip_input.c linux-2.4.35.3-prep/net/ipv4/ip_input.c
--- linux-2.4.35.3/net/ipv4/ip_input.c	2007-09-24 06:02:58.000000000 +0800
+++ linux-2.4.35.3-prep/net/ipv4/ip_input.c	2007-09-26 01:24:08.000000000 +0800
@@ -310,8 +310,12 @@ static inline int ip_rcv_finish(struct s
 	 *	how the packet travels inside Linux networking.
 	 */ 
 	if (skb->dst == NULL) {
-		if (ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))
-			goto drop; 
+		int err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev);
+		if (unlikely(err)) {
+			if (err == -EHOSTUNREACH)
+				IP_INC_STATS_BH(IpInAddrErrors);
+		}
+		goto drop; 
 	}
 
 #ifdef CONFIG_NET_CLS_ROUTE
diff -Narup linux-2.4.35.3/net/ipv4/route.c linux-2.4.35.3-prep/net/ipv4/route.c
--- linux-2.4.35.3/net/ipv4/route.c	2007-09-24 06:02:58.000000000 +0800
+++ linux-2.4.35.3-prep/net/ipv4/route.c	2007-09-26 01:26:15.000000000 +0800
@@ -1450,7 +1450,7 @@ int ip_route_input_slow(struct sk_buff *
 	 */
 	if ((err = fib_lookup(&key, &res)) != 0) {
 		if (!IN_DEV_FORWARD(in_dev))
-			goto e_inval;
+			goto e_hostunreach;
 		goto no_route;
 	}
 	free_res = 1;
@@ -1499,7 +1499,7 @@ int ip_route_input_slow(struct sk_buff *
 	}
 
 	if (!IN_DEV_FORWARD(in_dev))
-		goto e_inval;
+		goto e_hostunreach;
 	if (res.type != RTN_UNICAST)
 		goto martian_destination;
 
@@ -1668,6 +1668,11 @@ martian_destination:
 			"%u.%u.%u.%u, dev %s\n",
 			NIPQUAD(daddr), NIPQUAD(saddr), dev->name);
 #endif
+
+e_hostunreach:
+	err = -EHOSTUNREACH;
+	goto done;
+
 e_inval:
 	err = -EINVAL;
 	goto done;



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

end of thread, other threads:[~2007-10-22  7:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-22  6:07 [PATCH 2.4.35.3] Fix the "InAddrErrors" increasing problem Gui Jianfeng
2007-10-22  6:16 ` David Miller
2007-10-22  6:28 ` Krishna Kumar2
2007-10-22  6:45   ` Gui Jianfeng
2007-10-22  7:10   ` Gui Jianfeng
2007-10-22  7:23     ` 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).