All of lore.kernel.org
 help / color / mirror / Atom feed
* Fix "ipOutNoRoutes" counter error for TCP and UDP
@ 2007-02-14 15:03 weidong
  2007-02-27  1:08 ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: weidong @ 2007-02-14 15:03 UTC (permalink / raw)
  To: netdev; +Cc: davem

Hi, All
  When I tested Linux-2.6.20 and found that counter "ipOutNoRoutes" can
not increase correctly.
  The criteria is 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 }

In current Linux TCP/IP stack, maybe we should not increase this counter
in "input path", but only increase it in "output path" due to the TCP/IP
stack performance.

Now in "output path", when TCP client tries to connect to an unreachable
server(net unreachable, so no route can be found), this counter has no
increment. When we use UDP sending UDP datagram to an net unreachable
address, this counter also has no increment.

Function need to fix:
tcp_v4_connect(); ip4_datagram_connect(); udp_sendmsg();

The following patch can fix the problems mentioned above

BR 
Wei Dong

signed-off-by: Wei Dong <weid@np.css.fujitsu.com>

diff -ruN old/net/ipv4/datagram.c new/net/ipv4/datagram.c
--- old/net/ipv4/datagram.c	2007-02-02 12:28:54.000000000 -0500
+++ new/net/ipv4/datagram.c	2007-02-02 12:29:01.000000000 -0500
@@ -50,8 +50,10 @@
 			       RT_CONN_FLAGS(sk), oif,
 			       sk->sk_protocol,
 			       inet->sport, usin->sin_port, sk);
-	if (err)
+	if (err) {
+		IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 		return err;
+	}
 	if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
 		ip_rt_put(rt);
 		return -EACCES;
diff -ruN old/net/ipv4/tcp_ipv4.c new/net/ipv4/tcp_ipv4.c
--- old/net/ipv4/tcp_ipv4.c	2007-02-02 12:28:54.000000000 -0500
+++ new/net/ipv4/tcp_ipv4.c	2007-02-02 12:29:01.000000000 -0500
@@ -192,8 +192,10 @@
 			       RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
 			       IPPROTO_TCP,
 			       inet->sport, usin->sin_port, sk);
-	if (tmp < 0)
+	if (tmp < 0) {
+		IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 		return tmp;
+	}
 
 	if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
 		ip_rt_put(rt);
diff -ruN old/net/ipv4/udp.c new/net/ipv4/udp.c
--- old/net/ipv4/udp.c	2007-02-02 12:28:54.000000000 -0500
+++ new/net/ipv4/udp.c	2007-02-02 12:29:01.000000000 -0500
@@ -630,8 +630,10 @@
 						 .dport = dport } } };
 		security_sk_classify_flow(sk, &fl);
 		err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
-		if (err)
+		if (err) {
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 			goto out;
+		}
 
 		err = -EACCES;
 		if ((rt->rt_flags & RTCF_BROADCAST) &&





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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
  2007-02-14 15:03 Fix "ipOutNoRoutes" counter error for TCP and UDP weidong
@ 2007-02-27  1:08 ` David Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2007-02-27  1:08 UTC (permalink / raw)
  To: weid; +Cc: netdev

From: weidong <weid@np.css.fujitsu.com>
Date: Wed, 14 Feb 2007 10:03:49 -0500

> Hi, All
>   When I tested Linux-2.6.20 and found that counter "ipOutNoRoutes" can
> not increase correctly.
>   The criteria is 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 }
> 
> In current Linux TCP/IP stack, maybe we should not increase this counter
> in "input path", but only increase it in "output path" due to the TCP/IP
> stack performance.
> 
> Now in "output path", when TCP client tries to connect to an unreachable
> server(net unreachable, so no route can be found), this counter has no
> increment. When we use UDP sending UDP datagram to an net unreachable
> address, this counter also has no increment.
> 
> Function need to fix:
> tcp_v4_connect(); ip4_datagram_connect(); udp_sendmsg();
> 
> The following patch can fix the problems mentioned above

Thank you for this patch.

I think we need to make these checks more carefully.

Route lookup can fail for several reasons other than
no route being available.  Two examples are:

1) Out of memory error while creating route
2) IPSEC disallows communication to that flow ID

As a result, we'll probably best limiting the counter
increment when the error is either -EHOSTUNREACH or
-ENETUNREACH.

Probably, since this logic will be duplicated to several
locations, you'll want to implement the test inside of
a helper inline function.

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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
  2007-06-01  5:37   ` weidong
@ 2007-06-01  5:49     ` David Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2007-06-01  5:49 UTC (permalink / raw)
  To: weidong; +Cc: netdev

From: weidong <weidong@cn.fujitsu.com>
Date: Fri, 01 Jun 2007 13:37:08 +0800

> Mr David
> 
>     Sorry to trouble many times, I will attention to this next time.
> 
>     I have made this patch again, and I tried, it can be patched to the recently
>     kernel of linux-2.6.21.3. following is the patch, and I also attach this
>     patch to the attachment.
> 
>     Signed-off-by: Wei Dong <weidong@cn.fujitsu.com>

Patch applied, thank you.

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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
  2007-06-01  4:41 ` David Miller
@ 2007-06-01  5:37   ` weidong
  2007-06-01  5:49     ` David Miller
  0 siblings, 1 reply; 13+ messages in thread
From: weidong @ 2007-06-01  5:37 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 3538 bytes --]

Mr David

    Sorry to trouble many times, I will attention to this next time.

    I have made this patch again, and I tried, it can be patched to the recently
    kernel of linux-2.6.21.3. following is the patch, and I also attach this
    patch to the attachment.

    Signed-off-by: Wei Dong <weidong@cn.fujitsu.com>

diff -Nurp a/net/ipv4/datagram.c b/net/ipv4/datagram.c
--- a/net/ipv4/datagram.c       2007-06-01 13:22:39.000000000 +0800
+++ b/net/ipv4/datagram.c       2007-06-01 13:24:21.000000000 +0800
@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk
                                RT_CONN_FLAGS(sk), oif,
                                sk->sk_protocol,
                                inet->sport, usin->sin_port, sk, 1);
-       if (err)
+       if (err) {
+               if (err == -ENETUNREACH)
+                       IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
                 return err;
+       }
+
         if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
                 ip_rt_put(rt);
                 return -EACCES;
diff -Nurp a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
--- a/net/ipv4/tcp_ipv4.c       2007-06-01 13:22:39.000000000 +0800
+++ b/net/ipv4/tcp_ipv4.c       2007-06-01 13:25:07.000000000 +0800
@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, stru
                                RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
                                IPPROTO_TCP,
                                inet->sport, usin->sin_port, sk, 1);
-       if (tmp < 0)
+       if (tmp < 0) {
+               if (tmp == -ENETUNREACH)
+                       IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
                 return tmp;
+       }

         if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
                 ip_rt_put(rt);
diff -Nurp a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c    2007-06-01 13:22:39.000000000 +0800
+++ b/net/ipv4/udp.c    2007-06-01 13:26:47.000000000 +0800
@@ -631,8 +631,11 @@ int udp_sendmsg(struct kiocb *iocb, stru
                                                  .dport = dport } } };
                 security_sk_classify_flow(sk, &fl);
                 err = ip_route_output_flow(&rt, &fl, sk, 1);
