aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorAndreas Hofmeister <andi@collax.com>2011-10-24 19:13:15 -0400
committerDavid S. Miller <davem@davemloft.net>2011-10-24 19:13:15 -0400
commit9f56220fad0d13f8b0ebe7592f41fdb49874d143 (patch)
tree7e5d439d2f53fb86d509d8c9f4994754ca5c3fe2 /net/ipv6
parent48855432047c9de7ea9987349de4c47d48ade8d1 (diff)
ipv6: Do not use routes from locally generated RAs
When hybrid mode is enabled (accept_ra == 2), the kernel also sees RAs generated locally. This is useful since it allows the kernel to auto-configure its own interface addresses. However, if 'accept_ra_defrtr' and/or 'accept_ra_rtr_pref' are set and the locally generated RAs announce the default route and/or other route information, the kernel happily inserts bogus routes with its own address as gateway. With this patch, adding routes from an RA will be skiped when the RAs source address matches any local address, just as if 'accept_ra_defrtr' and 'accept_ra_rtr_pref' were set to 0. Signed-off-by: Andreas Hofmeister <andi@collax.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/ndisc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 7968bfec6138..44e5b7f2a6c1 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1221,6 +1221,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
1221 if (!in6_dev->cnf.accept_ra_defrtr) 1221 if (!in6_dev->cnf.accept_ra_defrtr)
1222 goto skip_defrtr; 1222 goto skip_defrtr;
1223 1223
1224 if (ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr, NULL, 0))
1225 goto skip_defrtr;
1226
1224 lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime); 1227 lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);
1225 1228
1226#ifdef CONFIG_IPV6_ROUTER_PREF 1229#ifdef CONFIG_IPV6_ROUTER_PREF
@@ -1343,6 +1346,9 @@ skip_linkparms:
1343 goto out; 1346 goto out;
1344 1347
1345#ifdef CONFIG_IPV6_ROUTE_INFO 1348#ifdef CONFIG_IPV6_ROUTE_INFO
1349 if (ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr, NULL, 0))
1350 goto skip_routeinfo;
1351
1346 if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) { 1352 if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) {
1347 struct nd_opt_hdr *p; 1353 struct nd_opt_hdr *p;
1348 for (p = ndopts.nd_opts_ri; 1354 for (p = ndopts.nd_opts_ri;
@@ -1360,6 +1366,8 @@ skip_linkparms:
1360 &ipv6_hdr(skb)->saddr); 1366 &ipv6_hdr(skb)->saddr);
1361 } 1367 }
1362 } 1368 }
1369
1370skip_routeinfo:
1363#endif 1371#endif
1364 1372
1365#ifdef CONFIG_IPV6_NDISC_NODETYPE 1373#ifdef CONFIG_IPV6_NDISC_NODETYPE