Build on Jeff Roberson's linker-set based dynamic per-CPU allocator

(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator.  Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...).  This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.

Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack.  Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory.  Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.

Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy.  Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address.  When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.

This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.

Bump __FreeBSD_version and update UPDATING.

Portions submitted by:  bz
Reviewed by:            bz, zec
Discussed with:         gnn, jamie, jeff, jhb, julian, sam
Suggested by:           peter
Approved by:            re (kensmith)
This commit is contained in:
Robert Watson 2009-07-14 22:48:30 +00:00
parent 2286fe7635
commit eddfbb763d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=195699
168 changed files with 2479 additions and 4286 deletions

View File

@ -14,6 +14,10 @@
# The file is partitioned: OLD_FILES first, then OLD_LIBS and OLD_DIRS last.
#
# 20090713: vimage container structs removed.
OLD_FILES+=usr/include/netinet/vinet.h
OLD_FILES+=usr/include/netinet6/vinet6.h
OLD_FILES+=usr/include/netipsec/vipsec.h
# 20090709: msgctl.3 msgget.3 msgrcv.3 msgsnd.3 manual pages moved
OLD_FILES+=usr/share/man/man3/msgctl.3.gz
OLD_FILES+=usr/share/man/man3/msgget.3.gz

View File

@ -22,6 +22,11 @@ NOTE TO PEOPLE WHO THINK THAT FreeBSD 8.x IS SLOW:
to maximize performance. (To disable malloc debugging, run
ln -s aj /etc/malloc.conf.)
20090714:
Due to changes in the implementation of virtual network stack
support, all network-related kernel modules must be recompiled.
As this change breaks the ABI, bump __FreeBSD_version to 800104.
20090713:
The TOE interface to the TCP syncache has been modified to remove struct
tcpopt (<netinet/tcp_var.h>) from the ABI of the network stack. The

View File

@ -1078,7 +1078,6 @@ linprocfs_doprocmaps(PFS_FILL_ARGS)
static int
linprocfs_donetdev(PFS_FILL_ARGS)
{
INIT_VNET_NET(TD_TO_VNET(td));
char ifname[16]; /* XXX LINUX_IFNAMSIZ */
struct ifnet *ifp;

View File

@ -2059,7 +2059,6 @@ linux_ioctl_console(struct thread *td, struct linux_ioctl_args *args)
int
linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen)
{
INIT_VNET_NET(ifp->if_vnet);
struct ifnet *ifscan;
int ethno;
@ -2093,7 +2092,6 @@ linux_ifname(struct ifnet *ifp, char *buffer, size_t buflen)
static struct ifnet *
ifname_linux_to_bsd(struct thread *td, const char *lxname, char *bsdname)
{
INIT_VNET_NET(TD_TO_VNET(td));
struct ifnet *ifp;
int len, unit;
char *ep;
@ -2134,7 +2132,6 @@ ifname_linux_to_bsd(struct thread *td, const char *lxname, char *bsdname)
static int
linux_ifconf(struct thread *td, struct ifconf *uifc)
{
INIT_VNET_NET(TD_TO_VNET(td));
#ifdef COMPAT_LINUX32
struct l_ifconf ifc;
#else

View File

@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#include <netinet6/in6_var.h>
#include <netinet6/vinet6.h>
#endif
#ifdef COMPAT_LINUX32
@ -599,11 +598,6 @@ struct linux_socket_args {
static int
linux_socket(struct thread *td, struct linux_socket_args *args)
{
#ifdef INET6
#ifndef KLD_MODULE
INIT_VNET_INET6(curvnet);
#endif
#endif
struct socket_args /* {
int domain;
int type;

View File

@ -89,7 +89,6 @@ svr4_sock_ioctl(fp, td, retval, fd, cmd, data)
switch (cmd) {
case SVR4_SIOCGIFNUM:
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
struct ifaddr *ifa;
int ifnum = 0;

View File

@ -1989,7 +1989,7 @@ kern/kern_time.c standard
kern/kern_timeout.c standard
kern/kern_umtx.c standard
kern/kern_uuid.c standard
kern/kern_vimage.c standard
kern/kern_vimage.c optional vimage
kern/kern_xxx.c standard
kern/link_elf.c standard
kern/linker_if.m standard
@ -2231,6 +2231,7 @@ net/route.c standard
net/rtsock.c standard
net/slcompress.c optional netgraph_vjc | sppp | \
netgraph_sppp
net/vnet.c optional vimage
net/zlib.c optional crypto | geom_uzip | ipsec | \
mxge | netgraph_deflate | \
ddb_ctf

View File

@ -823,7 +823,6 @@ TDMA_TXRATE_11NG_DEFAULT opt_tdma.h
# Virtualize the network stack
VIMAGE opt_global.h
VIMAGE_GLOBALS opt_global.h
# Common Flash Interface (CFI) options
CFI_SUPPORT_STRATAFLASH opt_cfi.h

View File

@ -469,7 +469,6 @@ tbr_timeout(arg)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
INIT_VNET_NET(vnet_iter);
#endif
for (ifp = TAILQ_FIRST(&V_ifnet); ifp;
ifp = TAILQ_NEXT(ifp, if_list)) {

View File

@ -64,6 +64,7 @@ static const char rcsid[] = "@(#)$Id: ip_fil_freebsd.c,v 2.53.2.50 2007/09/20 12
#endif
#if __FreeBSD_version >= 800044
# include <sys/vimage.h>
# include <netinet/tcp_var.h>
#else
#define V_path_mtu_discovery path_mtu_discovery
#define V_ipforwarding ipforwarding
@ -92,9 +93,6 @@ static const char rcsid[] = "@(#)$Id: ip_fil_freebsd.c,v 2.53.2.50 2007/09/20 12
#include <netinet/udp.h>
#include <netinet/tcpip.h>
#include <netinet/ip_icmp.h>
#if defined(__FreeBSD_version) && (__FreeBSD_version >= 800056)
# include <netinet/vinet.h>
#endif
#ifndef _KERNEL
# include "netinet/ipf.h"
#endif
@ -213,7 +211,6 @@ char *s;
int ipfattach()
{
INIT_VNET_INET(curvnet);
#ifdef USE_SPL
int s;
#endif
@ -265,7 +262,6 @@ int ipfattach()
*/
int ipfdetach()
{
INIT_VNET_INET(curvnet);
#ifdef USE_SPL
int s;
#endif
@ -654,7 +650,6 @@ static int fr_send_ip(fin, m, mpp)
fr_info_t *fin;
mb_t *m, **mpp;
{
INIT_VNET_INET(curvnet);
fr_info_t fnew;
ip_t *ip, *oip;
int hlen;

View File

@ -119,9 +119,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/udp_var.h>
#include <netinet/icmp_var.h>
#include <netinet/if_ether.h>
#ifdef __FreeBSD__
#include <netinet/vinet.h>
#endif
#ifndef __FreeBSD__
#include <dev/rndvar.h>
@ -141,7 +138,6 @@ __FBSDID("$FreeBSD$");
#ifdef __FreeBSD__
#include <netinet6/ip6_var.h>
#include <netinet6/in6_pcb.h>
#include <netinet6/vinet6.h>
#endif
#endif /* INET6 */
@ -1762,7 +1758,6 @@ pf_send_tcp(const struct pf_rule *r, sa_family_t af,
u_int8_t flags, u_int16_t win, u_int16_t mss, u_int8_t ttl, int tag,
u_int16_t rtag, struct ether_header *eh, struct ifnet *ifp)
{
INIT_VNET_INET(curvnet);
struct mbuf *m;
int len, tlen;
#ifdef INET
@ -2926,7 +2921,6 @@ pf_socket_lookup(int direction, struct pf_pdesc *pd, struct inpcb *inp_arg)
pf_socket_lookup(int direction, struct pf_pdesc *pd)
#endif
{
INIT_VNET_INET(curvnet);
struct pf_addr *saddr, *daddr;
u_int16_t sport, dport;
#ifdef __FreeBSD__
@ -3096,7 +3090,6 @@ pf_get_wscale(struct mbuf *m, int off, u_int16_t th_off, sa_family_t af)
u_int16_t
pf_get_mss(struct mbuf *m, int off, u_int16_t th_off, sa_family_t af)
{
INIT_VNET_INET(curvnet);
int hlen;
u_int8_t hdr[60];
u_int8_t *opt, optlen;
@ -3136,7 +3129,6 @@ u_int16_t
pf_calc_mss(struct pf_addr *addr, sa_family_t af, u_int16_t offer)
{
#ifdef INET
INIT_VNET_INET(curvnet);
struct sockaddr_in *dst;
struct route ro;
#endif /* INET */
@ -3239,7 +3231,6 @@ pf_test_tcp(struct pf_rule **rm, struct pf_state **sm, int direction,
struct ifqueue *ifq)
#endif
{
INIT_VNET_INET(curvnet);
struct pf_rule *nr = NULL;
struct pf_addr *saddr = pd->src, *daddr = pd->dst;
struct tcphdr *th = pd->hdr.tcp;
@ -6094,7 +6085,6 @@ void
pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
struct pf_state *s, struct pf_pdesc *pd)
{
INIT_VNET_INET(curvnet);
struct mbuf *m0, *m1;
struct route iproute;
struct route *ro = NULL;
@ -6633,26 +6623,22 @@ pf_check_proto_cksum(struct mbuf *m, int off, int len, u_int8_t p, sa_family_t a
switch (p) {
case IPPROTO_TCP:
{
INIT_VNET_INET(curvnet);
TCPSTAT_INC(tcps_rcvbadsum);
break;
}
case IPPROTO_UDP:
{
INIT_VNET_INET(curvnet);
UDPSTAT_INC(udps_badsum);
break;
}
case IPPROTO_ICMP:
{
INIT_VNET_INET(curvnet);
ICMPSTAT_INC(icps_checksum);
break;
}
#ifdef INET6
case IPPROTO_ICMPV6:
{
INIT_VNET_INET6(curvnet);
ICMP6STAT_INC(icp6s_checksum);
break;
}

View File

@ -115,9 +115,6 @@ void pfi_change_group_event(void * __unused, char *);
void pfi_detach_group_event(void * __unused, struct ifg_group *);
void pfi_ifaddr_event(void * __unused, struct ifnet *);
#ifdef VIMAGE_GLOBALS
extern struct ifgrouphead ifg_head;
#endif
#endif
RB_PROTOTYPE(pfi_ifhead, pfi_kif, pfik_tree, pfi_if_compare);
@ -129,7 +126,6 @@ RB_GENERATE(pfi_ifhead, pfi_kif, pfik_tree, pfi_if_compare);
void
pfi_initialize(void)
{
INIT_VNET_NET(curvnet);
if (pfi_all != NULL) /* already initialized */
return;

View File

@ -3703,7 +3703,6 @@ static int
pf_check6_in(void *arg, struct mbuf **m, struct ifnet *ifp, int dir,
struct inpcb *inp)
{
INIT_VNET_NET(curvnet);
/*
* IPv6 is not affected by ip_len/ip_off byte order changes.

View File

@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/if_ether.h>
#include <netinet/vinet.h>
#include <net/pfvar.h>
/*

View File

@ -1855,12 +1855,4 @@ int pf_osfp_match(struct pf_osfp_enlist *, pf_osfp_t);
struct pf_os_fingerprint *
pf_osfp_validate(void);
/*
* Symbol translation macros
*/
#define INIT_VNET_PF(vnet) \
INIT_FROM_VNET(vnet, VNET_MOD_PF, struct vnet_pf, vnet_pf)
#define VNET_PF(sym) VSYM(vnet_pf, sym)
#endif /* _NET_PFVAR_H_ */

View File

@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/in_pcb.h>
#include <netinet/vinet.h>
#include <contrib/rdma/rdma_cm.h>
#include <contrib/rdma/ib_cache.h>
@ -1950,7 +1949,6 @@ static int cma_alloc_port(struct kvl *ps, struct rdma_id_private *id_priv,
static int cma_alloc_any_port(struct kvl *ps, struct rdma_id_private *id_priv)
{
INIT_VNET_INET(curvnet);
struct rdma_bind_list *bind_list;
int port, ret;
@ -1995,7 +1993,6 @@ static int cma_alloc_any_port(struct kvl *ps, struct rdma_id_private *id_priv)
static int cma_use_port(struct kvl *ps, struct rdma_id_private *id_priv)
{
INIT_VNET_INET(curvnet);
struct rdma_id_private *cur_id;
struct sockaddr_in *sin, *cur_sin;
struct rdma_bind_list *bind_list;
@ -2915,7 +2912,6 @@ static void cma_remove_one(struct ib_device *device)
static int cma_init(void)
{
INIT_VNET_INET(curvnet);
int ret;
LIST_INIT(&listen_any_list);

View File

@ -51,7 +51,9 @@ db_term(db_expr_t *valuep)
t = db_read_token();
if (t == tIDENT) {
if (!db_value_of_name(db_tok_string, valuep)) {
if (!db_value_of_name(db_tok_string, valuep) &&
!db_value_of_name_pcpu(db_tok_string, valuep) &&
!db_value_of_name_vnet(db_tok_string, valuep)) {
db_error("Symbol not found\n");
/*NOTREACHED*/
}

View File

@ -32,10 +32,15 @@
__FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/smp.h>
#include <sys/systm.h>
#include <sys/vimage.h>
#include <net/vnet.h>
#include <ddb/ddb.h>
#include <ddb/db_sym.h>
#include <ddb/db_variables.h>
#include <opt_ddb.h>
@ -56,6 +61,117 @@ static char *db_qualify(c_db_sym_t sym, char *symtabname);
static boolean_t db_symbol_is_ambiguous(c_db_sym_t sym);
static boolean_t db_line_at_pc(c_db_sym_t, char **, int *, db_expr_t);
static int db_cpu = -1;
#ifdef VIMAGE
extern uintptr_t *__start_set_vnet;
extern uintptr_t *__stop_set_vnet;
#define VNET_START (uintptr_t)&__start_set_vnet
#define VNET_STOP (uintptr_t)&__stop_set_vnet
static void *db_vnet = NULL;
#endif
/*
* Validate the CPU number used to interpret per-CPU variables so we can
* avoid later confusion if an invalid CPU is requested.
*/
int
db_var_db_cpu(struct db_variable *vp, db_expr_t *valuep, int op)
{
switch (op) {
case DB_VAR_GET:
*valuep = db_cpu;
return (1);
case DB_VAR_SET:
if (*(int *)valuep < -1 && *(int *)valuep > mp_maxid) {
db_printf("Invalid value: %d", *(int*)valuep);
return (0);
}
db_cpu = *(int *)valuep;
return (1);
default:
db_printf("db_var_db_cpu: unknown operation\n");
return (0);
}
}
/*
* Read-only variable reporting the current CPU, which is what we use when
* db_cpu is set to -1.
*/
int
db_var_curcpu(struct db_variable *vp, db_expr_t *valuep, int op)
{
switch (op) {
case DB_VAR_GET:
*valuep = curcpu;
return (1);
case DB_VAR_SET:
db_printf("Read-only variable.\n");
return (0);
default:
db_printf("db_var_curcpu: unknown operation\n");
return (0);
}
}
#ifdef VIMAGE
/*
* Validate the virtual network pointer used to interpret per-vnet global
* variable expansion. Right now we don't do much here, really we should
* walk the global vnet list to check it's an OK pointer.
*/
int
db_var_db_vnet(struct db_variable *vp, db_expr_t *valuep, int op)
{
switch (op) {
case DB_VAR_GET:
*valuep = (db_expr_t)db_vnet;
return (1);
case DB_VAR_SET:
db_vnet = *(void **)valuep;
return (1);
default:
db_printf("db_var_db_vnet: unknown operation\n");
return (0);
}
}
/*
* Read-only variable reporting the current vnet, which is what we use when
* db_vnet is set to NULL.
*/
int
db_var_curvnet(struct db_variable *vp, db_expr_t *valuep, int op)
{
switch (op) {
case DB_VAR_GET:
*valuep = (db_expr_t)curvnet;
return (1);
case DB_VAR_SET:
db_printf("Read-only variable.\n");
return (0);
default:
db_printf("db_var_curcpu: unknown operation\n");
return (0);
}
}
#endif
/*
* Add symbol table, with given name, to list of symbol tables.
*/
@ -125,6 +241,59 @@ db_value_of_name(name, valuep)
return (TRUE);
}
boolean_t
db_value_of_name_pcpu(name, valuep)
const char *name;
db_expr_t *valuep;
{
static char tmp[256];
db_expr_t value;
c_db_sym_t sym;
int cpu;
if (db_cpu != -1)
cpu = db_cpu;
else
cpu = curcpu;
snprintf(tmp, sizeof(tmp), "pcpu_entry_%s", name);
sym = db_lookup(tmp);
if (sym == C_DB_SYM_NULL)
return (FALSE);
db_symbol_values(sym, &name, &value);
if (value < DPCPU_START || value >= DPCPU_STOP)
return (FALSE);
*valuep = (db_expr_t)((uintptr_t)value + dpcpu_off[cpu]);
return (TRUE);
}
boolean_t
db_value_of_name_vnet(name, valuep)
const char *name;
db_expr_t *valuep;
{
#ifdef VIMAGE
static char tmp[256];
db_expr_t value;
c_db_sym_t sym;
struct vnet *vnet;
if (db_vnet != NULL)
vnet = db_vnet;
else
vnet = curvnet;
snprintf(tmp, sizeof(tmp), "vnet_entry_%s", name);
sym = db_lookup(tmp);
if (sym == C_DB_SYM_NULL)
return (FALSE);
db_symbol_values(sym, &name, &value);
if (value < VNET_START || value >= VNET_STOP)
return (FALSE);
*valuep = (db_expr_t)((uintptr_t)value + vnet->vnet_data_base);
return (TRUE);
#else
return (FALSE);
#endif
}
/*
* Lookup a symbol.

View File

@ -46,6 +46,12 @@ static struct db_variable db_vars[] = {
{ "maxwidth", &db_max_width, FCN_NULL },
{ "tabstops", &db_tab_stop_width, FCN_NULL },
{ "lines", &db_lines_per_page, FCN_NULL },
{ "curcpu", NULL, db_var_curcpu },
{ "db_cpu", NULL, db_var_db_cpu },
#ifdef VIMAGE
{ "curvnet", NULL, db_var_curvnet },
{ "db_vnet", NULL, db_var_db_vnet },
#endif
};
static struct db_variable *db_evars =
db_vars + sizeof(db_vars)/sizeof(db_vars[0]);

View File

@ -52,6 +52,11 @@ struct db_variable {
extern struct db_variable db_regs[]; /* machine registers */
extern struct db_variable *db_eregs;
extern db_varfcn_t db_var_curcpu; /* DPCPU default CPU */
extern db_varfcn_t db_var_curvnet; /* Default vnet */
extern db_varfcn_t db_var_db_cpu; /* DPCPU active CPU */
extern db_varfcn_t db_var_db_vnet; /* Active vnet */
int db_read_variable(struct db_variable *, db_expr_t *);
int db_write_variable(struct db_variable *, db_expr_t);

View File

@ -213,6 +213,8 @@ boolean_t db_stop_at_pc(boolean_t *is_breakpoint);
void db_trace_self(void);
int db_trace_thread(struct thread *, int);
int db_value_of_name(const char *name, db_expr_t *valuep);
int db_value_of_name_pcpu(const char *name, db_expr_t *valuep);
int db_value_of_name_vnet(const char *name, db_expr_t *valuep);
int db_write_bytes(vm_offset_t addr, size_t size, char *data);
void db_command_register(struct command_table *, struct command *);
void db_command_unregister(struct command_table *, struct command *);

View File

@ -240,7 +240,6 @@ iwch_init_module(void)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter); /* XXX CURVNET_SET_QUIET() ? */
INIT_VNET_NET(vnet_iter);
TAILQ_FOREACH(ifp, &V_ifnet, if_link)
(void)ifaddr_event_handler(NULL, ifp);
CURVNET_RESTORE();

View File

@ -78,9 +78,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/tcp_seq.h>
#include <netinet/tcp_syncache.h>
#include <netinet/tcp_timer.h>
#if __FreeBSD_version >= 800056
#include <netinet/vinet.h>
#endif
#include <net/route.h>
#include <t3cdev.h>
@ -274,7 +271,6 @@ mk_tid_release(struct mbuf *m, const struct toepcb *toep, unsigned int tid)
static inline void
make_tx_data_wr(struct socket *so, struct mbuf *m, int len, struct mbuf *tail)
{
INIT_VNET_INET(so->so_vnet);
struct tcpcb *tp = so_sototcpcb(so);
struct toepcb *toep = tp->t_toe;
struct tx_data_wr *req;
@ -1219,7 +1215,6 @@ install_offload_ops(struct socket *so)
static __inline int
select_rcv_wscale(int space, struct vnet *vnet)
{
INIT_VNET_INET(vnet);
int wscale = 0;
if (space > MAX_RCV_WND)
@ -1237,7 +1232,6 @@ select_rcv_wscale(int space, struct vnet *vnet)
static unsigned long
select_rcv_wnd(struct toedev *dev, struct socket *so)
{
INIT_VNET_INET(so->so_vnet);
struct tom_data *d = TOM_DATA(dev);
unsigned int wnd;
unsigned int max_rcv_wnd;
@ -3780,7 +3774,6 @@ fixup_and_send_ofo(struct toepcb *toep)
static void
socket_act_establish(struct socket *so, struct mbuf *m)
{
INIT_VNET_INET(so->so_vnet);
struct cpl_act_establish *req = cplhdr(m);
u32 rcv_isn = ntohl(req->rcv_isn); /* real RCV_ISN + 1 */
struct tcpcb *tp = so_sototcpcb(so);

View File

@ -95,7 +95,6 @@
#include <netinet/tcp_seq.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/vinet.h>
#include <machine/in_cksum.h>
#include <crypto/des/des.h>
#include <sys/md5.h>

View File

@ -75,7 +75,6 @@ __FBSDID("$FreeBSD$");
#include <fs/nfsclient/nfs_lock.h>
#include <net/if.h>
#include <netinet/vinet.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
@ -1401,7 +1400,6 @@ nfs_create(struct vop_create_args *ap)
CURVNET_SET(P_TO_VNET(&proc0));
#ifdef INET
INIT_VNET_INET(curvnet);
IN_IFADDR_RLOCK();
if (!TAILQ_EMPTY(&V_in_ifaddrhead))
cverf.lval[0] = IA_SIN(TAILQ_FIRST(&V_in_ifaddrhead))->sin_addr.s_addr;

View File

@ -2671,7 +2671,6 @@ nfsrv_v4rootexport(void *argp, struct ucred *cred, struct thread *p)
int
nfsrv_getsocksndseq(struct socket *so, tcp_seq *maxp, tcp_seq *unap)
{
INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
struct tcpcb *tp;
int error = EPIPE;

View File

@ -1334,23 +1334,8 @@ kldsym(struct thread *td, struct kldsym_args *uap)
break;
}
}
#ifndef VIMAGE_GLOBALS
/*
* If the symbol is not found in global namespace,
* try to look it up in the current vimage namespace.
*/
if (lf == NULL) {
CURVNET_SET(TD_TO_VNET(td));
error = vi_symlookup(&lookup, symstr);
CURVNET_RESTORE();
if (error == 0)
error = copyout(&lookup, uap->data,
sizeof(lookup));
}
#else
if (lf == NULL)
error = ENOENT;
#endif
}
KLD_UNLOCK();
out:

View File

@ -545,7 +545,6 @@ ether_poll_deregister(struct ifnet *ifp)
static int
poll_switch(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
int error;
int val = polling;

View File

@ -59,6 +59,8 @@ __FBSDID("$FreeBSD$");
#include <sys/ktrace.h>
#endif
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
@ -936,33 +938,9 @@ sysctl_handle_int(SYSCTL_HANDLER_ARGS)
return (error);
}
#ifdef VIMAGE
int
sysctl_handle_v_int(SYSCTL_HANDLER_ARGS)
{
int tmpout, error = 0;
SYSCTL_RESOLVE_V_ARG1();
/*
* Attempt to get a coherent snapshot by making a copy of the data.
*/
tmpout = *(int *)arg1;
error = SYSCTL_OUT(req, &tmpout, sizeof(int));
if (error || !req->newptr)
return (error);
if (!arg1)
error = EPERM;
else
error = SYSCTL_IN(req, arg1, sizeof(int));
return (error);
}
#endif
/*
* Based on on sysctl_handle_int() convert milliseconds into ticks.
* Note: this is used by TCP.
*/
int
@ -970,8 +948,11 @@ sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS)
{
int error, s, tt;
SYSCTL_RESOLVE_V_ARG1();
#ifdef VIMAGE
if (arg1 != NULL)
arg1 = (void *)(TD_TO_VNET(req->td)->vnet_data_base +
(uintptr_t)arg1);
#endif
tt = *(int *)arg1;
s = (int)((int64_t)tt * 1000 / hz);
@ -1097,47 +1078,6 @@ sysctl_handle_string(SYSCTL_HANDLER_ARGS)
return (error);
}
#ifdef VIMAGE
int
sysctl_handle_v_string(SYSCTL_HANDLER_ARGS)
{
int error=0;
char *tmparg;
size_t outlen;
SYSCTL_RESOLVE_V_ARG1();
/*
* Attempt to get a coherent snapshot by copying to a
* temporary kernel buffer.
*/
retry:
outlen = strlen((char *)arg1)+1;
tmparg = malloc(outlen, M_SYSCTLTMP, M_WAITOK);
if (strlcpy(tmparg, (char *)arg1, outlen) >= outlen) {
free(tmparg, M_SYSCTLTMP);
goto retry;
}
error = SYSCTL_OUT(req, tmparg, outlen);
free(tmparg, M_SYSCTLTMP);
if (error || !req->newptr)
return (error);
if ((req->newlen - req->newidx) >= arg2) {
error = EINVAL;
} else {
arg2 = (req->newlen - req->newidx);
error = SYSCTL_IN(req, arg1, arg2);
((char *)arg1)[arg2] = '\0';
}
return (error);
}
#endif
/*
* Handle any kind of opaque data.
* arg1 points to it, arg2 is the size.
@ -1175,35 +1115,6 @@ sysctl_handle_opaque(SYSCTL_HANDLER_ARGS)
return (error);
}
#ifdef VIMAGE
int
sysctl_handle_v_opaque(SYSCTL_HANDLER_ARGS)
{
int error, tries;
u_int generation;
struct sysctl_req req2;
SYSCTL_RESOLVE_V_ARG1();
tries = 0;
req2 = *req;
retry:
generation = curthread->td_generation;
error = SYSCTL_OUT(req, arg1, arg2);
if (error)
return (error);
tries++;
if (generation != curthread->td_generation && tries < 3) {
*req = req2;
goto retry;
}
error = SYSCTL_IN(req, arg1, arg2);
return (error);
}
#endif
/*
* Transfer functions to/from kernel space.
* XXX: rather untested at this point

View File

@ -89,7 +89,6 @@ MTX_SYSINIT(uuid_lock, &uuid_mutex, "UUID generator mutex lock", MTX_DEF);
static void
uuid_node(uint16_t *node)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
struct ifaddr *ifa;
struct sockaddr_dl *sdl;

View File

@ -53,8 +53,6 @@ __FBSDID("$FreeBSD$");
#include <net/route.h>
#include <net/vnet.h>
#ifndef VIMAGE_GLOBALS
MALLOC_DEFINE(M_VIMAGE, "vimage", "vimage resource container");
MALLOC_DEFINE(M_VNET, "vnet", "network stack control block");
MALLOC_DEFINE(M_VPROCG, "vprocg", "process group control block");
@ -65,13 +63,11 @@ static void vnet_mod_complete_registration(struct vnet_modlink *);
static int vnet_mod_constructor(struct vnet_modlink *);
static int vnet_mod_destructor(struct vnet_modlink *);
#ifdef VIMAGE
static struct vimage *vi_alloc(struct vimage *, char *);
static int vi_destroy(struct vimage *);
static struct vimage *vimage_get_next(struct vimage *, struct vimage *, int);
static void vimage_relative_name(struct vimage *, struct vimage *,
char *, int);
#endif
#define VNET_LIST_WLOCK() \
mtx_lock(&vnet_list_refc_mtx); \
@ -81,17 +77,11 @@ static void vimage_relative_name(struct vimage *, struct vimage *,
#define VNET_LIST_WUNLOCK() \
mtx_unlock(&vnet_list_refc_mtx);
#ifdef VIMAGE
struct vimage_list_head vimage_head;
struct vnet_list_head vnet_head;
struct vprocg_list_head vprocg_head;
#else
#ifndef VIMAGE_GLOBALS
struct vprocg vprocg_0;
#endif
#endif
#ifdef VIMAGE
struct cv vnet_list_condvar;
struct mtx vnet_list_refc_mtx;
int vnet_list_refc = 0;
@ -100,9 +90,7 @@ static u_int last_vi_id = 0;
static u_int last_vprocg_id = 0;
struct vnet *vnet0;
#endif
#ifdef VIMAGE
/*
* Move an ifnet to or from another vnet, specified by the jail id. If a
@ -396,8 +384,6 @@ vimage_get_next(struct vimage *top, struct vimage *where, int recurse)
return (NULL);
}
#endif /* VIMAGE */ /* User interface block */
/*
* Kernel interfaces and handlers.
@ -540,25 +526,11 @@ vnet_mod_constructor(struct vnet_modlink *vml)
if (vml->vml_iarg)
printf("/%s", vml->vml_iname);
printf(": ");
#ifdef VIMAGE
if (vmi->vmi_size)
printf("malloc(%zu); ", vmi->vmi_size);
#endif
if (vmi->vmi_iattach != NULL)
printf("iattach()");
printf("\n");
#endif
#ifdef VIMAGE
if (vmi->vmi_size) {
void *mem = malloc(vmi->vmi_size, M_VNET,
M_NOWAIT | M_ZERO);
if (mem == NULL) /* XXX should return error, not panic. */
panic("malloc for %s\n", vmi->vmi_name);
curvnet->mod_data[vmi->vmi_id] = mem;
}
#endif
if (vmi->vmi_iattach != NULL)
vmi->vmi_iattach(vml->vml_iarg);
@ -577,63 +549,15 @@ vnet_mod_destructor(struct vnet_modlink *vml)
printf(": ");
if (vmi->vmi_idetach != NULL)
printf("idetach(); ");
#ifdef VIMAGE
if (vmi->vmi_size)
printf("free()");
#endif
printf("\n");
#endif
if (vmi->vmi_idetach)
vmi->vmi_idetach(vml->vml_iarg);
#ifdef VIMAGE
if (vmi->vmi_size) {
if (curvnet->mod_data[vmi->vmi_id] == NULL)
panic("vi_destroy: %s\n", vmi->vmi_name);
free(curvnet->mod_data[vmi->vmi_id], M_VNET);
curvnet->mod_data[vmi->vmi_id] = NULL;
}
#endif
return (0);
}
/*
* vi_symlookup() attempts to resolve name to address queries for
* variables which have been moved from global namespace to virtualization
* container structures, but are still directly accessed from legacy
* userspace processes via kldsym(2) and kmem(4) interfaces.
*/
int
vi_symlookup(struct kld_sym_lookup *lookup, char *symstr)
{
struct vnet_modlink *vml;
struct vnet_symmap *mapentry;
TAILQ_FOREACH(vml, &vnet_modlink_head, vml_mod_le) {
if (vml->vml_modinfo->vmi_symmap == NULL)
continue;
for (mapentry = vml->vml_modinfo->vmi_symmap;
mapentry->name != NULL; mapentry++) {
if (strcmp(symstr, mapentry->name) == 0) {
#ifdef VIMAGE
lookup->symvalue =
(u_long) curvnet->mod_data[
vml->vml_modinfo->vmi_id];
lookup->symvalue += mapentry->offset;
#else
lookup->symvalue = (u_long) mapentry->offset;
#endif
lookup->symsize = mapentry->size;
return (0);
}
}
}
return (ENOENT);
}
#ifdef VIMAGE
struct vnet *
vnet_alloc(void)
{
@ -642,6 +566,7 @@ vnet_alloc(void)
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);
@ -669,7 +594,6 @@ vnet_destroy(struct vnet *vnet)
VNET_LIST_WUNLOCK();
CURVNET_SET_QUIET(vnet);
INIT_VNET_NET(vnet);
/* Return all inherited interfaces to their parent vnets. */
TAILQ_FOREACH_SAFE(ifp, &V_ifnet, if_link, nifp) {
@ -685,10 +609,22 @@ vnet_destroy(struct vnet *vnet)
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 struct vimage *
vi_alloc(struct vimage *parent, char *name)
{
@ -757,7 +693,6 @@ vi_destroy(struct vimage *vip)
return (0);
}
#endif /* VIMAGE */
static void
vi_init(void *unused)
@ -766,7 +701,6 @@ vi_init(void *unused)
TAILQ_INIT(&vnet_modlink_head);
TAILQ_INIT(&vnet_modpending_head);
#ifdef VIMAGE
LIST_INIT(&vimage_head);
LIST_INIT(&vprocg_head);
LIST_INIT(&vnet_head);
@ -783,7 +717,6 @@ vi_init(void *unused)
* curvnet recursions.
*/
curvnet = prison0.pr_vnet = vnet0 = LIST_FIRST(&vnet_head);
#endif
}
static void
@ -791,9 +724,7 @@ vi_init_done(void *unused)
{
struct vnet_modlink *vml_iter;
#ifdef VIMAGE
curvnet = NULL;
#endif
if (TAILQ_EMPTY(&vnet_modpending_head))
return;
@ -809,45 +740,21 @@ vi_init_done(void *unused)
SYSINIT(vimage, SI_SUB_VIMAGE, SI_ORDER_FIRST, vi_init, NULL);
SYSINIT(vimage_done, SI_SUB_VIMAGE_DONE, SI_ORDER_FIRST, vi_init_done, NULL);
#endif /* !VIMAGE_GLOBALS */
#ifdef VIMAGE
#ifdef DDB
static void
db_vnet_ptr(void *arg)
{
if (arg)
db_printf(" %p", arg);
else
#if SIZE_MAX == UINT32_MAX /* 32-bit arch */
db_printf(" 0");
#else /* 64-bit arch, most probaly... */
db_printf(" 0");
#endif
}
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");
db_printf(" net inet inet6 ipsec netgraph\n");
#else /* 64-bit arch, most probaly... */
db_printf(" vnet ifs socks");
db_printf(" net inet inet6 ipsec netgraph\n");
#endif
VNET_FOREACH(vnet_iter) {
db_printf("%p %3d %5d",
vnet_iter, vnet_iter->ifcnt, vnet_iter->sockcnt);
db_vnet_ptr(vnet_iter->mod_data[VNET_MOD_NET]);
db_vnet_ptr(vnet_iter->mod_data[VNET_MOD_INET]);
db_vnet_ptr(vnet_iter->mod_data[VNET_MOD_INET6]);
db_vnet_ptr(vnet_iter->mod_data[VNET_MOD_IPSEC]);
db_vnet_ptr(vnet_iter->mod_data[VNET_MOD_NETGRAPH]);
db_printf("\n");
}
}
#endif
#endif /* VIMAGE */

View File

@ -49,6 +49,8 @@ __FBSDID("$FreeBSD$");
#include <machine/elf.h>
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
@ -111,6 +113,11 @@ typedef struct elf_file {
Elf_Addr pcpu_start; /* Pre-relocation pcpu set start. */
Elf_Addr pcpu_stop; /* Pre-relocation pcpu set stop. */
Elf_Addr pcpu_base; /* Relocated pcpu set address. */
#ifdef VIMAGE
Elf_Addr vnet_start; /* Pre-relocation vnet set start. */
Elf_Addr vnet_stop; /* Pre-relocation vnet set stop. */
Elf_Addr vnet_base; /* Relocated vnet set address. */
#endif
#ifdef GDB
struct link_map gdb; /* hooks for gdb */
#endif
@ -506,6 +513,36 @@ parse_dpcpu(elf_file_t ef)
return (0);
}
#ifdef VIMAGE
static int
parse_vnet(elf_file_t ef)
{
int count;
int error;
ef->vnet_start = 0;
ef->vnet_stop = 0;
error = link_elf_lookup_set(&ef->lf, "vnet", (void ***)&ef->vnet_start,
(void ***)&ef->vnet_stop, &count);
/* Error just means there is no vnet data set to relocate. */
if (error)
return (0);
count *= sizeof(void *);
/*
* Allocate space in the primary vnet area. Copy in our initialization
* from the data section and then initialize all per-vnet storage from
* that.
*/
ef->vnet_base = (Elf_Addr)(uintptr_t)vnet_data_alloc(count);
if (ef->vnet_base == (Elf_Addr)NULL)
return (ENOSPC);
memcpy((void *)ef->vnet_base, (void *)ef->vnet_start, count);
vnet_data_copy((void *)ef->vnet_base, count);
return (0);
}
#endif
static int
link_elf_link_preload(linker_class_t cls,
const char* filename, linker_file_t *result)
@ -553,6 +590,10 @@ link_elf_link_preload(linker_class_t cls,
error = parse_dynamic(ef);
if (error == 0)
error = parse_dpcpu(ef);
#ifdef VIMAGE
if (error == 0)
error = parse_vnet(ef);
#endif
if (error) {
linker_file_unload(lf, LINKER_UNLOAD_FORCE);
return error;
@ -838,6 +879,11 @@ link_elf_load_file(linker_class_t cls, const char* filename,
error = parse_dpcpu(ef);
if (error)
goto out;
#ifdef VIMAGE
error = parse_vnet(ef);
if (error)
goto out;
#endif
link_elf_reloc_local(lf);
VOP_UNLOCK(nd.ni_vp, 0);
@ -942,6 +988,10 @@ elf_relocaddr(linker_file_t lf, Elf_Addr x)
ef = (elf_file_t)lf;
if (x >= ef->pcpu_start && x < ef->pcpu_stop)
return ((x - ef->pcpu_start) + ef->pcpu_base);
#ifdef VIMAGE
if (x >= ef->vnet_start && x < ef->vnet_stop)
return ((x - ef->vnet_start) + ef->vnet_base);
#endif
return (x);
}
@ -954,6 +1004,11 @@ link_elf_unload_file(linker_file_t file)
if (ef->pcpu_base) {
dpcpu_free((void *)ef->pcpu_base, ef->pcpu_stop - ef->pcpu_start);
}
#ifdef VIMAGE
if (ef->vnet_base) {
vnet_data_free((void *)ef->vnet_base, ef->vnet_stop - ef->vnet_start);
}
#endif
#ifdef GDB
if (ef->gdb.l_ld) {
GDB_STATE(RT_DELETE);

View File

@ -45,6 +45,8 @@ __FBSDID("$FreeBSD$");
#include <machine/elf.h>
#include <net/vnet.h>
#include <security/mac/mac_framework.h>
#include <vm/vm.h>
@ -346,6 +348,21 @@ link_elf_link_preload(linker_class_t cls, const char *filename,
ef->progtab[pb].size);
dpcpu_copy(dpcpu, shdr[i].sh_size);
ef->progtab[pb].addr = dpcpu;
#ifdef VIMAGE
} else if (ef->progtab[pb].name != NULL &&
!strcmp(ef->progtab[pb].name, "set_vnet")) {
void *vnet_data;
vnet_data = vnet_data_alloc(shdr[i].sh_size);
if (vnet_data == NULL) {
error = ENOSPC;
goto out;
}
memcpy(vnet_data, ef->progtab[pb].addr,
ef->progtab[pb].size);
vnet_data_copy(vnet_data, shdr[i].sh_size);
ef->progtab[pb].addr = vnet_data;
#endif
}
/* Update all symbol values with the offset. */
@ -737,6 +754,12 @@ link_elf_load_file(linker_class_t cls, const char *filename,
!strcmp(ef->progtab[pb].name, "set_pcpu"))
ef->progtab[pb].addr =
dpcpu_alloc(shdr[i].sh_size);
#ifdef VIMAGE
else if (ef->progtab[pb].name != NULL &&
!strcmp(ef->progtab[pb].name, "set_vnet"))
ef->progtab[pb].addr =
vnet_data_alloc(shdr[i].sh_size);
#endif
else
ef->progtab[pb].addr =
(void *)(uintptr_t)mapbase;
@ -758,10 +781,21 @@ link_elf_load_file(linker_class_t cls, const char *filename,
error = EINVAL;
goto out;
}
/* Initialize the per-cpu area. */
if (ef->progtab[pb].addr != (void *)mapbase)
/* Initialize the per-cpu or vnet area. */
if (ef->progtab[pb].addr != (void *)mapbase &&
!strcmp(ef->progtab[pb].name, "set_pcpu"))
dpcpu_copy(ef->progtab[pb].addr,
shdr[i].sh_size);
#ifdef VIMAGE
else if (ef->progtab[pb].addr !=
(void *)mapbase &&
!strcmp(ef->progtab[pb].name, "set_vnet"))
vnet_data_copy(ef->progtab[pb].addr,
shdr[i].sh_size);
#endif
else
panic("link_elf_load_file: unexpected "
"progbits type");
} else
bzero(ef->progtab[pb].addr, shdr[i].sh_size);
@ -877,6 +911,11 @@ link_elf_unload_file(linker_file_t file)
if (!strcmp(ef->progtab[i].name, "set_pcpu"))
dpcpu_free(ef->progtab[i].addr,
ef->progtab[i].size);
#ifdef VIMAGE
else if (!strcmp(ef->progtab[i].name, "set_vnet"))
vnet_data_free(ef->progtab[i].addr,
ef->progtab[i].size);
#endif
}
}
if (ef->preloaded) {

View File

@ -106,14 +106,12 @@ struct pr_usrreqs nousrreqs = {
.pru_sopoll = pru_sopoll_notsupp,
};
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_modinfo_t vnet_domain_modinfo = {
.vmi_id = VNET_MOD_DOMAIN,
.vmi_name = "domain",
.vmi_iattach = net_init_domain,
#ifdef VIMAGE
.vmi_idetach = net_detach_domain,
#endif
};
#endif
@ -249,7 +247,7 @@ net_add_domain(void *data)
"domainfinalize()\n", dp->dom_name);
#endif
mtx_unlock(&dom_mtx);
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register_multi(&vnet_domain_modinfo, dp, dp->dom_name);
#else
net_init_domain(dp);

View File

@ -2006,7 +2006,6 @@ bstp_same_bridgeid(uint64_t id1, uint64_t id2)
void
bstp_reinit(struct bstp_state *bs)
{
INIT_VNET_NET(curvnet);
struct bstp_port *bp;
struct ifnet *ifp, *mif;
u_char *e_addr;

View File

@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/sctp.h>
#include <netinet/vinet.h>
#include <libkern/jenkins.h>
@ -164,29 +163,28 @@ struct flowtable {
};
static struct proc *flowcleanerproc;
#ifdef VIMAGE_GLOBALS
static struct flowtable *flow_list_head;
static uint32_t flow_hashjitter;
static uma_zone_t flow_ipv4_zone;
static uma_zone_t flow_ipv6_zone;
#endif
static VNET_DEFINE(struct flowtable *, flow_list_head);
static VNET_DEFINE(uint32_t, flow_hashjitter);
static VNET_DEFINE(uma_zone_t, flow_ipv4_zone);
static VNET_DEFINE(uma_zone_t, flow_ipv6_zone);
#define V_flow_list_head VNET_GET(flow_list_head)
#define V_flow_hashjitter VNET_GET(flow_hashjitter)
#define V_flow_ipv4_zone VNET_GET(flow_ipv4_zone)
#define V_flow_ipv6_zone VNET_GET(flow_ipv6_zone)
static int flowtable_iattach(const void *);
#ifdef VIMAGE
static int flowtable_idetach(const void *);
#endif
#ifndef VIMAGE_GLOBALS
static const vnet_modinfo_t flowtable_modinfo = {
.vmi_id = VNET_MOD_FLOWTABLE,
.vmi_name = "flowtable",
.vmi_dependson = VNET_MOD_INET,
.vmi_iattach = flowtable_iattach,
#ifdef VIMAGE
.vmi_idetach = flowtable_idetach
#endif
};
#endif /* !VIMAGE_GLOBALS */
#endif
/*
* TODO:
@ -205,54 +203,67 @@ static const vnet_modinfo_t flowtable_modinfo = {
* - support explicit connection state (currently only ad-hoc for DSR)
* - idetach() cleanup for options VIMAGE builds.
*/
#ifdef VIMAGE_GLOBALS
int flowtable_enable;
static int flowtable_hits;
static int flowtable_lookups;
static int flowtable_misses;
static int flowtable_frees;
static int flowtable_free_checks;
static int flowtable_max_depth;
static int flowtable_collisions;
static int flowtable_syn_expire;
static int flowtable_udp_expire;
static int flowtable_fin_wait_expire;
static int flowtable_tcp_expire;
static int flowtable_nmbflows;
#endif
VNET_DEFINE(int, flowtable_enable) = 1;
static VNET_DEFINE(int, flowtable_hits);
static VNET_DEFINE(int, flowtable_lookups);
static VNET_DEFINE(int, flowtable_misses);
static VNET_DEFINE(int, flowtable_frees);
static VNET_DEFINE(int, flowtable_free_checks);
static VNET_DEFINE(int, flowtable_max_depth);
static VNET_DEFINE(int, flowtable_collisions);
static VNET_DEFINE(int, flowtable_syn_expire) = SYN_IDLE;
static VNET_DEFINE(int, flowtable_udp_expire) = UDP_IDLE;
static VNET_DEFINE(int, flowtable_fin_wait_expire) = FIN_WAIT_IDLE;
static VNET_DEFINE(int, flowtable_tcp_expire) = TCP_IDLE;
static VNET_DEFINE(int, flowtable_nmbflows) = 4096;
#define V_flowtable_enable VNET_GET(flowtable_enable)
#define V_flowtable_hits VNET_GET(flowtable_hits)
#define V_flowtable_lookups VNET_GET(flowtable_lookups)
#define V_flowtable_misses VNET_GET(flowtable_misses)
#define V_flowtable_frees VNET_GET(flowtable_frees)
#define V_flowtable_free_checks VNET_GET(flowtable_free_checks)
#define V_flowtable_max_depth VNET_GET(flowtable_max_depth)
#define V_flowtable_collisions VNET_GET(flowtable_collisions)
#define V_flowtable_syn_expire VNET_GET(flowtable_syn_expire)
#define V_flowtable_udp_expire VNET_GET(flowtable_udp_expire)
#define V_flowtable_fin_wait_expire VNET_GET(flowtable_fin_wait_expire)
#define V_flowtable_tcp_expire VNET_GET(flowtable_tcp_expire)
#define V_flowtable_nmbflows VNET_GET(flowtable_nmbflows)
SYSCTL_NODE(_net_inet, OID_AUTO, flowtable, CTLFLAG_RD, NULL, "flowtable");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, enable,
CTLFLAG_RW, flowtable_enable, 0, "enable flowtable caching.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, hits,
CTLFLAG_RD, flowtable_hits, 0, "# flowtable hits.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, lookups,
CTLFLAG_RD, flowtable_lookups, 0, "# flowtable lookups.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, misses,
CTLFLAG_RD, flowtable_misses, 0, "#flowtable misses.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, frees,
CTLFLAG_RD, flowtable_frees, 0, "#flows freed.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, free_checks,
CTLFLAG_RD, flowtable_free_checks, 0, "#flows free checks.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, max_depth,
CTLFLAG_RD, flowtable_max_depth, 0, "max collision list length.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, collisions,
CTLFLAG_RD, flowtable_collisions, 0, "#flowtable collisions.");
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, enable, CTLFLAG_RW,
&VNET_NAME(flowtable_enable), 0, "enable flowtable caching.");
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, hits, CTLFLAG_RD,
&VNET_NAME(flowtable_hits), 0, "# flowtable hits.");
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, lookups, CTLFLAG_RD,
&VNET_NAME(flowtable_lookups), 0, "# flowtable lookups.");
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, misses, CTLFLAG_RD,
&VNET_NAME(flowtable_misses), 0, "#flowtable misses.");
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, frees, CTLFLAG_RD,
&VNET_NAME(flowtable_frees), 0, "#flows freed.");
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, free_checks, CTLFLAG_RD,
&VNET_NAME(flowtable_free_checks), 0, "#flows free checks.");
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, max_depth, CTLFLAG_RD,
&VNET_NAME(flowtable_max_depth), 0, "max collision list length.");
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, collisions, CTLFLAG_RD,
&VNET_NAME(flowtable_collisions), 0, "#flowtable collisions.");
/*
* XXX This does not end up updating timeouts at runtime
* and only reflects the value for the last table added :-/
*/
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, syn_expire,
CTLFLAG_RW, flowtable_syn_expire, 0,
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, syn_expire, CTLFLAG_RW,
&VNET_NAME(flowtable_syn_expire), 0,
"seconds after which to remove syn allocated flow.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, udp_expire,
CTLFLAG_RW, flowtable_udp_expire, 0,
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, udp_expire, CTLFLAG_RW,
&VNET_NAME(flowtable_udp_expire), 0,
"seconds after which to remove flow allocated to UDP.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, fin_wait_expire,
CTLFLAG_RW, flowtable_fin_wait_expire, 0,
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, fin_wait_expire, CTLFLAG_RW,
&VNET_NAME(flowtable_fin_wait_expire), 0,
"seconds after which to remove a flow in FIN_WAIT.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, tcp_expire,
CTLFLAG_RW, flowtable_tcp_expire, 0,
SYSCTL_VNET_INT(_net_inet_flowtable, OID_AUTO, tcp_expire, CTLFLAG_RW,
&VNET_NAME(flowtable_tcp_expire), 0,
"seconds after which to remove flow allocated to a TCP connection.");
@ -266,7 +277,6 @@ SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, tcp_expire,
static int
sysctl_nmbflows(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_INET(curvnet);
int error, newnmbflows;
newnmbflows = V_flowtable_nmbflows;
@ -283,8 +293,8 @@ sysctl_nmbflows(SYSCTL_HANDLER_ARGS)
}
return (error);
}
SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_flowtable, OID_AUTO, nmbflows,
CTLTYPE_INT|CTLFLAG_RW, flowtable_nmbflows, 0, sysctl_nmbflows, "IU",
SYSCTL_VNET_PROC(_net_inet_flowtable, OID_AUTO, nmbflows,
CTLTYPE_INT|CTLFLAG_RW, 0, 0, sysctl_nmbflows, "IU",
"Maximum number of flows allowed");
#ifndef RADIX_MPATH
@ -338,7 +348,6 @@ static uint32_t
ipv4_flow_lookup_hash_internal(struct mbuf *m, struct route *ro,
uint32_t *key, uint16_t *flags, uint8_t *protop)
{
INIT_VNET_INET(curvnet);
uint16_t sport = 0, dport = 0;
struct ip *ip = NULL;
uint8_t proto = 0;
@ -505,7 +514,6 @@ static int
flowtable_insert(struct flowtable *ft, uint32_t hash, uint32_t *key,
uint8_t proto, struct route *ro, uint16_t flags)
{
INIT_VNET_INET(curvnet);
struct flentry *fle, *fletail, *newfle, **flep;
int depth;
uma_zone_t flezone;
@ -596,7 +604,6 @@ flowtable_key_equal(struct flentry *fle, uint32_t *key)
int
flowtable_lookup(struct flowtable *ft, struct mbuf *m, struct route *ro)
{
INIT_VNET_INET(curvnet);
uint32_t key[9], hash;
struct flentry *fle;
uint16_t flags;
@ -718,7 +725,6 @@ flowtable_lookup(struct flowtable *ft, struct mbuf *m, struct route *ro)
struct flowtable *
flowtable_alloc(int nentry, int flags)
{
INIT_VNET_INET(curvnet);
struct flowtable *ft, *fttail;
int i;
@ -800,7 +806,7 @@ static void
flowtable_setup(void *arg)
{
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&flowtable_modinfo);
#else
flowtable_iattach(NULL);
@ -810,21 +816,6 @@ flowtable_setup(void *arg)
static int
flowtable_iattach(const void *unused __unused)
{
INIT_VNET_INET(curvnet);
V_flowtable_enable = 1;
V_flowtable_hits = 0;
V_flowtable_lookups = 0;
V_flowtable_misses = 0;
V_flowtable_frees = 0;
V_flowtable_free_checks = 0;
V_flowtable_max_depth = 0;
V_flowtable_collisions = 0;
V_flowtable_syn_expire = SYN_IDLE;
V_flowtable_udp_expire = UDP_IDLE;
V_flowtable_fin_wait_expire = FIN_WAIT_IDLE;
V_flowtable_tcp_expire = TCP_IDLE;
V_flowtable_nmbflows = 4096;
V_flow_ipv4_zone = uma_zcreate("ip4flow", sizeof(struct flentry_v4),
NULL, NULL, NULL, NULL, 64, UMA_ZONE_MAXBUCKET);
@ -839,7 +830,6 @@ flowtable_iattach(const void *unused __unused)
static int
flowtable_idetach(const void *unused __unused)
{
INIT_VNET_INET(curvnet);
uma_zdestroy(V_flow_ipv4_zone);
uma_zdestroy(V_flow_ipv6_zone);
@ -858,7 +848,6 @@ SYSINIT(flowtable_setup, SI_SUB_KTHREAD_INIT, SI_ORDER_ANY, flowtable_setup, NUL
static void
fle_free(struct flentry *fle)
{
INIT_VNET_INET(curvnet);
struct rtentry *rt;
struct llentry *lle;
@ -873,7 +862,6 @@ fle_free(struct flentry *fle)
static void
flowtable_free_stale(struct flowtable *ft)
{
INIT_VNET_INET(curvnet);
int curbit = 0, count;
struct flentry *fle, **flehead, *fleprev;
struct flentry *flefreehead, *flefreetail, *fletmp;
@ -961,7 +949,6 @@ flowtable_free_stale(struct flowtable *ft)
static void
flowtable_clean_vnet(void)
{
INIT_VNET_INET(curvnet);
struct flowtable *ft;
int i;

View File

@ -38,9 +38,8 @@ POSSIBILITY OF SUCH DAMAGE.
#define FL_PCPU (1<<1) /* pcpu cache */
struct flowtable;
#ifdef VIMAGE_GLOBALS
extern struct flowtable *ip_ft;
#endif
VNET_DECLARE(struct flowtable *, ip_ft);
#define V_ip_ft VNET_GET(ip_ft)
struct flowtable *flowtable_alloc(int nentry, int flags);

View File

@ -84,7 +84,6 @@
#endif
#ifdef INET
#include <netinet/if_ether.h>
#include <netinet/vinet.h>
#endif
#if defined(INET) || defined(INET6)
#ifdef DEV_CARP
@ -94,12 +93,6 @@
#include <security/mac/mac_framework.h>
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
struct vnet_net vnet_net_0;
#endif
#endif
struct ifindex_entry {
struct ifnet *ife_ifnet;
};
@ -162,37 +155,30 @@ static int vnet_net_iattach(const void *);
static int vnet_net_idetach(const void *);
#endif
#ifdef VIMAGE_GLOBALS
struct ifnethead ifnet; /* depend on static init XXX */
struct ifgrouphead ifg_head;
int if_index;
static int if_indexlim;
VNET_DEFINE(struct ifnethead, ifnet); /* depend on static init XXX */
VNET_DEFINE(struct ifgrouphead, ifg_head);
VNET_DEFINE(int, if_index);
static VNET_DEFINE(int, if_indexlim) = 8;
/* Table of ifnet by index. Locked with ifnet_lock. */
static struct ifindex_entry *ifindex_table;
#endif
static VNET_DEFINE(struct ifindex_entry *, ifindex_table);
#define V_if_indexlim VNET_GET(if_indexlim)
#define V_ifindex_table VNET_GET(ifindex_table)
int ifqmaxlen = IFQ_MAXLEN;
struct rwlock ifnet_lock;
static if_com_alloc_t *if_com_alloc[256];
static if_com_free_t *if_com_free[256];
#ifndef VIMAGE_GLOBALS
static struct vnet_symmap vnet_net_symmap[] = {
VNET_SYMMAP(net, ifnet),
VNET_SYMMAP_END
};
#ifdef VIMAGE
static const vnet_modinfo_t vnet_net_modinfo = {
.vmi_id = VNET_MOD_NET,
.vmi_name = "net",
.vmi_size = sizeof(struct vnet_net),
.vmi_symmap = vnet_net_symmap,
.vmi_iattach = vnet_net_iattach,
#ifdef VIMAGE
.vmi_idetach = vnet_net_idetach
#endif
};
#endif /* !VIMAGE_GLOBALS */
#endif
/*
* System initialization
@ -207,7 +193,6 @@ MALLOC_DEFINE(M_IFMADDR, "ether_multi", "link-level multicast address");
struct ifnet *
ifnet_byindex_locked(u_short idx)
{
INIT_VNET_NET(curvnet);
if (idx > V_if_index)
return (NULL);
@ -244,7 +229,6 @@ ifnet_byindex_ref(u_short idx)
static void
ifnet_setbyindex(u_short idx, struct ifnet *ifp)
{
INIT_VNET_NET(curvnet);
IFNET_WLOCK_ASSERT();
@ -276,7 +260,7 @@ static void
if_init(void *dummy __unused)
{
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_net_modinfo);
#else
vnet_net_iattach(NULL);
@ -289,11 +273,6 @@ if_init(void *dummy __unused)
static int
vnet_net_iattach(const void *unused __unused)
{
INIT_VNET_NET(curvnet);
V_if_index = 0;
V_ifindex_table = NULL;
V_if_indexlim = 8;
TAILQ_INIT(&V_ifnet);
TAILQ_INIT(&V_ifg_head);
@ -306,7 +285,6 @@ vnet_net_iattach(const void *unused __unused)
static int
vnet_net_idetach(const void *unused __unused)
{
INIT_VNET_NET(curvnet);
VNET_ASSERT(TAILQ_EMPTY(&V_ifnet));
VNET_ASSERT(TAILQ_EMPTY(&V_ifg_head));
@ -320,7 +298,6 @@ vnet_net_idetach(const void *unused __unused)
void
if_grow(void)
{
INIT_VNET_NET(curvnet);
u_int n;
struct ifindex_entry *e;
@ -354,7 +331,6 @@ if_check(void *dummy __unused)
struct ifnet *
if_alloc(u_char type)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
ifp = malloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO);
@ -418,7 +394,6 @@ if_alloc(u_char type)
static void
if_free_internal(struct ifnet *ifp)
{
INIT_VNET_NET(curvnet); /* ifp->if_vnet is already NULL here */
KASSERT((ifp->if_flags & IFF_DYING),
("if_free_internal: interface not dying"));
@ -544,7 +519,6 @@ if_attach(struct ifnet *ifp)
static void
if_attach_internal(struct ifnet *ifp, int vmove)
{
INIT_VNET_NET(curvnet);
unsigned socksize, ifasize;
int namelen, masklen;
struct sockaddr_dl *sdl;
@ -649,7 +623,6 @@ if_attach_internal(struct ifnet *ifp, int vmove)
static void
if_attachdomain(void *dummy)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
int s;
@ -769,7 +742,6 @@ if_detach(struct ifnet *ifp)
static void
if_detach_internal(struct ifnet *ifp, int vmove)
{
INIT_VNET_NET(ifp->if_vnet);
struct ifaddr *ifa;
struct radix_node_head *rnh;
int i, j;
@ -904,25 +876,17 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
/*
* Unlink the ifnet from ifindex_table[] in current vnet,
* and shrink the if_index for that vnet if possible.
* do / while construct below is needed to confine the scope
* of INIT_VNET_NET().
*/
{
INIT_VNET_NET(curvnet);
IFNET_WLOCK();
ifnet_setbyindex(ifp->if_index, NULL);
while (V_if_index > 0 && \
ifnet_byindex_locked(V_if_index) == NULL)
V_if_index--;
IFNET_WUNLOCK();
};
IFNET_WLOCK();
ifnet_setbyindex(ifp->if_index, NULL);
while (V_if_index > 0 && ifnet_byindex_locked(V_if_index) == NULL)
V_if_index--;
IFNET_WUNLOCK();
/*
* Switch to the context of the target vnet.
*/
CURVNET_SET_QUIET(new_vnet);
INIT_VNET_NET(new_vnet);
/*
* Try to find an empty slot below if_index. If we fail, take
@ -956,7 +920,6 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet)
int
if_addgroup(struct ifnet *ifp, const char *groupname)
{
INIT_VNET_NET(ifp->if_vnet);
struct ifg_list *ifgl;
struct ifg_group *ifg = NULL;
struct ifg_member *ifgm;
@ -1026,7 +989,6 @@ if_addgroup(struct ifnet *ifp, const char *groupname)
int
if_delgroup(struct ifnet *ifp, const char *groupname)
{
INIT_VNET_NET(ifp->if_vnet);
struct ifg_list *ifgl;
struct ifg_member *ifgm;
@ -1072,7 +1034,6 @@ if_delgroup(struct ifnet *ifp, const char *groupname)
static void
if_delgroups(struct ifnet *ifp)
{
INIT_VNET_NET(ifp->if_vnet);
struct ifg_list *ifgl;
struct ifg_member *ifgm;
char groupname[IFNAMSIZ];
@ -1164,7 +1125,6 @@ if_getgroup(struct ifgroupreq *data, struct ifnet *ifp)
static int
if_getgroupmembers(struct ifgroupreq *data)
{
INIT_VNET_NET(curvnet);
struct ifgroupreq *ifgr = data;
struct ifg_group *ifg;
struct ifg_member *ifgm;
@ -1336,7 +1296,6 @@ ifa_free(struct ifaddr *ifa)
static struct ifaddr *
ifa_ifwithaddr_internal(struct sockaddr *addr, int getref)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
struct ifaddr *ifa;
@ -1392,7 +1351,6 @@ ifa_ifwithaddr_check(struct sockaddr *addr)
struct ifaddr *
ifa_ifwithbroadaddr(struct sockaddr *addr)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
struct ifaddr *ifa;
@ -1426,7 +1384,6 @@ ifa_ifwithbroadaddr(struct sockaddr *addr)
struct ifaddr *
ifa_ifwithdstaddr(struct sockaddr *addr)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
struct ifaddr *ifa;
@ -1460,7 +1417,6 @@ ifa_ifwithdstaddr(struct sockaddr *addr)
struct ifaddr *
ifa_ifwithnet(struct sockaddr *addr)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
struct ifaddr *ifa;
struct ifaddr *ifa_maybe = NULL;
@ -1841,7 +1797,6 @@ if_slowtimo(void *arg)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
INIT_VNET_NET(vnet_iter);
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_timer == 0 || --ifp->if_timer)
continue;
@ -1863,7 +1818,6 @@ if_slowtimo(void *arg)
struct ifnet *
ifunit_ref(const char *name)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
IFNET_RLOCK();
@ -1881,7 +1835,6 @@ ifunit_ref(const char *name)
struct ifnet *
ifunit(const char *name)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
IFNET_RLOCK();
@ -2478,7 +2431,6 @@ ifpromisc(struct ifnet *ifp, int pswitch)
static int
ifconf(u_long cmd, caddr_t data)
{
INIT_VNET_NET(curvnet);
struct ifconf *ifc = (struct ifconf *)data;
#ifdef __amd64__
struct ifconf32 *ifc32 = (struct ifconf32 *)data;
@ -2837,7 +2789,6 @@ if_delmulti(struct ifnet *ifp, struct sockaddr *sa)
int lastref;
#ifdef INVARIANTS
struct ifnet *oifp;
INIT_VNET_NET(ifp->if_vnet);
IFNET_RLOCK();
TAILQ_FOREACH(oifp, &V_ifnet, if_link)
@ -2878,9 +2829,6 @@ if_delmulti(struct ifnet *ifp, struct sockaddr *sa)
void
if_delmulti_ifma(struct ifmultiaddr *ifma)
{
#ifdef DIAGNOSTIC
INIT_VNET_NET(curvnet);
#endif
struct ifnet *ifp;
int lastref;

View File

@ -116,11 +116,9 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_var.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/vinet.h>
#ifdef INET6
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#include <netinet6/vinet6.h>
#endif
#if defined(INET) || defined(INET6)
#ifdef DEV_CARP
@ -3042,7 +3040,6 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
}
if (ip_fw_chk_ptr && pfil_ipfw != 0 && dir == PFIL_OUT && ifp != NULL) {
INIT_VNET_INET(curvnet);
struct dn_pkt_tag *dn_tag;
error = -1;
@ -3236,7 +3233,6 @@ bridge_pfil(struct mbuf **mp, struct ifnet *bifp, struct ifnet *ifp, int dir)
static int
bridge_ip_checkbasic(struct mbuf **mp)
{
INIT_VNET_INET(curvnet);
struct mbuf *m = *mp;
struct ip *ip;
int len, hlen;
@ -3332,7 +3328,6 @@ bridge_ip_checkbasic(struct mbuf **mp)
static int
bridge_ip6_checkbasic(struct mbuf **mp)
{
INIT_VNET_INET6(curvnet);
struct mbuf *m = *mp;
struct ip6_hdr *ip6;
@ -3387,7 +3382,6 @@ static int
bridge_fragment(struct ifnet *ifp, struct mbuf *m, struct ether_header *eh,
int snap, struct llc *llc)
{
INIT_VNET_INET(curvnet);
struct mbuf *m0;
struct ip *ip;
int error = -1;

View File

@ -58,10 +58,11 @@ static int if_clone_createif(struct if_clone *ifc, char *name, size_t len,
static int vnet_clone_iattach(const void *);
static struct mtx if_cloners_mtx;
#ifdef VIMAGE_GLOBALS
static int if_cloners_count;
LIST_HEAD(, if_clone) if_cloners;
#endif
static VNET_DEFINE(int, if_cloners_count);
VNET_DEFINE(LIST_HEAD(, if_clone), if_cloners);
#define V_if_cloners_count VNET_GET(if_cloners_count)
#define V_if_cloners VNET_GET(if_cloners)
#define IF_CLONERS_LOCK_INIT() \
mtx_init(&if_cloners_mtx, "if_cloners lock", NULL, MTX_DEF)
@ -115,17 +116,16 @@ LIST_HEAD(, if_clone) if_cloners;
static MALLOC_DEFINE(M_CLONE, "clone", "interface cloning framework");
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
static const vnet_modinfo_t vnet_clone_modinfo = {
.vmi_id = VNET_MOD_IF_CLONE,
.vmi_name = "if_clone",
.vmi_iattach = vnet_clone_iattach
};
#endif /* !VIMAGE_GLOBALS */
#endif
static int vnet_clone_iattach(const void *unused __unused)
{
INIT_VNET_NET(curvnet);
LIST_INIT(&V_if_cloners);
return (0);
@ -136,7 +136,7 @@ if_clone_init(void)
{
IF_CLONERS_LOCK_INIT();
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_clone_modinfo);
#else
vnet_clone_iattach(NULL);
@ -149,7 +149,6 @@ if_clone_init(void)
int
if_clone_create(char *name, size_t len, caddr_t params)
{
INIT_VNET_NET(curvnet);
struct if_clone *ifc;
/* Try to find an applicable cloner for this request */
@ -162,7 +161,6 @@ if_clone_create(char *name, size_t len, caddr_t params)
#ifdef VIMAGE
if (ifc == NULL && !IS_DEFAULT_VNET(curvnet)) {
CURVNET_SET_QUIET(vnet0);
INIT_VNET_NET(vnet0);
LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
if (ifc->ifc_match(ifc, name))
break;
@ -213,7 +211,6 @@ if_clone_createif(struct if_clone *ifc, char *name, size_t len, caddr_t params)
int
if_clone_destroy(const char *name)
{
INIT_VNET_NET(curvnet);
struct if_clone *ifc;
struct ifnet *ifp;
@ -231,7 +228,6 @@ if_clone_destroy(const char *name)
#ifdef VIMAGE
if (ifc == NULL && !IS_DEFAULT_VNET(curvnet)) {
CURVNET_SET_QUIET(vnet0);
INIT_VNET_NET(vnet0);
LIST_FOREACH(ifc, &V_if_cloners, ifc_list) {
if (ifc->ifc_match(ifc, name))
break;
@ -289,7 +285,6 @@ if_clone_destroyif(struct if_clone *ifc, struct ifnet *ifp)
void
if_clone_attach(struct if_clone *ifc)
{
INIT_VNET_NET(curvnet);
int len, maxclone;
/*
@ -322,7 +317,6 @@ if_clone_attach(struct if_clone *ifc)
void
if_clone_detach(struct if_clone *ifc)
{
INIT_VNET_NET(curvnet);
struct ifc_simple_data *ifcs = ifc->ifc_data;
IF_CLONERS_LOCK();
@ -362,7 +356,6 @@ if_clone_free(struct if_clone *ifc)
int
if_clone_list(struct if_clonereq *ifcr)
{
INIT_VNET_NET(curvnet);
char *buf, *dst, *outbuf = NULL;
struct if_clone *ifc;
int buf_count, count, err = 0;

View File

@ -493,7 +493,6 @@ ef_load(void)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
INIT_VNET_NET(vnet_iter);
IFNET_RLOCK();
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type != IFT_ETHER) continue;

View File

@ -47,6 +47,7 @@
#include <net/route.h>
#include <net/netisr.h>
#include <net/bpf.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>

View File

@ -73,7 +73,7 @@
#include <netinet/if_ether.h>
#include <netinet/ip_fw.h>
#include <netinet/ip_dummynet.h>
#include <netinet/vinet.h>
#include <netinet/ip_var.h>
#endif
#ifdef INET6
#include <netinet6/nd6.h>
@ -148,9 +148,8 @@ MALLOC_DEFINE(M_ARPCOM, "arpcom", "802.* interface internals");
#if defined(INET) || defined(INET6)
int
ether_ipfw_chk(struct mbuf **m0, struct ifnet *dst, int shared);
#ifdef VIMAGE_GLOBALS
static int ether_ipfw;
#endif
static VNET_DEFINE(int, ether_ipfw);
#define V_ether_ipfw VNET_GET(ether_ipfw)
#endif
@ -434,7 +433,6 @@ int
ether_output_frame(struct ifnet *ifp, struct mbuf *m)
{
#if defined(INET) || defined(INET6)
INIT_VNET_NET(ifp->if_vnet);
if (ip_fw_chk_ptr && V_ether_ipfw != 0) {
if (ether_ipfw_chk(&m, ifp, 0) == 0) {
@ -463,7 +461,6 @@ ether_output_frame(struct ifnet *ifp, struct mbuf *m)
int
ether_ipfw_chk(struct mbuf **m0, struct ifnet *dst, int shared)
{
INIT_VNET_INET(dst->if_vnet);
struct ether_header *eh;
struct ether_header save_eh;
struct mbuf *m;
@ -774,7 +771,6 @@ ether_demux(struct ifnet *ifp, struct mbuf *m)
KASSERT(ifp != NULL, ("%s: NULL interface pointer", __func__));
#if defined(INET) || defined(INET6)
INIT_VNET_NET(ifp->if_vnet);
/*
* Allow dummynet and/or ipfw to claim the frame.
* Do not do this for PROMISC frames in case we are re-entered.
@ -994,8 +990,8 @@ ether_ifdetach(struct ifnet *ifp)
SYSCTL_DECL(_net_link);
SYSCTL_NODE(_net_link, IFT_ETHER, ether, CTLFLAG_RW, 0, "Ethernet");
#if defined(INET) || defined(INET6)
SYSCTL_V_INT(V_NET, vnet_net, _net_link_ether, OID_AUTO, ipfw, CTLFLAG_RW,
ether_ipfw, 0, "Pass ether pkts through firewall");
SYSCTL_VNET_INT(_net_link_ether, OID_AUTO, ipfw, CTLFLAG_RW,
&VNET_NAME(ether_ipfw), 0, "Pass ether pkts through firewall");
#endif
#if 0

View File

@ -77,7 +77,6 @@
#include <netinet6/in6_var.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#include <netinet6/vinet6.h>
#endif
#define FAITHNAME "faith"
@ -328,7 +327,6 @@ static int
faithprefix(in6)
struct in6_addr *in6;
{
INIT_VNET_INET6(curvnet);
struct rtentry *rt;
struct sockaddr_in6 sin6;
int ret;

View File

@ -95,22 +95,21 @@
static struct mtx gif_mtx;
static MALLOC_DEFINE(M_GIF, "gif", "Generic Tunnel Interface");
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
struct vnet_gif vnet_gif_0;
#endif
#endif
static VNET_DEFINE(LIST_HEAD(, gif_softc), gif_softc_list);
static VNET_DEFINE(int, max_gif_nesting);
static VNET_DEFINE(int, parallel_tunnels);
#define V_gif_softc_list VNET_GET(gif_softc_list)
#define V_max_gif_nesting VNET_GET(max_gif_nesting)
#define V_parallel_tunnels VNET_GET(parallel_tunnels)
#ifdef VIMAGE_GLOBALS
static LIST_HEAD(, gif_softc) gif_softc_list;
static int max_gif_nesting;
static int parallel_tunnels;
#ifdef INET
int ip_gif_ttl;
VNET_DEFINE(int, ip_gif_ttl);
#define V_ip_gif_ttl VNET_GET(ip_gif_ttl)
#endif
#ifdef INET6
int ip6_gif_hlim;
#endif
VNET_DEFINE(int, ip6_gif_hlim);
#define V_ip6_gif_hlim VNET_GET(ip6_gif_hlim)
#endif
void (*ng_gif_input_p)(struct ifnet *ifp, struct mbuf **mp, int af);
@ -123,11 +122,10 @@ static int gif_clone_create(struct if_clone *, int, caddr_t);
static void gif_clone_destroy(struct ifnet *);
static int vnet_gif_iattach(const void *);
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
static const vnet_modinfo_t vnet_gif_modinfo = {
.vmi_id = VNET_MOD_GIF,
.vmi_name = "gif",
.vmi_size = sizeof(struct vnet_gif),
.vmi_dependson = VNET_MOD_NET,
.vmi_iattach = vnet_gif_iattach
};
@ -151,13 +149,13 @@ SYSCTL_NODE(_net_link, IFT_GIF, gif, CTLFLAG_RW, 0,
*/
#define MAX_GIF_NEST 1
#endif
SYSCTL_V_INT(V_NET, vnet_gif, _net_link_gif, OID_AUTO, max_nesting,
CTLFLAG_RW, max_gif_nesting, 0, "Max nested tunnels");
SYSCTL_VNET_INT(_net_link_gif, OID_AUTO, max_nesting, CTLFLAG_RW,
&VNET_NAME(max_gif_nesting), 0, "Max nested tunnels");
#ifdef INET6
SYSCTL_DECL(_net_inet6_ip6);
SYSCTL_V_INT(V_NET, vnet_gif, _net_inet6_ip6, IPV6CTL_GIF_HLIM,
gifhlim, CTLFLAG_RW, ip6_gif_hlim, 0, "");
SYSCTL_VNET_INT(_net_inet6_ip6, IPV6CTL_GIF_HLIM, gifhlim, CTLFLAG_RW,
&VNET_NAME(ip6_gif_hlim), 0, "");
#endif
/*
@ -165,8 +163,8 @@ SYSCTL_V_INT(V_NET, vnet_gif, _net_inet6_ip6, IPV6CTL_GIF_HLIM,
* pair of addresses. Some applications require this functionality so
* we allow control over this check here.
*/
SYSCTL_V_INT(V_NET, vnet_gif, _net_link_gif, OID_AUTO, parallel_tunnels,
CTLFLAG_RW, parallel_tunnels, 0, "Allow parallel tunnels?");
SYSCTL_VNET_INT(_net_link_gif, OID_AUTO, parallel_tunnels, CTLFLAG_RW,
&VNET_NAME(parallel_tunnels), 0, "Allow parallel tunnels?");
/* copy from src/sys/net/if_ethersubr.c */
static const u_char etherbroadcastaddr[ETHER_ADDR_LEN] =
@ -182,7 +180,6 @@ gif_clone_create(ifc, unit, params)
int unit;
caddr_t params;
{
INIT_VNET_GIF(curvnet);
struct gif_softc *sc;
sc = malloc(sizeof(struct gif_softc), M_GIF, M_WAITOK | M_ZERO);
@ -265,7 +262,6 @@ gif_clone_destroy(ifp)
static int
vnet_gif_iattach(const void *unused __unused)
{
INIT_VNET_GIF(curvnet);
LIST_INIT(&V_gif_softc_list);
V_max_gif_nesting = MAX_GIF_NEST;
@ -295,7 +291,7 @@ gifmodevent(mod, type, data)
case MOD_LOAD:
mtx_init(&gif_mtx, "gif_mtx", NULL, MTX_DEF);
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_gif_modinfo);
#else
vnet_gif_iattach(NULL);
@ -419,7 +415,6 @@ gif_output(ifp, m, dst, ro)
struct sockaddr *dst;
struct route *ro;
{
INIT_VNET_GIF(ifp->if_vnet);
struct gif_softc *sc = ifp->if_softc;
struct m_tag *mtag;
int error = 0;
@ -944,7 +939,6 @@ gif_set_tunnel(ifp, src, dst)
struct sockaddr *src;
struct sockaddr *dst;
{
INIT_VNET_GIF(ifp->if_vnet);
struct gif_softc *sc = ifp->if_softc;
struct gif_softc *sc2;
struct sockaddr *osrc, *odst, *sa;

View File

@ -119,34 +119,8 @@ int gif_set_tunnel(struct ifnet *, struct sockaddr *, struct sockaddr *);
void gif_delete_tunnel(struct ifnet *);
int gif_encapcheck(const struct mbuf *, int, int, void *);
/*
* Virtualization support
*/
struct vnet_gif {
LIST_HEAD(, gif_softc) _gif_softc_list;
int _max_gif_nesting;
int _parallel_tunnels;
int _ip_gif_ttl;
int _ip6_gif_hlim;
};
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
extern struct vnet_gif vnet_gif_0;
#endif
#endif
#define INIT_VNET_GIF(vnet) \
INIT_FROM_VNET(vnet, VNET_MOD_GIF, struct vnet_gif, vnet_gif)
#define VNET_GIF(sym) VSYM(vnet_gif, sym)
#define V_gif_softc_list VNET_GIF(gif_softc_list)
#define V_max_gif_nesting VNET_GIF(max_gif_nesting)
#define V_parallel_tunnels VNET_GIF(parallel_tunnels)
#define V_ip_gif_ttl VNET_GIF(ip_gif_ttl)
#define V_ip6_gif_hlim VNET_GIF(ip6_gif_hlim)
VNET_DECLARE(int, ip_gif_ttl);
#define V_ip_gif_ttl VNET_GET(ip_gif_ttl)
#endif /* _KERNEL */

View File

@ -80,7 +80,6 @@
#include <netinet/ip_gre.h>
#include <netinet/ip_var.h>
#include <netinet/ip_encap.h>
#include <netinet/vinet.h>
#else
#error "Huh? if_gre without inet?"
#endif
@ -243,9 +242,6 @@ static int
gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
struct route *ro)
{
#ifdef INET6
INIT_VNET_INET(ifp->if_vnet);
#endif
int error = 0;
struct gre_softc *sc = ifp->if_softc;
struct greip *gh;

View File

@ -108,25 +108,26 @@ static int vnet_loif_iattach(const void *);
static int vnet_loif_idetach(const void *);
#endif
#ifdef VIMAGE_GLOBALS
struct ifnet *loif; /* Used externally */
#endif
VNET_DEFINE(struct ifnet *, loif); /* Used externally */
#ifdef VIMAGE
static VNET_DEFINE(struct ifc_simple_data *, lo_cloner_data);
static VNET_DEFINE(struct if_clone *, lo_cloner);
#define V_lo_cloner_data VNET_GET(lo_cloner_data)
#define V_lo_cloner VNET_GET(lo_cloner)
MALLOC_DEFINE(M_LO_CLONER, "lo_cloner", "lo_cloner");
#endif
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
static const vnet_modinfo_t vnet_loif_modinfo = {
.vmi_id = VNET_MOD_LOIF,
.vmi_dependson = VNET_MOD_IF_CLONE,
.vmi_name = "loif",
.vmi_iattach = vnet_loif_iattach,
#ifdef VIMAGE
.vmi_idetach = vnet_loif_idetach
#endif
};
#endif /* !VIMAGE_GLOBALS */
#endif
IFC_SIMPLE_DECLARE(lo, 1);
@ -147,7 +148,6 @@ lo_clone_destroy(struct ifnet *ifp)
static int
lo_clone_create(struct if_clone *ifc, int unit, caddr_t params)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
ifp = if_alloc(IFT_LOOP);
@ -173,10 +173,7 @@ lo_clone_create(struct if_clone *ifc, int unit, caddr_t params)
static int
vnet_loif_iattach(const void *unused __unused)
{
INIT_VNET_NET(curvnet);
V_loif = NULL;
#ifdef VIMAGE
V_lo_cloner = malloc(sizeof(*V_lo_cloner), M_LO_CLONER,
M_WAITOK | M_ZERO);
@ -196,7 +193,6 @@ vnet_loif_iattach(const void *unused __unused)
static int
vnet_loif_idetach(const void *unused __unused)
{
INIT_VNET_NET(curvnet);
if_clone_detach(V_lo_cloner);
free(V_lo_cloner, M_LO_CLONER);
@ -213,7 +209,7 @@ loop_modevent(module_t mod, int type, void *data)
switch (type) {
case MOD_LOAD:
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_loif_modinfo);
#else
vnet_loif_iattach(NULL);
@ -309,7 +305,6 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
int
if_simloop(struct ifnet *ifp, struct mbuf *m, int af, int hlen)
{
INIT_VNET_NET(ifp->if_vnet);
int isr;
M_ASSERTPKTHDR(m);

View File

@ -67,8 +67,8 @@ SYSCTL_DECL(_net_link_generic);
SYSCTL_NODE(_net_link_generic, IFMIB_SYSTEM, system, CTLFLAG_RW, 0,
"Variables global to all interfaces");
SYSCTL_V_INT(V_NET, vnet_net, _net_link_generic_system, IFMIB_IFCOUNT,
ifcount, CTLFLAG_RD, if_index, 0,
SYSCTL_VNET_INT(_net_link_generic_system, IFMIB_IFCOUNT, ifcount, CTLFLAG_RD,
&VNET_NAME(if_index), 0,
"Number of configured interfaces");
static int

View File

@ -56,7 +56,6 @@
#ifdef INET
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <netinet/vinet.h>
#endif
#ifdef INET6
@ -4937,7 +4936,6 @@ sppp_get_ip_addrs(struct sppp *sp, u_long *src, u_long *dst, u_long *srcmask)
static void
sppp_set_ip_addr(struct sppp *sp, u_long src)
{
INIT_VNET_INET(curvnet);
STDDCL;
struct ifaddr *ifa;
struct sockaddr_in *si;

View File

@ -106,7 +106,6 @@
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/in_var.h>
#include <netinet/vinet.h>
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
@ -378,7 +377,6 @@ static struct in6_ifaddr *
stf_getsrcifa6(ifp)
struct ifnet *ifp;
{
INIT_VNET_INET(ifp->if_vnet);
struct ifaddr *ia;
struct in_ifaddr *ia4;
struct sockaddr_in6 *sin6;
@ -596,7 +594,6 @@ stf_checkaddr4(sc, in, inifp)
struct in_addr *in;
struct ifnet *inifp; /* incoming interface */
{
INIT_VNET_INET(curvnet);
struct in_ifaddr *ia4;
/*

View File

@ -80,6 +80,7 @@ struct vnet;
#include <sys/mbuf.h>
#include <sys/eventhandler.h>
#include <sys/buf_ring.h>
#include <net/vnet.h>
#endif /* _KERNEL */
#include <sys/lock.h> /* XXX */
#include <sys/mutex.h> /* XXX */
@ -779,11 +780,16 @@ struct ifnet *ifnet_byindex_ref(u_short idx);
*/
struct ifaddr *ifaddr_byindex(u_short idx);
#ifdef VIMAGE_GLOBALS
extern struct ifnethead ifnet;
extern struct ifnet *loif; /* first loopback interface */
extern int if_index;
#endif
VNET_DECLARE(struct ifnethead, ifnet);
VNET_DECLARE(struct ifgrouphead, ifg_head);
VNET_DECLARE(int, if_index);
VNET_DECLARE(struct ifnet *, loif); /* first loopback interface */
#define V_ifnet VNET_GET(ifnet)
#define V_ifg_head VNET_GET(ifg_head)
#define V_if_index VNET_GET(if_index)
#define V_loif VNET_GET(loif)
extern int ifqmaxlen;
int if_addgroup(struct ifnet *, const char *);

View File

@ -576,7 +576,6 @@ MODULE_VERSION(if_vlan, 3);
static struct ifnet *
vlan_clone_match_ethertag(struct if_clone *ifc, const char *name, int *tag)
{
INIT_VNET_NET(curvnet);
const char *cp;
struct ifnet *ifp;
int t = 0;

View File

@ -58,9 +58,7 @@
*/
struct mtx rawcb_mtx;
#ifdef VIMAGE_GLOBALS
struct rawcb_list_head rawcb_list;
#endif
VNET_DEFINE(struct rawcb_list_head, rawcb_list);
SYSCTL_NODE(_net, OID_AUTO, raw, CTLFLAG_RW, 0, "Raw socket infrastructure");
@ -79,7 +77,6 @@ SYSCTL_ULONG(_net_raw, OID_AUTO, recvspace, CTLFLAG_RW, &raw_recvspace, 0,
int
raw_attach(struct socket *so, int proto)
{
INIT_VNET_NET(so->so_vnet);
struct rawcb *rp = sotorawcb(so);
int error;

View File

@ -55,9 +55,9 @@ struct rawcb {
#define RAWRCVQ 8192
#ifdef _KERNEL
#ifdef VIMAGE_GLOBALS
extern LIST_HEAD(rawcb_list_head, rawcb) rawcb_list;
#endif
VNET_DECLARE(LIST_HEAD(rawcb_list_head, rawcb), rawcb_list);
#define V_rawcb_list VNET_GET(rawcb_list)
extern struct mtx rawcb_mtx;
/*

View File

@ -58,7 +58,6 @@ MTX_SYSINIT(rawcb_mtx, &rawcb_mtx, "rawcb", MTX_DEF);
void
raw_init(void)
{
INIT_VNET_NET(curvnet);
LIST_INIT(&V_rawcb_list);
}
@ -73,7 +72,6 @@ raw_init(void)
void
raw_input(struct mbuf *m0, struct sockproto *proto, struct sockaddr *src)
{
INIT_VNET_NET(curvnet);
struct rawcb *rp;
struct mbuf *m = m0;
struct socket *last;

View File

@ -63,7 +63,6 @@
#include <netinet/in.h>
#include <netinet/ip_mroute.h>
#include <netinet/vinet.h>
#include <vm/uma.h>
@ -88,68 +87,29 @@ SYSCTL_INT(_net, OID_AUTO, add_addr_allfibs, CTLFLAG_RW,
&rt_add_addr_allfibs, 0, "");
TUNABLE_INT("net.add_addr_allfibs", &rt_add_addr_allfibs);
#ifdef VIMAGE_GLOBALS
struct radix_node_head *rt_tables;
static uma_zone_t rtzone; /* Routing table UMA zone. */
int rttrash; /* routes not in table but not freed */
struct rtstat rtstat;
#endif
VNET_DEFINE(struct radix_node_head *, rt_tables);
static VNET_DEFINE(uma_zone_t, rtzone); /* Routing table UMA zone. */
VNET_DEFINE(int, rttrash); /* routes not in table but not freed */
VNET_DEFINE(struct rtstat, rtstat);
#ifndef VIMAGE_GLOBALS
struct vnet_rtable {
struct radix_node_head *_rt_tables;
uma_zone_t _rtzone;
int _rttrash;
struct rtstat _rtstat;
};
/* Size guard. See sys/vimage.h. */
VIMAGE_CTASSERT(SIZEOF_vnet_rtable, sizeof(struct vnet_rtable));
#ifndef VIMAGE
static struct vnet_rtable vnet_rtable_0;
#endif
#endif
/*
* Symbol translation macros
*/
#define INIT_VNET_RTABLE(vnet) \
INIT_FROM_VNET(vnet, VNET_MOD_RTABLE, struct vnet_rtable, vnet_rtable)
#define VNET_RTABLE(sym) VSYM(vnet_rtable, sym)
#define V_rt_tables VNET_RTABLE(rt_tables)
#define V_rtstat VNET_RTABLE(rtstat)
#define V_rttrash VNET_RTABLE(rttrash)
#define V_rtzone VNET_RTABLE(rtzone)
#define V_rt_tables VNET_GET(rt_tables)
#define V_rtzone VNET_GET(rtzone)
#define V_rttrash VNET_GET(rttrash)
#define V_rtstat VNET_GET(rtstat)
static void rt_maskedcopy(struct sockaddr *,
struct sockaddr *, struct sockaddr *);
static int vnet_route_iattach(const void *);
#ifdef VIMAGE
static int vnet_route_idetach(const void *);
#endif
#ifndef VIMAGE_GLOBALS
static struct vnet_symmap vnet_rtable_symmap[] = {
VNET_SYMMAP(rtable, rt_tables),
VNET_SYMMAP(rtable, rtstat),
VNET_SYMMAP(rtable, rttrash),
VNET_SYMMAP_END
};
static const vnet_modinfo_t vnet_rtable_modinfo = {
.vmi_id = VNET_MOD_RTABLE,
.vmi_name = "rtable",
.vmi_size = sizeof(struct vnet_rtable),
.vmi_symmap = vnet_rtable_symmap,
.vmi_iattach = vnet_route_iattach,
#ifdef VIMAGE
.vmi_idetach = vnet_route_idetach
#endif
};
#endif /* !VIMAGE_GLOBALS */
#endif
/* compare two sockaddr structures */
#define sa_equal(a1, a2) (bcmp((a1), (a2), (a1)->sa_len) == 0)
@ -192,7 +152,6 @@ SYSCTL_PROC(_net, OID_AUTO, my_fibnum, CTLTYPE_INT|CTLFLAG_RD,
static __inline struct radix_node_head **
rt_tables_get_rnh_ptr(int table, int fam)
{
INIT_VNET_RTABLE(curvnet);
struct radix_node_head **rnh;
KASSERT(table >= 0 && table < rt_numfibs, ("%s: table out of bounds.",
@ -226,7 +185,7 @@ route_init(void)
rt_numfibs = 1;
rn_init(); /* initialize all zeroes, all ones, mask table */
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_rtable_modinfo);
#else
vnet_route_iattach(NULL);
@ -236,7 +195,6 @@ route_init(void)
static int
vnet_route_iattach(const void *unused __unused)
{
INIT_VNET_RTABLE(curvnet);
struct domain *dom;
struct radix_node_head **rnh;
int table;
@ -382,7 +340,6 @@ struct rtentry *
rtalloc1_fib(struct sockaddr *dst, int report, u_long ignflags,
u_int fibnum)
{
INIT_VNET_RTABLE(curvnet);
struct radix_node_head *rnh;
struct rtentry *rt;
struct radix_node *rn;
@ -452,7 +409,6 @@ rtalloc1_fib(struct sockaddr *dst, int report, u_long ignflags,
void
rtfree(struct rtentry *rt)
{
INIT_VNET_RTABLE(curvnet);
struct radix_node_head *rnh;
KASSERT(rt != NULL,("%s: NULL rt", __func__));
@ -551,7 +507,6 @@ rtredirect_fib(struct sockaddr *dst,
struct sockaddr *src,
u_int fibnum)
{
INIT_VNET_RTABLE(curvnet);
struct rtentry *rt, *rt0 = NULL;
int error = 0;
short *stat = NULL;
@ -880,7 +835,6 @@ rt_getifa_fib(struct rt_addrinfo *info, u_int fibnum)
int
rtexpunge(struct rtentry *rt)
{
INIT_VNET_RTABLE(curvnet);
struct radix_node *rn;
struct radix_node_head *rnh;
struct ifaddr *ifa;
@ -1018,8 +972,6 @@ rn_mpath_update(int req, struct rt_addrinfo *info,
RT_LOCK(rt);
RT_ADDREF(rt);
if (req == RTM_DELETE) {
INIT_VNET_RTABLE(curvnet);
rt->rt_flags &= ~RTF_UP;
/*
* One more rtentry floating around that is not
@ -1027,7 +979,6 @@ rn_mpath_update(int req, struct rt_addrinfo *info,
* when RTFREE(rt) is eventually called.
*/
V_rttrash++;
}
nondelete:
@ -1054,7 +1005,6 @@ int
rtrequest1_fib(int req, struct rt_addrinfo *info, struct rtentry **ret_nrt,
u_int fibnum)
{
INIT_VNET_RTABLE(curvnet);
int error = 0, needlock = 0;
register struct rtentry *rt;
register struct radix_node *rn;

View File

@ -1238,7 +1238,6 @@ rt_ifannouncemsg(struct ifnet *ifp, int what)
static void
rt_dispatch(struct mbuf *m, const struct sockaddr *sa)
{
INIT_VNET_NET(curvnet);
struct m_tag *tag;
/*
@ -1317,7 +1316,6 @@ sysctl_dumpentry(struct radix_node *rn, void *vw)
static int
sysctl_iflist(int af, struct walkarg *w)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
struct ifaddr *ifa;
struct rt_addrinfo info;
@ -1378,7 +1376,6 @@ sysctl_iflist(int af, struct walkarg *w)
static int
sysctl_ifmalist(int af, struct walkarg *w)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
struct ifmultiaddr *ifma;
struct rt_addrinfo info;

341
sys/net/vnet.c Normal file
View File

@ -0,0 +1,341 @@
/*-
* Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org>
* Copyright (c) 2009 Robert N. M. Watson
* All rights reserved.
*
* 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 <sys/param.h>
#include <sys/kernel.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/sx.h>
#include <sys/sysctl.h>
#include <sys/vimage.h>
#include <net/vnet.h>
/*-
* This is the virtual network stack allocator, which 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' linker set. The details of the implementation are somewhat
* subtle, but allow the majority of most network subsystems to maintain
* virtualization-agnostic.
*
* The virtual network stack allocator handles variables in the base kernel
* vs. modules in similar but different ways. In both cases, virtualized
* global variables are marked as such by being declared to be part of the
* vnet linker set. These "master" copies of global variables serve two
* functions:
*
* (1) They contain static initialization or "default" values for global
* variables which will be propagated to each virtual network stack
* instance when created. As with normal global variables, they default
* to zero-filled.
*
* (2) They act as unique global names by which the variable can be referred
* to, regardless of network stack instance. The single global symbol
* will be used to calculate the location of a per-virtual instance
* variable at run-time.
*
* Each virtual network stack instance has a complete copy of each
* virtualized global variable, stored in a malloc'd block of memory
* referred to by vnet->vnet_data_mem. Critical to the design is that each
* per-instance memory block is laid out identically to the master block so
* that the offset of each global variable is the same across all blocks. To
* optimize run-time access, a precalculated 'base' address,
* vnet->vnet_data_base, is stored in each vnet, and is the amount that can
* be added to the address of a 'master' instance of a variable to get to the
* per-vnet instance.
*
* Virtualized global variables are handled in a similar manner, but as each
* module has its own 'set_vnet' linker set, and we want to keep all
* virtualized globals togther, we reserve space in the kernel's linker set
* for potential module variables using a per-vnet character array,
* 'modspace'. The virtual network stack allocator maintains a free list to
* track what space in the array is free (all, initially) and as modules are
* linked, allocates portions of the space to specific globals. The kernel
* module linker queries the virtual network stack allocator and will
* bind references of the global to the location during linking. It also
* calls into the virtual network stack allocator, once the memory is
* initialized, in order to propagate the new static initializations to all
* existing virtual network stack instances so that the soon-to-be executing
* module will find every network stack instance with proper default values.
*/
/*
* Location of the kernel's 'set_vnet' linker set.
*/
extern uintptr_t *__start_set_vnet;
extern uintptr_t *__stop_set_vnet;
#define VNET_START (uintptr_t)&__start_set_vnet
#define VNET_STOP (uintptr_t)&__stop_set_vnet
/*
* Number of bytes of data in the 'set_vnet' linker set, and hence the total
* size of all kernel virtualized global variables, and the malloc(9) type
* that will be used to allocate it.
*/
#define VNET_BYTES (VNET_STOP - VNET_START)
MALLOC_DEFINE(M_VNET_DATA, "vnet_data", "VNET data");
/*
* VNET_MODMIN is the minimum number of bytes we will reserve for the sum of
* global variables across all loaded modules. As this actually sizes an
* array declared as a virtualized global variable in the kernel itself, and
* we want the virtualized global variable space to be page-sized, we may
* have more space than that in practice.
*/
#define VNET_MODMIN 8192
#define VNET_SIZE roundup2(VNET_BYTES, PAGE_SIZE)
#define VNET_MODSIZE (VNET_SIZE - (VNET_BYTES - VNET_MODMIN))
/*
* Space to store virtualized global variables from loadable kernel modules,
* and the free list to manage it.
*/
static VNET_DEFINE(char, modspace[VNET_MODMIN]);
struct vnet_data_free {
uintptr_t vnd_start;
int vnd_len;
TAILQ_ENTRY(vnet_data_free) vnd_link;
};
MALLOC_DEFINE(M_VNET_DATA_FREE, "vnet_data_free", "VNET resource accounting");
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 storage for virtualized global variables in a new virtual network
* stack instance, and copy in initial values from our 'master' copy.
*/
void
vnet_data_init(struct vnet *vnet)
{
vnet->vnet_data_mem = malloc(VNET_SIZE, M_VNET_DATA, M_WAITOK);
memcpy(vnet->vnet_data_mem, (void *)VNET_START, VNET_BYTES);
/*
* All use of vnet-specific data will immediately subtract VNET_START
* from the base memory pointer, so pre-calculate that now to avoid
* it on each use.
*/
vnet->vnet_data_base = (uintptr_t)vnet->vnet_data_mem - VNET_START;
}
/*
* Release storage for a virtual network stack instance.
*/
void
vnet_data_destroy(struct vnet *vnet)
{
free(vnet->vnet_data_mem, M_VNET_DATA);
vnet->vnet_data_mem = NULL;
vnet->vnet_data_base = 0;
}
/*
* Once on boot, initialize the modspace freelist to entirely cover modspace.
*/
static void
vnet_data_startup(void *dummy __unused)
{
struct vnet_data_free *df;
df = malloc(sizeof(*df), M_VNET_DATA_FREE, M_WAITOK | M_ZERO);
df->vnd_start = (uintptr_t)&VNET_NAME(modspace);
df->vnd_len = VNET_MODSIZE;
TAILQ_INSERT_HEAD(&vnet_data_free_head, df, vnd_link);
sx_init(&vnet_data_free_lock, "vnet_data alloc lock");
}
SYSINIT(vnet_data, SI_SUB_KLD, SI_ORDER_FIRST, vnet_data_startup, 0);
/*
* When a module is loaded and requires storage for a virtualized global
* variable, allocate space from the modspace free list. This interface
* should be used only by the kernel linker.
*/
void *
vnet_data_alloc(int size)
{
struct vnet_data_free *df;
void *s;
s = NULL;
size = roundup2(size, sizeof(void *));
sx_xlock(&vnet_data_free_lock);
TAILQ_FOREACH(df, &vnet_data_free_head, vnd_link) {
if (df->vnd_len < size)
continue;
if (df->vnd_len == size) {
s = (void *)df->vnd_start;
TAILQ_REMOVE(&vnet_data_free_head, df, vnd_link);
free(df, M_VNET_DATA_FREE);
break;
}
s = (void *)df->vnd_start;
df->vnd_len -= size;
df->vnd_start = df->vnd_start + size;
break;
}
sx_xunlock(&vnet_data_free_lock);
return (s);
}
/*
* Free space for a virtualized global variable on module unload.
*/
void
vnet_data_free(void *start_arg, int size)
{
struct vnet_data_free *df;
struct vnet_data_free *dn;
uintptr_t start;
uintptr_t end;
size = roundup2(size, sizeof(void *));
start = (uintptr_t)start_arg;
end = start + size;
/*
* Free a region of space and merge it with as many neighbors as
* possible. Keeping the list sorted simplifies this operation.
*/
sx_xlock(&vnet_data_free_lock);
TAILQ_FOREACH(df, &vnet_data_free_head, vnd_link) {
if (df->vnd_start > end)
break;
/*
* If we expand at the end of an entry we may have to
* merge it with the one following it as well.
*/
if (df->vnd_start + df->vnd_len == start) {
df->vnd_len += size;
dn = TAILQ_NEXT(df, vnd_link);
if (df->vnd_start + df->vnd_len == dn->vnd_start) {
df->vnd_len += dn->vnd_len;
TAILQ_REMOVE(&vnet_data_free_head, dn, vnd_link);
free(dn, M_VNET_DATA_FREE);
}
sx_xunlock(&vnet_data_free_lock);
return;
}
if (df->vnd_start == end) {
df->vnd_start = start;
df->vnd_len += size;
sx_xunlock(&vnet_data_free_lock);
return;
}
}
dn = malloc(sizeof(*df), M_VNET_DATA_FREE, M_WAITOK | M_ZERO);
dn->vnd_start = start;
dn->vnd_len = size;
if (df)
TAILQ_INSERT_BEFORE(df, dn, vnd_link);
else
TAILQ_INSERT_TAIL(&vnet_data_free_head, dn, vnd_link);
sx_xunlock(&vnet_data_free_lock);
}
struct vnet_data_copy_fn_arg {
void *start;
int size;
};
static void
vnet_data_copy_fn(struct vnet *vnet, void *arg)
{
struct vnet_data_copy_fn_arg *varg = arg;
memcpy((void *)((uintptr_t)vnet->vnet_data_base +
(uintptr_t)varg->start), varg->start, varg->size);
}
/*
* When a new virtualized global variable has been allocated, propagate its
* initial value to each already-allocated virtual network stack instance.
*/
void
vnet_data_copy(void *start, int size)
{
struct vnet_data_copy_fn_arg varg;
varg.start = start;
varg.size = size;
vnet_foreach(vnet_data_copy_fn, &varg);
}
/*
* Variants on sysctl_handle_foo that know how to handle virtualized global
* variables: if 'arg1' is a pointer, then we transform it to the local vnet
* offset.
*/
int
vnet_sysctl_handle_int(SYSCTL_HANDLER_ARGS)
{
if (arg1 != NULL)
arg1 = (void *)(curvnet->vnet_data_base + (uintptr_t)arg1);
return (sysctl_handle_int(oidp, arg1, arg2, req));
}
int
vnet_sysctl_handle_opaque(SYSCTL_HANDLER_ARGS)
{
if (arg1 != NULL)
arg1 = (void *)(curvnet->vnet_data_base + (uintptr_t)arg1);
return (sysctl_handle_opaque(oidp, arg1, arg2, req));
}
int
vnet_sysctl_handle_string(SYSCTL_HANDLER_ARGS)
{
if (arg1 != NULL)
arg1 = (void *)(curvnet->vnet_data_base + (uintptr_t)arg1);
return (sysctl_handle_string(oidp, arg1, arg2, req));
}
int
vnet_sysctl_handle_uint(SYSCTL_HANDLER_ARGS)
{
if (arg1 != NULL)
arg1 = (void *)(curvnet->vnet_data_base + (uintptr_t)arg1);
return (sysctl_handle_int(oidp, arg1, arg2, req));
}

View File

@ -1,10 +1,6 @@
/*-
* Copyright (c) 2006-2008 University of Zagreb
* Copyright (c) 2006-2008 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.
* Copyright (c) 2009 Jeffrey Roberson <jeff@freebsd.org>
* Copyright (c) 2009 Robert N. M. Watson
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -30,62 +26,131 @@
* $FreeBSD$
*/
/*
* This is the virtual network stack memory allocator, which provides support
* for virtualized global variables via a special linker set, set_vnet. When
* "options VIMAGE" isn't defined, virtualized global variables are compiled
* as normal globals.
*/
#ifndef _NET_VNET_H_
#define _NET_VNET_H_
#include <net/if_var.h>
#ifdef _KERNEL
#ifdef VIMAGE
struct ifindex_entry;
struct vnet_net {
int _if_index;
struct ifindex_entry * _ifindex_table;
struct ifnethead _ifnet;
struct ifgrouphead _ifg_head;
int _if_indexlim;
struct ifnet * _loif;
struct if_clone * _lo_cloner;
struct ifc_simple_data *_lo_cloner_data;
LIST_HEAD(, rawcb) _rawcb_list;
LIST_HEAD(, if_clone) _if_cloners;
int _if_cloners_count;
int _ether_ipfw;
};
/* Size guard. See sys/vimage.h. */
VIMAGE_CTASSERT(SIZEOF_vnet_net, sizeof(struct vnet_net));
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
extern struct vnet_net vnet_net_0;
#endif
#if defined(__arm__)
__asm__(".section set_vnet, \"aw\", %progbits");
#else
__asm__(".section set_vnet, \"aw\", @progbits");
#endif
__asm__(".previous");
#define VNET_NAME(n) vnet_entry_##n
#define VNET_DECLARE(t, n) extern t VNET_NAME(n)
#define VNET_DEFINE(t, n) t VNET_NAME(n) __section("set_vnet") __used
#define _VNET_PTR(b, n) (__typeof(VNET_NAME(n))*) \
((b) + (uintptr_t)&VNET_NAME(n))
#define _VNET_GET(b, n) (*_VNET_PTR(b, n))
#define _VNET_SET(b, n, v) (*_VNET_PTR(b, n) = v)
/*
* Symbol translation macros
* Virtualized global variable accessor macros.
*/
#define INIT_VNET_NET(vnet) \
INIT_FROM_VNET(vnet, VNET_MOD_NET, struct vnet_net, vnet_net)
#define VNET_VNET_PTR(vnet, n) _VNET_PTR((vnet)->vnet_data_base, n)
#define VNET_VNET_GET(vnet, n) (*VNET_VNET_PTR((vnet), n))
#define VNET_VNET_SET(vnet, n, v) ((*VNET_VNET_PTR((vnet), n)) = v)
#define VNET_NET(sym) VSYM(vnet_net, sym)
#define VNET_PTR(n) VNET_VNET_PTR(curvnet, n)
#define VNET_GET(n) VNET_VNET_GET(curvnet, n)
#define VNET_SET(n, v) VNET_VNET_SET(curvnet, n, v)
#define V_ether_ipfw VNET_NET(ether_ipfw)
#define V_if_index VNET_NET(if_index)
#define V_if_indexlim VNET_NET(if_indexlim)
#define V_if_cloners VNET_NET(if_cloners)
#define V_if_cloners_count VNET_NET(if_cloners_count)
#define V_ifg_head VNET_NET(ifg_head)
#define V_ifindex_table VNET_NET(ifindex_table)
#define V_ifklist VNET_NET(ifklist)
#define V_ifnet VNET_NET(ifnet)
#define V_lo_cloner VNET_NET(lo_cloner)
#define V_lo_cloner_data VNET_NET(lo_cloner_data)
#define V_loif VNET_NET(loif)
#define V_rawcb_list VNET_NET(rawcb_list)
/*
* Sysctl variants for vnet-virtualized global variables. Include
* <sys/sysctl.h> to expose these definitions.
*
* Note: SYSCTL_PROC() handler functions will need to resolve pointer
* arguments themselves, if required.
*/
#ifdef SYSCTL_OID
int vnet_sysctl_handle_int(SYSCTL_HANDLER_ARGS);
int vnet_sysctl_handle_opaque(SYSCTL_HANDLER_ARGS);
int vnet_sysctl_handle_string(SYSCTL_HANDLER_ARGS);
int vnet_sysctl_handle_uint(SYSCTL_HANDLER_ARGS);
#define SYSCTL_VNET_INT(parent, nbr, name, access, ptr, val, descr) \
SYSCTL_OID(parent, nbr, name, CTLTYPE_INT|CTLFLAG_MPSAFE|(access), \
ptr, val, vnet_sysctl_handle_int, "I", descr)
#define SYSCTL_VNET_PROC(parent, nbr, name, access, ptr, arg, handler, \
fmt, descr) \
SYSCTL_OID(parent, nbr, name, access, ptr, arg, handler, fmt, \
descr)
#define SYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr) \
SYSCTL_OID(parent, nbr, name, CTLTYPE_STRING|(access), arg, \
len, vnet_sysctl_handle_string, "A", descr)
#define SYSCTL_VNET_STRUCT(parent, nbr, name, access, ptr, type, descr) \
SYSCTL_OID(parent, nbr, name, CTLTYPE_OPAQUE|(access), ptr, \
sizeof(struct type), vnet_sysctl_handle_opaque, "S," #type, \
descr)
#define SYSCTL_VNET_UINT(parent, nbr, name, access, ptr, val, descr) \
SYSCTL_OID(parent, nbr, name, CTLTYPE_UINT|CTLFLAG_MPSAFE|(access), \
ptr, val, vnet_sysctl_handle_uint, "IU", descr)
#endif /* SYSCTL_OID */
/*
* Interfaces from the kernel linker.
*/
void *vnet_data_alloc(int size);
void vnet_data_copy(void *start, int size);
void vnet_data_free(void *start_arg, int size);
/*
* Interfaces for vnet setup/teardown.
*/
struct vnet;
void vnet_data_init(struct vnet *vnet);
void vnet_data_destroy(struct vnet *vnet);
#else /* !VIMAGE */
/*
* Versions of the VNET macros that compile to normal global variables and
* standard sysctl definitions.
*/
#define VNET_NAME(n) n
#define VNET_DECLARE(t, n) extern t n
#define VNET_DEFINE(t, n) t n
#define _VNET_PTR(b, n) &VNET_NAME(n)
#ifdef SYSCTL_OID
#define SYSCTL_VNET_INT(parent, nbr, name, access, ptr, val, descr) \
SYSCTL_INT(parent, nbr, name, access, ptr, val, descr)
#define SYSCTL_VNET_PROC(parent, nbr, name, access, ptr, arg, handler, \
fmt, descr) \
SYSCTL_PROC(parent, nbr, name, access, ptr, arg, handler, fmt, \
descr)
#define SYSCTL_VNET_STRING(parent, nbr, name, access, arg, len, descr) \
SYSCTL_STRING(parent, nbr, name, access, arg, len, descr)
#define SYSCTL_VNET_STRUCT(parent, nbr, name, access, ptr, type, descr) \
SYSCTL_STRUCT(parent, nbr, name, access, ptr, type, descr)
#define SYSCTL_VNET_UINT(parent, nbr, name, access, ptr, val, descr) \
SYSCTL_UINT(parent, nbr, name, access, ptr, val, descr)
#endif /* SYSCTL_OID */
/*
* Virtualized global variable accessor macros.
*/
#define VNET_VNET_PTR(vnet, n) (&(n))
#define VNET_VNET_GET(vnet, n) (n)
#define VNET_VNET_SET(vnet, n, v) ((n) = (v))
#define VNET_PTR(n) (&(n))
#define VNET_GET(n) (n)
#define VNET_SET(n, v) ((n) = (v))
#endif /* VIMAGE */
#endif /* _KERNEL */
#endif /* !_NET_VNET_H_ */

View File

@ -165,7 +165,6 @@ DB_SHOW_ALL_COMMAND(vaps, db_show_all_vaps)
}
VNET_FOREACH(vnet_iter) {
INIT_VNET_NET(vnet_iter);
TAILQ_FOREACH(ifp, &V_ifnet, if_list)
if (ifp->if_type == IFT_IEEE80211) {
const struct ieee80211com *ic = ifp->if_l2com;

View File

@ -1407,7 +1407,6 @@ ng_atm_mod_event(module_t mod, int event, void *data)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET_QUIET(vnet_iter);
INIT_VNET_NET(vnet_iter);
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_ATM)
ng_atm_attach(ifp);
@ -1431,7 +1430,6 @@ ng_atm_mod_event(module_t mod, int event, void *data)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET_QUIET(vnet_iter);
INIT_VNET_NET(vnet_iter);
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_ATM)
ng_atm_detach(ifp);

View File

@ -1218,36 +1218,4 @@ typedef void *meta_p;
("%s: negative td_ng_outbound", __func__)); \
} while (0)
/* Virtualization macros */
#define INIT_VNET_NETGRAPH(vnet) \
INIT_FROM_VNET(vnet, VNET_MOD_NETGRAPH, \
struct vnet_netgraph, vnet_netgraph)
#define VNET_NETGRAPH(sym) VSYM(vnet_netgraph, sym)
struct vnet_netgraph {
LIST_HEAD(, ng_node) _ng_ID_hash[NG_ID_HASH_SIZE];
LIST_HEAD(, ng_node) _ng_name_hash[NG_NAME_HASH_SIZE];
LIST_HEAD(, ng_node) _ng_nodelist;
ng_ID_t _nextID;
struct unrhdr *_ng_iface_unit;
struct unrhdr *_ng_eiface_unit;
struct unrhdr *_ng_wormhole_unit;
};
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
extern struct vnet_netgraph vnet_netgraph_0;
#endif
#endif
/* Symbol translation macros */
#define V_nextID VNET_NETGRAPH(nextID)
#define V_ng_ID_hash VNET_NETGRAPH(ng_ID_hash)
#define V_ng_eiface_unit VNET_NETGRAPH(ng_eiface_unit)
#define V_ng_iface_unit VNET_NETGRAPH(ng_iface_unit)
#define V_ng_name_hash VNET_NETGRAPH(ng_name_hash)
#define V_ng_nodelist VNET_NETGRAPH(ng_nodelist)
#define V_ng_wormhole_unit VNET_NETGRAPH(ng_wormhole_unit)
#endif /* _NETGRAPH_NETGRAPH_H_ */

View File

@ -68,6 +68,7 @@
#include <machine/cpu.h>
#include <net/netisr.h>
#include <net/vnet.h>
#include <netgraph/ng_message.h>
#include <netgraph/netgraph.h>
@ -75,16 +76,9 @@
MODULE_VERSION(netgraph, NG_ABI_VERSION);
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
struct vnet_netgraph vnet_netgraph_0;
#endif
#endif
/* Mutex to protect topology events. */
static struct mtx ng_topo_mtx;
static vnet_attach_fn vnet_netgraph_iattach;
#ifdef VIMAGE
static vnet_detach_fn vnet_netgraph_idetach;
#endif
@ -182,9 +176,9 @@ static struct mtx ng_typelist_mtx;
/* Hash related definitions */
/* XXX Don't need to initialise them because it's a LIST */
#ifdef VIMAGE_GLOBALS
static LIST_HEAD(, ng_node) ng_ID_hash[NG_ID_HASH_SIZE];
#endif
static VNET_DEFINE(LIST_HEAD(, ng_node), ng_ID_hash[NG_ID_HASH_SIZE]);
#define V_ng_ID_hash VNET_GET(ng_ID_hash)
static struct mtx ng_idhash_mtx;
/* Method to find a node.. used twice so do it here */
#define NG_IDHASH_FN(ID) ((ID) % (NG_ID_HASH_SIZE))
@ -200,9 +194,9 @@ static struct mtx ng_idhash_mtx;
} \
} while (0)
#ifdef VIMAGE_GLOBALS
static LIST_HEAD(, ng_node) ng_name_hash[NG_NAME_HASH_SIZE];
#endif
static VNET_DEFINE(LIST_HEAD(, ng_node), ng_name_hash[NG_NAME_HASH_SIZE]);
#define V_ng_name_hash VNET_GET(ng_name_hash)
static struct mtx ng_namehash_mtx;
#define NG_NAMEHASH(NAME, HASH) \
do { \
@ -370,9 +364,8 @@ ng_alloc_node(void)
#define TRAP_ERROR()
#endif
#ifdef VIMAGE_GLOBALS
static ng_ID_t nextID;
#endif
static VNET_DEFINE(ng_ID_t, nextID) = 1;
#define V_nextID VNET_GET(nextID)
#ifdef INVARIANTS
#define CHECK_DATA_MBUF(m) do { \
@ -634,7 +627,6 @@ ng_make_node(const char *typename, node_p *nodepp)
int
ng_make_node_common(struct ng_type *type, node_p *nodepp)
{
INIT_VNET_NETGRAPH(curvnet);
node_p node;
/* Require the node type to have been already installed */
@ -819,7 +811,6 @@ ng_unref_node(node_p node)
static node_p
ng_ID2noderef(ng_ID_t ID)
{
INIT_VNET_NETGRAPH(curvnet);
node_p node;
mtx_lock(&ng_idhash_mtx);
NG_IDHASH_FIND(ID, node);
@ -845,7 +836,6 @@ ng_node2ID(node_p node)
int
ng_name_node(node_p node, const char *name)
{
INIT_VNET_NETGRAPH(curvnet);
int i, hash;
node_p node2;
@ -896,7 +886,6 @@ ng_name_node(node_p node, const char *name)
node_p
ng_name2noderef(node_p here, const char *name)
{
INIT_VNET_NETGRAPH(curvnet);
node_p node;
ng_ID_t temp;
int hash;
@ -2457,7 +2446,6 @@ ng_apply_item(node_p node, item_p item, int rw)
static int
ng_generic_msg(node_p here, item_p item, hook_p lasthook)
{
INIT_VNET_NETGRAPH(curvnet);
int error = 0;
struct ng_mesg *msg;
struct ng_mesg *resp = NULL;
@ -3080,37 +3068,24 @@ ng_mod_event(module_t mod, int event, void *data)
return (error);
}
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
static const vnet_modinfo_t vnet_netgraph_modinfo = {
.vmi_id = VNET_MOD_NETGRAPH,
.vmi_name = "netgraph",
.vmi_size = sizeof(struct vnet_netgraph),
.vmi_dependson = VNET_MOD_LOIF,
.vmi_iattach = vnet_netgraph_iattach,
#ifdef VIMAGE
.vmi_idetach = vnet_netgraph_idetach
#endif
};
#endif
static int
vnet_netgraph_iattach(const void *unused __unused)
{
INIT_VNET_NETGRAPH(curvnet);
V_nextID = 1;
return (0);
}
#ifdef VIMAGE
static int
vnet_netgraph_idetach(const void *unused __unused)
{
INIT_VNET_NETGRAPH(curvnet);
#if 0
node_p node, last_killed = NULL;
while ((node = LIST_FIRST(&V_ng_nodelist)) != NULL) {
/* XXXRW: utterly bogus. */
while ((node = LIST_FIRST(&V_ng_allnodes)) != NULL) {
if (node == last_killed) {
/* This should never happen */
node->nd_flags |= NGF_REALLY_DIE;
@ -3118,13 +3093,14 @@ vnet_netgraph_idetach(const void *unused __unused)
node->nd_name);
ng_rmnode(node, NULL, NULL, 0);
/* This must never happen */
if (node == LIST_FIRST(&V_ng_nodelist))
if (node == LIST_FIRST(&V_ng_allnodes))
panic("netgraph node %s won't die",
node->nd_name);
}
ng_rmnode(node, NULL, NULL, 0);
last_killed = node;
}
#endif
return (0);
}
@ -3144,10 +3120,8 @@ ngb_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
/* Initialize everything. */
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_netgraph_modinfo);
#else
vnet_netgraph_iattach(NULL);
#endif
NG_WORKLIST_LOCK_INIT();
mtx_init(&ng_typelist_mtx, "netgraph types mutex", NULL,

View File

@ -116,11 +116,10 @@ NETGRAPH_INIT(eiface, &typestruct);
static vnet_attach_fn ng_eiface_iattach;
static vnet_detach_fn ng_eiface_idetach;
#ifdef VIMAGE_GLOBALS
static struct unrhdr *ng_eiface_unit;
#endif
static VNET_DEFINE(struct unrhdr *, ng_eiface_unit);
#define V_ng_eiface_unit VNET_GET(ng_eiface_unit)
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
static vnet_modinfo_t vnet_ng_eiface_modinfo = {
.vmi_id = VNET_MOD_NG_EIFACE,
.vmi_name = "ng_eiface",
@ -351,7 +350,6 @@ ng_eiface_print_ioctl(struct ifnet *ifp, int command, caddr_t data)
static int
ng_eiface_constructor(node_p node)
{
INIT_VNET_NETGRAPH(curvnet);
struct ifnet *ifp;
priv_p priv;
u_char eaddr[6] = {0,0,0,0,0,0};
@ -563,7 +561,6 @@ ng_eiface_rcvdata(hook_p hook, item_p item)
static int
ng_eiface_rmnode(node_p node)
{
INIT_VNET_NETGRAPH(curvnet);
const priv_p priv = NG_NODE_PRIVATE(node);
struct ifnet *const ifp = priv->ifp;
@ -604,14 +601,14 @@ ng_eiface_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_ng_eiface_modinfo);
#else
ng_eiface_iattach(NULL);
#endif
break;
case MOD_UNLOAD:
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_deregister(&vnet_ng_eiface_modinfo);
#else
ng_eiface_idetach(NULL);
@ -626,7 +623,6 @@ ng_eiface_mod_event(module_t mod, int event, void *data)
static int ng_eiface_iattach(const void *unused)
{
INIT_VNET_NETGRAPH(curvnet);
V_ng_eiface_unit = new_unrhdr(0, 0xffff, NULL);
@ -635,7 +631,6 @@ static int ng_eiface_iattach(const void *unused)
static int ng_eiface_idetach(const void *unused)
{
INIT_VNET_NETGRAPH(curvnet);
delete_unrhdr(V_ng_eiface_unit);

View File

@ -74,7 +74,7 @@
static vnet_attach_fn ng_ether_iattach;
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
static vnet_modinfo_t vnet_ng_ether_modinfo = {
.vmi_id = VNET_MOD_NG_ETHER,
.vmi_name = "ng_ether",
@ -783,7 +783,7 @@ ng_ether_mod_event(module_t mod, int event, void *data)
ng_ether_input_orphan_p = ng_ether_input_orphan;
ng_ether_link_state_p = ng_ether_link_state;
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_ng_ether_modinfo);
#else
error = ng_ether_iattach(NULL);
@ -800,7 +800,7 @@ ng_ether_mod_event(module_t mod, int event, void *data)
* is MOD_UNLOAD, so there's no need to detach any nodes.
*/
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_deregister(&vnet_ng_ether_modinfo);
#endif
@ -823,7 +823,6 @@ ng_ether_mod_event(module_t mod, int event, void *data)
static int ng_ether_iattach(const void *unused)
{
INIT_VNET_NET(curvnet);
struct ifnet *ifp;
/* Create nodes for any already-existing Ethernet interfaces. */

View File

@ -565,7 +565,6 @@ ng_gif_mod_event(module_t mod, int event, void *data)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET_QUIET(vnet_iter); /* XXX revisit quiet */
INIT_VNET_NET(curvnet);
TAILQ_FOREACH(ifp, &V_ifnet, if_link) {
if (ifp->if_type == IFT_GIF)
ng_gif_attach(ifp);

View File

@ -212,11 +212,10 @@ NETGRAPH_INIT(iface, &typestruct);
static vnet_attach_fn ng_iface_iattach;
static vnet_detach_fn ng_iface_idetach;
#ifdef VIMAGE_GLOBALS
static struct unrhdr *ng_iface_unit;
#endif
static VNET_DEFINE(struct unrhdr *, ng_iface_unit);
#define V_ng_iface_unit VNET_GET(ng_iface_unit)
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
static vnet_modinfo_t vnet_ng_iface_modinfo = {
.vmi_id = VNET_MOD_NG_IFACE,
.vmi_name = "ng_iface",
@ -542,7 +541,6 @@ ng_iface_print_ioctl(struct ifnet *ifp, int command, caddr_t data)
static int
ng_iface_constructor(node_p node)
{
INIT_VNET_NETGRAPH(curvnet);
struct ifnet *ifp;
priv_p priv;
@ -806,7 +804,6 @@ ng_iface_rcvdata(hook_p hook, item_p item)
static int
ng_iface_shutdown(node_p node)
{
INIT_VNET_NETGRAPH(curvnet);
const priv_p priv = NG_NODE_PRIVATE(node);
/*
@ -852,14 +849,14 @@ ng_iface_mod_event(module_t mod, int event, void *data)
switch (event) {
case MOD_LOAD:
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_ng_iface_modinfo);
#else
ng_iface_iattach(NULL);
#endif
break;
case MOD_UNLOAD:
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_deregister(&vnet_ng_iface_modinfo);
#else
ng_iface_idetach(NULL);
@ -874,7 +871,6 @@ ng_iface_mod_event(module_t mod, int event, void *data)
static int ng_iface_iattach(const void *unused)
{
INIT_VNET_NETGRAPH(curvnet);
V_ng_iface_unit = new_unrhdr(0, 0xffff, NULL);
@ -883,7 +879,6 @@ static int ng_iface_iattach(const void *unused)
static int ng_iface_idetach(const void *unused)
{
INIT_VNET_NETGRAPH(curvnet);
delete_unrhdr(V_ng_iface_unit);

View File

@ -716,10 +716,11 @@ do { \
} \
} while (/*CONSTCOND*/ 0)
#ifdef VIMAGE_GLOBALS
extern int icmp6_rediraccept; /* accept/process redirects */
extern int icmp6_redirtimeout; /* cache time for redirect routes */
#endif
VNET_DECLARE(int, icmp6_rediraccept); /* accept/process redirects */
VNET_DECLARE(int, icmp6_redirtimeout); /* cache time for redirect routes */
#define V_icmp6_rediraccept VNET_GET(icmp6_rediraccept)
#define V_icmp6_redirtimeout VNET_GET(icmp6_redirtimeout)
#define ICMP6_NODEINFO_FQDNOK 0x1
#define ICMP6_NODEINFO_NODEADDROK 0x2

View File

@ -79,9 +79,10 @@ struct icmpstat {
#ifdef _KERNEL
SYSCTL_DECL(_net_inet_icmp);
#ifdef VIMAGE_GLOBALS
extern struct icmpstat icmpstat; /* icmp statistics */
#endif
VNET_DECLARE(struct icmpstat, icmpstat); /* icmp statistics. */
#define V_icmpstat VNET_GET(icmpstat)
extern int badport_bandlim(int);
#define BANDLIM_UNLIMITED -1
#define BANDLIM_ICMP_UNREACH 0

View File

@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_var.h>
#include <net/if_llatbl.h>
#include <netinet/if_ether.h>
#include <netinet/vinet.h>
#include <net/if_arc.h>
#include <net/iso88025.h>
@ -83,28 +82,33 @@ SYSCTL_DECL(_net_link_ether);
SYSCTL_NODE(_net_link_ether, PF_INET, inet, CTLFLAG_RW, 0, "");
/* timer values */
#ifdef VIMAGE_GLOBALS
static int arpt_keep; /* once resolved, good for 20 more minutes */
static int arp_maxtries;
int useloopback; /* use loopback interface for local traffic */
static int arp_proxyall;
#endif
static VNET_DEFINE(int, arpt_keep) = (20*60); /* once resolved, good for 20
* minutes */
static VNET_DEFINE(int, arp_maxtries) = 5;
static VNET_DEFINE(int, useloopback) = 1; /* use loopback interface for
* local traffic */
static VNET_DEFINE(int, arp_proxyall);
SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, max_age,
CTLFLAG_RW, arpt_keep, 0, "ARP entry lifetime in seconds");
#define V_arpt_keep VNET_GET(arpt_keep)
#define V_arp_maxtries VNET_GET(arp_maxtries)
#define V_useloopback VNET_GET(useloopback)
#define V_arp_proxyall VNET_GET(arp_proxyall)
SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, maxtries,
CTLFLAG_RW, arp_maxtries, 0,
SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, max_age, CTLFLAG_RW,
&VNET_NAME(arpt_keep), 0,
"ARP entry lifetime in seconds");
SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, maxtries, CTLFLAG_RW,
&VNET_NAME(arp_maxtries), 0,
"ARP resolution attempts before returning error");
SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, useloopback,
CTLFLAG_RW, useloopback, 0,
SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, useloopback, CTLFLAG_RW,
&VNET_NAME(useloopback), 0,
"Use the loopback interface for local traffic");
SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, proxyall,
CTLFLAG_RW, arp_proxyall, 0,
SYSCTL_VNET_INT(_net_link_ether_inet, OID_AUTO, proxyall, CTLFLAG_RW,
&VNET_NAME(arp_proxyall), 0,
"Enable proxy ARP for all suitable requests");
static void arp_init(void);
static int arp_iattach(const void *);
void arprequest(struct ifnet *,
struct in_addr *, struct in_addr *, u_char *);
static void arpintr(struct mbuf *);
@ -120,15 +124,6 @@ static const struct netisr_handler arp_nh = {
.nh_policy = NETISR_POLICY_SOURCE,
};
#ifndef VIMAGE_GLOBALS
static const vnet_modinfo_t vnet_arp_modinfo = {
.vmi_id = VNET_MOD_ARP,
.vmi_name = "arp",
.vmi_dependson = VNET_MOD_INET,
.vmi_iattach = arp_iattach
};
#endif /* !VIMAGE_GLOBALS */
#ifdef AF_INET
void arp_ifscrub(struct ifnet *ifp, uint32_t addr);
@ -263,7 +258,6 @@ int
arpresolve(struct ifnet *ifp, struct rtentry *rt0, struct mbuf *m,
struct sockaddr *dst, u_char *desten, struct llentry **lle)
{
INIT_VNET_INET(ifp->if_vnet);
struct llentry *la = 0;
u_int flags = 0;
int error, renew;
@ -482,7 +476,6 @@ in_arpinput(struct mbuf *m)
sin.sin_len = sizeof(struct sockaddr_in);
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = 0;
INIT_VNET_INET(ifp->if_vnet);
if (ifp->if_bridge)
bridged = 1;
@ -825,29 +818,10 @@ arp_ifinit2(struct ifnet *ifp, struct ifaddr *ifa, u_char *enaddr)
ifa->ifa_rtrequest = NULL;
}
static int
arp_iattach(const void *unused __unused)
{
INIT_VNET_INET(curvnet);
V_arpt_keep = (20*60); /* once resolved, good for 20 more minutes */
V_arp_maxtries = 5;
V_useloopback = 1; /* use loopback interface for local traffic */
V_arp_proxyall = 0;
return (0);
}
static void
arp_init(void)
{
#ifndef VIMAGE_GLOBALS
vnet_mod_register(&vnet_arp_modinfo);
#else
arp_iattach(NULL);
#endif
netisr_register(&arp_nh);
}
SYSINIT(arp, SI_SUB_PROTO_DOMAIN, SI_ORDER_ANY, arp_init, 0);

View File

@ -75,7 +75,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_options.h>
#include <netinet/igmp.h>
#include <netinet/igmp_var.h>
#include <netinet/vinet.h>
#include <machine/in_cksum.h>
@ -212,55 +211,72 @@ MALLOC_DEFINE(M_IGMP, "igmp", "igmp state");
* FUTURE: Stop using IFP_TO_IA/INADDR_ANY, and use source address selection
* policy to control the address used by IGMP on the link.
*/
#ifdef VIMAGE_GLOBALS
int interface_timers_running; /* IGMPv3 general query response */
int state_change_timers_running; /* IGMPv3 state-change retransmit */
int current_state_timers_running; /* IGMPv1/v2 host report;
* IGMPv3 g/sg query response */
static VNET_DEFINE(int, interface_timers_running); /* IGMPv3 general
* query response */
static VNET_DEFINE(int, state_change_timers_running); /* IGMPv3 state-change
* retransmit */
static VNET_DEFINE(int, current_state_timers_running); /* IGMPv1/v2 host
* report; IGMPv3 g/sg
* query response */
LIST_HEAD(, igmp_ifinfo) igi_head;
struct igmpstat igmpstat;
struct timeval igmp_gsrdelay;
#define V_interface_timers_running VNET_GET(interface_timers_running)
#define V_state_change_timers_running VNET_GET(state_change_timers_running)
#define V_current_state_timers_running VNET_GET(current_state_timers_running)
int igmp_recvifkludge;
int igmp_sendra;
int igmp_sendlocal;
int igmp_v1enable;
int igmp_v2enable;
int igmp_legacysupp;
int igmp_default_version;
#endif /* VIMAGE_GLOBALS */
static VNET_DEFINE(LIST_HEAD(, igmp_ifinfo), igi_head);
static VNET_DEFINE(struct igmpstat, igmpstat);
static VNET_DEFINE(struct timeval, igmp_gsrdelay) = {10, 0};
#define V_igi_head VNET_GET(igi_head)
#define V_igmpstat VNET_GET(igmpstat)
#define V_igmp_gsrdelay VNET_GET(igmp_gsrdelay)
static VNET_DEFINE(int, igmp_recvifkludge) = 1;
static VNET_DEFINE(int, igmp_sendra) = 1;
static VNET_DEFINE(int, igmp_sendlocal) = 1;
static VNET_DEFINE(int, igmp_v1enable) = 1;
static VNET_DEFINE(int, igmp_v2enable) = 1;
static VNET_DEFINE(int, igmp_legacysupp);
static VNET_DEFINE(int, igmp_default_version) = IGMP_VERSION_3;
#define V_igmp_recvifkludge VNET_GET(igmp_recvifkludge)
#define V_igmp_sendra VNET_GET(igmp_sendra)
#define V_igmp_sendlocal VNET_GET(igmp_sendlocal)
#define V_igmp_v1enable VNET_GET(igmp_v1enable)
#define V_igmp_v2enable VNET_GET(igmp_v2enable)
#define V_igmp_legacysupp VNET_GET(igmp_legacysupp)
#define V_igmp_default_version VNET_GET(igmp_default_version)
/*
* Virtualized sysctls.
*/
SYSCTL_V_STRUCT(V_NET, vnet_inet, _net_inet_igmp, IGMPCTL_STATS, stats,
CTLFLAG_RW, igmpstat, igmpstat, "");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_igmp, OID_AUTO, recvifkludge,
CTLFLAG_RW, igmp_recvifkludge, 0,
SYSCTL_VNET_STRUCT(_net_inet_igmp, IGMPCTL_STATS, stats, CTLFLAG_RW,
&VNET_NAME(igmpstat), igmpstat, "");
SYSCTL_VNET_INT(_net_inet_igmp, OID_AUTO, recvifkludge, CTLFLAG_RW,
&VNET_NAME(igmp_recvifkludge), 0,
"Rewrite IGMPv1/v2 reports from 0.0.0.0 to contain subnet address");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_igmp, OID_AUTO, sendra,
CTLFLAG_RW, igmp_sendra, 0,
SYSCTL_VNET_INT(_net_inet_igmp, OID_AUTO, sendra, CTLFLAG_RW,
&VNET_NAME(igmp_sendra), 0,
"Send IP Router Alert option in IGMPv2/v3 messages");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_igmp, OID_AUTO, sendlocal,
CTLFLAG_RW, igmp_sendlocal, 0,
SYSCTL_VNET_INT(_net_inet_igmp, OID_AUTO, sendlocal, CTLFLAG_RW,
&VNET_NAME(igmp_sendlocal), 0,
"Send IGMP membership reports for 224.0.0.0/24 groups");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_igmp, OID_AUTO, v1enable,
CTLFLAG_RW, igmp_v1enable, 0,
SYSCTL_VNET_INT(_net_inet_igmp, OID_AUTO, v1enable, CTLFLAG_RW,
&VNET_NAME(igmp_v1enable), 0,
"Enable backwards compatibility with IGMPv1");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_igmp, OID_AUTO, v2enable,
CTLFLAG_RW, igmp_v2enable, 0,
SYSCTL_VNET_INT(_net_inet_igmp, OID_AUTO, v2enable, CTLFLAG_RW,
&VNET_NAME(igmp_v2enable), 0,
"Enable backwards compatibility with IGMPv2");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_igmp, OID_AUTO, legacysupp,
CTLFLAG_RW, igmp_legacysupp, 0,
SYSCTL_VNET_INT(_net_inet_igmp, OID_AUTO, legacysupp, CTLFLAG_RW,
&VNET_NAME(igmp_legacysupp), 0,
"Allow v1/v2 reports to suppress v3 group responses");
SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_igmp, OID_AUTO, default_version,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, igmp_default_version, 0,
sysctl_igmp_default_version, "I",
SYSCTL_VNET_PROC(_net_inet_igmp, OID_AUTO, default_version,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
&VNET_NAME(igmp_default_version), 0, sysctl_igmp_default_version, "I",
"Default version of IGMP to run on each interface");
SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_igmp, OID_AUTO, gsrdelay,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE, igmp_gsrdelay.tv_sec, 0,
sysctl_igmp_gsr, "I",
SYSCTL_VNET_PROC(_net_inet_igmp, OID_AUTO, gsrdelay,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_MPSAFE,
&VNET_NAME(igmp_gsrdelay.tv_sec), 0, sysctl_igmp_gsr, "I",
"Rate limit for IGMPv3 Group-and-Source queries in seconds");
/*
@ -327,7 +343,6 @@ igmp_restore_context(struct mbuf *m)
static int
sysctl_igmp_default_version(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_INET(curvnet);
int error;
int new;
@ -367,7 +382,6 @@ sysctl_igmp_default_version(SYSCTL_HANDLER_ARGS)
static int
sysctl_igmp_gsr(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_INET(curvnet);
int error;
int i;
@ -408,8 +422,6 @@ sysctl_igmp_gsr(SYSCTL_HANDLER_ARGS)
static int
sysctl_igmp_ifinfo(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_NET(curvnet);
INIT_VNET_INET(curvnet);
int *name;
int error;
u_int namelen;
@ -495,7 +507,6 @@ igmp_dispatch_queue(struct ifqueue *ifq, int limit, const int loop)
static __inline int
igmp_isgroupreported(const struct in_addr addr)
{
INIT_VNET_INET(curvnet);
if (in_allhosts(addr) ||
((!V_igmp_sendlocal && IN_LOCAL_GROUP(ntohl(addr.s_addr)))))
@ -553,7 +564,6 @@ igmp_domifattach(struct ifnet *ifp)
static struct igmp_ifinfo *
igi_alloc_locked(/*const*/ struct ifnet *ifp)
{
INIT_VNET_INET(ifp->if_vnet);
struct igmp_ifinfo *igi;
IGMP_LOCK_ASSERT();
@ -661,7 +671,6 @@ igmp_domifdetach(struct ifnet *ifp)
static void
igi_delete_locked(const struct ifnet *ifp)
{
INIT_VNET_INET(ifp->if_vnet);
struct igmp_ifinfo *igi, *tigi;
CTR3(KTR_IGMPV3, "%s: freeing igmp_ifinfo for ifp %p(%s)",
@ -702,7 +711,6 @@ static int
igmp_input_v1_query(struct ifnet *ifp, const struct ip *ip,
const struct igmp *igmp)
{
INIT_VNET_INET(ifp->if_vnet);
struct ifmultiaddr *ifma;
struct igmp_ifinfo *igi;
struct in_multi *inm;
@ -788,7 +796,6 @@ static int
igmp_input_v2_query(struct ifnet *ifp, const struct ip *ip,
const struct igmp *igmp)
{
INIT_VNET_INET(ifp->if_vnet);
struct ifmultiaddr *ifma;
struct igmp_ifinfo *igi;
struct in_multi *inm;
@ -893,7 +900,6 @@ igmp_input_v2_query(struct ifnet *ifp, const struct ip *ip,
static void
igmp_v2_update_group(struct in_multi *inm, const int timer)
{
INIT_VNET_INET(curvnet);
CTR4(KTR_IGMPV3, "%s: %s/%s timer=%d", __func__,
inet_ntoa(inm->inm_addr), inm->inm_ifp->if_xname, timer);
@ -941,7 +947,6 @@ static int
igmp_input_v3_query(struct ifnet *ifp, const struct ip *ip,
/*const*/ struct igmpv3 *igmpv3)
{
INIT_VNET_INET(ifp->if_vnet);
struct igmp_ifinfo *igi;
struct in_multi *inm;
int is_general_query;
@ -1106,7 +1111,6 @@ static int
igmp_input_v3_group_query(struct in_multi *inm, struct igmp_ifinfo *igi,
int timer, /*const*/ struct igmpv3 *igmpv3)
{
INIT_VNET_INET(curvnet);
int retval;
uint16_t nsrc;
@ -1209,7 +1213,6 @@ static int
igmp_input_v1_report(struct ifnet *ifp, /*const*/ struct ip *ip,
/*const*/ struct igmp *igmp)
{
INIT_VNET_INET(ifp->if_vnet);
struct in_ifaddr *ia;
struct in_multi *inm;
@ -1318,7 +1321,6 @@ static int
igmp_input_v2_report(struct ifnet *ifp, /*const*/ struct ip *ip,
/*const*/ struct igmp *igmp)
{
INIT_VNET_INET(ifp->if_vnet);
struct in_ifaddr *ia;
struct in_multi *inm;
@ -1436,7 +1438,6 @@ igmp_input(struct mbuf *m, int off)
CTR3(KTR_IGMPV3, "%s: called w/mbuf (%p,%d)", __func__, m, off);
ifp = m->m_pkthdr.rcvif;
INIT_VNET_INET(ifp->if_vnet);
IGMPSTAT_INC(igps_rcv_total);
@ -1633,7 +1634,6 @@ igmp_fasttimo(void)
static void
igmp_fasttimo_vnet(void)
{
INIT_VNET_INET(curvnet);
struct ifqueue scq; /* State-change packets */
struct ifqueue qrq; /* Query response packets */
struct ifnet *ifp;
@ -1756,7 +1756,6 @@ igmp_fasttimo_vnet(void)
static void
igmp_v1v2_process_group_timer(struct in_multi *inm, const int version)
{
INIT_VNET_INET(curvnet);
int report_timer_expired;
IN_MULTI_LOCK_ASSERT();
@ -1805,7 +1804,6 @@ igmp_v3_process_group_timers(struct igmp_ifinfo *igi,
struct ifqueue *qrq, struct ifqueue *scq,
struct in_multi *inm, const int uri_fasthz)
{
INIT_VNET_INET(curvnet);
int query_response_timer_expired;
int state_change_retransmit_timer_expired;
@ -2083,7 +2081,6 @@ igmp_v3_cancel_link_timers(struct igmp_ifinfo *igi)
static void
igmp_v1v2_process_querier_timers(struct igmp_ifinfo *igi)
{
INIT_VNET_INET(curvnet);
IGMP_LOCK_ASSERT();
@ -2177,7 +2174,6 @@ igmp_slowtimo(void)
static void
igmp_slowtimo_vnet(void)
{
INIT_VNET_INET(curvnet);
struct igmp_ifinfo *igi;
IGMP_LOCK();
@ -2342,7 +2338,6 @@ igmp_change_state(struct in_multi *inm)
static int
igmp_initial_join(struct in_multi *inm, struct igmp_ifinfo *igi)
{
INIT_VNET_INET(curvnet);
struct ifnet *ifp;
struct ifqueue *ifq;
int error, retval, syncstates;
@ -2471,7 +2466,6 @@ igmp_initial_join(struct in_multi *inm, struct igmp_ifinfo *igi)
static int
igmp_handle_state_change(struct in_multi *inm, struct igmp_ifinfo *igi)
{
INIT_VNET_INET(curvnet);
struct ifnet *ifp;
int retval;
@ -2531,7 +2525,6 @@ igmp_handle_state_change(struct in_multi *inm, struct igmp_ifinfo *igi)
static void
igmp_final_leave(struct in_multi *inm, struct igmp_ifinfo *igi)
{
INIT_VNET_INET(curvnet);
int syncstates;
syncstates = 1;
@ -3324,7 +3317,6 @@ igmp_v3_merge_state_changes(struct in_multi *inm, struct ifqueue *ifscq)
static void
igmp_v3_dispatch_general_query(struct igmp_ifinfo *igi)
{
INIT_VNET_INET(curvnet);
struct ifmultiaddr *ifma, *tifma;
struct ifnet *ifp;
struct in_multi *inm;
@ -3412,8 +3404,6 @@ igmp_intr(struct mbuf *m)
* unique to each VIMAGE and must be retrieved.
*/
CURVNET_SET((struct vnet *)(m->m_pkthdr.header));
INIT_VNET_NET(curvnet);
INIT_VNET_INET(curvnet);
ifindex = igmp_restore_context(m);
/*
@ -3495,7 +3485,6 @@ igmp_intr(struct mbuf *m)
static struct mbuf *
igmp_v3_encap_report(struct ifnet *ifp, struct mbuf *m)
{
INIT_VNET_INET(curvnet);
struct igmp_report *igmp;
struct ip *ip;
int hdrlen, igmpreclen;
@ -3621,30 +3610,14 @@ igmp_sysuninit(void)
static int
vnet_igmp_iattach(const void *unused __unused)
{
INIT_VNET_INET(curvnet);
CTR1(KTR_IGMPV3, "%s: initializing", __func__);
LIST_INIT(&V_igi_head);
V_current_state_timers_running = 0;
V_state_change_timers_running = 0;
V_interface_timers_running = 0;
/*
* Initialize sysctls to default values.
*/
V_igmp_recvifkludge = 1;
V_igmp_sendra = 1;
V_igmp_sendlocal = 1;
V_igmp_v1enable = 1;
V_igmp_v2enable = 1;
V_igmp_legacysupp = 0;
V_igmp_default_version = IGMP_VERSION_3;
V_igmp_gsrdelay.tv_sec = 10;
V_igmp_gsrdelay.tv_usec = 0;
memset(&V_igmpstat, 0, sizeof(struct igmpstat));
V_igmpstat.igps_version = IGPS_VERSION_3;
V_igmpstat.igps_len = sizeof(struct igmpstat);
@ -3654,9 +3627,6 @@ vnet_igmp_iattach(const void *unused __unused)
static int
vnet_igmp_idetach(const void *unused __unused)
{
#ifdef INVARIANTS
INIT_VNET_INET(curvnet);
#endif
CTR1(KTR_IGMPV3, "%s: tearing down", __func__);
@ -3666,7 +3636,7 @@ vnet_igmp_idetach(const void *unused __unused)
return (0);
}
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
static vnet_modinfo_t vnet_igmp_modinfo = {
.vmi_id = VNET_MOD_IGMP,
.vmi_name = "igmp",
@ -3683,14 +3653,14 @@ igmp_modevent(module_t mod, int type, void *unused __unused)
switch (type) {
case MOD_LOAD:
igmp_sysinit();
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_register(&vnet_igmp_modinfo);
#else
vnet_igmp_iattach(NULL);
#endif
break;
case MOD_UNLOAD:
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
vnet_mod_deregister(&vnet_igmp_modinfo);
#else
vnet_igmp_idetach(NULL);

View File

@ -59,8 +59,9 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_var.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/vinet.h>
#include <netinet/igmp_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
static int in_mask2len(struct in_addr *);
static void in_len2mask(struct in_addr *, int);
@ -74,17 +75,19 @@ static int in_ifinit(struct ifnet *,
struct in_ifaddr *, struct sockaddr_in *, int);
static void in_purgemaddrs(struct ifnet *);
#ifdef VIMAGE_GLOBALS
static int subnetsarelocal;
static int sameprefixcarponly;
extern struct inpcbinfo ripcbinfo;
#endif
static VNET_DEFINE(int, subnetsarelocal);
static VNET_DEFINE(int, sameprefixcarponly);
VNET_DECLARE(struct inpcbinfo, ripcbinfo);
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, subnets_are_local,
CTLFLAG_RW, subnetsarelocal, 0,
#define V_subnetsarelocal VNET_GET(subnetsarelocal)
#define V_sameprefixcarponly VNET_GET(sameprefixcarponly)
#define V_ripcbinfo VNET_GET(ripcbinfo)
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, subnets_are_local, CTLFLAG_RW,
&VNET_NAME(subnetsarelocal), 0,
"Treat all subnets as directly connected");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, same_prefix_carp_only,
CTLFLAG_RW, sameprefixcarponly, 0,
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, same_prefix_carp_only, CTLFLAG_RW,
&VNET_NAME(sameprefixcarponly), 0,
"Refuse to create same prefixes on different interfaces");
/*
@ -96,7 +99,6 @@ SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, same_prefix_carp_only,
int
in_localaddr(struct in_addr in)
{
INIT_VNET_INET(curvnet);
register u_long i = ntohl(in.s_addr);
register struct in_ifaddr *ia;
@ -127,7 +129,6 @@ in_localaddr(struct in_addr in)
int
in_localip(struct in_addr in)
{
INIT_VNET_INET(curvnet);
struct in_ifaddr *ia;
IN_IFADDR_RLOCK();
@ -225,7 +226,6 @@ int
in_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
struct thread *td)
{
INIT_VNET_INET(curvnet); /* both so and ifp can be NULL here! */
register struct ifreq *ifr = (struct ifreq *)data;
register struct in_ifaddr *ia, *iap;
register struct ifaddr *ifa;
@ -816,8 +816,6 @@ static int
in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin,
int scrub)
{
INIT_VNET_NET(ifp->if_vnet);
INIT_VNET_INET(ifp->if_vnet);
register u_long i = ntohl(sin->sin_addr.s_addr);
struct sockaddr_in oldaddr;
struct rtentry *rt = NULL;
@ -952,7 +950,6 @@ in_ifinit(struct ifnet *ifp, struct in_ifaddr *ia, struct sockaddr_in *sin,
static int
in_addprefix(struct in_ifaddr *target, int flags)
{
INIT_VNET_INET(curvnet);
struct in_ifaddr *ia;
struct in_addr prefix, mask, p, m;
int error;
@ -1020,8 +1017,6 @@ extern void arp_ifscrub(struct ifnet *ifp, uint32_t addr);
static int
in_scrubprefix(struct in_ifaddr *target)
{
INIT_VNET_NET(curvnet);
INIT_VNET_INET(curvnet);
struct in_ifaddr *ia;
struct in_addr prefix, mask, p;
int error;
@ -1166,7 +1161,6 @@ in_broadcast(struct in_addr in, struct ifnet *ifp)
void
in_ifdetach(struct ifnet *ifp)
{
INIT_VNET_INET(ifp->if_vnet);
in_pcbpurgeif0(&V_ripcbinfo, ifp);
in_pcbpurgeif0(&V_udbinfo, ifp);

View File

@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_var.h>
#include <netinet/ip_encap.h>
#include <netinet/ip_ecn.h>
#include <netinet/vinet.h>
#ifdef INET6
#include <netinet/ip6.h>
@ -86,16 +85,12 @@ struct protosw in_gif_protosw = {
.pr_usrreqs = &rip_usrreqs
};
#ifdef VIMAGE_GLOBALS
extern int ip_gif_ttl;
#endif
SYSCTL_V_INT(V_NET, vnet_gif, _net_inet_ip, IPCTL_GIF_TTL, gifttl,
CTLFLAG_RW, ip_gif_ttl, 0, "");
SYSCTL_VNET_INT(_net_inet_ip, IPCTL_GIF_TTL, gifttl, CTLFLAG_RW,
&VNET_NAME(ip_gif_ttl), 0, "");
int
in_gif_output(struct ifnet *ifp, int family, struct mbuf *m)
{
INIT_VNET_GIF(ifp->if_vnet);
struct gif_softc *sc = ifp->if_softc;
struct sockaddr_in *dst = (struct sockaddr_in *)&sc->gif_ro.ro_dst;
struct sockaddr_in *sin_src = (struct sockaddr_in *)sc->gif_psrc;
@ -273,7 +268,6 @@ in_gif_output(struct ifnet *ifp, int family, struct mbuf *m)
void
in_gif_input(struct mbuf *m, int off)
{
INIT_VNET_INET(curvnet);
struct ifnet *gifp = NULL;
struct gif_softc *sc;
struct ip *ip;
@ -368,7 +362,6 @@ in_gif_input(struct mbuf *m, int off)
static int
gif_validate4(const struct ip *ip, struct gif_softc *sc, struct ifnet *ifp)
{
INIT_VNET_INET(curvnet);
struct sockaddr_in *src, *dst;
struct in_ifaddr *ia4;

View File

@ -60,7 +60,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_var.h>
#include <netinet/ip_var.h>
#include <netinet/igmp_var.h>
#include <netinet/vinet.h>
#ifndef KTR_IGMPV3
#define KTR_IGMPV3 KTR_INET
@ -84,10 +83,6 @@ static MALLOC_DEFINE(M_IPMOPTS, "ip_moptions", "IPv4 multicast options");
static MALLOC_DEFINE(M_IPMSOURCE, "ip_msource",
"IPv4 multicast IGMP-layer source filter");
#ifdef VIMAGE_GLOBALS
struct in_multihead in_multihead; /* XXX now unused; retain for ABI */
#endif
/*
* Locking:
* - Lock order is: Giant, INP_WLOCK, IN_MULTI_LOCK, IGMP_LOCK, IF_ADDR_LOCK.
@ -1295,8 +1290,6 @@ in_delmulti(struct in_multi *inm)
static int
inp_block_unblock_source(struct inpcb *inp, struct sockopt *sopt)
{
INIT_VNET_NET(curvnet);
INIT_VNET_INET(curvnet);
struct group_source_req gsr;
sockunion_t *gsa, *ssa;
struct ifnet *ifp;
@ -1560,7 +1553,6 @@ inp_freemoptions(struct ip_moptions *imo)
static int
inp_get_source_filters(struct inpcb *inp, struct sockopt *sopt)
{
INIT_VNET_NET(curvnet);
struct __msfilterreq msfr;
sockunion_t *gsa;
struct ifnet *ifp;
@ -1678,7 +1670,6 @@ inp_get_source_filters(struct inpcb *inp, struct sockopt *sopt)
int
inp_getmoptions(struct inpcb *inp, struct sockopt *sopt)
{
INIT_VNET_INET(curvnet);
struct ip_mreqn mreqn;
struct ip_moptions *imo;
struct ifnet *ifp;
@ -1809,7 +1800,6 @@ static struct ifnet *
inp_lookup_mcast_ifp(const struct inpcb *inp,
const struct sockaddr_in *gsin, const struct in_addr ina)
{
INIT_VNET_INET(curvnet);
struct ifnet *ifp;
KASSERT(gsin->sin_family == AF_INET, ("%s: not AF_INET", __func__));
@ -1856,7 +1846,6 @@ inp_lookup_mcast_ifp(const struct inpcb *inp,
static int
inp_join_group(struct inpcb *inp, struct sockopt *sopt)
{
INIT_VNET_NET(curvnet);
struct group_source_req gsr;
sockunion_t *gsa, *ssa;
struct ifnet *ifp;
@ -2097,8 +2086,6 @@ inp_join_group(struct inpcb *inp, struct sockopt *sopt)
static int
inp_leave_group(struct inpcb *inp, struct sockopt *sopt)
{
INIT_VNET_NET(curvnet);
INIT_VNET_INET(curvnet);
struct group_source_req gsr;
struct ip_mreq_source mreqs;
sockunion_t *gsa, *ssa;
@ -2308,8 +2295,6 @@ inp_leave_group(struct inpcb *inp, struct sockopt *sopt)
static int
inp_set_multicast_if(struct inpcb *inp, struct sockopt *sopt)
{
INIT_VNET_NET(curvnet);
INIT_VNET_INET(curvnet);
struct in_addr addr;
struct ip_mreqn mreqn;
struct ifnet *ifp;
@ -2376,7 +2361,6 @@ inp_set_multicast_if(struct inpcb *inp, struct sockopt *sopt)
static int
inp_set_source_filters(struct inpcb *inp, struct sockopt *sopt)
{
INIT_VNET_NET(curvnet);
struct __msfilterreq msfr;
sockunion_t *gsa;
struct ifnet *ifp;
@ -2699,7 +2683,6 @@ inp_setmoptions(struct inpcb *inp, struct sockopt *sopt)
static int
sysctl_ip_mcast_filters(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_NET(curvnet);
struct in_addr src, group;
struct ifnet *ifp;
struct ifmultiaddr *ifma;

View File

@ -70,11 +70,9 @@ __FBSDID("$FreeBSD$");
#include <netinet/tcp_var.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/vinet.h>
#ifdef INET6
#include <netinet/ip6.h>
#include <netinet6/ip6_var.h>
#include <netinet6/vinet6.h>
#endif /* INET6 */
@ -85,34 +83,34 @@ __FBSDID("$FreeBSD$");
#include <security/mac/mac_framework.h>
#ifdef VIMAGE_GLOBALS
/*
* These configure the range of local port addresses assigned to
* "unspecified" outgoing connections/packets/whatever.
*/
int ipport_lowfirstauto;
int ipport_lowlastauto;
int ipport_firstauto;
int ipport_lastauto;
int ipport_hifirstauto;
int ipport_hilastauto;
VNET_DEFINE(int, ipport_lowfirstauto) = IPPORT_RESERVED - 1; /* 1023 */
VNET_DEFINE(int, ipport_lowlastauto) = IPPORT_RESERVEDSTART; /* 600 */
VNET_DEFINE(int, ipport_firstauto) = IPPORT_EPHEMERALFIRST; /* 10000 */
VNET_DEFINE(int, ipport_lastauto) = IPPORT_EPHEMERALLAST; /* 65535 */
VNET_DEFINE(int, ipport_hifirstauto) = IPPORT_HIFIRSTAUTO; /* 49152 */
VNET_DEFINE(int, ipport_hilastauto) = IPPORT_HILASTAUTO; /* 65535 */
/*
* Reserved ports accessible only to root. There are significant
* security considerations that must be accounted for when changing these,
* but the security benefits can be great. Please be careful.
*/
int ipport_reservedhigh;
int ipport_reservedlow;
VNET_DEFINE(int, ipport_reservedhigh) = IPPORT_RESERVED - 1; /* 1023 */
VNET_DEFINE(int, ipport_reservedlow);
/* Variables dealing with random ephemeral port allocation. */
int ipport_randomized;
int ipport_randomcps;
int ipport_randomtime;
int ipport_stoprandom;
int ipport_tcpallocs;
int ipport_tcplastcount;
#endif
VNET_DEFINE(int, ipport_randomized) = 1; /* user controlled via sysctl */
VNET_DEFINE(int, ipport_randomcps) = 10; /* user controlled via sysctl */
VNET_DEFINE(int, ipport_randomtime) = 45; /* user controlled via sysctl */
VNET_DEFINE(int, ipport_stoprandom); /* toggled by ipport_tick */
VNET_DEFINE(int, ipport_tcpallocs);
static VNET_DEFINE(int, ipport_tcplastcount);
#define V_ipport_tcplastcount VNET_GET(ipport_tcplastcount)
#define RANGECHK(var, min, max) \
if ((var) < (min)) { (var) = (min); } \
@ -123,12 +121,13 @@ static void in_pcbremlists(struct inpcb *inp);
static int
sysctl_net_ipport_check(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_INET(curvnet);
int error;
SYSCTL_RESOLVE_V_ARG1();
#ifdef VIMAGE
error = vnet_sysctl_handle_int(oidp, arg1, arg2, req);
#else
error = sysctl_handle_int(oidp, arg1, arg2, req);
#endif
if (error == 0) {
RANGECHK(V_ipport_lowfirstauto, 1, IPPORT_RESERVED - 1);
RANGECHK(V_ipport_lowlastauto, 1, IPPORT_RESERVED - 1);
@ -144,35 +143,35 @@ sysctl_net_ipport_check(SYSCTL_HANDLER_ARGS)
SYSCTL_NODE(_net_inet_ip, IPPROTO_IP, portrange, CTLFLAG_RW, 0, "IP Ports");
SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO,
lowfirst, CTLTYPE_INT|CTLFLAG_RW, ipport_lowfirstauto, 0,
SYSCTL_VNET_PROC(_net_inet_ip_portrange, OID_AUTO, lowfirst,
CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(ipport_lowfirstauto), 0,
&sysctl_net_ipport_check, "I", "");
SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO,
lowlast, CTLTYPE_INT|CTLFLAG_RW, ipport_lowlastauto, 0,
SYSCTL_VNET_PROC(_net_inet_ip_portrange, OID_AUTO, lowlast,
CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(ipport_lowlastauto), 0,
&sysctl_net_ipport_check, "I", "");
SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO,
first, CTLTYPE_INT|CTLFLAG_RW, ipport_firstauto, 0,
SYSCTL_VNET_PROC(_net_inet_ip_portrange, OID_AUTO, first,
CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(ipport_firstauto), 0,
&sysctl_net_ipport_check, "I", "");
SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO,
last, CTLTYPE_INT|CTLFLAG_RW, ipport_lastauto, 0,
SYSCTL_VNET_PROC(_net_inet_ip_portrange, OID_AUTO, last,
CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(ipport_lastauto), 0,
&sysctl_net_ipport_check, "I", "");
SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO,
hifirst, CTLTYPE_INT|CTLFLAG_RW, ipport_hifirstauto, 0,
SYSCTL_VNET_PROC(_net_inet_ip_portrange, OID_AUTO, hifirst,
CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(ipport_hifirstauto), 0,
&sysctl_net_ipport_check, "I", "");
SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO,
hilast, CTLTYPE_INT|CTLFLAG_RW, ipport_hilastauto, 0,
SYSCTL_VNET_PROC(_net_inet_ip_portrange, OID_AUTO, hilast,
CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(ipport_hilastauto), 0,
&sysctl_net_ipport_check, "I", "");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO,
reservedhigh, CTLFLAG_RW|CTLFLAG_SECURE, ipport_reservedhigh, 0, "");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO, reservedlow,
CTLFLAG_RW|CTLFLAG_SECURE, ipport_reservedlow, 0, "");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO, randomized,
CTLFLAG_RW, ipport_randomized, 0, "Enable random port allocation");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO, randomcps,
CTLFLAG_RW, ipport_randomcps, 0, "Maximum number of random port "
SYSCTL_VNET_INT(_net_inet_ip_portrange, OID_AUTO, reservedhigh,
CTLFLAG_RW|CTLFLAG_SECURE, &VNET_NAME(ipport_reservedhigh), 0, "");
SYSCTL_VNET_INT(_net_inet_ip_portrange, OID_AUTO, reservedlow,
CTLFLAG_RW|CTLFLAG_SECURE, &VNET_NAME(ipport_reservedlow), 0, "");
SYSCTL_VNET_INT(_net_inet_ip_portrange, OID_AUTO, randomized, CTLFLAG_RW,
&VNET_NAME(ipport_randomized), 0, "Enable random port allocation");
SYSCTL_VNET_INT(_net_inet_ip_portrange, OID_AUTO, randomcps, CTLFLAG_RW,
&VNET_NAME(ipport_randomcps), 0, "Maximum number of random port "
"allocations before switching to a sequental one");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO, randomtime,
CTLFLAG_RW, ipport_randomtime, 0,
SYSCTL_VNET_INT(_net_inet_ip_portrange, OID_AUTO, randomtime, CTLFLAG_RW,
&VNET_NAME(ipport_randomtime), 0,
"Minimum time to keep sequental port "
"allocation before switching to a random one");
@ -191,9 +190,6 @@ SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip_portrange, OID_AUTO, randomtime,
int
in_pcballoc(struct socket *so, struct inpcbinfo *pcbinfo)
{
#ifdef INET6
INIT_VNET_INET6(curvnet);
#endif
struct inpcb *inp;
int error;
@ -288,7 +284,6 @@ int
in_pcbbind_setup(struct inpcb *inp, struct sockaddr *nam, in_addr_t *laddrp,
u_short *lportp, struct ucred *cred)
{
INIT_VNET_INET(inp->inp_vnet);
struct socket *so = inp->inp_socket;
unsigned short *lastport;
struct sockaddr_in *sin;
@ -776,7 +771,6 @@ in_pcbconnect_setup(struct inpcb *inp, struct sockaddr *nam,
in_addr_t *laddrp, u_short *lportp, in_addr_t *faddrp, u_short *fportp,
struct inpcb **oinpp, struct ucred *cred)
{
INIT_VNET_INET(inp->inp_vnet);
struct sockaddr_in *sin = (struct sockaddr_in *)nam;
struct in_ifaddr *ia;
struct inpcb *oinp;
@ -1579,7 +1573,6 @@ ipport_tick(void *xtp)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter); /* XXX appease INVARIANTS here */
INIT_VNET_INET(vnet_iter);
if (V_ipport_tcpallocs <=
V_ipport_tcplastcount + V_ipport_randomcps) {
if (V_ipport_stoprandom > 0)
@ -1640,7 +1633,6 @@ inp_unlock_assert(struct inpcb *inp)
void
inp_apply_all(void (*func)(struct inpcb *, void *), void *arg)
{
INIT_VNET_INET(curvnet);
struct inpcb *inp;
INP_INFO_RLOCK(&V_tcbinfo);

View File

@ -41,6 +41,7 @@
#ifdef _KERNEL
#include <sys/rwlock.h>
#include <net/vnet.h>
#endif
#define in6pcb inpcb /* for KAME src sync over BSD*'s */
@ -450,21 +451,34 @@ void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
#define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af)
#ifdef _KERNEL
#ifdef VIMAGE_GLOBALS
extern int ipport_reservedhigh;
extern int ipport_reservedlow;
extern int ipport_lowfirstauto;
extern int ipport_lowlastauto;
extern int ipport_firstauto;
extern int ipport_lastauto;
extern int ipport_hifirstauto;
extern int ipport_hilastauto;
extern int ipport_randomized;
extern int ipport_randomcps;
extern int ipport_randomtime;
extern int ipport_stoprandom;
extern int ipport_tcpallocs;
#endif
VNET_DECLARE(int, ipport_reservedhigh);
VNET_DECLARE(int, ipport_reservedlow);
VNET_DECLARE(int, ipport_lowfirstauto);
VNET_DECLARE(int, ipport_lowlastauto);
VNET_DECLARE(int, ipport_firstauto);
VNET_DECLARE(int, ipport_lastauto);
VNET_DECLARE(int, ipport_hifirstauto);
VNET_DECLARE(int, ipport_hilastauto);
VNET_DECLARE(int, ipport_randomized);
VNET_DECLARE(int, ipport_randomcps);
VNET_DECLARE(int, ipport_randomtime);
VNET_DECLARE(int, ipport_stoprandom);
VNET_DECLARE(int, ipport_tcpallocs);
#define V_ipport_reservedhigh VNET_GET(ipport_reservedhigh)
#define V_ipport_reservedlow VNET_GET(ipport_reservedlow)
#define V_ipport_lowfirstauto VNET_GET(ipport_lowfirstauto)
#define V_ipport_lowlastauto VNET_GET(ipport_lowlastauto)
#define V_ipport_firstauto VNET_GET(ipport_firstauto)
#define V_ipport_lastauto VNET_GET(ipport_lastauto)
#define V_ipport_hifirstauto VNET_GET(ipport_hifirstauto)
#define V_ipport_hilastauto VNET_GET(ipport_hilastauto)
#define V_ipport_randomized VNET_GET(ipport_randomized)
#define V_ipport_randomcps VNET_GET(ipport_randomcps)
#define V_ipport_randomtime VNET_GET(ipport_randomtime)
#define V_ipport_stoprandom VNET_GET(ipport_stoprandom)
#define V_ipport_tcpallocs VNET_GET(ipport_tcpallocs)
extern struct callout ipport_tick_callout;
void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);

View File

@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netinet/ip_var.h>
#include <netinet/vinet.h>
extern int in_inithead(void **head, int off);
#ifdef VIMAGE
@ -132,22 +131,24 @@ in_matroute(void *v_arg, struct radix_node_head *head)
return rn;
}
#ifdef VIMAGE_GLOBALS
static int rtq_reallyold;
static int rtq_minreallyold;
static int rtq_toomany;
#endif
static VNET_DEFINE(int, rtq_reallyold);
static VNET_DEFINE(int, rtq_minreallyold);
static VNET_DEFINE(int, rtq_toomany);
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_RTEXPIRE, rtexpire,
CTLFLAG_RW, rtq_reallyold, 0,
#define V_rtq_reallyold VNET_GET(rtq_reallyold)
#define V_rtq_minreallyold VNET_GET(rtq_minreallyold)
#define V_rtq_toomany VNET_GET(rtq_toomany)
SYSCTL_VNET_INT(_net_inet_ip, IPCTL_RTEXPIRE, rtexpire, CTLFLAG_RW,
&VNET_NAME(rtq_reallyold), 0,
"Default expiration time on dynamically learned routes");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_RTMINEXPIRE,
rtminexpire, CTLFLAG_RW, rtq_minreallyold, 0,
SYSCTL_VNET_INT(_net_inet_ip, IPCTL_RTMINEXPIRE, rtminexpire, CTLFLAG_RW,
&VNET_NAME(rtq_minreallyold), 0,
"Minimum time to attempt to hold onto dynamically learned routes");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_RTMAXCACHE,
rtmaxcache, CTLFLAG_RW, rtq_toomany, 0,
SYSCTL_VNET_INT(_net_inet_ip, IPCTL_RTMAXCACHE, rtmaxcache, CTLFLAG_RW,
&VNET_NAME(rtq_toomany), 0,
"Upper limit on dynamically learned routes");
/*
@ -157,7 +158,6 @@ SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_RTMAXCACHE,
static void
in_clsroute(struct radix_node *rn, struct radix_node_head *head)
{
INIT_VNET_INET(curvnet);
struct rtentry *rt = (struct rtentry *)rn;
RT_LOCK_ASSERT(rt);
@ -200,7 +200,6 @@ struct rtqk_arg {
static int
in_rtqkill(struct radix_node *rn, void *rock)
{
INIT_VNET_INET(curvnet);
struct rtqk_arg *ap = rock;
struct rtentry *rt = (struct rtentry *)rn;
int err;
@ -240,10 +239,11 @@ in_rtqkill(struct radix_node *rn, void *rock)
}
#define RTQ_TIMEOUT 60*10 /* run no less than once every ten minutes */
#ifdef VIMAGE_GLOBALS
static int rtq_timeout;
static struct callout rtq_timer;
#endif
static VNET_DEFINE(int, rtq_timeout);
static VNET_DEFINE(struct callout, rtq_timer);
#define V_rtq_timeout VNET_GET(rtq_timeout)
#define V_rtq_timer VNET_GET(rtq_timer)
static void in_rtqtimo_one(void *rock);
@ -251,7 +251,6 @@ static void
in_rtqtimo(void *rock)
{
CURVNET_SET((struct vnet *) rock);
INIT_VNET_INET(curvnet);
int fibnum;
void *newrock;
struct timeval atv;
@ -270,7 +269,6 @@ in_rtqtimo(void *rock)
static void
in_rtqtimo_one(void *rock)
{
INIT_VNET_INET(curvnet);
struct radix_node_head *rnh = rock;
struct rtqk_arg arg;
static time_t last_adjusted_timeout = 0;
@ -348,7 +346,6 @@ static int _in_rt_was_here;
int
in_inithead(void **head, int off)
{
INIT_VNET_INET(curvnet);
struct radix_node_head *rnh;
/* XXX MRT
@ -386,7 +383,6 @@ in_inithead(void **head, int off)
int
in_detachhead(void **head, int off)
{
INIT_VNET_INET(curvnet);
callout_drain(&V_rtq_timer);
return (1);

View File

@ -102,11 +102,14 @@ extern u_char inetctlerrmap[];
*/
TAILQ_HEAD(in_ifaddrhead, in_ifaddr);
LIST_HEAD(in_ifaddrhashhead, in_ifaddr);
#ifdef VIMAGE_GLOBALS
extern struct in_ifaddrhashhead *in_ifaddrhashtbl;
extern struct in_ifaddrhead in_ifaddrhead;
extern u_long in_ifaddrhmask; /* mask for hash table */
#endif
VNET_DECLARE(struct in_ifaddrhashhead *, in_ifaddrhashtbl);
VNET_DECLARE(struct in_ifaddrhead, in_ifaddrhead);
VNET_DECLARE(u_long, in_ifaddrhmask); /* mask for hash table */
#define V_in_ifaddrhashtbl VNET_GET(in_ifaddrhashtbl)
#define V_in_ifaddrhead VNET_GET(in_ifaddrhead)
#define V_in_ifaddrhmask VNET_GET(in_ifaddrhmask)
#define INADDR_NHASH_LOG2 9
#define INADDR_NHASH (1 << INADDR_NHASH_LOG2)
@ -345,11 +348,6 @@ SYSCTL_DECL(_net_inet_ip);
SYSCTL_DECL(_net_inet_raw);
#endif
LIST_HEAD(in_multihead, in_multi); /* XXX unused */
#ifdef VIMAGE_GLOBALS
extern struct in_multihead in_multihead;
#endif
/*
* Lock macros for IPv4 layer multicast address lists. IPv4 lock goes
* before link layer multicast locks in the lock order. In most cases,

View File

@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_var.h>
#include <netinet/if_ether.h>
#include <machine/in_cksum.h>
#include <netinet/vinet.h>
#endif
#ifdef INET6
@ -83,7 +82,6 @@ __FBSDID("$FreeBSD$");
#include <netinet6/ip6_var.h>
#include <netinet6/scope6_var.h>
#include <netinet6/nd6.h>
#include <netinet6/vinet6.h>
#endif
#include <crypto/sha1.h>
@ -920,7 +918,6 @@ carp_send_ad_locked(struct carp_softc *sc)
ch.carp_cksum = 0;
#ifdef INET
INIT_VNET_INET(curvnet);
if (sc->sc_ia) {
struct ip *ip;
@ -1476,7 +1473,6 @@ carp_multicast6_cleanup(struct carp_softc *sc)
static int
carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin)
{
INIT_VNET_INET(curvnet);
struct ifnet *ifp;
struct carp_if *cif;
struct in_ifaddr *ia, *ia_if;
@ -1655,7 +1651,6 @@ carp_del_addr(struct carp_softc *sc, struct sockaddr_in *sin)
static int
carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6)
{
INIT_VNET_INET6(curvnet);
struct ifnet *ifp;
struct carp_if *cif;
struct in6_ifaddr *ia, *ia_if;

View File

@ -75,7 +75,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_divert.h>
#include <netinet/ip_var.h>
#include <netinet/ip_fw.h>
#include <netinet/vinet.h>
#ifdef SCTP
#include <netinet/sctp_crc32.h>
#endif
@ -117,10 +116,11 @@ __FBSDID("$FreeBSD$");
*/
/* Internal variables. */
#ifdef VIMAGE_GLOBALS
static struct inpcbhead divcb;
static struct inpcbinfo divcbinfo;
#endif
static VNET_DEFINE(struct inpcbhead, divcb);
static VNET_DEFINE(struct inpcbinfo, divcbinfo);
#define V_divcb VNET_GET(divcb)
#define V_divcbinfo VNET_GET(divcbinfo)
static u_long div_sendspace = DIVSNDQ; /* XXX sysctl ? */
static u_long div_recvspace = DIVRCVQ; /* XXX sysctl ? */
@ -131,7 +131,6 @@ static u_long div_recvspace = DIVRCVQ; /* XXX sysctl ? */
static void
div_zone_change(void *tag)
{
INIT_VNET_INET(curvnet);
uma_zone_set_max(V_divcbinfo.ipi_zone, maxsockets);
}
@ -156,7 +155,6 @@ div_inpcb_fini(void *mem, int size)
void
div_init(void)
{
INIT_VNET_INET(curvnet);
INP_INFO_LOCK_INIT(&V_divcbinfo, "div");
LIST_INIT(&V_divcb);
@ -187,7 +185,6 @@ div_init(void)
void
div_input(struct mbuf *m, int off)
{
INIT_VNET_INET(curvnet);
IPSTAT_INC(ips_noproto);
m_freem(m);
@ -202,7 +199,6 @@ div_input(struct mbuf *m, int off)
static void
divert_packet(struct mbuf *m, int incoming)
{
INIT_VNET_INET(curvnet);
struct ip *ip;
struct inpcb *inp;
struct socket *sa;
@ -330,7 +326,6 @@ static int
div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
struct mbuf *control)
{
INIT_VNET_INET(curvnet);
struct m_tag *mtag;
struct divert_tag *dt;
int error = 0;
@ -483,7 +478,6 @@ div_output(struct socket *so, struct mbuf *m, struct sockaddr_in *sin,
static int
div_attach(struct socket *so, int proto, struct thread *td)
{
INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
int error;
@ -515,7 +509,6 @@ div_attach(struct socket *so, int proto, struct thread *td)
static void
div_detach(struct socket *so)
{
INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
inp = sotoinpcb(so);
@ -530,7 +523,6 @@ div_detach(struct socket *so)
static int
div_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
{
INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
int error;
@ -571,7 +563,6 @@ static int
div_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
struct mbuf *control, struct thread *td)
{
INIT_VNET_INET(so->so_vnet);
/* Packet must have a header (but that's about it) */
if (m->m_len < sizeof (struct ip) &&
@ -600,7 +591,6 @@ div_ctlinput(int cmd, struct sockaddr *sa, void *vip)
static int
div_pcblist(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_INET(curvnet);
int error, i, n;
struct inpcb *inp, **inp_list;
inp_gen_t gencnt;
@ -725,7 +715,6 @@ struct protosw div_protosw = {
static int
div_modevent(module_t mod, int type, void *unused)
{
INIT_VNET_INET(curvnet); /* XXX move to iattach - revisit!!! */
int err = 0;
int n;

View File

@ -103,20 +103,18 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_var.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_options.h>
#include <netinet/vinet.h>
#include <machine/in_cksum.h>
#ifdef VIMAGE_GLOBALS
static int ipfastforward_active;
#endif
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, fastforwarding,
CTLFLAG_RW, ipfastforward_active, 0, "Enable fast IP forwarding");
static VNET_DEFINE(int, ipfastforward_active);
#define V_ipfastforward_active VNET_GET(ipfastforward_active)
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, fastforwarding, CTLFLAG_RW,
&VNET_NAME(ipfastforward_active), 0, "Enable fast IP forwarding");
static struct sockaddr_in *
ip_findroute(struct route *ro, struct in_addr dest, struct mbuf *m)
{
INIT_VNET_INET(curvnet);
struct sockaddr_in *dst;
struct rtentry *rt;
@ -160,7 +158,6 @@ ip_findroute(struct route *ro, struct in_addr dest, struct mbuf *m)
struct mbuf *
ip_fastforward(struct mbuf *m)
{
INIT_VNET_INET(curvnet);
struct ip *ip;
struct mbuf *m0 = NULL;
struct route ro;

View File

@ -651,12 +651,14 @@ void ipfw_destroy(void);
void ipfw_nat_destroy(void);
#endif
#ifdef VIMAGE_GLOBALS
extern int fw_one_pass;
extern int fw_enable;
VNET_DECLARE(int, fw_one_pass);
VNET_DECLARE(int, fw_enable);
#define V_fw_one_pass VNET_GET(fw_one_pass)
#define V_fw_enable VNET_GET(fw_enable)
#ifdef INET6
extern int fw6_enable;
#endif
VNET_DECLARE(int, fw6_enable);
#define V_fw6_enable VNET_GET(fw6_enable)
#endif
struct ip_fw_chain {
@ -692,83 +694,8 @@ typedef int ipfw_nat_t(struct ip_fw_args *, struct cfg_nat *, struct mbuf *);
typedef int ipfw_nat_cfg_t(struct sockopt *);
#endif
struct eventhandler_entry;
/*
* Stack virtualization support.
*/
struct vnet_ipfw {
int _fw_enable;
int _fw6_enable;
u_int32_t _set_disable;
int _fw_deny_unknown_exthdrs;
int _fw_verbose;
int _verbose_limit;
int _autoinc_step;
ipfw_dyn_rule ** _ipfw_dyn_v;
uma_zone_t _ipfw_dyn_rule_zone;
struct ip_fw_chain _layer3_chain;
u_int32_t _dyn_buckets;
u_int32_t _curr_dyn_buckets;
u_int32_t _dyn_ack_lifetime;
u_int32_t _dyn_syn_lifetime;
u_int32_t _dyn_fin_lifetime;
u_int32_t _dyn_rst_lifetime;
u_int32_t _dyn_udp_lifetime;
u_int32_t _dyn_short_lifetime;
u_int32_t _dyn_keepalive_interval;
u_int32_t _dyn_keepalive_period;
u_int32_t _dyn_keepalive;
u_int32_t _static_count;
u_int32_t _static_len;
u_int32_t _dyn_count;
u_int32_t _dyn_max;
u_int64_t _norule_counter;
struct callout _ipfw_timeout;
struct eventhandler_entry *_ifaddr_event_tag;
};
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
extern struct vnet_ipfw vnet_ipfw_0;
#endif
#endif
/*
* Symbol translation macros
*/
#define INIT_VNET_IPFW(vnet) \
INIT_FROM_VNET(vnet, VNET_MOD_IPFW, struct vnet_ipfw, vnet_ipfw)
#define VNET_IPFW(sym) VSYM(vnet_ipfw, sym)
#define V_fw_enable VNET_IPFW(fw_enable)
#define V_fw6_enable VNET_IPFW(fw6_enable)
#define V_set_disable VNET_IPFW(set_disable)
#define V_fw_deny_unknown_exthdrs VNET_IPFW(fw_deny_unknown_exthdrs)
#define V_fw_verbose VNET_IPFW(fw_verbose)
#define V_verbose_limit VNET_IPFW(verbose_limit)
#define V_autoinc_step VNET_IPFW(autoinc_step)
#define V_ipfw_dyn_v VNET_IPFW(ipfw_dyn_v)
#define V_ipfw_dyn_rule_zone VNET_IPFW(ipfw_dyn_rule_zone)
#define V_layer3_chain VNET_IPFW(layer3_chain)
#define V_dyn_buckets VNET_IPFW(dyn_buckets)
#define V_curr_dyn_buckets VNET_IPFW(curr_dyn_buckets)
#define V_dyn_ack_lifetime VNET_IPFW(dyn_ack_lifetime)
#define V_dyn_syn_lifetime VNET_IPFW(dyn_syn_lifetime)
#define V_dyn_fin_lifetime VNET_IPFW(dyn_fin_lifetime)
#define V_dyn_rst_lifetime VNET_IPFW(dyn_rst_lifetime)
#define V_dyn_udp_lifetime VNET_IPFW(dyn_udp_lifetime)
#define V_dyn_short_lifetime VNET_IPFW(dyn_short_lifetime)
#define V_dyn_keepalive_interval VNET_IPFW(dyn_keepalive_interval)
#define V_dyn_keepalive_period VNET_IPFW(dyn_keepalive_period)
#define V_dyn_keepalive VNET_IPFW(dyn_keepalive)
#define V_static_count VNET_IPFW(static_count)
#define V_static_len VNET_IPFW(static_len)
#define V_dyn_count VNET_IPFW(dyn_count)
#define V_dyn_max VNET_IPFW(dyn_max)
#define V_norule_counter VNET_IPFW(norule_counter)
#define V_ipfw_timeout VNET_IPFW(ipfw_timeout)
#define V_ifaddr_event_tag VNET_IPFW(ifaddr_event_tag)
VNET_DECLARE(struct ip_fw_chain, layer3_chain);
#define V_layer3_chain VNET_GET(layer3_chain)
#endif /* _KERNEL */
#endif /* _IPFW2_H */

View File

@ -47,6 +47,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>
@ -60,7 +61,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/tcp_var.h>
#include <netinet/tcpip.h>
#include <netinet/icmp_var.h>
#include <netinet/vinet.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
@ -77,61 +77,75 @@ __FBSDID("$FreeBSD$");
* host table maintenance routines.
*/
#ifdef VIMAGE_GLOBALS
struct icmpstat icmpstat;
static int icmpmaskrepl;
static u_int icmpmaskfake;
static int drop_redirect;
static int log_redirect;
static int icmplim;
static int icmplim_output;
static char reply_src[IFNAMSIZ];
static int icmp_rfi;
static int icmp_quotelen;
static int icmpbmcastecho;
#endif
VNET_DEFINE(struct icmpstat, icmpstat);
static VNET_DEFINE(int, icmpmaskrepl);
static VNET_DEFINE(u_int, icmpmaskfake);
static VNET_DEFINE(int, drop_redirect);
static VNET_DEFINE(int, log_redirect);
static VNET_DEFINE(int, icmplim);
static VNET_DEFINE(int, icmplim_output);
static VNET_DEFINE(char, reply_src[IFNAMSIZ]);
static VNET_DEFINE(int, icmp_rfi);
static VNET_DEFINE(int, icmp_quotelen);
static VNET_DEFINE(int, icmpbmcastecho);
SYSCTL_V_STRUCT(V_NET, vnet_inet, _net_inet_icmp, ICMPCTL_STATS, stats,
CTLFLAG_RW, icmpstat, icmpstat, "");
#define V_icmpmaskrepl VNET_GET(icmpmaskrepl)
#define V_icmpmaskfake VNET_GET(icmpmaskfake)
#define V_drop_redirect VNET_GET(drop_redirect)
#define V_log_redirect VNET_GET(log_redirect)
#define V_icmplim VNET_GET(icmplim)
#define V_icmplim_output VNET_GET(icmplim_output)
#define V_reply_src VNET_GET(reply_src)
#define V_icmp_rfi VNET_GET(icmp_rfi)
#define V_icmp_quotelen VNET_GET(icmp_quotelen)
#define V_icmpbmcastecho VNET_GET(icmpbmcastecho)
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_icmp, ICMPCTL_MASKREPL, maskrepl,
CTLFLAG_RW, icmpmaskrepl, 0,
SYSCTL_VNET_STRUCT(_net_inet_icmp, ICMPCTL_STATS, stats, CTLFLAG_RW,
&VNET_NAME(icmpstat), icmpstat, "");
SYSCTL_VNET_INT(_net_inet_icmp, ICMPCTL_MASKREPL, maskrepl, CTLFLAG_RW,
&VNET_NAME(icmpmaskrepl), 0,
"Reply to ICMP Address Mask Request packets.");
SYSCTL_V_UINT(V_NET, vnet_inet, _net_inet_icmp, OID_AUTO, maskfake, CTLFLAG_RW,
icmpmaskfake, 0, "Fake reply to ICMP Address Mask Request packets.");
SYSCTL_VNET_UINT(_net_inet_icmp, OID_AUTO, maskfake, CTLFLAG_RW,
&VNET_NAME(icmpmaskfake), 0,
"Fake reply to ICMP Address Mask Request packets.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_icmp, OID_AUTO, drop_redirect,
CTLFLAG_RW, drop_redirect, 0, "Ignore ICMP redirects");
SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, drop_redirect, CTLFLAG_RW,
&VNET_NAME(drop_redirect), 0,
"Ignore ICMP redirects");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_icmp, OID_AUTO, log_redirect,
CTLFLAG_RW, log_redirect, 0, "Log ICMP redirects to the console");
SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, log_redirect, CTLFLAG_RW,
&VNET_NAME(log_redirect), 0,
"Log ICMP redirects to the console");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_icmp, ICMPCTL_ICMPLIM, icmplim,
CTLFLAG_RW, icmplim, 0, "Maximum number of ICMP responses per second");
SYSCTL_VNET_INT(_net_inet_icmp, ICMPCTL_ICMPLIM, icmplim, CTLFLAG_RW,
&VNET_NAME(icmplim), 0,
"Maximum number of ICMP responses per second");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_icmp, OID_AUTO, icmplim_output,
CTLFLAG_RW, icmplim_output, 0,
SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, icmplim_output, CTLFLAG_RW,
&VNET_NAME(icmplim_output), 0,
"Enable rate limiting of ICMP responses");
SYSCTL_V_STRING(V_NET, vnet_inet, _net_inet_icmp, OID_AUTO, reply_src,
CTLFLAG_RW, reply_src, IFNAMSIZ,
SYSCTL_VNET_STRING(_net_inet_icmp, OID_AUTO, reply_src, CTLFLAG_RW,
&VNET_NAME(reply_src), IFNAMSIZ,
"icmp reply source for non-local packets.");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_icmp, OID_AUTO, reply_from_interface,
CTLFLAG_RW, icmp_rfi, 0, "ICMP reply from incoming interface for "
"non-local packets");
SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, reply_from_interface, CTLFLAG_RW,
&VNET_NAME(icmp_rfi), 0,
"ICMP reply from incoming interface for non-local packets");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_icmp, OID_AUTO, quotelen, CTLFLAG_RW,
icmp_quotelen, 0, "Number of bytes from original packet to "
"quote in ICMP reply");
SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, quotelen, CTLFLAG_RW,
&VNET_NAME(icmp_quotelen), 0,
"Number of bytes from original packet to quote in ICMP reply");
/*
* ICMP broadcast echo sysctl
*/
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_icmp, OID_AUTO, bmcastecho,
CTLFLAG_RW, icmpbmcastecho, 0, "");
SYSCTL_VNET_INT(_net_inet_icmp, OID_AUTO, bmcastecho, CTLFLAG_RW,
&VNET_NAME(icmpbmcastecho), 0,
"");
#ifdef ICMPPRINTFS
@ -146,7 +160,6 @@ extern struct protosw inetsw[];
void
icmp_init(void)
{
INIT_VNET_INET(curvnet);
V_icmpmaskrepl = 0;
V_icmpmaskfake = 0;
@ -166,7 +179,6 @@ icmp_init(void)
void
icmp_error(struct mbuf *n, int type, int code, uint32_t dest, int mtu)
{
INIT_VNET_INET(curvnet);
register struct ip *oip = mtod(n, struct ip *), *nip;
register unsigned oiphlen = oip->ip_hl << 2;
register struct icmp *icp;
@ -315,7 +327,6 @@ stdreply: icmpelen = max(8, min(V_icmp_quotelen, oip->ip_len - oiphlen));
void
icmp_input(struct mbuf *m, int off)
{
INIT_VNET_INET(curvnet);
struct icmp *icp;
struct in_ifaddr *ia;
struct ip *ip = mtod(m, struct ip *);
@ -649,7 +660,6 @@ icmp_input(struct mbuf *m, int off)
static void
icmp_reflect(struct mbuf *m)
{
INIT_VNET_INET(curvnet);
struct ip *ip = mtod(m, struct ip *);
struct ifaddr *ifa;
struct ifnet *ifp;
@ -941,7 +951,6 @@ ip_next_mtu(int mtu, int dir)
int
badport_bandlim(int which)
{
INIT_VNET_INET(curvnet);
#define N(a) (sizeof (a) / sizeof (a[0]))
static struct rate {

View File

@ -71,10 +71,10 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/ip_fw.h>
#include <netinet/ip_icmp.h>
#include <netinet/ip_options.h>
#include <machine/in_cksum.h>
#include <netinet/vinet.h>
#ifdef DEV_CARP
#include <netinet/ip_carp.h>
#endif
@ -90,58 +90,69 @@ __FBSDID("$FreeBSD$");
CTASSERT(sizeof(struct ip) == 20);
#endif
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
struct vnet_inet vnet_inet_0;
#endif
#endif
static VNET_DEFINE(int, ipsendredirects) = 1; /* XXX */
static VNET_DEFINE(int, ip_checkinterface);
static VNET_DEFINE(int, ip_keepfaith);
static VNET_DEFINE(int, ip_sendsourcequench);
#ifdef VIMAGE_GLOBALS
static int ipsendredirects;
static int ip_checkinterface;
static int ip_keepfaith;
static int ip_sendsourcequench;
int ip_defttl;
int ip_do_randomid;
int ipforwarding;
struct in_ifaddrhead in_ifaddrhead; /* first inet address */
struct in_ifaddrhashhead *in_ifaddrhashtbl; /* inet addr hash table */
u_long in_ifaddrhmask; /* mask for hash table */
struct ipstat ipstat;
static int ip_rsvp_on;
struct socket *ip_rsvpd;
int rsvp_on;
static struct ipqhead ipq[IPREASS_NHASH];
static int maxnipq; /* Administrative limit on # reass queues. */
static int maxfragsperpacket;
int ipstealth;
static int nipq; /* Total # of reass queues */
#endif
#define V_ipsendredirects VNET_GET(ipsendredirects)
#define V_ip_checkinterface VNET_GET(ip_checkinterface)
#define V_ip_keepfaith VNET_GET(ip_keepfaith)
#define V_ip_sendsourcequench VNET_GET(ip_sendsourcequench)
VNET_DEFINE(int, ip_defttl) = IPDEFTTL;
VNET_DEFINE(int, ip_do_randomid);
VNET_DEFINE(int, ipforwarding);
VNET_DEFINE(struct in_ifaddrhead, in_ifaddrhead); /* first inet address */
VNET_DEFINE(struct in_ifaddrhashhead *, in_ifaddrhashtbl); /* inet addr hash table */
VNET_DEFINE(u_long, in_ifaddrhmask); /* mask for hash table */
VNET_DEFINE(struct ipstat, ipstat);
static VNET_DEFINE(int, ip_rsvp_on);
VNET_DEFINE(struct socket *, ip_rsvpd);
VNET_DEFINE(int, rsvp_on);
#define V_ip_rsvp_on VNET_GET(ip_rsvp_on)
static VNET_DEFINE(TAILQ_HEAD(ipqhead, ipq), ipq[IPREASS_NHASH]);
static VNET_DEFINE(int, maxnipq); /* Administrative limit on # reass queues. */
static VNET_DEFINE(int, maxfragsperpacket);
static VNET_DEFINE(int, nipq); /* Total # of reass queues */
#define V_ipq VNET_GET(ipq)
#define V_maxnipq VNET_GET(maxnipq)
#define V_maxfragsperpacket VNET_GET(maxfragsperpacket)
#define V_nipq VNET_GET(nipq)
VNET_DEFINE(int, ipstealth);
struct rwlock in_ifaddr_lock;
RW_SYSINIT(in_ifaddr_lock, &in_ifaddr_lock, "in_ifaddr_lock");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_FORWARDING,
forwarding, CTLFLAG_RW, ipforwarding, 0,
SYSCTL_VNET_INT(_net_inet_ip, IPCTL_FORWARDING, forwarding, CTLFLAG_RW,
&VNET_NAME(ipforwarding), 0,
"Enable IP forwarding between interfaces");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_SENDREDIRECTS,
redirect, CTLFLAG_RW, ipsendredirects, 0,
SYSCTL_VNET_INT(_net_inet_ip, IPCTL_SENDREDIRECTS, redirect, CTLFLAG_RW,
&VNET_NAME(ipsendredirects), 0,
"Enable sending IP redirects");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_DEFTTL,
ttl, CTLFLAG_RW, ip_defttl, 0, "Maximum TTL on IP packets");
SYSCTL_VNET_INT(_net_inet_ip, IPCTL_DEFTTL, ttl, CTLFLAG_RW,
&VNET_NAME(ip_defttl), 0,
"Maximum TTL on IP packets");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_KEEPFAITH,
keepfaith, CTLFLAG_RW, ip_keepfaith, 0,
SYSCTL_VNET_INT(_net_inet_ip, IPCTL_KEEPFAITH, keepfaith, CTLFLAG_RW,
&VNET_NAME(ip_keepfaith), 0,
"Enable packet capture for FAITH IPv4->IPv6 translater daemon");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO,
sendsourcequench, CTLFLAG_RW, ip_sendsourcequench, 0,
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, sendsourcequench, CTLFLAG_RW,
&VNET_NAME(ip_sendsourcequench), 0,
"Enable the transmission of source quench packets");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, random_id,
CTLFLAG_RW, ip_do_randomid, 0, "Assign random ip_id values");
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, random_id, CTLFLAG_RW,
&VNET_NAME(ip_do_randomid), 0,
"Assign random ip_id values");
/*
* XXX - Setting ip_checkinterface mostly implements the receive side of
@ -156,8 +167,8 @@ SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, random_id,
* to the loopback interface instead of the interface where the
* packets for those addresses are received.
*/
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO,
check_interface, CTLFLAG_RW, ip_checkinterface, 0,
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, check_interface, CTLFLAG_RW,
&VNET_NAME(ip_checkinterface), 0,
"Verify packet arrives on correct interface");
struct pfil_head inet_pfil_hook; /* Packet filter hooks */
@ -173,13 +184,13 @@ extern struct domain inetdomain;
extern struct protosw inetsw[];
u_char ip_protox[IPPROTO_MAX];
SYSCTL_VNET_STRUCT(_net_inet_ip, IPCTL_STATS, stats, CTLFLAG_RW,
&VNET_NAME(ipstat), ipstat,
"IP statistics (struct ipstat, netinet/ip_var.h)");
SYSCTL_V_STRUCT(V_NET, vnet_inet, _net_inet_ip, IPCTL_STATS, stats, CTLFLAG_RW,
ipstat, ipstat, "IP statistics (struct ipstat, netinet/ip_var.h)");
static VNET_DEFINE(uma_zone_t, ipq_zone);
#define V_ipq_zone VNET_GET(ipq_zone)
#ifdef VIMAGE_GLOBALS
static uma_zone_t ipq_zone;
#endif
static struct mtx ipqlock;
#define IPQ_LOCK() mtx_lock(&ipqlock)
@ -190,12 +201,12 @@ static struct mtx ipqlock;
static void maxnipq_update(void);
static void ipq_zone_change(void *);
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, fragpackets,
CTLFLAG_RD, nipq, 0,
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, fragpackets, CTLFLAG_RD,
&VNET_NAME(nipq), 0,
"Current number of IPv4 fragment reassembly queue entries");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, maxfragsperpacket,
CTLFLAG_RW, maxfragsperpacket, 0,
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, maxfragsperpacket, CTLFLAG_RW,
&VNET_NAME(maxfragsperpacket), 0,
"Maximum number of IPv4 fragments allowed per packet");
struct callout ipport_tick_callout;
@ -206,32 +217,32 @@ SYSCTL_INT(_net_inet_ip, IPCTL_DEFMTU, mtu, CTLFLAG_RW,
#endif
#ifdef IPSTEALTH
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, stealth, CTLFLAG_RW,
ipstealth, 0, "IP stealth mode, no TTL decrementation on forwarding");
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, stealth, CTLFLAG_RW,
&VNET_NAME(ipstealth), 0,
"IP stealth mode, no TTL decrementation on forwarding");
#endif
#ifdef FLOWTABLE
#ifdef VIMAGE_GLOBALS
static int ip_output_flowtable_size;
struct flowtable *ip_ft;
#endif
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, output_flowtable_size,
CTLFLAG_RDTUN, ip_output_flowtable_size, 2048,
static VNET_DEFINE(int, ip_output_flowtable_size) = 2048;
VNET_DEFINE(struct flowtable *, ip_ft);
#define V_ip_output_flowtable_size VNET_GET(ip_output_flowtable_size)
SYSCTL_VNET_INT(_net_inet_ip, OID_AUTO, output_flowtable_size, CTLFLAG_RDTUN,
&VNET_NAME(ip_output_flowtable_size), 2048,
"number of entries in the per-cpu output flow caches");
#endif
#ifdef VIMAGE_GLOBALS
int fw_one_pass;
#endif
VNET_DEFINE(int, fw_one_pass) = 1;
static void ip_freef(struct ipqhead *, struct ipq *);
#ifndef VIMAGE_GLOBALS
#ifdef VIMAGE
/* XXX only has to stay for .vmi_dependson elsewhere. */
static void vnet_inet_register(void);
static const vnet_modinfo_t vnet_inet_modinfo = {
.vmi_id = VNET_MOD_INET,
.vmi_name = "inet",
.vmi_size = sizeof(struct vnet_inet)
};
static void vnet_inet_register()
@ -288,43 +299,10 @@ SYSCTL_PROC(_net_inet_ip, IPCTL_INTRQDROPS, intr_queue_drops,
void
ip_init(void)
{
INIT_VNET_INET(curvnet);
struct protosw *pr;
int i;
V_ipsendredirects = 1; /* XXX */
V_ip_checkinterface = 0;
V_ip_keepfaith = 0;
V_ip_sendsourcequench = 0;
V_rsvp_on = 0;
V_ip_defttl = IPDEFTTL;
V_ip_do_randomid = 0;
V_ip_id = time_second & 0xffff;
V_ipforwarding = 0;
V_ipstealth = 0;
V_nipq = 0; /* Total # of reass queues */
V_ipport_lowfirstauto = IPPORT_RESERVED - 1; /* 1023 */
V_ipport_lowlastauto = IPPORT_RESERVEDSTART; /* 600 */
V_ipport_firstauto = IPPORT_EPHEMERALFIRST; /* 10000 */
V_ipport_lastauto = IPPORT_EPHEMERALLAST; /* 65535 */
V_ipport_hifirstauto = IPPORT_HIFIRSTAUTO; /* 49152 */
V_ipport_hilastauto = IPPORT_HILASTAUTO; /* 65535 */
V_ipport_reservedhigh = IPPORT_RESERVED - 1; /* 1023 */
V_ipport_reservedlow = 0;
V_ipport_randomized = 1; /* user controlled via sysctl */
V_ipport_randomcps = 10; /* user controlled via sysctl */
V_ipport_randomtime = 45; /* user controlled via sysctl */
V_ipport_stoprandom = 0; /* toggled by ipport_tick */
V_fw_one_pass = 1;
#ifdef NOTYET
/* XXX global static but not instantiated in this file */
V_ipfastforward_active = 0;
V_subnetsarelocal = 0;
V_sameprefixcarponly = 0;
#endif
TAILQ_INIT(&V_in_ifaddrhead);
V_in_ifaddrhashtbl = hashinit(INADDR_NHASH, M_IFADDR, &V_in_ifaddrhmask);
@ -339,7 +317,6 @@ ip_init(void)
maxnipq_update();
#ifdef FLOWTABLE
V_ip_output_flowtable_size = 2048;
TUNABLE_INT_FETCH("net.inet.ip.output_flowtable_size",
&V_ip_output_flowtable_size);
V_ip_ft = flowtable_alloc(V_ip_output_flowtable_size, FL_PCPU);
@ -403,7 +380,6 @@ ip_fini(void *xtp)
void
ip_input(struct mbuf *m)
{
INIT_VNET_INET(curvnet);
struct ip *ip = NULL;
struct in_ifaddr *ia = NULL;
struct ifaddr *ifa;
@ -808,7 +784,6 @@ ip_input(struct mbuf *m)
static void
maxnipq_update(void)
{
INIT_VNET_INET(curvnet);
/*
* -1 for unlimited allocation.
@ -832,7 +807,6 @@ maxnipq_update(void)
static void
ipq_zone_change(void *tag)
{
INIT_VNET_INET(curvnet);
if (V_maxnipq > 0 && V_maxnipq < (nmbclusters / 32)) {
V_maxnipq = nmbclusters / 32;
@ -843,7 +817,6 @@ ipq_zone_change(void *tag)
static int
sysctl_maxnipq(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_INET(curvnet);
int error, i;
i = V_maxnipq;
@ -879,7 +852,6 @@ SYSCTL_PROC(_net_inet_ip, OID_AUTO, maxfragpackets, CTLTYPE_INT|CTLFLAG_RW,
struct mbuf *
ip_reass(struct mbuf *m)
{
INIT_VNET_INET(curvnet);
struct ip *ip;
struct mbuf *p, *q, *nq, *t;
struct ipq *fp = NULL;
@ -1195,7 +1167,6 @@ ip_reass(struct mbuf *m)
static void
ip_freef(struct ipqhead *fhp, struct ipq *fp)
{
INIT_VNET_INET(curvnet);
struct mbuf *q;
IPQ_LOCK_ASSERT();
@ -1226,7 +1197,6 @@ ip_slowtimo(void)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
INIT_VNET_INET(vnet_iter);
for (i = 0; i < IPREASS_NHASH; i++) {
for(fp = TAILQ_FIRST(&V_ipq[i]); fp;) {
struct ipq *fpp;
@ -1275,7 +1245,6 @@ ip_drain(void)
VNET_LIST_RLOCK();
VNET_FOREACH(vnet_iter) {
CURVNET_SET(vnet_iter);
INIT_VNET_INET(vnet_iter);
for (i = 0; i < IPREASS_NHASH; i++) {
while(!TAILQ_EMPTY(&V_ipq[i])) {
IPSTAT_ADD(ips_fragdropped,
@ -1403,7 +1372,6 @@ u_char inetctlerrmap[PRC_NCMDS] = {
void
ip_forward(struct mbuf *m, int srcrt)
{
INIT_VNET_INET(curvnet);
struct ip *ip = mtod(m, struct ip *);
struct in_ifaddr *ia;
struct mbuf *mcopy;
@ -1638,7 +1606,6 @@ void
ip_savecontrol(struct inpcb *inp, struct mbuf **mp, struct ip *ip,
struct mbuf *m)
{
INIT_VNET_NET(inp->inp_vnet);
if (inp->inp_socket->so_options & (SO_BINTIME | SO_TIMESTAMP)) {
struct bintime bt;
@ -1736,7 +1703,6 @@ ip_savecontrol(struct inpcb *inp, struct mbuf **mp, struct ip *ip,
int
ip_rsvp_init(struct socket *so)
{
INIT_VNET_INET(so->so_vnet);
if (so->so_type != SOCK_RAW ||
so->so_proto->pr_protocol != IPPROTO_RSVP)
@ -1761,7 +1727,6 @@ ip_rsvp_init(struct socket *so)
int
ip_rsvp_done(void)
{
INIT_VNET_INET(curvnet);
V_ip_rsvpd = NULL;
/*
@ -1778,7 +1743,6 @@ ip_rsvp_done(void)
void
rsvp_input(struct mbuf *m, int off) /* XXX must fixup manually */
{
INIT_VNET_INET(curvnet);
if (rsvp_input_p) { /* call the real one if loaded */
rsvp_input_p(m, off);

View File

@ -47,6 +47,7 @@ __FBSDID("$FreeBSD$");
#include <net/if.h>
#include <net/route.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
@ -56,7 +57,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_var.h>
#include <netinet/ip_options.h>
#include <netinet/ip_ipsec.h>
#include <netinet/vinet.h>
#ifdef SCTP
#include <netinet/sctp_crc32.h>
#endif
@ -71,9 +71,19 @@ __FBSDID("$FreeBSD$");
extern struct protosw inetsw[];
#ifdef VIMAGE_GLOBALS
int ip4_ipsec_filtertunnel;
#ifdef IPSEC
#ifdef IPSEC_FILTERTUNNEL
static VNET_DEFINE(int, ip4_ipsec_filtertunnel) = 1;
#else
static VNET_DEFINE(int, ip4_ipsec_filtertunnel) = 0;
#endif
#define V_ip4_ipsec_filtertunnel VNET_GET(ip4_ipsec_filtertunnel)
SYSCTL_DECL(_net_inet_ipsec);
SYSCTL_VNET_INT(_net_inet_ipsec, OID_AUTO, filtertunnel,
CTLFLAG_RW, &VNET_NAME(ip4_ipsec_filtertunnel), 0,
"If set filter packets from an IPsec tunnel.");
#endif /* IPSEC */
/*
* Check if we have to jump over firewall processing for this packet.
@ -84,7 +94,6 @@ int
ip_ipsec_filtertunnel(struct mbuf *m)
{
#if defined(IPSEC)
INIT_VNET_IPSEC(curvnet);
/*
* Bypass packet filtering for packets from a tunnel.
@ -106,8 +115,6 @@ int
ip_ipsec_fwd(struct mbuf *m)
{
#ifdef IPSEC
INIT_VNET_INET(curvnet);
INIT_VNET_IPSEC(curvnet);
struct m_tag *mtag;
struct tdb_ident *tdbi;
struct secpolicy *sp;
@ -153,9 +160,8 @@ ip_ipsec_fwd(struct mbuf *m)
int
ip_ipsec_input(struct mbuf *m)
{
struct ip *ip = mtod(m, struct ip *);
#ifdef IPSEC
INIT_VNET_IPSEC(curvnet);
struct ip *ip = mtod(m, struct ip *);
struct m_tag *mtag;
struct tdb_ident *tdbi;
struct secpolicy *sp;

View File

@ -111,7 +111,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/pim.h>
#include <netinet/pim_var.h>
#include <netinet/udp.h>
#include <netinet/vinet.h>
#include <machine/in_cksum.h>
@ -379,7 +378,6 @@ mfc_find(struct in_addr *o, struct in_addr *g)
static int
X_ip_mrouter_set(struct socket *so, struct sockopt *sopt)
{
INIT_VNET_INET(curvnet);
int error, optval;
vifi_t vifi;
struct vifctl vifc;
@ -602,7 +600,6 @@ ip_mrouter_reset(void)
static void
if_detached_event(void *arg __unused, struct ifnet *ifp)
{
INIT_VNET_INET(curvnet);
vifi_t vifi;
int i;
@ -651,7 +648,6 @@ if_detached_event(void *arg __unused, struct ifnet *ifp)
static int
ip_mrouter_init(struct socket *so, int version)
{
INIT_VNET_INET(curvnet);
CTR3(KTR_IPMF, "%s: so_type %d, pr_protocol %d", __func__,
so->so_type, so->so_proto->pr_protocol);
@ -699,7 +695,6 @@ ip_mrouter_init(struct socket *so, int version)
static int
X_ip_mrouter_done(void)
{
INIT_VNET_INET(curvnet);
vifi_t vifi;
int i;
struct ifnet *ifp;
@ -1220,7 +1215,6 @@ static int
X_ip_mforward(struct ip *ip, struct ifnet *ifp, struct mbuf *m,
struct ip_moptions *imo)
{
INIT_VNET_INET(curvnet);
struct mfc *rt;
int error;
vifi_t vifi;
@ -1475,7 +1469,6 @@ expire_upcalls(void *unused)
static int
ip_mdq(struct mbuf *m, struct ifnet *ifp, struct mfc *rt, vifi_t xmt_vif)
{
INIT_VNET_INET(curvnet);
struct ip *ip = mtod(m, struct ip *);
vifi_t vifi;
int plen = ip->ip_len;
@ -1709,7 +1702,6 @@ X_ip_rsvp_force_done(struct socket *so __unused)
static void
X_rsvp_input(struct mbuf *m, int off __unused)
{
INIT_VNET_INET(curvnet);
if (!V_rsvp_on)
m_freem(m);
@ -2044,7 +2036,6 @@ bw_meter_prepare_upcall(struct bw_meter *x, struct timeval *nowp)
static void
bw_upcalls_send(void)
{
INIT_VNET_INET(curvnet);
struct mbuf *m;
int len = bw_upcalls_n * sizeof(bw_upcalls[0]);
struct sockaddr_in k_igmpsrc = { sizeof k_igmpsrc, AF_INET };
@ -2401,7 +2392,6 @@ static int
pim_register_send_upcall(struct ip *ip, struct vif *vifp,
struct mbuf *mb_copy, struct mfc *rt)
{
INIT_VNET_INET(curvnet);
struct mbuf *mb_first;
int len = ntohs(ip->ip_len);
struct igmpmsg *im;
@ -2454,7 +2444,6 @@ static int
pim_register_send_rp(struct ip *ip, struct vif *vifp, struct mbuf *mb_copy,
struct mfc *rt)
{
INIT_VNET_INET(curvnet);
struct mbuf *mb_first;
struct ip *ip_outer;
struct pim_encap_pimhdr *pimhdr;
@ -2795,7 +2784,6 @@ SYSCTL_NODE(_net_inet_ip, OID_AUTO, mfctable, CTLFLAG_RD, sysctl_mfctable,
static int
ip_mroute_modevent(module_t mod, int type, void *unused)
{
INIT_VNET_INET(curvnet);
switch (type) {
case MOD_LOAD:

View File

@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_options.h>
#include <netinet/ip_icmp.h>
#include <machine/in_cksum.h>
#include <netinet/vinet.h>
#include <sys/socketvar.h>
@ -98,7 +97,6 @@ static void save_rte(struct mbuf *m, u_char *, struct in_addr);
int
ip_dooptions(struct mbuf *m, int pass)
{
INIT_VNET_INET(curvnet);
struct ip *ip = mtod(m, struct ip *);
u_char *cp;
struct in_ifaddr *ia;

View File

@ -70,7 +70,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/in_var.h>
#include <netinet/ip_var.h>
#include <netinet/ip_options.h>
#include <netinet/vinet.h>
#ifdef SCTP
#include <netinet/sctp.h>
#include <netinet/sctp_crc32.h>
@ -91,9 +90,7 @@ __FBSDID("$FreeBSD$");
(ntohl(a.s_addr)>>8)&0xFF,\
(ntohl(a.s_addr))&0xFF, y);
#ifdef VIMAGE_GLOBALS
u_short ip_id;
#endif
VNET_DEFINE(u_short, ip_id);
#ifdef MBUF_STRESS_TEST
int mbuf_frag_size = 0;
@ -120,8 +117,6 @@ int
ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
struct ip_moptions *imo, struct inpcb *inp)
{
INIT_VNET_NET(curvnet);
INIT_VNET_INET(curvnet);
struct ip *ip;
struct ifnet *ifp = NULL; /* keep compiler happy */
struct mbuf *m0;
@ -689,7 +684,6 @@ int
ip_fragment(struct ip *ip, struct mbuf **m_frag, int mtu,
u_long if_hwassist_flags, int sw_csum)
{
INIT_VNET_INET(curvnet);
int error = 0;
int hlen = ip->ip_hl << 2;
int len = (mtu - hlen) & ~7; /* size of payload in each fragment */

View File

@ -129,6 +129,8 @@ struct ipstat {
#ifdef _KERNEL
#include <net/vnet.h>
#define IPSTAT_ADD(name, val) V_ipstat.name += (val)
#define IPSTAT_SUB(name, val) V_ipstat.name -= (val)
#define IPSTAT_INC(name) IPSTAT_ADD(name, 1)
@ -158,19 +160,27 @@ struct inpcb;
struct route;
struct sockopt;
#ifdef VIMAGE_GLOBALS
extern struct ipstat ipstat;
extern u_short ip_id; /* ip packet ctr, for ids */
extern int ip_do_randomid;
extern int ip_defttl; /* default IP ttl */
extern int ipforwarding; /* ip forwarding */
VNET_DECLARE(struct ipstat, ipstat);
VNET_DECLARE(u_short, ip_id); /* ip packet ctr, for ids */
VNET_DECLARE(int, ip_defttl); /* default IP ttl */
VNET_DECLARE(int, ipforwarding); /* ip forwarding */
#ifdef IPSTEALTH
extern int ipstealth; /* stealth forwarding */
VNET_DECLARE(int, ipstealth); /* stealth forwarding */
#endif
extern int rsvp_on;
extern struct socket *ip_rsvpd; /* reservation protocol daemon */
extern struct socket *ip_mrouter; /* multicast routing daemon */
#endif /* VIMAGE_GLOBALS */
VNET_DECLARE(int, rsvp_on);
VNET_DECLARE(struct socket *, ip_rsvpd); /* reservation protocol daemon*/
VNET_DECLARE(struct socket *, ip_mrouter); /* multicast routing daemon */
#define V_ipstat VNET_GET(ipstat)
#define V_ip_id VNET_GET(ip_id)
#define V_ip_defttl VNET_GET(ip_defttl)
#define V_ipforwarding VNET_GET(ipforwarding)
#ifdef IPSTEALTH
#define V_ipstealth VNET_GET(ipstealth)
#endif
#define V_rsvp_on VNET_GET(rsvp_on)
#define V_ip_rsvpd VNET_GET(ip_rsvpd)
#define V_ip_mrouter VNET_GET(ip_mrouter)
extern u_char ip_protox[];
extern int (*legal_vif_num)(int);
@ -231,6 +241,12 @@ extern int (*ip_fw_ctl_ptr)(struct sockopt *);
extern int (*ip_dn_ctl_ptr)(struct sockopt *);
extern int (*ip_dn_io_ptr)(struct mbuf **m, int dir, struct ip_fw_args *fwa);
extern void (*ip_dn_ruledel_ptr)(void *); /* in ip_fw2.c */
VNET_DECLARE(int, ip_do_randomid);
#define V_ip_do_randomid VNET_GET(ip_do_randomid)
#define ip_newid() ((V_ip_do_randomid != 0) ? ip_randomid() : \
htons(V_ip_id++))
#endif /* _KERNEL */
#endif /* !_NETINET_IP_VAR_H_ */

View File

@ -88,7 +88,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <netinet/sctp.h>
#include <netinet/vinet.h>
#include <netgraph/ng_ipfw.h>
@ -104,12 +103,6 @@ __FBSDID("$FreeBSD$");
#include <security/mac/mac_framework.h>
#endif
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
struct vnet_ipfw vnet_ipfw_0;
#endif
#endif
/*
* set_disable contains one bit per set value (0..31).
* If the bit is set, all rules with the corresponding set
@ -118,12 +111,15 @@ struct vnet_ipfw vnet_ipfw_0;
* and CANNOT be disabled.
* Rules in set RESVD_SET can only be deleted explicitly.
*/
#ifdef VIMAGE_GLOBALS
static u_int32_t set_disable;
static int fw_verbose;
static struct callout ipfw_timeout;
static int verbose_limit;
#endif
static VNET_DEFINE(u_int32_t, set_disable);
static VNET_DEFINE(int, fw_verbose);
static VNET_DEFINE(struct callout, ipfw_timeout);
static VNET_DEFINE(int, verbose_limit);
#define V_set_disable VNET_GET(set_disable)
#define V_fw_verbose VNET_GET(fw_verbose)
#define V_ipfw_timeout VNET_GET(ipfw_timeout)
#define V_verbose_limit VNET_GET(verbose_limit)
#ifdef IPFIREWALL_DEFAULT_TO_ACCEPT
static int default_to_accept = 1;
@ -137,9 +133,7 @@ struct ip_fw *ip_fw_default_rule;
/*
* list of rules for layer 3
*/
#ifdef VIMAGE_GLOBALS
struct ip_fw_chain layer3_chain;
#endif
VNET_DEFINE(struct ip_fw_chain, layer3_chain);
MALLOC_DEFINE(M_IPFW, "IpFw/IpAcct", "IpFw/IpAcct chain's");
MALLOC_DEFINE(M_IPFW_TBL, "ipfw_tbl", "IpFw tables");
@ -156,27 +150,26 @@ struct table_entry {
u_int32_t value;
};
#ifdef VIMAGE_GLOBALS
static int autoinc_step;
#endif
static VNET_DEFINE(int, autoinc_step);
#define V_autoinc_step VNET_GET(autoinc_step)
extern int ipfw_chg_hook(SYSCTL_HANDLER_ARGS);
#ifdef SYSCTL_NODE
SYSCTL_NODE(_net_inet_ip, OID_AUTO, fw, CTLFLAG_RW, 0, "Firewall");
SYSCTL_V_PROC(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, enable,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE3, fw_enable, 0,
SYSCTL_VNET_PROC(_net_inet_ip_fw, OID_AUTO, enable,
CTLTYPE_INT | CTLFLAG_RW | CTLFLAG_SECURE3, &VNET_NAME(fw_enable), 0,
ipfw_chg_hook, "I", "Enable ipfw");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, autoinc_step,
CTLFLAG_RW, autoinc_step, 0, "Rule number auto-increment step");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip_fw, OID_AUTO, one_pass,
CTLFLAG_RW | CTLFLAG_SECURE3, fw_one_pass, 0,
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, autoinc_step,
CTLFLAG_RW, &VNET_NAME(autoinc_step), 0, "Rule number auto-increment step");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, one_pass,
CTLFLAG_RW | CTLFLAG_SECURE3, &VNET_NAME(fw_one_pass), 0,
"Only do a single pass through ipfw when using dummynet(4)");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, verbose,
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, verbose,
CTLFLAG_RW | CTLFLAG_SECURE3,
fw_verbose, 0, "Log matches to ipfw rules");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, verbose_limit,
CTLFLAG_RW, verbose_limit, 0,
&VNET_NAME(fw_verbose), 0, "Log matches to ipfw rules");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, verbose_limit,
CTLFLAG_RW, &VNET_NAME(verbose_limit), 0,
"Set upper limit of matches of ipfw rules logged");
SYSCTL_UINT(_net_inet_ip_fw, OID_AUTO, default_rule, CTLFLAG_RD,
NULL, IPFW_DEFAULT_RULE, "The default/max possible rule number.");
@ -223,11 +216,13 @@ TUNABLE_INT("net.inet.ip.fw.default_to_accept", &default_to_accept);
* obey the 'randomized match', and we do not do multiple
* passes through the firewall. XXX check the latter!!!
*/
#ifdef VIMAGE_GLOBALS
static ipfw_dyn_rule **ipfw_dyn_v;
static u_int32_t dyn_buckets;
static u_int32_t curr_dyn_buckets;
#endif
static VNET_DEFINE(ipfw_dyn_rule **, ipfw_dyn_v);
static VNET_DEFINE(u_int32_t, dyn_buckets);
static VNET_DEFINE(u_int32_t, curr_dyn_buckets);
#define V_ipfw_dyn_v VNET_GET(ipfw_dyn_v)
#define V_dyn_buckets VNET_GET(dyn_buckets)
#define V_curr_dyn_buckets VNET_GET(curr_dyn_buckets)
static struct mtx ipfw_dyn_mtx; /* mutex guarding dynamic rules */
#define IPFW_DYN_LOCK_INIT() \
@ -240,13 +235,19 @@ static struct mtx ipfw_dyn_mtx; /* mutex guarding dynamic rules */
/*
* Timeouts for various events in handing dynamic rules.
*/
#ifdef VIMAGE_GLOBALS
static u_int32_t dyn_ack_lifetime;
static u_int32_t dyn_syn_lifetime;
static u_int32_t dyn_fin_lifetime;
static u_int32_t dyn_rst_lifetime;
static u_int32_t dyn_udp_lifetime;
static u_int32_t dyn_short_lifetime;
static VNET_DEFINE(u_int32_t, dyn_ack_lifetime);
static VNET_DEFINE(u_int32_t, dyn_syn_lifetime);
static VNET_DEFINE(u_int32_t, dyn_fin_lifetime);
static VNET_DEFINE(u_int32_t, dyn_rst_lifetime);
static VNET_DEFINE(u_int32_t, dyn_udp_lifetime);
static VNET_DEFINE(u_int32_t, dyn_short_lifetime);
#define V_dyn_ack_lifetime VNET_GET(dyn_ack_lifetime)
#define V_dyn_syn_lifetime VNET_GET(dyn_syn_lifetime)
#define V_dyn_fin_lifetime VNET_GET(dyn_fin_lifetime)
#define V_dyn_rst_lifetime VNET_GET(dyn_rst_lifetime)
#define V_dyn_udp_lifetime VNET_GET(dyn_udp_lifetime)
#define V_dyn_short_lifetime VNET_GET(dyn_short_lifetime)
/*
* Keepalives are sent if dyn_keepalive is set. They are sent every
@ -256,42 +257,57 @@ static u_int32_t dyn_short_lifetime;
* than dyn_keepalive_period.
*/
static u_int32_t dyn_keepalive_interval;
static u_int32_t dyn_keepalive_period;
static u_int32_t dyn_keepalive;
static VNET_DEFINE(u_int32_t, dyn_keepalive_interval);
static VNET_DEFINE(u_int32_t, dyn_keepalive_period);
static VNET_DEFINE(u_int32_t, dyn_keepalive);
static u_int32_t static_count; /* # of static rules */
static u_int32_t static_len; /* size in bytes of static rules */
static u_int32_t dyn_count; /* # of dynamic rules */
static u_int32_t dyn_max; /* max # of dynamic rules */
#endif /* VIMAGE_GLOBALS */
#define V_dyn_keepalive_interval VNET_GET(dyn_keepalive_interval)
#define V_dyn_keepalive_period VNET_GET(dyn_keepalive_period)
#define V_dyn_keepalive VNET_GET(dyn_keepalive)
static VNET_DEFINE(u_int32_t, static_count); /* # of static rules */
static VNET_DEFINE(u_int32_t, static_len); /* bytes of static rules */
static VNET_DEFINE(u_int32_t, dyn_count); /* # of dynamic rules */
static VNET_DEFINE(u_int32_t, dyn_max); /* max # of dynamic rules */
#define V_static_count VNET_GET(static_count)
#define V_static_len VNET_GET(static_len)
#define V_dyn_count VNET_GET(dyn_count)
#define V_dyn_max VNET_GET(dyn_max)
#ifdef SYSCTL_NODE
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_buckets,
CTLFLAG_RW, dyn_buckets, 0, "Number of dyn. buckets");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, curr_dyn_buckets,
CTLFLAG_RD, curr_dyn_buckets, 0, "Current Number of dyn. buckets");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_count,
CTLFLAG_RD, dyn_count, 0, "Number of dyn. rules");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_max,
CTLFLAG_RW, dyn_max, 0, "Max number of dyn. rules");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, static_count,
CTLFLAG_RD, static_count, 0, "Number of static rules");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_ack_lifetime,
CTLFLAG_RW, dyn_ack_lifetime, 0, "Lifetime of dyn. rules for acks");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_syn_lifetime,
CTLFLAG_RW, dyn_syn_lifetime, 0, "Lifetime of dyn. rules for syn");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_fin_lifetime,
CTLFLAG_RW, dyn_fin_lifetime, 0, "Lifetime of dyn. rules for fin");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_rst_lifetime,
CTLFLAG_RW, dyn_rst_lifetime, 0, "Lifetime of dyn. rules for rst");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_udp_lifetime,
CTLFLAG_RW, dyn_udp_lifetime, 0, "Lifetime of dyn. rules for UDP");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_short_lifetime,
CTLFLAG_RW, dyn_short_lifetime, 0,
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_buckets,
CTLFLAG_RW, &VNET_NAME(dyn_buckets), 0, "Number of dyn. buckets");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, curr_dyn_buckets,
CTLFLAG_RD, &VNET_NAME(curr_dyn_buckets), 0,
"Current Number of dyn. buckets");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_count,
CTLFLAG_RD, &VNET_NAME(dyn_count), 0, "Number of dyn. rules");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_max,
CTLFLAG_RW, &VNET_NAME(dyn_max), 0, "Max number of dyn. rules");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, static_count,
CTLFLAG_RD, &VNET_NAME(static_count), 0, "Number of static rules");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_ack_lifetime,
CTLFLAG_RW, &VNET_NAME(dyn_ack_lifetime), 0,
"Lifetime of dyn. rules for acks");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_syn_lifetime,
CTLFLAG_RW, &VNET_NAME(dyn_syn_lifetime), 0,
"Lifetime of dyn. rules for syn");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_fin_lifetime,
CTLFLAG_RW, &VNET_NAME(dyn_fin_lifetime), 0,
"Lifetime of dyn. rules for fin");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_rst_lifetime,
CTLFLAG_RW, &VNET_NAME(dyn_rst_lifetime), 0,
"Lifetime of dyn. rules for rst");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_udp_lifetime,
CTLFLAG_RW, &VNET_NAME(dyn_udp_lifetime), 0,
"Lifetime of dyn. rules for UDP");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_short_lifetime,
CTLFLAG_RW, &VNET_NAME(dyn_short_lifetime), 0,
"Lifetime of dyn. rules for other situations");
SYSCTL_V_INT(V_NET, vnet_ipfw, _net_inet_ip_fw, OID_AUTO, dyn_keepalive,
CTLFLAG_RW, dyn_keepalive, 0, "Enable keepalives for dyn. rules");
SYSCTL_VNET_INT(_net_inet_ip_fw, OID_AUTO, dyn_keepalive,
CTLFLAG_RW, &VNET_NAME(dyn_keepalive), 0,
"Enable keepalives for dyn. rules");
#endif /* SYSCTL_NODE */
#ifdef INET6
@ -306,9 +322,8 @@ static struct sysctl_ctx_list ip6_fw_sysctl_ctx;
static struct sysctl_oid *ip6_fw_sysctl_tree;
#endif /* INET6 */
#ifdef VIMAGE_GLOBALS
static int fw_deny_unknown_exthdrs;
#endif
static VNET_DEFINE(int, fw_deny_unknown_exthdrs);
#define V_fw_deny_unknown_exthdrs VNET_GET(fw_deny_unknown_exthdrs)
/*
* L3HDR maps an ipv4 pointer into a layer3 header pointer of type T
@ -581,7 +596,6 @@ flow6id_match( int curr_flow, ipfw_insn_u32 *cmd )
static int
search_ip6_addr_net (struct in6_addr * ip6_addr)
{
INIT_VNET_NET(curvnet);
struct ifnet *mdc;
struct ifaddr *mdc2;
struct in6_ifaddr *fdm;
@ -764,9 +778,9 @@ send_reject6(struct ip_fw_args *args, int code, u_int hlen, struct ip6_hdr *ip6)
#endif /* INET6 */
#ifdef VIMAGE_GLOBALS
static u_int64_t norule_counter; /* counter for ipfw_log(NULL...) */
#endif
/* counter for ipfw_log(NULL...) */
static VNET_DEFINE(u_int64_t, norule_counter);
#define V_norule_counter VNET_GET(norule_counter)
#define SNPARGS(buf, len) buf + len, sizeof(buf) > len ? sizeof(buf) - len : 0
#define SNP(buf) buf, sizeof(buf)
@ -780,7 +794,6 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ip_fw_args *args,
struct mbuf *m, struct ifnet *oif, u_short offset, uint32_t tablearg,
struct ip *ip)
{
INIT_VNET_IPFW(curvnet);
struct ether_header *eh = args->eh;
char *action;
int limit_reached = 0;
@ -1054,7 +1067,6 @@ ipfw_log(struct ip_fw *f, u_int hlen, struct ip_fw_args *args,
static __inline int
hash_packet(struct ipfw_flow_id *id)
{
INIT_VNET_IPFW(curvnet);
u_int32_t i;
#ifdef INET6
@ -1106,7 +1118,6 @@ hash_packet(struct ipfw_flow_id *id)
static void
remove_dyn_rule(struct ip_fw *rule, ipfw_dyn_rule *keep_me)
{
INIT_VNET_IPFW(curvnet);
static u_int32_t last_remove = 0;
#define FORCE (keep_me == NULL)
@ -1177,7 +1188,6 @@ static ipfw_dyn_rule *
lookup_dyn_rule_locked(struct ipfw_flow_id *pkt, int *match_direction,
struct tcphdr *tcp)
{
INIT_VNET_IPFW(curvnet);
/*
* stateful ipfw extensions.
* Lookup into dynamic session queue
@ -1334,7 +1344,6 @@ lookup_dyn_rule(struct ipfw_flow_id *pkt, int *match_direction,
static void
realloc_dynamic_table(void)
{
INIT_VNET_IPFW(curvnet);
IPFW_DYN_LOCK_ASSERT();
/*
@ -1374,7 +1383,6 @@ realloc_dynamic_table(void)
static ipfw_dyn_rule *
add_dyn_rule(struct ipfw_flow_id *id, u_int8_t dyn_type, struct ip_fw *rule)
{
INIT_VNET_IPFW(curvnet);
ipfw_dyn_rule *r;
int i;
@ -1430,7 +1438,6 @@ add_dyn_rule(struct ipfw_flow_id *id, u_int8_t dyn_type, struct ip_fw *rule)
static ipfw_dyn_rule *
lookup_dyn_parent(struct ipfw_flow_id *pkt, struct ip_fw *rule)
{
INIT_VNET_IPFW(curvnet);
ipfw_dyn_rule *q;
int i;
@ -1474,7 +1481,6 @@ static int
install_state(struct ip_fw *rule, ipfw_insn_limit *cmd,
struct ip_fw_args *args, uint32_t tablearg)
{
INIT_VNET_IPFW(curvnet);
static int last_log;
ipfw_dyn_rule *q;
struct in_addr da;
@ -1636,7 +1642,6 @@ static struct mbuf *
send_pkt(struct mbuf *replyto, struct ipfw_flow_id *id, u_int32_t seq,
u_int32_t ack, int flags)
{
INIT_VNET_INET(curvnet);
struct mbuf *m;
struct ip *ip;
struct tcphdr *tcp;
@ -2002,7 +2007,6 @@ check_uidgid(ipfw_insn_u32 *insn, int proto, struct ifnet *oif,
u_int16_t src_port, struct ucred **uc, int *ugid_lookupp,
struct inpcb *inp)
{
INIT_VNET_INET(curvnet);
struct inpcbinfo *pi;
int wildcard;
struct inpcb *pcb;
@ -2110,8 +2114,6 @@ check_uidgid(ipfw_insn_u32 *insn, int proto, struct ifnet *oif,
int
ipfw_chk(struct ip_fw_args *args)
{
INIT_VNET_INET(curvnet);
INIT_VNET_IPFW(curvnet);
/*
* Local variables holding state during the processing of a packet:
@ -3491,7 +3493,6 @@ flush_rule_ptrs(struct ip_fw_chain *chain)
static int
add_rule(struct ip_fw_chain *chain, struct ip_fw *input_rule)
{
INIT_VNET_IPFW(curvnet);
struct ip_fw *rule, *f, *prev;
int l = RULESIZE(input_rule);
@ -3580,7 +3581,6 @@ static struct ip_fw *
remove_rule(struct ip_fw_chain *chain, struct ip_fw *rule,
struct ip_fw *prev)
{
INIT_VNET_IPFW(curvnet);
struct ip_fw *n;
int l = RULESIZE(rule);
@ -3793,7 +3793,6 @@ clear_counters(struct ip_fw *rule, int log_only)
static int
zero_entry(struct ip_fw_chain *chain, u_int32_t arg, int log_only)
{
INIT_VNET_IPFW(curvnet);
struct ip_fw *rule;
char *msg;
@ -4167,7 +4166,6 @@ check_ipfw_struct(struct ip_fw *rule, int size)
static size_t
ipfw_getrules(struct ip_fw_chain *chain, void *buf, size_t space)
{
INIT_VNET_IPFW(curvnet);
char *bp = buf;
char *ep = bp + space;
struct ip_fw *rule;
@ -4250,7 +4248,6 @@ static int
ipfw_ctl(struct sockopt *sopt)
{
#define RULE_MAXSIZE (256*sizeof(u_int32_t))
INIT_VNET_IPFW(curvnet);
int error;
size_t size;
struct ip_fw *buf, *rule;
@ -4521,7 +4518,6 @@ ipfw_ctl(struct sockopt *sopt)
static void
ipfw_tick(void * __unused unused)
{
INIT_VNET_IPFW(curvnet);
struct mbuf *m0, *m, *mnext, **mtailp;
int i;
ipfw_dyn_rule *q;
@ -4576,7 +4572,6 @@ ipfw_tick(void * __unused unused)
int
ipfw_init(void)
{
INIT_VNET_IPFW(curvnet);
struct ip_fw default_rule;
int error;
@ -4701,7 +4696,6 @@ ipfw_init(void)
void
ipfw_destroy(void)
{
INIT_VNET_IPFW(curvnet);
struct ip_fw *reap;
ip_fw_chk_ptr = NULL;

View File

@ -69,10 +69,8 @@ __FBSDID("$FreeBSD$");
MALLOC_DECLARE(M_IPFW);
#ifdef VIMAGE_GLOBALS
extern struct ip_fw_chain layer3_chain;
static eventhandler_tag ifaddr_event_tag;
#endif
static VNET_DEFINE(eventhandler_tag, ifaddr_event_tag);
#define V_ifaddr_event_tag VNET_GET(ifaddr_event_tag)
extern ipfw_nat_t *ipfw_nat_ptr;
extern ipfw_nat_cfg_t *ipfw_nat_cfg_ptr;
@ -83,7 +81,6 @@ extern ipfw_nat_cfg_t *ipfw_nat_get_log_ptr;
static void
ifaddr_change(void *arg __unused, struct ifnet *ifp)
{
INIT_VNET_IPFW(curvnet);
struct cfg_nat *ptr;
struct ifaddr *ifa;
@ -111,7 +108,6 @@ ifaddr_change(void *arg __unused, struct ifnet *ifp)
static void
flush_nat_ptrs(const int i)
{
INIT_VNET_IPFW(curvnet);
struct ip_fw *rule;
IPFW_WLOCK_ASSERT(&V_layer3_chain);
@ -411,7 +407,6 @@ ipfw_nat(struct ip_fw_args *args, struct cfg_nat *t, struct mbuf *m)
static int
ipfw_nat_cfg(struct sockopt *sopt)
{
INIT_VNET_IPFW(curvnet);
struct cfg_nat *ptr, *ser_n;
char *buf;
@ -482,7 +477,6 @@ ipfw_nat_cfg(struct sockopt *sopt)
static int
ipfw_nat_del(struct sockopt *sopt)
{
INIT_VNET_IPFW(curvnet);
struct cfg_nat *ptr;
int i;
@ -505,7 +499,6 @@ ipfw_nat_del(struct sockopt *sopt)
static int
ipfw_nat_get_cfg(struct sockopt *sopt)
{
INIT_VNET_IPFW(curvnet);
uint8_t *data;
struct cfg_nat *n;
struct cfg_redir *r;
@ -560,7 +553,6 @@ ipfw_nat_get_cfg(struct sockopt *sopt)
static int
ipfw_nat_get_log(struct sockopt *sopt)
{
INIT_VNET_IPFW(curvnet);
uint8_t *data;
struct cfg_nat *ptr;
int i, size, cnt, sof;
@ -595,7 +587,6 @@ ipfw_nat_get_log(struct sockopt *sopt)
static void
ipfw_nat_init(void)
{
INIT_VNET_IPFW(curvnet);
IPFW_WLOCK(&V_layer3_chain);
/* init ipfw hooks */
@ -612,7 +603,6 @@ ipfw_nat_init(void)
static void
ipfw_nat_destroy(void)
{
INIT_VNET_IPFW(curvnet);
struct ip_fw *rule;
struct cfg_nat *ptr, *ptr_temp;

View File

@ -62,17 +62,14 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_fw.h>
#include <netinet/ip_divert.h>
#include <netinet/ip_dummynet.h>
#include <netinet/vinet.h>
#include <netgraph/ng_ipfw.h>
#include <machine/in_cksum.h>
#ifdef VIMAGE_GLOBALS
int fw_enable = 1;
VNET_DEFINE(int, fw_enable) = 1;
#ifdef INET6
int fw6_enable = 1;
#endif
VNET_DEFINE(int, fw6_enable) = 1;
#endif
int ipfw_chg_hook(SYSCTL_HANDLER_ARGS);
@ -92,7 +89,6 @@ int
ipfw_check_in(void *arg, struct mbuf **m0, struct ifnet *ifp, int dir,
struct inpcb *inp)
{
INIT_VNET_INET(curvnet);
struct ip_fw_args args;
struct ng_ipfw_tag *ng_tag;
struct m_tag *dn_tag;
@ -226,7 +222,6 @@ int
ipfw_check_out(void *arg, struct mbuf **m0, struct ifnet *ifp, int dir,
struct inpcb *inp)
{
INIT_VNET_INET(curvnet);
struct ip_fw_args args;
struct ng_ipfw_tag *ng_tag;
struct m_tag *dn_tag;
@ -520,7 +515,6 @@ ipfw6_unhook(void)
int
ipfw_chg_hook(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_IPFW(curvnet);
int enable = *(int *)arg1;
int error;

View File

@ -68,18 +68,17 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_var.h>
#include <netinet/ip_mroute.h>
#include <netinet/vinet.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
#endif /*IPSEC*/
#include <security/mac/mac_framework.h>
#ifdef VIMAGE_GLOBALS
struct inpcbhead ripcb;
struct inpcbinfo ripcbinfo;
#endif
VNET_DEFINE(struct inpcbhead, ripcb);
VNET_DEFINE(struct inpcbinfo, ripcbinfo);
#define V_ripcb VNET_GET(ripcb)
#define V_ripcbinfo VNET_GET(ripcbinfo)
/*
* Control and data hooks for ipfw and dummynet.
@ -99,9 +98,7 @@ int (*ip_dn_io_ptr)(struct mbuf **m, int dir, struct ip_fw_args *fwa) = NULL;
/*
* The socket used to communicate with the multicast routing daemon.
*/
#ifdef VIMAGE_GLOBALS
struct socket *ip_mrouter;
#endif
VNET_DEFINE(struct socket *, ip_mrouter);
/*
* The various mrouter and rsvp functions.
@ -168,7 +165,6 @@ rip_delhash(struct inpcb *inp)
static void
rip_zone_change(void *tag)
{
INIT_VNET_INET(curvnet);
uma_zone_set_max(V_ripcbinfo.ipi_zone, maxsockets);
}
@ -185,7 +181,6 @@ rip_inpcb_init(void *mem, int size, int flags)
void
rip_init(void)
{
INIT_VNET_INET(curvnet);
INP_INFO_LOCK_INIT(&V_ripcbinfo, "rip");
LIST_INIT(&V_ripcb);
@ -208,7 +203,6 @@ rip_init(void)
void
rip_destroy(void)
{
INIT_VNET_INET(curvnet);
hashdestroy(V_ripcbinfo.ipi_hashbase, M_PCB,
V_ripcbinfo.ipi_hashmask);
@ -268,7 +262,6 @@ rip_append(struct inpcb *last, struct ip *ip, struct mbuf *n,
void
rip_input(struct mbuf *m, int off)
{
INIT_VNET_INET(curvnet);
struct ifnet *ifp;
struct ip *ip = mtod(m, struct ip *);
int proto = ip->ip_p;
@ -398,7 +391,6 @@ rip_input(struct mbuf *m, int off)
int
rip_output(struct mbuf *m, struct socket *so, u_long dst)
{
INIT_VNET_INET(so->so_vnet);
struct ip *ip;
int error;
struct inpcb *inp = sotoinpcb(so);
@ -670,7 +662,6 @@ rip_ctloutput(struct socket *so, struct sockopt *sopt)
void
rip_ctlinput(int cmd, struct sockaddr *sa, void *vip)
{
INIT_VNET_INET(curvnet);
struct in_ifaddr *ia;
struct ifnet *ifp;
int err;
@ -741,7 +732,6 @@ SYSCTL_ULONG(_net_inet_raw, OID_AUTO, recvspace, CTLFLAG_RW,
static int
rip_attach(struct socket *so, int proto, struct thread *td)
{
INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
int error;
@ -775,7 +765,6 @@ rip_attach(struct socket *so, int proto, struct thread *td)
static void
rip_detach(struct socket *so)
{
INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
inp = sotoinpcb(so);
@ -815,7 +804,6 @@ rip_dodisconnect(struct socket *so, struct inpcb *inp)
static void
rip_abort(struct socket *so)
{
INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
inp = sotoinpcb(so);
@ -831,7 +819,6 @@ rip_abort(struct socket *so)
static void
rip_close(struct socket *so)
{
INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
inp = sotoinpcb(so);
@ -847,7 +834,6 @@ rip_close(struct socket *so)
static int
rip_disconnect(struct socket *so)
{
INIT_VNET_INET(so->so_vnet);
struct inpcb *inp;
if ((so->so_state & SS_ISCONNECTED) == 0)
@ -867,8 +853,6 @@ rip_disconnect(struct socket *so)
static int
rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
{
INIT_VNET_NET(so->so_vnet);
INIT_VNET_INET(so->so_vnet);
struct sockaddr_in *addr = (struct sockaddr_in *)nam;
struct inpcb *inp;
int error;
@ -903,8 +887,6 @@ rip_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
static int
rip_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
{
INIT_VNET_NET(so->so_vnet);
INIT_VNET_INET(so->so_vnet);
struct sockaddr_in *addr = (struct sockaddr_in *)nam;
struct inpcb *inp;
@ -975,7 +957,6 @@ rip_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam,
static int
rip_pcblist(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_INET(curvnet);
int error, i, n;
struct inpcb *inp, **inp_list;
inp_gen_t gencnt;

View File

@ -78,12 +78,10 @@ __FBSDID("$FreeBSD$");
#include <netinet/ip_var.h>
#include <netinet/ip_icmp.h>
#include <netinet/icmp_var.h>
#include <netinet/vinet.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
#include <netipsec/key.h>
#include <netipsec/vipsec.h>
#endif /* IPSEC */
#ifdef INET6
@ -98,7 +96,6 @@ __FBSDID("$FreeBSD$");
#include <netinet6/ip6protosw.h>
#include <netinet6/nd6.h>
#include <netinet6/scope6_var.h>
#include <netinet6/vinet6.h>
#endif /* INET6 */

View File

@ -94,7 +94,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/tcp.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp_hostcache.h>
#include <netinet/vinet.h>
#ifdef INET6
#include <netinet6/tcp6_var.h>
#endif
@ -107,10 +106,11 @@ __FBSDID("$FreeBSD$");
#define TCP_HOSTCACHE_EXPIRE 60*60 /* one hour */
#define TCP_HOSTCACHE_PRUNE 5*60 /* every 5 minutes */
#ifdef VIMAGE_GLOBALS
static struct tcp_hostcache tcp_hostcache;
static struct callout tcp_hc_callout;
#endif
static VNET_DEFINE(struct tcp_hostcache, tcp_hostcache);
static VNET_DEFINE(struct callout, tcp_hc_callout);
#define V_tcp_hostcache VNET_GET(tcp_hostcache)
#define V_tcp_hc_callout VNET_GET(tcp_hc_callout)
static struct hc_metrics *tcp_hc_lookup(struct in_conninfo *);
static struct hc_metrics *tcp_hc_insert(struct in_conninfo *);
@ -120,31 +120,32 @@ static void tcp_hc_purge(void *);
SYSCTL_NODE(_net_inet_tcp, OID_AUTO, hostcache, CTLFLAG_RW, 0,
"TCP Host cache");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, cachelimit,
CTLFLAG_RDTUN, tcp_hostcache.cache_limit, 0,
SYSCTL_VNET_INT(_net_inet_tcp_hostcache, OID_AUTO, cachelimit, CTLFLAG_RDTUN,
&VNET_NAME(tcp_hostcache.cache_limit), 0,
"Overall entry limit for hostcache");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, hashsize,
CTLFLAG_RDTUN, tcp_hostcache.hashsize, 0,
SYSCTL_VNET_INT(_net_inet_tcp_hostcache, OID_AUTO, hashsize, CTLFLAG_RDTUN,
&VNET_NAME(tcp_hostcache.hashsize), 0,
"Size of TCP hostcache hashtable");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, bucketlimit,
CTLFLAG_RDTUN, tcp_hostcache.bucket_limit, 0,
SYSCTL_VNET_INT(_net_inet_tcp_hostcache, OID_AUTO, bucketlimit,
CTLFLAG_RDTUN, &VNET_NAME(tcp_hostcache.bucket_limit), 0,
"Per-bucket hash limit for hostcache");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, count,
CTLFLAG_RD, tcp_hostcache.cache_count, 0,
SYSCTL_VNET_INT(_net_inet_tcp_hostcache, OID_AUTO, count, CTLFLAG_RD,
&VNET_NAME(tcp_hostcache.cache_count), 0,
"Current number of entries in hostcache");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, expire,
CTLFLAG_RW, tcp_hostcache.expire, 0,
SYSCTL_VNET_INT(_net_inet_tcp_hostcache, OID_AUTO, expire, CTLFLAG_RW,
&VNET_NAME(tcp_hostcache.expire), 0,
"Expire time of TCP hostcache entries");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, prune,
CTLFLAG_RW, tcp_hostcache.prune, 0, "Time between purge runs");
SYSCTL_VNET_INT(_net_inet_tcp_hostcache, OID_AUTO, prune, CTLFLAG_RW,
&VNET_NAME(tcp_hostcache.prune), 0,
"Time between purge runs");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_hostcache, OID_AUTO, purge,
CTLFLAG_RW, tcp_hostcache.purgeall, 0,
SYSCTL_VNET_INT(_net_inet_tcp_hostcache, OID_AUTO, purge, CTLFLAG_RW,
&VNET_NAME(tcp_hostcache.purgeall), 0,
"Expire all entires on next purge run");
SYSCTL_PROC(_net_inet_tcp_hostcache, OID_AUTO, list,
@ -172,7 +173,6 @@ static MALLOC_DEFINE(M_HOSTCACHE, "hostcache", "TCP hostcache");
void
tcp_hc_init(void)
{
INIT_VNET_INET(curvnet);
int i;
/*
@ -235,7 +235,6 @@ tcp_hc_init(void)
void
tcp_hc_destroy(void)
{
INIT_VNET_INET(curvnet);
/* XXX TODO walk the hashtable and free all entries */
@ -252,7 +251,6 @@ tcp_hc_destroy(void)
static struct hc_metrics *
tcp_hc_lookup(struct in_conninfo *inc)
{
INIT_VNET_INET(curvnet);
int hash;
struct hc_head *hc_head;
struct hc_metrics *hc_entry;
@ -308,7 +306,6 @@ tcp_hc_lookup(struct in_conninfo *inc)
static struct hc_metrics *
tcp_hc_insert(struct in_conninfo *inc)
{
INIT_VNET_INET(curvnet);
int hash;
struct hc_head *hc_head;
struct hc_metrics *hc_entry;
@ -399,7 +396,6 @@ tcp_hc_insert(struct in_conninfo *inc)
void
tcp_hc_get(struct in_conninfo *inc, struct hc_metrics_lite *hc_metrics_lite)
{
INIT_VNET_INET(curvnet);
struct hc_metrics *hc_entry;
/*
@ -440,7 +436,6 @@ tcp_hc_get(struct in_conninfo *inc, struct hc_metrics_lite *hc_metrics_lite)
u_long
tcp_hc_getmtu(struct in_conninfo *inc)
{
INIT_VNET_INET(curvnet);
struct hc_metrics *hc_entry;
u_long mtu;
@ -463,7 +458,6 @@ tcp_hc_getmtu(struct in_conninfo *inc)
void
tcp_hc_updatemtu(struct in_conninfo *inc, u_long mtu)
{
INIT_VNET_INET(curvnet);
struct hc_metrics *hc_entry;
/*
@ -503,7 +497,6 @@ tcp_hc_updatemtu(struct in_conninfo *inc, u_long mtu)
void
tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
{
INIT_VNET_INET(curvnet);
struct hc_metrics *hc_entry;
hc_entry = tcp_hc_lookup(inc);
@ -584,7 +577,6 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
static int
sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
{
INIT_VNET_INET(curvnet);
int bufsize;
int linesize = 128;
char *p, *buf;
@ -648,7 +640,6 @@ static void
tcp_hc_purge(void *arg)
{
CURVNET_SET((struct vnet *) arg);
INIT_VNET_INET(curvnet);
struct hc_metrics *hc_entry, *hc_next;
int all = 0;
int i;

View File

@ -86,11 +86,6 @@ __FBSDID("$FreeBSD$");
#ifdef TCPDEBUG
#include <netinet/tcp_debug.h>
#endif /* TCPDEBUG */
#include <netinet/vinet.h>
#ifdef INET6
#include <netinet6/vinet6.h>
#endif
#ifdef IPSEC
#include <netipsec/ipsec.h>
@ -103,75 +98,82 @@ __FBSDID("$FreeBSD$");
static const int tcprexmtthresh = 3;
#ifdef VIMAGE_GLOBALS
struct tcpstat tcpstat;
int blackhole;
int tcp_delack_enabled;
int drop_synfin;
int tcp_do_rfc3042;
int tcp_do_rfc3390;
int tcp_do_ecn;
int tcp_ecn_maxretries;
int tcp_insecure_rst;
int tcp_do_autorcvbuf;
int tcp_autorcvbuf_inc;
int tcp_autorcvbuf_max;
int tcp_do_rfc3465;
int tcp_abc_l_var;
#endif
VNET_DEFINE(struct tcpstat, tcpstat);
VNET_DEFINE(int, blackhole);
VNET_DEFINE(int, tcp_delack_enabled);
VNET_DEFINE(int, drop_synfin);
VNET_DEFINE(int, tcp_do_rfc3042);
VNET_DEFINE(int, tcp_do_rfc3390);
VNET_DEFINE(int, tcp_do_ecn);
VNET_DEFINE(int, tcp_ecn_maxretries);
VNET_DEFINE(int, tcp_insecure_rst);
VNET_DEFINE(int, tcp_do_autorcvbuf);
VNET_DEFINE(int, tcp_autorcvbuf_inc);
VNET_DEFINE(int, tcp_autorcvbuf_max);
VNET_DEFINE(int, tcp_do_rfc3465);
VNET_DEFINE(int, tcp_abc_l_var);
SYSCTL_V_STRUCT(V_NET, vnet_inet, _net_inet_tcp, TCPCTL_STATS, stats,
CTLFLAG_RW, tcpstat , tcpstat,
SYSCTL_VNET_STRUCT(_net_inet_tcp, TCPCTL_STATS, stats, CTLFLAG_RW,
&VNET_NAME(tcpstat), tcpstat,
"TCP statistics (struct tcpstat, netinet/tcp_var.h)");
int tcp_log_in_vain = 0;
SYSCTL_INT(_net_inet_tcp, OID_AUTO, log_in_vain, CTLFLAG_RW,
&tcp_log_in_vain, 0, "Log all incoming TCP segments to closed ports");
&tcp_log_in_vain, 0,
"Log all incoming TCP segments to closed ports");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, blackhole, CTLFLAG_RW,
blackhole, 0, "Do not send RST on segments to closed ports");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, blackhole, CTLFLAG_RW,
&VNET_NAME(blackhole), 0,
"Do not send RST on segments to closed ports");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, delayed_ack,
CTLFLAG_RW, tcp_delack_enabled, 0,
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, delayed_ack, CTLFLAG_RW,
&VNET_NAME(tcp_delack_enabled), 0,
"Delay ACK to try and piggyback it onto a data packet");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, drop_synfin,
CTLFLAG_RW, drop_synfin, 0, "Drop TCP packets with SYN+FIN set");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, drop_synfin, CTLFLAG_RW,
&VNET_NAME(drop_synfin), 0,
"Drop TCP packets with SYN+FIN set");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, rfc3042, CTLFLAG_RW,
tcp_do_rfc3042, 0, "Enable RFC 3042 (Limited Transmit)");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, rfc3042, CTLFLAG_RW,
&VNET_NAME(tcp_do_rfc3042), 0,
"Enable RFC 3042 (Limited Transmit)");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, rfc3390, CTLFLAG_RW,
tcp_do_rfc3390, 0,
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, rfc3390, CTLFLAG_RW,
&VNET_NAME(tcp_do_rfc3390), 0,
"Enable RFC 3390 (Increasing TCP's Initial Congestion Window)");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, rfc3465, CTLFLAG_RW,
tcp_do_rfc3465, 0,
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, rfc3465, CTLFLAG_RW,
&VNET_NAME(tcp_do_rfc3465), 0,
"Enable RFC 3465 (Appropriate Byte Counting)");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, abc_l_var, CTLFLAG_RW,
tcp_abc_l_var, 2,
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, abc_l_var, CTLFLAG_RW,
&VNET_NAME(tcp_abc_l_var), 2,
"Cap the max cwnd increment during slow-start to this number of segments");
SYSCTL_NODE(_net_inet_tcp, OID_AUTO, ecn, CTLFLAG_RW, 0, "TCP ECN");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_ecn, OID_AUTO, enable,
CTLFLAG_RW, tcp_do_ecn, 0, "TCP ECN support");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_ecn, OID_AUTO, maxretries,
CTLFLAG_RW, tcp_ecn_maxretries, 0, "Max retries before giving up on ECN");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, insecure_rst,
CTLFLAG_RW, tcp_insecure_rst, 0,
SYSCTL_VNET_INT(_net_inet_tcp_ecn, OID_AUTO, enable, CTLFLAG_RW,
&VNET_NAME(tcp_do_ecn), 0,
"TCP ECN support");
SYSCTL_VNET_INT(_net_inet_tcp_ecn, OID_AUTO, maxretries, CTLFLAG_RW,
&VNET_NAME(tcp_ecn_maxretries), 0,
"Max retries before giving up on ECN");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, insecure_rst, CTLFLAG_RW,
&VNET_NAME(tcp_insecure_rst), 0,
"Follow the old (insecure) criteria for accepting RST packets");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, recvbuf_auto,
CTLFLAG_RW, tcp_do_autorcvbuf, 0,
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, recvbuf_auto, CTLFLAG_RW,
&VNET_NAME(tcp_do_autorcvbuf), 0,
"Enable automatic receive buffer sizing");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, recvbuf_inc,
CTLFLAG_RW, tcp_autorcvbuf_inc, 0,
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, recvbuf_inc, CTLFLAG_RW,
&VNET_NAME(tcp_autorcvbuf_inc), 0,
"Incrementor step size of automatic receive buffer");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, recvbuf_max,
CTLFLAG_RW, tcp_autorcvbuf_max, 0,
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, recvbuf_max, CTLFLAG_RW,
&VNET_NAME(tcp_autorcvbuf_max), 0,
"Max size of automatic receive buffer");
int tcp_read_locking = 1;
@ -198,10 +200,8 @@ int tcp_wlock_looped;
SYSCTL_INT(_net_inet_tcp, OID_AUTO, wlock_looped, CTLFLAG_RD,
&tcp_wlock_looped, 0, "");
#ifdef VIMAGE_GLOBALS
struct inpcbhead tcb;
struct inpcbinfo tcbinfo;
#endif
VNET_DEFINE(struct inpcbhead, tcb);
VNET_DEFINE(struct inpcbinfo, tcbinfo);
#define tcb6 tcb /* for KAME src sync over BSD*'s */
static void tcp_dooptions(struct tcpopt *, u_char *, int, int);
@ -271,7 +271,6 @@ do { \
int
tcp6_input(struct mbuf **mp, int *offp, int proto)
{
INIT_VNET_INET6(curvnet);
struct mbuf *m = *mp;
struct in6_ifaddr *ia6;
@ -300,13 +299,6 @@ tcp6_input(struct mbuf **mp, int *offp, int proto)
void
tcp_input(struct mbuf *m, int off0)
{
INIT_VNET_INET(curvnet);
#ifdef INET6
INIT_VNET_INET6(curvnet);
#endif
#ifdef IPSEC
INIT_VNET_IPSEC(curvnet);
#endif
struct tcphdr *th;
struct ip *ip = NULL;
struct ipovly *ipov;
@ -1083,7 +1075,6 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos,
int ti_locked)
{
INIT_VNET_INET(tp->t_vnet);
int thflags, acked, ourfinisacked, needoutput = 0;
int rstreason, todrop, win;
u_long tiwin;
@ -2868,7 +2859,6 @@ tcp_dropwithreset(struct mbuf *m, struct tcphdr *th, struct tcpcb *tp,
static void
tcp_dooptions(struct tcpopt *to, u_char *cp, int cnt, int flags)
{
INIT_VNET_INET(curvnet);
int opt, optlen;
to->to_flags = 0;
@ -2996,7 +2986,6 @@ tcp_pulloutofband(struct socket *so, struct tcphdr *th, struct mbuf *m,
static void
tcp_xmit_timer(struct tcpcb *tp, int rtt)
{
INIT_VNET_INET(tp->t_inpcb->inp_vnet);
int delta;
INP_WLOCK_ASSERT(tp->t_inpcb);
@ -3103,7 +3092,6 @@ void
tcp_mss_update(struct tcpcb *tp, int offer,
struct hc_metrics_lite *metricptr, int *mtuflags)
{
INIT_VNET_INET(tp->t_inpcb->inp_vnet);
int mss;
u_long maxmtu;
struct inpcb *inp = tp->t_inpcb;
@ -3269,7 +3257,6 @@ tcp_mss(struct tcpcb *tp, int offer)
int isipv6;
#endif
KASSERT(tp != NULL, ("%s: tp == NULL", __func__));
INIT_VNET_INET(tp->t_vnet);
tcp_mss_update(tp, offer, &metrics, &mtuflags);
@ -3396,7 +3383,6 @@ tcp_mss(struct tcpcb *tp, int offer)
int
tcp_mssopt(struct in_conninfo *inc)
{
INIT_VNET_INET(curvnet);
int mss = 0;
u_long maxmtu = 0;
u_long thcmtu = 0;

View File

@ -51,7 +51,6 @@ __FBSDID("$FreeBSD$");
#include <netinet/tcp_var.h>
#include <netinet/tcp_offload.h>
#include <netinet/toedev.h>
#include <netinet/vinet.h>
uint32_t toedev_registration_count;
@ -109,7 +108,6 @@ tcp_offload_connect(struct socket *so, struct sockaddr *nam)
void
tcp_offload_twstart(struct tcpcb *tp)
{
INIT_VNET_INET(curvnet);
INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(tp->t_inpcb);
@ -120,8 +118,7 @@ tcp_offload_twstart(struct tcpcb *tp)
struct tcpcb *
tcp_offload_close(struct tcpcb *tp)
{
INIT_VNET_INET(curvnet);
INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(tp->t_inpcb);
tp = tcp_close(tp);
@ -135,8 +132,7 @@ tcp_offload_close(struct tcpcb *tp)
struct tcpcb *
tcp_offload_drop(struct tcpcb *tp, int error)
{
INIT_VNET_INET(curvnet);
INP_INFO_WLOCK(&V_tcbinfo);
INP_WLOCK(tp->t_inpcb);
tp = tcp_drop(tp, error);

View File

@ -74,7 +74,6 @@ __FBSDID("$FreeBSD$");
#ifdef TCPDEBUG
#include <netinet/tcp_debug.h>
#endif
#include <netinet/vinet.h>
#ifdef IPSEC
#include <netipsec/ipsec.h>
@ -88,44 +87,45 @@ __FBSDID("$FreeBSD$");
extern struct mbuf *m_copypack();
#endif
#ifdef VIMAGE_GLOBALS
int path_mtu_discovery;
int ss_fltsz;
int ss_fltsz_local;
int tcp_do_newreno;
int tcp_do_tso;
int tcp_do_autosndbuf;
int tcp_autosndbuf_inc;
int tcp_autosndbuf_max;
#endif
VNET_DEFINE(int, path_mtu_discovery);
VNET_DEFINE(int, ss_fltsz);
VNET_DEFINE(int, ss_fltsz_local);
VNET_DEFINE(int, tcp_do_newreno);
VNET_DEFINE(int, tcp_do_tso);
VNET_DEFINE(int, tcp_do_autosndbuf);
VNET_DEFINE(int, tcp_autosndbuf_inc);
VNET_DEFINE(int, tcp_autosndbuf_max);
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, path_mtu_discovery,
CTLFLAG_RW, path_mtu_discovery, 1, "Enable Path MTU Discovery");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, path_mtu_discovery, CTLFLAG_RW,
&VNET_NAME(path_mtu_discovery), 1,
"Enable Path MTU Discovery");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO,
slowstart_flightsize, CTLFLAG_RW,
ss_fltsz, 1, "Slow start flight size");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, slowstart_flightsize, CTLFLAG_RW,
&VNET_NAME(ss_fltsz), 1,
"Slow start flight size");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO,
local_slowstart_flightsize, CTLFLAG_RW,
ss_fltsz_local, 1, "Slow start flight size for local networks");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, local_slowstart_flightsize,
CTLFLAG_RW, &VNET_NAME(ss_fltsz_local), 1,
"Slow start flight size for local networks");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, newreno, CTLFLAG_RW,
tcp_do_newreno, 0, "Enable NewReno Algorithms");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, newreno, CTLFLAG_RW,
&VNET_NAME(tcp_do_newreno), 0,
"Enable NewReno Algorithms");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, tso, CTLFLAG_RW,
tcp_do_tso, 0, "Enable TCP Segmentation Offload");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, tso, CTLFLAG_RW,
&VNET_NAME(tcp_do_tso), 0,
"Enable TCP Segmentation Offload");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, sendbuf_auto,
CTLFLAG_RW,
tcp_do_autosndbuf, 0, "Enable automatic send buffer sizing");
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, sendbuf_auto, CTLFLAG_RW,
&VNET_NAME(tcp_do_autosndbuf), 0,
"Enable automatic send buffer sizing");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, sendbuf_inc,
CTLFLAG_RW, tcp_autosndbuf_inc, 0,
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, sendbuf_inc, CTLFLAG_RW,
&VNET_NAME(tcp_autosndbuf_inc), 0,
"Incrementor step size of automatic send buffer");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, sendbuf_max,
CTLFLAG_RW, tcp_autosndbuf_max, 0,
SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, sendbuf_max, CTLFLAG_RW,
&VNET_NAME(tcp_autosndbuf_max), 0,
"Max size of automatic send buffer");
@ -135,7 +135,6 @@ SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, sendbuf_max,
int
tcp_output(struct tcpcb *tp)
{
INIT_VNET_INET(tp->t_inpcb->inp_vnet);
struct socket *so = tp->t_inpcb->inp_socket;
long len, recwin, sendwin;
int off, flags, error;
@ -1328,7 +1327,6 @@ tcp_setpersist(struct tcpcb *tp)
int
tcp_addoptions(struct tcpopt *to, u_char *optp)
{
INIT_VNET_INET(curvnet);
u_int mask, optlen = 0;
for (mask = 1; mask < TOF_MAXOPT; mask <<= 1) {

View File

@ -73,52 +73,49 @@ __FBSDID("$FreeBSD$");
#ifdef TCPDEBUG
#include <netinet/tcp_debug.h>
#endif /* TCPDEBUG */
#include <netinet/vinet.h>
#ifdef VIMAGE_GLOBALS
static int tcp_reass_maxseg;
int tcp_reass_qsize;
static int tcp_reass_maxqlen;
static int tcp_reass_overflows;
#endif
static VNET_DEFINE(int, tcp_reass_maxseg);
VNET_DEFINE(int, tcp_reass_qsize);
static VNET_DEFINE(int, tcp_reass_maxqlen);
static VNET_DEFINE(int, tcp_reass_overflows);
#define V_tcp_reass_maxseg VNET_GET(tcp_reass_maxseg)
#define V_tcp_reass_maxqlen VNET_GET(tcp_reass_maxqlen)
#define V_tcp_reass_overflows VNET_GET(tcp_reass_overflows)
SYSCTL_NODE(_net_inet_tcp, OID_AUTO, reass, CTLFLAG_RW, 0,
"TCP Segment Reassembly Queue");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_reass, OID_AUTO, maxsegments,
CTLFLAG_RDTUN, tcp_reass_maxseg, 0,
SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, maxsegments, CTLFLAG_RDTUN,
&VNET_NAME(tcp_reass_maxseg), 0,
"Global maximum number of TCP Segments in Reassembly Queue");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_reass, OID_AUTO, cursegments,
CTLFLAG_RD, tcp_reass_qsize, 0,
SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, cursegments, CTLFLAG_RD,
&VNET_NAME(tcp_reass_qsize), 0,
"Global number of TCP Segments currently in Reassembly Queue");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_reass, OID_AUTO, maxqlen,
CTLFLAG_RW, tcp_reass_maxqlen, 0,
SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, maxqlen, CTLFLAG_RW,
&VNET_NAME(tcp_reass_maxqlen), 0,
"Maximum number of TCP Segments per individual Reassembly Queue");
SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_reass, OID_AUTO, overflows,
CTLFLAG_RD, tcp_reass_overflows, 0,
SYSCTL_VNET_INT(_net_inet_tcp_reass, OID_AUTO, overflows, CTLFLAG_RD,
&VNET_NAME(tcp_reass_overflows), 0,
"Global number of TCP Segment Reassembly Queue Overflows");
/* Initialize TCP reassembly queue */
static void
tcp_reass_zone_change(void *tag)
{
INIT_VNET_INET(curvnet);
V_tcp_reass_maxseg = nmbclusters / 16;
uma_zone_set_max(V_tcp_reass_zone, V_tcp_reass_maxseg);
}
#ifdef VIMAGE_GLOBALS
uma_zone_t tcp_reass_zone;
#endif
VNET_DEFINE(uma_zone_t, tcp_reass_zone);
void
tcp_reass_init(void)
{
INIT_VNET_INET(curvnet);
V_tcp_reass_maxseg = 0;
V_tcp_reass_qsize = 0;
@ -138,7 +135,6 @@ tcp_reass_init(void)
int
tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m)
{
INIT_VNET_INET(curvnet);
struct tseg_qent *q;
struct tseg_qent *p = NULL;
struct tseg_qent *nq;

Some files were not shown because too many files have changed in this diff Show More