Lines Matching refs:vnet

37 __FBSDID("$FreeBSD: stable/11/sys/net/vnet.c 359652 2020-04-06 07:16:31Z hselasky $");
66 #include <net/vnet.h>
83 static MALLOC_DEFINE(M_VNET, "vnet", "network stack control block");
105 struct vnet *vnet0;
118 * vnet linker set. These "master" copies of global variables serve two
133 * referred to by vnet->vnet_data_mem. Critical to the design is that each
137 * vnet->vnet_data_base, is stored in each vnet, and is the amount that can
139 * per-vnet instance.
144 * for potential module variables using a per-vnet character array,
210 SDT_PROVIDER_DEFINE(vnet);
211 SDT_PROBE_DEFINE1(vnet, functions, vnet_alloc, entry, "int");
212 SDT_PROBE_DEFINE2(vnet, functions, vnet_alloc, alloc, "int",
213 "struct vnet *");
214 SDT_PROBE_DEFINE2(vnet, functions, vnet_alloc, return,
215 "int", "struct vnet *");
216 SDT_PROBE_DEFINE2(vnet, functions, vnet_destroy, entry,
217 "int", "struct vnet *");
218 SDT_PROBE_DEFINE1(vnet, functions, vnet_destroy, return,
228 struct vnet *
231 struct vnet *vnet;
233 SDT_PROBE1(vnet, functions, vnet_alloc, entry, __LINE__);
234 vnet = malloc(sizeof(struct vnet), M_VNET, M_WAITOK | M_ZERO);
235 vnet->vnet_magic_n = VNET_MAGIC_N;
236 vnet->vnet_state = 0;
237 SDT_PROBE2(vnet, functions, vnet_alloc, alloc, __LINE__, vnet);
243 vnet->vnet_data_mem = malloc(VNET_SIZE, M_VNET_DATA, M_WAITOK);
244 memcpy(vnet->vnet_data_mem, (void *)VNET_START, VNET_BYTES);
247 * All use of vnet-specific data will immediately subtract VNET_START
251 vnet->vnet_data_base = (uintptr_t)vnet->vnet_data_mem - VNET_START;
253 /* Initialize / attach vnet module instances. */
254 CURVNET_SET_QUIET(vnet);
259 LIST_INSERT_HEAD(&vnet_head, vnet, vnet_le);
262 SDT_PROBE2(vnet, functions, vnet_alloc, return, __LINE__, vnet);
263 return (vnet);
270 vnet_destroy(struct vnet *vnet)
273 SDT_PROBE2(vnet, functions, vnet_destroy, entry, __LINE__, vnet);
274 KASSERT(vnet->vnet_sockcnt == 0,
275 ("%s: vnet still has sockets", __func__));
278 LIST_REMOVE(vnet, vnet_le);
281 CURVNET_SET_QUIET(vnet);
288 free(vnet->vnet_data_mem, M_VNET_DATA);
289 vnet->vnet_data_mem = NULL;
290 vnet->vnet_data_base = 0;
291 vnet->vnet_magic_n = 0xdeadbeef;
292 free(vnet, M_VNET);
293 SDT_PROBE1(vnet, functions, vnet_destroy, return, __LINE__);
458 struct vnet *vnet;
461 LIST_FOREACH(vnet, &vnet_head, vnet_le)
462 memcpy((void *)((uintptr_t)vnet->vnet_data_base +
475 struct vnet *vnet;
478 KASSERT(vs->subsystem > SI_SUB_VNET, ("vnet sysinit too early"));
480 /* Add the constructor to the global list of vnet constructors. */
497 VNET_FOREACH(vnet) {
498 CURVNET_SET_QUIET(vnet);
512 /* Remove the constructor from the global list of vnet constructors. */
525 /* Add the destructor to the global list of vnet destructors. */
544 struct vnet *vnet;
553 VNET_FOREACH(vnet) {
554 CURVNET_SET_QUIET(vnet);
559 /* Remove the destructor from the global list of vnet destructors. */
565 * Invoke all registered vnet constructors on the current vnet. Used during
566 * vnet construction. The caller is responsible for ensuring the new vnet is
567 * the current vnet and that the vnet_sysinit_sxlock lock is locked.
583 * Invoke all registered vnet destructors on the current vnet. Used during
584 * vnet destruction. The caller is responsible for ensuring the dying vnet
585 * the current vnet and that the vnet_sysinit_sxlock lock is locked.
640 struct vnet *old_vnet;
641 struct vnet *new_vnet;
663 vnet_log_recursion(struct vnet *old_vnet, const char *old_fn, int line)
698 db_vnet_print(struct vnet *vnet)
701 db_printf("vnet = %p\n", vnet);
703 vnet->vnet_magic_n,
704 (vnet->vnet_magic_n == VNET_MAGIC_N) ?
706 db_printf(" vnet_ifcnt = %u\n", vnet->vnet_ifcnt);
707 db_printf(" vnet_sockcnt = %u\n", vnet->vnet_sockcnt);
708 db_printf(" vnet_data_mem = %p\n", vnet->vnet_data_mem);
710 (uintmax_t)vnet->vnet_data_base);
711 db_printf(" vnet_state = %#08x\n", vnet->vnet_state);
726 DB_SHOW_COMMAND(vnet, db_show_vnet)
730 db_printf("usage: show vnet <struct vnet *>\n");
734 db_vnet_print((struct vnet *)addr);