FreeBSD kernel IPv4 code
tcp_input.c File Reference
#include <sys/cdefs.h>
#include "opt_inet.h"
#include "opt_inet6.h"
#include "opt_ipsec.h"
#include "opt_tcpdebug.h"
#include <sys/param.h>
#include <sys/arb.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/proc.h>
#include <sys/protosw.h>
#include <sys/qmath.h>
#include <sys/sdt.h>
#include <sys/signalvar.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/syslog.h>
#include <sys/systm.h>
#include <sys/stats.h>
#include <machine/cpu.h>
#include <vm/uma.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/ip.h>
#include <netinet/ip_icmp.h>
#include <netinet/icmp_var.h>
#include <netinet/ip_var.h>
#include <netinet/ip_options.h>
#include <netinet/ip6.h>
#include <netinet/icmp6.h>
#include <netinet6/in6_pcb.h>
#include <netinet6/in6_var.h>
#include <netinet6/ip6_var.h>
#include <netinet6/nd6.h>
#include <netinet/tcp.h>
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_log_buf.h>
#include <netinet/tcp_seq.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcp_var.h>
#include <netinet6/tcp6_var.h>
#include <netinet/tcpip.h>
#include <netinet/cc/cc.h>
#include <netinet/tcp_fastopen.h>
#include <netinet/tcp_syncache.h>
#include <netinet/tcp_ecn.h>
#include <netinet/udp.h>
#include <netipsec/ipsec_support.h>
#include <machine/in_cksum.h>
#include <security/mac/mac_framework.h>

Go to the source code of this file.

Macros

#define TCPSTATES   /* for logging */
 
#define V_blackhole   VNET(blackhole)
 
#define V_blackhole_local   VNET(blackhole_local)
 
#define V_tcp_recvspace   VNET(tcp_recvspace)
 
#define DELAY_ACK(tp, tlen)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 VNET_DEFINE (int, tcp_log_in_vain)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, log_in_vain, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_log_in_vain), 0, "Log all incoming TCP segments to closed ports")
 
 VNET_DEFINE (int, blackhole)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, blackhole, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(blackhole), 0, "Do not send RST on segments to closed ports")
 
 VNET_DEFINE (bool, blackhole_local)
 
 SYSCTL_BOOL (_net_inet_tcp, OID_AUTO, blackhole_local, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(blackhole_local), false, "Enforce net.inet.tcp.blackhole for locally originated packets")
 
 VNET_DEFINE (int, tcp_delack_enabled)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, delayed_ack, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_delack_enabled), 0, "Delay ACK to try and piggyback it onto a data packet")
 
 VNET_DEFINE (int, drop_synfin)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, drop_synfin, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(drop_synfin), 0, "Drop TCP packets with SYN+FIN set")
 
 VNET_DEFINE (int, tcp_do_prr_conservative)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, do_prr_conservative, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_prr_conservative), 0, "Do conservative Proportional Rate Reduction")
 
 VNET_DEFINE (int, tcp_do_prr)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, do_prr, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_prr), 1, "Enable Proportional Rate Reduction per RFC 6937")
 
 VNET_DEFINE (int, tcp_do_lrd)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, do_lrd, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_lrd), 1, "Perform Lost Retransmission Detection")
 
 VNET_DEFINE (int, tcp_do_newcwv)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, newcwv, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_newcwv), 0, "Enable New Congestion Window Validation per RFC7661")
 
 VNET_DEFINE (int, tcp_do_rfc3042)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, rfc3042, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_rfc3042), 0, "Enable RFC 3042 (Limited Transmit)")
 
 VNET_DEFINE (int, tcp_do_rfc3390)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, rfc3390, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_rfc3390), 0, "Enable RFC 3390 (Increasing TCP's Initial Congestion Window)")
 
 VNET_DEFINE (int, tcp_initcwnd_segments)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, initcwnd_segments, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_initcwnd_segments), 0, "Slow-start flight size (initial congestion window) in number of segments")
 
 VNET_DEFINE (int, tcp_do_rfc3465)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, rfc3465, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_rfc3465), 0, "Enable RFC 3465 (Appropriate Byte Counting)")
 
 VNET_DEFINE (int, tcp_abc_l_var)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, abc_l_var, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_abc_l_var), 2, "Cap the max cwnd increment during slow-start to this number of segments")
 
