Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_subr.c
Show First 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | |||||
#include <netinet/tcp_timer.h> | #include <netinet/tcp_timer.h> | ||||
#include <netinet/tcp_var.h> | #include <netinet/tcp_var.h> | ||||
#include <netinet/tcp_syncache.h> | #include <netinet/tcp_syncache.h> | ||||
#include <netinet/cc/cc.h> | #include <netinet/cc/cc.h> | ||||
#ifdef INET6 | #ifdef INET6 | ||||
#include <netinet6/tcp6_var.h> | #include <netinet6/tcp6_var.h> | ||||
#endif | #endif | ||||
#include <netinet/tcpip.h> | #include <netinet/tcpip.h> | ||||
#ifdef TCP_RFC7413 | |||||
#include <netinet/tcp_fastopen.h> | #include <netinet/tcp_fastopen.h> | ||||
#endif | |||||
#ifdef TCPPCAP | #ifdef TCPPCAP | ||||
#include <netinet/tcp_pcap.h> | #include <netinet/tcp_pcap.h> | ||||
#endif | #endif | ||||
#ifdef TCPDEBUG | #ifdef TCPDEBUG | ||||
#include <netinet/tcp_debug.h> | #include <netinet/tcp_debug.h> | ||||
#endif | #endif | ||||
#ifdef INET6 | #ifdef INET6 | ||||
#include <netinet6/ip6protosw.h> | #include <netinet6/ip6protosw.h> | ||||
▲ Show 20 Lines • Show All 632 Lines • ▼ Show 20 Lines | #endif | ||||
tcp_tw_init(); | tcp_tw_init(); | ||||
syncache_init(); | syncache_init(); | ||||
tcp_hc_init(); | tcp_hc_init(); | ||||
TUNABLE_INT_FETCH("net.inet.tcp.sack.enable", &V_tcp_do_sack); | TUNABLE_INT_FETCH("net.inet.tcp.sack.enable", &V_tcp_do_sack); | ||||
V_sack_hole_zone = uma_zcreate("sackhole", sizeof(struct sackhole), | V_sack_hole_zone = uma_zcreate("sackhole", sizeof(struct sackhole), | ||||
NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); | NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); | ||||
#ifdef TCP_RFC7413 | |||||
tcp_fastopen_init(); | tcp_fastopen_init(); | ||||
#endif | |||||
/* Skip initialization of globals for non-default instances. */ | /* Skip initialization of globals for non-default instances. */ | ||||
if (!IS_DEFAULT_VNET(curvnet)) | if (!IS_DEFAULT_VNET(curvnet)) | ||||
return; | return; | ||||
tcp_reass_global_init(); | tcp_reass_global_init(); | ||||
/* XXX virtualize those bellow? */ | /* XXX virtualize those bellow? */ | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | #endif | ||||
tcp_hc_destroy(); | tcp_hc_destroy(); | ||||
syncache_destroy(); | syncache_destroy(); | ||||
tcp_tw_destroy(); | tcp_tw_destroy(); | ||||
in_pcbinfo_destroy(&V_tcbinfo); | in_pcbinfo_destroy(&V_tcbinfo); | ||||
/* tcp_discardcb() clears the sack_holes up. */ | /* tcp_discardcb() clears the sack_holes up. */ | ||||
uma_zdestroy(V_sack_hole_zone); | uma_zdestroy(V_sack_hole_zone); | ||||
uma_zdestroy(V_tcpcb_zone); | uma_zdestroy(V_tcpcb_zone); | ||||
#ifdef TCP_RFC7413 | |||||
/* | /* | ||||
* Cannot free the zone until all tcpcbs are released as we attach | * Cannot free the zone until all tcpcbs are released as we attach | ||||
* the allocations to them. | * the allocations to them. | ||||
*/ | */ | ||||
tcp_fastopen_destroy(); | tcp_fastopen_destroy(); | ||||
#endif | |||||
#ifdef TCP_HHOOK | #ifdef TCP_HHOOK | ||||
error = hhook_head_deregister(V_tcp_hhh[HHOOK_TCP_EST_IN]); | error = hhook_head_deregister(V_tcp_hhh[HHOOK_TCP_EST_IN]); | ||||
if (error != 0) { | if (error != 0) { | ||||
printf("%s: WARNING: unable to deregister helper hook " | printf("%s: WARNING: unable to deregister helper hook " | ||||
"type=%d, id=%d: error %d returned\n", __func__, | "type=%d, id=%d: error %d returned\n", __func__, | ||||
HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, error); | HHOOK_TYPE_TCP, HHOOK_TCP_EST_IN, error); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 780 Lines • ▼ Show 20 Lines | tcp_close(struct tcpcb *tp) | ||||
INP_INFO_LOCK_ASSERT(&V_tcbinfo); | INP_INFO_LOCK_ASSERT(&V_tcbinfo); | ||||
INP_WLOCK_ASSERT(inp); | INP_WLOCK_ASSERT(inp); | ||||
#ifdef TCP_OFFLOAD | #ifdef TCP_OFFLOAD | ||||
if (tp->t_state == TCPS_LISTEN) | if (tp->t_state == TCPS_LISTEN) | ||||
tcp_offload_listen_stop(tp); | tcp_offload_listen_stop(tp); | ||||
#endif | #endif | ||||
#ifdef TCP_RFC7413 | |||||
/* | /* | ||||
* This releases the TFO pending counter resource for TFO listen | * This releases the TFO pending counter resource for TFO listen | ||||
* sockets as well as passively-created TFO sockets that transition | * sockets as well as passively-created TFO sockets that transition | ||||
* from SYN_RECEIVED to CLOSED. | * from SYN_RECEIVED to CLOSED. | ||||
*/ | */ | ||||
if (tp->t_tfo_pending) { | if (tp->t_tfo_pending) { | ||||
tcp_fastopen_decrement_counter(tp->t_tfo_pending); | tcp_fastopen_decrement_counter(tp->t_tfo_pending); | ||||
tp->t_tfo_pending = NULL; | tp->t_tfo_pending = NULL; | ||||
} | } | ||||
#endif | |||||
in_pcbdrop(inp); | in_pcbdrop(inp); | ||||
TCPSTAT_INC(tcps_closed); | TCPSTAT_INC(tcps_closed); | ||||
if (tp->t_state != TCPS_CLOSED) | if (tp->t_state != TCPS_CLOSED) | ||||
tcp_state_change(tp, TCPS_CLOSED); | tcp_state_change(tp, TCPS_CLOSED); | ||||
KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL")); | KASSERT(inp->inp_socket != NULL, ("tcp_close: inp_socket NULL")); | ||||
so = inp->inp_socket; | so = inp->inp_socket; | ||||
soisdisconnected(so); | soisdisconnected(so); | ||||
if (inp->inp_flags & INP_SOCKREF) { | if (inp->inp_flags & INP_SOCKREF) { | ||||
▲ Show 20 Lines • Show All 733 Lines • ▼ Show 20 Lines | tcp_drop_syn_sent(struct inpcb *inp, int errno) | ||||
if ((inp->inp_flags & INP_TIMEWAIT) || | if ((inp->inp_flags & INP_TIMEWAIT) || | ||||
(inp->inp_flags & INP_DROPPED)) | (inp->inp_flags & INP_DROPPED)) | ||||
return (inp); | return (inp); | ||||
tp = intotcpcb(inp); | tp = intotcpcb(inp); | ||||
if (tp->t_state != TCPS_SYN_SENT) | if (tp->t_state != TCPS_SYN_SENT) | ||||
return (inp); | return (inp); | ||||
#ifdef TCP_RFC7413 | |||||
if (IS_FASTOPEN(tp->t_flags)) | if (IS_FASTOPEN(tp->t_flags)) | ||||
tcp_fastopen_disable_path(tp); | tcp_fastopen_disable_path(tp); | ||||
#endif | |||||
tp = tcp_drop(tp, errno); | tp = tcp_drop(tp, errno); | ||||
if (tp != NULL) | if (tp != NULL) | ||||
return (inp); | return (inp); | ||||
else | else | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 477 Lines • Show Last 20 Lines |