Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_subr.c
Show All 36 Lines | |||||
#include "opt_inet.h" | #include "opt_inet.h" | ||||
#include "opt_inet6.h" | #include "opt_inet6.h" | ||||
#include "opt_ipsec.h" | #include "opt_ipsec.h" | ||||
#include "opt_kern_tls.h" | #include "opt_kern_tls.h" | ||||
#include "opt_tcpdebug.h" | #include "opt_tcpdebug.h" | ||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
#include <sys/arb.h> | |||||
#include <sys/callout.h> | #include <sys/callout.h> | ||||
#include <sys/eventhandler.h> | #include <sys/eventhandler.h> | ||||
#ifdef TCP_HHOOK | #ifdef TCP_HHOOK | ||||
#include <sys/hhook.h> | #include <sys/hhook.h> | ||||
#endif | #endif | ||||
#include <sys/kernel.h> | #include <sys/kernel.h> | ||||
#ifdef TCP_HHOOK | #ifdef TCP_HHOOK | ||||
#include <sys/khelp.h> | #include <sys/khelp.h> | ||||
#endif | #endif | ||||
#ifdef KERN_TLS | #ifdef KERN_TLS | ||||
#include <sys/ktls.h> | #include <sys/ktls.h> | ||||
#endif | #endif | ||||
#include <sys/qmath.h> | |||||
#include <sys/stats.h> | |||||
#include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
#include <sys/jail.h> | #include <sys/jail.h> | ||||
#include <sys/malloc.h> | #include <sys/malloc.h> | ||||
#include <sys/refcount.h> | #include <sys/refcount.h> | ||||
#include <sys/mbuf.h> | #include <sys/mbuf.h> | ||||
#ifdef INET6 | #ifdef INET6 | ||||
#include <sys/domain.h> | #include <sys/domain.h> | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 935 Lines • ▼ Show 20 Lines | |||||
#ifdef TCP_HHOOK | #ifdef TCP_HHOOK | ||||
if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, | if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, | ||||
&V_tcp_hhh[HHOOK_TCP_EST_IN], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) | &V_tcp_hhh[HHOOK_TCP_EST_IN], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) | ||||
printf("%s: WARNING: unable to register helper hook\n", __func__); | printf("%s: WARNING: unable to register helper hook\n", __func__); | ||||
if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT, | if (hhook_head_register(HHOOK_TYPE_TCP, HHOOK_TCP_EST_OUT, | ||||
&V_tcp_hhh[HHOOK_TCP_EST_OUT], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) | &V_tcp_hhh[HHOOK_TCP_EST_OUT], HHOOK_NOWAIT|HHOOK_HEADISINVNET) != 0) | ||||
printf("%s: WARNING: unable to register helper hook\n", __func__); | printf("%s: WARNING: unable to register helper hook\n", __func__); | ||||
#endif | #endif | ||||
#ifdef STATS | |||||
if (tcp_stats_init()) | |||||
printf("%s: WARNING: unable to initialise TCP stats\n", | |||||
__func__); | |||||
#endif | |||||
hashsize = TCBHASHSIZE; | hashsize = TCBHASHSIZE; | ||||
TUNABLE_INT_FETCH(tcbhash_tuneable, &hashsize); | TUNABLE_INT_FETCH(tcbhash_tuneable, &hashsize); | ||||
if (hashsize == 0) { | if (hashsize == 0) { | ||||
/* | /* | ||||
* Auto tune the hash size based on maxsockets. | * Auto tune the hash size based on maxsockets. | ||||
* A perfect hash would have a 1:1 mapping | * A perfect hash would have a 1:1 mapping | ||||
* (hashsize = maxsockets) however it's been | * (hashsize = maxsockets) however it's been | ||||
* suggested that O(2) average is better. | * suggested that O(2) average is better. | ||||
▲ Show 20 Lines • Show All 673 Lines • ▼ Show 20 Lines | |||||
#endif | #endif | ||||
#ifdef TCP_BLACKBOX | #ifdef TCP_BLACKBOX | ||||
/* Initialize the per-TCPCB log data. */ | /* Initialize the per-TCPCB log data. */ | ||||
tcp_log_tcpcbinit(tp); | tcp_log_tcpcbinit(tp); | ||||
#endif | #endif | ||||
if (tp->t_fb->tfb_tcp_fb_init) { | if (tp->t_fb->tfb_tcp_fb_init) { | ||||
(*tp->t_fb->tfb_tcp_fb_init)(tp); | (*tp->t_fb->tfb_tcp_fb_init)(tp); | ||||
} | } | ||||
#ifdef STATS | |||||
if (V_tcp_perconn_stats_enable == 1) | |||||
tp->t_stats = stats_blob_alloc(V_tcp_perconn_stats_dflt_tpl, 0); | |||||
#endif | |||||
return (tp); /* XXX */ | return (tp); /* XXX */ | ||||
} | } | ||||
/* | /* | ||||
* Switch the congestion control algorithm back to NewReno for any active | * Switch the congestion control algorithm back to NewReno for any active | ||||
* control blocks using an algorithm which is about to go away. | * control blocks using an algorithm which is about to go away. | ||||
* This ensures the CC framework can allow the unload to proceed without leaving | * This ensures the CC framework can allow the unload to proceed without leaving | ||||
* any dangling pointers which would trigger a panic. | * any dangling pointers which would trigger a panic. | ||||
▲ Show 20 Lines • Show All 201 Lines • ▼ Show 20 Lines | #endif | ||||
/* Allow the CC algorithm to clean up after itself. */ | /* Allow the CC algorithm to clean up after itself. */ | ||||
if (CC_ALGO(tp)->cb_destroy != NULL) | if (CC_ALGO(tp)->cb_destroy != NULL) | ||||
CC_ALGO(tp)->cb_destroy(tp->ccv); | CC_ALGO(tp)->cb_destroy(tp->ccv); | ||||
CC_DATA(tp) = NULL; | CC_DATA(tp) = NULL; | ||||
#ifdef TCP_HHOOK | #ifdef TCP_HHOOK | ||||
khelp_destroy_osd(tp->osd); | khelp_destroy_osd(tp->osd); | ||||
#endif | |||||
#ifdef STATS | |||||
stats_blob_destroy(tp->t_stats); | |||||
#endif | #endif | ||||
CC_ALGO(tp) = NULL; | CC_ALGO(tp) = NULL; | ||||
inp->inp_ppcb = NULL; | inp->inp_ppcb = NULL; | ||||
if (tp->t_timers->tt_draincnt == 0) { | if (tp->t_timers->tt_draincnt == 0) { | ||||
/* We own the last reference on tcpcb, let's free it. */ | /* We own the last reference on tcpcb, let's free it. */ | ||||
#ifdef TCP_BLACKBOX | #ifdef TCP_BLACKBOX | ||||
tcp_log_tcpcbfini(tp); | tcp_log_tcpcbfini(tp); | ||||
▲ Show 20 Lines • Show All 1,471 Lines • Show Last 20 Lines |