static SYSCTL_NODE (_net_inet_tcp, OID_AUTO, ecn, CTLFLAG_RW|CTLFLAG_MPSAFE, 0, "TCP ECN")
 
 VNET_DEFINE (int, tcp_do_ecn)
 
 SYSCTL_INT (_net_inet_tcp_ecn, OID_AUTO, enable, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_ecn), 0, "TCP ECN support")
 
 VNET_DEFINE (int, tcp_ecn_maxretries)
 
 SYSCTL_INT (_net_inet_tcp_ecn, OID_AUTO, maxretries, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_ecn_maxretries), 0, "Max retries before giving up on ECN")
 
 VNET_DEFINE (int, tcp_insecure_syn)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, insecure_syn, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_insecure_syn), 0, "Follow RFC793 instead of RFC5961 criteria for accepting SYN packets")
 
 VNET_DEFINE (int, tcp_insecure_rst)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, insecure_rst, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_insecure_rst), 0, "Follow RFC793 instead of RFC5961 criteria for accepting RST packets")
 
 VNET_DEFINE (int, tcp_recvspace)
 
 SYSCTL_INT (_net_inet_tcp, TCPCTL_RECVSPACE, recvspace, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_recvspace), 0, "Initial receive socket buffer size")
 
 VNET_DEFINE (int, tcp_do_autorcvbuf)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, recvbuf_auto, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_autorcvbuf), 0, "Enable automatic receive buffer sizing")
 
 VNET_DEFINE (int, tcp_autorcvbuf_max)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, recvbuf_max, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_autorcvbuf_max), 0, "Max size of automatic receive buffer")
 
 VNET_DEFINE (struct inpcbinfo, tcbinfo)
 
 VNET_PCPUSTAT_DEFINE (struct tcpstat, tcpstat)
 
 SYSCTL_VNET_PCPUSTAT (_net_inet_tcp, TCPCTL_STATS, stats, struct tcpstat, tcpstat, "TCP statistics (struct tcpstat, netinet/tcp_var.h)")
 
 VNET_DEFINE (counter_u64_t, tcps_states[TCP_NSTATES])
 
 SYSCTL_COUNTER_U64_ARRAY (_net_inet_tcp, TCPCTL_STATES, states, CTLFLAG_RD|CTLFLAG_VNET, &VNET_NAME(tcps_states)[0], TCP_NSTATES, "TCP connection counts by TCP state")
 
void kmod_tcpstat_add (int statnum, int val)
 
void cc_ack_received (struct tcpcb *tp, struct tcphdr *th, uint16_t nsegs, uint16_t type)
 
void cc_conn_init (struct tcpcb *tp)
 
void cc_cong_signal (struct tcpcb *tp, struct tcphdr *th, uint32_t type)
 
void cc_post_recovery (struct tcpcb *tp, struct tcphdr *th)
 
void cc_ecnpkt_handler_flags (struct tcpcb *tp, uint16_t flags, uint8_t iptos)
 
void cc_ecnpkt_handler (struct tcpcb *tp, struct tcphdr *th, uint8_t iptos)
 
int tcp_input_with_port (struct mbuf **mp, int *offp, int proto, uint16_t port)
 
int tcp_autorcvbuf (struct mbuf *m, struct tcphdr *th, struct socket *so, struct tcpcb *tp, int tlen)
 
int tcp_input (struct mbuf **mp, int *offp, int proto)
 
void tcp_handle_wakeup (struct tcpcb *tp, struct socket *so)
 
void tcp_do_segment (struct mbuf *m, struct tcphdr *th, struct socket *so, struct tcpcb *tp, int drop_hdrlen, int tlen, uint8_t iptos)
 
void tcp_dropwithreset (struct mbuf *m, struct tcphdr *th, struct tcpcb *tp, int tlen, int rstreason)
 
void tcp_dooptions (struct tcpopt *to, u_char *cp, int cnt, int flags)
 
