Commit 9f56220f authored by Andreas Hofmeister's avatar Andreas Hofmeister Committed by David S. Miller

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: default avatarAndreas Hofmeister <andi@collax.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 48855432
...@@ -1221,6 +1221,9 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1221,6 +1221,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
if (!in6_dev->cnf.accept_ra_defrtr) if (!in6_dev->cnf.accept_ra_defrtr)
goto skip_defrtr; goto skip_defrtr;
if (ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr, NULL, 0))
goto skip_defrtr;
lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime); lifetime = ntohs(ra_msg->icmph.icmp6_rt_lifetime);
#ifdef CONFIG_IPV6_ROUTER_PREF #ifdef CONFIG_IPV6_ROUTER_PREF
...@@ -1343,6 +1346,9 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1343,6 +1346,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
goto out; goto out;
#ifdef CONFIG_IPV6_ROUTE_INFO #ifdef CONFIG_IPV6_ROUTE_INFO
if (ipv6_chk_addr(dev_net(in6_dev->dev), &ipv6_hdr(skb)->saddr, NULL, 0))
goto skip_routeinfo;
if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) { if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) {
struct nd_opt_hdr *p; struct nd_opt_hdr *p;
for (p = ndopts.nd_opts_ri; for (p = ndopts.nd_opts_ri;
...@@ -1360,6 +1366,8 @@ static void ndisc_router_discovery(struct sk_buff *skb) ...@@ -1360,6 +1366,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
&ipv6_hdr(skb)->saddr); &ipv6_hdr(skb)->saddr);
} }
} }
skip_routeinfo:
#endif #endif
#ifdef CONFIG_IPV6_NDISC_NODETYPE #ifdef CONFIG_IPV6_NDISC_NODETYPE
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment