]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Use standard mtx(9), rwlock(9), sx(9) system initialization macros
authorglebius <glebius@FreeBSD.org>
Sun, 9 Nov 2014 11:11:08 +0000 (11:11 +0000)
committerglebius <glebius@FreeBSD.org>
Sun, 9 Nov 2014 11:11:08 +0000 (11:11 +0000)
instead of doing initialization manually.

Sponsored by: Nginx, Inc.
Sponsored by: Netflix

sys/net/if.c
sys/net/if_clone.c
sys/net/if_clone.h
sys/net/if_var.h

index 1d3e3233e886f8a051aed3a66b188ffbef7bf84c..0103c3fdd5c4565d4dcc3c3623d7b89bd316e278 100644 (file)
@@ -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_table);
  * 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)
index abbda41199d717b1b84eaa3515cd158e7dea664a..09f8d2a613bfcc6a12ddb0a8a0270a9a54cc9c5f 100644 (file)
@@ -103,15 +103,14 @@ static int     ifc_simple_match(struct if_clone *, const char *);
 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.
  */
index 90d9b7b18a15eecfe1f600eb400b4bd5cbda310b..67ec8046dffc202e253065537e1415bf62888433 100644 (file)
@@ -65,7 +65,6 @@ EVENTHANDLER_DECLARE(if_clone_event, if_clone_event_handler_t);
 #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 *);
index 049d3b043e0aad0699b78288536e37c4f2d9e54e..643a1a489a57926195d9d2b5a5b401962d2c7c4d 100644 (file)
@@ -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);                                        \