aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/icmp.c
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2015-10-09 08:34:31 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-12 22:38:02 -0400
commite2ca690b657f4ca5c204fcc6470d462b776d73b3 (patch)
treebad7ed1b3899da4affa41704c52c27e0a8a616c0 /net/ipv4/icmp.c
parent0944d6b5a2fad9ba3b7abb2e94a6b7d40cd4a935 (diff)
ipv4/icmp: redirect messages can use the ingress daddr as source
This patch allows configuring how the source address of ICMP redirect messages is selected; by default the old behaviour is retained, while setting icmp_redirects_use_orig_daddr force the usage of the destination address of the packet that caused the redirect. The new behaviour fits closely the RFC 5798 section 8.1.1, and fix the following scenario: Two machines are set up with VRRP to act as routers out of a subnet, they have IPs x.x.x.1/24 and x.x.x.2/24, with VRRP holding on to x.x.x.254/24. If a host in said subnet needs to get an ICMP redirect from the VRRP router, i.e. to reach a destination behind a different gateway, the source IP in the ICMP redirect is chosen as the primary IP on the interface that the packet arrived at, i.e. x.x.x.1 or x.x.x.2. The host will then ignore said redirect, due to RFC 1122 section 3.2.2.2, and will continue to use the wrong next-op. Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/icmp.c')
-rw-r--r--net/ipv4/icmp.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 36e26977c908..f3c356b7c1f0 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -659,7 +659,9 @@ void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info)
659 */ 659 */
660 660
661 saddr = iph->daddr; 661 saddr = iph->daddr;
662 if (!(rt->rt_flags & RTCF_LOCAL)) { 662 if (!((type == ICMP_REDIRECT) &&
663 net->ipv4.sysctl_icmp_redirects_use_orig_daddr) &&
664 !(rt->rt_flags & RTCF_LOCAL)) {
663 struct net_device *dev = NULL; 665 struct net_device *dev = NULL;
664 666
665 rcu_read_lock(); 667 rcu_read_lock();
@@ -1222,6 +1224,11 @@ static int __net_init icmp_sk_init(struct net *net)
1222 net->ipv4.sysctl_icmp_ratemask = 0x1818; 1224 net->ipv4.sysctl_icmp_ratemask = 0x1818;
1223 net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr = 0; 1225 net->ipv4.sysctl_icmp_errors_use_inbound_ifaddr = 0;
1224 1226
1227 /* Control paramerer - use the daddr of originating packets as saddr
1228 * in redirect messages?
1229 */
1230 net->ipv4.sysctl_icmp_redirects_use_orig_daddr = 0;
1231
1225 return 0; 1232 return 0;
1226 1233
1227fail: 1234fail: