public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: weidong <weidong@cn•fujitsu.com>
To: davem@davemloft•net
Cc: netdev@vger•kernel.org
Subject: Re: Fix "ipOutNoRoutes" counter error for TCP and UDP
Date: Wed, 28 Mar 2007 09:15:03 +0800	[thread overview]
Message-ID: <1175044503.4691.3.camel@RedHat4U4> (raw)

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



             reply	other threads:[~2007-03-28  1:12 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-28  1:15 weidong [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-05-31  1:18 Fix "ipOutNoRoutes" counter error for TCP and UDP Wei Dong
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-04-25  9:04 weidong
     [not found] <462F029D.5070301@cn.fujitsu.com>
2007-04-25  8:27 ` David Miller
2007-04-25  7:39 weidong
2007-03-27 10:53 Wei Dong
2007-02-14 15:03 weidong
2007-02-27  1:08 ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1175044503.4691.3.camel@RedHat4U4 \
    --to=weidong@cn$(echo .)fujitsu.com \
    --cc=davem@davemloft$(echo .)net \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox