diff options
Diffstat (limited to 'sys/netinet')
42 files changed, 852 insertions, 1619 deletions
diff --git a/sys/netinet/icmp6.h b/sys/netinet/icmp6.h index c9daa93bc26e..32e3e9fbe38a 100644 --- a/sys/netinet/icmp6.h +++ b/sys/netinet/icmp6.h @@ -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 diff --git a/sys/netinet/icmp_var.h b/sys/netinet/icmp_var.h index 8d7b9dee8894..8be07b8d1f0f 100644 --- a/sys/netinet/icmp_var.h +++ b/sys/netinet/icmp_var.h @@ -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 diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 97ea1085bfdf..bf5f124921ea 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -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 - -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"); - -SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, maxtries, - CTLFLAG_RW, arp_maxtries, 0, +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); + +#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_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); diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index be102d442e78..c8bd09a265b6 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -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 */ - -LIST_HEAD(, igmp_ifinfo) igi_head; -struct igmpstat igmpstat; -struct timeval igmp_gsrdelay; - -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(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 */ + +#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) + +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 @@ out_locked: static int sysctl_igmp_gsr(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(curvnet); int error; int i; @@ -408,8 +422,6 @@ out_locked: 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 @@ out_locked: 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 @@ out_locked: 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 @@ out_locked: 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 @@ out: 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); diff --git a/sys/netinet/in.c b/sys/netinet/in.c index b9db746591e8..8b7eab67fdc3 100644 --- a/sys/netinet/in.c +++ b/sys/netinet/in.c @@ -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); + +#define V_subnetsarelocal VNET_GET(subnetsarelocal) +#define V_sameprefixcarponly VNET_GET(sameprefixcarponly) +#define V_ripcbinfo VNET_GET(ripcbinfo) -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_ip, OID_AUTO, subnets_are_local, - CTLFLAG_RW, subnetsarelocal, 0, +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); diff --git a/sys/netinet/in_gif.c b/sys/netinet/in_gif.c index 11e32c356408..fe2c9ee3bca4 100644 --- a/sys/netinet/in_gif.c +++ b/sys/netinet/in_gif.c @@ -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; diff --git a/sys/netinet/in_mcast.c b/sys/netinet/in_mcast.c index 5c299af6a6e1..6efa7d852b1c 100644 --- a/sys/netinet/in_mcast.c +++ b/sys/netinet/in_mcast.c @@ -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 @@ out_inp_locked: 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 @@ out_inp_locked: 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; diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 958e6b6ab313..58bf77a8b3ee 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -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); diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index f5b713bd6ac6..d8ac3bff0b08 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -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 *); diff --git a/sys/netinet/in_rmx.c b/sys/netinet/in_rmx.c index feaa2f9a6370..d39187181811 100644 --- a/sys/netinet/in_rmx.c +++ b/sys/netinet/in_rmx.c @@ -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); + +#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_V_INT(V_NET, vnet_inet, _net_inet_ip, IPCTL_RTEXPIRE, rtexpire, - CTLFLAG_RW, rtq_reallyold, 0, +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); diff --git a/sys/netinet/in_var.h b/sys/netinet/in_var.h index d4ba18c6c5ca..9a7cfb56548f 100644 --- a/sys/netinet/in_var.h +++ b/sys/netinet/in_var.h @@ -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, diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 152f5e6cd422..a4cd95029870 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -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; diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 80b001ab64b4..86ec9fce84c7 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -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 @@ cantsend: 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; diff --git a/sys/netinet/ip_fastfwd.c b/sys/netinet/ip_fastfwd.c index 8752916934f1..2207cc46aaae 100644 --- a/sys/netinet/ip_fastfwd.c +++ b/sys/netinet/ip_fastfwd.c @@ -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; diff --git a/sys/netinet/ip_fw.h b/sys/netinet/ip_fw.h index 9e3468f1671d..609ac4c4a503 100644 --- a/sys/netinet/ip_fw.h +++ b/sys/netinet/ip_fw.h @@ -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 */ diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index f3ef17524470..475f297e1f43 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -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 - -SYSCTL_V_STRUCT(V_NET, vnet_inet, _net_inet_icmp, ICMPCTL_STATS, stats, - CTLFLAG_RW, icmpstat, icmpstat, ""); - -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_icmp, ICMPCTL_MASKREPL, maskrepl, - CTLFLAG_RW, icmpmaskrepl, 0, +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); + +#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_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 @@ freeit: 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 @@ freeit: 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 { diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index 73ee28635197..11ab3c7355a1 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -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 @@ bad: 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 @@ done: 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 @@ makedummy: 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); diff --git a/sys/netinet/ip_ipsec.c b/sys/netinet/ip_ipsec.c index 20baa15dfcc7..da34d770b871 100644 --- a/sys/netinet/ip_ipsec.c +++ b/sys/netinet/ip_ipsec.c @@ -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; diff --git a/sys/netinet/ip_mroute.c b/sys/netinet/ip_mroute.c index 3c3c014238aa..b8957f42e421 100644 --- a/sys/netinet/ip_mroute.c +++ b/sys/netinet/ip_mroute.c @@ -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: diff --git a/sys/netinet/ip_options.c b/sys/netinet/ip_options.c index 09a1d6279202..5c4b441f546e 100644 --- a/sys/netinet/ip_options.c +++ b/sys/netinet/ip_options.c @@ -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; diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 8ed63a524682..220bf234b498 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -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 */ diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index c0b02eb1ea19..0db34d28d6b1 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -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 +VNET_DECLARE(int, ipstealth); /* stealth forwarding */ +#endif +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 -extern int ipstealth; /* stealth forwarding */ +#define V_ipstealth VNET_GET(ipstealth) #endif -extern int rsvp_on; -extern struct socket *ip_rsvpd; /* reservation protocol daemon */ -extern struct socket *ip_mrouter; /* multicast routing daemon */ -#endif /* VIMAGE_GLOBALS */ +#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_ */ diff --git a/sys/netinet/ipfw/ip_fw2.c b/sys/netinet/ipfw/ip_fw2.c index cce1a4d44a69..95efc2b9869c 100644 --- a/sys/netinet/ipfw/ip_fw2.c +++ b/sys/netinet/ipfw/ip_fw2.c @@ -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); + +#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 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 */ +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 @@ bad_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 @@ done: 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; diff --git a/sys/netinet/ipfw/ip_fw_nat.c b/sys/netinet/ipfw/ip_fw_nat.c index 6ef30bbdd314..9ba2f5f13962 100644 --- a/sys/netinet/ipfw/ip_fw_nat.c +++ b/sys/netinet/ipfw/ip_fw_nat.c @@ -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 @@ nospace: 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; diff --git a/sys/netinet/ipfw/ip_fw_pfil.c b/sys/netinet/ipfw/ip_fw_pfil.c index 5fd6a05e8fb3..a763855d5396 100644 --- a/sys/netinet/ipfw/ip_fw_pfil.c +++ b/sys/netinet/ipfw/ip_fw_pfil.c @@ -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; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 00ec4231988b..c3a0a74dcfb9 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -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; diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h index db139d8a8f45..46a73bf94cb9 100644 --- a/sys/netinet/sctp_os_bsd.h +++ b/sys/netinet/sctp_os_bsd.h @@ -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 */ diff --git a/sys/netinet/tcp_hostcache.c b/sys/netinet/tcp_hostcache.c index cdd8c3652183..e7bf0d1ec9cd 100644 --- a/sys/netinet/tcp_hostcache.c +++ b/sys/netinet/tcp_hostcache.c @@ -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; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index cad7bbef4c5a..42ed197fe693 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -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 - -SYSCTL_V_STRUCT(V_NET, vnet_inet, _net_inet_tcp, TCPCTL_STATS, stats, - CTLFLAG_RW, tcpstat , tcpstat, +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_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 @@ drop: 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; diff --git a/sys/netinet/tcp_offload.c b/sys/netinet/tcp_offload.c index 5afd8cdb0249..94cf5706bd88 100644 --- a/sys/netinet/tcp_offload.c +++ b/sys/netinet/tcp_offload.c @@ -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 @@ fail: 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); diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 35ba51cadf53..c74107e74a6a 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -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 - -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_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, - slowstart_flightsize, CTLFLAG_RW, - 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_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, newreno, CTLFLAG_RW, - 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_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_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, sendbuf_inc, - CTLFLAG_RW, tcp_autosndbuf_inc, 0, +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_VNET_INT(_net_inet_tcp, OID_AUTO, path_mtu_discovery, CTLFLAG_RW, + &VNET_NAME(path_mtu_discovery), 1, + "Enable Path MTU Discovery"); + +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, slowstart_flightsize, CTLFLAG_RW, + &VNET_NAME(ss_fltsz), 1, + "Slow start flight size"); + +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_VNET_INT(_net_inet_tcp, OID_AUTO, newreno, CTLFLAG_RW, + &VNET_NAME(tcp_do_newreno), 0, + "Enable NewReno Algorithms"); + +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, tso, CTLFLAG_RW, + &VNET_NAME(tcp_do_tso), 0, + "Enable TCP Segmentation Offload"); + +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, sendbuf_auto, CTLFLAG_RW, + &VNET_NAME(tcp_do_autosndbuf), 0, + "Enable automatic send buffer sizing"); + +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) { diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index 0849c25161c3..88ef3917be85 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -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; diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c index 2a2ae9cdf452..defc9ebb1ab3 100644 --- a/sys/netinet/tcp_sack.c +++ b/sys/netinet/tcp_sack.c @@ -119,32 +119,35 @@ __FBSDID("$FreeBSD$"); #ifdef TCPDEBUG #include <netinet/tcp_debug.h> #endif /* TCPDEBUG */ -#include <netinet/vinet.h> #include <machine/in_cksum.h> -#ifdef VIMAGE_GLOBALS -extern struct uma_zone *sack_hole_zone; -int tcp_do_sack; -int tcp_sack_maxholes; -int tcp_sack_globalmaxholes; -int tcp_sack_globalholes; -#endif +VNET_DECLARE(struct uma_zone *, sack_hole_zone); +VNET_DEFINE(int, tcp_do_sack); +VNET_DEFINE(int, tcp_sack_maxholes); +VNET_DEFINE(int, tcp_sack_globalmaxholes); +VNET_DEFINE(int, tcp_sack_globalholes); + +#define V_sack_hole_zone VNET_GET(sack_hole_zone) +#define V_tcp_do_sack VNET_GET(tcp_do_sack) +#define V_tcp_sack_maxholes VNET_GET(tcp_sack_maxholes) +#define V_tcp_sack_globalmaxholes VNET_GET(tcp_sack_globalmaxholes) +#define V_tcp_sack_globalholes VNET_GET(tcp_sack_globalholes) SYSCTL_NODE(_net_inet_tcp, OID_AUTO, sack, CTLFLAG_RW, 0, "TCP SACK"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_sack, OID_AUTO, enable, - CTLFLAG_RW, tcp_do_sack, 0, "Enable/Disable TCP SACK support"); +SYSCTL_VNET_INT(_net_inet_tcp_sack, OID_AUTO, enable, CTLFLAG_RW, + &VNET_NAME(tcp_do_sack), 0, "Enable/Disable TCP SACK support"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_sack, OID_AUTO, maxholes, - CTLFLAG_RW, tcp_sack_maxholes, 0, +SYSCTL_VNET_INT(_net_inet_tcp_sack, OID_AUTO, maxholes, CTLFLAG_RW, + &VNET_NAME(tcp_sack_maxholes), 0, "Maximum number of TCP SACK holes allowed per connection"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_sack, OID_AUTO, globalmaxholes, - CTLFLAG_RW, tcp_sack_globalmaxholes, 0, +SYSCTL_VNET_INT(_net_inet_tcp_sack, OID_AUTO, globalmaxholes, CTLFLAG_RW, + &VNET_NAME(tcp_sack_globalmaxholes), 0, "Global maximum number of TCP SACK holes"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_sack, OID_AUTO, globalholes, - CTLFLAG_RD, tcp_sack_globalholes, 0, +SYSCTL_VNET_INT(_net_inet_tcp_sack, OID_AUTO, globalholes, CTLFLAG_RD, + &VNET_NAME(tcp_sack_globalholes), 0, "Global number of TCP SACK holes currently allocated"); /* @@ -255,7 +258,6 @@ tcp_clean_sackreport(struct tcpcb *tp) static struct sackhole * tcp_sackhole_alloc(struct tcpcb *tp, tcp_seq start, tcp_seq end) { - INIT_VNET_INET(tp->t_inpcb->inp_vnet); struct sackhole *hole; if (tp->snd_numholes >= V_tcp_sack_maxholes || @@ -284,7 +286,6 @@ tcp_sackhole_alloc(struct tcpcb *tp, tcp_seq start, tcp_seq end) static void tcp_sackhole_free(struct tcpcb *tp, struct sackhole *hole) { - INIT_VNET_INET(tp->t_vnet); uma_zfree(V_sack_hole_zone, hole); diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 2b2231309140..7839cfa9503d 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -94,9 +94,7 @@ __FBSDID("$FreeBSD$"); #ifdef TCPDEBUG #include <netinet/tcp_debug.h> #endif -#include <netinet/vinet.h> #include <netinet6/ip6protosw.h> -#include <netinet6/vinet6.h> #ifdef IPSEC #include <netipsec/ipsec.h> @@ -113,26 +111,32 @@ __FBSDID("$FreeBSD$"); #include <security/mac/mac_framework.h> -#ifdef VIMAGE_GLOBALS -int tcp_mssdflt; +VNET_DEFINE(int, tcp_mssdflt); #ifdef INET6 -int tcp_v6mssdflt; -#endif -int tcp_minmss; -int tcp_do_rfc1323; -static int icmp_may_rst; -static int tcp_isn_reseed_interval; -static int tcp_inflight_enable; -static int tcp_inflight_rttthresh; -static int tcp_inflight_min; -static int tcp_inflight_max; -static int tcp_inflight_stab; +VNET_DEFINE(int, tcp_v6mssdflt); #endif +VNET_DEFINE(int, tcp_minmss); +VNET_DEFINE(int, tcp_do_rfc1323); + +static VNET_DEFINE(int, icmp_may_rst); +static VNET_DEFINE(int, tcp_isn_reseed_interval); +static VNET_DEFINE(int, tcp_inflight_enable); +static VNET_DEFINE(int, tcp_inflight_rttthresh); +static VNET_DEFINE(int, tcp_inflight_min); +static VNET_DEFINE(int, tcp_inflight_max); +static VNET_DEFINE(int, tcp_inflight_stab); + +#define V_icmp_may_rst VNET_GET(icmp_may_rst) +#define V_tcp_isn_reseed_interval VNET_GET(tcp_isn_reseed_interval) +#define V_tcp_inflight_enable VNET_GET(tcp_inflight_enable) +#define V_tcp_inflight_rttthresh VNET_GET(tcp_inflight_rttthresh) +#define V_tcp_inflight_min VNET_GET(tcp_inflight_min) +#define V_tcp_inflight_max VNET_GET(tcp_inflight_max) +#define V_tcp_inflight_stab VNET_GET(tcp_inflight_stab) static int sysctl_net_inet_tcp_mss_check(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(TD_TO_VNET(req->td)); int error, new; new = V_tcp_mssdflt; @@ -146,8 +150,8 @@ sysctl_net_inet_tcp_mss_check(SYSCTL_HANDLER_ARGS) return (error); } -SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_tcp, TCPCTL_MSSDFLT, mssdflt, - CTLTYPE_INT|CTLFLAG_RW, tcp_mssdflt, 0, +SYSCTL_VNET_PROC(_net_inet_tcp, TCPCTL_MSSDFLT, mssdflt, + CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(tcp_mssdflt), 0, &sysctl_net_inet_tcp_mss_check, "I", "Default TCP Maximum Segment Size"); @@ -155,7 +159,6 @@ SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_tcp, TCPCTL_MSSDFLT, mssdflt, static int sysctl_net_inet_tcp_mss_v6_check(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(TD_TO_VNET(req->td)); int error, new; new = V_tcp_v6mssdflt; @@ -169,8 +172,8 @@ sysctl_net_inet_tcp_mss_v6_check(SYSCTL_HANDLER_ARGS) return (error); } -SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_tcp, TCPCTL_V6MSSDFLT, v6mssdflt, - CTLTYPE_INT|CTLFLAG_RW, tcp_v6mssdflt, 0, +SYSCTL_VNET_PROC(_net_inet_tcp, TCPCTL_V6MSSDFLT, v6mssdflt, + CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(tcp_v6mssdflt), 0, &sysctl_net_inet_tcp_mss_v6_check, "I", "Default TCP Maximum Segment Size for IPv6"); #endif @@ -183,11 +186,12 @@ SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_tcp, TCPCTL_V6MSSDFLT, v6mssdflt, * with packet generation and sending. Set to zero to disable MINMSS * checking. This setting prevents us from sending too small packets. */ -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, minmss, - CTLFLAG_RW, tcp_minmss , 0, "Minmum TCP Maximum Segment Size"); +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, minmss, CTLFLAG_RW, + &VNET_NAME(tcp_minmss), 0, + "Minmum TCP Maximum Segment Size"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, TCPCTL_DO_RFC1323, rfc1323, - CTLFLAG_RW, tcp_do_rfc1323, 0, +SYSCTL_VNET_INT(_net_inet_tcp, TCPCTL_DO_RFC1323, rfc1323, CTLFLAG_RW, + &VNET_NAME(tcp_do_rfc1323), 0, "Enable rfc1323 (high performance TCP) extensions"); static int tcp_log_debug = 0; @@ -202,15 +206,15 @@ static int do_tcpdrain = 1; SYSCTL_INT(_net_inet_tcp, OID_AUTO, do_tcpdrain, CTLFLAG_RW, &do_tcpdrain, 0, "Enable tcp_drain routine for extra help when low on mbufs"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, pcbcount, - CTLFLAG_RD, tcbinfo.ipi_count, 0, "Number of active PCBs"); +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, pcbcount, CTLFLAG_RD, + &VNET_NAME(tcbinfo.ipi_count), 0, "Number of active PCBs"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, icmp_may_rst, - CTLFLAG_RW, icmp_may_rst, 0, +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, icmp_may_rst, CTLFLAG_RW, + &VNET_NAME(icmp_may_rst), 0, "Certain ICMP unreachable messages may abort connections in SYN_SENT"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, isn_reseed_interval, - CTLFLAG_RW, tcp_isn_reseed_interval, 0, +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, isn_reseed_interval, CTLFLAG_RW, + &VNET_NAME(tcp_isn_reseed_interval), 0, "Seconds between reseeding of ISN secret"); /* @@ -221,31 +225,34 @@ SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, isn_reseed_interval, SYSCTL_NODE(_net_inet_tcp, OID_AUTO, inflight, CTLFLAG_RW, 0, "TCP inflight data limiting"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_inflight, OID_AUTO, enable, - CTLFLAG_RW, tcp_inflight_enable, 0, +SYSCTL_VNET_INT(_net_inet_tcp_inflight, OID_AUTO, enable, CTLFLAG_RW, + &VNET_NAME(tcp_inflight_enable), 0, "Enable automatic TCP inflight data limiting"); static int tcp_inflight_debug = 0; SYSCTL_INT(_net_inet_tcp_inflight, OID_AUTO, debug, CTLFLAG_RW, - &tcp_inflight_debug, 0, "Debug TCP inflight calculations"); + &tcp_inflight_debug, 0, + "Debug TCP inflight calculations"); -SYSCTL_V_PROC(V_NET, vnet_inet, _net_inet_tcp_inflight, OID_AUTO, rttthresh, - CTLTYPE_INT|CTLFLAG_RW, tcp_inflight_rttthresh, 0, sysctl_msec_to_ticks, - "I", "RTT threshold below which inflight will deactivate itself"); +SYSCTL_VNET_PROC(_net_inet_tcp_inflight, OID_AUTO, rttthresh, + CTLTYPE_INT|CTLFLAG_RW, &VNET_NAME(tcp_inflight_rttthresh), 0, + sysctl_msec_to_ticks, "I", + "RTT threshold below which inflight will deactivate itself"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_inflight, OID_AUTO, min, - CTLFLAG_RW, tcp_inflight_min, 0, "Lower-bound for TCP inflight window"); +SYSCTL_VNET_INT(_net_inet_tcp_inflight, OID_AUTO, min, CTLFLAG_RW, + &VNET_NAME(tcp_inflight_min), 0, + "Lower-bound for TCP inflight window"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_inflight, OID_AUTO, max, - CTLFLAG_RW, tcp_inflight_max, 0, "Upper-bound for TCP inflight window"); +SYSCTL_VNET_INT(_net_inet_tcp_inflight, OID_AUTO, max, CTLFLAG_RW, + &VNET_NAME(tcp_inflight_max), 0, + "Upper-bound for TCP inflight window"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_inflight, OID_AUTO, stab, - CTLFLAG_RW, tcp_inflight_stab, 0, +SYSCTL_VNET_INT(_net_inet_tcp_inflight, OID_AUTO, stab, CTLFLAG_RW, + &VNET_NAME(tcp_inflight_stab), 0, "Inflight Algorithm Stabilization 20 = 2 packets"); -#ifdef VIMAGE_GLOBALS -uma_zone_t sack_hole_zone; -#endif +VNET_DEFINE(uma_zone_t, sack_hole_zone); +#define V_sack_hole_zone VNET_GET(sack_hole_zone) static struct inpcb *tcp_notify(struct inpcb *, int); static void tcp_isn_tick(void *); @@ -271,9 +278,9 @@ struct tcpcb_mem { struct tcp_timer tt; }; -#ifdef VIMAGE_GLOBALS -static uma_zone_t tcpcb_zone; -#endif +static VNET_DEFINE(uma_zone_t, tcpcb_zone); +#define V_tcpcb_zone VNET_GET(tcpcb_zone) + MALLOC_DEFINE(M_TCPLOG, "tcplog", "TCP address and flags print buffers"); struct callout isn_callout; static struct mtx isn_mtx; @@ -288,7 +295,6 @@ static struct mtx isn_mtx; static void tcp_zone_change(void *tag) { - INIT_VNET_INET(curvnet); uma_zone_set_max(V_tcbinfo.ipi_zone, maxsockets); uma_zone_set_max(V_tcpcb_zone, maxsockets); @@ -307,7 +313,6 @@ tcp_inpcb_init(void *mem, int size, int flags) void tcp_init(void) { - INIT_VNET_INET(curvnet); int hashsize; V_blackhole = 0; @@ -431,7 +436,6 @@ tcp_init(void) void tcp_destroy(void) { - INIT_VNET_INET(curvnet); tcp_tw_destroy(); tcp_hc_destroy(); @@ -543,7 +547,6 @@ void tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m, tcp_seq ack, tcp_seq seq, int flags) { - INIT_VNET_INET(curvnet); int tlen; int win = 0; struct ip *ip; @@ -714,7 +717,6 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m, struct tcpcb * tcp_newtcpcb(struct inpcb *inp) { - INIT_VNET_INET(inp->inp_vnet); struct tcpcb_mem *tm; struct tcpcb *tp; #ifdef INET6 @@ -781,7 +783,6 @@ tcp_newtcpcb(struct inpcb *inp) struct tcpcb * tcp_drop(struct tcpcb *tp, int errno) { - INIT_VNET_INET(tp->t_inpcb->inp_vnet); struct socket *so = tp->t_inpcb->inp_socket; INP_INFO_WLOCK_ASSERT(&V_tcbinfo); @@ -802,7 +803,6 @@ tcp_drop(struct tcpcb *tp, int errno) void tcp_discardcb(struct tcpcb *tp) { - INIT_VNET_INET(tp->t_vnet); struct tseg_qent *q; struct inpcb *inp = tp->t_inpcb; struct socket *so = inp->inp_socket; @@ -904,7 +904,6 @@ tcp_discardcb(struct tcpcb *tp) struct tcpcb * tcp_close(struct tcpcb *tp) { - INIT_VNET_INET(tp->t_inpcb->inp_vnet); struct inpcb *inp = tp->t_inpcb; struct socket *so; @@ -944,7 +943,6 @@ tcp_drain(void) VNET_LIST_RLOCK(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); - INIT_VNET_INET(vnet_iter); struct inpcb *inpb; struct tcpcb *tcpb; struct tseg_qent *te; @@ -993,9 +991,6 @@ static struct inpcb * tcp_notify(struct inpcb *inp, int error) { struct tcpcb *tp; -#ifdef INVARIANTS - INIT_VNET_INET(inp->inp_vnet); /* V_tcbinfo WLOCK ASSERT */ -#endif INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); @@ -1039,7 +1034,6 @@ tcp_notify(struct inpcb *inp, int error) static int tcp_pcblist(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(curvnet); int error, i, m, n, pcb_count; struct inpcb *inp, **inp_list; inp_gen_t gencnt; @@ -1175,7 +1169,6 @@ SYSCTL_PROC(_net_inet_tcp, TCPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0, static int tcp_getcred(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(curvnet); struct xucred xuc; struct sockaddr_in addrs[2]; struct inpcb *inp; @@ -1217,8 +1210,6 @@ SYSCTL_PROC(_net_inet_tcp, OID_AUTO, getcred, static int tcp6_getcred(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(curvnet); - INIT_VNET_INET6(curvnet); struct xucred xuc; struct sockaddr_in6 addrs[2]; struct inpcb *inp; @@ -1281,7 +1272,6 @@ SYSCTL_PROC(_net_inet6_tcp6, OID_AUTO, getcred, void tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip) { - INIT_VNET_INET(curvnet); struct ip *ip = vip; struct tcphdr *th; struct in_addr faddr; @@ -1398,7 +1388,6 @@ tcp_ctlinput(int cmd, struct sockaddr *sa, void *vip) void tcp6_ctlinput(int cmd, struct sockaddr *sa, void *d) { - INIT_VNET_INET(curvnet); struct tcphdr th; struct inpcb *(*notify)(struct inpcb *, int) = tcp_notify; struct ip6_hdr *ip6; @@ -1520,16 +1509,19 @@ tcp6_ctlinput(int cmd, struct sockaddr *sa, void *d) #define ISN_STATIC_INCREMENT 4096 #define ISN_RANDOM_INCREMENT (4096 - 1) -#ifdef VIMAGE_GLOBALS -static u_char isn_secret[32]; -static int isn_last_reseed; -static u_int32_t isn_offset, isn_offset_old; -#endif +static VNET_DEFINE(u_char, isn_secret[32]); +static VNET_DEFINE(int, isn_last_reseed); +static VNET_DEFINE(u_int32_t, isn_offset); +static VNET_DEFINE(u_int32_t, isn_offset_old); + +#define V_isn_secret VNET_GET(isn_secret) +#define V_isn_last_reseed VNET_GET(isn_last_reseed) +#define V_isn_offset VNET_GET(isn_offset) +#define V_isn_offset_old VNET_GET(isn_offset_old) tcp_seq tcp_new_isn(struct tcpcb *tp) { - INIT_VNET_INET(tp->t_vnet); MD5_CTX isn_ctx; u_int32_t md5_buffer[4]; tcp_seq new_isn; @@ -1588,7 +1580,6 @@ tcp_isn_tick(void *xtp) ISN_LOCK(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); /* XXX appease INVARIANTS */ - INIT_VNET_INET(curvnet); projected_offset = V_isn_offset_old + ISN_BYTES_PER_SECOND / 100; @@ -1611,9 +1602,6 @@ tcp_isn_tick(void *xtp) struct inpcb * tcp_drop_syn_sent(struct inpcb *inp, int errno) { -#ifdef INVARIANTS - INIT_VNET_INET(inp->inp_vnet); -#endif struct tcpcb *tp; INP_INFO_WLOCK_ASSERT(&V_tcbinfo); @@ -1643,7 +1631,6 @@ tcp_drop_syn_sent(struct inpcb *inp, int errno) struct inpcb * tcp_mtudisc(struct inpcb *inp, int errno) { - INIT_VNET_INET(inp->inp_vnet); struct tcpcb *tp; struct socket *so; @@ -1850,7 +1837,6 @@ ipsec_hdrsiz_tcp(struct tcpcb *tp) void tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq) { - INIT_VNET_INET(tp->t_vnet); u_long bw; u_long bwnd; int save_ticks; @@ -1987,7 +1973,6 @@ int tcp_signature_compute(struct mbuf *m, int _unused, int len, int optlen, u_char *buf, u_int direction) { - INIT_VNET_IPSEC(curvnet); union sockaddr_union dst; struct ippseudo ippseudo; MD5_CTX ctx; @@ -2140,10 +2125,6 @@ tcp_signature_compute(struct mbuf *m, int _unused, int len, int optlen, static int sysctl_drop(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(curvnet); -#ifdef INET6 - INIT_VNET_INET6(curvnet); -#endif /* addrs[0] is a foreign socket, addrs[1] is a local one. */ struct sockaddr_storage addrs[2]; struct inpcb *inp; diff --git a/sys/netinet/tcp_syncache.c b/sys/netinet/tcp_syncache.c index 440115df3651..9a7ce79b6096 100644 --- a/sys/netinet/tcp_syncache.c +++ b/sys/netinet/tcp_syncache.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include <net/if.h> #include <net/route.h> +#include <net/vnet.h> #include <netinet/in.h> #include <netinet/in_systm.h> @@ -84,7 +85,6 @@ __FBSDID("$FreeBSD$"); #ifdef INET6 #include <netinet6/tcp6_var.h> #endif -#include <netinet/vinet.h> #ifdef IPSEC #include <netipsec/ipsec.h> @@ -98,19 +98,21 @@ __FBSDID("$FreeBSD$"); #include <security/mac/mac_framework.h> -#ifdef VIMAGE_GLOBALS -static struct tcp_syncache tcp_syncache; -static int tcp_syncookies; -static int tcp_syncookiesonly; -int tcp_sc_rst_sock_fail; -#endif +static VNET_DEFINE(struct tcp_syncache, tcp_syncache); +static VNET_DEFINE(int, tcp_syncookies); +static VNET_DEFINE(int, tcp_syncookiesonly); +VNET_DEFINE(int, tcp_sc_rst_sock_fail); + +#define V_tcp_syncache VNET_GET(tcp_syncache) +#define V_tcp_syncookies VNET_GET(tcp_syncookies) +#define V_tcp_syncookiesonly VNET_GET(tcp_syncookiesonly) -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, syncookies, - CTLFLAG_RW, tcp_syncookies, 0, +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, syncookies, CTLFLAG_RW, + &VNET_NAME(tcp_syncookies), 0, "Use TCP SYN cookies if the syncache overflows"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, syncookies_only, - CTLFLAG_RW, tcp_syncookiesonly, 0, +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, syncookies_only, CTLFLAG_RW, + &VNET_NAME(tcp_syncookiesonly), 0, "Use only TCP SYN cookies"); #ifdef TCP_OFFLOAD_DISABLE @@ -149,29 +151,29 @@ static struct syncache SYSCTL_NODE(_net_inet_tcp, OID_AUTO, syncache, CTLFLAG_RW, 0, "TCP SYN cache"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_syncache, OID_AUTO, - bucketlimit, CTLFLAG_RDTUN, - tcp_syncache.bucket_limit, 0, "Per-bucket hash limit for syncache"); +SYSCTL_VNET_INT(_net_inet_tcp_syncache, OID_AUTO, bucketlimit, CTLFLAG_RDTUN, + &VNET_NAME(tcp_syncache.bucket_limit), 0, + "Per-bucket hash limit for syncache"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_syncache, OID_AUTO, - cachelimit, CTLFLAG_RDTUN, - tcp_syncache.cache_limit, 0, "Overall entry limit for syncache"); +SYSCTL_VNET_INT(_net_inet_tcp_syncache, OID_AUTO, cachelimit, CTLFLAG_RDTUN, + &VNET_NAME(tcp_syncache.cache_limit), 0, + "Overall entry limit for syncache"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_syncache, OID_AUTO, - count, CTLFLAG_RD, - tcp_syncache.cache_count, 0, "Current number of entries in syncache"); +SYSCTL_VNET_INT(_net_inet_tcp_syncache, OID_AUTO, count, CTLFLAG_RD, + &VNET_NAME(tcp_syncache.cache_count), 0, + "Current number of entries in syncache"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_syncache, OID_AUTO, - hashsize, CTLFLAG_RDTUN, - tcp_syncache.hashsize, 0, "Size of TCP syncache hashtable"); +SYSCTL_VNET_INT(_net_inet_tcp_syncache, OID_AUTO, hashsize, CTLFLAG_RDTUN, + &VNET_NAME(tcp_syncache.hashsize), 0, + "Size of TCP syncache hashtable"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_syncache, OID_AUTO, - rexmtlimit, CTLFLAG_RW, - tcp_syncache.rexmt_limit, 0, "Limit on SYN/ACK retransmissions"); +SYSCTL_VNET_INT(_net_inet_tcp_syncache, OID_AUTO, rexmtlimit, CTLFLAG_RW, + &VNET_NAME(tcp_syncache.rexmt_limit), 0, + "Limit on SYN/ACK retransmissions"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_syncache, OID_AUTO, - rst_on_sock_fail, CTLFLAG_RW, - tcp_sc_rst_sock_fail, 0, "Send reset on socket allocation failure"); +SYSCTL_VNET_INT(_net_inet_tcp_syncache, OID_AUTO, rst_on_sock_fail, + CTLFLAG_RW, &VNET_NAME(tcp_sc_rst_sock_fail), 0, + "Send reset on socket allocation failure"); static MALLOC_DEFINE(M_SYNCACHE, "syncache", "TCP syncache"); @@ -206,7 +208,6 @@ static MALLOC_DEFINE(M_SYNCACHE, "syncache", "TCP syncache"); static void syncache_free(struct syncache *sc) { - INIT_VNET_INET(curvnet); if (sc->sc_ipopts) (void) m_free(sc->sc_ipopts); @@ -222,7 +223,6 @@ syncache_free(struct syncache *sc) void syncache_init(void) { - INIT_VNET_INET(curvnet); int i; V_tcp_syncookies = 1; @@ -279,7 +279,6 @@ syncache_init(void) void syncache_destroy(void) { - INIT_VNET_INET(curvnet); /* XXX walk the cache, free remaining objects, stop timers */ @@ -295,7 +294,6 @@ syncache_destroy(void) static void syncache_insert(struct syncache *sc, struct syncache_head *sch) { - INIT_VNET_INET(sch->sch_vnet); struct syncache *sc2; SCH_LOCK(sch); @@ -334,7 +332,6 @@ syncache_insert(struct syncache *sc, struct syncache_head *sch) static void syncache_drop(struct syncache *sc, struct syncache_head *sch) { - INIT_VNET_INET(sch->sch_vnet); SCH_LOCK_ASSERT(sch); @@ -380,7 +377,6 @@ syncache_timer(void *xsch) char *s; CURVNET_SET(sch->sch_vnet); - INIT_VNET_INET(sch->sch_vnet); /* NB: syncache_head has already been locked by the callout. */ SCH_LOCK_ASSERT(sch); @@ -440,7 +436,6 @@ syncache_timer(void *xsch) struct syncache * syncache_lookup(struct in_conninfo *inc, struct syncache_head **schp) { - INIT_VNET_INET(curvnet); struct syncache *sc; struct syncache_head *sch; @@ -488,7 +483,6 @@ syncache_lookup(struct in_conninfo *inc, struct syncache_head **schp) void syncache_chkrst(struct in_conninfo *inc, struct tcphdr *th) { - INIT_VNET_INET(curvnet); struct syncache *sc; struct syncache_head *sch; char *s = NULL; @@ -563,7 +557,6 @@ done: void syncache_badack(struct in_conninfo *inc) { - INIT_VNET_INET(curvnet); struct syncache *sc; struct syncache_head *sch; @@ -579,7 +572,6 @@ syncache_badack(struct in_conninfo *inc) void syncache_unreach(struct in_conninfo *inc, struct tcphdr *th) { - INIT_VNET_INET(curvnet); struct syncache *sc; struct syncache_head *sch; @@ -616,7 +608,6 @@ done: static struct socket * syncache_socket(struct syncache *sc, struct socket *lso, struct mbuf *m) { - INIT_VNET_INET(lso->so_vnet); struct inpcb *inp = NULL; struct socket *so; struct tcpcb *tp; @@ -827,7 +818,6 @@ int syncache_expand(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, struct socket **lsop, struct mbuf *m) { - INIT_VNET_INET(curvnet); struct syncache *sc; struct syncache_head *sch; struct syncache scs; @@ -946,7 +936,6 @@ int tcp_offload_syncache_expand(struct in_conninfo *inc, struct toeopt *toeo, struct tcphdr *th, struct socket **lsop, struct mbuf *m) { - INIT_VNET_INET(curvnet); struct tcpopt to; int rc; @@ -980,7 +969,6 @@ _syncache_add(struct in_conninfo *inc, struct tcpopt *to, struct tcphdr *th, struct inpcb *inp, struct socket **lsop, struct mbuf *m, struct toe_usrreqs *tu, void *toepcb) { - INIT_VNET_INET(inp->inp_vnet); struct tcpcb *tp; struct socket *so; struct syncache *sc = NULL; @@ -1277,7 +1265,6 @@ done: static int syncache_respond(struct syncache *sc) { - INIT_VNET_INET(curvnet); struct ip *ip = NULL; struct mbuf *m; struct tcphdr *th; @@ -1447,7 +1434,6 @@ tcp_offload_syncache_add(struct in_conninfo *inc, struct toeopt *toeo, struct tcphdr *th, struct inpcb *inp, struct socket **lsop, struct toe_usrreqs *tu, void *toepcb) { - INIT_VNET_INET(curvnet); struct tcpopt to; bzero(&to, sizeof(struct tcpopt)); @@ -1543,7 +1529,6 @@ static void syncookie_generate(struct syncache_head *sch, struct syncache *sc, u_int32_t *flowlabel) { - INIT_VNET_INET(curvnet); MD5_CTX ctx; u_int32_t md5_buffer[MD5_DIGEST_LENGTH / sizeof(u_int32_t)]; u_int32_t data; @@ -1618,7 +1603,6 @@ syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, struct syncache *sc, struct tcpopt *to, struct tcphdr *th, struct socket *so) { - INIT_VNET_INET(curvnet); MD5_CTX ctx; u_int32_t md5_buffer[MD5_DIGEST_LENGTH / sizeof(u_int32_t)]; u_int32_t data = 0; @@ -1726,7 +1710,6 @@ syncookie_lookup(struct in_conninfo *inc, struct syncache_head *sch, int syncache_pcbcount(void) { - INIT_VNET_INET(curvnet); struct syncache_head *sch; int count, i; @@ -1750,7 +1733,6 @@ syncache_pcbcount(void) int syncache_pcblist(struct sysctl_req *req, int max_pcbs, int *pcbs_exported) { - INIT_VNET_INET(curvnet); struct xtcpcb xt; struct syncache *sc; struct syncache_head *sch; diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index ec4d68837294..7006b70d6740 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -65,7 +65,6 @@ __FBSDID("$FreeBSD$"); #ifdef TCPDEBUG #include <netinet/tcp_debug.h> #endif -#include <netinet/vinet.h> int tcp_keepinit; SYSCTL_PROC(_net_inet_tcp, TCPCTL_KEEPINIT, keepinit, CTLTYPE_INT|CTLFLAG_RW, @@ -131,7 +130,6 @@ tcp_slowtimo(void) VNET_LIST_RLOCK(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); - INIT_VNET_INET(vnet_iter); tcp_maxidle = tcp_keepcnt * tcp_keepintvl; INP_INFO_WLOCK(&V_tcbinfo); (void) tcp_tw_2msl_scan(0); @@ -163,7 +161,6 @@ tcp_timer_delack(void *xtp) struct tcpcb *tp = xtp; struct inpcb *inp; CURVNET_SET(tp->t_vnet); - INIT_VNET_INET(tp->t_vnet); INP_INFO_RLOCK(&V_tcbinfo); inp = tp->t_inpcb; @@ -203,7 +200,6 @@ tcp_timer_2msl(void *xtp) struct tcpcb *tp = xtp; struct inpcb *inp; CURVNET_SET(tp->t_vnet); - INIT_VNET_INET(tp->t_vnet); #ifdef TCPDEBUG int ostate; @@ -279,7 +275,6 @@ tcp_timer_keep(void *xtp) struct tcptemp *t_template; struct inpcb *inp; CURVNET_SET(tp->t_vnet); - INIT_VNET_INET(tp->t_vnet); #ifdef TCPDEBUG int ostate; @@ -375,7 +370,6 @@ tcp_timer_persist(void *xtp) struct tcpcb *tp = xtp; struct inpcb *inp; CURVNET_SET(tp->t_vnet); - INIT_VNET_INET(tp->t_vnet); #ifdef TCPDEBUG int ostate; @@ -445,7 +439,6 @@ tcp_timer_rexmt(void * xtp) { struct tcpcb *tp = xtp; CURVNET_SET(tp->t_vnet); - INIT_VNET_INET(tp->t_vnet); int rexmt; int headlocked; struct inpcb *inp; diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index 32108c74af3e..1ac14ec69843 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -87,7 +87,6 @@ __FBSDID("$FreeBSD$"); #include <netinet/tcp_debug.h> #endif #include <netinet6/ip6protosw.h> -#include <netinet/vinet.h> #include <machine/in_cksum.h> @@ -101,11 +100,12 @@ static int maxtcptw; * queue pointers in each tcptw structure, are protected using the global * tcbinfo lock, which must be held over queue iteration and modification. */ -#ifdef VIMAGE_GLOBALS -static uma_zone_t tcptw_zone; -static TAILQ_HEAD(, tcptw) twq_2msl; -int nolocaltimewait; -#endif +static VNET_DEFINE(uma_zone_t, tcptw_zone); +static VNET_DEFINE(TAILQ_HEAD(, tcptw), twq_2msl); +VNET_DEFINE(int, nolocaltimewait); + +#define V_tcptw_zone VNET_GET(tcptw_zone) +#define V_twq_2msl VNET_GET(twq_2msl) static void tcp_tw_2msl_reset(struct tcptw *, int); static void tcp_tw_2msl_stop(struct tcptw *); @@ -113,7 +113,6 @@ static void tcp_tw_2msl_stop(struct tcptw *); static int tcptw_auto_size(void) { - INIT_VNET_INET(curvnet); int halfrange; /* @@ -131,7 +130,6 @@ tcptw_auto_size(void) static int sysctl_maxtcptw(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(curvnet); int error, new; if (maxtcptw == 0) @@ -151,14 +149,13 @@ SYSCTL_PROC(_net_inet_tcp, OID_AUTO, maxtcptw, CTLTYPE_INT|CTLFLAG_RW, &maxtcptw, 0, sysctl_maxtcptw, "IU", "Maximum number of compressed TCP TIME_WAIT entries"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp, OID_AUTO, nolocaltimewait, - CTLFLAG_RW, nolocaltimewait, 0, +SYSCTL_VNET_INT(_net_inet_tcp, OID_AUTO, nolocaltimewait, CTLFLAG_RW, + &VNET_NAME(nolocaltimewait), 0, "Do not create compressed TCP TIME_WAIT entries for local connections"); void tcp_tw_zone_change(void) { - INIT_VNET_INET(curvnet); if (maxtcptw == 0) uma_zone_set_max(V_tcptw_zone, tcptw_auto_size()); @@ -167,7 +164,6 @@ tcp_tw_zone_change(void) void tcp_tw_init(void) { - INIT_VNET_INET(curvnet); V_tcptw_zone = uma_zcreate("tcptw", sizeof(struct tcptw), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); @@ -183,7 +179,6 @@ tcp_tw_init(void) void tcp_tw_destroy(void) { - INIT_VNET_INET(curvnet); struct tcptw *tw; INP_INFO_WLOCK(&V_tcbinfo); @@ -201,7 +196,6 @@ tcp_tw_destroy(void) void tcp_twstart(struct tcpcb *tp) { - INIT_VNET_INET(tp->t_vnet); struct tcptw *tw; struct inpcb *inp = tp->t_inpcb; int acknow; @@ -317,7 +311,6 @@ tcp_twstart(struct tcpcb *tp) int tcp_twrecycleable(struct tcptw *tw) { - INIT_VNET_INET(curvnet); tcp_seq new_iss = tw->iss; tcp_seq new_irs = tw->irs; @@ -340,9 +333,6 @@ int tcp_twcheck(struct inpcb *inp, struct tcpopt *to, struct tcphdr *th, struct mbuf *m, int tlen) { -#if defined(INVARIANTS) || defined(INVARIANT_SUPPORT) - INIT_VNET_INET(curvnet); -#endif struct tcptw *tw; int thflags; tcp_seq seq; @@ -434,7 +424,6 @@ drop: void tcp_twclose(struct tcptw *tw, int reuse) { - INIT_VNET_INET(curvnet); struct socket *so; struct inpcb *inp; @@ -496,7 +485,6 @@ tcp_twclose(struct tcptw *tw, int reuse) int tcp_twrespond(struct tcptw *tw, int flags) { - INIT_VNET_INET(curvnet); struct inpcb *inp = tw->tw_inpcb; struct tcphdr *th; struct mbuf *m; @@ -590,7 +578,6 @@ tcp_twrespond(struct tcptw *tw, int flags) static void tcp_tw_2msl_reset(struct tcptw *tw, int rearm) { - INIT_VNET_INET(curvnet); INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(tw->tw_inpcb); @@ -603,7 +590,6 @@ tcp_tw_2msl_reset(struct tcptw *tw, int rearm) static void tcp_tw_2msl_stop(struct tcptw *tw) { - INIT_VNET_INET(curvnet); INP_INFO_WLOCK_ASSERT(&V_tcbinfo); TAILQ_REMOVE(&V_twq_2msl, tw, tw_2msl); @@ -612,7 +598,6 @@ tcp_tw_2msl_stop(struct tcptw *tw) struct tcptw * tcp_tw_2msl_scan(int reuse) { - INIT_VNET_INET(curvnet); struct tcptw *tw; INP_INFO_WLOCK_ASSERT(&V_tcbinfo); diff --git a/sys/netinet/tcp_usrreq.c b/sys/netinet/tcp_usrreq.c index 5fc283734633..dfd05dcff486 100644 --- a/sys/netinet/tcp_usrreq.c +++ b/sys/netinet/tcp_usrreq.c @@ -87,7 +87,6 @@ __FBSDID("$FreeBSD$"); #include <netinet/tcp_debug.h> #endif #include <netinet/tcp_offload.h> -#include <netinet/vinet.h> /* * TCP protocol interface to socket abstraction. @@ -157,9 +156,6 @@ static void tcp_detach(struct socket *so, struct inpcb *inp) { struct tcpcb *tp; -#ifdef INVARIANTS - INIT_VNET_INET(so->so_vnet); -#endif INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); @@ -221,7 +217,6 @@ tcp_detach(struct socket *so, struct inpcb *inp) static void tcp_usr_detach(struct socket *so) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; inp = sotoinpcb(so); @@ -240,7 +235,6 @@ tcp_usr_detach(struct socket *so) static int tcp_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { - INIT_VNET_INET(so->so_vnet); int error = 0; struct inpcb *inp; struct tcpcb *tp = NULL; @@ -281,7 +275,6 @@ out: static int tcp6_usr_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { - INIT_VNET_INET(so->so_vnet); int error = 0; struct inpcb *inp; struct tcpcb *tp = NULL; @@ -340,7 +333,6 @@ out: static int tcp_usr_listen(struct socket *so, int backlog, struct thread *td) { - INIT_VNET_INET(so->so_vnet); int error = 0; struct inpcb *inp; struct tcpcb *tp = NULL; @@ -378,7 +370,6 @@ out: static int tcp6_usr_listen(struct socket *so, int backlog, struct thread *td) { - INIT_VNET_INET(so->so_vnet); int error = 0; struct inpcb *inp; struct tcpcb *tp = NULL; @@ -426,7 +417,6 @@ out: static int tcp_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { - INIT_VNET_INET(so->so_vnet); int error = 0; struct inpcb *inp; struct tcpcb *tp = NULL; @@ -469,7 +459,6 @@ out: static int tcp6_usr_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { - INIT_VNET_INET(so->so_vnet); int error = 0; struct inpcb *inp; struct tcpcb *tp = NULL; @@ -547,7 +536,6 @@ out: static int tcp_usr_disconnect(struct socket *so) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; struct tcpcb *tp = NULL; int error = 0; @@ -579,7 +567,6 @@ out: static int tcp_usr_accept(struct socket *so, struct sockaddr **nam) { - INIT_VNET_INET(so->so_vnet); int error = 0; struct inpcb *inp = NULL; struct tcpcb *tp = NULL; @@ -677,7 +664,6 @@ out: static int tcp_usr_shutdown(struct socket *so) { - INIT_VNET_INET(so->so_vnet); int error = 0; struct inpcb *inp; struct tcpcb *tp = NULL; @@ -745,7 +731,6 @@ static int tcp_usr_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, struct mbuf *control, struct thread *td) { - INIT_VNET_INET(so->so_vnet); int error = 0; struct inpcb *inp; struct tcpcb *tp = NULL; @@ -901,7 +886,6 @@ out: static void tcp_usr_abort(struct socket *so) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; struct tcpcb *tp = NULL; TCPDEBUG0; @@ -940,7 +924,6 @@ tcp_usr_abort(struct socket *so) static void tcp_usr_close(struct socket *so) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; struct tcpcb *tp = NULL; TCPDEBUG0; @@ -1079,7 +1062,6 @@ tcp_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) { struct inpcb *inp = tp->t_inpcb, *oinp; struct socket *so = inp->inp_socket; - INIT_VNET_INET(so->so_vnet); struct in_addr laddr; u_short lport; int error; @@ -1135,7 +1117,6 @@ tcp6_connect(struct tcpcb *tp, struct sockaddr *nam, struct thread *td) { struct inpcb *inp = tp->t_inpcb, *oinp; struct socket *so = inp->inp_socket; - INIT_VNET_INET(so->so_vnet); struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)nam; struct in6_addr addr6; int error; @@ -1257,7 +1238,6 @@ tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti) int tcp_ctloutput(struct socket *so, struct sockopt *sopt) { - INIT_VNET_INET(so->so_vnet); int error, opt, optval; struct inpcb *inp; struct tcpcb *tp; @@ -1445,7 +1425,6 @@ SYSCTL_ULONG(_net_inet_tcp, TCPCTL_RECVSPACE, recvspace, CTLFLAG_RW, static int tcp_attach(struct socket *so) { - INIT_VNET_INET(so->so_vnet); struct tcpcb *tp; struct inpcb *inp; int error; @@ -1498,9 +1477,6 @@ tcp_disconnect(struct tcpcb *tp) { struct inpcb *inp = tp->t_inpcb; struct socket *so = inp->inp_socket; -#ifdef INVARIANTS - INIT_VNET_INET(so->so_vnet); -#endif INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(inp); @@ -1539,9 +1515,6 @@ tcp_disconnect(struct tcpcb *tp) static void tcp_usrclosed(struct tcpcb *tp) { -#ifdef INVARIANTS - INIT_VNET_INET(tp->t_inpcb->inp_vnet); -#endif INP_INFO_WLOCK_ASSERT(&V_tcbinfo); INP_WLOCK_ASSERT(tp->t_inpcb); diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index e8022204e83e..8c175f8a5573 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -35,14 +35,20 @@ #include <netinet/tcp.h> -struct vnet; +#ifdef _KERNEL +#include <net/vnet.h> /* * Kernel variables for tcp. */ -#ifdef VIMAGE_GLOBALS -extern int tcp_do_rfc1323; -#endif +VNET_DECLARE(int, tcp_do_rfc1323); +VNET_DECLARE(int, tcp_reass_qsize); +VNET_DECLARE(struct uma_zone *, tcp_reass_zone); +#define V_tcp_do_rfc1323 VNET_GET(tcp_do_rfc1323) +#define V_tcp_reass_qsize VNET_GET(tcp_reass_qsize) +#define V_tcp_reass_zone VNET_GET(tcp_reass_zone) + +#endif /* _KERNEL */ /* TCP segment queue entry */ struct tseg_qent { @@ -52,10 +58,6 @@ struct tseg_qent { struct mbuf *tqe_m; /* mbuf contains packet */ }; LIST_HEAD(tsegqe_head, tseg_qent); -#ifdef VIMAGE_GLOBALS -extern int tcp_reass_qsize; -#endif -extern struct uma_zone *tcp_reass_zone; struct sackblk { tcp_seq start; /* start seq no. of sack block */ @@ -538,44 +540,79 @@ MALLOC_DECLARE(M_TCPLOG); extern int tcp_log_in_vain; -#ifdef VIMAGE_GLOBALS -extern struct inpcbhead tcb; /* head of queue of active tcpcb's */ -extern struct inpcbinfo tcbinfo; -extern struct tcpstat tcpstat; /* tcp statistics */ -extern int tcp_mssdflt; /* XXX */ -extern int tcp_minmss; -extern int tcp_delack_enabled; -extern int tcp_do_newreno; -extern int path_mtu_discovery; -extern int ss_fltsz; -extern int ss_fltsz_local; - -extern int blackhole; -extern int drop_synfin; -extern int tcp_do_rfc3042; -extern int tcp_do_rfc3390; -extern int tcp_insecure_rst; -extern int tcp_do_autorcvbuf; -extern int tcp_autorcvbuf_inc; -extern int tcp_autorcvbuf_max; -extern int tcp_do_rfc3465; -extern int tcp_abc_l_var; - -extern int tcp_do_tso; -extern int tcp_do_autosndbuf; -extern int tcp_autosndbuf_inc; -extern int tcp_autosndbuf_max; - -extern int nolocaltimewait; - -extern int tcp_do_sack; /* SACK enabled/disabled */ -extern int tcp_sack_maxholes; -extern int tcp_sack_globalmaxholes; -extern int tcp_sack_globalholes; -extern int tcp_sc_rst_sock_fail; /* RST on sock alloc failure */ -extern int tcp_do_ecn; /* TCP ECN enabled/disabled */ -extern int tcp_ecn_maxretries; -#endif /* VIMAGE_GLOBALS */ +VNET_DECLARE(struct inpcbhead, tcb); /* queue of active tcpcb's */ +VNET_DECLARE(struct inpcbinfo, tcbinfo); +VNET_DECLARE(struct tcpstat, tcpstat); /* tcp statistics */ +VNET_DECLARE(int, tcp_mssdflt); /* XXX */ +VNET_DECLARE(int, tcp_minmss); +VNET_DECLARE(int, tcp_delack_enabled); +VNET_DECLARE(int, tcp_do_newreno); +VNET_DECLARE(int, path_mtu_discovery); +VNET_DECLARE(int, ss_fltsz); +VNET_DECLARE(int, ss_fltsz_local); + +#define V_tcb VNET_GET(tcb) +#define V_tcbinfo VNET_GET(tcbinfo) +#define V_tcpstat VNET_GET(tcpstat) +#define V_tcp_mssdflt VNET_GET(tcp_mssdflt) +#define V_tcp_minmss VNET_GET(tcp_minmss) +#define V_tcp_delack_enabled VNET_GET(tcp_delack_enabled) +#define V_tcp_do_newreno VNET_GET(tcp_do_newreno) +#define V_path_mtu_discovery VNET_GET(path_mtu_discovery) +#define V_ss_fltsz VNET_GET(ss_fltsz) +#define V_ss_fltsz_local VNET_GET(ss_fltsz_local) + +VNET_DECLARE(int, blackhole); +VNET_DECLARE(int, drop_synfin); +VNET_DECLARE(int, tcp_do_rfc3042); +VNET_DECLARE(int, tcp_do_rfc3390); +VNET_DECLARE(int, tcp_insecure_rst); +VNET_DECLARE(int, tcp_do_autorcvbuf); +VNET_DECLARE(int, tcp_autorcvbuf_inc); +VNET_DECLARE(int, tcp_autorcvbuf_max); +VNET_DECLARE(int, tcp_do_rfc3465); +VNET_DECLARE(int, tcp_abc_l_var); + +#define V_blackhole VNET_GET(blackhole) +#define V_drop_synfin VNET_GET(drop_synfin) +#define V_tcp_do_rfc3042 VNET_GET(tcp_do_rfc3042) +#define V_tcp_do_rfc3390 VNET_GET(tcp_do_rfc3390) +#define V_tcp_insecure_rst VNET_GET(tcp_insecure_rst) +#define V_tcp_do_autorcvbuf VNET_GET(tcp_do_autorcvbuf) +#define V_tcp_autorcvbuf_inc VNET_GET(tcp_autorcvbuf_inc) +#define V_tcp_autorcvbuf_max VNET_GET(tcp_autorcvbuf_max) +#define V_tcp_do_rfc3465 VNET_GET(tcp_do_rfc3465) +#define V_tcp_abc_l_var VNET_GET(tcp_abc_l_var) + +VNET_DECLARE(int, tcp_do_tso); +VNET_DECLARE(int, tcp_do_autosndbuf); +VNET_DECLARE(int, tcp_autosndbuf_inc); +VNET_DECLARE(int, tcp_autosndbuf_max); + +#define V_tcp_do_tso VNET_GET(tcp_do_tso) +#define V_tcp_do_autosndbuf VNET_GET(tcp_do_autosndbuf) +#define V_tcp_autosndbuf_inc VNET_GET(tcp_autosndbuf_inc) +#define V_tcp_autosndbuf_max VNET_GET(tcp_autosndbuf_max) + +VNET_DECLARE(int, nolocaltimewait); + +#define V_nolocaltimewait VNET_GET(nolocaltimewait) + +VNET_DECLARE(int, tcp_do_sack); /* SACK enabled/disabled */ +VNET_DECLARE(int, tcp_sack_maxholes); +VNET_DECLARE(int, tcp_sack_globalmaxholes); +VNET_DECLARE(int, tcp_sack_globalholes); +VNET_DECLARE(int, tcp_sc_rst_sock_fail); /* RST on sock alloc failure */ +VNET_DECLARE(int, tcp_do_ecn); /* TCP ECN enabled/disabled */ +VNET_DECLARE(int, tcp_ecn_maxretries); + +#define V_tcp_do_sack VNET_GET(tcp_do_sack) +#define V_tcp_sack_maxholes VNET_GET(tcp_sack_maxholes) +#define V_tcp_sack_globalmaxholes VNET_GET(tcp_sack_globalmaxholes) +#define V_tcp_sack_globalholes VNET_GET(tcp_sack_globalholes) +#define V_tcp_sc_rst_sock_fail VNET_GET(tcp_sc_rst_sock_fail) +#define V_tcp_do_ecn VNET_GET(tcp_do_ecn) +#define V_tcp_ecn_maxretries VNET_GET(tcp_ecn_maxretries) int tcp_addoptions(struct tcpopt *, u_char *); struct tcpcb * diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 51dda23ad23f..f9623f3af65f 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -80,7 +80,6 @@ __FBSDID("$FreeBSD$"); #endif #include <netinet/udp.h> #include <netinet/udp_var.h> -#include <netinet/vinet.h> #ifdef IPSEC #include <netipsec/ipsec.h> @@ -96,9 +95,7 @@ __FBSDID("$FreeBSD$"); * Per RFC 768, August, 1980. */ -#ifdef VIMAGE_GLOBALS -int udp_blackhole; -#endif +VNET_DEFINE(int, udp_blackhole); /* * BSD 4.2 defaulted the udp checksum to be off. Turning off udp checksums @@ -114,8 +111,8 @@ int udp_log_in_vain = 0; SYSCTL_INT(_net_inet_udp, OID_AUTO, log_in_vain, CTLFLAG_RW, &udp_log_in_vain, 0, "Log all incoming UDP packets"); -SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_udp, OID_AUTO, blackhole, - CTLFLAG_RW, udp_blackhole, 0, +SYSCTL_VNET_INT(_net_inet_udp, OID_AUTO, blackhole, CTLFLAG_RW, + &VNET_NAME(udp_blackhole), 0, "Do not send port unreachables for refused connects"); u_long udp_sendspace = 9216; /* really max datagram size */ @@ -134,19 +131,19 @@ u_long udp_recvspace = 40 * (1024 + SYSCTL_ULONG(_net_inet_udp, UDPCTL_RECVSPACE, recvspace, CTLFLAG_RW, &udp_recvspace, 0, "Maximum space for incoming UDP datagrams"); -#ifdef VIMAGE_GLOBALS -struct inpcbhead udb; /* from udp_var.h */ -struct inpcbinfo udbinfo; -static uma_zone_t udpcb_zone; -struct udpstat udpstat; /* from udp_var.h */ -#endif +VNET_DEFINE(struct inpcbhead, udb); /* from udp_var.h */ +VNET_DEFINE(struct inpcbinfo, udbinfo); +static VNET_DEFINE(uma_zone_t, udpcb_zone); +VNET_DEFINE(struct udpstat, udpstat); /* from udp_var.h */ + +#define V_udpcb_zone VNET_GET(udpcb_zone) #ifndef UDBHASHSIZE #define UDBHASHSIZE 128 #endif -SYSCTL_V_STRUCT(V_NET, vnet_inet, _net_inet_udp, UDPCTL_STATS, stats, - CTLFLAG_RW, udpstat, udpstat, +SYSCTL_VNET_STRUCT(_net_inet_udp, UDPCTL_STATS, stats, CTLFLAG_RW, + &VNET_NAME(udpstat), udpstat, "UDP statistics (struct udpstat, netinet/udp_var.h)"); static void udp_detach(struct socket *so); @@ -164,7 +161,6 @@ static struct mbuf *udp4_espdecap(struct inpcb *, struct mbuf *, int); static void udp_zone_change(void *tag) { - INIT_VNET_INET(curvnet); uma_zone_set_max(V_udbinfo.ipi_zone, maxsockets); uma_zone_set_max(V_udpcb_zone, maxsockets); @@ -183,7 +179,6 @@ udp_inpcb_init(void *mem, int size, int flags) void udp_init(void) { - INIT_VNET_INET(curvnet); V_udp_blackhole = 0; @@ -212,7 +207,6 @@ udp_init(void) int udp_newudpcb(struct inpcb *inp) { - INIT_VNET_INET(curvnet); struct udpcb *up; up = uma_zalloc(V_udpcb_zone, M_NOWAIT | M_ZERO); @@ -225,7 +219,6 @@ udp_newudpcb(struct inpcb *inp) void udp_discardcb(struct udpcb *up) { - INIT_VNET_INET(curvnet); uma_zfree(V_udpcb_zone, up); } @@ -234,7 +227,6 @@ udp_discardcb(struct udpcb *up) void udp_destroy(void) { - INIT_VNET_INET(curvnet); hashdestroy(V_udbinfo.ipi_hashbase, M_PCB, V_udbinfo.ipi_hashmask); @@ -274,7 +266,6 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off, #ifdef IPSEC /* Check AH/ESP integrity. */ if (ipsec4_in_reject(n, inp)) { - INIT_VNET_IPSEC(curvnet); m_freem(n); V_ipsec4stat.in_polvio++; return; @@ -321,7 +312,6 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off, so = inp->inp_socket; SOCKBUF_LOCK(&so->so_rcv); if (sbappendaddr_locked(&so->so_rcv, append_sa, n, opts) == 0) { - INIT_VNET_INET(so->so_vnet); SOCKBUF_UNLOCK(&so->so_rcv); m_freem(n); if (opts) @@ -334,7 +324,6 @@ udp_append(struct inpcb *inp, struct ip *ip, struct mbuf *n, int off, void udp_input(struct mbuf *m, int off) { - INIT_VNET_INET(curvnet); int iphlen = off; struct ip *ip; struct udphdr *uh; @@ -668,7 +657,6 @@ udp_notify(struct inpcb *inp, int errno) void udp_ctlinput(int cmd, struct sockaddr *sa, void *vip) { - INIT_VNET_INET(curvnet); struct ip *ip = vip; struct udphdr *uh; struct in_addr faddr; @@ -715,7 +703,6 @@ udp_ctlinput(int cmd, struct sockaddr *sa, void *vip) static int udp_pcblist(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(curvnet); int error, i, n; struct inpcb *inp, **inp_list; inp_gen_t gencnt; @@ -814,7 +801,6 @@ SYSCTL_PROC(_net_inet_udp, UDPCTL_PCBLIST, pcblist, CTLFLAG_RD, 0, 0, static int udp_getcred(SYSCTL_HANDLER_ARGS) { - INIT_VNET_INET(curvnet); struct xucred xuc; struct sockaddr_in addrs[2]; struct inpcb *inp; @@ -949,7 +935,6 @@ static int udp_output(struct inpcb *inp, struct mbuf *m, struct sockaddr *addr, struct mbuf *control, struct thread *td) { - INIT_VNET_INET(inp->inp_vnet); struct udpiphdr *ui; int len = m->m_pkthdr.len; struct in_addr faddr, laddr; @@ -1270,7 +1255,6 @@ release: static struct mbuf * udp4_espdecap(struct inpcb *inp, struct mbuf *m, int off) { - INIT_VNET_IPSEC(curvnet); size_t minlen, payload, skip, iphlen; caddr_t data; struct udpcb *up; @@ -1397,7 +1381,6 @@ udp4_espdecap(struct inpcb *inp, struct mbuf *m, int off) static void udp_abort(struct socket *so) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; inp = sotoinpcb(so); @@ -1416,7 +1399,6 @@ udp_abort(struct socket *so) static int udp_attach(struct socket *so, int proto, struct thread *td) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; int error; @@ -1480,7 +1462,6 @@ udp_set_kernel_tunneling(struct socket *so, udp_tun_func_t f) static int udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; int error; @@ -1497,7 +1478,6 @@ udp_bind(struct socket *so, struct sockaddr *nam, struct thread *td) static void udp_close(struct socket *so) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; inp = sotoinpcb(so); @@ -1516,7 +1496,6 @@ udp_close(struct socket *so) static int udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; int error; struct sockaddr_in *sin; @@ -1548,7 +1527,6 @@ udp_connect(struct socket *so, struct sockaddr *nam, struct thread *td) static void udp_detach(struct socket *so) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; struct udpcb *up; @@ -1570,7 +1548,6 @@ udp_detach(struct socket *so) static int udp_disconnect(struct socket *so) { - INIT_VNET_INET(so->so_vnet); struct inpcb *inp; inp = sotoinpcb(so); diff --git a/sys/netinet/udp_var.h b/sys/netinet/udp_var.h index 211edff8fa3f..417c59716362 100644 --- a/sys/netinet/udp_var.h +++ b/sys/netinet/udp_var.h @@ -119,12 +119,16 @@ SYSCTL_DECL(_net_inet_udp); extern struct pr_usrreqs udp_usrreqs; -#ifdef VIMAGE_GLOBALS -extern struct inpcbhead udb; -extern struct inpcbinfo udbinfo; -extern struct udpstat udpstat; -extern int udp_blackhole; -#endif +VNET_DECLARE(struct inpcbhead, udb); +VNET_DECLARE(struct inpcbinfo, udbinfo); +VNET_DECLARE(struct udpstat, udpstat); +VNET_DECLARE(int, udp_blackhole); + +#define V_udb VNET_GET(udb) +#define V_udbinfo VNET_GET(udbinfo) +#define V_udpstat VNET_GET(udpstat) +#define V_udp_blackhole VNET_GET(udp_blackhole) + extern u_long udp_sendspace; extern u_long udp_recvspace; extern int udp_log_in_vain; diff --git a/sys/netinet/vinet.h b/sys/netinet/vinet.h deleted file mode 100644 index 495f79759630..000000000000 --- a/sys/netinet/vinet.h +++ /dev/null @@ -1,422 +0,0 @@ -/*- - * 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; - - 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; - int _ip_output_flowtable_size; - 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; - uma_zone_t _udpcb_zone; - 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; - - struct flowtable * _ip_ft; - struct flowtable * _flow_list_head; - uint32_t _flow_hashjitter; - uma_zone_t _flow_ipv4_zone; - uma_zone_t _flow_ipv6_zone; - int _flowtable_enable; - int _flowtable_hits; - int _flowtable_lookups; - int _flowtable_misses; - int _flowtable_frees; - int _flowtable_free_checks; - int _flowtable_max_depth; - int _flowtable_collisions; - int _flowtable_syn_expire; - int _flowtable_udp_expire; - int _flowtable_fin_wait_expire; - int _flowtable_tcp_expire; - int _flowtable_nmbflows; -}; - -/* 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_flow_hashjitter VNET_INET(flow_hashjitter) -#define V_flow_ipv4_zone VNET_INET(flow_ipv4_zone) -#define V_flow_ipv6_zone VNET_INET(flow_ipv6_zone) -#define V_flow_list_head VNET_INET(flow_list_head) -#define V_flowtable_collisions VNET_INET(flowtable_collisions) -#define V_flowtable_enable VNET_INET(flowtable_enable) -#define V_flowtable_fin_wait_expire VNET_INET(flowtable_fin_wait_expire) -#define V_flowtable_free_checks VNET_INET(flowtable_free_checks) -#define V_flowtable_frees VNET_INET(flowtable_frees) -#define V_flowtable_hits VNET_INET(flowtable_hits) -#define V_flowtable_lookups VNET_INET(flowtable_lookups) -#define V_flowtable_max_depth VNET_INET(flowtable_max_depth) -#define V_flowtable_misses VNET_INET(flowtable_misses) -#define V_flowtable_nmbflows VNET_INET(flowtable_nmbflows) -#define V_flowtable_syn_expire VNET_INET(flowtable_syn_expire) -#define V_flowtable_tcp_expire VNET_INET(flowtable_tcp_expire) -#define V_flowtable_udp_expire VNET_INET(flowtable_udp_expire) -#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_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_ft VNET_INET(ip_ft) -#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_output_flowtable_size VNET_INET(ip_output_flowtable_size) -#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_udpcb_zone VNET_INET(udpcb_zone) -#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_ */ |