-               if (err)
+               if (err) {
+                       if (err == -ENETUNREACH)
+                               IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
                         goto out;
+               }

                 err = -EACCES;
                 if ((rt->rt_flags & RTCF_BROADCAST) &&



David Miller wrote:
> From: Wei Dong <weidong@cn.fujitsu.com>
> Date: Thu, 31 May 2007 09:16:50 +0800
> 
>> Hi Mr. David
>>   I have modified my patch according to you advice. I think -
>> EHOSTUNREACH is only for "input path". In "output" path, we can just
>> simply check-ENETUNREACH  (^_^), the patch is shown in the end of this mail.
>>
>>  I send this patch to you several weeks ago, but you have not replied to me.
>> This patch is not correctly?
> 
> Your email client is still corrupting the patch, it changes
> tab characters into spaces.  This makes the patch not apply.
> 
> Please do not send the same unusable patch so many times.
> Instead, I recommend to email the patch to yourself, and
> you try to apply it, in the same way someone else receiving
> your patch posting would.
> 
> -
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 

[-- Attachment #2: ipOutNoRoutes.patch --]
[-- Type: text/x-patch, Size: 1670 bytes --]

diff -Nurp a/net/ipv4/datagram.c b/net/ipv4/datagram.c
--- a/net/ipv4/datagram.c	2007-06-01 13:22:39.000000000 +0800
+++ b/net/ipv4/datagram.c	2007-06-01 13:24:21.000000000 +0800
@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk
 			       RT_CONN_FLAGS(sk), oif,
 			       sk->sk_protocol,
 			       inet->sport, usin->sin_port, sk, 1);
-	if (err)
+	if (err) {
+		if (err == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 
 		return err;
+	}
+
 	if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
 		ip_rt_put(rt);
 		return -EACCES;
diff -Nurp a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
--- a/net/ipv4/tcp_ipv4.c	2007-06-01 13:22:39.000000000 +0800
+++ b/net/ipv4/tcp_ipv4.c	2007-06-01 13:25:07.000000000 +0800
@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, stru
 			       RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
 			       IPPROTO_TCP,
 			       inet->sport, usin->sin_port, sk, 1);
-	if (tmp < 0)
+	if (tmp < 0) {
+		if (tmp == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 		return tmp;
+	}
 
 	if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
 		ip_rt_put(rt);
diff -Nurp a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c	2007-06-01 13:22:39.000000000 +0800
+++ b/net/ipv4/udp.c	2007-06-01 13:26:47.000000000 +0800
@@ -631,8 +631,11 @@ int udp_sendmsg(struct kiocb *iocb, stru
 						 .dport = dport } } };
 		security_sk_classify_flow(sk, &fl);
 		err = ip_route_output_flow(&rt, &fl, sk, 1);
