FreeBSD kernel IPv4 code
tcp_usrreq.c File Reference
#include <sys/cdefs.h>
#include "opt_ddb.h"
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_ipsec.h"
#include "opt_kern_tls.h"
#include "opt_tcpdebug.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/arb.h>
#include <sys/limits.h>
#include <sys/malloc.h>
#include <sys/refcount.h>
#include <sys/kernel.h>
#include <sys/ktls.h>
#include <sys/qmath.h>
#include <sys/sysctl.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/protosw.h>
#include <sys/proc.h>
#include <sys/jail.h>
#include <sys/stats.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/route.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_kdtrace.h>
#include <netinet/in_pcb.h>
#include <netinet/in_systm.h>
#include <netinet/in_var.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_seq.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp_log_buf.h>
#include <netinet/tcpip.h>
#include <netinet/cc/cc.h>
#include <netinet/tcp_fastopen.h>
#include <netinet/tcp_hpts.h>
#include <netipsec/ipsec_support.h>
#include <vm/vm.h>
#include <vm/vm_param.h>
#include <vm/pmap.h>
#include <vm/vm_extern.h>
#include <vm/vm_map.h>
#include <vm/vm_page.h>

Go to the source code of this file.

Macros

#define TCPDEBUG0
 
#define TCPDEBUG1()
 
#define TCPDEBUG2(req)
 
#define V_tcp_require_unique_port   VNET(tcp_require_unique_port)
 
#define INP_WLOCK_RECHECK_CLEANUP(inp, cleanup)
 
#define INP_WLOCK_RECHECK(inp)   INP_WLOCK_RECHECK_CLEANUP((inp), /* noop */)
 

Functions

 __FBSDID ("$FreeBSD$")
 
static void tcp_disconnect (struct tcpcb *)
 
static void tcp_usrclosed (struct tcpcb *)
 
static void tcp_fill_info (struct tcpcb *, struct tcp_info *)
 
static int tcp_pru_options_support (struct tcpcb *tp, int flags)
 
 VNET_DEFINE (int, tcp_require_unique_port)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, require_unique_port, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_require_unique_port), 0, "Require globally-unique ephemeral port for outgoing connections")
 
static int tcp_usr_attach (struct socket *so, int proto, struct thread *td)
 
static void tcp_usr_detach (struct socket *so)
 
static int tcp_usr_disconnect (struct socket *so)
 
static int tcp_usr_shutdown (struct socket *so)
 
static int tcp_usr_rcvd (struct socket *so, int flags)
 
static int tcp_usr_send (struct socket *so, int flags, struct mbuf *m, struct sockaddr *nam, struct mbuf *control, struct thread *td)
 
static int tcp_usr_ready (struct socket *so, struct mbuf *m, int count)
 
static void tcp_usr_abort (struct socket *so)
 
static void tcp_usr_close (struct socket *so)
 
static int tcp_usr_rcvoob (struct socket *so, struct mbuf *m, int flags)
 
int tcp_ctloutput_set (struct inpcb *inp, struct sockopt *sopt)
 
static int tcp_ctloutput_get (struct inpcb *inp, struct sockopt *sopt)
 
int tcp_ctloutput (struct socket *so, struct sockopt *sopt)
 
static int tcp_set_cc_mod (struct inpcb *inp, struct sockopt *sopt)
 
int tcp_default_ctloutput (struct inpcb *inp, struct sockopt *sopt)
 

Variables

struct cc_algo newreno_cc_algo
 

Macro Definition Documentation

◆ INP_WLOCK_RECHECK

#define INP_WLOCK_RECHECK (   inp)    INP_WLOCK_RECHECK_CLEANUP((inp), /* noop */)

Definition at line 1714 of file tcp_usrreq.c.

◆ INP_WLOCK_RECHECK_CLEANUP

#define INP_WLOCK_RECHECK_CLEANUP (   inp,
  cleanup 
)
Value:
do { \
INP_WLOCK(inp); \
if (inp->inp_flags & (INP_TIMEWAIT | INP_DROPPED)) { \
INP_WUNLOCK(inp); \
cleanup; \
return (ECONNRESET); \
} \
tp = intotcpcb(inp); \
} while(0)
#define INP_TIMEWAIT
Definition: in_pcb.h:644
#define INP_DROPPED
Definition: in_pcb.h:646
#define intotcpcb(ip)
Definition: tcp_var.h:645

