freebsd-dev/sys/netinet/vinet.h
Marko Zec 1ed81b739e First pass at separating per-vnet initializer functions
from existing functions for initializing global state.

        At this stage, the new per-vnet initializer functions are
	directly called from the existing global initialization code,
	which should in most cases result in compiler inlining those
	new functions, hence yielding a near-zero functional change.

        Modify the existing initializer functions which are invoked via
        protosw, like ip_init() et. al., to allow them to be invoked
	multiple times, i.e. per each vnet.  Global state, if any,
	is initialized only if such functions are called within the
	context of vnet0, which will be determined via the
	IS_DEFAULT_VNET(curvnet) check (currently always true).

        While here, V_irtualize a few remaining global UMA zones
        used by net/netinet/netipsec networking code.  While it is
        not yet clear to me or anybody else whether this is the right
        thing to do, at this stage this makes the code more readable,
        and makes it easier to track uncollected UMA-zone-backed
        objects on vnet removal.  In the long run, it's quite possible
        that some form of shared use of UMA zone pools among multiple
        vnets should be considered.

	Bump __FreeBSD_version due to changes in layout of structs
	vnet_ipfw, vnet_inet and vnet_net.

Approved by:	julian (mentor)
2009-04-06 22:29:41 +00:00

384 lines
13 KiB
C

