mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-15 04:43:53 +00:00
Merge the remainder of kern_vimage.c and vimage.h into vnet.c and
vnet.h, we now use jails (rather than vimages) as the abstraction for virtualization management, and what remained was specific to virtual network stacks. Minor cleanups are done in the process, and comments updated to reflect these changes. Reviewed by: bz Approved by: re (vimage blanket)
This commit is contained in:
parent
2df76c160b
commit
530c006014
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=196019
|
@ -14,6 +14,8 @@
|
|||
# The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
|
||||
#
|
||||
|
||||
# 20090801: vimage.h removed in favour of vnet.h
|
||||
OLD_FILES+=usr/include/sys/vimage.h
|
||||
# 20090719: library version bump for 8.0
|
||||
OLD_LIBS+=lib/libalias.so.6
|
||||
OLD_LIBS+=lib/libavl.so.1
|
||||
|
|
|
@ -40,7 +40,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/jail.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/vnet.h>
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/kernel.h>
|
||||
#include <sys/kerneldump.h>
|
||||
#include <sys/msgbuf.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <vm/vm.h>
|
||||
#include <vm/pmap.h>
|
||||
#include <machine/pmap.h>
|
||||
|
|
|
@ -73,7 +73,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/user.h>
|
||||
#include <sys/vmmeter.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
|
|
@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sx.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
|
|
|
@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/uio.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/un.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
|
|
@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/filedesc.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/vnet.h>
|
||||
|
|
|
@ -1992,7 +1992,6 @@ kern/kern_time.c standard
|
|||
kern/kern_timeout.c standard
|
||||
kern/kern_umtx.c standard
|
||||
kern/kern_uuid.c standard
|
||||
kern/kern_vimage.c optional vimage
|
||||
kern/kern_xxx.c standard
|
||||
kern/link_elf.c standard
|
||||
kern/linker_if.m standard
|
||||
|
|
|
@ -47,9 +47,6 @@
|
|||
#include <sys/syslog.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/queue.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/vimage.h>
|
||||
#endif
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
|
|
|
@ -33,9 +33,6 @@
|
|||
# if (__FreeBSD_version == 400019)
|
||||
# define CSUM_DELAY_DATA
|
||||
# endif
|
||||
# if (__FreeBSD_version >= 800044)
|
||||
# include <sys/vimage.h>
|
||||
# endif
|
||||
# endif
|
||||
# include <sys/filio.h>
|
||||
#else
|
||||
|
|
|
@ -63,7 +63,6 @@ static const char rcsid[] = "@(#)$Id: ip_fil_freebsd.c,v 2.53.2.50 2007/09/20 12
|
|||
# include <sys/select.h>
|
||||
#endif
|
||||
#if __FreeBSD_version >= 800044
|
||||
# include <sys/vimage.h>
|
||||
# include <netinet/tcp_var.h>
|
||||
#else
|
||||
#define V_path_mtu_discovery path_mtu_discovery
|
||||
|
|
|
@ -91,7 +91,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/kthread.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/vimage.h>
|
||||
#else
|
||||
#include <sys/rwlock.h>
|
||||
#endif
|
||||
|
|
|
@ -54,9 +54,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/device.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
#ifdef __FreeBSD__
|
||||
#include <sys/vimage.h>
|
||||
#endif
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
|
|
|
@ -83,7 +83,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/conf.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
#else
|
||||
#include <sys/timeout.h>
|
||||
#include <sys/pool.h>
|
||||
|
|
|
@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
|
|
|
@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/taskqueue.h>
|
||||
#include <sys/priv.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <netinet/in.h>
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/pcpu.h>
|
||||
#include <sys/smp.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/vnet.h>
|
||||
|
||||
|
|
|
@ -54,9 +54,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/proc.h>
|
||||
#include <sys/eventhandler.h>
|
||||
|
||||
#if __FreeBSD_version >= 800044
|
||||
#include <sys/vimage.h>
|
||||
#else
|
||||
#if __FreeBSD_version < 800044
|
||||
#define V_ifnet ifnet
|
||||
#endif
|
||||
|
||||
|
|
|
@ -48,9 +48,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/protosw.h>
|
||||
#include <sys/priv.h>
|
||||
|
||||
#if __FreeBSD_version >= 800044
|
||||
#include <sys/vimage.h>
|
||||
#else
|
||||
#if __FreeBSD_version < 800044
|
||||
#define V_tcp_do_autosndbuf tcp_do_autosndbuf
|
||||
#define V_tcp_autosndbuf_max tcp_autosndbuf_max
|
||||
#define V_tcp_do_rfc1323 tcp_do_rfc1323
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
#include <sys/priv.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/syscallsubr.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <fs/fifofs/fifo.h>
|
||||
#include <net/if.h>
|
||||
#include <net/radix.h>
|
||||
|
|
|
@ -58,9 +58,12 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/syscallsubr.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
#ifdef INET6
|
||||
|
|
|
@ -51,7 +51,8 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/vnode.h>
|
||||
#include <sys/syscallsubr.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <security/mac/mac_framework.h>
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sockio.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h> /* for IFF_* flags */
|
||||
#include <net/netisr.h> /* for NETISR_POLL */
|
||||
|
|
|
@ -54,7 +54,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sx.h>
|
||||
#include <sys/sysproto.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/vimage.h>
|
||||
#ifdef KTRACE
|
||||
#include <sys/ktrace.h>
|
||||
#endif
|
||||
|
|
|
@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sysproto.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/uuid.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
|
|
|
@ -1,186 +0,0 @@
|
|||
/*-
|
||||
* Copyright (c) 2004-2009 University of Zagreb
|
||||
* Copyright (c) 2006-2009 FreeBSD Foundation
|
||||
*
|
||||
* This software was developed by the University of Zagreb and the
|
||||
* FreeBSD Foundation under sponsorship by the Stichting NLnet and the
|
||||
* FreeBSD Foundation.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/vimage.h>
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
#endif
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
MALLOC_DEFINE(M_VNET, "vnet", "network stack control block");
|
||||
|
||||
struct rwlock vnet_rwlock;
|
||||
struct sx vnet_sxlock;
|
||||
|
||||
#define VNET_LIST_WLOCK() do { \
|
||||
sx_xlock(&vnet_sxlock); \
|
||||
rw_wlock(&vnet_rwlock); \
|
||||
} while (0)
|
||||
|
||||
#define VNET_LIST_WUNLOCK() do { \
|
||||
rw_wunlock(&vnet_rwlock); \
|
||||
sx_xunlock(&vnet_sxlock); \
|
||||
} while (0)
|
||||
|
||||
struct vnet_list_head vnet_head;
|
||||
struct vnet *vnet0;
|
||||
|
||||
|
||||
struct vnet *
|
||||
vnet_alloc(void)
|
||||
{
|
||||
struct vnet *vnet;
|
||||
|
||||
vnet = malloc(sizeof(struct vnet), M_VNET, M_WAITOK | M_ZERO);
|
||||
vnet->vnet_magic_n = VNET_MAGIC_N;
|
||||
vnet_data_init(vnet);
|
||||
|
||||
/* Initialize / attach vnet module instances. */
|
||||
CURVNET_SET_QUIET(vnet);
|
||||
|
||||
sx_xlock(&vnet_sxlock);
|
||||
vnet_sysinit();
|
||||
CURVNET_RESTORE();
|
||||
|
||||
rw_wlock(&vnet_rwlock);
|
||||
LIST_INSERT_HEAD(&vnet_head, vnet, vnet_le);
|
||||
VNET_LIST_WUNLOCK();
|
||||
|
||||
return (vnet);
|
||||
}
|
||||
|
||||
void
|
||||
vnet_destroy(struct vnet *vnet)
|
||||
{
|
||||
struct ifnet *ifp, *nifp;
|
||||
|
||||
KASSERT(vnet->vnet_sockcnt == 0,
|
||||
("%s: vnet still has sockets", __func__));
|
||||
|
||||
VNET_LIST_WLOCK();
|
||||
LIST_REMOVE(vnet, vnet_le);
|
||||
rw_wunlock(&vnet_rwlock);
|
||||
|
||||
CURVNET_SET_QUIET(vnet);
|
||||
|
||||
/* Return all inherited interfaces to their parent vnets. */
|
||||
TAILQ_FOREACH_SAFE(ifp, &V_ifnet, if_link, nifp) {
|
||||
if (ifp->if_home_vnet != ifp->if_vnet)
|
||||
if_vmove(ifp, ifp->if_home_vnet);
|
||||
}
|
||||
|
||||
vnet_sysuninit();
|
||||
sx_xunlock(&vnet_sxlock);
|
||||
|
||||
CURVNET_RESTORE();
|
||||
|
||||
/* Hopefully, we are OK to free the vnet container itself. */
|
||||
vnet_data_destroy(vnet);
|
||||
vnet->vnet_magic_n = 0xdeadbeef;
|
||||
free(vnet, M_VNET);
|
||||
}
|
||||
|
||||
void
|
||||
vnet_foreach(void (*vnet_foreach_fn)(struct vnet *, void *), void *arg)
|
||||
{
|
||||
struct vnet *vnet;
|
||||
|
||||
VNET_LIST_RLOCK();
|
||||
LIST_FOREACH(vnet, &vnet_head, vnet_le)
|
||||
vnet_foreach_fn(vnet, arg);
|
||||
VNET_LIST_RUNLOCK();
|
||||
}
|
||||
|
||||
static void
|
||||
vnet_init_prelink(void *arg)
|
||||
{
|
||||
|
||||
rw_init(&vnet_rwlock, "vnet_rwlock");
|
||||
sx_init(&vnet_sxlock, "vnet_sxlock");
|
||||
LIST_INIT(&vnet_head);
|
||||
}
|
||||
SYSINIT(vnet_init_prelink, SI_SUB_VNET_PRELINK, SI_ORDER_FIRST,
|
||||
vnet_init_prelink, NULL);
|
||||
|
||||
static void
|
||||
vnet0_init(void *arg)
|
||||
{
|
||||
|
||||
/*
|
||||
* We MUST clear curvnet in vi_init_done() before going SMP,
|
||||
* otherwise CURVNET_SET() macros would scream about unnecessary
|
||||
* curvnet recursions.
|
||||
*/
|
||||
curvnet = prison0.pr_vnet = vnet0 = vnet_alloc();
|
||||
}
|
||||
SYSINIT(vnet0_init, SI_SUB_VNET, SI_ORDER_FIRST, vnet0_init, NULL);
|
||||
|
||||
static void
|
||||
vnet_init_done(void *unused)
|
||||
{
|
||||
|
||||
curvnet = NULL;
|
||||
}
|
||||
|
||||
SYSINIT(vnet_init_done, SI_SUB_VNET_DONE, SI_ORDER_FIRST, vnet_init_done,
|
||||
NULL);
|
||||
|
||||
#ifdef DDB
|
||||
DB_SHOW_COMMAND(vnets, db_show_vnets)
|
||||
{
|
||||
VNET_ITERATOR_DECL(vnet_iter);
|
||||
|
||||
#if SIZE_MAX == UINT32_MAX /* 32-bit arch */
|
||||
db_printf(" vnet ifs socks\n");
|
||||
#else /* 64-bit arch, most probaly... */
|
||||
db_printf(" vnet ifs socks\n");
|
||||
#endif
|
||||
VNET_FOREACH(vnet_iter) {
|
||||
db_printf("%p %3d %5d\n", vnet_iter, vnet_iter->vnet_ifcnt,
|
||||
vnet_iter->vnet_sockcnt);
|
||||
}
|
||||
}
|
||||
#endif
|
|
@ -48,10 +48,10 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/stat.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <security/mac/mac_framework.h>
|
||||
|
||||
|
|
|
@ -43,7 +43,9 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/mutex.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <vm/uma.h>
|
||||
|
||||
/*
|
||||
|
|
|
@ -129,7 +129,8 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sysctl.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <security/mac/mac_framework.h>
|
||||
|
||||
|
|
|
@ -64,12 +64,13 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/syscallsubr.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <sys/vnode.h>
|
||||
#ifdef KTRACE
|
||||
#include <sys/ktrace.h>
|
||||
#endif
|
||||
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <security/audit/audit.h>
|
||||
#include <security/mac/mac_framework.h>
|
||||
|
||||
|
|
|
@ -88,7 +88,8 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/un.h>
|
||||
#include <sys/unpcb.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/vnet.h>
|
||||
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
|
|
|
@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sockio.h>
|
||||
#include <sys/ttycom.h>
|
||||
#include <sys/uio.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <sys/event.h>
|
||||
#include <sys/file.h>
|
||||
|
@ -73,6 +72,7 @@ __FBSDID("$FreeBSD$");
|
|||
#endif
|
||||
#include <net/bpf_zerocopy.h>
|
||||
#include <net/bpfdesc.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/if_ether.h>
|
||||
|
|
|
@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/taskqueue.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
|
|
|
@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_llatbl.h>
|
||||
|
|
|
@ -59,7 +59,6 @@
|
|||
#include <sys/taskqueue.h>
|
||||
#include <sys/domain.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <machine/stdarg.h>
|
||||
#include <vm/uma.h>
|
||||
|
||||
|
|
|
@ -101,7 +101,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
#include <net/if.h>
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include <sys/systm.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_clone.h>
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include <sys/syslog.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if_llc.h>
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_clone.h>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
/*
|
||||
* Things to re-think once we have more experience:
|
||||
* - ifp->if_reassign function once we can test with vimage. Depending on
|
||||
* how if_vomve() is going to be improved.
|
||||
* how if_vmove() is going to be improved.
|
||||
* - Real random etheraddrs that are checked to be uniquish; we would need
|
||||
* to re-do them in case we move the interface between network stacks
|
||||
* in a private if_reassign function.
|
||||
|
@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sockio.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
#include <net/ethernet.h>
|
||||
|
@ -70,6 +69,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <net/if_var.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/netisr.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#define EPAIRNAME "epair"
|
||||
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
#include <sys/queue.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_clone.h>
|
||||
|
@ -62,6 +61,7 @@
|
|||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
#include <net/bpf.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include <sys/proc.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
@ -58,6 +57,7 @@
|
|||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
#include <net/bpf.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -64,13 +64,13 @@
|
|||
#include <sys/sockio.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_clone.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
|
|
|
@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <vm/uma.h>
|
||||
|
||||
|
@ -51,6 +50,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <net/if_dl.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
#include <netinet/if_ether.h>
|
||||
#include <netinet6/in6_var.h>
|
||||
#include <netinet6/nd6.h>
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include <sys/socket.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_clone.h>
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_mib.h>
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <sys/random.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <sys/md5.h>
|
||||
|
||||
|
@ -44,6 +43,7 @@
|
|||
#include <net/netisr.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
|
|
|
@ -92,7 +92,6 @@
|
|||
#include <machine/cpu.h>
|
||||
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_clone.h>
|
||||
|
@ -100,6 +99,7 @@
|
|||
#include <net/netisr.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_stf.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -43,13 +43,13 @@
|
|||
#include <sys/uio.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/random.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_clone.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
#endif
|
||||
|
|
|
@ -55,7 +55,6 @@
|
|||
#include <sys/sockio.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
#include <net/ethernet.h>
|
||||
|
|
|
@ -78,7 +78,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
|
@ -87,6 +86,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/netisr.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
/*-
|
||||
* Synchronize use and modification of the registered netisr data structures;
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/raw_cb.h>
|
||||
|
|
|
@ -44,7 +44,6 @@
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/raw_cb.h>
|
||||
|
|
|
@ -51,11 +51,11 @@
|
|||
#include <sys/proc.h>
|
||||
#include <sys/domain.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#ifdef RADIX_MPATH
|
||||
#include <net/radix_mpath.h>
|
||||
|
|
|
@ -50,7 +50,6 @@
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
|
|
174
sys/net/vnet.c
174
sys/net/vnet.c
|
@ -1,4 +1,12 @@
|
|||
/*-
|
||||
* Copyright (c) 2004-2009 University of Zagreb
|
||||
* Copyright (c) 2006-2009 FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by the University of Zagreb and the
|
||||
* FreeBSD Foundation under sponsorship by the Stichting NLnet and the
|
||||
* FreeBSD Foundation.
|
||||
*
|
||||
* Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org>
|
||||
* Copyright (c) 2009 Robert N. M. Watson
|
||||
* All rights reserved.
|
||||
|
@ -28,30 +36,67 @@
|
|||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/jail.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/linker_set.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sx.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
#endif
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
/*-
|
||||
* This file implements core functions for virtual network stacks:
|
||||
*
|
||||
* - Core virtual network stack management functions.
|
||||
*
|
||||
* - Virtual network stack memory allocator, which virtualized global
|
||||
* variables in the network stack
|
||||
*
|
||||
* - Virtualized SYSINIT's/SYSUNINIT's, which allow network stack subsystems
|
||||
* to register startup/shutdown events to be run for each virtual network
|
||||
* stack instance.
|
||||
*
|
||||
*/
|
||||
|
||||
MALLOC_DEFINE(M_VNET, "vnet", "network stack control block");
|
||||
|
||||
/*
|
||||
* The virtual network stack list has two read-write locks, one sleepable and
|
||||
* the other not, so that the list can be stablized and walked in a variety
|
||||
* of network stack contexts. Both must be acquired exclusively to modify
|
||||
* the list.
|
||||
*/
|
||||
struct rwlock vnet_rwlock;
|
||||
struct sx vnet_sxlock;
|
||||
|
||||
#define VNET_LIST_WLOCK() do { \
|
||||
sx_xlock(&vnet_sxlock); \
|
||||
rw_wlock(&vnet_rwlock); \
|
||||
} while (0)
|
||||
|
||||
#define VNET_LIST_WUNLOCK() do { \
|
||||
rw_wunlock(&vnet_rwlock); \
|
||||
sx_xunlock(&vnet_sxlock); \
|
||||
} while (0)
|
||||
|
||||
struct vnet_list_head vnet_head;
|
||||
struct vnet *vnet0;
|
||||
|
||||
/*
|
||||
* The virtual network stack allocator provides storage for virtualized
|
||||
* global variables. These variables are defined/declared using the
|
||||
* VNET_DEFINE()/VNET_DECLARE() macros, which place them in the 'set_vnet'
|
||||
|
@ -156,6 +201,114 @@ static TAILQ_HEAD(, vnet_data_free) vnet_data_free_head =
|
|||
TAILQ_HEAD_INITIALIZER(vnet_data_free_head);
|
||||
static struct sx vnet_data_free_lock;
|
||||
|
||||
/*
|
||||
* Allocate a virtual network stack.
|
||||
*/
|
||||
struct vnet *
|
||||
vnet_alloc(void)
|
||||
{
|
||||
struct vnet *vnet;
|
||||
|
||||
vnet = malloc(sizeof(struct vnet), M_VNET, M_WAITOK | M_ZERO);
|
||||
vnet->vnet_magic_n = VNET_MAGIC_N;
|
||||
vnet_data_init(vnet);
|
||||
|
||||
/* Initialize / attach vnet module instances. */
|
||||
CURVNET_SET_QUIET(vnet);
|
||||
|
||||
sx_xlock(&vnet_sxlock);
|
||||
vnet_sysinit();
|
||||
CURVNET_RESTORE();
|
||||
|
||||
rw_wlock(&vnet_rwlock);
|
||||
LIST_INSERT_HEAD(&vnet_head, vnet, vnet_le);
|
||||
VNET_LIST_WUNLOCK();
|
||||
|
||||
return (vnet);
|
||||
}
|
||||
|
||||
/*
|
||||
* Destroy a virtual network stack.
|
||||
*/
|
||||
void
|
||||
vnet_destroy(struct vnet *vnet)
|
||||
{
|
||||
struct ifnet *ifp, *nifp;
|
||||
|
||||
KASSERT(vnet->vnet_sockcnt == 0,
|
||||
("%s: vnet still has sockets", __func__));
|
||||
|
||||
VNET_LIST_WLOCK();
|
||||
LIST_REMOVE(vnet, vnet_le);
|
||||
rw_wunlock(&vnet_rwlock);
|
||||
|
||||
CURVNET_SET_QUIET(vnet);
|
||||
|
||||
/* Return all inherited interfaces to their parent vnets. */
|
||||
TAILQ_FOREACH_SAFE(ifp, &V_ifnet, if_link, nifp) {
|
||||
if (ifp->if_home_vnet != ifp->if_vnet)
|
||||
if_vmove(ifp, ifp->if_home_vnet);
|
||||
}
|
||||
|
||||
vnet_sysuninit();
|
||||
sx_xunlock(&vnet_sxlock);
|
||||
|
||||
CURVNET_RESTORE();
|
||||
|
||||
/* Hopefully, we are OK to free the vnet container itself. */
|
||||
vnet_data_destroy(vnet);
|
||||
vnet->vnet_magic_n = 0xdeadbeef;
|
||||
free(vnet, M_VNET);
|
||||
}
|
||||
|
||||
static void
|
||||
vnet_foreach(void (*vnet_foreach_fn)(struct vnet *, void *), void *arg)
|
||||
{
|
||||
struct vnet *vnet;
|
||||
|
||||
VNET_LIST_RLOCK();
|
||||
LIST_FOREACH(vnet, &vnet_head, vnet_le)
|
||||
vnet_foreach_fn(vnet, arg);
|
||||
VNET_LIST_RUNLOCK();
|
||||
}
|
||||
|
||||
/*
|
||||
* Boot time initialization and allocation of virtual network stacks.
|
||||
*/
|
||||
static void
|
||||
vnet_init_prelink(void *arg)
|
||||
{
|
||||
|
||||
rw_init(&vnet_rwlock, "vnet_rwlock");
|
||||
sx_init(&vnet_sxlock, "vnet_sxlock");
|
||||
LIST_INIT(&vnet_head);
|
||||
}
|
||||
SYSINIT(vnet_init_prelink, SI_SUB_VNET_PRELINK, SI_ORDER_FIRST,
|
||||
vnet_init_prelink, NULL);
|
||||
|
||||
static void
|
||||
vnet0_init(void *arg)
|
||||
{
|
||||
|
||||
/*
|
||||
* We MUST clear curvnet in vi_init_done() before going SMP,
|
||||
* otherwise CURVNET_SET() macros would scream about unnecessary
|
||||
* curvnet recursions.
|
||||
*/
|
||||
curvnet = prison0.pr_vnet = vnet0 = vnet_alloc();
|
||||
}
|
||||
SYSINIT(vnet0_init, SI_SUB_VNET, SI_ORDER_FIRST, vnet0_init, NULL);
|
||||
|
||||
static void
|
||||
vnet_init_done(void *unused)
|
||||
{
|
||||
|
||||
curvnet = NULL;
|
||||
}
|
||||
|
||||
SYSINIT(vnet_init_done, SI_SUB_VNET_DONE, SI_ORDER_FIRST, vnet_init_done,
|
||||
NULL);
|
||||
|
||||
/*
|
||||
* Allocate storage for virtualized global variables in a new virtual network
|
||||
* stack instance, and copy in initial values from our 'master' copy.
|
||||
|
@ -490,3 +643,20 @@ vnet_sysuninit(void)
|
|||
vs->func(vs->arg);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DDB
|
||||
DB_SHOW_COMMAND(vnets, db_show_vnets)
|
||||
{
|
||||
VNET_ITERATOR_DECL(vnet_iter);
|
||||
|
||||
#if SIZE_MAX == UINT32_MAX /* 32-bit arch */
|
||||
db_printf(" vnet ifs socks\n");
|
||||
#else /* 64-bit arch, most probaly... */
|
||||
db_printf(" vnet ifs socks\n");
|
||||
#endif
|
||||
VNET_FOREACH(vnet_iter) {
|
||||
db_printf("%p %3d %5d\n", vnet_iter, vnet_iter->vnet_ifcnt,
|
||||
vnet_iter->vnet_sockcnt);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
155
sys/net/vnet.h
155
sys/net/vnet.h
|
@ -1,4 +1,12 @@
|
|||
/*-
|
||||
* Copyright (c) 2006-2009 University of Zagreb
|
||||
* Copyright (c) 2006-2009 FreeBSD Foundation
|
||||
* All rights reserved.
|
||||
*
|
||||
* This software was developed by the University of Zagreb and the
|
||||
* FreeBSD Foundation under sponsorship by the Stichting NLnet and the
|
||||
* FreeBSD Foundation.
|
||||
*
|
||||
* Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org>
|
||||
* Copyright (c) 2009 Robert N. M. Watson
|
||||
* All rights reserved.
|
||||
|
@ -31,6 +39,9 @@
|
|||
* This header file defines several sets of interfaces supporting virtualized
|
||||
* network stacks:
|
||||
*
|
||||
* - Definition of 'struct vnet' and functions and macros to allocate/free/
|
||||
* manipulate it.
|
||||
*
|
||||
* - A virtual network stack memory allocator, which provides support for
|
||||
* virtualized global variables via a special linker set, set_vnet.
|
||||
*
|
||||
|
@ -47,17 +58,133 @@
|
|||
#define _NET_VNET_H_
|
||||
|
||||
/*
|
||||
* Virtual network stack memory allocator, which allows global variables to
|
||||
* be automatically instantiated for each network stack instance.
|
||||
* struct vnet describes a virtualized network stack, and is primarily a
|
||||
* pointer to storage for virtualized global variables. Expose to userspace
|
||||
* as required for libkvm.
|
||||
*/
|
||||
#if defined(_KERNEL) || defined(_WANT_VNET)
|
||||
#include <sys/queue.h>
|
||||
|
||||
struct vnet {
|
||||
LIST_ENTRY(vnet) vnet_le; /* all vnets list */
|
||||
u_int vnet_magic_n;
|
||||
u_int vnet_ifcnt;
|
||||
u_int vnet_sockcnt;
|
||||
void *vnet_data_mem;
|
||||
uintptr_t vnet_data_base;
|
||||
};
|
||||
#define VNET_MAGIC_N 0x3e0d8f29
|
||||
|
||||
/*
|
||||
* These two virtual network stack allocator definitions are also required
|
||||
* for libkvm so that it can evaluate virtualized global variables.
|
||||
*/
|
||||
#define VNET_SETNAME "set_vnet"
|
||||
#define VNET_SYMPREFIX "vnet_entry_"
|
||||
#endif
|
||||
|
||||
#ifdef _KERNEL
|
||||
#ifdef VIMAGE
|
||||
|
||||
#ifdef VIMAGE
|
||||
#include <sys/lock.h>
|
||||
#include <sys/proc.h> /* for struct thread */
|
||||
#include <sys/rwlock.h>
|
||||
#include <sys/sx.h>
|
||||
|
||||
/*
|
||||
* Functions to allocate and destroy virtual network stacks.
|
||||
*/
|
||||
struct vnet *vnet_alloc(void);
|
||||
void vnet_destroy(struct vnet *vnet);
|
||||
|
||||
/*
|
||||
* The current virtual network stack -- we may wish to move this to struct
|
||||
* pcpu in the future.
|
||||
*/
|
||||
#define curvnet curthread->td_vnet
|
||||
|
||||
/*
|
||||
* Various macros -- get and set the current network stack, but also
|
||||
* assertions.
|
||||
*/
|
||||
#ifdef INVARIANTS
|
||||
#define VNET_DEBUG
|
||||
#endif
|
||||
#ifdef VNET_DEBUG
|
||||
#define VNET_ASSERT(condition) \
|
||||
if (!(condition)) { \
|
||||
printf("VNET_ASSERT @ %s:%d %s():\n", \
|
||||
__FILE__, __LINE__, __FUNCTION__); \
|
||||
panic(#condition); \
|
||||
}
|
||||
|
||||
#define CURVNET_SET_QUIET(arg) \
|
||||
VNET_ASSERT((arg)->vnet_magic_n == VNET_MAGIC_N); \
|
||||
struct vnet *saved_vnet = curvnet; \
|
||||
const char *saved_vnet_lpush = curthread->td_vnet_lpush; \
|
||||
curvnet = arg; \
|
||||
curthread->td_vnet_lpush = __FUNCTION__;
|
||||
|
||||
#define CURVNET_SET_VERBOSE(arg) \
|
||||
CURVNET_SET_QUIET(arg) \
|
||||
if (saved_vnet) \
|
||||
printf("CURVNET_SET(%p) in %s() on cpu %d, prev %p in %s()\n", \
|
||||
curvnet, curthread->td_vnet_lpush, curcpu, \
|
||||
saved_vnet, saved_vnet_lpush);
|
||||
|
||||
#define CURVNET_SET(arg) CURVNET_SET_VERBOSE(arg)
|
||||
|
||||
#define CURVNET_RESTORE() \
|
||||
VNET_ASSERT(saved_vnet == NULL || \
|
||||
saved_vnet->vnet_magic_n == VNET_MAGIC_N); \
|
||||
curvnet = saved_vnet; \
|
||||
curthread->td_vnet_lpush = saved_vnet_lpush;
|
||||
#else /* !VNET_DEBUG */
|
||||
#define VNET_ASSERT(condition)
|
||||
|
||||
#define CURVNET_SET(arg) \
|
||||
struct vnet *saved_vnet = curvnet; \
|
||||
curvnet = arg;
|
||||
|
||||
#define CURVNET_SET_VERBOSE(arg) CURVNET_SET(arg)
|
||||
#define CURVNET_SET_QUIET(arg) CURVNET_SET(arg)
|
||||
|
||||
#define CURVNET_RESTORE() \
|
||||
curvnet = saved_vnet;
|
||||
#endif /* VNET_DEBUG */
|
||||
|
||||
extern struct vnet *vnet0;
|
||||
#define IS_DEFAULT_VNET(arg) ((arg) == vnet0)
|
||||
|
||||
#define CRED_TO_VNET(cr) (cr)->cr_prison->pr_vnet
|
||||
#define TD_TO_VNET(td) CRED_TO_VNET((td)->td_ucred)
|
||||
#define P_TO_VNET(p) CRED_TO_VNET((p)->p_ucred)
|
||||
|
||||
/*
|
||||
* Global linked list of all virtual network stacks, along with read locks to
|
||||
* access it. If a caller may sleep while accessing the list, it must use
|
||||
* the sleepable lock macros.
|
||||
*/
|
||||
LIST_HEAD(vnet_list_head, vnet);
|
||||
extern struct vnet_list_head vnet_head;
|
||||
extern struct rwlock vnet_rwlock;
|
||||
extern struct sx vnet_sxlock;
|
||||
|
||||
#define VNET_LIST_RLOCK() sx_slock(&vnet_sxlock)
|
||||
#define VNET_LIST_RLOCK_NOSLEEP() rw_rlock(&vnet_rwlock)
|
||||
#define VNET_LIST_RUNLOCK() sx_sunlock(&vnet_sxlock)
|
||||
#define VNET_LIST_RUNLOCK_NOSLEEP() rw_runlock(&vnet_rwlock)
|
||||
|
||||
/*
|
||||
* Iteration macros to walk the global list of virtual network stacks.
|
||||
*/
|
||||
#define VNET_ITERATOR_DECL(arg) struct vnet *arg
|
||||
#define VNET_FOREACH(arg) LIST_FOREACH((arg), &vnet_head, vnet_le)
|
||||
|
||||
/*
|
||||
* Virtual network stack memory allocator, which allows global variables to
|
||||
* be automatically instantiated for each network stack instance.
|
||||
*/
|
||||
#if defined(__arm__)
|
||||
__asm__(".section " VNET_SETNAME ", \"aw\", %progbits");
|
||||
#else
|
||||
|
@ -192,6 +319,28 @@ void vnet_deregister_sysuninit(void *arg);
|
|||
|
||||
#else /* !VIMAGE */
|
||||
|
||||
/*
|
||||
* Various virtual network stack macros compile to no-ops without VIMAGE.
|
||||
*/
|
||||
#define curvnet NULL
|
||||
|
||||
#define VNET_ASSERT(condition)
|
||||
#define CURVNET_SET(arg)
|
||||
#define CURVNET_SET_QUIET(arg)
|
||||
#define CURVNET_RESTORE()
|
||||
|
||||
#define VNET_LIST_RLOCK()
|
||||
#define VNET_LIST_RLOCK_NOSLEEP()
|
||||
#define VNET_LIST_RUNLOCK()
|
||||
#define VNET_LIST_RUNLOCK_NOSLEEP()
|
||||
#define VNET_ITERATOR_DECL(arg)
|
||||
#define VNET_FOREACH(arg)
|
||||
|
||||
#define IS_DEFAULT_VNET(arg) 1
|
||||
#define CRED_TO_VNET(cr) NULL
|
||||
#define TD_TO_VNET(td) NULL
|
||||
#define P_TO_VNET(p) NULL
|
||||
|
||||
/*
|
||||
* Versions of the VNET macros that compile to normal global variables and
|
||||
* standard sysctl definitions.
|
||||
|
|
|
@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/systm.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
|
|
|
@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sysctl.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
#include <net/if.h>
|
||||
|
@ -51,6 +50,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <net/if_types.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <net80211/ieee80211_var.h>
|
||||
#include <net80211/ieee80211_input.h>
|
||||
|
|
|
@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sbuf.h>
|
||||
#include <sys/ioccom.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
|
|
|
@ -61,7 +61,6 @@
|
|||
#include <sys/syslog.h>
|
||||
#include <sys/refcount.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/kthread.h>
|
||||
#include <sys/smp.h>
|
||||
|
|
|
@ -69,10 +69,10 @@
|
|||
#include <sys/syslog.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ctype.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/ip_fw.h>
|
||||
|
|
|
@ -35,10 +35,10 @@
|
|||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
|
|
|
@ -52,9 +52,9 @@
|
|||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
|
|
|
@ -76,7 +76,6 @@
|
|||
#include <sys/errno.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
|
|
|
@ -64,12 +64,12 @@
|
|||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/random.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/libkern.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
|
|
|
@ -46,10 +46,11 @@
|
|||
#include <sys/malloc.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <vm/uma.h>
|
||||
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
#include <netinet/ip.h>
|
||||
|
|
|
@ -66,9 +66,9 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/mbuf.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/vnet.h>
|
||||
#include <netgraph/ng_message.h>
|
||||
#include <netgraph/netgraph.h>
|
||||
#include <netgraph/ng_parse.h>
|
||||
|
|
|
@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/proc.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_dl.h>
|
||||
|
@ -60,6 +59,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <net/if_llc.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_var.h>
|
||||
|
|
|
@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/protosw.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/condvar.h>
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/proc.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_var.h>
|
||||
|
|
|
@ -46,10 +46,10 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sysctl.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <sys/ktr.h>
|
||||
#include <sys/tree.h>
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/jail.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#ifdef DDB
|
||||
#include <ddb/ddb.h>
|
||||
|
@ -62,6 +61,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_pcb.h>
|
||||
|
|
|
@ -50,13 +50,13 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/protosw.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#ifdef RADIX_MPATH
|
||||
#include <net/radix_mpath.h>
|
||||
#endif
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -51,10 +51,10 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/mbuf.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/callout.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_var.h>
|
||||
|
|
|
@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$");
|
|||
|
||||
#include <sys/socket.h>
|
||||
#include <sys/vnode.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <machine/stdarg.h>
|
||||
|
||||
|
@ -65,6 +64,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <net/if_dl.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#ifdef INET
|
||||
#include <netinet/in.h>
|
||||
|
|
|
@ -59,13 +59,13 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sx.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <vm/uma.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_pcb.h>
|
||||
|
|
|
@ -87,7 +87,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/protosw.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/pfil.h>
|
||||
#include <net/if.h>
|
||||
|
@ -95,6 +94,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <net/if_var.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/time.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
|
|
|
@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/rwlock.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/pfil.h>
|
||||
#include <net/if.h>
|
||||
|
|
|
@ -43,7 +43,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
|
|
|
@ -93,11 +93,11 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/syslog.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/netisr.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/igmp.h>
|
||||
|
|
|
@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/kernel.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
|
@ -52,6 +51,7 @@ __FBSDID("$FreeBSD$");
|
|||
#include <net/if_dl.h>
|
||||
#include <net/route.h>
|
||||
#include <net/netisr.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/netisr.h>
|
||||
|
|
|
@ -63,7 +63,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sysctl.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <net/ethernet.h> /* for ETHERTYPE_IP */
|
||||
#include <net/if.h>
|
||||
#include <net/radix.h>
|
||||
|
|
|
@ -45,7 +45,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sysctl.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <netinet/libalias/alias.h>
|
||||
#include <netinet/libalias/alias_local.h>
|
||||
|
|
|
@ -49,7 +49,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
|
|
|
@ -52,7 +52,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sx.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <vm/uma.h>
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/random.h>
|
||||
#include <sys/limits.h>
|
||||
#include <sys/queue.h>
|
||||
#include <sys/vimage.h>
|
||||
#include <machine/cpu.h>
|
||||
|
||||
#include <net/if.h>
|
||||
|
|
|
@ -76,10 +76,10 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -50,7 +50,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sysctl.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <machine/cpu.h> /* before tcp_seq.h, for tcp_random18() */
|
||||
|
||||
|
@ -58,6 +57,7 @@ __FBSDID("$FreeBSD$");
|
|||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#define TCPSTATES /* for logging */
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/mbuf.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_types.h>
|
||||
#include <net/if_var.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -48,10 +48,10 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socket.h>
|
||||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -45,12 +45,12 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/sysctl.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <vm/uma.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_pcb.h>
|
||||
|
|
|
@ -89,7 +89,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <machine/cpu.h> /* before tcp_seq.h, for tcp_random18() */
|
||||
|
||||
|
@ -97,6 +96,7 @@ __FBSDID("$FreeBSD$");
|
|||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -55,12 +55,12 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/protosw.h>
|
||||
#include <sys/random.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <vm/uma.h>
|
||||
|
||||
#include <net/route.h>
|
||||
#include <net/if.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_systm.h>
|
||||
|
|
|
@ -53,7 +53,6 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/syslog.h>
|
||||
#include <sys/ucred.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <vm/uma.h>
|
||||
|
||||
|
|
|
@ -45,10 +45,10 @@ __FBSDID("$FreeBSD$");
|
|||
#include <sys/socketvar.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/vimage.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/route.h>
|
||||
#include <net/vnet.h>
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <netinet/in_pcb.h>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue