diff options
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r-- | net/ipv4/route.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 987bf9adb318..93bfd95584f4 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) |
@@ -2648,8 +2649,12 @@ static int ip_route_output_slow(struct net *net, struct rtable **rp, | |||
2648 | } | 2649 | } |
2649 | 2650 | ||
2650 | if (res.type == RTN_LOCAL) { | 2651 | if (res.type == RTN_LOCAL) { |
2651 | if (!fl.fl4_src) | 2652 | if (!fl.fl4_src) { |
2652 | fl.fl4_src = fl.fl4_dst; | 2653 | if (res.fi->fib_prefsrc) |
2654 | fl.fl4_src = res.fi->fib_prefsrc; | ||
2655 | else | ||
2656 | fl.fl4_src = fl.fl4_dst; | ||
2657 | } | ||
2653 | dev_out = net->loopback_dev; | 2658 | dev_out = net->loopback_dev; |
2654 | fl.oif = dev_out->ifindex; | 2659 | fl.oif = dev_out->ifindex; |
2655 | res.fi = NULL; | 2660 | res.fi = NULL; |