tcp_var.h revision 125783
11541Srgrimes/* 210937Swollman * Copyright (c) 1982, 1986, 1993, 1994, 1995 31541Srgrimes * The Regents of the University of California. All rights reserved. 41541Srgrimes * 51541Srgrimes * Redistribution and use in source and binary forms, with or without 61541Srgrimes * modification, are permitted provided that the following conditions 71541Srgrimes * are met: 81541Srgrimes * 1. Redistributions of source code must retain the above copyright 91541Srgrimes * notice, this list of conditions and the following disclaimer. 101541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111541Srgrimes * notice, this list of conditions and the following disclaimer in the 121541Srgrimes * documentation and/or other materials provided with the distribution. 131541Srgrimes * 3. All advertising materials mentioning features or use of this software 141541Srgrimes * must display the following acknowledgement: 151541Srgrimes * This product includes software developed by the University of 161541Srgrimes * California, Berkeley and its contributors. 171541Srgrimes * 4. Neither the name of the University nor the names of its contributors 181541Srgrimes * may be used to endorse or promote products derived from this software 191541Srgrimes * without specific prior written permission. 201541Srgrimes * 211541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311541Srgrimes * SUCH DAMAGE. 321541Srgrimes * 3310937Swollman * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 3450477Speter * $FreeBSD: head/sys/netinet/tcp_var.h 125783 2004-02-13 18:21:45Z bms $ 351541Srgrimes */ 361541Srgrimes 372169Spaul#ifndef _NETINET_TCP_VAR_H_ 382169Spaul#define _NETINET_TCP_VAR_H_ 3986764Sjlemon 4086764Sjlemon#include <netinet/in_pcb.h> /* needed for in_conninfo, inp_gen_t */ 4198102Shsu#include <netinet/tcp.h> 4286764Sjlemon 431541Srgrimes/* 441541Srgrimes * Kernel variables for tcp. 451541Srgrimes */ 4686764Sjlemonextern int tcp_do_rfc1323; 4786764Sjlemonextern int tcp_do_rfc1644; 481541Srgrimes 4955679Sshin/* TCP segment queue entry */ 5055679Sshinstruct tseg_qent { 5160938Sjake LIST_ENTRY(tseg_qent) tqe_q; 5255679Sshin int tqe_len; /* TCP segment data length */ 5355679Sshin struct tcphdr *tqe_th; /* a pointer to tcp header */ 5455679Sshin struct mbuf *tqe_m; /* mbuf contains packet */ 5555679Sshin}; 5660938SjakeLIST_HEAD(tsegqe_head, tseg_qent); 5755679Sshin#ifdef MALLOC_DECLARE 5855679SshinMALLOC_DECLARE(M_TSEGQ); 5955679Sshin#endif 6055679Sshin 6155679Sshinstruct tcptemp { 6255679Sshin u_char tt_ipgen[40]; /* the size must be of max ip header, now IPv6 */ 6355679Sshin struct tcphdr tt_t; 6455679Sshin}; 6555679Sshin 6655679Sshin#define tcp6cb tcpcb /* for KAME src sync over BSD*'s */ 6755679Sshin 681541Srgrimes/* 691541Srgrimes * Tcp control block, one per tcp; fields: 7032821Sdg * Organized for 16 byte cacheline efficiency. 711541Srgrimes */ 721541Srgrimesstruct tcpcb { 7355679Sshin struct tsegqe_head t_segq; 7432821Sdg int t_dupacks; /* consecutive dup acks recd */ 7578642Ssilby struct tcptemp *unused; /* unused */ 7632821Sdg 7750673Sjlemon struct callout *tt_rexmt; /* retransmit timer */ 7850673Sjlemon struct callout *tt_persist; /* retransmit persistence */ 7950673Sjlemon struct callout *tt_keep; /* keepalive */ 8050673Sjlemon struct callout *tt_2msl; /* 2*msl TIME_WAIT timer */ 8150673Sjlemon struct callout *tt_delack; /* delayed ACK timer */ 8232821Sdg 8332821Sdg struct inpcb *t_inpcb; /* back pointer to internet pcb */ 8411187Swollman int t_state; /* state of this connection */ 8511187Swollman u_int t_flags; 86117650Shsu#define TF_ACKNOW 0x000001 /* ack peer immediately */ 87117650Shsu#define TF_DELACK 0x000002 /* ack, but try to delay it */ 88117650Shsu#define TF_NODELAY 0x000004 /* don't delay packets to coalesce */ 89117650Shsu#define TF_NOOPT 0x000008 /* don't use tcp options */ 90117650Shsu#define TF_SENTFIN 0x000010 /* have sent FIN */ 91117650Shsu#define TF_REQ_SCALE 0x000020 /* have/will request window scaling */ 92117650Shsu#define TF_RCVD_SCALE 0x000040 /* other side has requested scaling */ 93117650Shsu#define TF_REQ_TSTMP 0x000080 /* have/will request timestamps */ 94117650Shsu#define TF_RCVD_TSTMP 0x000100 /* a timestamp was received in SYN */ 95117650Shsu#define TF_SACK_PERMIT 0x000200 /* other side said I could SACK */ 96117650Shsu#define TF_NEEDSYN 0x000400 /* send SYN (implicit state) */ 97117650Shsu#define TF_NEEDFIN 0x000800 /* send FIN (implicit state) */ 98117650Shsu#define TF_NOPUSH 0x001000 /* don't push */ 99117650Shsu#define TF_REQ_CC 0x002000 /* have/will request CC */ 100117650Shsu#define TF_RCVD_CC 0x004000 /* a CC was received in SYN */ 101117650Shsu#define TF_SENDCCNEW 0x008000 /* send CCnew instead of CC in SYN */ 102117650Shsu#define TF_MORETOCOME 0x010000 /* More data to be appended to sock */ 103117650Shsu#define TF_LQ_OVERFLOW 0x020000 /* listen queue overflow */ 104117650Shsu#define TF_LASTIDLE 0x040000 /* connection was previously idle */ 105117650Shsu#define TF_RXWIN0SENT 0x080000 /* sent a receiver win 0 in response */ 106117650Shsu#define TF_FASTRECOVERY 0x100000 /* in NewReno Fast Recovery */ 107117650Shsu#define TF_WASFRECOVERY 0x200000 /* was in NewReno Fast Recovery */ 108125680Sbms#define TF_SIGNATURE 0x400000 /* require MD5 digests (RFC2385) */ 10932821Sdg int t_force; /* 1 if forcing out a byte */ 1101541Srgrimes 1111541Srgrimes tcp_seq snd_una; /* send unacknowledged */ 11232821Sdg tcp_seq snd_max; /* highest sequence number sent; 11332821Sdg * used to recognize retransmits 11432821Sdg */ 1151541Srgrimes tcp_seq snd_nxt; /* send next */ 1161541Srgrimes tcp_seq snd_up; /* send urgent pointer */ 11732821Sdg 1181541Srgrimes tcp_seq snd_wl1; /* window update seg seq number */ 1191541Srgrimes tcp_seq snd_wl2; /* window update seg ack number */ 1201541Srgrimes tcp_seq iss; /* initial send sequence number */ 12132821Sdg tcp_seq irs; /* initial receive sequence number */ 12232821Sdg 12332821Sdg tcp_seq rcv_nxt; /* receive next */ 12432821Sdg tcp_seq rcv_adv; /* advertised window */ 1251541Srgrimes u_long rcv_wnd; /* receive window */ 1261541Srgrimes tcp_seq rcv_up; /* receive urgent pointer */ 12732821Sdg 12832821Sdg u_long snd_wnd; /* send window */ 1291541Srgrimes u_long snd_cwnd; /* congestion-controlled window */ 130102017Sdillon u_long snd_bwnd; /* bandwidth-controlled window */ 13113765Smpp u_long snd_ssthresh; /* snd_cwnd size threshold for 1321541Srgrimes * for slow start exponential to 1331541Srgrimes * linear switch 1341541Srgrimes */ 135102017Sdillon u_long snd_bandwidth; /* calculated bandwidth or 0 */ 136109175Shsu tcp_seq snd_recover; /* for use in NewReno Fast Recovery */ 13760067Sjlemon 13832821Sdg u_int t_maxopd; /* mss plus options */ 13932821Sdg 14050673Sjlemon u_long t_rcvtime; /* inactivity time */ 14150673Sjlemon u_long t_starttime; /* time connection was established */ 14250673Sjlemon int t_rtttime; /* round trip time */ 1431541Srgrimes tcp_seq t_rtseq; /* sequence number being timed */ 14432821Sdg 145102017Sdillon int t_bw_rtttime; /* used for bandwidth calculation */ 146102017Sdillon tcp_seq t_bw_rtseq; /* used for bandwidth calculation */ 147102017Sdillon 14850673Sjlemon int t_rxtcur; /* current retransmit value (ticks) */ 14932821Sdg u_int t_maxseg; /* maximum segment size */ 15011187Swollman int t_srtt; /* smoothed round-trip time */ 15111187Swollman int t_rttvar; /* variance in round-trip time */ 15232821Sdg 15332821Sdg int t_rxtshift; /* log(2) of rexmt exp. backoff */ 15411187Swollman u_int t_rttmin; /* minimum rtt allowed */ 155102017Sdillon u_int t_rttbest; /* best rtt we've seen */ 15632821Sdg u_long t_rttupdated; /* number of times rtt sampled */ 1571541Srgrimes u_long max_sndwnd; /* largest window peer has offered */ 1581541Srgrimes 15932821Sdg int t_softerror; /* possible error not yet reported */ 1601541Srgrimes/* out-of-band data */ 1611541Srgrimes char t_oobflags; /* have some */ 1621541Srgrimes char t_iobc; /* input character */ 1631541Srgrimes#define TCPOOB_HAVEDATA 0x01 1641541Srgrimes#define TCPOOB_HADDATA 0x02 1651541Srgrimes/* RFC 1323 variables */ 1661541Srgrimes u_char snd_scale; /* window scaling for send window */ 1671541Srgrimes u_char rcv_scale; /* window scaling for recv window */ 1681541Srgrimes u_char request_r_scale; /* pending window scaling */ 1691541Srgrimes u_char requested_s_scale; 1701541Srgrimes u_long ts_recent; /* timestamp echo data */ 17132821Sdg 1721541Srgrimes u_long ts_recent_age; /* when last updated */ 1731541Srgrimes tcp_seq last_ack_sent; 1746247Swollman/* RFC 1644 variables */ 1756247Swollman tcp_cc cc_send; /* send connection count */ 1766247Swollman tcp_cc cc_recv; /* receive connection count */ 17750673Sjlemon/* experimental */ 17850673Sjlemon u_long snd_cwnd_prev; /* cwnd prior to retransmit */ 17950673Sjlemon u_long snd_ssthresh_prev; /* ssthresh prior to retransmit */ 180117650Shsu tcp_seq snd_recover_prev; /* snd_recover prior to retransmit */ 18150673Sjlemon u_long t_badrxtwin; /* window for retransmit recovery */ 182112957Shsu u_char snd_limited; /* segments limited transmitted */ 183124258Sandre/* anti DoS counters */ 184124258Sandre u_long rcv_second; /* start of interval second */ 185124258Sandre u_long rcv_pps; /* received packets per second */ 186124258Sandre u_long rcv_byps; /* received bytes per second */ 1871541Srgrimes}; 1881541Srgrimes 189117650Shsu#define IN_FASTRECOVERY(tp) (tp->t_flags & TF_FASTRECOVERY) 190117650Shsu#define ENTER_FASTRECOVERY(tp) tp->t_flags |= TF_FASTRECOVERY 191117650Shsu#define EXIT_FASTRECOVERY(tp) tp->t_flags &= ~TF_FASTRECOVERY 192117650Shsu 193125680Sbms#ifdef TCP_SIGNATURE 1946247Swollman/* 195125680Sbms * Defines which are needed by the xform_tcp module and tcp_[in|out]put 196125680Sbms * for SADB verification and lookup. 197125680Sbms */ 198125680Sbms#define TCP_SIGLEN 16 /* length of computed digest in bytes */ 199125680Sbms#define TCP_KEYLEN_MIN 1 /* minimum length of TCP-MD5 key */ 200125680Sbms#define TCP_KEYLEN_MAX 80 /* maximum length of TCP-MD5 key */ 201125680Sbms/* 202125680Sbms * Only a single SA per host may be specified at this time. An SPI is 203125680Sbms * needed in order for the KEY_ALLOCSA() lookup to work. 204125680Sbms */ 205125680Sbms#define TCP_SIG_SPI 0x1000 206125680Sbms#endif /* TCP_SIGNATURE */ 207125680Sbms 208125680Sbms/* 2096247Swollman * Structure to hold TCP options that are only used during segment 2106247Swollman * processing (in tcp_input), but not held in the tcpcb. 2116247Swollman * It's basically used to reduce the number of parameters 2126247Swollman * to tcp_dooptions. 2136247Swollman */ 2146247Swollmanstruct tcpopt { 21586764Sjlemon u_long to_flags; /* which options are present */ 2166247Swollman#define TOF_TS 0x0001 /* timestamp */ 2176247Swollman#define TOF_CC 0x0002 /* CC and CCnew are exclusive */ 2186247Swollman#define TOF_CCNEW 0x0004 2196247Swollman#define TOF_CCECHO 0x0008 22086764Sjlemon#define TOF_MSS 0x0010 22186764Sjlemon#define TOF_SCALE 0x0020 222125680Sbms#define TOF_SIGNATURE 0x0040 /* signature option present */ 223125680Sbms#define TOF_SIGLEN 0x0080 /* sigature length valid (RFC2385) */ 22486764Sjlemon u_int32_t to_tsval; 22586764Sjlemon u_int32_t to_tsecr; 22686764Sjlemon tcp_cc to_cc; /* holds CC or CCnew */ 22786764Sjlemon tcp_cc to_ccecho; 22886764Sjlemon u_int16_t to_mss; 22986764Sjlemon u_int8_t to_requested_s_scale; 23086764Sjlemon u_int8_t to_pad; 2316247Swollman}; 2326247Swollman 23386764Sjlemonstruct syncache { 23486764Sjlemon inp_gen_t sc_inp_gencnt; /* pointer check */ 23586764Sjlemon struct tcpcb *sc_tp; /* tcb for listening socket */ 23686764Sjlemon struct mbuf *sc_ipopts; /* source route */ 23786764Sjlemon struct in_conninfo sc_inc; /* addresses */ 23886764Sjlemon u_int32_t sc_tsrecent; 23986764Sjlemon tcp_cc sc_cc_send; /* holds CC or CCnew */ 24086764Sjlemon tcp_cc sc_cc_recv; 24186764Sjlemon tcp_seq sc_irs; /* seq from peer */ 24286764Sjlemon tcp_seq sc_iss; /* our ISS */ 24386764Sjlemon u_long sc_rxttime; /* retransmit time */ 24486764Sjlemon u_int16_t sc_rxtslot; /* retransmit counter */ 24586764Sjlemon u_int16_t sc_peer_mss; /* peer's MSS */ 24686764Sjlemon u_int16_t sc_wnd; /* advertised window */ 24786764Sjlemon u_int8_t sc_requested_s_scale:4, 24886764Sjlemon sc_request_r_scale:4; 24986764Sjlemon u_int8_t sc_flags; 25086764Sjlemon#define SCF_NOOPT 0x01 /* no TCP options */ 25186764Sjlemon#define SCF_WINSCALE 0x02 /* negotiated window scaling */ 25286764Sjlemon#define SCF_TIMESTAMP 0x04 /* negotiated timestamps */ 25386764Sjlemon#define SCF_CC 0x08 /* negotiated CC */ 25486764Sjlemon#define SCF_UNREACH 0x10 /* icmp unreachable received */ 255125680Sbms#define SCF_SIGNATURE 0x20 /* send MD5 digests */ 25686764Sjlemon TAILQ_ENTRY(syncache) sc_hash; 25786764Sjlemon TAILQ_ENTRY(syncache) sc_timerq; 25886764Sjlemon}; 25986764Sjlemon 26086764Sjlemonstruct syncache_head { 26186764Sjlemon TAILQ_HEAD(, syncache) sch_bucket; 26286764Sjlemon u_int sch_length; 26386764Sjlemon}; 264111145Sjlemon 265122922Sandrestruct hc_metrics_lite { /* must stay in sync with hc_metrics */ 266122922Sandre u_long rmx_mtu; /* MTU for this path */ 267122922Sandre u_long rmx_ssthresh; /* outbound gateway buffer limit */ 268122922Sandre u_long rmx_rtt; /* estimated round trip time */ 269122922Sandre u_long rmx_rttvar; /* estimated rtt variance */ 270122922Sandre u_long rmx_bandwidth; /* estimated bandwidth */ 271122922Sandre u_long rmx_cwnd; /* congestion window */ 272122922Sandre u_long rmx_sendpipe; /* outbound delay-bandwidth product */ 273122922Sandre u_long rmx_recvpipe; /* inbound delay-bandwidth product */ 274122922Sandre}; 275122922Sandre 276111145Sjlemonstruct tcptw { 277111145Sjlemon struct inpcb *tw_inpcb; /* XXX back pointer to internet pcb */ 278111145Sjlemon tcp_seq snd_nxt; 279111145Sjlemon tcp_seq rcv_nxt; 280121850Ssilby tcp_seq iss; 281121884Ssilby tcp_seq irs; 282111145Sjlemon tcp_cc cc_recv; 283111145Sjlemon tcp_cc cc_send; 284111145Sjlemon u_short last_win; /* cached window value */ 285111145Sjlemon u_short tw_so_options; /* copy of so_options */ 286111145Sjlemon struct ucred *tw_cred; /* user credentials */ 287111145Sjlemon u_long t_recent; 288111145Sjlemon u_long t_starttime; 289112009Sjlemon int tw_time; 290112009Sjlemon LIST_ENTRY(tcptw) tw_2msl; 291111145Sjlemon}; 29286764Sjlemon 2936247Swollman/* 294122922Sandre * The TAO cache entry which is stored in the tcp hostcache. 2956247Swollman */ 2966247Swollmanstruct rmxp_tao { 2976247Swollman tcp_cc tao_cc; /* latest CC in valid SYN */ 2986247Swollman tcp_cc tao_ccsent; /* latest CC sent to peer */ 2996247Swollman u_short tao_mssopt; /* peer's cached MSS */ 3006247Swollman#ifdef notyet 3016247Swollman u_short tao_flags; /* cache status flags */ 3026247Swollman#define TAOF_DONT 0x0001 /* peer doesn't understand rfc1644 */ 3036247Swollman#define TAOF_OK 0x0002 /* peer does understand rfc1644 */ 3046247Swollman#define TAOF_UNDEF 0 /* we don't know yet */ 3056247Swollman#endif /* notyet */ 3066247Swollman}; 3076247Swollman 3081541Srgrimes#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) 309111145Sjlemon#define intotw(ip) ((struct tcptw *)(ip)->inp_ppcb) 3101541Srgrimes#define sototcpcb(so) (intotcpcb(sotoinpcb(so))) 3111541Srgrimes 3121541Srgrimes/* 3131541Srgrimes * The smoothed round-trip time and estimated variance 3141541Srgrimes * are stored as fixed point numbers scaled by the values below. 3151541Srgrimes * For convenience, these scales are also used in smoothing the average 3161541Srgrimes * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed). 3171541Srgrimes * With these scales, srtt has 3 bits to the right of the binary point, 3181541Srgrimes * and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the 3191541Srgrimes * binary point, and is smoothed with an ALPHA of 0.75. 3201541Srgrimes */ 32114753Swollman#define TCP_RTT_SCALE 32 /* multiplier for srtt; 3 bits frac. */ 32214753Swollman#define TCP_RTT_SHIFT 5 /* shift for srtt; 3 bits frac. */ 32314753Swollman#define TCP_RTTVAR_SCALE 16 /* multiplier for rttvar; 2 bits */ 32414753Swollman#define TCP_RTTVAR_SHIFT 4 /* shift for rttvar; 2 bits */ 32514753Swollman#define TCP_DELTA_SHIFT 2 /* see tcp_input.c */ 3261541Srgrimes 3271541Srgrimes/* 3281541Srgrimes * The initial retransmission should happen at rtt + 4 * rttvar. 3291541Srgrimes * Because of the way we do the smoothing, srtt and rttvar 3301541Srgrimes * will each average +1/2 tick of bias. When we compute 3311541Srgrimes * the retransmit timer, we want 1/2 tick of rounding and 3321541Srgrimes * 1 extra tick because of +-1/2 tick uncertainty in the 3331541Srgrimes * firing of the timer. The bias will give us exactly the 3341541Srgrimes * 1.5 tick we need. But, because the bias is 3351541Srgrimes * statistical, we have to test that we don't drop below 3361541Srgrimes * the minimum feasible timer (which is 2 ticks). 33714753Swollman * This version of the macro adapted from a paper by Lawrence 33814753Swollman * Brakmo and Larry Peterson which outlines a problem caused 33914753Swollman * by insufficient precision in the original implementation, 34014753Swollman * which results in inappropriately large RTO values for very 34114753Swollman * fast networks. 3421541Srgrimes */ 3431541Srgrimes#define TCP_REXMTVAL(tp) \ 34435419Sdg max((tp)->t_rttmin, (((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT)) \ 34516141Swollman + (tp)->t_rttvar) >> TCP_DELTA_SHIFT) 3461541Srgrimes 3471541Srgrimes/* 3481541Srgrimes * TCP statistics. 3491541Srgrimes * Many of these should be kept per connection, 3501541Srgrimes * but that's inconvenient at the moment. 3511541Srgrimes */ 3521541Srgrimesstruct tcpstat { 3531541Srgrimes u_long tcps_connattempt; /* connections initiated */ 3541541Srgrimes u_long tcps_accepts; /* connections accepted */ 3551541Srgrimes u_long tcps_connects; /* connections established */ 3561541Srgrimes u_long tcps_drops; /* connections dropped */ 3571541Srgrimes u_long tcps_conndrops; /* embryonic connections dropped */ 358124258Sandre u_long tcps_minmssdrops; /* average minmss too low drops */ 3591541Srgrimes u_long tcps_closed; /* conn. closed (includes drops) */ 3601541Srgrimes u_long tcps_segstimed; /* segs where we tried to get rtt */ 3611541Srgrimes u_long tcps_rttupdated; /* times we succeeded */ 3621541Srgrimes u_long tcps_delack; /* delayed acks sent */ 3631541Srgrimes u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ 3641541Srgrimes u_long tcps_rexmttimeo; /* retransmit timeouts */ 3651541Srgrimes u_long tcps_persisttimeo; /* persist timeouts */ 3661541Srgrimes u_long tcps_keeptimeo; /* keepalive timeouts */ 3671541Srgrimes u_long tcps_keepprobe; /* keepalive probes sent */ 3681541Srgrimes u_long tcps_keepdrops; /* connections dropped in keepalive */ 3691541Srgrimes 3701541Srgrimes u_long tcps_sndtotal; /* total packets sent */ 3711541Srgrimes u_long tcps_sndpack; /* data packets sent */ 3721541Srgrimes u_long tcps_sndbyte; /* data bytes sent */ 3731541Srgrimes u_long tcps_sndrexmitpack; /* data packets retransmitted */ 3741541Srgrimes u_long tcps_sndrexmitbyte; /* data bytes retransmitted */ 375100373Sdillon u_long tcps_sndrexmitbad; /* unnecessary packet retransmissions */ 3761541Srgrimes u_long tcps_sndacks; /* ack-only packets sent */ 3771541Srgrimes u_long tcps_sndprobe; /* window probes sent */ 3781541Srgrimes u_long tcps_sndurg; /* packets sent with URG only */ 3791541Srgrimes u_long tcps_sndwinup; /* window update-only packets sent */ 3801541Srgrimes u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ 3811541Srgrimes 3821541Srgrimes u_long tcps_rcvtotal; /* total packets received */ 3831541Srgrimes u_long tcps_rcvpack; /* packets received in sequence */ 3841541Srgrimes u_long tcps_rcvbyte; /* bytes received in sequence */ 3851541Srgrimes u_long tcps_rcvbadsum; /* packets received with ccksum errs */ 3861541Srgrimes u_long tcps_rcvbadoff; /* packets received with bad offset */ 38752904Sshin u_long tcps_rcvmemdrop; /* packets dropped for lack of memory */ 3881541Srgrimes u_long tcps_rcvshort; /* packets received too short */ 3891541Srgrimes u_long tcps_rcvduppack; /* duplicate-only packets received */ 3901541Srgrimes u_long tcps_rcvdupbyte; /* duplicate-only bytes received */ 3911541Srgrimes u_long tcps_rcvpartduppack; /* packets with some duplicate data */ 3921541Srgrimes u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ 3931541Srgrimes u_long tcps_rcvoopack; /* out-of-order packets received */ 3941541Srgrimes u_long tcps_rcvoobyte; /* out-of-order bytes received */ 3951541Srgrimes u_long tcps_rcvpackafterwin; /* packets with data after window */ 3961541Srgrimes u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */ 3971541Srgrimes u_long tcps_rcvafterclose; /* packets rcvd after "close" */ 3981541Srgrimes u_long tcps_rcvwinprobe; /* rcvd window probe packets */ 3991541Srgrimes u_long tcps_rcvdupack; /* rcvd duplicate acks */ 4001541Srgrimes u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */ 4011541Srgrimes u_long tcps_rcvackpack; /* rcvd ack packets */ 4021541Srgrimes u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */ 4031541Srgrimes u_long tcps_rcvwinupd; /* rcvd window update packets */ 4041541Srgrimes u_long tcps_pawsdrop; /* segments dropped due to PAWS */ 4051541Srgrimes u_long tcps_predack; /* times hdr predict ok for acks */ 4061541Srgrimes u_long tcps_preddat; /* times hdr predict ok for data pkts */ 4071541Srgrimes u_long tcps_pcbcachemiss; 4089263Swollman u_long tcps_cachedrtt; /* times cached RTT in route updated */ 4099263Swollman u_long tcps_cachedrttvar; /* times cached rttvar updated */ 4109263Swollman u_long tcps_cachedssthresh; /* times cached ssthresh updated */ 4119470Swollman u_long tcps_usedrtt; /* times RTT initialized from route */ 4129470Swollman u_long tcps_usedrttvar; /* times RTTVAR initialized from rt */ 4139470Swollman u_long tcps_usedssthresh; /* times ssthresh initialized from rt*/ 41410937Swollman u_long tcps_persistdrop; /* timeout in persist state */ 41510937Swollman u_long tcps_badsyn; /* bogus SYN, e.g. premature ACK */ 41611415Swollman u_long tcps_mturesent; /* resends due to MTU discovery */ 41714281Sbde u_long tcps_listendrop; /* listen queue overflows */ 41886764Sjlemon 41986764Sjlemon u_long tcps_sc_added; /* entry added to syncache */ 42086764Sjlemon u_long tcps_sc_retransmitted; /* syncache entry was retransmitted */ 42186764Sjlemon u_long tcps_sc_dupsyn; /* duplicate SYN packet */ 42286764Sjlemon u_long tcps_sc_dropped; /* could not reply to packet */ 42386764Sjlemon u_long tcps_sc_completed; /* successful extraction of entry */ 42486764Sjlemon u_long tcps_sc_bucketoverflow; /* syncache per-bucket limit hit */ 42586764Sjlemon u_long tcps_sc_cacheoverflow; /* syncache cache limit hit */ 42686764Sjlemon u_long tcps_sc_reset; /* RST removed entry from syncache */ 42786764Sjlemon u_long tcps_sc_stale; /* timed out or listen socket gone */ 42886764Sjlemon u_long tcps_sc_aborted; /* syncache entry aborted */ 42986764Sjlemon u_long tcps_sc_badack; /* removed due to bad ACK */ 43086764Sjlemon u_long tcps_sc_unreach; /* ICMP unreachable received */ 43186764Sjlemon u_long tcps_sc_zonefail; /* zalloc() failed */ 43286764Sjlemon u_long tcps_sc_sendcookie; /* SYN cookie sent */ 43386764Sjlemon u_long tcps_sc_recvcookie; /* SYN cookie received */ 434122922Sandre 435122922Sandre u_long tcps_hc_added; /* entry added to hostcache */ 436122922Sandre u_long tcps_hc_bucketoverflow; /* hostcache per bucket limit hit */ 4371541Srgrimes}; 4381541Srgrimes 4396247Swollman/* 44036079Swollman * TCB structure exported to user-land via sysctl(3). 44137183Sjhay * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been 44237183Sjhay * included. Not all of our clients do. 44336079Swollman */ 44437183Sjhay#if defined(_NETINET_IN_PCB_H_) && defined(_SYS_SOCKETVAR_H_) 44536079Swollmanstruct xtcpcb { 44636079Swollman size_t xt_len; 44736079Swollman struct inpcb xt_inp; 44836079Swollman struct tcpcb xt_tp; 44936079Swollman struct xsocket xt_socket; 45036079Swollman u_quad_t xt_alignment_hack; 45136079Swollman}; 45236079Swollman#endif 45336079Swollman 45436079Swollman/* 4556247Swollman * Names for TCP sysctl objects 4566247Swollman */ 4576247Swollman#define TCPCTL_DO_RFC1323 1 /* use RFC-1323 extensions */ 4586247Swollman#define TCPCTL_DO_RFC1644 2 /* use RFC-1644 extensions */ 4596247Swollman#define TCPCTL_MSSDFLT 3 /* MSS default */ 4606472Swollman#define TCPCTL_STATS 4 /* statistics (read-only) */ 4616472Swollman#define TCPCTL_RTTDFLT 5 /* default RTT estimate */ 4626472Swollman#define TCPCTL_KEEPIDLE 6 /* keepalive idle timer */ 4636472Swollman#define TCPCTL_KEEPINTVL 7 /* interval to send keepalives */ 46418281Spst#define TCPCTL_SENDSPACE 8 /* send buffer space */ 46518281Spst#define TCPCTL_RECVSPACE 9 /* receive buffer space */ 46663431Ssheldonh#define TCPCTL_KEEPINIT 10 /* timeout for establishing syn */ 46736079Swollman#define TCPCTL_PCBLIST 11 /* list of all outstanding PCBs */ 46850673Sjlemon#define TCPCTL_DELACKTIME 12 /* time before sending delayed ACK */ 46952904Sshin#define TCPCTL_V6MSSDFLT 13 /* MSS default for IPv6 */ 47052904Sshin#define TCPCTL_MAXID 14 4716247Swollman 4726247Swollman#define TCPCTL_NAMES { \ 4736247Swollman { 0, 0 }, \ 4746348Swollman { "rfc1323", CTLTYPE_INT }, \ 4756348Swollman { "rfc1644", CTLTYPE_INT }, \ 4766247Swollman { "mssdflt", CTLTYPE_INT }, \ 4776472Swollman { "stats", CTLTYPE_STRUCT }, \ 4786472Swollman { "rttdflt", CTLTYPE_INT }, \ 4796472Swollman { "keepidle", CTLTYPE_INT }, \ 4806472Swollman { "keepintvl", CTLTYPE_INT }, \ 4816472Swollman { "sendspace", CTLTYPE_INT }, \ 4826472Swollman { "recvspace", CTLTYPE_INT }, \ 48318281Spst { "keepinit", CTLTYPE_INT }, \ 48436079Swollman { "pcblist", CTLTYPE_STRUCT }, \ 48550673Sjlemon { "delacktime", CTLTYPE_INT }, \ 48652904Sshin { "v6mssdflt", CTLTYPE_INT }, \ 487122922Sandre { "maxid", CTLTYPE_INT }, \ 4886247Swollman} 4896247Swollman 49044078Sdfr 49155205Speter#ifdef _KERNEL 49244078Sdfr#ifdef SYSCTL_DECL 49344078SdfrSYSCTL_DECL(_net_inet_tcp); 49444078Sdfr#endif 49544078Sdfr 4967684Sdgextern struct inpcbhead tcb; /* head of queue of active tcpcb's */ 4977684Sdgextern struct inpcbinfo tcbinfo; 4986348Swollmanextern struct tcpstat tcpstat; /* tcp statistics */ 4997090Sbdeextern int tcp_mssdflt; /* XXX */ 500124258Sandreextern int tcp_minmss; 501124258Sandreextern int tcp_minmssoverload; 50233846Sdgextern int tcp_delack_enabled; 50360067Sjlemonextern int tcp_do_newreno; 50498204Ssilbyextern int path_mtu_discovery; 50550673Sjlemonextern int ss_fltsz; 50650673Sjlemonextern int ss_fltsz_local; 5071541Srgrimes 50892723Salfredvoid tcp_canceltimers(struct tcpcb *); 5091541Srgrimesstruct tcpcb * 51092723Salfred tcp_close(struct tcpcb *); 511111145Sjlemonvoid tcp_twstart(struct tcpcb *); 512121850Ssilbyint tcp_twrecycleable(struct tcptw *tw); 513112009Sjlemonstruct tcptw * 514112009Sjlemon tcp_twclose(struct tcptw *_tw, int _reuse); 51592723Salfredvoid tcp_ctlinput(int, struct sockaddr *, void *); 51692723Salfredint tcp_ctloutput(struct socket *, struct sockopt *); 5171541Srgrimesstruct tcpcb * 51892723Salfred tcp_drop(struct tcpcb *, int); 51992723Salfredvoid tcp_drain(void); 52092723Salfredvoid tcp_fasttimo(void); 52192723Salfredvoid tcp_init(void); 52292723Salfredvoid tcp_input(struct mbuf *, int); 523122922Sandreu_long tcp_maxmtu(struct in_conninfo *); 524122922Sandreu_long tcp_maxmtu6(struct in_conninfo *); 52592723Salfredvoid tcp_mss(struct tcpcb *, int); 526122922Sandreint tcp_mssopt(struct in_conninfo *); 52798211Shsustruct inpcb * 52898211Shsu tcp_drop_syn_sent(struct inpcb *, int); 52998211Shsustruct inpcb * 53098211Shsu tcp_mtudisc(struct inpcb *, int); 5311541Srgrimesstruct tcpcb * 53292723Salfred tcp_newtcpcb(struct inpcb *); 53392723Salfredint tcp_output(struct tcpcb *); 53498211Shsustruct inpcb * 53598211Shsu tcp_quench(struct inpcb *, int); 53692723Salfredvoid tcp_respond(struct tcpcb *, void *, 53792723Salfred struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, int); 538114794Srwatsonint tcp_twrespond(struct tcptw *, struct socket *, struct mbuf *, int); 53992723Salfredvoid tcp_setpersist(struct tcpcb *); 540125783Sbms#ifdef TCP_SIGNATURE 541125783Sbmsint tcp_signature_compute(struct mbuf *, int, int, int, u_char *, u_int); 542125783Sbms#endif 54392723Salfredvoid tcp_slowtimo(void); 54455679Sshinstruct tcptemp * 545111144Sjlemon tcpip_maketemplate(struct inpcb *); 546111144Sjlemonvoid tcpip_fillheaders(struct inpcb *, void *, void *); 5471541Srgrimesstruct tcpcb * 54892723Salfred tcp_timers(struct tcpcb *, int); 54992723Salfredvoid tcp_trace(int, int, struct tcpcb *, void *, struct tcphdr *, int); 550102017Sdillonvoid tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq); 55186764Sjlemonvoid syncache_init(void); 55286764Sjlemonvoid syncache_unreach(struct in_conninfo *, struct tcphdr *); 55386764Sjlemonint syncache_expand(struct in_conninfo *, struct tcphdr *, 55486764Sjlemon struct socket **, struct mbuf *); 55586764Sjlemonint syncache_add(struct in_conninfo *, struct tcpopt *, 55686764Sjlemon struct tcphdr *, struct socket **, struct mbuf *); 55786764Sjlemonvoid syncache_chkrst(struct in_conninfo *, struct tcphdr *); 55886764Sjlemonvoid syncache_badack(struct in_conninfo *); 559122922Sandre/* 560122922Sandre * All tcp_hc_* functions are IPv4 and IPv6 (via in_conninfo) 561122922Sandre */ 562122922Sandrevoid tcp_hc_init(void); 563122922Sandrevoid tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *); 564122922Sandreu_long tcp_hc_getmtu(struct in_conninfo *); 565122922Sandrevoid tcp_hc_gettao(struct in_conninfo *, struct rmxp_tao *); 566122922Sandrevoid tcp_hc_updatemtu(struct in_conninfo *, u_long); 567122922Sandrevoid tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *); 568122922Sandrevoid tcp_hc_updatetao(struct in_conninfo *, int, tcp_cc, u_short); 569122922Sandre/* update which tao field */ 570122922Sandre#define TCP_HC_TAO_CC 0x1 571122922Sandre#define TCP_HC_TAO_CCSENT 0x2 572122922Sandre#define TCP_HC_TAO_MSSOPT 0x3 5739470Swollman 57417096Swollmanextern struct pr_usrreqs tcp_usrreqs; 5759470Swollmanextern u_long tcp_sendspace; 5769470Swollmanextern u_long tcp_recvspace; 57792723Salfredtcp_seq tcp_new_isn(struct tcpcb *); 5789470Swollman 57955205Speter#endif /* _KERNEL */ 5802169Spaul 5816348Swollman#endif /* _NETINET_TCP_VAR_H_ */ 582