-		if (err)
+		if (err) {
+			if (err == -ENETUNREACH)
+				IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 			goto out;
+		}
 
 		err = -EACCES;
 		if ((rt->rt_flags & RTCF_BROADCAST) &&

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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
  2007-05-31  1:16 Wei Dong
  2007-05-31  1:38 ` David Miller
@ 2007-06-01  4:41 ` David Miller
  2007-06-01  5:37   ` weidong
  1 sibling, 1 reply; 13+ messages in thread
From: David Miller @ 2007-06-01  4:41 UTC (permalink / raw)
  To: weidong; +Cc: netdev

From: Wei Dong <weidong@cn.fujitsu.com>
Date: Thu, 31 May 2007 09:16:50 +0800

> Hi Mr. David
>   I have modified my patch according to you advice. I think -
> EHOSTUNREACH is only for "input path". In "output" path, we can just
> simply check-ENETUNREACH  (^_^), the patch is shown in the end of this mail.
> 
>  I send this patch to you several weeks ago, but you have not replied to me.
> This patch is not correctly?

Your email client is still corrupting the patch, it changes
tab characters into spaces.  This makes the patch not apply.

Please do not send the same unusable patch so many times.
Instead, I recommend to email the patch to yourself, and
you try to apply it, in the same way someone else receiving
your patch posting would.


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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
  2007-05-31  1:16 Wei Dong
@ 2007-05-31  1:38 ` David Miller
  2007-06-01  4:41 ` David Miller
  1 sibling, 0 replies; 13+ messages in thread
From: David Miller @ 2007-05-31  1:38 UTC (permalink / raw)
  To: weidong; +Cc: netdev


Please stop sending your patche emails twice every time.

I got the first copy!

Thank you :-)

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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
@ 2007-05-31  1:18 Wei Dong
  0 siblings, 0 replies; 13+ messages in thread
From: Wei Dong @ 2007-05-31  1:18 UTC (permalink / raw)
  To: davem; +Cc: netdev

Hi Mr. David
   I have modified my patch according to you advice. I think -
EHOSTUNREACH is only for "input path". In "output" path, we can just
simply check-ENETUNREACH  (^_^), the patch is shown in the end of this mail.

  I send this patch to you several weeks ago, but you have not replied to me.
This patch is not correctly?


 >>>>>>>> >>>> >> >> Function need to fix:
 >>>>>>>> >>>> >> >> tcp_v4_connect(); ip4_datagram_connect(); udp_sendmsg();
 >>>> >> >>

 >>>> >> > > I think we need to make these checks more carefully.
 >>>> >> > >
 >>>> >> > > Route lookup can fail for several reasons other than
 >>>> >> > > no route being available.  Two examples are:
 >>>> >> > >
 >>>> >> > > 1) Out of memory error while creating route
 >>>> >> > > 2) IPSEC disallows communication to that flow ID
 >>>> >> > >
 >>>> >> > > As a result, we'll probably best limiting the counter
 >>>> >> > > increment when the error is either -EHOSTUNREACH or
 >>>> >> > > -ENETUNREACH.
 >> > >

signed-off-by: Wei Dong <weidong@cn.fujitsu.com>


diff -ruNp a/net/ipv4/datagram.c b/net/ipv4/datagram.c
--- a/net/ipv4/datagram.c    2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/datagram.c    2007-04-25 15:21:42.000000000 +0800
@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk
                     RT_CONN_FLAGS(sk), oif,
                     sk->sk_protocol,
                     inet->sport, usin->sin_port, sk);
-    if (err)
+    if (err) {
+        if (err == -ENETUNREACH)
+            IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
          return err;
+    }
+
      if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
          ip_rt_put(rt);
          return -EACCES;
diff -ruNp a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
--- a/net/ipv4/tcp_ipv4.c    2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/tcp_ipv4.c    2007-04-25 15:21:42.000000000 +0800
@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, stru
                     RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
                     IPPROTO_TCP,
                     inet->sport, usin->sin_port, sk);
-    if (tmp < 0)
+    if (tmp < 0) {
+        if (tmp == -ENETUNREACH)
+            IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
          return tmp;
+    }

      if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
          ip_rt_put(rt);
diff -ruNp a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c    2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/udp.c    2007-04-25 15:21:42.000000000 +0800
@@ -630,8 +630,11 @@ int udp_sendmsg(struct kiocb *iocb, stru
                           .dport = dport } } };
          security_sk_classify_flow(sk, &fl);
          err = ip_route_output_flow(&rt, &fl, sk,
!(msg->msg_flags&MSG_DONTWAIT));
-        if (err)
+        if (err) {
+            if (err == -ENETUNREACH)
+                IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
              goto out;
+        }

          err = -EACCES;
          if ((rt->rt_flags & RTCF_BROADCAST) &&


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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
@ 2007-05-31  1:16 Wei Dong
  2007-05-31  1:38 ` David Miller
  2007-06-01  4:41 ` David Miller
  0 siblings, 2 replies; 13+ messages in thread
From: Wei Dong @ 2007-05-31  1:16 UTC (permalink / raw)
  To: davem; +Cc: netdev

Hi Mr. David
  I have modified my patch according to you advice. I think -
EHOSTUNREACH is only for "input path". In "output" path, we can just
simply check-ENETUNREACH  (^_^), the patch is shown in the end of this mail.

 I send this patch to you several weeks ago, but you have not replied to me.
This patch is not correctly?


>>>> >> >> Function need to fix:
>>>> >> >> tcp_v4_connect(); ip4_datagram_connect(); udp_sendmsg();
>> >>

>> > > I think we need to make these checks more carefully.
>> > >
>> > > Route lookup can fail for several reasons other than
>> > > no route being available.  Two examples are:
>> > >
>> > > 1) Out of memory error while creating route
>> > > 2) IPSEC disallows communication to that flow ID
>> > >
>> > > As a result, we'll probably best limiting the counter
>> > > increment when the error is either -EHOSTUNREACH or
>> > > -ENETUNREACH.
> >

signed-off-by: Wei Dong <weidong@cn.fujitsu.com>


diff -ruNp a/net/ipv4/datagram.c b/net/ipv4/datagram.c
--- a/net/ipv4/datagram.c    2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/datagram.c    2007-04-25 15:21:42.000000000 +0800
@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk
                    RT_CONN_FLAGS(sk), oif,
                    sk->sk_protocol,
                    inet->sport, usin->sin_port, sk);
-    if (err)
+    if (err) {
+        if (err == -ENETUNREACH)
+            IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
         return err;
+    }
+
     if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
         ip_rt_put(rt);
         return -EACCES;
diff -ruNp a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
--- a/net/ipv4/tcp_ipv4.c    2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/tcp_ipv4.c    2007-04-25 15:21:42.000000000 +0800
@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, stru
                    RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
                    IPPROTO_TCP,
                    inet->sport, usin->sin_port, sk);
-    if (tmp < 0)
+    if (tmp < 0) {
+        if (tmp == -ENETUNREACH)
+            IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
         return tmp;
+    }

     if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
         ip_rt_put(rt);
diff -ruNp a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c    2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/udp.c    2007-04-25 15:21:42.000000000 +0800
@@ -630,8 +630,11 @@ int udp_sendmsg(struct kiocb *iocb, stru
                          .dport = dport } } };
         security_sk_classify_flow(sk, &fl);
         err = ip_route_output_flow(&rt, &fl, sk,
!(msg->msg_flags&MSG_DONTWAIT));
-        if (err)
+        if (err) {
+            if (err == -ENETUNREACH)
+                IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
             goto out;
+        }

         err = -EACCES;
         if ((rt->rt_flags & RTCF_BROADCAST) &&

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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
@ 2007-04-25  9:04 weidong
  0 siblings, 0 replies; 13+ messages in thread
From: weidong @ 2007-04-25  9:04 UTC (permalink / raw)
  To: davem, netdev

Hi Mr. David
     I have modified my patch according to you advice. I think -
EHOSTUNREACH is only for "input path". In "output" path, we can just
simply check-ENETUNREACH  (^_^), the patch is shown in the end of this mail.

BTW: my E-mail has been changed to weidong@cn.fujitsu.com


>>>> >> >> Function need to fix:
>>>> >> >> tcp_v4_connect(); ip4_datagram_connect(); udp_sendmsg();
>> >>

>> > > I think we need to make these checks more carefully.
>> > >
>> > > Route lookup can fail for several reasons other than
>> > > no route being available.  Two examples are:
>> > >
>> > > 1) Out of memory error while creating route
>> > > 2) IPSEC disallows communication to that flow ID
>> > >
>> > > As a result, we'll probably best limiting the counter
>> > > increment when the error is either -EHOSTUNREACH or
>> > > -ENETUNREACH.
> >

signed-off-by: Wei Dong <weidong@cn.fujitsu.com>


diff -ruNp a/net/ipv4/datagram.c b/net/ipv4/datagram.c
--- a/net/ipv4/datagram.c	2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/datagram.c	2007-04-25 15:21:42.000000000 +0800
@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk
  			       RT_CONN_FLAGS(sk), oif,
  			       sk->sk_protocol,
  			       inet->sport, usin->sin_port, sk);
-	if (err)
+	if (err) {
+		if (err == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
  		return err;
+	}
+
  	if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
  		ip_rt_put(rt);
  		return -EACCES;
diff -ruNp a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
--- a/net/ipv4/tcp_ipv4.c	2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/tcp_ipv4.c	2007-04-25 15:21:42.000000000 +0800
@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, stru
  			       RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
  			       IPPROTO_TCP,
  			       inet->sport, usin->sin_port, sk);
-	if (tmp < 0)
+	if (tmp < 0) {
+		if (tmp == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
  		return tmp;
+	}

  	if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
  		ip_rt_put(rt);
diff -ruNp a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c	2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/udp.c	2007-04-25 15:21:42.000000000 +0800
@@ -630,8 +630,11 @@ int udp_sendmsg(struct kiocb *iocb, stru
  						 .dport = dport } } };
  		security_sk_classify_flow(sk, &fl);
  		err = ip_route_output_flow(&rt, &fl, sk,
!(msg->msg_flags&MSG_DONTWAIT));
-		if (err)
+		if (err) {
+			if (err == -ENETUNREACH)
+				IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
  			goto out;
+		}

  		err = -EACCES;
  		if ((rt->rt_flags & RTCF_BROADCAST) &&


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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
       [not found] <462F029D.5070301@cn.fujitsu.com>
@ 2007-04-25  8:27 ` David Miller
  0 siblings, 0 replies; 13+ messages in thread
From: David Miller @ 2007-04-25  8:27 UTC (permalink / raw)
  To: weidong; +Cc: netdev


Please do not post in HTML, nobody will read it, including
me.

Please use plain ASCII text for all mailing list postings,
especially those containing patches.


Thank you.

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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
@ 2007-04-25  7:39 weidong
  0 siblings, 0 replies; 13+ messages in thread
From: weidong @ 2007-04-25  7:39 UTC (permalink / raw)
  To: davem, netdev

Hi Mr. David
    I have modified my patch according to you advice. I think -
EHOSTUNREACH
is only for "input path". In "output" path, we can just simply check
-ENETUNREACH  (^_^), the patch is shown in the end of this mail.

BTW: my E-mail has been changed to weidong@cn.fujitsu.com


>> >> Function need to fix:
>> >> tcp_v4_connect(); ip4_datagram_connect(); udp_sendmsg();
>>

> > I think we need to make these checks more carefully.
> >
> > Route lookup can fail for several reasons other than
> > no route being available.  Two examples are:
> >
> > 1) Out of memory error while creating route
> > 2) IPSEC disallows communication to that flow ID
> >
> > As a result, we'll probably best limiting the counter
> > increment when the error is either -EHOSTUNREACH or
> > -ENETUNREACH.
>

signed-off-by: Wei Dong <weidong@cn.fujitsu.com>


diff -ruNp a/net/ipv4/datagram.c b/net/ipv4/datagram.c
--- a/net/ipv4/datagram.c	2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/datagram.c	2007-04-25 15:21:42.000000000 +0800
@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk
 			       RT_CONN_FLAGS(sk), oif,
 			       sk->sk_protocol,
 			       inet->sport, usin->sin_port, sk);
-	if (err)
+	if (err) {
+		if (err == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 		return err;
+	}
+
 	if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
 		ip_rt_put(rt);
 		return -EACCES;
diff -ruNp a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
--- a/net/ipv4/tcp_ipv4.c	2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/tcp_ipv4.c	2007-04-25 15:21:42.000000000 +0800
@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, stru
 			       RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
 			       IPPROTO_TCP,
 			       inet->sport, usin->sin_port, sk);
-	if (tmp < 0)
+	if (tmp < 0) {
+		if (tmp == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 		return tmp;
+	}

 	if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
 		ip_rt_put(rt);
diff -ruNp a/net/ipv4/udp.c b/net/ipv4/udp.c
--- a/net/ipv4/udp.c	2007-04-25 15:20:19.000000000 +0800
+++ b/net/ipv4/udp.c	2007-04-25 15:21:42.000000000 +0800
@@ -630,8 +630,11 @@ int udp_sendmsg(struct kiocb *iocb, stru
 						 .dport = dport } } };
 		security_sk_classify_flow(sk, &fl);
 		err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
