svn commit: r229614 - head/sys/net

John Baldwin jhb at FreeBSD.org
Thu Jan 5 18:35:49 UTC 2012


Author: jhb
Date: Thu Jan  5 18:35:49 2012
New Revision: 229614
URL: http://svn.freebsd.org/changeset/base/229614

Log:
  Add new variants of the IF_ADDR_*LOCK*() macros used for protecting
  interface address lists that distinguish read locks from write locks.
  To preserve the KPI, the previous operations are mapped to the write
  lock macros.  The lock is still kept as a mutex for now.
  
  Reviewed by:	bz
  MFC after:	2 weeks

Modified:
  head/sys/net/if_var.h

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h	Thu Jan  5 18:32:37 2012	(r229613)
+++ head/sys/net/if_var.h	Thu Jan  5 18:35:49 2012	(r229614)
@@ -249,9 +249,15 @@ typedef void if_init_f_t(void *);
 #define	IF_ADDR_LOCK_INIT(if)	mtx_init(&(if)->if_addr_mtx,		\
 				    "if_addr_mtx", NULL, MTX_DEF)
 #define	IF_ADDR_LOCK_DESTROY(if)	mtx_destroy(&(if)->if_addr_mtx)
-#define	IF_ADDR_LOCK(if)	mtx_lock(&(if)->if_addr_mtx)
-#define	IF_ADDR_UNLOCK(if)	mtx_unlock(&(if)->if_addr_mtx)
+#define	IF_ADDR_WLOCK(if)	mtx_lock(&(if)->if_addr_mtx)
+#define	IF_ADDR_WUNLOCK(if)	mtx_unlock(&(if)->if_addr_mtx)
+#define	IF_ADDR_RLOCK(if)	mtx_lock(&(if)->if_addr_mtx)
+#define	IF_ADDR_RUNLOCK(if)	mtx_unlock(&(if)->if_addr_mtx)
 #define	IF_ADDR_LOCK_ASSERT(if)	mtx_assert(&(if)->if_addr_mtx, MA_OWNED)
+#define	IF_ADDR_WLOCK_ASSERT(if)	mtx_assert(&(if)->if_addr_mtx, MA_OWNED)
+/* XXX: Compat. */
+#define	IF_ADDR_LOCK(if)	IF_ADDR_WLOCK(if)
+#define	IF_ADDR_UNLOCK(if)	IF_ADDR_WUNLOCK(if)
 
 /*
  * Function variations on locking macros intended to be used by loadable


More information about the svn-src-all mailing list