1183550Szec/*- 2196019Srwatson * Copyright (c) 2006-2009 University of Zagreb 3196019Srwatson * Copyright (c) 2006-2009 FreeBSD Foundation 4196019Srwatson * All rights reserved. 5196019Srwatson * 6196019Srwatson * This software was developed by the University of Zagreb and the 7196019Srwatson * FreeBSD Foundation under sponsorship by the Stichting NLnet and the 8196019Srwatson * FreeBSD Foundation. 9196019Srwatson * 10195699Srwatson * Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org> 11195699Srwatson * Copyright (c) 2009 Robert N. M. Watson 12195705Srwatson * All rights reserved. 13183550Szec * 14183550Szec * Redistribution and use in source and binary forms, with or without 15183550Szec * modification, are permitted provided that the following conditions 16183550Szec * are met: 17183550Szec * 1. Redistributions of source code must retain the above copyright 18183550Szec * notice, this list of conditions and the following disclaimer. 19183550Szec * 2. Redistributions in binary form must reproduce the above copyright 20183550Szec * notice, this list of conditions and the following disclaimer in the 21183550Szec * documentation and/or other materials provided with the distribution. 22195705Srwatson * 23183550Szec * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 24183550Szec * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25183550Szec * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26183550Szec * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 27183550Szec * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28183550Szec * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29183550Szec * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30183550Szec * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31183550Szec * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32183550Szec * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33183550Szec * SUCH DAMAGE. 34183550Szec * 35183550Szec * $FreeBSD: stable/11/sys/net/vnet.h 354610 2019-11-11 14:49:45Z hselasky $ 36183550Szec */ 37183550Szec 38195972Srwatson/*- 39195972Srwatson * This header file defines several sets of interfaces supporting virtualized 40195972Srwatson * network stacks: 41195972Srwatson * 42196019Srwatson * - Definition of 'struct vnet' and functions and macros to allocate/free/ 43196019Srwatson * manipulate it. 44196019Srwatson * 45195972Srwatson * - A virtual network stack memory allocator, which provides support for 46195972Srwatson * virtualized global variables via a special linker set, set_vnet. 47195972Srwatson * 48195972Srwatson * - Virtualized sysinits/sysuninits, which allow constructors and 49195972Srwatson * destructors to be run for each network stack subsystem as virtual 50195972Srwatson * instances are created and destroyed. 51195972Srwatson * 52195972Srwatson * If VIMAGE isn't compiled into the kernel, virtualized global variables 53195972Srwatson * compile to normal global variables, and virtualized sysinits to regular 54195972Srwatson * sysinits. 55195699Srwatson */ 56195699Srwatson 57183550Szec#ifndef _NET_VNET_H_ 58192669Szec#define _NET_VNET_H_ 59183550Szec 60195972Srwatson/* 61196019Srwatson * struct vnet describes a virtualized network stack, and is primarily a 62196019Srwatson * pointer to storage for virtualized global variables. Expose to userspace 63196019Srwatson * as required for libkvm. 64195972Srwatson */ 65195778Srwatson#if defined(_KERNEL) || defined(_WANT_VNET) 66196019Srwatson#include <sys/queue.h> 67196019Srwatson 68196019Srwatsonstruct vnet { 69196019Srwatson LIST_ENTRY(vnet) vnet_le; /* all vnets list */ 70196019Srwatson u_int vnet_magic_n; 71196019Srwatson u_int vnet_ifcnt; 72196019Srwatson u_int vnet_sockcnt; 73300155Sbz u_int vnet_state; /* SI_SUB_* */ 74196019Srwatson void *vnet_data_mem; 75196019Srwatson uintptr_t vnet_data_base; 76196019Srwatson}; 77196019Srwatson#define VNET_MAGIC_N 0x3e0d8f29 78196019Srwatson 79196019Srwatson/* 80196019Srwatson * These two virtual network stack allocator definitions are also required 81196019Srwatson * for libkvm so that it can evaluate virtualized global variables. 82196019Srwatson */ 83195778Srwatson#define VNET_SETNAME "set_vnet" 84195778Srwatson#define VNET_SYMPREFIX "vnet_entry_" 85195778Srwatson#endif 86195778Srwatson 87195699Srwatson#ifdef _KERNEL 88196019Srwatson 89253082Sae#define VNET_PCPUSTAT_DECLARE(type, name) \ 90253082Sae VNET_DECLARE(counter_u64_t, name[sizeof(type) / sizeof(uint64_t)]) 91253082Sae 92253082Sae#define VNET_PCPUSTAT_DEFINE(type, name) \ 93253082Sae VNET_DEFINE(counter_u64_t, name[sizeof(type) / sizeof(uint64_t)]) 94253082Sae 95253082Sae#define VNET_PCPUSTAT_ALLOC(name, wait) \ 96253082Sae COUNTER_ARRAY_ALLOC(VNET(name), \ 97253082Sae sizeof(VNET(name)) / sizeof(counter_u64_t), (wait)) 98253082Sae 99253082Sae#define VNET_PCPUSTAT_FREE(name) \ 100253082Sae COUNTER_ARRAY_FREE(VNET(name), sizeof(VNET(name)) / sizeof(counter_u64_t)) 101253082Sae 102253082Sae#define VNET_PCPUSTAT_ADD(type, name, f, v) \ 103253082Sae counter_u64_add(VNET(name)[offsetof(type, f) / sizeof(uint64_t)], (v)) 104253082Sae 105294867Sglebius#define VNET_PCPUSTAT_FETCH(type, name, f) \ 106294867Sglebius counter_u64_fetch(VNET(name)[offsetof(type, f) / sizeof(uint64_t)]) 107294867Sglebius 108253082Sae#define VNET_PCPUSTAT_SYSINIT(name) \ 109253082Saestatic void \ 110253082Saevnet_##name##_init(const void *unused) \ 111253082Sae{ \ 112253082Sae VNET_PCPUSTAT_ALLOC(name, M_WAITOK); \ 113253082Sae} \ 114302054SbzVNET_SYSINIT(vnet_ ## name ## _init, SI_SUB_INIT_IF, \ 115302054Sbz SI_ORDER_FIRST, vnet_ ## name ## _init, NULL) 116253082Sae 117253082Sae#define VNET_PCPUSTAT_SYSUNINIT(name) \ 118253082Saestatic void \ 119253082Saevnet_##name##_uninit(const void *unused) \ 120253082Sae{ \ 121253082Sae VNET_PCPUSTAT_FREE(name); \ 122253082Sae} \ 123302054SbzVNET_SYSUNINIT(vnet_ ## name ## _uninit, SI_SUB_INIT_IF, \ 124302054Sbz SI_ORDER_FIRST, vnet_ ## name ## _uninit, NULL) 125253082Sae 126274225Sglebius#ifdef SYSCTL_OID 127253082Sae#define SYSCTL_VNET_PCPUSTAT(parent, nbr, name, type, array, desc) \ 128253082Saestatic int \ 129253082Saearray##_sysctl(SYSCTL_HANDLER_ARGS) \ 130253082Sae{ \ 131253082Sae type s; \ 132253100Sae CTASSERT((sizeof(type) / sizeof(uint64_t)) == \ 133253100Sae (sizeof(VNET(array)) / sizeof(counter_u64_t))); \ 134253082Sae COUNTER_ARRAY_COPY(VNET(array), &s, sizeof(type) / sizeof(uint64_t));\ 135253082Sae if (req->newptr) \ 136253082Sae COUNTER_ARRAY_ZERO(VNET(array), \ 137253082Sae sizeof(type) / sizeof(uint64_t)); \ 138253082Sae return (SYSCTL_OUT(req, &s, sizeof(type))); \ 139253082Sae} \ 140274225SglebiusSYSCTL_PROC(parent, nbr, name, CTLFLAG_VNET | CTLTYPE_OPAQUE | CTLFLAG_RW, \ 141274225Sglebius NULL, 0, array ## _sysctl, "I", desc) 142274225Sglebius#endif /* SYSCTL_OID */ 143253082Sae 144195699Srwatson#ifdef VIMAGE 145196019Srwatson#include <sys/lock.h> 146196019Srwatson#include <sys/proc.h> /* for struct thread */ 147196019Srwatson#include <sys/rwlock.h> 148196019Srwatson#include <sys/sx.h> 149183550Szec 150196019Srwatson/* 151206639Sjulian * Location of the kernel's 'set_vnet' linker set. 152206639Sjulian */ 153206639Sjulianextern uintptr_t *__start_set_vnet; 154215701Sdim__GLOBL(__start_set_vnet); 155206639Sjulianextern uintptr_t *__stop_set_vnet; 156215701Sdim__GLOBL(__stop_set_vnet); 157206639Sjulian 158206639Sjulian#define VNET_START (uintptr_t)&__start_set_vnet 159206639Sjulian#define VNET_STOP (uintptr_t)&__stop_set_vnet 160206639Sjulian 161206639Sjulian/* 162196019Srwatson * Functions to allocate and destroy virtual network stacks. 163196019Srwatson */ 164196019Srwatsonstruct vnet *vnet_alloc(void); 165196019Srwatsonvoid vnet_destroy(struct vnet *vnet); 166196019Srwatson 167196019Srwatson/* 168196019Srwatson * The current virtual network stack -- we may wish to move this to struct 169196019Srwatson * pcpu in the future. 170196019Srwatson */ 171196019Srwatson#define curvnet curthread->td_vnet 172196019Srwatson 173196019Srwatson/* 174196019Srwatson * Various macros -- get and set the current network stack, but also 175196019Srwatson * assertions. 176196019Srwatson */ 177218559Sbz#if defined(INVARIANTS) || defined(VNET_DEBUG) 178218559Sbz#define VNET_ASSERT(exp, msg) do { \ 179218559Sbz if (!(exp)) \ 180218559Sbz panic msg; \ 181218559Sbz} while (0) 182218559Sbz#else 183218559Sbz#define VNET_ASSERT(exp, msg) do { \ 184218559Sbz} while (0) 185218559Sbz#endif 186218559Sbz 187196019Srwatson#ifdef VNET_DEBUG 188203483Szecvoid vnet_log_recursion(struct vnet *, const char *, int); 189203483Szec 190196019Srwatson#define CURVNET_SET_QUIET(arg) \ 191218559Sbz VNET_ASSERT((arg) != NULL && (arg)->vnet_magic_n == VNET_MAGIC_N, \ 192218559Sbz ("CURVNET_SET at %s:%d %s() curvnet=%p vnet=%p", \ 193218559Sbz __FILE__, __LINE__, __func__, curvnet, (arg))); \ 194196019Srwatson struct vnet *saved_vnet = curvnet; \ 195196019Srwatson const char *saved_vnet_lpush = curthread->td_vnet_lpush; \ 196196019Srwatson curvnet = arg; \ 197218555Sbz curthread->td_vnet_lpush = __func__; 198196019Srwatson 199196019Srwatson#define CURVNET_SET_VERBOSE(arg) \ 200196019Srwatson CURVNET_SET_QUIET(arg) \ 201196019Srwatson if (saved_vnet) \ 202203483Szec vnet_log_recursion(saved_vnet, saved_vnet_lpush, __LINE__); 203196019Srwatson 204196019Srwatson#define CURVNET_SET(arg) CURVNET_SET_VERBOSE(arg) 205196019Srwatson 206196019Srwatson#define CURVNET_RESTORE() \ 207218559Sbz VNET_ASSERT(curvnet != NULL && (saved_vnet == NULL || \ 208218559Sbz saved_vnet->vnet_magic_n == VNET_MAGIC_N), \ 209218559Sbz ("CURVNET_RESTORE at %s:%d %s() curvnet=%p saved_vnet=%p", \ 210218559Sbz __FILE__, __LINE__, __func__, curvnet, saved_vnet)); \ 211196019Srwatson curvnet = saved_vnet; \ 212196019Srwatson curthread->td_vnet_lpush = saved_vnet_lpush; 213196019Srwatson#else /* !VNET_DEBUG */ 214196019Srwatson 215218567Sbz#define CURVNET_SET_QUIET(arg) \ 216218567Sbz VNET_ASSERT((arg) != NULL && (arg)->vnet_magic_n == VNET_MAGIC_N, \ 217218567Sbz ("CURVNET_SET at %s:%d %s() curvnet=%p vnet=%p", \ 218218567Sbz __FILE__, __LINE__, __func__, curvnet, (arg))); \ 219196019Srwatson struct vnet *saved_vnet = curvnet; \ 220196019Srwatson curvnet = arg; 221196019Srwatson 222218567Sbz#define CURVNET_SET_VERBOSE(arg) \ 223218567Sbz CURVNET_SET_QUIET(arg) 224218567Sbz 225218567Sbz#define CURVNET_SET(arg) CURVNET_SET_VERBOSE(arg) 226196019Srwatson 227196019Srwatson#define CURVNET_RESTORE() \ 228218567Sbz VNET_ASSERT(curvnet != NULL && (saved_vnet == NULL || \ 229218567Sbz saved_vnet->vnet_magic_n == VNET_MAGIC_N), \ 230218567Sbz ("CURVNET_RESTORE at %s:%d %s() curvnet=%p saved_vnet=%p", \ 231218567Sbz __FILE__, __LINE__, __func__, curvnet, saved_vnet)); \ 232196019Srwatson curvnet = saved_vnet; 233196019Srwatson#endif /* VNET_DEBUG */ 234196019Srwatson 235196019Srwatsonextern struct vnet *vnet0; 236196019Srwatson#define IS_DEFAULT_VNET(arg) ((arg) == vnet0) 237196019Srwatson 238196019Srwatson#define CRED_TO_VNET(cr) (cr)->cr_prison->pr_vnet 239196019Srwatson#define TD_TO_VNET(td) CRED_TO_VNET((td)->td_ucred) 240196019Srwatson#define P_TO_VNET(p) CRED_TO_VNET((p)->p_ucred) 241196019Srwatson 242196019Srwatson/* 243196019Srwatson * Global linked list of all virtual network stacks, along with read locks to 244196019Srwatson * access it. If a caller may sleep while accessing the list, it must use 245196019Srwatson * the sleepable lock macros. 246196019Srwatson */ 247196019SrwatsonLIST_HEAD(vnet_list_head, vnet); 248196019Srwatsonextern struct vnet_list_head vnet_head; 249196019Srwatsonextern struct rwlock vnet_rwlock; 250196019Srwatsonextern struct sx vnet_sxlock; 251196019Srwatson 252196019Srwatson#define VNET_LIST_RLOCK() sx_slock(&vnet_sxlock) 253196019Srwatson#define VNET_LIST_RLOCK_NOSLEEP() rw_rlock(&vnet_rwlock) 254196019Srwatson#define VNET_LIST_RUNLOCK() sx_sunlock(&vnet_sxlock) 255196019Srwatson#define VNET_LIST_RUNLOCK_NOSLEEP() rw_runlock(&vnet_rwlock) 256196019Srwatson 257196019Srwatson/* 258196019Srwatson * Iteration macros to walk the global list of virtual network stacks. 259196019Srwatson */ 260196019Srwatson#define VNET_ITERATOR_DECL(arg) struct vnet *arg 261196019Srwatson#define VNET_FOREACH(arg) LIST_FOREACH((arg), &vnet_head, vnet_le) 262196019Srwatson 263196019Srwatson/* 264196019Srwatson * Virtual network stack memory allocator, which allows global variables to 265196019Srwatson * be automatically instantiated for each network stack instance. 266196019Srwatson */ 267195699Srwatson#define VNET_NAME(n) vnet_entry_##n 268195699Srwatson#define VNET_DECLARE(t, n) extern t VNET_NAME(n) 269215701Sdim#define VNET_DEFINE(t, n) t VNET_NAME(n) __section(VNET_SETNAME) __used 270215701Sdim#define _VNET_PTR(b, n) (__typeof(VNET_NAME(n))*) \ 271215701Sdim ((b) + (uintptr_t)&VNET_NAME(n)) 272183550Szec 273195727Srwatson#define _VNET(b, n) (*_VNET_PTR(b, n)) 274183550Szec 275195699Srwatson/* 276195699Srwatson * Virtualized global variable accessor macros. 277195699Srwatson */ 278195699Srwatson#define VNET_VNET_PTR(vnet, n) _VNET_PTR((vnet)->vnet_data_base, n) 279195727Srwatson#define VNET_VNET(vnet, n) (*VNET_VNET_PTR((vnet), n)) 280183550Szec 281195699Srwatson#define VNET_PTR(n) VNET_VNET_PTR(curvnet, n) 282195727Srwatson#define VNET(n) VNET_VNET(curvnet, n) 283183550Szec 284195699Srwatson/* 285195972Srwatson * Virtual network stack allocator interfaces from the kernel linker. 286195972Srwatson */ 287195972Srwatsonvoid *vnet_data_alloc(int size); 288195972Srwatsonvoid vnet_data_copy(void *start, int size); 289195972Srwatsonvoid vnet_data_free(void *start_arg, int size); 290195972Srwatson 291195972Srwatson/* 292195972Srwatson * Virtual sysinit mechanism, allowing network stack components to declare 293195972Srwatson * startup and shutdown methods to be run when virtual network stack 294195972Srwatson * instances are created and destroyed. 295195699Srwatson */ 296195972Srwatson#include <sys/kernel.h> 297189225Sbz 298195699Srwatson/* 299195972Srwatson * SYSINIT/SYSUNINIT variants that provide per-vnet constructors and 300195972Srwatson * destructors. 301195699Srwatson */ 302195972Srwatsonstruct vnet_sysinit { 303195972Srwatson enum sysinit_sub_id subsystem; 304195972Srwatson enum sysinit_elem_order order; 305195972Srwatson sysinit_cfunc_t func; 306195972Srwatson const void *arg; 307195972Srwatson TAILQ_ENTRY(vnet_sysinit) link; 308195972Srwatson}; 309195972Srwatson 310195972Srwatson#define VNET_SYSINIT(ident, subsystem, order, func, arg) \ 311354610Shselasky CTASSERT((subsystem) > SI_SUB_VNET && \ 312354610Shselasky (subsystem) <= SI_SUB_VNET_DONE); \ 313195972Srwatson static struct vnet_sysinit ident ## _vnet_init = { \ 314195972Srwatson subsystem, \ 315195972Srwatson order, \ 316195972Srwatson (sysinit_cfunc_t)(sysinit_nfunc_t)func, \ 317195972Srwatson (arg) \ 318195972Srwatson }; \ 319195972Srwatson SYSINIT(vnet_init_ ## ident, subsystem, order, \ 320195972Srwatson vnet_register_sysinit, &ident ## _vnet_init); \ 321195972Srwatson SYSUNINIT(vnet_init_ ## ident, subsystem, order, \ 322195972Srwatson vnet_deregister_sysinit, &ident ## _vnet_init) 323195972Srwatson 324195972Srwatson#define VNET_SYSUNINIT(ident, subsystem, order, func, arg) \ 325354610Shselasky CTASSERT((subsystem) > SI_SUB_VNET && \ 326354610Shselasky (subsystem) <= SI_SUB_VNET_DONE); \ 327195972Srwatson static struct vnet_sysinit ident ## _vnet_uninit = { \ 328195972Srwatson subsystem, \ 329195972Srwatson order, \ 330195972Srwatson (sysinit_cfunc_t)(sysinit_nfunc_t)func, \ 331195972Srwatson (arg) \ 332195972Srwatson }; \ 333195972Srwatson SYSINIT(vnet_uninit_ ## ident, subsystem, order, \ 334195972Srwatson vnet_register_sysuninit, &ident ## _vnet_uninit); \ 335195972Srwatson SYSUNINIT(vnet_uninit_ ## ident, subsystem, order, \ 336195972Srwatson vnet_deregister_sysuninit, &ident ## _vnet_uninit) 337195972Srwatson 338195972Srwatson/* 339195972Srwatson * Run per-vnet sysinits or sysuninits during vnet creation/destruction. 340195972Srwatson */ 341195837Srwatsonvoid vnet_sysinit(void); 342195837Srwatsonvoid vnet_sysuninit(void); 343185895Szec 344195837Srwatson/* 345195837Srwatson * Interfaces for managing per-vnet constructors and destructors. 346195837Srwatson */ 347195837Srwatsonvoid vnet_register_sysinit(void *arg); 348195837Srwatsonvoid vnet_register_sysuninit(void *arg); 349195837Srwatsonvoid vnet_deregister_sysinit(void *arg); 350195837Srwatsonvoid vnet_deregister_sysuninit(void *arg); 351195837Srwatson 352205345Sbz/* 353205345Sbz * EVENTHANDLER(9) extensions. 354205345Sbz */ 355205345Sbz#include <sys/eventhandler.h> 356205345Sbz 357205345Sbzvoid vnet_global_eventhandler_iterator_func(void *, ...); 358205345Sbz#define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \ 359205345Sbzdo { \ 360205345Sbz if (IS_DEFAULT_VNET(curvnet)) { \ 361205345Sbz (tag) = vimage_eventhandler_register(NULL, #name, func, \ 362205345Sbz arg, priority, \ 363205345Sbz vnet_global_eventhandler_iterator_func); \ 364205345Sbz } \ 365205345Sbz} while(0) 366205345Sbz#define VNET_GLOBAL_EVENTHANDLER_REGISTER(name, func, arg, priority) \ 367205345Sbzdo { \ 368205345Sbz if (IS_DEFAULT_VNET(curvnet)) { \ 369205345Sbz vimage_eventhandler_register(NULL, #name, func, \ 370205345Sbz arg, priority, \ 371205345Sbz vnet_global_eventhandler_iterator_func); \ 372205345Sbz } \ 373205345Sbz} while(0) 374205345Sbz 375195699Srwatson#else /* !VIMAGE */ 376195699Srwatson 377183550Szec/* 378196019Srwatson * Various virtual network stack macros compile to no-ops without VIMAGE. 379196019Srwatson */ 380196019Srwatson#define curvnet NULL 381196019Srwatson 382218559Sbz#define VNET_ASSERT(exp, msg) 383196019Srwatson#define CURVNET_SET(arg) 384196019Srwatson#define CURVNET_SET_QUIET(arg) 385196019Srwatson#define CURVNET_RESTORE() 386196019Srwatson 387196019Srwatson#define VNET_LIST_RLOCK() 388196019Srwatson#define VNET_LIST_RLOCK_NOSLEEP() 389196019Srwatson#define VNET_LIST_RUNLOCK() 390196019Srwatson#define VNET_LIST_RUNLOCK_NOSLEEP() 391196019Srwatson#define VNET_ITERATOR_DECL(arg) 392196019Srwatson#define VNET_FOREACH(arg) 393196019Srwatson 394196019Srwatson#define IS_DEFAULT_VNET(arg) 1 395196019Srwatson#define CRED_TO_VNET(cr) NULL 396196019Srwatson#define TD_TO_VNET(td) NULL 397196019Srwatson#define P_TO_VNET(p) NULL 398196019Srwatson 399196019Srwatson/* 400195699Srwatson * Versions of the VNET macros that compile to normal global variables and 401195699Srwatson * standard sysctl definitions. 402183550Szec */ 403215701Sdim#define VNET_NAME(n) n 404215701Sdim#define VNET_DECLARE(t, n) extern t n 405215701Sdim#define VNET_DEFINE(t, n) t n 406215701Sdim#define _VNET_PTR(b, n) &VNET_NAME(n) 407183550Szec 408195972Srwatson/* 409195972Srwatson * Virtualized global variable accessor macros. 410195972Srwatson */ 411195972Srwatson#define VNET_VNET_PTR(vnet, n) (&(n)) 412195972Srwatson#define VNET_VNET(vnet, n) (n) 413195972Srwatson 414195972Srwatson#define VNET_PTR(n) (&(n)) 415195972Srwatson#define VNET(n) (n) 416195972Srwatson 417195972Srwatson/* 418195972Srwatson * When VIMAGE isn't compiled into the kernel, VNET_SYSINIT/VNET_SYSUNINIT 419195972Srwatson * map into normal sysinits, which have the same ordering properties. 420195699Srwatson */ 421195972Srwatson#define VNET_SYSINIT(ident, subsystem, order, func, arg) \ 422195972Srwatson SYSINIT(ident, subsystem, order, func, arg) 423195972Srwatson#define VNET_SYSUNINIT(ident, subsystem, order, func, arg) \ 424195972Srwatson SYSUNINIT(ident, subsystem, order, func, arg) 425183550Szec 426205345Sbz/* 427205345Sbz * Without VIMAGE revert to the default implementation. 428205345Sbz */ 429205345Sbz#define VNET_GLOBAL_EVENTHANDLER_REGISTER_TAG(tag, name, func, arg, priority) \ 430205345Sbz (tag) = eventhandler_register(NULL, #name, func, arg, priority) 431205345Sbz#define VNET_GLOBAL_EVENTHANDLER_REGISTER(name, func, arg, priority) \ 432205345Sbz eventhandler_register(NULL, #name, func, arg, priority) 433195699Srwatson#endif /* VIMAGE */ 434195699Srwatson#endif /* _KERNEL */ 435195699Srwatson 436183550Szec#endif /* !_NET_VNET_H_ */ 437