-		if (err)
+		if (err) {
+			if (err == -ENETUNREACH)
+				IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 			goto out;
+		}

 		err = -EACCES;
 		if ((rt->rt_flags & RTCF_BROADCAST) &&


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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
@ 2007-03-28  1:15 weidong
  0 siblings, 0 replies; 13+ messages in thread
From: weidong @ 2007-03-28  1:15 UTC (permalink / raw)
  To: davem; +Cc: netdev

Hi Mr. David 
    I have modified my patch according to you advice. I think -
EHOSTUNREACH 
is only for "input path". In "output" path, we can just simply check 
-ENETUNREACH  (^_^), the patch is shown in the end of this mail. 

BTW: my E-mail has been changed to weidong@cn.fujitsu.com 

>> Function need to fix: 
>> tcp_v4_connect(); ip4_datagram_connect(); udp_sendmsg(); 

> I think we need to make these checks more carefully. 
> 
> Route lookup can fail for several reasons other than 
> no route being available.  Two examples are: 
> 
> 1) Out of memory error while creating route 
> 2) IPSEC disallows communication to that flow ID 
> 
> As a result, we'll probably best limiting the counter 
> increment when the error is either -EHOSTUNREACH or 
> -ENETUNREACH. 

signed-off-by: Wei Dong <weidong@cn.fujitsu.com>

diff -ruNp old/net/ipv4/datagram.c new/net/ipv4/datagram.c
--- old/net/ipv4/datagram.c	2007-03-27 18:15:56.000000000 +0800
+++ new/net/ipv4/datagram.c	2007-03-27 18:23:58.000000000 +0800
@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk
 			       RT_CONN_FLAGS(sk), oif,
 			       sk->sk_protocol,
 			       inet->sport, usin->sin_port, sk);
-	if (err)
+	if (err) {
+		if (err == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 		return err;
+	}
+
 	if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
 		ip_rt_put(rt);
 		return -EACCES;
diff -ruNp old/net/ipv4/tcp_ipv4.c new/net/ipv4/tcp_ipv4.c
--- old/net/ipv4/tcp_ipv4.c	2007-03-27 18:15:56.000000000 +0800
+++ new/net/ipv4/tcp_ipv4.c	2007-03-27 18:28:38.000000000 +0800
@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, stru
 			       RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
 			       IPPROTO_TCP,
 			       inet->sport, usin->sin_port, sk);
-	if (tmp < 0)
+	if (tmp < 0) {
+		if (tmp == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 		return tmp;
+	}
 
 	if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
 		ip_rt_put(rt);
diff -ruNp old/net/ipv4/udp.c new/net/ipv4/udp.c
--- old/net/ipv4/udp.c	2007-03-27 18:15:56.000000000 +0800
+++ new/net/ipv4/udp.c	2007-03-27 18:26:47.000000000 +0800
@@ -630,8 +630,11 @@ int udp_sendmsg(struct kiocb *iocb, stru
 						 .dport = dport } } };
 		security_sk_classify_flow(sk, &fl);
 		err = ip_route_output_flow(&rt, &fl, sk, !(msg->msg_flags&MSG_DONTWAIT));
-		if (err)
+		if (err) {
+			if (err == -ENETUNREACH)
+				IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
 			goto out;
+		}
 
 		err = -EACCES;
 		if ((rt->rt_flags & RTCF_BROADCAST) &&



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

* Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
@ 2007-03-27 10:53 Wei Dong
  0 siblings, 0 replies; 13+ messages in thread
From: Wei Dong @ 2007-03-27 10:53 UTC (permalink / raw)
  To: davem; +Cc: netdev

Hi Mr. David
	I have modified my patch according to you advice. I think -EHOSTUNREACH
is only for "input path". In "output" path, we can just simply check
-ENETUNREACH  (^_^), the patch is shown in the end of this mail.

BTW: my E-mail has been changed to weidong@cn.fujitsu.com

 >> Function need to fix:
 >> tcp_v4_connect(); ip4_datagram_connect(); udp_sendmsg();

 > I think we need to make these checks more carefully.
 >
 > Route lookup can fail for several reasons other than
 > no route being available.  Two examples are:
 >
 > 1) Out of memory error while creating route
 > 2) IPSEC disallows communication to that flow ID
 >
 > As a result, we'll probably best limiting the counter
 > increment when the error is either -EHOSTUNREACH or
 > -ENETUNREACH.

signed-off-by: Wei Dong <weidong@cn.fujitsu.com>

diff -ruNp old/net/ipv4/datagram.c new/net/ipv4/datagram.c
--- old/net/ipv4/datagram.c	2007-03-27 18:15:56.000000000 +0800
+++ new/net/ipv4/datagram.c	2007-03-27 18:23:58.000000000 +0800
@@ -50,8 +50,12 @@ int ip4_datagram_connect(struct sock *sk
  			       RT_CONN_FLAGS(sk), oif,
  			       sk->sk_protocol,
  			       inet->sport, usin->sin_port, sk);
-	if (err)
+	if (err) {
+		if (err == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
  		return err;
+	}
+
  	if ((rt->rt_flags & RTCF_BROADCAST) && !sock_flag(sk, SOCK_BROADCAST)) {
  		ip_rt_put(rt);
  		return -EACCES;
diff -ruNp old/net/ipv4/tcp_ipv4.c new/net/ipv4/tcp_ipv4.c
--- old/net/ipv4/tcp_ipv4.c	2007-03-27 18:15:56.000000000 +0800
+++ new/net/ipv4/tcp_ipv4.c	2007-03-27 18:28:38.000000000 +0800
@@ -192,8 +192,11 @@ int tcp_v4_connect(struct sock *sk, stru
  			       RT_CONN_FLAGS(sk), sk->sk_bound_dev_if,
  			       IPPROTO_TCP,
  			       inet->sport, usin->sin_port, sk);
-	if (tmp < 0)
+	if (tmp < 0) {
+		if (tmp == -ENETUNREACH)
+			IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
  		return tmp;
+	}

  	if (rt->rt_flags & (RTCF_MULTICAST | RTCF_BROADCAST)) {
  		ip_rt_put(rt);
diff -ruNp old/net/ipv4/udp.c new/net/ipv4/udp.c
--- old/net/ipv4/udp.c	2007-03-27 18:15:56.000000000 +0800
+++ new/net/ipv4/udp.c	2007-03-27 18:26:47.000000000 +0800
@@ -630,8 +630,11 @@ int udp_sendmsg(struct kiocb *iocb, stru
  						 .dport = dport } } };
  		security_sk_classify_flow(sk, &fl);
  		err = ip_route_output_flow(&rt, &fl, sk, 
!(msg->msg_flags&MSG_DONTWAIT));
-		if (err)
+		if (err) {
+			if (err == -ENETUNREACH)
+				IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES);
  			goto out;
+		}

  		err = -EACCES;
  		if ((rt->rt_flags & RTCF_BROADCAST) &&


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

end of thread, other threads:[~2007-06-01  5:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-14 15:03 Fix "ipOutNoRoutes" counter error for TCP and UDP weidong
2007-02-27  1:08 ` David Miller
2007-03-27 10:53 Wei Dong
2007-03-28  1:15 weidong
2007-04-25  7:39 weidong
     [not found] <462F029D.5070301@cn.fujitsu.com>
2007-04-25  8:27 ` David Miller
2007-04-25  9:04 weidong
2007-05-31  1:16 Wei Dong
2007-05-31  1:38 ` David Miller
2007-06-01  4:41 ` David Miller
2007-06-01  5:37   ` weidong
2007-06-01  5:49     ` David Miller
2007-05-31  1:18 Wei Dong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.