Changeset View
Changeset View
Standalone View
Standalone View
head/sys/netinet/tcp_usrreq.c
Show First 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | |||||
#include <netinet6/ip6_var.h> | #include <netinet6/ip6_var.h> | ||||
#include <netinet6/scope6_var.h> | #include <netinet6/scope6_var.h> | ||||
#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/tcp_log_buf.h> | |||||
#include <netinet/tcpip.h> | #include <netinet/tcpip.h> | ||||
#include <netinet/cc/cc.h> | #include <netinet/cc/cc.h> | ||||
#include <netinet/tcp_fastopen.h> | #include <netinet/tcp_fastopen.h> | ||||
#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> | ||||
▲ Show 20 Lines • Show All 920 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
tp->snd_up = tp->snd_una + sbavail(&so->so_snd); | tp->snd_up = tp->snd_una + sbavail(&so->so_snd); | ||||
if (!(flags & PRUS_NOTREADY)) { | if (!(flags & PRUS_NOTREADY)) { | ||||
tp->t_flags |= TF_FORCEDATA; | tp->t_flags |= TF_FORCEDATA; | ||||
error = tp->t_fb->tfb_tcp_output(tp); | error = tp->t_fb->tfb_tcp_output(tp); | ||||
tp->t_flags &= ~TF_FORCEDATA; | tp->t_flags &= ~TF_FORCEDATA; | ||||
} | } | ||||
} | } | ||||
TCP_LOG_EVENT(tp, NULL, | |||||
&inp->inp_socket->so_rcv, | |||||
&inp->inp_socket->so_snd, | |||||
TCP_LOG_USERSEND, error, | |||||
0, NULL, false); | |||||
out: | out: | ||||
TCPDEBUG2((flags & PRUS_OOB) ? PRU_SENDOOB : | TCPDEBUG2((flags & PRUS_OOB) ? PRU_SENDOOB : | ||||
((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND)); | ((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND)); | ||||
TCP_PROBE2(debug__user, tp, (flags & PRUS_OOB) ? PRU_SENDOOB : | TCP_PROBE2(debug__user, tp, (flags & PRUS_OOB) ? PRU_SENDOOB : | ||||
((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND)); | ((flags & PRUS_EOF) ? PRU_SEND_EOF : PRU_SEND)); | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
if (flags & PRUS_EOF) | if (flags & PRUS_EOF) | ||||
INP_INFO_RUNLOCK(&V_tcbinfo); | INP_INFO_RUNLOCK(&V_tcbinfo); | ||||
▲ Show 20 Lines • Show All 491 Lines • ▼ Show 20 Lines | #endif | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
error = sooptcopyout(sopt, &fsn, sizeof fsn); | error = sooptcopyout(sopt, &fsn, sizeof fsn); | ||||
return (error); | return (error); | ||||
} | } | ||||
/* Pass in the INP locked, called must unlock it */ | /* Pass in the INP locked, called must unlock it */ | ||||
return (tp->t_fb->tfb_tcp_ctloutput(so, sopt, inp, tp)); | return (tp->t_fb->tfb_tcp_ctloutput(so, sopt, inp, tp)); | ||||
} | } | ||||
/* | |||||
* If this assert becomes untrue, we need to change the size of the buf | |||||
* variable in tcp_default_ctloutput(). | |||||
*/ | |||||
#ifdef CTASSERT | |||||
CTASSERT(TCP_CA_NAME_MAX <= TCP_LOG_ID_LEN); | |||||
CTASSERT(TCP_LOG_REASON_LEN <= TCP_LOG_ID_LEN); | |||||
#endif | |||||
int | int | ||||
tcp_default_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb *inp, struct tcpcb *tp) | tcp_default_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb *inp, struct tcpcb *tp) | ||||
{ | { | ||||
int error, opt, optval; | int error, opt, optval; | ||||
u_int ui; | u_int ui; | ||||
struct tcp_info ti; | struct tcp_info ti; | ||||
struct cc_algo *algo; | struct cc_algo *algo; | ||||
char *pbuf, buf[TCP_CA_NAME_MAX]; | char *pbuf, buf[TCP_LOG_ID_LEN]; | ||||
size_t len; | size_t len; | ||||
/* | /* | ||||
* For TCP_CCALGOOPT forward the control to CC module, for both | * For TCP_CCALGOOPT forward the control to CC module, for both | ||||
* SOPT_SET and SOPT_GET. | * SOPT_SET and SOPT_GET. | ||||
*/ | */ | ||||
switch (sopt->sopt_name) { | switch (sopt->sopt_name) { | ||||
case TCP_CCALGOOPT: | case TCP_CCALGOOPT: | ||||
▲ Show 20 Lines • Show All 265 Lines • ▼ Show 20 Lines | case TCP_FASTOPEN: { | ||||
} | } | ||||
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; | ||||
} | } | ||||
case TCP_LOG: | |||||
INP_WUNLOCK(inp); | |||||
error = sooptcopyin(sopt, &optval, sizeof optval, | |||||
sizeof optval); | |||||
if (error) | |||||
return (error); | |||||
INP_WLOCK_RECHECK(inp); | |||||
error = tcp_log_state_change(tp, optval); | |||||
goto unlock_and_done; | |||||
case TCP_LOGBUF: | |||||
INP_WUNLOCK(inp); | |||||
error = EINVAL; | |||||
break; | |||||
case TCP_LOGID: | |||||
INP_WUNLOCK(inp); | |||||
error = sooptcopyin(sopt, buf, TCP_LOG_ID_LEN - 1, 0); | |||||
if (error) | |||||
break; | |||||
buf[sopt->sopt_valsize] = '\0'; | |||||
INP_WLOCK_RECHECK(inp); | |||||
error = tcp_log_set_id(tp, buf); | |||||
/* tcp_log_set_id() unlocks the INP. */ | |||||
break; | |||||
case TCP_LOGDUMP: | |||||
case TCP_LOGDUMPID: | |||||
INP_WUNLOCK(inp); | |||||
error = | |||||
sooptcopyin(sopt, buf, TCP_LOG_REASON_LEN - 1, 0); | |||||
if (error) | |||||
break; | |||||
buf[sopt->sopt_valsize] = '\0'; | |||||
INP_WLOCK_RECHECK(inp); | |||||
if (sopt->sopt_name == TCP_LOGDUMP) { | |||||
error = tcp_log_dump_tp_logbuf(tp, buf, | |||||
M_WAITOK, true); | |||||
INP_WUNLOCK(inp); | |||||
} else { | |||||
tcp_log_dump_tp_bucket_logbufs(tp, buf); | |||||
/* | |||||
* tcp_log_dump_tp_bucket_logbufs() drops the | |||||
* INP lock. | |||||
*/ | |||||
} | |||||
break; | |||||
default: | default: | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
error = ENOPROTOOPT; | error = ENOPROTOOPT; | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
case SOPT_GET: | case SOPT_GET: | ||||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | case TCP_PCAP_IN: | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
error = sooptcopyout(sopt, &optval, sizeof optval); | error = sooptcopyout(sopt, &optval, sizeof optval); | ||||
break; | break; | ||||
#endif | #endif | ||||
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; | |||||
case TCP_LOG: | |||||
optval = tp->t_logstate; | |||||
INP_WUNLOCK(inp); | |||||
error = sooptcopyout(sopt, &optval, sizeof(optval)); | |||||
break; | |||||
case TCP_LOGBUF: | |||||
/* tcp_log_getlogbuf() does INP_WUNLOCK(inp) */ | |||||
error = tcp_log_getlogbuf(sopt, tp); | |||||
break; | |||||
case TCP_LOGID: | |||||
len = tcp_log_get_id(tp, buf); | |||||
INP_WUNLOCK(inp); | |||||
error = sooptcopyout(sopt, buf, len + 1); | |||||
break; | |||||
case TCP_LOGDUMP: | |||||
case TCP_LOGDUMPID: | |||||
INP_WUNLOCK(inp); | |||||
error = EINVAL; | |||||
break; | break; | ||||
default: | default: | ||||
INP_WUNLOCK(inp); | INP_WUNLOCK(inp); | ||||
error = ENOPROTOOPT; | error = ENOPROTOOPT; | ||||
break; | break; | ||||
} | } | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 468 Lines • Show Last 20 Lines |