@@ -567,7 +567,7 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
rcu_read_lock();
if (rt_is_input_route(rt) &&
- net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr)
+ net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr == 1)
dev = dev_get_by_index_rcu(net, rt->rt_iif);
if (dev)
@@ -577,6 +577,23 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
rcu_read_unlock();
}
+ /*
+ * Set source in case of error reply
+ */
+
+ if (icmp_pointers[type].error && net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr == 2) {
+ struct net_device *dev = NULL;
+ __be32 tmpaddr = 0;
+
+ rcu_read_lock();
+ dev = dev_get_by_name_rcu(net, "lo");
+ if (dev)
+ tmpaddr = inet_select_addr(dev, 0, RT_SCOPE_UNIVERSE);
+ if (tmpaddr)
+ saddr = tmpaddr;
+ rcu_read_unlock();
+ }
+
tos = icmp_pointers[type].error ? ((iph->tos & IPTOS_TOS_MASK) |
IPTOS_PREC_INTERNETCONTROL) :
iph->tos;