summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authorglebius <glebius@FreeBSD.org>2014-11-09 11:11:08 +0000
committerglebius <glebius@FreeBSD.org>2014-11-09 11:11:08 +0000
commit83e84205ec887b0e6deeded16265050f3237bd1f (patch)
tree83198ad2c3500fdb72f1d2a0defc8a2716f6cfce /sys/net
parent0d7beefb910ec2b91d59cdbd90c0073e466f36c4 (diff)
downloadFreeBSD-src-83e84205ec887b0e6deeded16265050f3237bd1f.zip
FreeBSD-src-83e84205ec887b0e6deeded16265050f3237bd1f.tar.gz
Use standard mtx(9), rwlock(9), sx(9) system initialization macros
instead of doing initialization manually. Sponsored by: Nginx, Inc. Sponsored by: Netflix
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if.c14
-rw-r--r--sys/net/if_clone.c12
-rw-r--r--sys/net/if_clone.h1
-rw-r--r--sys/net/if_var.h5
4 files changed, 4 insertions, 28 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 1d3e323..0103c3f 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -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)
diff --git a/sys/net/if_clone.c b/sys/net/if_clone.c
index abbda41..09f8d2a 100644
--- a/sys/net/if_clone.c
+++ b/sys/net/if_clone.c
@@ -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.
*/
diff --git a/sys/net/if_clone.h b/sys/net/if_clone.h
index 90d9b7b..67ec804 100644
--- a/sys/net/if_clone.h
+++ b/sys/net/if_clone.h
@@ -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 *);
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
index 049d3b0..643a1a4 100644
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -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); \
OpenPOWER on IntegriCloud