void tcp_pulloutofband (struct socket *so, struct tcphdr *th, struct mbuf *m, int off)
 
void tcp_xmit_timer (struct tcpcb *tp, int rtt)
 
void tcp_mss_update (struct tcpcb *tp, int offer, int mtuoffer, struct hc_metrics_lite *metricptr, struct tcp_ifcap *cap)
 
void tcp_mss (struct tcpcb *tp, int offer)
 
int tcp_mssopt (struct in_conninfo *inc)
 
void tcp_do_prr_ack (struct tcpcb *tp, struct tcphdr *th, struct tcpopt *to)
 
void tcp_newreno_partial_ack (struct tcpcb *tp, struct tcphdr *th)
 
int tcp_compute_pipe (struct tcpcb *tp)
 
uint32_t tcp_compute_initwnd (uint32_t maxseg)
 

Variables

const int tcprexmtthresh = 3
 

Macro Definition Documentation

◆ DELAY_ACK

#define DELAY_ACK (   tp,
  tlen 
)
Value:
(tp->t_flags & TF_RXWIN0SENT) == 0) && \
(tlen <= tp->t_maxseg) && \
(V_tcp_delack_enabled || (tp->t_flags & TF_NEEDSYN)))
int tcp_timer_active(struct tcpcb *tp, uint32_t timer_type)
Definition: tcp_timer.c:905
#define TT_DELACK
Definition: tcp_timer.h:161
#define V_tcp_delack_enabled
Definition: tcp_var.h:1035
#define TF_RXWIN0SENT
Definition: tcp_var.h:516
#define TF_NEEDSYN
Definition: tcp_var.h:507

Definition at line 510 of file tcp_input.c.

◆ TCPSTATES

#define TCPSTATES   /* for logging */

Definition at line 89 of file tcp_input.c.

◆ V_blackhole

#define V_blackhole   VNET(blackhole)

Definition at line 143 of file tcp_input.c.

◆ V_blackhole_local

#define V_blackhole_local   VNET(blackhole_local)

Definition at line 149 of file tcp_input.c.

◆ V_tcp_recvspace

#define V_tcp_recvspace   VNET(tcp_recvspace)

Definition at line 234 of file tcp_input.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ cc_ack_received()

◆ cc_cong_signal()

◆ cc_conn_init()

◆ cc_ecnpkt_handler()

void cc_ecnpkt_handler ( struct tcpcb tp,
struct tcphdr *  th,
uint8_t  iptos 
)
inline

Definition at line 550 of file tcp_input.c.

References cc_ecnpkt_handler_flags(), and tcp_get_flags().

Here is the call graph for this function:

◆ cc_ecnpkt_handler_flags()

void cc_ecnpkt_handler_flags ( struct tcpcb tp,
uint16_t  flags,
uint8_t  iptos 
)
inline

◆ cc_post_recovery()

void cc_post_recovery ( struct tcpcb tp,
struct tcphdr *  th 
)
inline

Definition at line 485 of file tcp_input.c.

References CC_ALGO, tcpcb::ccv, cc_var::curack, sackhint::delivered_data, INP_WLOCK_ASSERT, sackhint::prr_out, tcpcb::sackhint, tcpcb::t_bytes_acked, and tcpcb::t_inpcb.

Referenced by tcp_do_segment().

Here is the caller graph for this function:

◆ kmod_tcpstat_add()

void kmod_tcpstat_add ( int  statnum,
int  val 
)

Definition at line 267 of file tcp_input.c.

◆ SYSCTL_BOOL()

SYSCTL_BOOL ( _net_inet_tcp  ,
OID_AUTO  ,
blackhole_local  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEblackhole_local,
false  ,
"Enforce net.inet.tcp.blackhole for locally originated packets"   
)

◆ SYSCTL_COUNTER_U64_ARRAY()

SYSCTL_COUNTER_U64_ARRAY ( _net_inet_tcp  ,
TCPCTL_STATES  ,
states  ,
CTLFLAG_RD|  CTLFLAG_VNET,
VNET_NAME(tcps_states)[0],
TCP_NSTATES  ,
"TCP connection counts by TCP state  
)

◆ SYSCTL_INT() [1/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
abc_l_var  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_abc_l_var,
,
"Cap the max cwnd increment during slow-start to this number of segments"   
)

◆ SYSCTL_INT() [2/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
blackhole  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEblackhole,
,
"Do not send RST on segments to closed ports"   
)

◆ SYSCTL_INT() [3/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
delayed_ack  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_delack_enabled,
,
"Delay ACK to try and piggyback it onto a data packet  
)

◆ SYSCTL_INT() [4/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
do_lrd  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_lrd,
,
"Perform Lost Retransmission Detection"   
)

◆ SYSCTL_INT() [5/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
do_prr  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_prr,
,
"Enable Proportional Rate Reduction per RFC 6937"   
)

◆ SYSCTL_INT() [6/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
do_prr_conservative  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_prr_conservative,
,
"Do conservative Proportional Rate Reduction"   
)

◆ SYSCTL_INT() [7/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
drop_synfin  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEdrop_synfin,
,
"Drop TCP packets with SYN+FIN set"   
)

◆ SYSCTL_INT() [8/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
initcwnd_segments  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_initcwnd_segments,
,
"Slow-start flight size (initial congestion window) in number of segments"   
)

◆ SYSCTL_INT() [9/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
insecure_rst  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_insecure_rst,
,
"Follow RFC793 instead of RFC5961 criteria for accepting RST packets"   
)

◆ SYSCTL_INT() [10/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
insecure_syn  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_insecure_syn,
,
"Follow RFC793 instead of RFC5961 criteria for accepting SYN packets"   
)

◆ SYSCTL_INT() [11/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
log_in_vain  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_log_in_vain,
,
"Log all incoming TCP segments to closed ports"   
)

◆ SYSCTL_INT() [12/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
newcwv  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_newcwv,
,
"Enable New Congestion Window Validation per RFC7661"   
)

◆ SYSCTL_INT() [13/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
recvbuf_auto  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_autorcvbuf,
,
"Enable automatic receive buffer sizing"   
)

◆ SYSCTL_INT() [14/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
recvbuf_max  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_autorcvbuf_max,
,
"Max size of automatic receive buffer"   
)

◆ SYSCTL_INT() [15/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
rfc3042  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_rfc3042,
,
"Enable RFC 3042 (Limited Transmit)"   
)

◆ SYSCTL_INT() [16/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
rfc3390  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_rfc3390,
,
"Enable RFC 3390 (Increasing TCP's Initial Congestion Window)"   
)

◆ SYSCTL_INT() [17/20]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
rfc3465  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_rfc3465,
,
"Enable RFC 3465 (Appropriate Byte Counting)"   
)

◆ SYSCTL_INT() [18/20]

SYSCTL_INT ( _net_inet_tcp  ,
TCPCTL_RECVSPACE  ,
recvspace  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_recvspace,
,
"Initial receive socket buffer size"   
)

◆ SYSCTL_INT() [19/20]

SYSCTL_INT ( _net_inet_tcp_ecn  ,
OID_AUTO  ,
enable  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_ecn,
,
"TCP ECN support"   
)

◆ SYSCTL_INT() [20/20]

SYSCTL_INT ( _net_inet_tcp_ecn  ,
OID_AUTO  ,
maxretries  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_ecn_maxretries,
,
"Max retries before giving up on ECN"   
)

◆ SYSCTL_NODE()

static SYSCTL_NODE ( _net_inet_tcp  ,
OID_AUTO  ,
ecn  ,
CTLFLAG_RW|  CTLFLAG_MPSAFE,
,
"TCP ECN"   
)
static

◆ SYSCTL_VNET_PCPUSTAT()

SYSCTL_VNET_PCPUSTAT ( _net_inet_tcp  ,
TCPCTL_STATS  ,
stats  ,
struct tcpstat  ,
tcpstat  ,
"TCP statistics (struct tcpstat, netinet/tcp_var.h)"   
)

◆ tcp_autorcvbuf()

int tcp_autorcvbuf ( struct mbuf *  m,
struct tcphdr *  th,
struct socket *  so,
struct tcpcb tp,
int  tlen 
)

