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

* Re: [PATCH 2.4.35.3] Fix the "InAddrErrors" increasing problem
  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
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2007-10-22  6:16 UTC (permalink / raw)
  To: guijianfeng; +Cc: netdev

From: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
Date: Mon, 22 Oct 2007 14:07:07 +0800

> 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>

This patch looks fine, but I really don't handle 2.4.x
kernel patches for networking as 2.6.x takes enough of
my time and effort.

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

* Re: [PATCH 2.4.35.3] Fix the "InAddrErrors" increasing problem
  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
  1 sibling, 2 replies; 6+ messages in thread
From: Krishna Kumar2 @ 2007-10-22  6:28 UTC (permalink / raw)
  To: Gui Jianfeng; +Cc: davem, netdev

Gui Jianfeng wrote on 10/22/2007 11:37:07 AM:

> @@ -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;
>     }

Shouldn't the "goto drop" be inside the "if (unlikely(err)) {" case?
And normally it is nice to have a blank line after variable declaration.

- KK


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

* Re: [PATCH 2.4.35.3] Fix the "InAddrErrors" increasing problem
  2007-10-22  6:28 ` Krishna Kumar2
@ 2007-10-22  6:45   ` Gui Jianfeng
  2007-10-22  7:10   ` Gui Jianfeng
  1 sibling, 0 replies; 6+ messages in thread
From: Gui Jianfeng @ 2007-10-22  6:45 UTC (permalink / raw)
  To: Krishna Kumar2; +Cc: davem, netdev

Krishna Kumar2 写道:
> Gui Jianfeng wrote on 10/22/2007 11:37:07 AM:
> 
>> @@ -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;
>>     }
> 
> Shouldn't the "goto drop" be inside the "if (unlikely(err)) {" case?
yes, you are right :-)

> And normally it is nice to have a blank line after variable declaration.
> 
> - KK
> 
> 
> 


-- 


Regards
Gui Jianfeng
--------------------------------------------------
Gui Jianfeng
Development Dept.I
Nanjing Fujitsu Nanda Software Tech. Co., Ltd.(FNST)
8/F., Civil Defense Building, No.189 Guangzhou Road,
Nanjing, 210029, China
TEL: +86+25-86630566-851
COINS: 79955-851
FAX: +86+25-83317685
MAIL:guijianfeng@cn.fujitsu.com
--------------------------------------------------

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

* Re: [PATCH 2.4.35.3] Fix the "InAddrErrors" increasing problem
  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
  1 sibling, 1 reply; 6+ messages in thread
From: Gui Jianfeng @ 2007-10-22  7:10 UTC (permalink / raw)
  To: Krishna Kumar2; +Cc: davem, netdev

Krishna Kumar2 写道:
> Gui Jianfeng wrote on 10/22/2007 11:37:07 AM:
> 
>> @@ -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;
>>     }
> 
> Shouldn't the "goto drop" be inside the "if (unlikely(err)) {" case?
> And normally it is nice to have a blank line after variable declaration.
sorry for my careless, here is the correct one

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 11:30:22.000000000 +0800
@@ -310,8 +310,13 @@ 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))
+		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 11:29:19.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;

> 
> - KK
> 
> 
> 

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

* Re: [PATCH 2.4.35.3] Fix the "InAddrErrors" increasing problem
  2007-10-22  7:10   ` Gui Jianfeng
@ 2007-10-22  7:23     ` David Miller
  0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2007-10-22  7:23 UTC (permalink / raw)
  To: guijianfeng; +Cc: krkumar2, netdev

From: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
Date: Mon, 22 Oct 2007 15:10:46 +0800

> sorry for my careless, here is the correct one
> 
> Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>

BTW, I would also like to say that I think a statistics correction is
totally inappropriate for the 2.4.x kernel series which is in super
maintainence mode.

Only crash fixes and fixes for bugs that severely harm functionality
should go into that tree.

These obscure statistic counter cases absolutely do not qualify.

^ 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).