FreeBSD kernel IPv4 code
tcp_output.c File Reference
#include <sys/cdefs.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/domain.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
#include <sys/protosw.h>
#include <sys/qmath.h>
#include <sys/sdt.h>
#include <sys/socket.h>
#include <sys/socketvar.h>
#include <sys/sysctl.h>
#include <sys/stats.h>
#include <net/if.h>
#include <net/route.h>
#include <net/route/nhop.h>
#include <net/vnet.h>
#include <netinet/in.h>
#include <netinet/in_kdtrace.h>
#include <netinet/in_systm.h>
#include <netinet/ip.h>
#include <netinet/in_pcb.h>
#include <netinet/ip_var.h>
#include <netinet/ip_options.h>
#include <netinet/tcp.h>
#include <netinet/tcp_fsm.h>
#include <netinet/tcp_log_buf.h>
#include <netinet/tcp_seq.h>
#include <netinet/tcp_var.h>
#include <netinet/tcp_syncache.h>
#include <netinet/tcp_timer.h>
#include <netinet/tcpip.h>
#include <netinet/cc/cc.h>
#include <netinet/tcp_fastopen.h>
#include <netinet/tcp_ecn.h>
#include <netipsec/ipsec_support.h>
#include <netinet/udp.h>
#include <netinet/udp_var.h>
#include <machine/in_cksum.h>
#include <security/mac/mac_framework.h>
Include dependency graph for tcp_output.c:

Go to the source code of this file.

Macros

#define TCPOUTFLAGS
 
#define V_tcp_sendspace   VNET(tcp_sendspace)
 
#define V_tcp_sendbuf_auto_lowat   VNET(tcp_sendbuf_auto_lowat)
 
#define TCP_XMIT_TIMER_ASSERT(tp, len, th_flags)
 

Functions

 __FBSDID ("$FreeBSD$")
 
 VNET_DEFINE (int, path_mtu_discovery)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, path_mtu_discovery, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(path_mtu_discovery), 1, "Enable Path MTU Discovery")
 
 VNET_DEFINE (int, tcp_do_tso)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, tso, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_tso), 0, "Enable TCP Segmentation Offload")
 
 VNET_DEFINE (int, tcp_sendspace)
 
 SYSCTL_INT (_net_inet_tcp, TCPCTL_SENDSPACE, sendspace, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_sendspace), 0, "Initial send socket buffer size")
 
 VNET_DEFINE (int, tcp_do_autosndbuf)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, sendbuf_auto, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_do_autosndbuf), 0, "Enable automatic send buffer sizing")
 
 VNET_DEFINE (int, tcp_autosndbuf_inc)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, sendbuf_inc, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_autosndbuf_inc), 0, "Incrementor step size of automatic send buffer")
 
 VNET_DEFINE (int, tcp_autosndbuf_max)
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, sendbuf_max, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_autosndbuf_max), 0, "Max size of automatic send buffer")
 
 VNET_DEFINE (int, tcp_sendbuf_auto_lowat)=0
 
 SYSCTL_INT (_net_inet_tcp, OID_AUTO, sendbuf_auto_lowat, CTLFLAG_VNET|CTLFLAG_RW, &VNET_NAME(tcp_sendbuf_auto_lowat), 0, "Modify threshold for auto send buffer growth to account for SO_SNDLOWAT")
 
static void cc_after_idle (struct tcpcb *tp)
 
int tcp_default_output (struct tcpcb *tp)
 
void tcp_setpersist (struct tcpcb *tp)
 
int tcp_addoptions (struct tcpopt *to, u_char *optp)
 
struct mbuf * tcp_m_copym (struct mbuf *m, int32_t off0, int32_t *plen, int32_t seglimit, int32_t segsize, struct sockbuf *sb, bool hw_tls)
 
void tcp_sndbuf_autoscale (struct tcpcb *tp, struct socket *so, uint32_t sendwin)
 

Macro Definition Documentation

◆ TCP_XMIT_TIMER_ASSERT

#define TCP_XMIT_TIMER_ASSERT (   tp,
  len,
  th_flags 
)
Value:
KASSERT(((len) == 0 && ((th_flags) & (TH_SYN | TH_FIN)) == 0) ||\
("neither rexmt nor persist timer is set"))
int tcp_timer_active(struct tcpcb *tp, uint32_t timer_type)
Definition: tcp_timer.c:905
#define TT_PERSIST
Definition: tcp_timer.h:163
#define TT_REXMT
Definition: tcp_timer.h:162

Definition at line 152 of file tcp_output.c.

◆ TCPOUTFLAGS

#define TCPOUTFLAGS

Definition at line 83 of file tcp_output.c.

◆ V_tcp_sendbuf_auto_lowat

#define V_tcp_sendbuf_auto_lowat   VNET(tcp_sendbuf_auto_lowat)

