Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: nicolas.dichtel@6wind.com, David Miller <davem@davemloft.net>
Cc: Octavian Purdila <opurdila@ixiacom.com>, netdev <netdev@vger.kernel.org>
Subject: [PATCH] ipv4: dont create routes on down devices
Date: Wed, 22 Dec 2010 15:39:39 +0100	[thread overview]
Message-ID: <1293028779.3027.133.camel@edumazet-laptop> (raw)
In-Reply-To: <4D120096.6080508@6wind.com>

Le mercredi 22 décembre 2010 à 14:43 +0100, Nicolas Dichtel a écrit :
> Yes, I saw this commit, but I still got the problem:
> 
> shelby:/home/root/src# uname -a
> Linux shelby 2.6.37-rc5+ #10 SMP Wed Dec 22 05:02:53 EST 2010 i686 GNU/Linux
> shelby:/home/root/src# ip tunnel add mode ipip remote 10.16.0.164 local 
> 10.16.0.72 dev eth0
> shelby:/home/root/src# ./a.out tunl1
> shelby:/home/root/src# ip tunnel del tunl1
> 
> Message from syslogd@shelby at Dec 22 10:12:08 ...
>   kernel:[18459.828011] unregister_netdevice: waiting for tunl1 to become free. 
> Usage count = 3
> 

On another machine, and net-next-2.6, I reproduced the problem, so we
need the patch after all, sorry for the delay.

Thanks

[PATCH] ipv4: dont create routes on down devices

In ip_route_output_slow(), instead of allowing a route to be created on
a not UPed device, report -ENETUNREACH immediately.

# ip tunnel add mode ipip remote 10.16.0.164 local 
10.16.0.72 dev eth0
# (Note : tunl1 is down)
# ping -I tunl1 10.1.2.3
PING 10.1.2.3 (10.1.2.3) from 192.168.18.5 tunl1: 56(84) bytes of data.
(nothing)
# ./a.out tunl1
# ip tunnel del tunl1
Message from syslogd@shelby at Dec 22 10:12:08 ...
  kernel: unregister_netdevice: waiting for tunl1 to become free. 
Usage count = 3

After patch:
# ping -I tunl1 10.1.2.3
connect: Network is unreachable


Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Cc: Octavian Purdila <opurdila@ixiacom.com>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
---
 net/ipv4/route.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index d8b4f4d..f1defb7 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -2562,9 +2562,10 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp,
 			goto out;
 
 		/* RACE: Check return value of inet_select_addr instead. */
-		if (rcu_dereference(dev_out->ip_ptr) == NULL)
-			goto out;	/* Wrong error code */
-
+		if (!(dev_out->flags & IFF_UP) || !__in_dev_get_rcu(dev_out)) {
+			err = -ENETUNREACH;
+			goto out;
+		}
 		if (ipv4_is_local_multicast(oldflp->fl4_dst) ||
 		    ipv4_is_lbcast(oldflp->fl4_dst)) {
 			if (!fl.fl4_src)



  reply	other threads:[~2010-12-22 14:39 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-28 15:24 [PATCH] ipv4: remove all rt cache entries on UNREGISTER event Nicolas Dichtel
2010-09-28 16:33 ` Eric Dumazet
2010-09-28 16:45   ` Nicolas Dichtel
2010-09-28 16:56     ` Eric Dumazet
2010-09-29  7:49       ` Nicolas Dichtel
2010-09-29  8:35         ` Eric Dumazet
2010-09-29  9:18           ` Eric Dumazet
2010-09-30 11:49             ` Nicolas Dichtel
2010-12-22  8:32             ` Nicolas Dichtel
2010-12-22  9:55               ` Eric Dumazet
2010-12-22 10:07                 ` Eric Dumazet
2010-12-22 13:43                   ` Nicolas Dichtel
2010-12-22 14:39                     ` Eric Dumazet [this message]
2010-12-23  8:50                       ` [PATCH] ipv4: dont create routes on down devices Octavian Purdila
2010-12-26  4:05                         ` David Miller
2010-09-28 17:35   ` [PATCH] ipv4: remove all rt cache entries on UNREGISTER event Octavian Purdila

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=1293028779.3027.133.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=opurdila@ixiacom.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
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