diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/icmp.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index e7bbff4340bb..17ba9cb86720 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c @@ -513,9 +513,15 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, u32 info) saddr = iph->daddr; if (!(rt->rt_flags & RTCF_LOCAL)) { - if (sysctl_icmp_errors_use_inbound_ifaddr) - saddr = inet_select_addr(skb_in->dev, 0, RT_SCOPE_LINK); - else + struct net_device *dev = NULL; + + if (rt->fl.iif && sysctl_icmp_errors_use_inbound_ifaddr) + dev = dev_get_by_index(rt->fl.iif); + + if (dev) { + saddr = inet_select_addr(dev, 0, RT_SCOPE_LINK); + dev_put(dev); + } else saddr = 0; } |