diff options
Diffstat (limited to 'sys/netinet')
-rw-r--r-- | sys/netinet/if_ether.c | 14 | ||||
-rw-r--r-- | sys/netinet/ip_fw.h | 2 | ||||
-rw-r--r-- | sys/netinet/ip_input.c | 27 | ||||
-rw-r--r-- | sys/netinet/tcp_reass.c | 16 | ||||
-rw-r--r-- | sys/netinet/tcp_sack.c | 7 | ||||
-rw-r--r-- | sys/netinet/tcp_subr.c | 76 | ||||
-rw-r--r-- | sys/netinet/tcp_timewait.c | 16 | ||||
-rw-r--r-- | sys/netinet/vinet.h | 9 |
8 files changed, 103 insertions, 64 deletions
diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index a918415..3a44f5c 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -111,6 +111,7 @@ SYSCTL_V_INT(V_NET, vnet_inet, _net_link_ether_inet, OID_AUTO, proxyall, "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 *); @@ -790,8 +791,8 @@ arp_ifinit2(struct ifnet *ifp, struct ifaddr *ifa, u_char *enaddr) ifa->ifa_rtrequest = NULL; } -static void -arp_init(void) +static int +arp_iattach(const void *unused __unused) { INIT_VNET_INET(curvnet); @@ -800,6 +801,15 @@ arp_init(void) V_useloopback = 1; /* use loopback interface for local traffic */ V_arp_proxyall = 0; + return (0); +} + +static void +arp_init(void) +{ + + arp_iattach(NULL); + arpintrq.ifq_maxlen = 50; mtx_init(&arpintrq.ifq_mtx, "arp_inq", NULL, MTX_DEF); netisr_register(NETISR_ARP, arpintr, &arpintrq, 0); diff --git a/sys/netinet/ip_fw.h b/sys/netinet/ip_fw.h index 35e7e12..fa37a73 100644 --- a/sys/netinet/ip_fw.h +++ b/sys/netinet/ip_fw.h @@ -698,6 +698,7 @@ struct vnet_ipfw { int _fw_debug; /* actually unused */ 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; @@ -742,6 +743,7 @@ extern struct vnet_ipfw vnet_ipfw_0; #define V_fw_debug VNET_IPFW(fw_debug) #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) diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index a75ee72..db53a23 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -242,6 +242,7 @@ ip_init(void) 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 */ @@ -270,6 +271,20 @@ ip_init(void) TAILQ_INIT(&V_in_ifaddrhead); V_in_ifaddrhashtbl = hashinit(INADDR_NHASH, M_IFADDR, &V_in_ifaddrhmask); + + /* Initialize IP reassembly queue. */ + for (i = 0; i < IPREASS_NHASH; i++) + TAILQ_INIT(&V_ipq[i]); + V_maxnipq = nmbclusters / 32; + V_maxfragsperpacket = 16; + V_ipq_zone = uma_zcreate("ipq", sizeof(struct ipq), NULL, NULL, NULL, + NULL, UMA_ALIGN_PTR, 0); + maxnipq_update(); + + /* Skip initialization of globals for non-default instances. */ + if (!IS_DEFAULT_VNET(curvnet)) + return; + pr = pffindproto(PF_INET, IPPROTO_RAW, SOCK_RAW); if (pr == NULL) panic("ip_init: PF_INET not found"); @@ -297,16 +312,6 @@ ip_init(void) printf("%s: WARNING: unable to register pfil hook, " "error %d\n", __func__, i); - /* Initialize IP reassembly queue. */ - IPQ_LOCK_INIT(); - for (i = 0; i < IPREASS_NHASH; i++) - TAILQ_INIT(&V_ipq[i]); - V_maxnipq = nmbclusters / 32; - V_maxfragsperpacket = 16; - V_ipq_zone = uma_zcreate("ipq", sizeof(struct ipq), NULL, NULL, NULL, - NULL, UMA_ALIGN_PTR, 0); - maxnipq_update(); - /* Start ipport_tick. */ callout_init(&ipport_tick_callout, CALLOUT_MPSAFE); ipport_tick(NULL); @@ -316,7 +321,7 @@ ip_init(void) NULL, EVENTHANDLER_PRI_ANY); /* Initialize various other remaining things. */ - V_ip_id = time_second & 0xffff; + IPQ_LOCK_INIT(); ipintrq.ifq_maxlen = ipqmaxlen; mtx_init(&ipintrq.ifq_mtx, "ip_inq", NULL, MTX_DEF); netisr_register(NETISR_IP, ip_input, &ipintrq, 0); diff --git a/sys/netinet/tcp_reass.c b/sys/netinet/tcp_reass.c index 172abc5..ba5e0b3 100644 --- a/sys/netinet/tcp_reass.c +++ b/sys/netinet/tcp_reass.c @@ -108,10 +108,12 @@ tcp_reass_zone_change(void *tag) INIT_VNET_INET(curvnet); V_tcp_reass_maxseg = nmbclusters / 16; - uma_zone_set_max(tcp_reass_zone, V_tcp_reass_maxseg); + uma_zone_set_max(V_tcp_reass_zone, V_tcp_reass_maxseg); } +#ifdef VIMAGE_GLOBALS uma_zone_t tcp_reass_zone; +#endif void tcp_reass_init(void) @@ -126,9 +128,9 @@ tcp_reass_init(void) V_tcp_reass_maxseg = nmbclusters / 16; TUNABLE_INT_FETCH("net.inet.tcp.reass.maxsegments", &V_tcp_reass_maxseg); - tcp_reass_zone = uma_zcreate("tcpreass", sizeof (struct tseg_qent), + V_tcp_reass_zone = uma_zcreate("tcpreass", sizeof (struct tseg_qent), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); - uma_zone_set_max(tcp_reass_zone, V_tcp_reass_maxseg); + uma_zone_set_max(V_tcp_reass_zone, V_tcp_reass_maxseg); EVENTHANDLER_REGISTER(nmbclusters_change, tcp_reass_zone_change, NULL, EVENTHANDLER_PRI_ANY); } @@ -180,7 +182,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m) * Allocate a new queue entry. If we can't, or hit the zone limit * just drop the pkt. */ - te = uma_zalloc(tcp_reass_zone, M_NOWAIT); + te = uma_zalloc(V_tcp_reass_zone, M_NOWAIT); if (te == NULL) { V_tcpstat.tcps_rcvmemdrop++; m_freem(m); @@ -213,7 +215,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m) V_tcpstat.tcps_rcvduppack++; V_tcpstat.tcps_rcvdupbyte += *tlenp; m_freem(m); - uma_zfree(tcp_reass_zone, te); + uma_zfree(V_tcp_reass_zone, te); tp->t_segqlen--; V_tcp_reass_qsize--; /* @@ -250,7 +252,7 @@ tcp_reass(struct tcpcb *tp, struct tcphdr *th, int *tlenp, struct mbuf *m) nq = LIST_NEXT(q, tqe_q); LIST_REMOVE(q, tqe_q); m_freem(q->tqe_m); - uma_zfree(tcp_reass_zone, q); + uma_zfree(V_tcp_reass_zone, q); tp->t_segqlen--; V_tcp_reass_qsize--; q = nq; @@ -287,7 +289,7 @@ present: m_freem(q->tqe_m); else sbappendstream_locked(&so->so_rcv, q->tqe_m); - uma_zfree(tcp_reass_zone, q); + uma_zfree(V_tcp_reass_zone, q); tp->t_segqlen--; V_tcp_reass_qsize--; q = nq; diff --git a/sys/netinet/tcp_sack.c b/sys/netinet/tcp_sack.c index 4ca10af..f4998af 100644 --- a/sys/netinet/tcp_sack.c +++ b/sys/netinet/tcp_sack.c @@ -123,9 +123,8 @@ __FBSDID("$FreeBSD$"); #include <machine/in_cksum.h> -extern struct uma_zone *sack_hole_zone; - #ifdef VIMAGE_GLOBALS +extern struct uma_zone *sack_hole_zone; int tcp_do_sack; int tcp_sack_maxholes; int tcp_sack_globalmaxholes; @@ -265,7 +264,7 @@ tcp_sackhole_alloc(struct tcpcb *tp, tcp_seq start, tcp_seq end) return NULL; } - hole = (struct sackhole *)uma_zalloc(sack_hole_zone, M_NOWAIT); + hole = (struct sackhole *)uma_zalloc(V_sack_hole_zone, M_NOWAIT); if (hole == NULL) return NULL; @@ -287,7 +286,7 @@ tcp_sackhole_free(struct tcpcb *tp, struct sackhole *hole) { INIT_VNET_INET(tp->t_vnet); - uma_zfree(sack_hole_zone, hole); + uma_zfree(V_sack_hole_zone, hole); tp->snd_numholes--; V_tcp_sack_globalholes--; diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index cda8817..e566434 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -243,7 +243,9 @@ SYSCTL_V_INT(V_NET, vnet_inet, _net_inet_tcp_inflight, OID_AUTO, stab, CTLFLAG_RW, tcp_inflight_stab, 0, "Inflight Algorithm Stabilization 20 = 2 packets"); +#ifdef VIMAGE_GLOBALS uma_zone_t sack_hole_zone; +#endif static struct inpcb *tcp_notify(struct inpcb *, int); static void tcp_isn_tick(void *); @@ -269,7 +271,9 @@ struct tcpcb_mem { struct tcp_timer tt; }; +#ifdef VIMAGE_GLOBALS static uma_zone_t tcpcb_zone; +#endif MALLOC_DEFINE(M_TCPLOG, "tcplog", "TCP address and flags print buffers"); struct callout isn_callout; static struct mtx isn_mtx; @@ -286,7 +290,7 @@ tcp_zone_change(void *tag) { uma_zone_set_max(V_tcbinfo.ipi_zone, maxsockets); - uma_zone_set_max(tcpcb_zone, maxsockets); + uma_zone_set_max(V_tcpcb_zone, maxsockets); tcp_tw_zone_change(); } @@ -348,18 +352,7 @@ tcp_init(void) V_tcp_sack_globalmaxholes = 65536; V_tcp_sack_globalholes = 0; - tcp_delacktime = TCPTV_DELACK; - tcp_keepinit = TCPTV_KEEP_INIT; - tcp_keepidle = TCPTV_KEEP_IDLE; - tcp_keepintvl = TCPTV_KEEPINTVL; - tcp_maxpersistidle = TCPTV_KEEP_IDLE; - tcp_msl = TCPTV_MSL; - tcp_rexmit_min = TCPTV_MIN; - if (tcp_rexmit_min < 1) - tcp_rexmit_min = 1; - tcp_rexmit_slop = TCPTV_CPU_VAR; V_tcp_inflight_rttthresh = TCPTV_INFLIGHT_RTTTHRESH; - tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT; TUNABLE_INT_FETCH("net.inet.tcp.sack.enable", &V_tcp_do_sack); @@ -372,7 +365,6 @@ tcp_init(void) printf("WARNING: TCB hash size not a power of 2\n"); hashsize = 512; /* safe default */ } - tcp_tcbhashsize = hashsize; V_tcbinfo.ipi_hashbase = hashinit(hashsize, M_PCB, &V_tcbinfo.ipi_hashmask); V_tcbinfo.ipi_porthashbase = hashinit(hashsize, M_PCB, @@ -380,6 +372,37 @@ tcp_init(void) V_tcbinfo.ipi_zone = uma_zcreate("inpcb", sizeof(struct inpcb), NULL, NULL, tcp_inpcb_init, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); uma_zone_set_max(V_tcbinfo.ipi_zone, maxsockets); + /* + * These have to be type stable for the benefit of the timers. + */ + V_tcpcb_zone = uma_zcreate("tcpcb", sizeof(struct tcpcb_mem), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); + uma_zone_set_max(V_tcpcb_zone, maxsockets); + tcp_tw_init(); + syncache_init(); + tcp_hc_init(); + tcp_reass_init(); + V_sack_hole_zone = uma_zcreate("sackhole", sizeof(struct sackhole), + NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); + + /* Skip initialization of globals for non-default instances. */ + if (!IS_DEFAULT_VNET(curvnet)) + return; + + /* XXX virtualize those bellow? */ + tcp_delacktime = TCPTV_DELACK; + tcp_keepinit = TCPTV_KEEP_INIT; + tcp_keepidle = TCPTV_KEEP_IDLE; + tcp_keepintvl = TCPTV_KEEPINTVL; + tcp_maxpersistidle = TCPTV_KEEP_IDLE; + tcp_msl = TCPTV_MSL; + tcp_rexmit_min = TCPTV_MIN; + if (tcp_rexmit_min < 1) + tcp_rexmit_min = 1; + tcp_rexmit_slop = TCPTV_CPU_VAR; + tcp_finwait2_timeout = TCPTV_FINWAIT2_TIMEOUT; + tcp_tcbhashsize = hashsize; + #ifdef INET6 #define TCP_MINPROTOHDR (sizeof(struct ip6_hdr) + sizeof(struct tcphdr)) #else /* INET6 */ @@ -390,23 +413,12 @@ tcp_init(void) if (max_linkhdr + TCP_MINPROTOHDR > MHLEN) panic("tcp_init"); #undef TCP_MINPROTOHDR - /* - * These have to be type stable for the benefit of the timers. - */ - tcpcb_zone = uma_zcreate("tcpcb", sizeof(struct tcpcb_mem), - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); - uma_zone_set_max(tcpcb_zone, maxsockets); - tcp_tw_init(); - syncache_init(); - tcp_hc_init(); - tcp_reass_init(); + ISN_LOCK_INIT(); callout_init(&isn_callout, CALLOUT_MPSAFE); - tcp_isn_tick(NULL); + callout_reset(&isn_callout, hz/100, tcp_isn_tick, NULL); EVENTHANDLER_REGISTER(shutdown_pre_sync, tcp_fini, NULL, SHUTDOWN_PRI_DEFAULT); - sack_hole_zone = uma_zcreate("sackhole", sizeof(struct sackhole), - NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); EVENTHANDLER_REGISTER(maxsockets_change, tcp_zone_change, NULL, EVENTHANDLER_PRI_ANY); } @@ -686,7 +698,7 @@ tcp_newtcpcb(struct inpcb *inp) int isipv6 = (inp->inp_vflag & INP_IPV6) != 0; #endif /* INET6 */ - tm = uma_zalloc(tcpcb_zone, M_NOWAIT | M_ZERO); + tm = uma_zalloc(V_tcpcb_zone, M_NOWAIT | M_ZERO); if (tm == NULL) return (NULL); tp = &tm->tcb; @@ -846,7 +858,7 @@ tcp_discardcb(struct tcpcb *tp) while ((q = LIST_FIRST(&tp->t_segq)) != NULL) { LIST_REMOVE(q, tqe_q); m_freem(q->tqe_m); - uma_zfree(tcp_reass_zone, q); + uma_zfree(V_tcp_reass_zone, q); tp->t_segqlen--; V_tcp_reass_qsize--; } @@ -856,7 +868,7 @@ tcp_discardcb(struct tcpcb *tp) tcp_free_sackholes(tp); inp->inp_ppcb = NULL; tp->t_inpcb = NULL; - uma_zfree(tcpcb_zone, tp); + uma_zfree(V_tcpcb_zone, tp); } /* @@ -929,7 +941,7 @@ tcp_drain(void) != NULL) { LIST_REMOVE(te, tqe_q); m_freem(te->tqe_m); - uma_zfree(tcp_reass_zone, te); + uma_zfree(V_tcp_reass_zone, te); tcpb->t_segqlen--; V_tcp_reass_qsize--; } @@ -1546,8 +1558,8 @@ tcp_isn_tick(void *xtp) VNET_ITERATOR_DECL(vnet_iter); u_int32_t projected_offset; - ISN_LOCK(); VNET_LIST_RLOCK(); + ISN_LOCK(); VNET_FOREACH(vnet_iter) { CURVNET_SET(vnet_iter); /* XXX appease INVARIANTS */ INIT_VNET_INET(curvnet); @@ -1560,9 +1572,9 @@ tcp_isn_tick(void *xtp) V_isn_offset_old = V_isn_offset; CURVNET_RESTORE(); } + ISN_UNLOCK(); VNET_LIST_RUNLOCK(); callout_reset(&isn_callout, hz/100, tcp_isn_tick, NULL); - ISN_UNLOCK(); } /* diff --git a/sys/netinet/tcp_timewait.c b/sys/netinet/tcp_timewait.c index c5b02ba..a2c5a4c 100644 --- a/sys/netinet/tcp_timewait.c +++ b/sys/netinet/tcp_timewait.c @@ -94,7 +94,6 @@ __FBSDID("$FreeBSD$"); #include <security/mac/mac_framework.h> -static uma_zone_t tcptw_zone; static int maxtcptw; /* @@ -104,6 +103,7 @@ static int maxtcptw; * 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 @@ -142,7 +142,7 @@ sysctl_maxtcptw(SYSCTL_HANDLER_ARGS) if (error == 0 && req->newptr) if (new >= 32) { maxtcptw = new; - uma_zone_set_max(tcptw_zone, maxtcptw); + uma_zone_set_max(V_tcptw_zone, maxtcptw); } return (error); } @@ -160,7 +160,7 @@ tcp_tw_zone_change(void) { if (maxtcptw == 0) - uma_zone_set_max(tcptw_zone, tcptw_auto_size()); + uma_zone_set_max(V_tcptw_zone, tcptw_auto_size()); } void @@ -168,13 +168,13 @@ tcp_tw_init(void) { INIT_VNET_INET(curvnet); - tcptw_zone = uma_zcreate("tcptw", sizeof(struct tcptw), + V_tcptw_zone = uma_zcreate("tcptw", sizeof(struct tcptw), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, UMA_ZONE_NOFREE); TUNABLE_INT_FETCH("net.inet.tcp.maxtcptw", &maxtcptw); if (maxtcptw == 0) - uma_zone_set_max(tcptw_zone, tcptw_auto_size()); + uma_zone_set_max(V_tcptw_zone, tcptw_auto_size()); else - uma_zone_set_max(tcptw_zone, maxtcptw); + uma_zone_set_max(V_tcptw_zone, maxtcptw); TAILQ_INIT(&V_twq_2msl); } @@ -204,7 +204,7 @@ tcp_twstart(struct tcpcb *tp) return; } - tw = uma_zalloc(tcptw_zone, M_NOWAIT); + tw = uma_zalloc(V_tcptw_zone, M_NOWAIT); if (tw == NULL) { tw = tcp_tw_2msl_scan(1); if (tw == NULL) { @@ -477,7 +477,7 @@ tcp_twclose(struct tcptw *tw, int reuse) tw->tw_cred = NULL; if (reuse) return; - uma_zfree(tcptw_zone, tw); + uma_zfree(V_tcptw_zone, tw); } int diff --git a/sys/netinet/vinet.h b/sys/netinet/vinet.h index e5b0bab..b65acc1 100644 --- a/sys/netinet/vinet.h +++ b/sys/netinet/vinet.h @@ -86,6 +86,11 @@ struct vnet_inet { 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; @@ -315,12 +320,15 @@ extern struct vnet_inet vnet_inet_0; #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) @@ -353,6 +361,7 @@ extern struct vnet_inet vnet_inet_0; #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) |