Definition at line 1705 of file tcp_usrreq.c.

◆ TCPDEBUG0

#define TCPDEBUG0

Definition at line 144 of file tcp_usrreq.c.

◆ TCPDEBUG1

#define TCPDEBUG1 ( )

Definition at line 145 of file tcp_usrreq.c.

◆ TCPDEBUG2

#define TCPDEBUG2 (   req)

Definition at line 146 of file tcp_usrreq.c.

◆ V_tcp_require_unique_port

#define V_tcp_require_unique_port   VNET(tcp_require_unique_port)

Definition at line 157 of file tcp_usrreq.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ SYSCTL_INT()

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
require_unique_port  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_require_unique_port,
,
"Require globally-unique ephemeral port for outgoing connections"   
)

◆ tcp_ctloutput()

int tcp_ctloutput ( struct socket *  so,
struct sockopt *  sopt 
)

Definition at line 1944 of file tcp_usrreq.c.

References INP_DROPPED, inpcb::inp_flags, INP_TIMEWAIT, INP_WLOCK, INP_WUNLOCK, sotoinpcb, tcp_ctloutput_get(), and tcp_ctloutput_set().

Here is the call graph for this function:

◆ tcp_ctloutput_get()

◆ tcp_ctloutput_set()

◆ tcp_default_ctloutput()

int tcp_default_ctloutput ( struct inpcb inp,
struct sockopt *  sopt 
)

Definition at line 2120 of file tcp_usrreq.c.

References CC_ALGO, CC_ALGOOPT_LIMIT, tcpcb::ccv, tcpcb::client, in_pcblbgroup_numa(), INP_DROPPED, inpcb::inp_flags, INP_IPV6PROTO, inpcb::inp_socket, INP_TIMEWAIT, inpcb::inp_vflag, INP_WLOCK_ASSERT, INP_WLOCK_RECHECK, INP_WLOCK_RECHECK_CLEANUP, INP_WUNLOCK, intotcpcb, IPPROTO_IP, tcpcb::t_flags, tcpcb::t_keepcnt, tcpcb::t_keepidle, tcpcb::t_keepinit, tcpcb::t_keepintvl, tcpcb::t_logstate, tcpcb::t_maxseg, tcpcb::t_port, tcpcb::t_state, tcpcb::t_stats, tcpcb::t_tfo_client_cookie_len, tcpcb::t_tfo_cookie, tcpcb::t_tfo_pending, tcp6_use_min_mtu(), tcp_fastopen_alloc_counter(), tcp_fill_info(), tcp_log_dump_tp_bucket_logbufs(), tcp_log_dump_tp_logbuf(), tcp_log_get_id(), tcp_log_getlogbuf(), TCP_LOG_REASON_LEN, tcp_log_set_id(), tcp_log_state_change(), TCP_NODELAY, tcp_offload_ctloutput(), tcp_pcap_get_sock_max(), tcp_pcap_set_sock_max(), tcp_set_cc_mod(), tcp_timer_activate(), TCP_TUNNELING_PORT_MAX, TCP_TUNNELING_PORT_MIN, TCPS_CLOSED, TCPS_CLOSING, TCPS_FIN_WAIT_2, TCPS_HAVEESTABLISHED, TCPS_LISTEN, TCPS_SYN_RECEIVED, TCPS_SYN_SENT, TF_FASTOPEN, TF_LRD, TF_NODELAY, TF_NOOPT, TF_NOPUSH, TF_TOE, TP_KEEPCNT, TP_KEEPIDLE, TP_KEEPINIT, TP_KEEPINTVL, TP_MAXIDLE, TT_2MSL, TT_KEEP, V_tcp_fastopen_client_enable, V_tcp_fastopen_server_enable, V_tcp_minmss, and V_tcp_udp_tunneling_port.

Referenced by bbr_get_sockopt(), bbr_set_sockopt(), rack_get_sockopt(), and rack_set_sockopt().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcp_disconnect()

