netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net/ipv6: Fix updates to prefix route
@ 2018-06-28 20:36 dsahern
  2018-06-30 11:54 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: dsahern @ 2018-06-28 20:36 UTC (permalink / raw)
  To: netdev; +Cc: sowmini.varadhan, David Ahern

From: David Ahern <dsahern@gmail.com>

Sowmini reported that a recent commit broke prefix routes for linklocal
addresses. The newly added modify_prefix_route is attempting to add a
new prefix route when the ifp priority does not match the route metric
however the check needs to account for the default priority. In addition,
the route add fails because the route already exists, and then the delete
removes the one that exists. Flip the order to do the delete first.

Fixes: 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
Reported-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Tested-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
---
 net/ipv6/addrconf.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index c134286d6a41..91580c62bb86 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4528,6 +4528,7 @@ static int modify_prefix_route(struct inet6_ifaddr *ifp,
 			       unsigned long expires, u32 flags)
 {
 	struct fib6_info *f6i;
+	u32 prio;
 
 	f6i = addrconf_get_prefix_route(&ifp->addr,
 					ifp->prefix_len,
@@ -4536,13 +4537,15 @@ static int modify_prefix_route(struct inet6_ifaddr *ifp,
 	if (!f6i)
 		return -ENOENT;
 
-	if (f6i->fib6_metric != ifp->rt_priority) {
+	prio = ifp->rt_priority ? : IP6_RT_PRIO_ADDRCONF;
+	if (f6i->fib6_metric != prio) {
+		/* delete old one */
+		ip6_del_rt(dev_net(ifp->idev->dev), f6i);
+
 		/* add new one */
 		addrconf_prefix_route(&ifp->addr, ifp->prefix_len,
 				      ifp->rt_priority, ifp->idev->dev,
 				      expires, flags, GFP_KERNEL);
-		/* delete old one */
-		ip6_del_rt(dev_net(ifp->idev->dev), f6i);
 	} else {
 		if (!expires)
 			fib6_clean_expires(f6i);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net/ipv6: Fix updates to prefix route
  2018-06-28 20:36 [PATCH net] net/ipv6: Fix updates to prefix route dsahern
@ 2018-06-30 11:54 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-06-30 11:54 UTC (permalink / raw)
  To: dsahern; +Cc: netdev, sowmini.varadhan, dsahern

From: dsahern@kernel.org
Date: Thu, 28 Jun 2018 13:36:55 -0700

> From: David Ahern <dsahern@gmail.com>
> 
> Sowmini reported that a recent commit broke prefix routes for linklocal
> addresses. The newly added modify_prefix_route is attempting to add a
> new prefix route when the ifp priority does not match the route metric
> however the check needs to account for the default priority. In addition,
> the route add fails because the route already exists, and then the delete
> removes the one that exists. Flip the order to do the delete first.
> 
> Fixes: 8308f3ff1753 ("net/ipv6: Add support for specifying metric of connected routes")
> Reported-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
> Tested-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
> Signed-off-by: David Ahern <dsahern@gmail.com>

Applied, thanks David.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-30 11:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-28 20:36 [PATCH net] net/ipv6: Fix updates to prefix route dsahern
2018-06-30 11:54 ` 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).