tcp_var.h revision 166405
1139823Simp/*- 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 * 4. Neither the name of the University nor the names of its contributors 141541Srgrimes * may be used to endorse or promote products derived from this software 151541Srgrimes * without specific prior written permission. 161541Srgrimes * 171541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271541Srgrimes * SUCH DAMAGE. 281541Srgrimes * 2910937Swollman * @(#)tcp_var.h 8.4 (Berkeley) 5/24/95 3050477Speter * $FreeBSD: head/sys/netinet/tcp_var.h 166405 2007-02-01 18:32:13Z andre $ 311541Srgrimes */ 321541Srgrimes 332169Spaul#ifndef _NETINET_TCP_VAR_H_ 342169Spaul#define _NETINET_TCP_VAR_H_ 3586764Sjlemon 3698102Shsu#include <netinet/tcp.h> 3786764Sjlemon 381541Srgrimes/* 391541Srgrimes * Kernel variables for tcp. 401541Srgrimes */ 4186764Sjlemonextern int tcp_do_rfc1323; 421541Srgrimes 4355679Sshin/* TCP segment queue entry */ 4455679Sshinstruct tseg_qent { 4560938Sjake LIST_ENTRY(tseg_qent) tqe_q; 4655679Sshin int tqe_len; /* TCP segment data length */ 4755679Sshin struct tcphdr *tqe_th; /* a pointer to tcp header */ 4855679Sshin struct mbuf *tqe_m; /* mbuf contains packet */ 4955679Sshin}; 5060938SjakeLIST_HEAD(tsegqe_head, tseg_qent); 51126193Sandreextern int tcp_reass_qsize; 52126225Sbdeextern struct uma_zone *tcp_reass_zone; 5355679Sshin 54130989Spsstruct sackblk { 55130989Sps tcp_seq start; /* start seq no. of sack block */ 56131078Sbms tcp_seq end; /* end seq no. */ 57130989Sps}; 58130989Sps 59130989Spsstruct sackhole { 60130989Sps tcp_seq start; /* start seq no. of hole */ 61130989Sps tcp_seq end; /* end seq no. */ 62130989Sps tcp_seq rxmit; /* next seq. no in hole to be retransmitted */ 63145370Sps TAILQ_ENTRY(sackhole) scblink; /* scoreboard linkage */ 64130989Sps}; 65131078Sbms 66146123Spsstruct sackhint { 67146123Sps struct sackhole *nexthole; 68146123Sps int sack_bytes_rexmit; 69146123Sps}; 70146123Sps 7155679Sshinstruct tcptemp { 7255679Sshin u_char tt_ipgen[40]; /* the size must be of max ip header, now IPv6 */ 7355679Sshin struct tcphdr tt_t; 7455679Sshin}; 7555679Sshin 7655679Sshin#define tcp6cb tcpcb /* for KAME src sync over BSD*'s */ 7755679Sshin 781541Srgrimes/* 791541Srgrimes * Tcp control block, one per tcp; fields: 8032821Sdg * Organized for 16 byte cacheline efficiency. 811541Srgrimes */ 821541Srgrimesstruct tcpcb { 83126193Sandre struct tsegqe_head t_segq; /* segment reassembly queue */ 84126193Sandre int t_segqlen; /* segment reassembly queue length */ 8532821Sdg int t_dupacks; /* consecutive dup acks recd */ 8632821Sdg 8750673Sjlemon struct callout *tt_rexmt; /* retransmit timer */ 8850673Sjlemon struct callout *tt_persist; /* retransmit persistence */ 8950673Sjlemon struct callout *tt_keep; /* keepalive */ 9050673Sjlemon struct callout *tt_2msl; /* 2*msl TIME_WAIT timer */ 9150673Sjlemon struct callout *tt_delack; /* delayed ACK timer */ 9232821Sdg 9332821Sdg struct inpcb *t_inpcb; /* back pointer to internet pcb */ 9411187Swollman int t_state; /* state of this connection */ 9511187Swollman u_int t_flags; 96117650Shsu#define TF_ACKNOW 0x000001 /* ack peer immediately */ 97117650Shsu#define TF_DELACK 0x000002 /* ack, but try to delay it */ 98117650Shsu#define TF_NODELAY 0x000004 /* don't delay packets to coalesce */ 99117650Shsu#define TF_NOOPT 0x000008 /* don't use tcp options */ 100117650Shsu#define TF_SENTFIN 0x000010 /* have sent FIN */ 101117650Shsu#define TF_REQ_SCALE 0x000020 /* have/will request window scaling */ 102117650Shsu#define TF_RCVD_SCALE 0x000040 /* other side has requested scaling */ 103117650Shsu#define TF_REQ_TSTMP 0x000080 /* have/will request timestamps */ 104117650Shsu#define TF_RCVD_TSTMP 0x000100 /* a timestamp was received in SYN */ 105117650Shsu#define TF_SACK_PERMIT 0x000200 /* other side said I could SACK */ 106117650Shsu#define TF_NEEDSYN 0x000400 /* send SYN (implicit state) */ 107117650Shsu#define TF_NEEDFIN 0x000800 /* send FIN (implicit state) */ 108117650Shsu#define TF_NOPUSH 0x001000 /* don't push */ 109117650Shsu#define TF_MORETOCOME 0x010000 /* More data to be appended to sock */ 110117650Shsu#define TF_LQ_OVERFLOW 0x020000 /* listen queue overflow */ 111117650Shsu#define TF_LASTIDLE 0x040000 /* connection was previously idle */ 112117650Shsu#define TF_RXWIN0SENT 0x080000 /* sent a receiver win 0 in response */ 113117650Shsu#define TF_FASTRECOVERY 0x100000 /* in NewReno Fast Recovery */ 114117650Shsu#define TF_WASFRECOVERY 0x200000 /* was in NewReno Fast Recovery */ 115125680Sbms#define TF_SIGNATURE 0x400000 /* require MD5 digests (RFC2385) */ 116146463Sps#define TF_FORCEDATA 0x800000 /* force out a byte */ 117162084Sandre#define TF_TSO 0x1000000 /* TSO enabled on this connection */ 1181541Srgrimes 1191541Srgrimes tcp_seq snd_una; /* send unacknowledged */ 12032821Sdg tcp_seq snd_max; /* highest sequence number sent; 12132821Sdg * used to recognize retransmits 12232821Sdg */ 1231541Srgrimes tcp_seq snd_nxt; /* send next */ 1241541Srgrimes tcp_seq snd_up; /* send urgent pointer */ 12532821Sdg 1261541Srgrimes tcp_seq snd_wl1; /* window update seg seq number */ 1271541Srgrimes tcp_seq snd_wl2; /* window update seg ack number */ 1281541Srgrimes tcp_seq iss; /* initial send sequence number */ 12932821Sdg tcp_seq irs; /* initial receive sequence number */ 13032821Sdg 13132821Sdg tcp_seq rcv_nxt; /* receive next */ 13232821Sdg tcp_seq rcv_adv; /* advertised window */ 1331541Srgrimes u_long rcv_wnd; /* receive window */ 1341541Srgrimes tcp_seq rcv_up; /* receive urgent pointer */ 13532821Sdg 13632821Sdg u_long snd_wnd; /* send window */ 1371541Srgrimes u_long snd_cwnd; /* congestion-controlled window */ 138102017Sdillon u_long snd_bwnd; /* bandwidth-controlled window */ 13913765Smpp u_long snd_ssthresh; /* snd_cwnd size threshold for 1401541Srgrimes * for slow start exponential to 1411541Srgrimes * linear switch 1421541Srgrimes */ 143102017Sdillon u_long snd_bandwidth; /* calculated bandwidth or 0 */ 144109175Shsu tcp_seq snd_recover; /* for use in NewReno Fast Recovery */ 14560067Sjlemon 14632821Sdg u_int t_maxopd; /* mss plus options */ 14732821Sdg 14850673Sjlemon u_long t_rcvtime; /* inactivity time */ 14950673Sjlemon u_long t_starttime; /* time connection was established */ 15050673Sjlemon int t_rtttime; /* round trip time */ 1511541Srgrimes tcp_seq t_rtseq; /* sequence number being timed */ 15232821Sdg 153102017Sdillon int t_bw_rtttime; /* used for bandwidth calculation */ 154102017Sdillon tcp_seq t_bw_rtseq; /* used for bandwidth calculation */ 155102017Sdillon 15650673Sjlemon int t_rxtcur; /* current retransmit value (ticks) */ 15732821Sdg u_int t_maxseg; /* maximum segment size */ 15811187Swollman int t_srtt; /* smoothed round-trip time */ 15911187Swollman int t_rttvar; /* variance in round-trip time */ 16032821Sdg 16132821Sdg int t_rxtshift; /* log(2) of rexmt exp. backoff */ 16211187Swollman u_int t_rttmin; /* minimum rtt allowed */ 163102017Sdillon u_int t_rttbest; /* best rtt we've seen */ 16432821Sdg u_long t_rttupdated; /* number of times rtt sampled */ 1651541Srgrimes u_long max_sndwnd; /* largest window peer has offered */ 1661541Srgrimes 16732821Sdg int t_softerror; /* possible error not yet reported */ 1681541Srgrimes/* out-of-band data */ 1691541Srgrimes char t_oobflags; /* have some */ 1701541Srgrimes char t_iobc; /* input character */ 1711541Srgrimes#define TCPOOB_HAVEDATA 0x01 1721541Srgrimes#define TCPOOB_HADDATA 0x02 1731541Srgrimes/* RFC 1323 variables */ 1741541Srgrimes u_char snd_scale; /* window scaling for send window */ 1751541Srgrimes u_char rcv_scale; /* window scaling for recv window */ 1761541Srgrimes u_char request_r_scale; /* pending window scaling */ 177156125Sandre u_char requested_s_scale; /* unused, to be reused later */ 178162277Sandre u_int32_t ts_recent; /* timestamp echo data */ 179162277Sandre u_long ts_recent_age; /* when last updated */ 180162277Sandre u_int32_t ts_offset; /* our timestamp offset */ 18132821Sdg 1821541Srgrimes tcp_seq last_ack_sent; 18350673Sjlemon/* experimental */ 18450673Sjlemon u_long snd_cwnd_prev; /* cwnd prior to retransmit */ 18550673Sjlemon u_long snd_ssthresh_prev; /* ssthresh prior to retransmit */ 186117650Shsu tcp_seq snd_recover_prev; /* snd_recover prior to retransmit */ 18750673Sjlemon u_long t_badrxtwin; /* window for retransmit recovery */ 188112957Shsu u_char snd_limited; /* segments limited transmitted */ 189124258Sandre/* anti DoS counters */ 190124258Sandre u_long rcv_second; /* start of interval second */ 191124258Sandre u_long rcv_pps; /* received packets per second */ 192124258Sandre u_long rcv_byps; /* received bytes per second */ 193131078Sbms/* SACK related state */ 194130989Sps int sack_enable; /* enable SACK for this connection */ 195130989Sps int snd_numholes; /* number of holes seen by sender */ 196146953Sps TAILQ_HEAD(sackhole_head, sackhole) snd_holes; 197146953Sps /* SACK scoreboard (sorted) */ 198146630Sps tcp_seq snd_fack; /* last seq number(+1) sack'd by rcv'r*/ 199130989Sps int rcv_numsacks; /* # distinct sack blks present */ 200130989Sps struct sackblk sackblks[MAX_SACK_BLKS]; /* seq nos. of sack blocks */ 201136151Sps tcp_seq sack_newdata; /* New data xmitted in this recovery 202136151Sps episode starts at this seq number */ 203146123Sps struct sackhint sackhint; /* SACK scoreboard hint */ 204155767Sandre int t_rttlow; /* smallest observerved RTT */ 205166405Sandre u_int32_t rfbuf_ts; /* recv buffer autoscaling timestamp */ 206166405Sandre int rfbuf_cnt; /* recv buffer autoscaling byte count */ 2071541Srgrimes}; 2081541Srgrimes 209117650Shsu#define IN_FASTRECOVERY(tp) (tp->t_flags & TF_FASTRECOVERY) 210117650Shsu#define ENTER_FASTRECOVERY(tp) tp->t_flags |= TF_FASTRECOVERY 211117650Shsu#define EXIT_FASTRECOVERY(tp) tp->t_flags &= ~TF_FASTRECOVERY 212117650Shsu 213125680Sbms#ifdef TCP_SIGNATURE 2146247Swollman/* 215125680Sbms * Defines which are needed by the xform_tcp module and tcp_[in|out]put 216125680Sbms * for SADB verification and lookup. 217125680Sbms */ 218125680Sbms#define TCP_SIGLEN 16 /* length of computed digest in bytes */ 219125680Sbms#define TCP_KEYLEN_MIN 1 /* minimum length of TCP-MD5 key */ 220125680Sbms#define TCP_KEYLEN_MAX 80 /* maximum length of TCP-MD5 key */ 221125680Sbms/* 222125680Sbms * Only a single SA per host may be specified at this time. An SPI is 223125680Sbms * needed in order for the KEY_ALLOCSA() lookup to work. 224125680Sbms */ 225125680Sbms#define TCP_SIG_SPI 0x1000 226125680Sbms#endif /* TCP_SIGNATURE */ 227125680Sbms 228125680Sbms/* 2296247Swollman * Structure to hold TCP options that are only used during segment 2306247Swollman * processing (in tcp_input), but not held in the tcpcb. 2316247Swollman * It's basically used to reduce the number of parameters 2326247Swollman * to tcp_dooptions. 2336247Swollman */ 2346247Swollmanstruct tcpopt { 23586764Sjlemon u_long to_flags; /* which options are present */ 236159949Sandre#define TOF_TS 0x0001 /* timestamp */ 237159949Sandre#define TOF_MSS 0x0010 /* maximum segment size */ 238159949Sandre#define TOF_SCALE 0x0020 /* window scaling */ 239125680Sbms#define TOF_SIGNATURE 0x0040 /* signature option present */ 240128493Sbms#define TOF_SIGLEN 0x0080 /* signature length valid (RFC2385) */ 241130989Sps#define TOF_SACK 0x0100 /* Peer sent SACK option */ 24286764Sjlemon u_int32_t to_tsval; 24386764Sjlemon u_int32_t to_tsecr; 24486764Sjlemon u_int16_t to_mss; 245133874Srwatson u_int8_t to_requested_s_scale; 246147637Sps u_int8_t to_nsacks; /* number of SACK blocks */ 247147637Sps u_char *to_sacks; /* pointer to the first SACK blocks */ 2486247Swollman}; 2496247Swollman 250159949Sandre/* 251159949Sandre * Flags for tcp_dooptions. 252159949Sandre */ 253159949Sandre#define TO_SYN 0x01 /* parse SYN-only options */ 254159949Sandre 255122922Sandrestruct hc_metrics_lite { /* must stay in sync with hc_metrics */ 256122922Sandre u_long rmx_mtu; /* MTU for this path */ 257122922Sandre u_long rmx_ssthresh; /* outbound gateway buffer limit */ 258122922Sandre u_long rmx_rtt; /* estimated round trip time */ 259122922Sandre u_long rmx_rttvar; /* estimated rtt variance */ 260122922Sandre u_long rmx_bandwidth; /* estimated bandwidth */ 261122922Sandre u_long rmx_cwnd; /* congestion window */ 262122922Sandre u_long rmx_sendpipe; /* outbound delay-bandwidth product */ 263122922Sandre u_long rmx_recvpipe; /* inbound delay-bandwidth product */ 264122922Sandre}; 265122922Sandre 266159725Sandre#ifndef _NETINET_IN_PCB_H_ 267159725Sandrestruct in_conninfo; 268159725Sandre#endif /* _NETINET_IN_PCB_H_ */ 269159725Sandre 270111145Sjlemonstruct tcptw { 271111145Sjlemon struct inpcb *tw_inpcb; /* XXX back pointer to internet pcb */ 272111145Sjlemon tcp_seq snd_nxt; 273111145Sjlemon tcp_seq rcv_nxt; 274121850Ssilby tcp_seq iss; 275121884Ssilby tcp_seq irs; 276111145Sjlemon u_short last_win; /* cached window value */ 277111145Sjlemon u_short tw_so_options; /* copy of so_options */ 278111145Sjlemon struct ucred *tw_cred; /* user credentials */ 279133874Srwatson u_long t_recent; 280111145Sjlemon u_long t_starttime; 281112009Sjlemon int tw_time; 282162111Sru TAILQ_ENTRY(tcptw) tw_2msl; 283111145Sjlemon}; 284133874Srwatson 2851541Srgrimes#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb) 286111145Sjlemon#define intotw(ip) ((struct tcptw *)(ip)->inp_ppcb) 2871541Srgrimes#define sototcpcb(so) (intotcpcb(sotoinpcb(so))) 2881541Srgrimes 2891541Srgrimes/* 2901541Srgrimes * The smoothed round-trip time and estimated variance 2911541Srgrimes * are stored as fixed point numbers scaled by the values below. 2921541Srgrimes * For convenience, these scales are also used in smoothing the average 2931541Srgrimes * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed). 2941541Srgrimes * With these scales, srtt has 3 bits to the right of the binary point, 2951541Srgrimes * and thus an "ALPHA" of 0.875. rttvar has 2 bits to the right of the 2961541Srgrimes * binary point, and is smoothed with an ALPHA of 0.75. 2971541Srgrimes */ 29814753Swollman#define TCP_RTT_SCALE 32 /* multiplier for srtt; 3 bits frac. */ 29914753Swollman#define TCP_RTT_SHIFT 5 /* shift for srtt; 3 bits frac. */ 30014753Swollman#define TCP_RTTVAR_SCALE 16 /* multiplier for rttvar; 2 bits */ 30114753Swollman#define TCP_RTTVAR_SHIFT 4 /* shift for rttvar; 2 bits */ 30214753Swollman#define TCP_DELTA_SHIFT 2 /* see tcp_input.c */ 3031541Srgrimes 3041541Srgrimes/* 3051541Srgrimes * The initial retransmission should happen at rtt + 4 * rttvar. 3061541Srgrimes * Because of the way we do the smoothing, srtt and rttvar 3071541Srgrimes * will each average +1/2 tick of bias. When we compute 3081541Srgrimes * the retransmit timer, we want 1/2 tick of rounding and 3091541Srgrimes * 1 extra tick because of +-1/2 tick uncertainty in the 3101541Srgrimes * firing of the timer. The bias will give us exactly the 3111541Srgrimes * 1.5 tick we need. But, because the bias is 3121541Srgrimes * statistical, we have to test that we don't drop below 3131541Srgrimes * the minimum feasible timer (which is 2 ticks). 31414753Swollman * This version of the macro adapted from a paper by Lawrence 31514753Swollman * Brakmo and Larry Peterson which outlines a problem caused 31614753Swollman * by insufficient precision in the original implementation, 31714753Swollman * which results in inappropriately large RTO values for very 31814753Swollman * fast networks. 3191541Srgrimes */ 3201541Srgrimes#define TCP_REXMTVAL(tp) \ 32135419Sdg max((tp)->t_rttmin, (((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT)) \ 32216141Swollman + (tp)->t_rttvar) >> TCP_DELTA_SHIFT) 3231541Srgrimes 3241541Srgrimes/* 3251541Srgrimes * TCP statistics. 3261541Srgrimes * Many of these should be kept per connection, 3271541Srgrimes * but that's inconvenient at the moment. 3281541Srgrimes */ 3291541Srgrimesstruct tcpstat { 3301541Srgrimes u_long tcps_connattempt; /* connections initiated */ 3311541Srgrimes u_long tcps_accepts; /* connections accepted */ 3321541Srgrimes u_long tcps_connects; /* connections established */ 3331541Srgrimes u_long tcps_drops; /* connections dropped */ 3341541Srgrimes u_long tcps_conndrops; /* embryonic connections dropped */ 335124258Sandre u_long tcps_minmssdrops; /* average minmss too low drops */ 3361541Srgrimes u_long tcps_closed; /* conn. closed (includes drops) */ 3371541Srgrimes u_long tcps_segstimed; /* segs where we tried to get rtt */ 3381541Srgrimes u_long tcps_rttupdated; /* times we succeeded */ 3391541Srgrimes u_long tcps_delack; /* delayed acks sent */ 3401541Srgrimes u_long tcps_timeoutdrop; /* conn. dropped in rxmt timeout */ 3411541Srgrimes u_long tcps_rexmttimeo; /* retransmit timeouts */ 3421541Srgrimes u_long tcps_persisttimeo; /* persist timeouts */ 3431541Srgrimes u_long tcps_keeptimeo; /* keepalive timeouts */ 3441541Srgrimes u_long tcps_keepprobe; /* keepalive probes sent */ 3451541Srgrimes u_long tcps_keepdrops; /* connections dropped in keepalive */ 3461541Srgrimes 3471541Srgrimes u_long tcps_sndtotal; /* total packets sent */ 3481541Srgrimes u_long tcps_sndpack; /* data packets sent */ 3491541Srgrimes u_long tcps_sndbyte; /* data bytes sent */ 3501541Srgrimes u_long tcps_sndrexmitpack; /* data packets retransmitted */ 3511541Srgrimes u_long tcps_sndrexmitbyte; /* data bytes retransmitted */ 352100373Sdillon u_long tcps_sndrexmitbad; /* unnecessary packet retransmissions */ 3531541Srgrimes u_long tcps_sndacks; /* ack-only packets sent */ 3541541Srgrimes u_long tcps_sndprobe; /* window probes sent */ 3551541Srgrimes u_long tcps_sndurg; /* packets sent with URG only */ 3561541Srgrimes u_long tcps_sndwinup; /* window update-only packets sent */ 3571541Srgrimes u_long tcps_sndctrl; /* control (SYN|FIN|RST) packets sent */ 3581541Srgrimes 3591541Srgrimes u_long tcps_rcvtotal; /* total packets received */ 3601541Srgrimes u_long tcps_rcvpack; /* packets received in sequence */ 3611541Srgrimes u_long tcps_rcvbyte; /* bytes received in sequence */ 3621541Srgrimes u_long tcps_rcvbadsum; /* packets received with ccksum errs */ 3631541Srgrimes u_long tcps_rcvbadoff; /* packets received with bad offset */ 36452904Sshin u_long tcps_rcvmemdrop; /* packets dropped for lack of memory */ 3651541Srgrimes u_long tcps_rcvshort; /* packets received too short */ 3661541Srgrimes u_long tcps_rcvduppack; /* duplicate-only packets received */ 3671541Srgrimes u_long tcps_rcvdupbyte; /* duplicate-only bytes received */ 3681541Srgrimes u_long tcps_rcvpartduppack; /* packets with some duplicate data */ 3691541Srgrimes u_long tcps_rcvpartdupbyte; /* dup. bytes in part-dup. packets */ 3701541Srgrimes u_long tcps_rcvoopack; /* out-of-order packets received */ 3711541Srgrimes u_long tcps_rcvoobyte; /* out-of-order bytes received */ 3721541Srgrimes u_long tcps_rcvpackafterwin; /* packets with data after window */ 3731541Srgrimes u_long tcps_rcvbyteafterwin; /* bytes rcvd after window */ 3741541Srgrimes u_long tcps_rcvafterclose; /* packets rcvd after "close" */ 3751541Srgrimes u_long tcps_rcvwinprobe; /* rcvd window probe packets */ 3761541Srgrimes u_long tcps_rcvdupack; /* rcvd duplicate acks */ 3771541Srgrimes u_long tcps_rcvacktoomuch; /* rcvd acks for unsent data */ 3781541Srgrimes u_long tcps_rcvackpack; /* rcvd ack packets */ 3791541Srgrimes u_long tcps_rcvackbyte; /* bytes acked by rcvd acks */ 3801541Srgrimes u_long tcps_rcvwinupd; /* rcvd window update packets */ 3811541Srgrimes u_long tcps_pawsdrop; /* segments dropped due to PAWS */ 3821541Srgrimes u_long tcps_predack; /* times hdr predict ok for acks */ 3831541Srgrimes u_long tcps_preddat; /* times hdr predict ok for data pkts */ 3841541Srgrimes u_long tcps_pcbcachemiss; 3859263Swollman u_long tcps_cachedrtt; /* times cached RTT in route updated */ 3869263Swollman u_long tcps_cachedrttvar; /* times cached rttvar updated */ 3879263Swollman u_long tcps_cachedssthresh; /* times cached ssthresh updated */ 3889470Swollman u_long tcps_usedrtt; /* times RTT initialized from route */ 3899470Swollman u_long tcps_usedrttvar; /* times RTTVAR initialized from rt */ 3909470Swollman u_long tcps_usedssthresh; /* times ssthresh initialized from rt*/ 39110937Swollman u_long tcps_persistdrop; /* timeout in persist state */ 39210937Swollman u_long tcps_badsyn; /* bogus SYN, e.g. premature ACK */ 39311415Swollman u_long tcps_mturesent; /* resends due to MTU discovery */ 39414281Sbde u_long tcps_listendrop; /* listen queue overflows */ 395128653Ssilby u_long tcps_badrst; /* ignored RSTs in the window */ 39686764Sjlemon 39786764Sjlemon u_long tcps_sc_added; /* entry added to syncache */ 39886764Sjlemon u_long tcps_sc_retransmitted; /* syncache entry was retransmitted */ 39986764Sjlemon u_long tcps_sc_dupsyn; /* duplicate SYN packet */ 40086764Sjlemon u_long tcps_sc_dropped; /* could not reply to packet */ 40186764Sjlemon u_long tcps_sc_completed; /* successful extraction of entry */ 40286764Sjlemon u_long tcps_sc_bucketoverflow; /* syncache per-bucket limit hit */ 40386764Sjlemon u_long tcps_sc_cacheoverflow; /* syncache cache limit hit */ 40486764Sjlemon u_long tcps_sc_reset; /* RST removed entry from syncache */ 40586764Sjlemon u_long tcps_sc_stale; /* timed out or listen socket gone */ 40686764Sjlemon u_long tcps_sc_aborted; /* syncache entry aborted */ 40786764Sjlemon u_long tcps_sc_badack; /* removed due to bad ACK */ 40886764Sjlemon u_long tcps_sc_unreach; /* ICMP unreachable received */ 40986764Sjlemon u_long tcps_sc_zonefail; /* zalloc() failed */ 41086764Sjlemon u_long tcps_sc_sendcookie; /* SYN cookie sent */ 41186764Sjlemon u_long tcps_sc_recvcookie; /* SYN cookie received */ 412122922Sandre 413122922Sandre u_long tcps_hc_added; /* entry added to hostcache */ 414122922Sandre u_long tcps_hc_bucketoverflow; /* hostcache per bucket limit hit */ 415130989Sps 416130989Sps /* SACK related stats */ 417130989Sps u_long tcps_sack_recovery_episode; /* SACK recovery episodes */ 418130989Sps u_long tcps_sack_rexmits; /* SACK rexmit segments */ 419133874Srwatson u_long tcps_sack_rexmit_bytes; /* SACK rexmit bytes */ 420130989Sps u_long tcps_sack_rcv_blocks; /* SACK blocks (options) received */ 421130989Sps u_long tcps_sack_send_blocks; /* SACK blocks (options) sent */ 422143339Sps u_long tcps_sack_sboverflow; /* times scoreboard overflowed */ 4231541Srgrimes}; 4241541Srgrimes 4256247Swollman/* 42636079Swollman * TCB structure exported to user-land via sysctl(3). 42737183Sjhay * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been 42837183Sjhay * included. Not all of our clients do. 42936079Swollman */ 43037183Sjhay#if defined(_NETINET_IN_PCB_H_) && defined(_SYS_SOCKETVAR_H_) 43136079Swollmanstruct xtcpcb { 43236079Swollman size_t xt_len; 43336079Swollman struct inpcb xt_inp; 43436079Swollman struct tcpcb xt_tp; 43536079Swollman struct xsocket xt_socket; 43636079Swollman u_quad_t xt_alignment_hack; 43736079Swollman}; 43836079Swollman#endif 43936079Swollman 44036079Swollman/* 4416247Swollman * Names for TCP sysctl objects 4426247Swollman */ 4436247Swollman#define TCPCTL_DO_RFC1323 1 /* use RFC-1323 extensions */ 4446247Swollman#define TCPCTL_MSSDFLT 3 /* MSS default */ 4456472Swollman#define TCPCTL_STATS 4 /* statistics (read-only) */ 4466472Swollman#define TCPCTL_RTTDFLT 5 /* default RTT estimate */ 4476472Swollman#define TCPCTL_KEEPIDLE 6 /* keepalive idle timer */ 4486472Swollman#define TCPCTL_KEEPINTVL 7 /* interval to send keepalives */ 44918281Spst#define TCPCTL_SENDSPACE 8 /* send buffer space */ 45018281Spst#define TCPCTL_RECVSPACE 9 /* receive buffer space */ 45163431Ssheldonh#define TCPCTL_KEEPINIT 10 /* timeout for establishing syn */ 45236079Swollman#define TCPCTL_PCBLIST 11 /* list of all outstanding PCBs */ 45350673Sjlemon#define TCPCTL_DELACKTIME 12 /* time before sending delayed ACK */ 45452904Sshin#define TCPCTL_V6MSSDFLT 13 /* MSS default for IPv6 */ 455130989Sps#define TCPCTL_SACK 14 /* Selective Acknowledgement,rfc 2018 */ 456141381Smaxim#define TCPCTL_DROP 15 /* drop tcp connection */ 457141381Smaxim#define TCPCTL_MAXID 16 4586247Swollman 4596247Swollman#define TCPCTL_NAMES { \ 4606247Swollman { 0, 0 }, \ 4616348Swollman { "rfc1323", CTLTYPE_INT }, \ 4626247Swollman { "mssdflt", CTLTYPE_INT }, \ 4636472Swollman { "stats", CTLTYPE_STRUCT }, \ 4646472Swollman { "rttdflt", CTLTYPE_INT }, \ 4656472Swollman { "keepidle", CTLTYPE_INT }, \ 4666472Swollman { "keepintvl", CTLTYPE_INT }, \ 4676472Swollman { "sendspace", CTLTYPE_INT }, \ 4686472Swollman { "recvspace", CTLTYPE_INT }, \ 46918281Spst { "keepinit", CTLTYPE_INT }, \ 47036079Swollman { "pcblist", CTLTYPE_STRUCT }, \ 47150673Sjlemon { "delacktime", CTLTYPE_INT }, \ 47252904Sshin { "v6mssdflt", CTLTYPE_INT }, \ 473122922Sandre { "maxid", CTLTYPE_INT }, \ 4746247Swollman} 4756247Swollman 47644078Sdfr 47755205Speter#ifdef _KERNEL 47844078Sdfr#ifdef SYSCTL_DECL 47944078SdfrSYSCTL_DECL(_net_inet_tcp); 480136151SpsSYSCTL_DECL(_net_inet_tcp_sack); 48144078Sdfr#endif 48244078Sdfr 4837684Sdgextern struct inpcbhead tcb; /* head of queue of active tcpcb's */ 4847684Sdgextern struct inpcbinfo tcbinfo; 4856348Swollmanextern struct tcpstat tcpstat; /* tcp statistics */ 4867090Sbdeextern int tcp_mssdflt; /* XXX */ 487124258Sandreextern int tcp_minmss; 488124258Sandreextern int tcp_minmssoverload; 48933846Sdgextern int tcp_delack_enabled; 49060067Sjlemonextern int tcp_do_newreno; 49198204Ssilbyextern int path_mtu_discovery; 49250673Sjlemonextern int ss_fltsz; 49350673Sjlemonextern int ss_fltsz_local; 4941541Srgrimes 495130989Spsextern int tcp_do_sack; /* SACK enabled/disabled */ 496130989Sps 4971541Srgrimesstruct tcpcb * 49892723Salfred tcp_close(struct tcpcb *); 499157376Srwatsonvoid tcp_discardcb(struct tcpcb *); 500111145Sjlemonvoid tcp_twstart(struct tcpcb *); 501162064Sglebius#if 0 502121850Ssilbyint tcp_twrecycleable(struct tcptw *tw); 503162064Sglebius#endif 504157376Srwatsonvoid tcp_twclose(struct tcptw *_tw, int _reuse); 50592723Salfredvoid tcp_ctlinput(int, struct sockaddr *, void *); 50692723Salfredint tcp_ctloutput(struct socket *, struct sockopt *); 5071541Srgrimesstruct tcpcb * 50892723Salfred tcp_drop(struct tcpcb *, int); 50992723Salfredvoid tcp_drain(void); 51092723Salfredvoid tcp_fasttimo(void); 51192723Salfredvoid tcp_init(void); 512128452Ssilbyvoid tcp_fini(void *); 513126193Sandrevoid tcp_reass_init(void); 51492723Salfredvoid tcp_input(struct mbuf *, int); 515162084Sandreu_long tcp_maxmtu(struct in_conninfo *, int *); 516162084Sandreu_long tcp_maxmtu6(struct in_conninfo *, int *); 51792723Salfredvoid tcp_mss(struct tcpcb *, int); 518122922Sandreint tcp_mssopt(struct in_conninfo *); 519133874Srwatsonstruct inpcb * 52098211Shsu tcp_drop_syn_sent(struct inpcb *, int); 52198211Shsustruct inpcb * 52298211Shsu tcp_mtudisc(struct inpcb *, int); 5231541Srgrimesstruct tcpcb * 52492723Salfred tcp_newtcpcb(struct inpcb *); 52592723Salfredint tcp_output(struct tcpcb *); 52692723Salfredvoid tcp_respond(struct tcpcb *, void *, 52792723Salfred struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, int); 528126351Srwatsonint tcp_twrespond(struct tcptw *, int); 52992723Salfredvoid tcp_setpersist(struct tcpcb *); 530125783Sbms#ifdef TCP_SIGNATURE 531125783Sbmsint tcp_signature_compute(struct mbuf *, int, int, int, u_char *, u_int); 532125783Sbms#endif 53392723Salfredvoid tcp_slowtimo(void); 53455679Sshinstruct tcptemp * 535111144Sjlemon tcpip_maketemplate(struct inpcb *); 536111144Sjlemonvoid tcpip_fillheaders(struct inpcb *, void *, void *); 5371541Srgrimesstruct tcpcb * 53892723Salfred tcp_timers(struct tcpcb *, int); 53992723Salfredvoid tcp_trace(int, int, struct tcpcb *, void *, struct tcphdr *, int); 540102017Sdillonvoid tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq); 54186764Sjlemonvoid syncache_init(void); 54286764Sjlemonvoid syncache_unreach(struct in_conninfo *, struct tcphdr *); 543162277Sandreint syncache_expand(struct in_conninfo *, struct tcpopt *, 544162277Sandre struct tcphdr *, struct socket **, struct mbuf *); 54586764Sjlemonint syncache_add(struct in_conninfo *, struct tcpopt *, 546159695Sandre struct tcphdr *, struct inpcb *, struct socket **, struct mbuf *); 54786764Sjlemonvoid syncache_chkrst(struct in_conninfo *, struct tcphdr *); 54886764Sjlemonvoid syncache_badack(struct in_conninfo *); 549122922Sandre/* 550122922Sandre * All tcp_hc_* functions are IPv4 and IPv6 (via in_conninfo) 551122922Sandre */ 552122922Sandrevoid tcp_hc_init(void); 553122922Sandrevoid tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *); 554122922Sandreu_long tcp_hc_getmtu(struct in_conninfo *); 555122922Sandrevoid tcp_hc_updatemtu(struct in_conninfo *, u_long); 556122922Sandrevoid tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *); 5579470Swollman 55817096Swollmanextern struct pr_usrreqs tcp_usrreqs; 5599470Swollmanextern u_long tcp_sendspace; 5609470Swollmanextern u_long tcp_recvspace; 56192723Salfredtcp_seq tcp_new_isn(struct tcpcb *); 5629470Swollman 563147637Spsvoid tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq); 564142031Spsvoid tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, tcp_seq rcv_lastend); 565130989Spsvoid tcp_clean_sackreport(struct tcpcb *tp); 566130989Spsvoid tcp_sack_adjust(struct tcpcb *tp); 567136151Spsstruct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt); 568130989Spsvoid tcp_sack_partialack(struct tcpcb *, struct tcphdr *); 569130989Spsvoid tcp_free_sackholes(struct tcpcb *tp); 570130989Spsint tcp_newreno(struct tcpcb *, struct tcphdr *); 571130989Spsu_long tcp_seq_subtract(u_long, u_long ); 572130989Sps 57355205Speter#endif /* _KERNEL */ 5742169Spaul 5756348Swollman#endif /* _NETINET_TCP_VAR_H_ */ 576