Commit 8ef802aa authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

ipv6: prepare RCU lookups for idev->addr_list

inet6_ifa_finish_destroy() already uses kfree_rcu() to free
inet6_ifaddr structs.

We need to use proper list additions/deletions in order
to allow readers to use RCU instead of idev->lock rwlock.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a4231778
...@@ -945,7 +945,7 @@ ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp) ...@@ -945,7 +945,7 @@ ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
break; break;
} }
list_add_tail(&ifp->if_list, p); list_add_tail_rcu(&ifp->if_list, p);
} }
static u32 inet6_addr_hash(const struct in6_addr *addr) static u32 inet6_addr_hash(const struct in6_addr *addr)
...@@ -1204,7 +1204,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp) ...@@ -1204,7 +1204,7 @@ static void ipv6_del_addr(struct inet6_ifaddr *ifp)
if (ifp->flags & IFA_F_PERMANENT && !(ifp->flags & IFA_F_NOPREFIXROUTE)) if (ifp->flags & IFA_F_PERMANENT && !(ifp->flags & IFA_F_NOPREFIXROUTE))
action = check_cleanup_prefix_route(ifp, &expires); action = check_cleanup_prefix_route(ifp, &expires);
list_del_init(&ifp->if_list); list_del_rcu(&ifp->if_list);
__in6_ifa_put(ifp); __in6_ifa_put(ifp);
write_unlock_bh(&ifp->idev->lock); write_unlock_bh(&ifp->idev->lock);
...@@ -3562,7 +3562,6 @@ static int addrconf_ifdown(struct net_device *dev, int how) ...@@ -3562,7 +3562,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
struct inet6_dev *idev; struct inet6_dev *idev;
struct inet6_ifaddr *ifa, *tmp; struct inet6_ifaddr *ifa, *tmp;
struct list_head del_list;
int _keep_addr; int _keep_addr;
bool keep_addr; bool keep_addr;
int state, i; int state, i;
...@@ -3654,7 +3653,6 @@ static int addrconf_ifdown(struct net_device *dev, int how) ...@@ -3654,7 +3653,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
*/ */
keep_addr = (!how && _keep_addr > 0 && !idev->cnf.disable_ipv6); keep_addr = (!how && _keep_addr > 0 && !idev->cnf.disable_ipv6);
INIT_LIST_HEAD(&del_list);
list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) { list_for_each_entry_safe(ifa, tmp, &idev->addr_list, if_list) {
struct rt6_info *rt = NULL; struct rt6_info *rt = NULL;
bool keep; bool keep;
...@@ -3663,8 +3661,6 @@ static int addrconf_ifdown(struct net_device *dev, int how) ...@@ -3663,8 +3661,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
keep = keep_addr && (ifa->flags & IFA_F_PERMANENT) && keep = keep_addr && (ifa->flags & IFA_F_PERMANENT) &&
!addr_is_local(&ifa->addr); !addr_is_local(&ifa->addr);
if (!keep)
list_move(&ifa->if_list, &del_list);
write_unlock_bh(&idev->lock); write_unlock_bh(&idev->lock);
spin_lock_bh(&ifa->lock); spin_lock_bh(&ifa->lock);
...@@ -3698,19 +3694,14 @@ static int addrconf_ifdown(struct net_device *dev, int how) ...@@ -3698,19 +3694,14 @@ static int addrconf_ifdown(struct net_device *dev, int how)
} }
write_lock_bh(&idev->lock); write_lock_bh(&idev->lock);
if (!keep) {
list_del_rcu(&ifa->if_list);
in6_ifa_put(ifa);
}
} }
write_unlock_bh(&idev->lock); write_unlock_bh(&idev->lock);
/* now clean up addresses to be removed */
while (!list_empty(&del_list)) {
ifa = list_first_entry(&del_list,
struct inet6_ifaddr, if_list);
list_del(&ifa->if_list);
in6_ifa_put(ifa);
}
/* Step 5: Discard anycast and multicast list */ /* Step 5: Discard anycast and multicast list */
if (how) { if (how) {
ipv6_ac_destroy_dev(idev); ipv6_ac_destroy_dev(idev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment