Commit fc75fc83 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

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 local dev eth0
# (Note : tunl1 is down)
# ping -I tunl1
PING ( from tunl1: 56(84) bytes of data.
# ./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
connect: Network is unreachable
Reported-by: default avatarNicolas Dichtel <>
Signed-off-by: default avatarEric Dumazet <>
Reviewed-by: default avatarOctavian Purdila <>
Signed-off-by: default avatarDavid S. Miller <>
parent 7a36df8a
......@@ -2585,9 +2585,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)) {
goto out;
if (ipv4_is_local_multicast(oldflp->fl4_dst) ||
ipv4_is_lbcast(oldflp->fl4_dst)) {
if (!fl.fl4_src)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment