svn commit: r274306 - head/sys/net

Gleb Smirnoff glebius at FreeBSD.org
Sun Nov 9 11:11:10 UTC 2014


Author: glebius
Date: Sun Nov  9 11:11:08 2014
New Revision: 274306
URL: https://svnweb.freebsd.org/changeset/base/274306

Log:
  Use standard mtx(9), rwlock(9), sx(9) system initialization macros
  instead of doing initialization manually.
  
  Sponsored by:	Nginx, Inc.
  Sponsored by:	Netflix

Modified:
  head/sys/net/if.c
  head/sys/net/if_clone.c
  head/sys/net/if_clone.h
  head/sys/net/if_var.h

Modified: head/sys/net/if.c
==============================================================================
--- head/sys/net/if.c	Sun Nov  9 09:44:09 2014	(r274305)
+++ head/sys/net/if.c	Sun Nov  9 11:11:08 2014	(r274306)
@@ -159,7 +159,6 @@ static void	if_attachdomain(void *);
 static void	if_attachdomain1(struct ifnet *);
 static int	ifconf(u_long, caddr_t);
 static void	if_freemulti(struct ifmultiaddr *);
-static void	if_init(void *);
 static void	if_grow(void);
 static void	if_route(struct ifnet *, int flag, int fam);
 static int	if_setflag(struct ifnet *, int, int, int *, int);
@@ -207,7 +206,9 @@ VNET_DEFINE(struct ifnet **, ifindex_tab
  * inversions and deadlocks.
  */
 struct rwlock ifnet_rwlock;
+RW_SYSINIT_FLAGS(ifnet_rw, &ifnet_rwlock, "ifnet_rw", RW_RECURSE);
 struct sx ifnet_sxlock;
+SX_SYSINIT_FLAGS(ifnet_sx, &ifnet_sxlock, "ifnet_sx", SX_RECURSE);
 
 /*
  * The allocation of network interfaces is a rather non-atomic affair; we
@@ -364,17 +365,6 @@ vnet_if_init(const void *unused __unused
 VNET_SYSINIT(vnet_if_init, SI_SUB_INIT_IF, SI_ORDER_SECOND, vnet_if_init,
     NULL);
 
-/* ARGSUSED*/
-static void
-if_init(void *dummy __unused)
-{
-
-	IFNET_LOCK_INIT();
-	if_clone_init();
-}
-SYSINIT(interfaces, SI_SUB_INIT_IF, SI_ORDER_FIRST, if_init, NULL);
-
-
 #ifdef VIMAGE
 static void
 vnet_if_uninit(const void *unused __unused)

Modified: head/sys/net/if_clone.c
==============================================================================
--- head/sys/net/if_clone.c	Sun Nov  9 09:44:09 2014	(r274305)
+++ head/sys/net/if_clone.c	Sun Nov  9 11:11:08 2014	(r274306)
@@ -103,15 +103,14 @@ static int     ifc_simple_match(struct i
 static int     ifc_simple_create(struct if_clone *, char *, size_t, caddr_t);
 static int     ifc_simple_destroy(struct if_clone *, struct ifnet *);
 
-static struct mtx	if_cloners_mtx;
+static struct mtx if_cloners_mtx;
+MTX_SYSINIT(if_cloners_lock, &if_cloners_mtx, "if_cloners lock", MTX_DEF);
 static VNET_DEFINE(int, if_cloners_count);
 VNET_DEFINE(LIST_HEAD(, if_clone), if_cloners);
 
 #define	V_if_cloners_count	VNET(if_cloners_count)
 #define	V_if_cloners		VNET(if_cloners)
 
-#define IF_CLONERS_LOCK_INIT()		\
-    mtx_init(&if_cloners_mtx, "if_cloners lock", NULL, MTX_DEF)
 #define IF_CLONERS_LOCK_ASSERT()	mtx_assert(&if_cloners_mtx, MA_OWNED)
 #define IF_CLONERS_LOCK()		mtx_lock(&if_cloners_mtx)
 #define IF_CLONERS_UNLOCK()		mtx_unlock(&if_cloners_mtx)
@@ -169,13 +168,6 @@ vnet_if_clone_init(void)
 	LIST_INIT(&V_if_cloners);
 }
 
-void
-if_clone_init(void)
-{
-
-	IF_CLONERS_LOCK_INIT();
-}
-
 /*
  * Lookup and create a clone network interface.
  */

Modified: head/sys/net/if_clone.h
==============================================================================
--- head/sys/net/if_clone.h	Sun Nov  9 09:44:09 2014	(r274305)
+++ head/sys/net/if_clone.h	Sun Nov  9 11:11:08 2014	(r274306)
@@ -65,7 +65,6 @@ EVENTHANDLER_DECLARE(if_clone_event, if_
 #endif
 
 /* The below interfaces used only by net/if.c. */
-void	if_clone_init(void);
 void	vnet_if_clone_init(void);
 int	if_clone_create(char *, size_t, caddr_t);
 int	if_clone_destroy(const char *);

Modified: head/sys/net/if_var.h
==============================================================================
--- head/sys/net/if_var.h	Sun Nov  9 09:44:09 2014	(r274305)
+++ head/sys/net/if_var.h	Sun Nov  9 11:11:08 2014	(r274306)
@@ -421,11 +421,6 @@ struct ifmultiaddr {
 extern	struct rwlock ifnet_rwlock;
 extern	struct sx ifnet_sxlock;
 
-#define	IFNET_LOCK_INIT() do {						\
-	rw_init_flags(&ifnet_rwlock, "ifnet_rw",  RW_RECURSE);		\
-	sx_init_flags(&ifnet_sxlock, "ifnet_sx",  SX_RECURSE);		\
-} while(0)
-
 #define	IFNET_WLOCK() do {						\
 	sx_xlock(&ifnet_sxlock);					\
 	rw_wlock(&ifnet_rwlock);					\


More information about the svn-src-head mailing list