Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_usrreq.c
Show First 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
#include <netinet/in_var.h> | #include <netinet/in_var.h> | ||||
#include <netinet/ip_var.h> | #include <netinet/ip_var.h> | ||||
#ifdef INET6 | #ifdef INET6 | ||||
#include <netinet/ip6.h> | #include <netinet/ip6.h> | ||||
#include <netinet6/in6_pcb.h> | #include <netinet6/in6_pcb.h> | ||||
#include <netinet6/ip6_var.h> | #include <netinet6/ip6_var.h> | ||||
#include <netinet6/scope6_var.h> | #include <netinet6/scope6_var.h> | ||||
#endif | #endif | ||||
#ifdef TCP_RFC7413 | |||||
#include <netinet/tcp_fastopen.h> | |||||
#endif | |||||
#include <netinet/tcp.h> | #include <netinet/tcp.h> | ||||
#include <netinet/tcp_fsm.h> | #include <netinet/tcp_fsm.h> | ||||
#include <netinet/tcp_seq.h> | #include <netinet/tcp_seq.h> | ||||
#include <netinet/tcp_timer.h> | #include <netinet/tcp_timer.h> | ||||
#include <netinet/tcp_var.h> | #include <netinet/tcp_var.h> | ||||
#include <netinet/tcpip.h> | #include <netinet/tcpip.h> | ||||
#include <netinet/cc/cc.h> | #include <netinet/cc/cc.h> | ||||
#ifdef TCP_RFC7413 | |||||
#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 TCP_OFFLOAD | #ifdef TCP_OFFLOAD | ||||
#include <netinet/tcp_offload.h> | #include <netinet/tcp_offload.h> | ||||
▲ Show 20 Lines • Show All 839 Lines • ▼ Show 20 Lines | |||||
#if defined(INET6) && defined(INET) | #if defined(INET6) && defined(INET) | ||||
else | else | ||||
#endif | #endif | ||||
#ifdef INET | #ifdef INET | ||||
error = tcp_connect(tp, nam, td); | error = tcp_connect(tp, nam, td); | ||||
#endif | #endif | ||||
if (error) | if (error) | ||||
goto out; | goto out; | ||||
#ifdef TCP_RFC7413 | |||||
if (IS_FASTOPEN(tp->t_flags)) | |||||
tcp_fastopen_connect(tp); | |||||
else | |||||
#endif | |||||
{ | |||||
tp->snd_wnd = TTCP_CLIENT_SND_WND; | tp->snd_wnd = TTCP_CLIENT_SND_WND; | ||||
tcp_mss(tp, -1); | tcp_mss(tp, -1); | ||||
} | } | ||||
} | |||||
if (flags & PRUS_EOF) { | if (flags & PRUS_EOF) { | ||||
/* | /* | ||||
* Close the send side of the connection after | * Close the send side of the connection after | ||||
* the data is sent. | * the data is sent. | ||||
*/ | */ | ||||
INP_INFO_RLOCK_ASSERT(&V_tcbinfo); | INP_INFO_RLOCK_ASSERT(&V_tcbinfo); | ||||
socantsendmore(so); | socantsendmore(so); | ||||
tcp_usrclosed(tp); | tcp_usrclosed(tp); | ||||
Show All 28 Lines | #endif | ||||
sbappendstream_locked(&so->so_snd, m, flags); | sbappendstream_locked(&so->so_snd, m, flags); | ||||
SOCKBUF_UNLOCK(&so->so_snd); | SOCKBUF_UNLOCK(&so->so_snd); | ||||
if (nam && tp->t_state < TCPS_SYN_SENT) { | if (nam && tp->t_state < TCPS_SYN_SENT) { | ||||
/* | /* | ||||
* Do implied connect if not yet connected, | * Do implied connect if not yet connected, | ||||
* initialize window to default value, and | * initialize window to default value, and | ||||
* initialize maxseg using peer's cached MSS. | * initialize maxseg using peer's cached MSS. | ||||
*/ | */ | ||||
#ifdef TCP_RFC7413 | |||||
/* | |||||
* Not going to contemplate SYN|URG | |||||
*/ | |||||
if (IS_FASTOPEN(tp->t_flags)) | |||||
tp->t_flags &= ~TF_FASTOPEN; | |||||
#endif | |||||
#ifdef INET6 | #ifdef INET6 | ||||
if (isipv6) | if (isipv6) | ||||
error = tcp6_connect(tp, nam, td); | error = tcp6_connect(tp, nam, td); | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
#if defined(INET6) && defined(INET) | #if defined(INET6) && defined(INET) | ||||
else | else | ||||
#endif | #endif | ||||
#ifdef INET | #ifdef INET | ||||
▲ Show 20 Lines • Show All 756 Lines • ▼ Show 20 Lines | case TCP_PCAP_IN: | ||||
&(tp->t_outpkts) : &(tp->t_inpkts), | &(tp->t_outpkts) : &(tp->t_inpkts), | ||||
optval); | optval); | ||||
else | else | ||||
error = EINVAL; | error = EINVAL; | ||||
goto unlock_and_done; | goto unlock_and_done; | ||||
#endif | #endif | ||||
#ifdef TCP_RFC7413 | #ifdef TCP_RFC7413 | ||||
case TCP_FASTOPEN: | case TCP_FASTOPEN: { | ||||
struct tcp_fastopen tfo_optval; | |||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
if (!V_tcp_fastopen_enabled) | if (!V_tcp_fastopen_client_enable && | ||||
!V_tcp_fastopen_server_enable) | |||||
return (EPERM); | return (EPERM); | ||||
error = sooptcopyin(sopt, &optval, sizeof optval, | error = sooptcopyin(sopt, &tfo_optval, | ||||
sizeof optval); | sizeof(tfo_optval), sizeof(int)); | ||||
if (error) | if (error) | ||||
return (error); | return (error); | ||||
INP_WLOCK_RECHECK(inp); | INP_WLOCK_RECHECK(inp); | ||||
if (optval) { | if (tfo_optval.enable) { | ||||
if (tp->t_state == TCPS_LISTEN) { | |||||
if (!V_tcp_fastopen_server_enable) { | |||||
error = EPERM; | |||||
goto unlock_and_done; | |||||
} | |||||
tp->t_flags |= TF_FASTOPEN; | tp->t_flags |= TF_FASTOPEN; | ||||
if ((tp->t_state == TCPS_LISTEN) && | if (tp->t_tfo_pending == NULL) | ||||
(tp->t_tfo_pending == NULL)) | |||||
tp->t_tfo_pending = | tp->t_tfo_pending = | ||||
tcp_fastopen_alloc_counter(); | tcp_fastopen_alloc_counter(); | ||||
} else { | |||||
/* | |||||
* If a pre-shared key was provided, | |||||
* stash it in the client cookie | |||||
* field of the tcpcb for use during | |||||
* connect. | |||||
*/ | |||||
if (sopt->sopt_valsize == | |||||
sizeof(tfo_optval)) { | |||||
memcpy(tp->t_tfo_cookie.client, | |||||
tfo_optval.psk, | |||||
TCP_FASTOPEN_PSK_LEN); | |||||
tp->t_tfo_client_cookie_len = | |||||
TCP_FASTOPEN_PSK_LEN; | |||||
} | |||||
tp->t_flags |= TF_FASTOPEN; | |||||
} | |||||
} else | } else | ||||
tp->t_flags &= ~TF_FASTOPEN; | tp->t_flags &= ~TF_FASTOPEN; | ||||
goto unlock_and_done; | goto unlock_and_done; | ||||
} | |||||
#endif | #endif | ||||
default: | default: | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
error = ENOPROTOOPT; | error = ENOPROTOOPT; | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 557 Lines • Show Last 20 Lines |