Changeset View
Changeset View
Standalone View
Standalone View
sys/net/vnet.c
Show First 20 Lines • Show All 273 Lines • ▼ Show 20 Lines | vnet_destroy(struct vnet *vnet) | ||||
SDT_PROBE2(vnet, functions, vnet_destroy, entry, __LINE__, vnet); | SDT_PROBE2(vnet, functions, vnet_destroy, entry, __LINE__, vnet); | ||||
KASSERT(vnet->vnet_sockcnt == 0, | KASSERT(vnet->vnet_sockcnt == 0, | ||||
("%s: vnet still has sockets", __func__)); | ("%s: vnet still has sockets", __func__)); | ||||
VNET_LIST_WLOCK(); | VNET_LIST_WLOCK(); | ||||
LIST_REMOVE(vnet, vnet_le); | LIST_REMOVE(vnet, vnet_le); | ||||
VNET_LIST_WUNLOCK(); | VNET_LIST_WUNLOCK(); | ||||
/* Signal that VNET is being shutdown. */ | |||||
vnet->vnet_shutdown = true; | |||||
CURVNET_SET_QUIET(vnet); | CURVNET_SET_QUIET(vnet); | ||||
vnet_sysuninit(); | vnet_sysuninit(); | ||||
CURVNET_RESTORE(); | CURVNET_RESTORE(); | ||||
/* | /* | ||||
* Release storage for the virtual network stack instance. | * Release storage for the virtual network stack instance. | ||||
*/ | */ | ||||
free(vnet->vnet_data_mem, M_VNET_DATA); | free(vnet->vnet_data_mem, M_VNET_DATA); | ||||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | vnet_data_startup(void *dummy __unused) | ||||
df = malloc(sizeof(*df), M_VNET_DATA_FREE, M_WAITOK | M_ZERO); | df = malloc(sizeof(*df), M_VNET_DATA_FREE, M_WAITOK | M_ZERO); | ||||
df->vnd_start = (uintptr_t)&VNET_NAME(modspace); | df->vnd_start = (uintptr_t)&VNET_NAME(modspace); | ||||
df->vnd_len = VNET_MODMIN; | df->vnd_len = VNET_MODMIN; | ||||
TAILQ_INSERT_HEAD(&vnet_data_free_head, df, vnd_link); | TAILQ_INSERT_HEAD(&vnet_data_free_head, df, vnd_link); | ||||
sx_init(&vnet_data_free_lock, "vnet_data alloc lock"); | sx_init(&vnet_data_free_lock, "vnet_data alloc lock"); | ||||
} | } | ||||
SYSINIT(vnet_data, SI_SUB_KLD, SI_ORDER_FIRST, vnet_data_startup, NULL); | SYSINIT(vnet_data, SI_SUB_KLD, SI_ORDER_FIRST, vnet_data_startup, NULL); | ||||
/* Dummy VNET_SYSINIT to make sure we always reach the final end state. */ | |||||
hselasky: Should there be a dummy sysuninit aswell, forcing the vnet state off DONE state? | |||||
bzAuthorUnsubmitted Done Inline ActionsNot sure I understand that question. If you mean a VNET_SYSUNINIT() then the answer is 'no' as the very next operation when reaching the end of SYSUINITs is to call free. bz: Not sure I understand that question. If you mean a VNET_SYSUNINIT() then the answer is 'no' as… | |||||
bzAuthorUnsubmitted Done Inline ActionsAs I mentioned early in the review vnet0 will be dealt with separately. bz: As I mentioned early in the review vnet0 will be dealt with separately.
Also you mean sysinit… | |||||
static void | static void | ||||
vnet_sysuninit_shutdown(void *unused __unused) | vnet_sysinit_done(void *unused __unused) | ||||
{ | { | ||||
/* Signal that VNET is being shutdown. */ | return; | ||||
curvnet->vnet_shutdown = 1; | |||||
} | } | ||||
VNET_SYSUNINIT(vnet_sysuninit_shutdown, SI_SUB_VNET_DONE, SI_ORDER_FIRST, | VNET_SYSINIT(vnet_sysinit_done, SI_SUB_VNET_DONE, SI_ORDER_ANY, | ||||
vnet_sysuninit_shutdown, NULL); | vnet_sysinit_done, NULL); | ||||
/* | /* | ||||
* When a module is loaded and requires storage for a virtualized global | * When a module is loaded and requires storage for a virtualized global | ||||
* variable, allocate space from the modspace free list. This interface | * variable, allocate space from the modspace free list. This interface | ||||
* should be used only by the kernel linker. | * should be used only by the kernel linker. | ||||
*/ | */ | ||||
void * | void * | ||||
vnet_data_alloc(int size) | vnet_data_alloc(int size) | ||||
▲ Show 20 Lines • Show All 197 Lines • ▼ Show 20 Lines | |||||
* the current vnet and that the vnet_sysinit_sxlock lock is locked. | * the current vnet and that the vnet_sysinit_sxlock lock is locked. | ||||
*/ | */ | ||||
void | void | ||||
vnet_sysinit(void) | vnet_sysinit(void) | ||||
{ | { | ||||
struct vnet_sysinit *vs; | struct vnet_sysinit *vs; | ||||
VNET_SYSINIT_RLOCK(); | VNET_SYSINIT_RLOCK(); | ||||
TAILQ_FOREACH(vs, &vnet_constructors, link) | TAILQ_FOREACH(vs, &vnet_constructors, link) { | ||||
curvnet->vnet_state = vs->subsystem; | |||||
vs->func(vs->arg); | vs->func(vs->arg); | ||||
} | |||||
VNET_SYSINIT_RUNLOCK(); | VNET_SYSINIT_RUNLOCK(); | ||||
} | } | ||||
/* | /* | ||||
* Invoke all registered vnet destructors on the current vnet. Used during | * Invoke all registered vnet destructors on the current vnet. Used during | ||||
* vnet destruction. The caller is responsible for ensuring the dying vnet | * vnet destruction. The caller is responsible for ensuring the dying vnet | ||||
* the current vnet and that the vnet_sysinit_sxlock lock is locked. | * the current vnet and that the vnet_sysinit_sxlock lock is locked. | ||||
*/ | */ | ||||
void | void | ||||
vnet_sysuninit(void) | vnet_sysuninit(void) | ||||
{ | { | ||||
struct vnet_sysinit *vs; | struct vnet_sysinit *vs; | ||||
VNET_SYSINIT_RLOCK(); | VNET_SYSINIT_RLOCK(); | ||||
TAILQ_FOREACH_REVERSE(vs, &vnet_destructors, vnet_sysuninit_head, | TAILQ_FOREACH_REVERSE(vs, &vnet_destructors, vnet_sysuninit_head, | ||||
link) | link) { | ||||
curvnet->vnet_state = vs->subsystem; | |||||
vs->func(vs->arg); | vs->func(vs->arg); | ||||
} | |||||
VNET_SYSINIT_RUNLOCK(); | VNET_SYSINIT_RUNLOCK(); | ||||
} | } | ||||
/* | /* | ||||
* EVENTHANDLER(9) extensions. | * EVENTHANDLER(9) extensions. | ||||
*/ | */ | ||||
/* | /* | ||||
* Invoke the eventhandler function originally registered with the possibly | * Invoke the eventhandler function originally registered with the possibly | ||||
▲ Show 20 Lines • Show All 97 Lines • ▼ Show 20 Lines | db_printf(" vnet_magic_n = %#08x (%s, orig %#08x)\n", | ||||
vnet->vnet_magic_n, | vnet->vnet_magic_n, | ||||
(vnet->vnet_magic_n == VNET_MAGIC_N) ? | (vnet->vnet_magic_n == VNET_MAGIC_N) ? | ||||
"ok" : "mismatch", VNET_MAGIC_N); | "ok" : "mismatch", VNET_MAGIC_N); | ||||
db_printf(" vnet_ifcnt = %u\n", vnet->vnet_ifcnt); | db_printf(" vnet_ifcnt = %u\n", vnet->vnet_ifcnt); | ||||
db_printf(" vnet_sockcnt = %u\n", vnet->vnet_sockcnt); | db_printf(" vnet_sockcnt = %u\n", vnet->vnet_sockcnt); | ||||
db_printf(" vnet_data_mem = %p\n", vnet->vnet_data_mem); | db_printf(" vnet_data_mem = %p\n", vnet->vnet_data_mem); | ||||
db_printf(" vnet_data_base = %#jx\n", | db_printf(" vnet_data_base = %#jx\n", | ||||
(uintmax_t)vnet->vnet_data_base); | (uintmax_t)vnet->vnet_data_base); | ||||
db_printf(" vnet_shutdown = %#08x\n", vnet->vnet_shutdown); | db_printf(" vnet_state = %#08x\n", vnet->vnet_state); | ||||
db_printf(" vnet_shutdown = %#03x\n", vnet->vnet_shutdown); | |||||
db_printf("\n"); | db_printf("\n"); | ||||
} | } | ||||
DB_SHOW_ALL_COMMAND(vnets, db_show_all_vnets) | DB_SHOW_ALL_COMMAND(vnets, db_show_all_vnets) | ||||
{ | { | ||||
VNET_ITERATOR_DECL(vnet_iter); | VNET_ITERATOR_DECL(vnet_iter); | ||||
VNET_FOREACH(vnet_iter) { | VNET_FOREACH(vnet_iter) { | ||||
▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines |
Should there be a dummy sysuninit aswell, forcing the vnet state off DONE state?