* [PATCH -next] ipv6: reject locally assigned nexthop addresses
@ 2015-05-20 22:25 Florian Westphal
2015-05-20 23:55 ` Hannes Frederic Sowa
2015-05-22 3:24 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Florian Westphal @ 2015-05-20 22:25 UTC (permalink / raw)
To: netdev; +Cc: hannes, Florian Westphal
ip -6 addr add dead::1/128 dev eth0
sleep 5
ip -6 route add default via dead::1/128
-> fails
ip -6 addr add dead::1/128 dev eth0
ip -6 route add default via dead::1/128
-> succeeds
reason is that if (nonsensensical) route above is added,
dead::1 is still subject to DAD, so the route lookup will
pick eth0 as outdev due to the prefix route that is added before
DAD work is started.
Add explicit test that checks if nexthop gateway is a local address.
Link: https://bugzilla.redhat.com/show_bug.cgi?id=1167969
Signed-off-by: Florian Westphal <fw@strlen.de>
---
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 6f4a350..98fce6f 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1624,6 +1624,16 @@ int ip6_route_add(struct fib6_config *cfg)
int gwa_type;
gw_addr = &cfg->fc_gateway;
+
+ /* if gw_addr is local we will fail to detect this in case
+ * address is still TENTATIVE (DAD in progress). rt6_lookup()
+ * will return already-added prefix route via interface that
+ * prefix route was assigned to, which might be non-loopback.
+ */
+ err = -EINVAL;
+ if (ipv6_chk_addr_and_flags(net, gw_addr, NULL, 0, 0))
+ goto out;
+
rt->rt6i_gateway = *gw_addr;
gwa_type = ipv6_addr_type(gw_addr);
@@ -1637,7 +1647,6 @@ int ip6_route_add(struct fib6_config *cfg)
(SIT, PtP, NBMA NOARP links) it is handy to allow
some exceptions. --ANK
*/
- err = -EINVAL;
if (!(gwa_type & IPV6_ADDR_UNICAST))
goto out;
--
2.0.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH -next] ipv6: reject locally assigned nexthop addresses
2015-05-20 22:25 [PATCH -next] ipv6: reject locally assigned nexthop addresses Florian Westphal
@ 2015-05-20 23:55 ` Hannes Frederic Sowa
2015-05-22 3:24 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Hannes Frederic Sowa @ 2015-05-20 23:55 UTC (permalink / raw)
To: Florian Westphal, netdev
On Thu, May 21, 2015, at 00:25, Florian Westphal wrote:
> ip -6 addr add dead::1/128 dev eth0
> sleep 5
> ip -6 route add default via dead::1/128
> -> fails
> ip -6 addr add dead::1/128 dev eth0
> ip -6 route add default via dead::1/128
> -> succeeds
>
> reason is that if (nonsensensical) route above is added,
> dead::1 is still subject to DAD, so the route lookup will
> pick eth0 as outdev due to the prefix route that is added before
> DAD work is started.
>
> Add explicit test that checks if nexthop gateway is a local address.
>
> Link: https://bugzilla.redhat.com/show_bug.cgi?id=1167969
Should hopefully be public soon. :/
> Signed-off-by: Florian Westphal <fw@strlen.de>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH -next] ipv6: reject locally assigned nexthop addresses
2015-05-20 22:25 [PATCH -next] ipv6: reject locally assigned nexthop addresses Florian Westphal
2015-05-20 23:55 ` Hannes Frederic Sowa
@ 2015-05-22 3:24 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-05-22 3:24 UTC (permalink / raw)
To: fw; +Cc: netdev, hannes
From: Florian Westphal <fw@strlen.de>
Date: Thu, 21 May 2015 00:25:41 +0200
> ip -6 addr add dead::1/128 dev eth0
> sleep 5
> ip -6 route add default via dead::1/128
> -> fails
> ip -6 addr add dead::1/128 dev eth0
> ip -6 route add default via dead::1/128
> -> succeeds
>
> reason is that if (nonsensensical) route above is added,
> dead::1 is still subject to DAD, so the route lookup will
> pick eth0 as outdev due to the prefix route that is added before
> DAD work is started.
>
> Add explicit test that checks if nexthop gateway is a local address.
>
> Link: https://bugzilla.redhat.com/show_bug.cgi?id=1167969
> Signed-off-by: Florian Westphal <fw@strlen.de>
Applied to net-next, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-05-22 3:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-20 22:25 [PATCH -next] ipv6: reject locally assigned nexthop addresses Florian Westphal
2015-05-20 23:55 ` Hannes Frederic Sowa
2015-05-22 3:24 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).