summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorzec <zec@FreeBSD.org>2009-04-06 22:29:41 +0000
committerzec <zec@FreeBSD.org>2009-04-06 22:29:41 +0000
commitc85551e0bc714ce0e1634c2d308b1616c8dd88ca (patch)
tree1b479c98f577a974d301743e3161bc32e49c0e64 /sys/net/if.c
parentf28ea657e983e90686b8309747fd1c6ad718135c (diff)
downloadFreeBSD-src-c85551e0bc714ce0e1634c2d308b1616c8dd88ca.zip
FreeBSD-src-c85551e0bc714ce0e1634c2d308b1616c8dd88ca.tar.gz
First pass at separating per-vnet initializer functions
from existing functions for initializing global state. At this stage, the new per-vnet initializer functions are directly called from the existing global initialization code, which should in most cases result in compiler inlining those new functions, hence yielding a near-zero functional change. Modify the existing initializer functions which are invoked via protosw, like ip_init() et. al., to allow them to be invoked multiple times, i.e. per each vnet. Global state, if any, is initialized only if such functions are called within the context of vnet0, which will be determined via the IS_DEFAULT_VNET(curvnet) check (currently always true). While here, V_irtualize a few remaining global UMA zones used by net/netinet/netipsec networking code. While it is not yet clear to me or anybody else whether this is the right thing to do, at this stage this makes the code more readable, and makes it easier to track uncollected UMA-zone-backed objects on vnet removal. In the long run, it's quite possible that some form of shared use of UMA zone pools among multiple vnets should be considered. Bump __FreeBSD_version due to changes in layout of structs vnet_ipfw, vnet_inet and vnet_net. Approved by: julian (mentor)
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index d9af711..20627d3 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -150,6 +150,8 @@ static int if_getgroupmembers(struct ifgroupreq *);
extern void nd6_setmtu(struct ifnet *);
#endif
+static int vnet_net_iattach(const void *);
+
#ifdef VIMAGE_GLOBALS
struct ifnethead ifnet; /* depend on static init XXX */
struct ifgrouphead ifg_head;
@@ -391,24 +393,33 @@ filt_netdev(struct knote *kn, long hint)
static void
if_init(void *dummy __unused)
{
- INIT_VNET_NET(curvnet);
#ifndef VIMAGE_GLOBALS
vnet_mod_register(&vnet_net_modinfo);
#endif
+ vnet_net_iattach(NULL);
+
+ IFNET_LOCK_INIT();
+ ifdev_setbyindex(0, make_dev(&net_cdevsw, 0, UID_ROOT, GID_WHEEL,
+ 0600, "network"));
+ if_clone_init();
+}
+
+static int
+vnet_net_iattach(const void *unused __unused)
+{
+ INIT_VNET_NET(curvnet);
V_if_index = 0;
V_ifindex_table = NULL;
V_if_indexlim = 8;
- IFNET_LOCK_INIT();
TAILQ_INIT(&V_ifnet);
TAILQ_INIT(&V_ifg_head);
knlist_init(&V_ifklist, NULL, NULL, NULL, NULL);
if_grow(); /* create initial table */
- ifdev_setbyindex(0, make_dev(&net_cdevsw, 0, UID_ROOT, GID_WHEEL,
- 0600, "network"));
- if_clone_init();
+
+ return (0);
}
static void
OpenPOWER on IntegriCloud