Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jun 2016 13:17:25 +0000 (UTC)
From:      "Bjoern A. Zeeb" <bz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r301505 - head/sys/net
Message-ID:  <201606061317.u56DHPXd040681@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: bz
Date: Mon Jun  6 13:17:25 2016
New Revision: 301505
URL: https://svnweb.freebsd.org/changeset/base/301505

Log:
  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

Modified:
  head/sys/net/if.c

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Mon Jun  6 13:04:22 2016	(r301504)
+++ head/sys/net/if.c	Mon Jun  6 13:17:25 2016	(r301505)
@@ -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);
 	}
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606061317.u56DHPXd040681>