Definition at line 1465 of file tcp_input.c.

References tcpcb::rfbuf_cnt, tcpcb::rfbuf_ts, tcpcb::t_srtt, TCP_PROBE6, TCP_RTT_SHIFT, tcp_ts_getticks(), TCP_TS_TO_TICKS, V_tcp_autorcvbuf_max, and V_tcp_do_autorcvbuf.

Referenced by bbr_do_fastnewdata(), rack_do_fastnewdata(), and tcp_do_segment().

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

◆ tcp_compute_initwnd()

uint32_t tcp_compute_initwnd ( uint32_t  maxseg)

Definition at line 4049 of file tcp_input.c.

References V_tcp_do_rfc3390, and V_tcp_initcwnd_segments.

Referenced by cc_conn_init(), newreno_cc_after_idle(), rack_get_bw(), and rc_init_window().

Here is the caller graph for this function:

◆ tcp_compute_pipe()

int tcp_compute_pipe ( struct tcpcb tp)

◆ tcp_do_prr_ack()

◆ tcp_do_segment()

void tcp_do_segment ( struct mbuf *  m,
struct tcphdr *  th,
struct socket *  so,
struct tcpcb tp,
int  drop_hdrlen,
int  tlen,
uint8_t  iptos 
)

Definition at line 1518 of file tcp_input.c.

