Skip to content

Commit 6179401

Browse files
liuhangbindavem330
authored andcommitted
net/ipv6: need update peer route when modify metric
When we modify the route metric, the peer address's route need also be updated. Before the fix: + ip addr add dev dummy1 2001:db8::1 peer 2001:db8::2 metric 60 + ip -6 route show dev dummy1 2001:db8::1 proto kernel metric 60 pref medium 2001:db8::2 proto kernel metric 60 pref medium + ip addr change dev dummy1 2001:db8::1 peer 2001:db8::2 metric 61 + ip -6 route show dev dummy1 2001:db8::1 proto kernel metric 61 pref medium 2001:db8::2 proto kernel metric 60 pref medium After the fix: + ip addr change dev dummy1 2001:db8::1 peer 2001:db8::2 metric 61 + ip -6 route show dev dummy1 2001:db8::1 proto kernel metric 61 pref medium 2001:db8::2 proto kernel metric 61 pref medium Fixes: 8308f3f ("net/ipv6: Add support for specifying metric of connected routes") Signed-off-by: Hangbin Liu <[email protected]> Reviewed-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a6fbcdd commit 6179401

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

net/ipv6/addrconf.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4586,12 +4586,14 @@ inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh,
45864586
}
45874587

45884588
static int modify_prefix_route(struct inet6_ifaddr *ifp,
4589-
unsigned long expires, u32 flags)
4589+
unsigned long expires, u32 flags,
4590+
bool modify_peer)
45904591
{
45914592
struct fib6_info *f6i;
45924593
u32 prio;
45934594

4594-
f6i = addrconf_get_prefix_route(&ifp->addr, ifp->prefix_len,
4595+
f6i = addrconf_get_prefix_route(modify_peer ? &ifp->peer_addr : &ifp->addr,
4596+
ifp->prefix_len,
45954597
ifp->idev->dev, 0, RTF_DEFAULT, true);
45964598
if (!f6i)
45974599
return -ENOENT;
@@ -4602,7 +4604,8 @@ static int modify_prefix_route(struct inet6_ifaddr *ifp,
46024604
ip6_del_rt(dev_net(ifp->idev->dev), f6i);
46034605

46044606
/* add new one */
4605-
addrconf_prefix_route(&ifp->addr, ifp->prefix_len,
4607+
addrconf_prefix_route(modify_peer ? &ifp->peer_addr : &ifp->addr,
4608+
ifp->prefix_len,
46064609
ifp->rt_priority, ifp->idev->dev,
46074610
expires, flags, GFP_KERNEL);
46084611
} else {
@@ -4678,14 +4681,23 @@ static int inet6_addr_modify(struct inet6_ifaddr *ifp, struct ifa6_config *cfg)
46784681
int rc = -ENOENT;
46794682

46804683
if (had_prefixroute)
4681-
rc = modify_prefix_route(ifp, expires, flags);
4684+
rc = modify_prefix_route(ifp, expires, flags, false);
46824685

46834686
/* prefix route could have been deleted; if so restore it */
46844687
if (rc == -ENOENT) {
46854688
addrconf_prefix_route(&ifp->addr, ifp->prefix_len,
46864689
ifp->rt_priority, ifp->idev->dev,
46874690
expires, flags, GFP_KERNEL);
46884691
}
4692+
4693+
if (had_prefixroute && !ipv6_addr_any(&ifp->peer_addr))
4694+
rc = modify_prefix_route(ifp, expires, flags, true);
4695+
4696+
if (rc == -ENOENT && !ipv6_addr_any(&ifp->peer_addr)) {
4697+
addrconf_prefix_route(&ifp->peer_addr, ifp->prefix_len,
4698+
ifp->rt_priority, ifp->idev->dev,
4699+
expires, flags, GFP_KERNEL);
4700+
}
46894701
} else if (had_prefixroute) {
46904702
enum cleanup_prefix_rt_t action;
46914703
unsigned long rt_expires;

0 commit comments

Comments
 (0)