11543Srgrimes/*-
21543Srgrimes * Copyright (c) 2006-2009 University of Zagreb
31543Srgrimes * Copyright (c) 2006-2009 FreeBSD Foundation
41543Srgrimes * All rights reserved.
51543Srgrimes *
61543Srgrimes * This software was developed by the University of Zagreb and the
71543Srgrimes * FreeBSD Foundation under sponsorship by the Stichting NLnet and the
81543Srgrimes * FreeBSD Foundation.
91543Srgrimes *
101543Srgrimes * Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org>
111543Srgrimes * Copyright (c) 2009 Robert N. M. Watson
121543Srgrimes * All rights reserved.
131543Srgrimes *
141543Srgrimes * Redistribution and use in source and binary forms, with or without
151543Srgrimes * modification, are permitted provided that the following conditions
161543Srgrimes * are met:
171543Srgrimes * 1. Redistributions of source code must retain the above copyright
181543Srgrimes *    notice, this list of conditions and the following disclaimer.
191543Srgrimes * 2. Redistributions in binary form must reproduce the above copyright
201543Srgrimes *    notice, this list of conditions and the following disclaimer in the
211543Srgrimes *    documentation and/or other materials provided with the distribution.
221543Srgrimes *
231543Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
241543Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
251543Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
261543Srgrimes * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
271543Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
281543Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
291543Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
301543Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
311543Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
321543Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
331543Srgrimes * SUCH DAMAGE.
3450477Speter *
351543Srgrimes * $FreeBSD$
361543Srgrimes */
3713107Sbde
3813107Sbde/*-
392166Spaul * This header file defines several sets of interfaces supporting virtualized
4055205Speter * network stacks:
4137542Sbde *
4213157Sbde * - Definition of 'struct vnet' and functions and macros to allocate/free/
4322639Sbde *   manipulate it.
4422639Sbde *
4522639Sbde * - A virtual network stack memory allocator, which provides support for
4622639Sbde *   virtualized global variables via a special linker set, set_vnet.
4722639Sbde *
4822639Sbde * - Virtualized sysinits/sysuninits, which allow constructors and
4913157Sbde *   destructors to be run for each network stack subsystem as virtual
5013157Sbde *   instances are created and destroyed.
5113157Sbde *
5213157Sbde * If VIMAGE isn't compiled into the kernel, virtualized global variables
5313157Sbde * compile to normal global variables, and virtualized sysinits to regular
5413157Sbde * sysinits.
551543Srgrimes */
5617879Sbde
5717879Sbde#ifndef _NET_VNET_H_
5817879Sbde#define	_NET_VNET_H_
5922639Sbde
6017879Sbde/*
6117879Sbde * struct vnet describes a virtualized network stack, and is primarily a
6217879Sbde * pointer to storage for virtualized global variables.  Expose to userspace
6337629Sbde * as required for libkvm.
6417879Sbde */
6517879Sbde#if defined(_KERNEL) || defined(_WANT_VNET)
6628921Sfsmp#include <sys/queue.h>
6790024Sbde
68114349Speterstruct vnet {
6979734Sjhb	LIST_ENTRY(vnet)	 vnet_le;	/* all vnets list */
7078908Sjhb	u_int			 vnet_magic_n;
7178908Sjhb	u_int			 vnet_ifcnt;
72114349Speter	u_int			 vnet_sockcnt;
7328921Sfsmp	void			*vnet_data_mem;
74114349Speter	uintptr_t		 vnet_data_base;
75114349Speter};
7628921Sfsmp#define	VNET_MAGIC_N	0x3e0d8f29
7717879Sbde
7817879Sbde/*
7955205Speter * These two virtual network stack allocator definitions are also required
8013157Sbde * for libkvm so that it can evaluate virtualized global variables.
8122639Sbde */
8222639Sbde#define	VNET_SETNAME		"set_vnet"
8313157Sbde#define	VNET_SYMPREFIX		"vnet_entry_"
8413157Sbde#endif
8595195Smarkm
8695195Smarkm#ifdef _KERNEL
8795195Smarkm
8895195Smarkm#define	VNET_PCPUSTAT_DECLARE(type, name)	\
8995195Smarkm    VNET_DECLARE(counter_u64_t, name[sizeof(type) / sizeof(uint64_t)])
9095195Smarkm
9195195Smarkm#define	VNET_PCPUSTAT_DEFINE(type, name)	\
9295195Smarkm    VNET_DEFINE(counter_u64_t, name[sizeof(type) / sizeof(uint64_t)])
9395195Smarkm
9495195Smarkm#define	VNET_PCPUSTAT_ALLOC(name, wait)	\
9595195Smarkm    COUNTER_ARRAY_ALLOC(VNET(name), \
9695195Smarkm	sizeof(VNET(name)) / sizeof(counter_u64_t), (wait))
97114349Speter
9895195Smarkm#define	VNET_PCPUSTAT_FREE(name)	\
9995195Smarkm    COUNTER_ARRAY_FREE(VNET(name), sizeof(VNET(name)) / sizeof(counter_u64_t))
10095195Smarkm
10195195Smarkm#define	VNET_PCPUSTAT_ADD(type, name, f, v)	\
10295195Smarkm    counter_u64_add(VNET(name)[offsetof(type, f) / sizeof(uint64_t)], (v))
10395195Smarkm
104114349Speter#define	VNET_PCPUSTAT_SYSINIT(name)	\
10595195Smarkmstatic void				\
10695195Smarkmvnet_##name##_init(const void *unused)	\
1071543Srgrimes{					\
10895195Smarkm	VNET_PCPUSTAT_ALLOC(name, M_WAITOK);	\
109103965Smarkm}					\
11095195SmarkmVNET_SYSINIT(vnet_ ## name ## _init, SI_SUB_PROTO_IFATTACHDOMAIN,	\
11195195Smarkm    SI_ORDER_ANY, vnet_ ## name ## _init, NULL)
11295195Smarkm
11395195Smarkm#define	VNET_PCPUSTAT_SYSUNINIT(name)					\
11495195Smarkmstatic void								\
11537542Sbdevnet_##name##_uninit(const void *unused)				\
116114349Speter{									\
11737542Sbde	VNET_PCPUSTAT_FREE(name);					\
11855205Speter}									\
1192166SpaulVNET_SYSUNINIT(vnet_ ## name ## _uninit, SI_SUB_PROTO_IFATTACHDOMAIN,	\
12013107Sbde    SI_ORDER_ANY, vnet_ ## name ## _uninit, NULL)
12113107Sbde
12213107Sbde#define	SYSCTL_VNET_PCPUSTAT(parent, nbr, name, type, array, desc)	\
12313107Sbdestatic int								\
12431723Steggearray##_sysctl(SYSCTL_HANDLER_ARGS)					\
12513107Sbde{									\
12655205Speter	type s;								\
12719000Sbde	CTASSERT((sizeof(type) / sizeof(uint64_t)) ==			\
12892761Salfred	    (sizeof(VNET(array)) / sizeof(counter_u64_t)));		\
12992761Salfred	COUNTER_ARRAY_COPY(VNET(array), &s, sizeof(type) / sizeof(uint64_t));\
13019000Sbde	if (req->newptr)						\
13119000Sbde		COUNTER_ARRAY_ZERO(VNET(array),				\
13219000Sbde		    sizeof(type) / sizeof(uint64_t));			\
13319000Sbde	return (SYSCTL_OUT(req, &s, sizeof(type)));			\
13492761Salfred}									\
13592761SalfredSYSCTL_VNET_PROC(parent, nbr, name, CTLTYPE_OPAQUE | CTLFLAG_RW, NULL,	\
13692761Salfred    0, array ## _sysctl, "I", desc)
13792761Salfred
13813157Sbde#ifdef VIMAGE
13919000Sbde#include <sys/lock.h>
14019000Sbde#include <sys/proc.h>			/* for struct thread */
14119000Sbde#include <sys/rwlock.h>
14219000Sbde#include <sys/sx.h>
14355205Speter
14419000Sbde/*
14519000Sbde * Location of the kernel's 'set_vnet' linker set.
14619000Sbde */
14719000Sbdeextern uintptr_t	*__start_set_vnet;
14833047Sbde__GLOBL(__start_set_vnet);
14992761Salfredextern uintptr_t	*__stop_set_vnet;
15033047Sbde__GLOBL(__stop_set_vnet);
15192761Salfred
15219000Sbde#define	VNET_START	(uintptr_t)&__start_set_vnet
15313157Sbde#define	VNET_STOP	(uintptr_t)&__stop_set_vnet
15455205Speter
15519000Sbde/*
15613157Sbde * Functions to allocate and destroy virtual network stacks.
15719000Sbde */
15819000Sbdestruct vnet *vnet_alloc(void);
15919000Sbdevoid	vnet_destroy(struct vnet *vnet);
16019000Sbde
16192761Salfred/*
16292761Salfred * The current virtual network stack -- we may wish to move this to struct
16392761Salfred * pcpu in the future.
16492761Salfred */
16592761Salfred#define	curvnet	curthread->td_vnet
16619000Sbde
16713157Sbde/*
16813107Sbde * Various macros -- get and set the current network stack, but also
16913157Sbde * assertions.
170 */
171#if defined(INVARIANTS) || defined(VNET_DEBUG)
172#define	VNET_ASSERT(exp, msg)	do {					\
173	if (!(exp))							\
174		panic msg;						\
175} while (0)
176#else
177#define	VNET_ASSERT(exp, msg)	do {					\
178} while (0)
179#endif
180
181#ifdef VNET_DEBUG
182void vnet_log_recursion(struct vnet *, const char *, int);
183
184#define	CURVNET_SET_QUIET(arg)						\
185	VNET_ASSERT((arg) != NULL && (arg)->vnet_magic_n == VNET_MAGIC_N, \
186	    ("CURVNET_SET at %s:%d %s() curvnet=%p vnet=%p",		\
187	    __FILE__, __LINE__, __func__, curvnet, (arg)));		\
188	struct vnet *saved_vnet = curvnet;				\
189	const char *saved_vnet_lpush = curthread->td_vnet_lpush;	\
190	curvnet = arg;							\
191	curthread->td_vnet_lpush = __func__;
192
193#define	CURVNET_SET_VERBOSE(arg)					\
194	CURVNET_SET_QUIET(arg)						\
195	if (saved_vnet)							\
196		vnet_log_recursion(saved_vnet, saved_vnet_lpush, __LINE__);
197
198#define	CURVNET_SET(arg)	CURVNET_SET_VERBOSE(arg)
199
200#define	CURVNET_RESTORE()						\
201	VNET_ASSERT(curvnet != NULL && (saved_vnet == NULL ||		\
202	    saved_vnet->vnet_magic_n == VNET_MAGIC_N),			\
203	    ("CURVNET_RESTORE at %s:%d %s() curvnet=%p saved_vnet=%p",	\
204	    __FILE__, __LINE__, __func__, curvnet, saved_vnet));	\
205	curvnet = saved_vnet;						\
206	curthread->td_vnet_lpush = saved_vnet_lpush;
207#else /* !VNET_DEBUG */
208
209#define	CURVNET_SET_QUIET(arg)						\
210	VNET_ASSERT((arg) != NULL && (arg)->vnet_magic_n == VNET_MAGIC_N, \
211	    ("CURVNET_SET at %s:%d %s() curvnet=%p vnet=%p",		\
212	    __FILE__, __LINE__, __func__, curvnet, (arg)));		\
213	struct vnet *saved_vnet = curvnet;				\
214	curvnet = arg;
215
216#define	CURVNET_SET_VERBOSE(arg)					\
217	CURVNET_SET_QUIET(arg)
218
219#define	CURVNET_SET(arg)	CURVNET_SET_VERBOSE(arg)
220
221#define	CURVNET_RESTORE()						\
222	VNET_ASSERT(curvnet != NULL && (saved_vnet == NULL ||		\
223	    saved_vnet->vnet_magic_n == VNET_MAGIC_N),			\
224	    ("CURVNET_RESTORE at %s:%d %s() curvnet=%p saved_vnet=%p",	\
225	    __FILE__, __LINE__, __func__, curvnet, saved_vnet));	\
226	curvnet = saved_vnet;
227#endif /* VNET_DEBUG */
228
229extern struct vnet *vnet0;
230#define	IS_DEFAULT_VNET(arg)	((arg) == vnet0)
231
232#define	CRED_TO_VNET(cr)	(cr)->cr_prison->pr_vnet
233#define	TD_TO_VNET(td)		CRED_TO_VNET((td)->td_ucred)
234#define	P_TO_VNET(p)		CRED_TO_VNET((p)->p_ucred)
235
236/*
237 * Global linked list of all virtual network stacks, along with read locks to
238 * access it.  If a caller may sleep while accessing the list, it must use
239 * the sleepable lock macros.
240 */
241LIST_HEAD(vnet_list_head, vnet);
242extern struct vnet_list_head vnet_head;
243extern struct rwlock vnet_rwlock;
244extern struct sx vnet_sxlock;
245
246#define	VNET_LIST_RLOCK()		sx_slock(&vnet_sxlock)
247#define	VNET_LIST_RLOCK_NOSLEEP()	rw_rlock(&vnet_rwlock)
248#define	VNET_LIST_RUNLOCK()		sx_sunlock(&vnet_sxlock)
249#define	VNET_LIST_RUNLOCK_NOSLEEP()	rw_runlock(&vnet_rwlock)
250
251/*
252 * Iteration macros to walk the global list of virtual network stacks.
253 */
254#define	VNET_ITERATOR_DECL(arg)	struct vnet *arg
255#define	VNET_FOREACH(arg)	LIST_FOREACH((arg), &vnet_head, vnet_le)
256
257/*
258 * Virtual network stack memory allocator, which allows global variables to
259 * be automatically instantiated for each network stack instance.
260 */
261#define	VNET_NAME(n)		vnet_entry_##n
262#define	VNET_DECLARE(t, n)	extern t VNET_NAME(n)
263#define	VNET_DEFINE(t, n)	t VNET_NAME(n) __section(VNET_SETNAME) __used
264#define	_VNET_PTR(b, n)		(__typeof(VNET_NAME(n))*)		\
265				    ((b) + (uintptr_t)&VNET_NAME(n))
266
267#define	_VNET(b, n)		(*_VNET_PTR(b, n))
268
269/*
270 * Virtualized global variable accessor macros.
271 */
272#define	VNET_VNET_PTR(vnet, n)		_VNET_PTR((vnet)->vnet_data_base, n)
273#define	VNET_VNET(vnet, n)		(*VNET_VNET_PTR((vnet), n))
274
275#define	VNET_PTR(n)		VNET_VNET_PTR(curvnet, n)
276#define	VNET(n)			VNET_VNET(curvnet, n)
277
278/*
279 * Virtual network stack allocator interfaces from the kernel linker.
280 */
281void	*vnet_data_alloc(int size);
282void	 vnet_data_copy(void *start, int size);
283void	 vnet_data_free(void *start_arg, int size);
284
285/*
286 * Sysctl variants for vnet-virtualized global variables.  Include
287 * <sys/sysctl.h> to expose these definitions.
288 *
289 * Note: SYSCTL_PROC() handler functions will need to resolve pointer
290 * arguments themselves, if required.
291 */
292#ifdef SYSCTL_OID
293#define	SYSCTL_VNET_INT(parent, nbr, name, access, ptr, val, descr)	\
294	SYSCTL_OID(parent, nbr, name,					\
295	    CTLTYPE_INT|CTLFLAG_MPSAFE|CTLFLAG_VNET|(access),		\
296	    ptr, val, sysctl_handle_int, "I", descr)
297#define	SYSCTL_VNET_PROC(parent, nbr, name, access, ptr, arg, handler,	\
298	    fmt, descr)							\
299	CTASSERT(((access) & CTLTYPE) != 0);				\
300	SYSCTL_OID(parent, nbr, name, CTLFLAG_VNET|(access), ptr, arg, 	\
301	    handler, fmt, descr)
302#define	SYSCTL_VNET_OPAQUE(parent, nbr, name, access, ptr, len, fmt,    \
303	    descr)							\
304	SYSCTL_OID(parent, nbr, name,					\
305	    CTLTYPE_OPAQUE|CTLFLAG_VNET|(access), ptr, len, 		\
306	    sysctl_handle_opaque, fmt, descr)
307#define	SYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr)	\
308	SYSCTL_OID(parent, nbr, name,					\
309	    CTLTYPE_STRING|CTLFLAG_VNET|(access),			\
310	    arg, len, sysctl_handle_string, "A", descr)
311#define	SYSCTL_VNET_STRUCT(parent, nbr, name, access, ptr, type, descr)	\
312	SYSCTL_OID(parent, nbr, name,					\
313	    CTLTYPE_OPAQUE|CTLFLAG_VNET|(access), ptr,			\
314	    sizeof(struct type), sysctl_handle_opaque, "S," #type,	\
315	    descr)
316#define	SYSCTL_VNET_UINT(parent, nbr, name, access, ptr, val, descr)	\
317	SYSCTL_OID(parent, nbr, name,					\
318	    CTLTYPE_UINT|CTLFLAG_MPSAFE|CTLFLAG_VNET|(access),		\
319	    ptr, val, sysctl_handle_int, "IU", descr)
320#define	VNET_SYSCTL_ARG(req, arg1) do {					\
321	if (arg1 != NULL)						\
322		arg1 = (void *)(TD_TO_VNET((req)->td)->vnet_data_base +	\
323		    (uintptr_t)(arg1));					\
324} while (0)
325#endif /* SYSCTL_OID */
326
327/*
328 * Virtual sysinit mechanism, allowing network stack components to declare
329 * startup and shutdown methods to be run when virtual network stack
330 * instances are created and destroyed.
331 */
332#include <sys/kernel.h>
333
334/*
335 * SYSINIT/SYSUNINIT variants that provide per-vnet constructors and
336 * destructors.
337 */
338struct vnet_sysinit {
339	enum sysinit_sub_id	subsystem;
340	enum sysinit_elem_order	order;
341	sysinit_cfunc_t		func;
342	const void		*arg;
343	TAILQ_ENTRY(vnet_sysinit) link;
344};
345
346#define	VNET_SYSINIT(ident, subsystem, order, func, arg)		\
347	static struct vnet_sysinit ident ## _vnet_init = {		\
348		subsystem,						\
349		order,							\
350		(sysinit_cfunc_t)(sysinit_nfunc_t)func,			\
351		(arg)							\
352	};								\
353	SYSINIT(vnet_init_ ## ident, subsystem, order,			\
354	    vnet_register_sysinit, &ident ## _vnet_init);		\
355	SYSUNINIT(vnet_init_ ## ident, subsystem, order,		\
356	    vnet_deregister_sysinit, &ident ## _vnet_init)
357
358#define	VNET_SYSUNINIT(ident, subsystem, order, func, arg)		\
359	static struct vnet_sysinit ident ## _vnet_uninit = {		\
360		subsystem,						\
361		order,							\
362		(sysinit_cfunc_t)(sysinit_nfunc_t)func,			\
363		(arg)							\
364	};								\
365	SYSINIT(vnet_uninit_ ## ident, subsystem, order,		\
366	    vnet_register_sysuninit, &ident ## _vnet_uninit);		\
367	SYSUNINIT(vnet_uninit_ ## ident, subsystem, order,		\
368	    vnet_deregister_sysuninit, &ident ## _vnet_uninit)
369
370/*
371 * Run per-vnet sysinits or sysuninits during vnet creation/destruction.
372 */
373void	 vnet_sysinit(void);
374void	 vnet_sysuninit(void);
375
376/*
377 * Interfaces for managing per-vnet constructors and destructors.
378 */
379void	vnet_register_sysinit(void *arg);
380void	vnet_register_sysuninit(void *arg);
381void	vnet_deregister_sysinit(void *arg);
382void	vnet_deregister_sysuninit(void *arg);
383
384/*
385 * EVENTHANDLER(9) extensions.
386 */
387#include <sys/eventhandler.h>
388
389void	vnet_global_eventhandler_iterator_func(void *, ...);
390#define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \
391do {									\
392	if (IS_DEFAULT_VNET(curvnet)) {					\
393		(tag) = vimage_eventhandler_register(NULL, #name, func,	\
394		    arg, priority,					\
395		    vnet_global_eventhandler_iterator_func);		\
396	}								\
397} while(0)
398#define VNET_GLOBAL_EVENTHANDLER_REGISTER(name, func, arg, priority)	\
399do {									\
400	if (IS_DEFAULT_VNET(curvnet)) {					\
401		vimage_eventhandler_register(NULL, #name, func,		\
402		    arg, priority,					\
403		    vnet_global_eventhandler_iterator_func);		\
404	}								\
405} while(0)
406
407#else /* !VIMAGE */
408
409/*
410 * Various virtual network stack macros compile to no-ops without VIMAGE.
411 */
412#define	curvnet			NULL
413
414#define	VNET_ASSERT(exp, msg)
415#define	CURVNET_SET(arg)
416#define	CURVNET_SET_QUIET(arg)
417#define	CURVNET_RESTORE()
418
419#define	VNET_LIST_RLOCK()
420#define	VNET_LIST_RLOCK_NOSLEEP()
421#define	VNET_LIST_RUNLOCK()
422#define	VNET_LIST_RUNLOCK_NOSLEEP()
423#define	VNET_ITERATOR_DECL(arg)
424#define	VNET_FOREACH(arg)
425
426#define	IS_DEFAULT_VNET(arg)	1
427#define	CRED_TO_VNET(cr)	NULL
428#define	TD_TO_VNET(td)		NULL
429#define	P_TO_VNET(p)		NULL
430
431/*
432 * Versions of the VNET macros that compile to normal global variables and
433 * standard sysctl definitions.
434 */
435#define	VNET_NAME(n)		n
436#define	VNET_DECLARE(t, n)	extern t n
437#define	VNET_DEFINE(t, n)	t n
438#define	_VNET_PTR(b, n)		&VNET_NAME(n)
439
440/*
441 * Virtualized global variable accessor macros.
442 */
443#define	VNET_VNET_PTR(vnet, n)		(&(n))
444#define	VNET_VNET(vnet, n)		(n)
445
446#define	VNET_PTR(n)		(&(n))
447#define	VNET(n)			(n)
448
449/*
450 * When VIMAGE isn't compiled into the kernel, virtaulized SYSCTLs simply
451 * become normal SYSCTLs.
452 */
453#ifdef SYSCTL_OID
454#define	SYSCTL_VNET_INT(parent, nbr, name, access, ptr, val, descr)	\
455	SYSCTL_INT(parent, nbr, name, access, ptr, val, descr)
456#define	SYSCTL_VNET_PROC(parent, nbr, name, access, ptr, arg, handler,	\
457	    fmt, descr)							\
458	SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt,	\
459	    descr)
460#define	SYSCTL_VNET_OPAQUE(parent, nbr, name, access, ptr, len, fmt,    \
461	    descr)							\
462	SYSCTL_OPAQUE(parent, nbr, name, access, ptr, len, fmt, descr)
463#define	SYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr)	\
464	SYSCTL_STRING(parent, nbr, name, access, arg, len, descr)
465#define	SYSCTL_VNET_STRUCT(parent, nbr, name, access, ptr, type, descr)	\
466	SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr)
467#define	SYSCTL_VNET_UINT(parent, nbr, name, access, ptr, val, descr)	\
468	SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr)
469#define	VNET_SYSCTL_ARG(req, arg1)
470#endif /* SYSCTL_OID */
471
472/*
473 * When VIMAGE isn't compiled into the kernel, VNET_SYSINIT/VNET_SYSUNINIT
474 * map into normal sysinits, which have the same ordering properties.
475 */
476#define	VNET_SYSINIT(ident, subsystem, order, func, arg)		\
477	SYSINIT(ident, subsystem, order, func, arg)
478#define	VNET_SYSUNINIT(ident, subsystem, order, func, arg)		\
479	SYSUNINIT(ident, subsystem, order, func, arg)
480
481/*
482 * Without VIMAGE revert to the default implementation.
483 */
484#define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \
485	(tag) = eventhandler_register(NULL, #name, func, arg, priority)
486#define VNET_GLOBAL_EVENTHANDLER_REGISTER(name, func, arg, priority)	\
487	eventhandler_register(NULL, #name, func, arg, priority)
488#endif /* VIMAGE */
489#endif /* _KERNEL */
490
491#endif /* !_NET_VNET_H_ */
492