References BANDLIM_RST_OPENPORT, BANDLIM_UNLIMITED, BYTES_THIS_ACK, CC_ACK, cc_ack_received(), cc_cong_signal(), cc_conn_init(), CC_DUPACK, CC_ECN, CC_NDUPACK, cc_post_recovery(), CC_RTO_ERR, DELAY_ACK, sackhint::delivered_data, sackblk::end, EXIT_RECOVERY, IN_CONGRECOVERY, IN_FASTRECOVERY, IN_RECOVERY, inpcb::inp_inc, INP_IPV6, inpcb::inp_socket, inpcb::inp_vflag, INP_WLOCK_ASSERT, INP_WUNLOCK, IP6_HDR_LEN, tcpcb::irs, IS_FASTOPEN, tcpcb::iss, tcpcb::last_ack_sent, sackhint::last_sack_ack, tcpcb::max_sndwnd, sackhint::prr_delivered, tcpcb::rcv_adv, tcpcb::rcv_numsacks, tcpcb::rcv_nxt, tcpcb::rcv_scale, tcpcb::rcv_up, tcpcb::rcv_wnd, sackhint::recover_fs, tcpcb::request_r_scale, sackhint::sack_bytes_rexmit, tcpcb::sackblks, sackhint::sacked_bytes, tcpcb::sackhint, SEGQ_EMPTY, SEQ_GEQ, SEQ_GT, SEQ_LEQ, SEQ_LT, tcpcb::snd_cwnd, tcpcb::snd_fack, tcpcb::snd_limited, tcpcb::snd_max, tcpcb::snd_nxt, tcpcb::snd_recover, tcpcb::snd_scale, tcpcb::snd_ssthresh, tcpcb::snd_una, tcpcb::snd_wl1, tcpcb::snd_wl2, tcpcb::snd_wnd, sackblk::start, tcpcb::t_badrxtwin, tcpcb::t_dupacks, tcpcb::t_fbyte_in, tcpcb::t_fbyte_out, tcpcb::t_flags, tcpcb::t_flags2, tcpcb::t_inpcb, tcpcb::t_oobflags, tcpcb::t_rcvtime, tcpcb::t_rtseq, tcpcb::t_rttlow, tcpcb::t_rtttime, tcpcb::t_rxtcur, tcpcb::t_rxtshift, tcpcb::t_starttime, tcpcb::t_state, tcpcb::t_stats, tcpcb::t_tfo_pending, TA_DROP, TA_INPUT, tcp_autorcvbuf(), tcp_clean_sackreport(), tcp_close(), tcp_compute_pipe(), tcp_delacktime, tcp_do_prr_ack(), tcp_dooptions(), tcp_drop(), tcp_dropwithreset(), tcp_ecn_input_parallel_syn(), tcp_ecn_input_segment(), tcp_ecn_input_syn_sent(), tcp_fast_finwait2_recycle, tcp_fastopen_decrement_counter(), tcp_fastopen_disable_path(), tcp_fastopen_update_cache(), tcp_finwait2_timeout, tcp_get_flags(), tcp_handle_wakeup(), tcp_log_addrs(), TCP_LOG_EVENT, TCP_LOG_IN, tcp_maxseg(), tcp_mss(), tcp_newreno_partial_ack(), TCP_PAWS_IDLE, tcp_pcap_add(), TCP_PROBE3, TCP_PROBE5, tcp_pulloutofband(), tcp_rcvseqinit, tcp_reass(), tcp_respond(), tcp_sack_doack(), tcp_sack_lost_retransmission(), tcp_sack_partialack(), tcp_state_change(), tcp_timer_activate(), tcp_timer_active(), tcp_trace(), tcp_ts_getticks(), TCP_TS_TO_TICKS, tcp_twstart(), tcp_update_dsack_list(), tcp_update_sack_list(), tcp_xmit_timer(), TCPOOB_HADDATA, TCPOOB_HAVEDATA, tcprexmtthresh, TCPS_CLOSE_WAIT, TCPS_CLOSING, TCPS_ESTABLISHED, TCPS_FIN_WAIT_1, TCPS_FIN_WAIT_2, TCPS_HAVEESTABLISHED, TCPS_HAVERCVDFIN, TCPS_LAST_ACK, TCPS_LISTEN, TCPS_SYN_RECEIVED, TCPS_SYN_SENT, TCPS_TIME_WAIT, TCPSTAT_ADD, TCPSTAT_INC, TF2_FBYTES_COMPLETE, TF_ACKNOW, TF_DELACK, TF_LRD, TF_NEEDFIN, TF_NEEDSYN, TF_NOOPT, TF_PREVVALID, TF_RCVD_SCALE, TF_RCVD_TSTMP, TF_REQ_SCALE, TF_REQ_TSTMP, TF_SACK_PERMIT, TF_SENTFIN, TF_SIGNATURE, TF_WAKESOR, tcpopt::to_flags, tcpopt::to_mss, TO_SYN, tcpopt::to_tfo_cookie, tcpopt::to_tfo_len, tcpopt::to_tsecr, tcpopt::to_tsval, tcpopt::to_wscale, TOF_FASTOPEN, TOF_MSS, TOF_SACK, TOF_SACKPERM, TOF_SCALE, TOF_SIGNATURE, TOF_TS, TP_KEEPIDLE, TP_MAXIDLE, tcpcb::ts_offset, tcpcb::ts_recent, tcpcb::ts_recent_age, TSTMP_GEQ, TSTMP_GT, TSTMP_LT, TT_2MSL, TT_DELACK, TT_KEEP, TT_PERSIST, TT_REXMT, V_drop_synfin, V_tcp_do_newsack, V_tcp_do_prr, V_tcp_do_rfc3042, V_tcp_insecure_rst, V_tcp_insecure_syn, V_tcp_tolerate_missing_ts, and VOI_TCP_FRWIN.

Here is the call graph for this function:

◆ tcp_dooptions()

◆ tcp_dropwithreset()

void tcp_dropwithreset ( struct mbuf *  m,
struct tcphdr *  th,
struct tcpcb tp,
int  tlen,
int  rstreason 
)

Definition at line 3357 of file tcp_input.c.

References badport_bandlim(), in_broadcast(), INADDR_BROADCAST, INP_LOCK_ASSERT, ip6_hdr::ip6_dst, ip6_hdr::ip6_src, ip::ip_dst, ip_v, in_addr::s_addr, tcpcb::t_inpcb, tcp_get_flags(), and tcp_respond().

Referenced by ctf_do_dropwithreset(), ctf_do_dropwithreset_conn(), tcp_do_segment(), and tcp_input_with_port().

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

◆ tcp_handle_wakeup()

void tcp_handle_wakeup ( struct tcpcb tp,
struct socket *  so 
)

Definition at line 1496 of file tcp_input.c.