/*-
* 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.
*
* 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.
*
* $FreeBSD$
*/
#ifndef _NETINET_VINET_H_
#define _NETINET_VINET_H_
#include <sys/sysctl.h>
#include <netinet/in.h>
#include <netinet/in_var.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/icmp_var.h>
#include <netinet/igmp_var.h>
#include <netinet/tcp.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp_hostcache.h>
#include <netinet/tcp_syncache.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
struct vnet_inet {
struct in_ifaddrhashhead *_in_ifaddrhashtbl;
struct in_ifaddrhead _in_ifaddrhead;
u_long _in_ifaddrhmask;
struct in_multihead _in_multihead; /* XXX unused */
int _arpt_keep;
int _arp_maxtries;
int _useloopback;
int _arp_proxyall;
int _subnetsarelocal;
int _sameprefixcarponly;
int _ipforwarding;
int _ipstealth;
int _ipfastforward_active;
int _ipsendredirects;
int _ip_defttl;
int _ip_keepfaith;
int _ip_sendsourcequench;
int _ip_do_randomid;
int _ip_checkinterface;
u_short _ip_id;
uma_zone_t _ipq_zone;
int _nipq; /* Total # of reass queues */
int _maxnipq; /* Admin. limit on # reass queues. */
int _maxfragsperpacket;
TAILQ_HEAD(ipqhead, ipq) _ipq[IPREASS_NHASH];
struct inpcbhead _tcb; /* head of queue of active tcpcb's */
struct inpcbinfo _tcbinfo;
struct tcpstat _tcpstat; /* tcp statistics */
struct tcp_hostcache _tcp_hostcache;
struct callout _tcp_hc_callout;
uma_zone_t _tcp_reass_zone;
uma_zone_t _tcpcb_zone;
uma_zone_t _tcptw_zone;
uma_zone_t _sack_hole_zone;
struct tcp_syncache _tcp_syncache;
int _tcp_syncookies;
int _tcp_syncookiesonly;
int _tcp_sc_rst_sock_fail;
struct inpcbhead _divcb;
struct inpcbinfo _divcbinfo;
TAILQ_HEAD(, tcptw) _twq_2msl;
int _tcp_mssdflt;
int _tcp_v6mssdflt;
int _tcp_minmss;
int _tcp_do_rfc1323;
int _icmp_may_rst;
int _tcp_isn_reseed_interval;
int _tcp_inflight_enable;
int _tcp_inflight_rttthresh;
int _tcp_inflight_min;
int _tcp_inflight_max;
int _tcp_inflight_stab;
int _nolocaltimewait;
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;
int _tcp_do_sack;
int _tcp_sack_maxholes;
int _tcp_sack_globalmaxholes;
int _tcp_sack_globalholes;
int _blackhole;
int _tcp_delack_enabled;
int _drop_synfin;
int _tcp_do_rfc3042;
int _tcp_do_rfc3390;
int _tcp_do_rfc3465;
int _tcp_abc_l_var;
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_reass_maxseg;
int _tcp_reass_qsize;
int _tcp_reass_maxqlen;
int _tcp_reass_overflows;
u_char _isn_secret[32];
int _isn_last_reseed;
u_int32_t _isn_offset;
u_int32_t _isn_offset_old;
struct inpcbhead _udb;
struct inpcbinfo _udbinfo;
struct udpstat _udpstat;
int _udp_blackhole;
struct inpcbhead _ripcb;
struct inpcbinfo _ripcbinfo;
struct socket *_ip_mrouter;
struct socket *_ip_rsvpd;
int _ip_rsvp_on;
int _rsvp_on;
struct icmpstat _icmpstat;
struct ipstat _ipstat;
LIST_HEAD(, igmp_ifinfo) _igi_head;
struct igmpstat _igmpstat;
int _interface_timers_running;
int _state_change_timers_running;
int _current_state_timers_running;
int _igmp_recvifkludge;
int _igmp_sendra;
int _igmp_sendlocal;
int _igmp_v1enable;
int _igmp_v2enable;
int _igmp_legacysupp;
int _igmp_sgalloc;
int _igmp_default_version;
struct timeval _igmp_gsrdelay;
int _rtq_timeout;
int _rtq_reallyold;
int _rtq_minreallyold;
int _rtq_toomany;
struct callout _rtq_timer;
int _ipport_lowfirstauto;
int _ipport_lowlastauto;
int _ipport_firstauto;
int _ipport_lastauto;
int _ipport_hifirstauto;
int _ipport_hilastauto;
int _ipport_reservedhigh;
int _ipport_reservedlow;
int _ipport_randomized;
int _ipport_randomcps;
int _ipport_randomtime;
int _ipport_stoprandom;
int _ipport_tcpallocs;
int _ipport_tcplastcount;
int _icmpmaskrepl;
u_int _icmpmaskfake;
int _drop_redirect;
int _log_redirect;
int _icmplim;
int _icmplim_output;
char _reply_src[IFNAMSIZ];
int _icmp_rfi;
int _icmp_quotelen;
int _icmpbmcastecho;
int _fw_one_pass;
};
/* Size guard. See sys/vimage.h. */
VIMAGE_CTASSERT(SIZEOF_vnet_inet, sizeof(struct vnet_inet));
#ifndef VIMAGE
#ifndef VIMAGE_GLOBALS
extern struct vnet_inet vnet_inet_0;
#endif
#endif
/*
* Symbol translation macros
*/
#define INIT_VNET_INET(vnet) \
INIT_FROM_VNET(vnet, VNET_MOD_INET, struct vnet_inet, vnet_inet)
#define VNET_INET(sym) VSYM(vnet_inet, sym)
#define V_arp_maxtries VNET_INET(arp_maxtries)
#define V_arp_proxyall VNET_INET(arp_proxyall)
#define V_arpt_keep VNET_INET(arpt_keep)
#define V_blackhole VNET_INET(blackhole)
#define V_divcb VNET_INET(divcb)
#define V_divcbinfo VNET_INET(divcbinfo)
#define V_drop_redirect VNET_INET(drop_redirect)
#define V_drop_synfin VNET_INET(drop_synfin)
#define V_fw_one_pass VNET_INET(fw_one_pass)
#define V_icmp_may_rst VNET_INET(icmp_may_rst)
#define V_icmp_quotelen VNET_INET(icmp_quotelen)
#define V_icmp_rfi VNET_INET(icmp_rfi)
#define V_icmpbmcastecho VNET_INET(icmpbmcastecho)
#define V_icmplim VNET_INET(icmplim)
#define V_icmplim_output VNET_INET(icmplim_output)
#define V_icmpmaskfake VNET_INET(icmpmaskfake)
#define V_icmpmaskrepl VNET_INET(icmpmaskrepl)
#define V_icmpstat VNET_INET(icmpstat)
#define V_igi_head VNET_INET(igi_head)
#define V_igmpstat VNET_INET(igmpstat)
#define V_interface_timers_running \
VNET_INET(interface_timers_running)
#define V_state_change_timers_running \
VNET_INET(state_change_timers_running)
#define V_current_state_timers_running \
VNET_INET(current_state_timers_running)
#define V_igmp_recvifkludge VNET_INET(igmp_recvifkludge)
#define V_igmp_sendra VNET_INET(igmp_sendra)
#define V_igmp_sendlocal VNET_INET(igmp_sendlocal)
#define V_igmp_v1enable VNET_INET(igmp_v1enable)
#define V_igmp_v2enable VNET_INET(igmp_v2enable)
#define V_igmp_legacysupp VNET_INET(igmp_legacysupp)
#define V_igmp_sgalloc VNET_INET(igmp_sgalloc)
#define V_igmp_default_version VNET_INET(igmp_default_version)
#define V_igmp_gsrdelay VNET_INET(igmp_gsrdelay)
#define V_in_ifaddrhashtbl VNET_INET(in_ifaddrhashtbl)
#define V_in_ifaddrhead VNET_INET(in_ifaddrhead)
#define V_in_ifaddrhmask VNET_INET(in_ifaddrhmask)
#define V_in_multihead VNET_INET(in_multihead)
#define V_ip_checkinterface VNET_INET(ip_checkinterface)
#define V_ip_defttl VNET_INET(ip_defttl)
#define V_ip_do_randomid VNET_INET(ip_do_randomid)
#define V_ip_id VNET_INET(ip_id)
#define V_ip_keepfaith VNET_INET(ip_keepfaith)
#define V_ip_mrouter VNET_INET(ip_mrouter)
#define V_ip_rsvp_on VNET_INET(ip_rsvp_on)
#define V_ip_rsvpd VNET_INET(ip_rsvpd)
#define V_ip_sendsourcequench VNET_INET(ip_sendsourcequench)
#define V_ipfastforward_active VNET_INET(ipfastforward_active)
#define V_ipforwarding VNET_INET(ipforwarding)
#define V_ipport_firstauto VNET_INET(ipport_firstauto)
#define V_ipport_hifirstauto VNET_INET(ipport_hifirstauto)
#define V_ipport_hilastauto VNET_INET(ipport_hilastauto)
#define V_ipport_lastauto VNET_INET(ipport_lastauto)
#define V_ipport_lowfirstauto VNET_INET(ipport_lowfirstauto)
#define V_ipport_lowlastauto VNET_INET(ipport_lowlastauto)
#define V_ipport_randomcps VNET_INET(ipport_randomcps)
#define V_ipport_randomized VNET_INET(ipport_randomized)
#define V_ipport_randomtime VNET_INET(ipport_randomtime)
#define V_ipport_reservedhigh VNET_INET(ipport_reservedhigh)
#define V_ipport_reservedlow VNET_INET(ipport_reservedlow)
#define V_ipport_stoprandom VNET_INET(ipport_stoprandom)
#define V_ipport_tcpallocs VNET_INET(ipport_tcpallocs)
#define V_ipport_tcplastcount VNET_INET(ipport_tcplastcount)
#define V_ipq VNET_INET(ipq)
#define V_ipq_zone VNET_INET(ipq_zone)
#define V_ipsendredirects VNET_INET(ipsendredirects)
#define V_ipstat VNET_INET(ipstat)
#define V_ipstealth VNET_INET(ipstealth)
#define V_isn_last_reseed VNET_INET(isn_last_reseed)
#define V_isn_offset VNET_INET(isn_offset)
#define V_isn_offset_old VNET_INET(isn_offset_old)
#define V_isn_secret VNET_INET(isn_secret)
#define V_llinfo_arp VNET_INET(llinfo_arp)
#define V_log_redirect VNET_INET(log_redirect)
#define V_maxfragsperpacket VNET_INET(maxfragsperpacket)
#define V_maxnipq VNET_INET(maxnipq)
#define V_nipq VNET_INET(nipq)
#define V_nolocaltimewait VNET_INET(nolocaltimewait)
#define V_path_mtu_discovery VNET_INET(path_mtu_discovery)
#define V_reply_src VNET_INET(reply_src)
#define V_ripcb VNET_INET(ripcb)
#define V_ripcbinfo VNET_INET(ripcbinfo)
#define V_router_info_head VNET_INET(router_info_head)
#define V_rsvp_on VNET_INET(rsvp_on)
#define V_rtq_minreallyold VNET_INET(rtq_minreallyold)
#define V_rtq_reallyold VNET_INET(rtq_reallyold)
#define V_rtq_timeout VNET_INET(rtq_timeout)
#define V_rtq_timer VNET_INET(rtq_timer)
#define V_rtq_toomany VNET_INET(rtq_toomany)
#define V_sack_hole_zone VNET_INET(sack_hole_zone)
#define V_sameprefixcarponly VNET_INET(sameprefixcarponly)
#define V_ss_fltsz VNET_INET(ss_fltsz)
#define V_ss_fltsz_local VNET_INET(ss_fltsz_local)
#define V_subnetsarelocal VNET_INET(subnetsarelocal)
#define V_tcb VNET_INET(tcb)
#define V_tcbinfo VNET_INET(tcbinfo)
#define V_tcpcb_zone VNET_INET(tcpcb_zone)
#define V_tcptw_zone VNET_INET(tcptw_zone)
#define V_tcp_abc_l_var VNET_INET(tcp_abc_l_var)
#define V_tcp_autorcvbuf_inc VNET_INET(tcp_autorcvbuf_inc)
#define V_tcp_autorcvbuf_max VNET_INET(tcp_autorcvbuf_max)
#define V_tcp_autosndbuf_inc VNET_INET(tcp_autosndbuf_inc)
#define V_tcp_autosndbuf_max VNET_INET(tcp_autosndbuf_max)
#define V_tcp_delack_enabled VNET_INET(tcp_delack_enabled)
#define V_tcp_do_autorcvbuf VNET_INET(tcp_do_autorcvbuf)
#define V_tcp_do_autosndbuf VNET_INET(tcp_do_autosndbuf)
#define V_tcp_do_ecn VNET_INET(tcp_do_ecn)
#define V_tcp_do_newreno VNET_INET(tcp_do_newreno)
#define V_tcp_do_rfc1323 VNET_INET(tcp_do_rfc1323)
#define V_tcp_do_rfc3042 VNET_INET(tcp_do_rfc3042)
#define V_tcp_do_rfc3390 VNET_INET(tcp_do_rfc3390)
#define V_tcp_do_rfc3465 VNET_INET(tcp_do_rfc3465)
#define V_tcp_do_sack VNET_INET(tcp_do_sack)
#define V_tcp_do_tso VNET_INET(tcp_do_tso)
#define V_tcp_ecn_maxretries VNET_INET(tcp_ecn_maxretries)
#define V_tcp_hc_callout VNET_INET(tcp_hc_callout)
#define V_tcp_hostcache VNET_INET(tcp_hostcache)
#define V_tcp_inflight_enable VNET_INET(tcp_inflight_enable)
#define V_tcp_inflight_max VNET_INET(tcp_inflight_max)
#define V_tcp_inflight_min VNET_INET(tcp_inflight_min)
#define V_tcp_inflight_rttthresh VNET_INET(tcp_inflight_rttthresh)
#define V_tcp_inflight_stab VNET_INET(tcp_inflight_stab)
#define V_tcp_insecure_rst VNET_INET(tcp_insecure_rst)
#define V_tcp_isn_reseed_interval VNET_INET(tcp_isn_reseed_interval)
#define V_tcp_minmss VNET_INET(tcp_minmss)
#define V_tcp_mssdflt VNET_INET(tcp_mssdflt)
#define V_tcp_reass_maxqlen VNET_INET(tcp_reass_maxqlen)
#define V_tcp_reass_maxseg VNET_INET(tcp_reass_maxseg)
#define V_tcp_reass_overflows VNET_INET(tcp_reass_overflows)
#define V_tcp_reass_qsize VNET_INET(tcp_reass_qsize)
#define V_tcp_reass_zone VNET_INET(tcp_reass_zone)
#define V_tcp_sack_globalholes VNET_INET(tcp_sack_globalholes)
#define V_tcp_sack_globalmaxholes VNET_INET(tcp_sack_globalmaxholes)
#define V_tcp_sack_maxholes VNET_INET(tcp_sack_maxholes)
#define V_tcp_sc_rst_sock_fail VNET_INET(tcp_sc_rst_sock_fail)
#define V_tcp_syncache VNET_INET(tcp_syncache)
#define V_tcp_syncookies VNET_INET(tcp_syncookies)
#define V_tcp_syncookiesonly VNET_INET(tcp_syncookiesonly)
#define V_tcp_v6mssdflt VNET_INET(tcp_v6mssdflt)
#define V_tcpstat VNET_INET(tcpstat)
#define V_twq_2msl VNET_INET(twq_2msl)
#define V_udb VNET_INET(udb)
#define V_udbinfo VNET_INET(udbinfo)
#define V_udp_blackhole VNET_INET(udp_blackhole)
#define V_udpstat VNET_INET(udpstat)
#define V_useloopback VNET_INET(useloopback)
#define ip_newid() ((V_ip_do_randomid != 0) ? ip_randomid() : htons(V_ip_id++))
#endif /* !_NETINET_VINET_H_ */