In if_purgeaddrs() we cannot hold the lock over the entire loop

due to called functions (as in other parts of the stack, leave a comment).
Put around a lock the removal of the ifa from the list however to
reduce the possible race with other places.

Obtained from:	projects/vnet
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
bz 2016-06-06 13:17:25 +00:00
parent 25cd3a2011
commit 28309d8186

View File

@ -848,6 +848,7 @@ if_purgeaddrs(struct ifnet *ifp)
{
struct ifaddr *ifa, *next;
/* XXX cannot hold IF_ADDR_WLOCK over called functions. */
TAILQ_FOREACH_SAFE(ifa, &ifp->if_addrhead, ifa_link, next) {
if (ifa->ifa_addr->sa_family == AF_LINK)
continue;
@ -872,7 +873,9 @@ if_purgeaddrs(struct ifnet *ifp)
continue;
}
#endif /* INET6 */
IF_ADDR_WLOCK(ifp);
TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
IF_ADDR_WUNLOCK(ifp);
ifa_free(ifa);
}
}