References INP_LOCK_ASSERT, tcpcb::t_flags, tcpcb::t_inpcb, and TF_WAKESOR.

Referenced by tcp_do_segment().

Here is the caller graph for this function:

◆ tcp_input()

int tcp_input ( struct mbuf **  mp,
int *  offp,
int  proto 
)

Definition at line 1490 of file tcp_input.c.

References tcp_input_with_port().

Here is the call graph for this function:

◆ tcp_input_with_port()

int tcp_input_with_port ( struct mbuf **  mp,
int *  offp,
int  proto,
uint16_t  port 
)

Definition at line 608 of file tcp_input.c.

References BANDLIM_RST_CLOSEDPORT, BANDLIM_RST_OPENPORT, BANDLIM_UNLIMITED, ipovly::ih_len, ipovly::ih_x1, in_broadcast(), in_localip(), in_pcblookup(), in_pcblookup_mbuf(), in_pseudo(), INADDR_BROADCAST, in_conninfo::inc_fibnum, in_conninfo::inc_flags, INC_IPV6MINMTU, INC_ISIPV6, INP_DROPPED, inpcb::inp_flags, inpcb::inp_flowid, inpcb::inp_flowtype, inpcb::inp_inc, inpcb::inp_ip_minttl, INP_LOCK_ASSERT, INP_RLOCK_ASSERT, inpcb::inp_socket, INP_TIMEWAIT, INP_TRY_UPGRADE, INP_UNLOCK, INP_WLOCK_ASSERT, INPLOOKUP_RLOCKPCB, INPLOOKUP_WILDCARD, INPLOOKUP_WLOCKPCB, intotcpcb, ip6_hdr::ip6_dst, IP6_HDR_LEN, ip6_hdr::ip6_src, ip::ip_dst, ip::ip_hl, ip::ip_len, ip_stripoptions(), ip::ip_tos, ip::ip_ttl, ip::ip_v, IPPROTO_TCP, IPV6_TRAFFIC_CLASS, IPVERSION, in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_port, sotoinpcb, syncache_add(), syncache_badack(), syncache_chkrst(), syncache_expand(), tcpcb::t_fb, tcpcb::t_flags, tcpcb::t_port, tcpcb::t_state, TA_INPUT, tcp_dooptions(), tcp_dropwithreset(), tcp_fields_to_host(), tcp_get_flags(), tcp_log_addrs(), tcp_log_vain(), tcp_offload_input(), TCP_PROBE3, TCP_PROBE5, tcp_trace(), tcp_twcheck(), TCPS_CLOSED, TCPS_LISTEN, TCPS_SYN_RECEIVED, TCPSTAT_INC, TF_SIGNATURE, TF_TOE, tcp_function_block::tfb_tcp_do_segment, tcpopt::to_flags, tcpopt::to_signature, TO_SYN, TOF_SIGNATURE, V_blackhole, V_blackhole_local, V_drop_synfin, V_tcbinfo, V_tcp_log_in_vain, and V_tcp_sc_rst_sock_fail.

Referenced by tcp_input(), and tcp_recv_udp_tunneled_packet().

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

◆ tcp_mss()

◆ tcp_mss_update()

void tcp_mss_update ( struct tcpcb tp,
int  offer,
int  mtuoffer,
struct hc_metrics_lite metricptr,
struct tcp_ifcap cap 
)

◆ tcp_mssopt()

int tcp_mssopt ( struct in_conninfo inc)

Definition at line 3891 of file tcp_input.c.

References in_conninfo::inc_flags, INC_ISIPV6, tcp_hc_getmtu(), tcp_maxmtu(), tcp_maxmtu6(), and V_tcp_mssdflt.

Referenced by bbr_output_wtime(), rack_output(), syncache_respond(), and tcp_default_output().

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

◆ tcp_newreno_partial_ack()

void tcp_newreno_partial_ack ( struct tcpcb tp,
struct tcphdr *  th 
)

Definition at line 4008 of file tcp_input.c.

