Skip to content

Commit 6046d5b

Browse files
hkallweitdavem330
authored andcommitted
ipv6: support IFA_F_MANAGETEMPADDR for address deletion too
Userspace applications can use IFA_F_MANAGETEMPADDR with RTM_NEWADDR already to indicate that the kernel should take care of temporary address management. This patch adds related functionality to RTM_DELADDR. By setting IFA_F_MANAGETEMPADDR a userspace application can indicate that the kernel should delete all related temporary addresses as well. A corresponding patch for the "ip addr del" command has been applied to iproute2 already. Signed-off-by: Heiner Kallweit <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Acked-by: Hannes Frederic Sowa <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 0080d4f commit 6046d5b

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
@@ -2504,8 +2504,8 @@ static int inet6_addr_add(struct net *net, int ifindex,
25042504
return PTR_ERR(ifp);
25052505
}
25062506

2507-
static int inet6_addr_del(struct net *net, int ifindex, const struct in6_addr *pfx,
2508-
unsigned int plen)
2507+
static int inet6_addr_del(struct net *net, int ifindex, u32 ifa_flags,
2508+
const struct in6_addr *pfx, unsigned int plen)
25092509
{
25102510
struct inet6_ifaddr *ifp;
25112511
struct inet6_dev *idev;
@@ -2528,7 +2528,12 @@ static int inet6_addr_del(struct net *net, int ifindex, const struct in6_addr *p
25282528
in6_ifa_hold(ifp);
25292529
read_unlock_bh(&idev->lock);
25302530

2531+
if (!(ifp->flags & IFA_F_TEMPORARY) &&
2532+
(ifa_flags & IFA_F_MANAGETEMPADDR))
2533+
manage_tempaddrs(idev, ifp, 0, 0, false,
2534+
jiffies);
25312535
ipv6_del_addr(ifp);
2536+
addrconf_verify_rtnl();
25322537
return 0;
25332538
}
25342539
}
@@ -2568,7 +2573,7 @@ int addrconf_del_ifaddr(struct net *net, void __user *arg)
25682573
return -EFAULT;
25692574

25702575
rtnl_lock();
2571-
err = inet6_addr_del(net, ireq.ifr6_ifindex, &ireq.ifr6_addr,
2576+
err = inet6_addr_del(net, ireq.ifr6_ifindex, 0, &ireq.ifr6_addr,
25722577
ireq.ifr6_prefixlen);
25732578
rtnl_unlock();
25742579
return err;
@@ -3743,6 +3748,7 @@ inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh)
37433748
struct ifaddrmsg *ifm;
37443749
struct nlattr *tb[IFA_MAX+1];
37453750
struct in6_addr *pfx, *peer_pfx;
3751+
u32 ifa_flags;
37463752
int err;
37473753

37483754
err = nlmsg_parse(nlh, sizeof(*ifm), tb, IFA_MAX, ifa_ipv6_policy);
@@ -3754,7 +3760,13 @@ inet6_rtm_deladdr(struct sk_buff *skb, struct nlmsghdr *nlh)
37543760
if (pfx == NULL)
37553761
return -EINVAL;
37563762

3757-
return inet6_addr_del(net, ifm->ifa_index, pfx, ifm->ifa_prefixlen);
3763+
ifa_flags = tb[IFA_FLAGS] ? nla_get_u32(tb[IFA_FLAGS]) : ifm->ifa_flags;
3764+
3765+
/* We ignore other flags so far. */
3766+
ifa_flags &= IFA_F_MANAGETEMPADDR;
3767+
3768+
return inet6_addr_del(net, ifm->ifa_index, ifa_flags, pfx,
3769+
ifm->ifa_prefixlen);
37583770
}
37593771

37603772
static int inet6_addr_modify(struct inet6_ifaddr *ifp, u32 ifa_flags,

0 commit comments

Comments
 (0)