Use standard mtx(9), rwlock(9), sx(9) system initialization macros

instead of doing initialization manually.

Sponsored by:	Nginx, Inc.
Sponsored by:	Netflix
This commit is contained in:
Gleb Smirnoff 2014-11-09 11:11:08 +00:00
parent 42350b6bde
commit 4ea05db88e
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=274306
4 changed files with 4 additions and 28 deletions

View 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)

View 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.
*/

View 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 *);

View 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); \