Skip to content

Commit e7c7faa

Browse files
dsaherndavem330
authored andcommitted
net/ipv6: Fix updates to prefix route
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: 8308f3f ("net/ipv6: Add support for specifying metric of connected routes") Reported-by: Sowmini Varadhan <[email protected]> Tested-by: Sowmini Varadhan <[email protected]> Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d14b56f commit e7c7faa

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

net/ipv6/addrconf.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,6 +4528,7 @@ static int modify_prefix_route(struct inet6_ifaddr *ifp,
45284528
unsigned long expires, u32 flags)
45294529
{
45304530
struct fib6_info *f6i;
4531+
u32 prio;
45314532

45324533
f6i = addrconf_get_prefix_route(&ifp->addr,
45334534
ifp->prefix_len,
@@ -4536,13 +4537,15 @@ static int modify_prefix_route(struct inet6_ifaddr *ifp,
45364537
if (!f6i)
45374538
return -ENOENT;
45384539

4539-
if (f6i->fib6_metric != ifp->rt_priority) {
4540+
prio = ifp->rt_priority ? : IP6_RT_PRIO_ADDRCONF;
4541+
if (f6i->fib6_metric != prio) {
4542+
/* delete old one */
4543+
ip6_del_rt(dev_net(ifp->idev->dev), f6i);
4544+
45404545
/* add new one */
45414546
addrconf_prefix_route(&ifp->addr, ifp->prefix_len,
45424547
ifp->rt_priority, ifp->idev->dev,
45434548
expires, flags, GFP_KERNEL);
4544-
/* delete old one */
4545-
ip6_del_rt(dev_net(ifp->idev->dev), f6i);
45464549
} else {
45474550
if (!expires)
45484551
fib6_clean_expires(f6i);

0 commit comments

Comments
 (0)