]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[ICMP]: Fix icmp_errors_use_inbound_ifaddr sysctl
authorPatrick McHardy <kaber@trash.net>
Fri, 2 Nov 2007 21:42:48 +0000 (22:42 +0100)
committerAdrian Bunk <bunk@kernel.org>
Fri, 2 Nov 2007 21:42:48 +0000 (22:42 +0100)
Currently when icmp_errors_use_inbound_ifaddr is set and an ICMP error is
sent after the packet passed through ip_output(), an address from the
outgoing interface is chosen as ICMP source address since skb->dev doesn't
point to the incoming interface anymore.

Fix this by doing an interface lookup on rt->dst.iif and using that device.

Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Adrian Bunk <bunk@kernel.org>
net/ipv4/icmp.c

index e7bbff4340bb6c2d73c956b15c40a4b596296ecb..17ba9cb867200e4b3660f9ee770a4b71d97842c7 100644 (file)
@@ -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;
        }