Definition at line 143 of file tcp_output.c.

◆ V_tcp_sendspace

#define V_tcp_sendspace   VNET(tcp_sendspace)

Definition at line 123 of file tcp_output.c.

Function Documentation

◆ __FBSDID()

__FBSDID ( "$FreeBSD$"  )

◆ cc_after_idle()

static void cc_after_idle ( struct tcpcb tp)
inlinestatic

Definition at line 187 of file tcp_output.c.

References CC_ALGO, tcpcb::ccv, INP_WLOCK_ASSERT, tcpcb::t_inpcb, and tcp_hhook_data::tp.

Referenced by tcp_default_output().

Here is the caller graph for this function:

◆ SYSCTL_INT() [1/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
path_mtu_discovery  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEpath_mtu_discovery,
,
"Enable Path MTU Discovery"   
)

◆ SYSCTL_INT() [2/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
sendbuf_auto  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_autosndbuf,
,
"Enable automatic send buffer sizing"   
)

◆ SYSCTL_INT() [3/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
sendbuf_auto_lowat  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_sendbuf_auto_lowat,
,
"Modify threshold for auto send buffer growth to account for SO_SNDLOWAT"   
)

◆ SYSCTL_INT() [4/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
sendbuf_inc  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_autosndbuf_inc,
,
"Incrementor step size of automatic send buffer"   
)

◆ SYSCTL_INT() [5/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
sendbuf_max  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_autosndbuf_max,
,
"Max size of automatic send buffer"   
)

◆ SYSCTL_INT() [6/7]

SYSCTL_INT ( _net_inet_tcp  ,
OID_AUTO  ,
tso  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_do_tso,
,
"Enable TCP Segmentation Offload"   
)

◆ SYSCTL_INT() [7/7]

SYSCTL_INT ( _net_inet_tcp  ,
TCPCTL_SENDSPACE  ,
sendspace  ,
CTLFLAG_VNET|  CTLFLAG_RW,
VNET_NAMEtcp_sendspace,
,
"Initial send socket buffer size"   
)

◆ tcp_addoptions()

◆ tcp_default_output()

int tcp_default_output ( struct tcpcb tp)

Definition at line 199 of file tcp_output.c.

References cc_after_idle(), tcpcb::client, sackhole::end, ERRNO_UNK, tcpcb::gput_ack, tcpcb::gput_seq, tcpcb::gput_ts, ipovly::ih_len, inpcb::in6p_outputopts, IN_FASTRECOVERY, in_pseudo(), IN_RECOVERY, inpcb::inp_inc, INP_IPV6, INP_IPV6PROTO, inpcb::inp_options, inpcb::inp_route, inpcb::inp_route6, inpcb::inp_socket, inpcb::inp_vflag, INP_WLOCK_ASSERT, IP_DF, ip::ip_dst, ip::ip_len, IP_MAXPACKET, ip::ip_off, ip_output(), IP_ROUTETOIF, ip::ip_tos, ip::ip_ttl, ip::ip_v, IPPROTO_TCP, IPPROTO_UDP, IPTOS_ECN_MASK, IPVERSION, IS_FASTOPEN, tcpcb::iss, tcpcb::last_ack_sent, tcpcb::max_sndwnd, sackhint::prr_out, tcpcb::rcv_adv, tcpcb::rcv_numsacks, tcpcb::rcv_nxt, tcpcb::rcv_scale, tcpcb::request_r_scale, tcpcb::rfbuf_ts, sackhole::rxmit, in_addr::s_addr, sackhint::sack_bytes_rexmit, tcpcb::sackblks, tcpcb::sackhint, SEQ_GEQ, SEQ_GT, SEQ_LT, tcpcb::server, tcpcb::snd_cwnd, tcpcb::snd_max, tcpcb::snd_nxt, tcpcb::snd_recover, tcpcb::snd_una, tcpcb::snd_up, tcpcb::snd_wnd, tcpcb::t_badrxtwin, tcpcb::t_flags, tcpcb::t_flags2, tcpcb::t_inpcb, tcpcb::t_maxseg, tcpcb::t_port, tcpcb::t_rcvtime, tcpcb::t_rtseq, tcpcb::t_rtttime, tcpcb::t_rxtcur, tcpcb::t_rxtshift, tcpcb::t_sndrexmitpack, tcpcb::t_sndtime, tcpcb::t_sndzerowin, tcpcb::t_softerror, tcpcb::t_state, tcpcb::t_stats, tcpcb::t_tfo_client_cookie_len, tcpcb::t_tfo_cookie, tcpcb::t_tsomax, tcpcb::t_tsomaxsegcount, tcpcb::t_tsomaxsegsize, TA_OUTPUT, tcp_account_for_send(), tcp_addoptions(), tcp_clean_dsack_blocks(), tcp_ecn_output_established(), tcp_ecn_output_syn_sent(), TCP_FASTOPEN_COOKIE_LEN, TCP_LOG_EVENT, TCP_LOG_OUT, tcp_m_copym(), tcp_maxseg(), tcp_mss_update(), tcp_mssopt(), tcp_offload_output(), tcp_pcap_add(), TCP_PROBE3, TCP_PROBE5, tcp_sack_adjust(), tcp_sack_output(), tcp_set_flags(), tcp_setpersist(), tcp_sndbuf_autoscale(), tcp_timer_activate(), tcp_timer_active(), tcp_trace(), tcp_ts_getticks(), TCP_XMIT_TIMER_ASSERT, tcpip_fillheaders(), TCPS_HAVEESTABLISHED, TCPS_HAVERCVDFIN, TCPS_HAVERCVDSYN, TCPS_SYN_RECEIVED, TCPS_SYN_SENT, TCPSTAT_ADD, TCPSTAT_INC, TF2_ECN_PERMIT, TF2_ECN_SND_ECE, TF2_PLPMTU_MAXSEGSNT, TF2_PLPMTU_PMTUD, TF_ACKNOW, TF_DELACK, TF_FORCEDATA, TF_GPUTINPROG, TF_LASTIDLE, TF_LRD, TF_MORETOCOME, TF_NEEDFIN, TF_NEEDSYN, TF_NODELAY, TF_NOOPT, TF_NOPUSH, TF_RCVD_TSTMP, TF_REQ_SCALE, TF_REQ_TSTMP, TF_RXWIN0SENT, TF_SACK_PERMIT, TF_SENTFIN, TF_SIGNATURE, TF_TOE, TF_TSO, tcpopt::to_flags, tcpopt::to_mss, tcpopt::to_nsacks, tcpopt::to_sacks, tcpopt::to_signature, 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, tcpcb::ts_offset, tcpcb::ts_recent, TT_DELACK, TT_PERSIST, TT_REXMT, UDPSTAT_INC, udphdr::uh_dport, udphdr::uh_sport, udphdr::uh_sum, udphdr::uh_ulen, V_path_mtu_discovery, V_tcp_do_ecn, V_tcp_do_tso, V_tcp_minmss, V_tcp_udp_tunneling_overhead, V_tcp_udp_tunneling_port, VOI_TCP_RETXPB, and VOI_TCP_TXPB.

Here is the call graph for this function:

◆ tcp_m_copym()

struct mbuf * tcp_m_copym ( struct mbuf *  m,
int32_t  off0,
int32_t *  plen,
int32_t  seglimit,
int32_t  segsize,
struct sockbuf *  sb,
bool  hw_tls 
)

Definition at line 1954 of file tcp_output.c.

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

Here is the caller graph for this function:

◆ tcp_setpersist()

void tcp_setpersist ( struct tcpcb tp)

Definition at line 1754 of file tcp_output.c.

References tcpcb::t_flags, tcpcb::t_rttvar, tcpcb::t_rxtshift, tcpcb::t_srtt, tcp_backoff, TCP_MAXRXTSHIFT, tcp_persmax, tcp_persmin, tcp_timer_activate(), tcp_timer_active(), TCPT_RANGESET, TT_PERSIST, and TT_REXMT.

Referenced by tcp_default_fb_init(), tcp_default_output(), tcp_timer_persist(), and tcp_timers_unsuspend().

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

◆ tcp_sndbuf_autoscale()

void tcp_sndbuf_autoscale ( struct tcpcb tp,
struct socket *  so,
uint32_t  sendwin 
)

Definition at line 2119 of file tcp_output.c.

References tcpcb::snd_nxt, tcpcb::snd_una, tcpcb::snd_wnd, V_tcp_autosndbuf_inc, V_tcp_autosndbuf_max, V_tcp_do_autosndbuf, and V_tcp_sendbuf_auto_lowat.

Referenced by bbr_output_wtime(), and tcp_default_output().

Here is the caller graph for this function:

◆ VNET_DEFINE() [1/7]

VNET_DEFINE ( int  ,
path_mtu_discovery   
)

◆ VNET_DEFINE() [2/7]

VNET_DEFINE ( int  ,
tcp_autosndbuf_inc   
)

◆ VNET_DEFINE() [3/7]

VNET_DEFINE ( int  ,
tcp_autosndbuf_max   
)

◆ VNET_DEFINE() [4/7]

VNET_DEFINE ( int  ,
tcp_do_autosndbuf   
)

◆ VNET_DEFINE() [5/7]

VNET_DEFINE ( int  ,
tcp_do_tso   
)

◆ VNET_DEFINE() [6/7]

VNET_DEFINE ( int  ,
tcp_sendbuf_auto_lowat   
)
pure virtual

◆ VNET_DEFINE() [7/7]

VNET_DEFINE ( int  ,
tcp_sendspace   
)