static void tcp_disconnect ( struct tcpcb tp)
static

Definition at line 2761 of file tcp_usrreq.c.

References INP_DROPPED, inpcb::inp_flags, inpcb::inp_socket, INP_WLOCK_ASSERT, IS_FASTOPEN, tcpcb::t_flags, tcpcb::t_inpcb, tcpcb::t_state, tcp_close(), tcp_drop(), tcp_usrclosed(), TCPS_ESTABLISHED, and TCPS_LISTEN.

Referenced by tcp_usr_close(), and tcp_usr_disconnect().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcp_fill_info()

◆ tcp_pru_options_support()

static int tcp_pru_options_support ( struct tcpcb tp,
int  flags 
)
static

Definition at line 1409 of file tcp_usrreq.c.

References tcpcb::t_fb, and tcp_function_block::tfb_pru_options.

Referenced by tcp_usr_rcvoob(), and tcp_usr_send().

Here is the caller graph for this function:

◆ tcp_set_cc_mod()

static int tcp_set_cc_mod ( struct inpcb inp,
struct sockopt *  sopt 
)
static

◆ tcp_usr_abort()

static void tcp_usr_abort ( struct socket *  so)
static

Definition at line 1328 of file tcp_usrreq.c.

References INP_DROPPED, inpcb::inp_flags, inpcb::inp_socket, INP_SOCKREF, INP_TIMEWAIT, INP_WLOCK, INP_WUNLOCK, intotcpcb, sotoinpcb, tcp_drop(), TCP_PROBE2, TCPDEBUG0, TCPDEBUG1, and TCPDEBUG2.

Here is the call graph for this function:

◆ tcp_usr_attach()

static int tcp_usr_attach ( struct socket *  so,
int  proto,
struct thread *  td 
)
static

◆ tcp_usr_close()

static void tcp_usr_close ( struct socket *  so)
static

Definition at line 1371 of file tcp_usrreq.c.

References INP_DROPPED, inpcb::inp_flags, inpcb::inp_socket, INP_SOCKREF, INP_TIMEWAIT, INP_WLOCK, INP_WUNLOCK, intotcpcb, sotoinpcb, tcp_disconnect(), TCP_PROBE2, TCPDEBUG0, TCPDEBUG1, and TCPDEBUG2.

Here is the call graph for this function:

◆ tcp_usr_detach()

static void tcp_usr_detach ( struct socket *  so)
static

◆ tcp_usr_disconnect()

static int tcp_usr_disconnect ( struct socket *  so)
static

Definition at line 756 of file tcp_usrreq.c.

References INP_DROPPED, inpcb::inp_flags, INP_TIMEWAIT, INP_WLOCK, INP_WUNLOCK, intotcpcb, sotoinpcb, tcp_disconnect(), TCP_PROBE2, TCPDEBUG0, TCPDEBUG1, and TCPDEBUG2.

Here is the call graph for this function:

◆ tcp_usr_rcvd()

static int tcp_usr_rcvd ( struct socket *  so,
int  flags 
)
static

◆ tcp_usr_rcvoob()

static int tcp_usr_rcvoob ( struct socket *  so,
struct mbuf *  m,
int  flags 
)
static

◆ tcp_usr_ready()

static int tcp_usr_ready ( struct socket *  so,
struct mbuf *  m,
int  count 
)
static

◆ tcp_usr_send()

◆ tcp_usr_shutdown()

static int tcp_usr_shutdown ( struct socket *  so)
static

Definition at line 892 of file tcp_usrreq.c.

References INP_DROPPED, inpcb::inp_flags, INP_TIMEWAIT, INP_WLOCK, INP_WUNLOCK, intotcpcb, sotoinpcb, TCP_PROBE2, tcp_usrclosed(), TCPDEBUG0, TCPDEBUG1, and TCPDEBUG2.

Here is the call graph for this function:

◆ tcp_usrclosed()

◆ VNET_DEFINE()

VNET_DEFINE ( int  ,
tcp_require_unique_port   
)
pure virtual

Variable Documentation

◆ newreno_cc_algo

struct cc_algo newreno_cc_algo
extern

Definition at line 105 of file cc_newreno.c.

Referenced by newreno_ctl_output().