diff options
author | zec <zec@FreeBSD.org> | 2008-11-19 09:39:34 +0000 |
---|---|---|
committer | zec <zec@FreeBSD.org> | 2008-11-19 09:39:34 +0000 |
commit | 815d52c5df6a76286604478e5223d2f2c87b2c04 (patch) | |
tree | 3d398563f1e14b804a0558dd3dda1de9a42b9970 /sys/net/if.c | |
parent | 881f5acc93790d49318ffde65d52c6f45ca9c1f8 (diff) | |
download | FreeBSD-src-815d52c5df6a76286604478e5223d2f2c87b2c04.zip FreeBSD-src-815d52c5df6a76286604478e5223d2f2c87b2c04.tar.gz |
Change the initialization methodology for global variables scheduled
for virtualization.
Instead of initializing the affected global variables at instatiation,
assign initial values to them in initializer functions. As a rule,
initialization at instatiation for such variables should never be
introduced again from now on. Furthermore, enclose all instantiations
of such global variables in #ifdef VIMAGE_GLOBALS blocks.
Essentialy, this change should have zero functional impact. In the next
phase of merging network stack virtualization infrastructure from
p4/vimage branch, the new initialization methology will allow us to
switch between using global variables and their counterparts residing in
virtualization containers with minimum code churn, and in the long run
allow us to intialize multiple instances of such container structures.
Discussed at: devsummit Strassburg
Reviewed by: bz, julian
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index eb428ff..f44262c 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -134,22 +134,21 @@ static int if_getgroupmembers(struct ifgroupreq *); extern void nd6_setmtu(struct ifnet *); #endif -int if_index = 0; -int ifqmaxlen = IFQ_MAXLEN; +#ifdef VIMAGE_GLOBALS struct ifnethead ifnet; /* depend on static init XXX */ struct ifgrouphead ifg_head; +int if_index; +static int if_indexlim; +/* Table of ifnet/cdev by index. Locked with ifnet_lock. */ +static struct ifindex_entry *ifindex_table; +static struct knlist ifklist; +#endif + +int ifqmaxlen = IFQ_MAXLEN; struct mtx ifnet_lock; static if_com_alloc_t *if_com_alloc[256]; static if_com_free_t *if_com_free[256]; -static int if_indexlim = 8; -static struct knlist ifklist; - -/* - * Table of ifnet/cdev by index. Locked with ifnet_lock. - */ -static struct ifindex_entry *ifindex_table = NULL; - static void filt_netdetach(struct knote *kn); static int filt_netdev(struct knote *kn, long hint); @@ -357,6 +356,10 @@ if_init(void *dummy __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); |