References BYTES_THIS_ACK, INP_WLOCK_ASSERT, SEQ_GT, tcpcb::snd_cwnd, tcpcb::snd_nxt, tcpcb::t_flags, tcpcb::t_inpcb, tcpcb::t_rtttime, tcp_maxseg(), tcp_timer_activate(), TF_ACKNOW, and TT_REXMT.

Referenced by tcp_do_segment().

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

◆ tcp_pulloutofband()

void tcp_pulloutofband ( struct socket *  so,
struct tcphdr *  th,
struct mbuf *  m,
int  off 
)

Definition at line 3530 of file tcp_input.c.

References INP_WLOCK_ASSERT, sototcpcb, tcpcb::t_inpcb, tcpcb::t_iobc, tcpcb::t_oobflags, and TCPOOB_HAVEDATA.

Referenced by tcp_do_segment().

Here is the caller graph for this function:

◆ tcp_xmit_timer()

◆ VNET_DEFINE() [1/23]

VNET_DEFINE ( bool  ,
blackhole_local   
)

◆ VNET_DEFINE() [2/23]

VNET_DEFINE ( counter_u64_t  ,
tcps_states  [TCP_NSTATES] 
)

◆ VNET_DEFINE() [3/23]

VNET_DEFINE ( int  ,
blackhole   
)
pure virtual

◆ VNET_DEFINE() [4/23]

VNET_DEFINE ( int  ,
drop_synfin   
)
pure virtual

◆ VNET_DEFINE() [5/23]

VNET_DEFINE ( int  ,
tcp_abc_l_var   
)

◆ VNET_DEFINE() [6/23]

VNET_DEFINE ( int  ,
tcp_autorcvbuf_max   
)

◆ VNET_DEFINE() [7/23]

VNET_DEFINE ( int  ,
tcp_delack_enabled   
)

◆ VNET_DEFINE() [8/23]

VNET_DEFINE ( int  ,
tcp_do_autorcvbuf   
)

◆ VNET_DEFINE() [9/23]

VNET_DEFINE ( int  ,
tcp_do_ecn   
)

◆ VNET_DEFINE() [10/23]

VNET_DEFINE ( int  ,
tcp_do_lrd   
)
pure virtual

◆ VNET_DEFINE() [11/23]

VNET_DEFINE ( int  ,
tcp_do_newcwv   
)
pure virtual

◆ VNET_DEFINE() [12/23]

VNET_DEFINE ( int  ,
tcp_do_prr   
)

◆ VNET_DEFINE() [13/23]

VNET_DEFINE ( int  ,
tcp_do_prr_conservative   
)
pure virtual

◆ VNET_DEFINE() [14/23]

VNET_DEFINE ( int  ,
tcp_do_rfc3042   
)

◆ VNET_DEFINE() [15/23]

VNET_DEFINE ( int  ,
tcp_do_rfc3390   
)

◆ VNET_DEFINE() [16/23]

VNET_DEFINE ( int  ,
tcp_do_rfc3465   
)

◆ VNET_DEFINE() [17/23]

VNET_DEFINE ( int  ,
tcp_ecn_maxretries   
)

◆ VNET_DEFINE() [18/23]

VNET_DEFINE ( int  ,
tcp_initcwnd_segments   
)

◆ VNET_DEFINE() [19/23]

VNET_DEFINE ( int  ,
tcp_insecure_rst   
)
pure virtual

◆ VNET_DEFINE() [20/23]

VNET_DEFINE ( int  ,
tcp_insecure_syn   
)
pure virtual

◆ VNET_DEFINE() [21/23]

VNET_DEFINE ( int  ,
tcp_log_in_vain   
)
pure virtual

◆ VNET_DEFINE() [22/23]

VNET_DEFINE ( int  ,
tcp_recvspace   
)

◆ VNET_DEFINE() [23/23]

VNET_DEFINE ( struct inpcbinfo  ,
tcbinfo   
)

◆ VNET_PCPUSTAT_DEFINE()

VNET_PCPUSTAT_DEFINE ( struct tcpstat  ,
tcpstat   
)

Variable Documentation

◆ tcprexmtthresh

const int tcprexmtthresh = 3

Definition at line 135 of file tcp_input.c.

Referenced by tcp_do_prr_ack(), and tcp_do_segment().