Changeset View
Changeset View
Standalone View
Standalone View
sys/netinet/tcp_usrreq.c
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Lines | |||||
#endif | #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> | #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 319 Lines • ▼ Show 20 Lines | if (error == 0) { | ||||
solisten_proto(so, backlog); | solisten_proto(so, backlog); | ||||
#ifdef TCP_OFFLOAD | #ifdef TCP_OFFLOAD | ||||
if ((so->so_options & SO_NO_OFFLOAD) == 0) | if ((so->so_options & SO_NO_OFFLOAD) == 0) | ||||
tcp_offload_listen_start(tp); | tcp_offload_listen_start(tp); | ||||
#endif | #endif | ||||
} | } | ||||
SOCK_UNLOCK(so); | SOCK_UNLOCK(so); | ||||
#ifdef TCP_RFC7413 | |||||
if (IS_FASTOPEN(tp->t_flags)) | if (IS_FASTOPEN(tp->t_flags)) | ||||
tp->t_tfo_pending = tcp_fastopen_alloc_counter(); | tp->t_tfo_pending = tcp_fastopen_alloc_counter(); | ||||
#endif | |||||
out: | out: | ||||
TCPDEBUG2(PRU_LISTEN); | TCPDEBUG2(PRU_LISTEN); | ||||
TCP_PROBE2(debug__user, tp, PRU_LISTEN); | TCP_PROBE2(debug__user, tp, PRU_LISTEN); | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
return (error); | return (error); | ||||
} | } | ||||
#endif /* INET */ | #endif /* INET */ | ||||
Show All 30 Lines | if (error == 0) { | ||||
solisten_proto(so, backlog); | solisten_proto(so, backlog); | ||||
#ifdef TCP_OFFLOAD | #ifdef TCP_OFFLOAD | ||||
if ((so->so_options & SO_NO_OFFLOAD) == 0) | if ((so->so_options & SO_NO_OFFLOAD) == 0) | ||||
tcp_offload_listen_start(tp); | tcp_offload_listen_start(tp); | ||||
#endif | #endif | ||||
} | } | ||||
SOCK_UNLOCK(so); | SOCK_UNLOCK(so); | ||||
#ifdef TCP_RFC7413 | |||||
if (IS_FASTOPEN(tp->t_flags)) | if (IS_FASTOPEN(tp->t_flags)) | ||||
tp->t_tfo_pending = tcp_fastopen_alloc_counter(); | tp->t_tfo_pending = tcp_fastopen_alloc_counter(); | ||||
#endif | |||||
out: | out: | ||||
TCPDEBUG2(PRU_LISTEN); | TCPDEBUG2(PRU_LISTEN); | ||||
TCP_PROBE2(debug__user, tp, PRU_LISTEN); | TCP_PROBE2(debug__user, tp, PRU_LISTEN); | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
return (error); | return (error); | ||||
} | } | ||||
#endif /* INET6 */ | #endif /* INET6 */ | ||||
▲ Show 20 Lines • Show All 348 Lines • ▼ Show 20 Lines | tcp_usr_rcvd(struct socket *so, int flags) | ||||
KASSERT(inp != NULL, ("tcp_usr_rcvd: inp == NULL")); | KASSERT(inp != NULL, ("tcp_usr_rcvd: inp == NULL")); | ||||
INP_WLOCK(inp); | INP_WLOCK(inp); | ||||
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { | ||||
error = ECONNRESET; | error = ECONNRESET; | ||||
goto out; | goto out; | ||||
} | } | ||||
tp = intotcpcb(inp); | tp = intotcpcb(inp); | ||||
TCPDEBUG1(); | TCPDEBUG1(); | ||||
#ifdef TCP_RFC7413 | |||||
/* | /* | ||||
* For passively-created TFO connections, don't attempt a window | * For passively-created TFO connections, don't attempt a window | ||||
* update while still in SYN_RECEIVED as this may trigger an early | * update while still in SYN_RECEIVED as this may trigger an early | ||||
* SYN|ACK. It is preferable to have the SYN|ACK be sent along with | * SYN|ACK. It is preferable to have the SYN|ACK be sent along with | ||||
* application response data, or failing that, when the DELACK timer | * application response data, or failing that, when the DELACK timer | ||||
* expires. | * expires. | ||||
*/ | */ | ||||
if (IS_FASTOPEN(tp->t_flags) && | if (IS_FASTOPEN(tp->t_flags) && | ||||
(tp->t_state == TCPS_SYN_RECEIVED)) | (tp->t_state == TCPS_SYN_RECEIVED)) | ||||
goto out; | goto out; | ||||
#endif | |||||
#ifdef TCP_OFFLOAD | #ifdef TCP_OFFLOAD | ||||
if (tp->t_flags & TF_TOE) | if (tp->t_flags & TF_TOE) | ||||
tcp_offload_rcvd(tp); | tcp_offload_rcvd(tp); | ||||
else | else | ||||
#endif | #endif | ||||
tp->t_fb->tfb_tcp_output(tp); | tp->t_fb->tfb_tcp_output(tp); | ||||
out: | out: | ||||
▲ Show 20 Lines • Show All 74 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)) | if (IS_FASTOPEN(tp->t_flags)) | ||||
tcp_fastopen_connect(tp); | tcp_fastopen_connect(tp); | ||||
else | 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. | ||||
Show All 32 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 | * Not going to contemplate SYN|URG | ||||
*/ | */ | ||||
if (IS_FASTOPEN(tp->t_flags)) | if (IS_FASTOPEN(tp->t_flags)) | ||||
tp->t_flags &= ~TF_FASTOPEN; | 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 755 Lines • ▼ Show 20 Lines | case TCP_PCAP_IN: | ||||
tcp_pcap_set_sock_max(TCP_PCAP_OUT ? | tcp_pcap_set_sock_max(TCP_PCAP_OUT ? | ||||
&(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 | |||||
case TCP_FASTOPEN: { | case TCP_FASTOPEN: { | ||||
struct tcp_fastopen tfo_optval; | struct tcp_fastopen tfo_optval; | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
if (!V_tcp_fastopen_client_enable && | if (!V_tcp_fastopen_client_enable && | ||||
!V_tcp_fastopen_server_enable) | !V_tcp_fastopen_server_enable) | ||||
return (EPERM); | return (EPERM); | ||||
Show All 30 Lines | case TCP_FASTOPEN: { | ||||
TCP_FASTOPEN_PSK_LEN; | TCP_FASTOPEN_PSK_LEN; | ||||
} | } | ||||
tp->t_flags |= TF_FASTOPEN; | 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 | |||||
default: | default: | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
error = ENOPROTOOPT; | error = ENOPROTOOPT; | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | #ifdef TCPPCAP | ||||
case TCP_PCAP_OUT: | case TCP_PCAP_OUT: | ||||
case TCP_PCAP_IN: | case TCP_PCAP_IN: | ||||
optval = tcp_pcap_get_sock_max(TCP_PCAP_OUT ? | optval = tcp_pcap_get_sock_max(TCP_PCAP_OUT ? | ||||
&(tp->t_outpkts) : &(tp->t_inpkts)); | &(tp->t_outpkts) : &(tp->t_inpkts)); | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
error = sooptcopyout(sopt, &optval, sizeof optval); | error = sooptcopyout(sopt, &optval, sizeof optval); | ||||
break; | break; | ||||
#endif | #endif | ||||
#ifdef TCP_RFC7413 | |||||
case TCP_FASTOPEN: | case TCP_FASTOPEN: | ||||
optval = tp->t_flags & TF_FASTOPEN; | optval = tp->t_flags & TF_FASTOPEN; | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
error = sooptcopyout(sopt, &optval, sizeof optval); | error = sooptcopyout(sopt, &optval, sizeof optval); | ||||
break; | break; | ||||
#endif | |||||
default: | default: | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
error = ENOPROTOOPT; | error = ENOPROTOOPT; | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
return (error); | return (error); | ||||
▲ Show 20 Lines • Show All 467 Lines • Show Last 20 Lines |