diff options
author | Eric Dumazet <eric.dumazet@gmail.com> | 2010-12-21 23:39:39 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-12-25 23:05:31 -0500 |
commit | fc75fc8339e7727167443469027540b283daac71 (patch) | |
tree | f4e4a6b9554b157976d73db9f1ae2e93ddf6e24e /net | |
parent | 7a36df8a857edee8cd8967cbe99a85574d22f482 (diff) |
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>
Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Reviewed-by: Octavian Purdila <opurdila@ixiacom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/route.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 987bf9adb318..df948b0f1ac9 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -2585,9 +2585,10 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp, | |||
2585 | goto out; | 2585 | goto out; |
2586 | 2586 | ||
2587 | /* RACE: Check return value of inet_select_addr instead. */ | 2587 | /* RACE: Check return value of inet_select_addr instead. */ |
2588 | if (rcu_dereference(dev_out->ip_ptr) == NULL) | 2588 | if (!(dev_out->flags & IFF_UP) || !__in_dev_get_rcu(dev_out)) { |
2589 | goto out; /* Wrong error code */ | 2589 | err = -ENETUNREACH; |
2590 | 2590 | goto out; | |
2591 | } | ||
2591 | if (ipv4_is_local_multicast(oldflp->fl4_dst) || | 2592 | if (ipv4_is_local_multicast(oldflp->fl4_dst) || |
2592 | ipv4_is_lbcast(oldflp->fl4_dst)) { | 2593 | ipv4_is_lbcast(oldflp->fl4_dst)) { |
2593 | if (!fl.fl4_src) | 2594 | if (!fl.fl4_src) |