tcp_var.h revision 196039
165557Sjasone/*-
265557Sjasone * Copyright (c) 1982, 1986, 1993, 1994, 1995
365557Sjasone *	The Regents of the University of California.  All rights reserved.
465557Sjasone *
565557Sjasone * Redistribution and use in source and binary forms, with or without
665557Sjasone * modification, are permitted provided that the following conditions
765557Sjasone * are met:
865557Sjasone * 1. Redistributions of source code must retain the above copyright
965557Sjasone *    notice, this list of conditions and the following disclaimer.
1065557Sjasone * 2. Redistributions in binary form must reproduce the above copyright
1165557Sjasone *    notice, this list of conditions and the following disclaimer in the
1265557Sjasone *    documentation and/or other materials provided with the distribution.
1365557Sjasone * 4. Neither the name of the University nor the names of its contributors
1465557Sjasone *    may be used to endorse or promote products derived from this software
1565557Sjasone *    without specific prior written permission.
1665557Sjasone *
1765557Sjasone * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1865557Sjasone * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1965557Sjasone * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2065557Sjasone * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2165557Sjasone * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2265557Sjasone * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2365557Sjasone * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2465557Sjasone * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2565557Sjasone * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2665557Sjasone * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2765557Sjasone * SUCH DAMAGE.
2865557Sjasone *
2967352Sjhb *	@(#)tcp_var.h	8.4 (Berkeley) 5/24/95
3065557Sjasone * $FreeBSD: head/sys/netinet/tcp_var.h 196039 2009-08-02 19:43:32Z rwatson $
3165557Sjasone */
3265557Sjasone
3365557Sjasone#ifndef _NETINET_TCP_VAR_H_
3465557Sjasone#define _NETINET_TCP_VAR_H_
3565557Sjasone
3665557Sjasone#include <netinet/tcp.h>
3765557Sjasone
3865557Sjasone#ifdef _KERNEL
3965557Sjasone#include <net/vnet.h>
4065557Sjasone
4165557Sjasone/*
4265557Sjasone * Kernel variables for tcp.
4365557Sjasone */
4465557SjasoneVNET_DECLARE(int, tcp_do_rfc1323);
4565557SjasoneVNET_DECLARE(int, tcp_reass_qsize);
4665557SjasoneVNET_DECLARE(struct uma_zone *, tcp_reass_zone);
4765557Sjasone#define	V_tcp_do_rfc1323	VNET(tcp_do_rfc1323)
4865557Sjasone#define	V_tcp_reass_qsize	VNET(tcp_reass_qsize)
4965557Sjasone#define	V_tcp_reass_zone	VNET(tcp_reass_zone)
5065557Sjasone
5165557Sjasone#endif /* _KERNEL */
5265557Sjasone
5368790Sjhb/* TCP segment queue entry */
5467676Sjhbstruct tseg_qent {
5567676Sjhb	LIST_ENTRY(tseg_qent) tqe_q;
5669215Salfred	int	tqe_len;		/* TCP segment data length */
5769215Salfred	struct	tcphdr *tqe_th;		/* a pointer to tcp header */
5869215Salfred	struct	mbuf	*tqe_m;		/* mbuf contains packet */
5969215Salfred};
6069215SalfredLIST_HEAD(tsegqe_head, tseg_qent);
6169215Salfred
6265557Sjasonestruct sackblk {
6367352Sjhb	tcp_seq start;		/* start seq no. of sack block */
6467352Sjhb	tcp_seq end;		/* end seq no. */
6567352Sjhb};
6665557Sjasone
6767676Sjhbstruct sackhole {
6865557Sjasone	tcp_seq start;		/* start seq no. of hole */
6967352Sjhb	tcp_seq end;		/* end seq no. */
7065557Sjasone	tcp_seq rxmit;		/* next seq. no in hole to be retransmitted */
7165557Sjasone	TAILQ_ENTRY(sackhole) scblink;	/* scoreboard linkage */
7267352Sjhb};
7367352Sjhb
7467352Sjhbstruct sackhint {
7565557Sjasone	struct sackhole	*nexthole;
7667352Sjhb	int		sack_bytes_rexmit;
7768790Sjhb
7868790Sjhb	int		ispare;		/* explicit pad for 64bit alignment */
7967352Sjhb	uint64_t	_pad[2];	/* 1 sacked_bytes, 1 TBD */
8067352Sjhb};
8167352Sjhb
8267352Sjhbstruct tcptemp {
8365557Sjasone	u_char	tt_ipgen[40]; /* the size must be of max ip header, now IPv6 */
8465557Sjasone	struct	tcphdr tt_t;
8567352Sjhb};
8667352Sjhb
8771352Sjasone#define tcp6cb		tcpcb  /* for KAME src sync over BSD*'s */
8871352Sjasone
8971352Sjasone/* Neighbor Discovery, Neighbor Unreachability Detection Upper layer hint. */
9071352Sjasone#ifdef INET6
9171352Sjasone#define ND6_HINT(tp)						\
9271352Sjasonedo {								\
9371352Sjasone	if ((tp) && (tp)->t_inpcb &&				\
9471352Sjasone	    ((tp)->t_inpcb->inp_vflag & INP_IPV6) != 0)		\
9571352Sjasone		nd6_nud_hint(NULL, NULL, 0);			\
9671560Sjhb} while (0)
9771560Sjhb#else
9871560Sjhb#define ND6_HINT(tp)
9971560Sjhb#endif
10071352Sjasone
10171352Sjasone/*
10271352Sjasone * Tcp control block, one per tcp; fields:
10371352Sjasone * Organized for 16 byte cacheline efficiency.
10471352Sjasone */
10571352Sjasonestruct tcpcb {
10671352Sjasone	struct	tsegqe_head t_segq;	/* segment reassembly queue */
10771352Sjasone	void	*t_pspare[2];		/* new reassembly queue */
10871352Sjasone	int	t_segqlen;		/* segment reassembly queue length */
10971352Sjasone	int	t_dupacks;		/* consecutive dup acks recd */
11071352Sjasone
11171352Sjasone	struct tcp_timer *t_timers;	/* All the TCP timers in one struct */
11271352Sjasone
11371352Sjasone	struct	inpcb *t_inpcb;		/* back pointer to internet pcb */
11471352Sjasone	int	t_state;		/* state of this connection */
11571352Sjasone	u_int	t_flags;
11671352Sjasone
11771352Sjasone	struct	vnet *t_vnet;		/* back pointer to parent vnet */
11871352Sjasone
11971352Sjasone	tcp_seq	snd_una;		/* send unacknowledged */
12071352Sjasone	tcp_seq	snd_max;		/* highest sequence number sent;
12171352Sjasone					 * used to recognize retransmits
12271352Sjasone					 */
12371352Sjasone	tcp_seq	snd_nxt;		/* send next */
12471352Sjasone	tcp_seq	snd_up;			/* send urgent pointer */
12571352Sjasone
12671352Sjasone	tcp_seq	snd_wl1;		/* window update seg seq number */
12771352Sjasone	tcp_seq	snd_wl2;		/* window update seg ack number */
12871352Sjasone	tcp_seq	iss;			/* initial send sequence number */
12971352Sjasone	tcp_seq	irs;			/* initial receive sequence number */
13071352Sjasone
13171352Sjasone	tcp_seq	rcv_nxt;		/* receive next */
13271352Sjasone	tcp_seq	rcv_adv;		/* advertised window */
13371352Sjasone	u_long	rcv_wnd;		/* receive window */
13471352Sjasone	tcp_seq	rcv_up;			/* receive urgent pointer */
13571352Sjasone
13671352Sjasone	u_long	snd_wnd;		/* send window */
13771352Sjasone	u_long	snd_cwnd;		/* congestion-controlled window */
13871352Sjasone	u_long	snd_bwnd;		/* bandwidth-controlled window */
13971352Sjasone	u_long	snd_ssthresh;		/* snd_cwnd size threshold for
14071352Sjasone					 * for slow start exponential to
14171352Sjasone					 * linear switch
14271352Sjasone					 */
14371352Sjasone	u_long	snd_bandwidth;		/* calculated bandwidth or 0 */
14471352Sjasone	tcp_seq	snd_recover;		/* for use in NewReno Fast Recovery */
14571352Sjasone
14671352Sjasone	u_int	t_maxopd;		/* mss plus options */
14771352Sjasone
14871352Sjasone	u_int	t_rcvtime;		/* inactivity time */
14971352Sjasone	u_int	t_starttime;		/* time connection was established */
15071352Sjasone	u_int	t_rtttime;		/* RTT measurement start time */
15171352Sjasone	tcp_seq	t_rtseq;		/* sequence number being timed */
15271352Sjasone
15371352Sjasone	u_int	t_bw_rtttime;		/* used for bandwidth calculation */
15471352Sjasone	tcp_seq	t_bw_rtseq;		/* used for bandwidth calculation */
15571352Sjasone
15671352Sjasone	int	t_rxtcur;		/* current retransmit value (ticks) */
15771352Sjasone	u_int	t_maxseg;		/* maximum segment size */
15871352Sjasone	int	t_srtt;			/* smoothed round-trip time */
15971352Sjasone	int	t_rttvar;		/* variance in round-trip time */
16071352Sjasone
16171352Sjasone	int	t_rxtshift;		/* log(2) of rexmt exp. backoff */
16271352Sjasone	u_int	t_rttmin;		/* minimum rtt allowed */
16371352Sjasone	u_int	t_rttbest;		/* best rtt we've seen */
16471352Sjasone	u_long	t_rttupdated;		/* number of times rtt sampled */
16571352Sjasone	u_long	max_sndwnd;		/* largest window peer has offered */
16671352Sjasone
16771352Sjasone	int	t_softerror;		/* possible error not yet reported */
16871352Sjasone/* out-of-band data */
16971352Sjasone	char	t_oobflags;		/* have some */
17071352Sjasone	char	t_iobc;			/* input character */
17171352Sjasone/* RFC 1323 variables */
17271352Sjasone	u_char	snd_scale;		/* window scaling for send window */
17371352Sjasone	u_char	rcv_scale;		/* window scaling for recv window */
17471352Sjasone	u_char	request_r_scale;	/* pending window scaling */
17571352Sjasone	u_int32_t  ts_recent;		/* timestamp echo data */
17671352Sjasone	u_int	ts_recent_age;		/* when last updated */
17771352Sjasone	u_int32_t  ts_offset;		/* our timestamp offset */
17871352Sjasone
17971352Sjasone	tcp_seq	last_ack_sent;
18071352Sjasone/* experimental */
18171352Sjasone	u_long	snd_cwnd_prev;		/* cwnd prior to retransmit */
18271352Sjasone	u_long	snd_ssthresh_prev;	/* ssthresh prior to retransmit */
18371352Sjasone	tcp_seq	snd_recover_prev;	/* snd_recover prior to retransmit */
18471352Sjasone	u_int	t_badrxtwin;		/* window for retransmit recovery */
18571352Sjasone	u_char	snd_limited;		/* segments limited transmitted */
18671352Sjasone/* SACK related state */
18771352Sjasone	int	snd_numholes;		/* number of holes seen by sender */
18871352Sjasone	TAILQ_HEAD(sackhole_head, sackhole) snd_holes;
18971352Sjasone					/* SACK scoreboard (sorted) */
19071352Sjasone	tcp_seq	snd_fack;		/* last seq number(+1) sack'd by rcv'r*/
19171352Sjasone	int	rcv_numsacks;		/* # distinct sack blks present */
19271352Sjasone	struct sackblk sackblks[MAX_SACK_BLKS]; /* seq nos. of sack blocks */
19371352Sjasone	tcp_seq sack_newdata;		/* New data xmitted in this recovery
19471352Sjasone					   episode starts at this seq number */
19571352Sjasone	struct sackhint	sackhint;	/* SACK scoreboard hint */
19671352Sjasone	int	t_rttlow;		/* smallest observerved RTT */
19771352Sjasone	u_int32_t	rfbuf_ts;	/* recv buffer autoscaling timestamp */
19871352Sjasone	int	rfbuf_cnt;		/* recv buffer autoscaling byte count */
19971352Sjasone	struct toe_usrreqs *t_tu;	/* offload operations vector */
20071352Sjasone	void	*t_toe;			/* TOE pcb pointer */
20171352Sjasone	int	t_bytes_acked;		/* # bytes acked during current RTT */
20271352Sjasone
20371352Sjasone	int	t_ispare;		/* explicit pad for 64bit alignment */
20471352Sjasone	void	*t_pspare2[6];		/* 2 CC / 4 TBD */
20571352Sjasone	uint64_t _pad[12];		/* 7 UTO, 5 TBD (1-2 CC/RTT?) */
20671352Sjasone};
20771352Sjasone
20871352Sjasone/*
20971352Sjasone * Flags and utility macros for the t_flags field.
21071352Sjasone */
21171352Sjasone#define	TF_ACKNOW	0x000001	/* ack peer immediately */
21271352Sjasone#define	TF_DELACK	0x000002	/* ack, but try to delay it */
21371352Sjasone#define	TF_NODELAY	0x000004	/* don't delay packets to coalesce */
21471352Sjasone#define	TF_NOOPT	0x000008	/* don't use tcp options */
21571352Sjasone#define	TF_SENTFIN	0x000010	/* have sent FIN */
21667352Sjhb#define	TF_REQ_SCALE	0x000020	/* have/will request window scaling */
21771560Sjhb#define	TF_RCVD_SCALE	0x000040	/* other side has requested scaling */
21871320Sjasone#define	TF_REQ_TSTMP	0x000080	/* have/will request timestamps */
21971320Sjasone#define	TF_RCVD_TSTMP	0x000100	/* a timestamp was received in SYN */
22071320Sjasone#define	TF_SACK_PERMIT	0x000200	/* other side said I could SACK */
22171320Sjasone#define	TF_NEEDSYN	0x000400	/* send SYN (implicit state) */
22271320Sjasone#define	TF_NEEDFIN	0x000800	/* send FIN (implicit state) */
22369429Sjhb#define	TF_NOPUSH	0x001000	/* don't push */
22471352Sjasone#define	TF_MORETOCOME	0x010000	/* More data to be appended to sock */
22571352Sjasone#define	TF_LQ_OVERFLOW	0x020000	/* listen queue overflow */
22671352Sjasone#define	TF_LASTIDLE	0x040000	/* connection was previously idle */
22771352Sjasone#define	TF_RXWIN0SENT	0x080000	/* sent a receiver win 0 in response */
22871352Sjasone#define	TF_FASTRECOVERY	0x100000	/* in NewReno Fast Recovery */
22971352Sjasone#define	TF_WASFRECOVERY	0x200000	/* was in NewReno Fast Recovery */
23071352Sjasone#define	TF_SIGNATURE	0x400000	/* require MD5 digests (RFC2385) */
23171352Sjasone#define	TF_FORCEDATA	0x800000	/* force out a byte */
23269429Sjhb#define	TF_TSO		0x1000000	/* TSO enabled on this connection */
23367352Sjhb#define	TF_TOE		0x2000000	/* this connection is offloaded */
23471560Sjhb#define	TF_ECN_PERMIT	0x4000000	/* connection ECN-ready */
23571560Sjhb#define	TF_ECN_SND_CWR	0x8000000	/* ECN CWR in queue */
23671560Sjhb#define	TF_ECN_SND_ECE	0x10000000	/* ECN ECE in queue */
23771560Sjhb
23871560Sjhb#define IN_FASTRECOVERY(tp)	(tp->t_flags & TF_FASTRECOVERY)
23971560Sjhb#define ENTER_FASTRECOVERY(tp)	tp->t_flags |= TF_FASTRECOVERY
24071560Sjhb#define EXIT_FASTRECOVERY(tp)	tp->t_flags &= ~TF_FASTRECOVERY
24171560Sjhb
24271560Sjhb/*
24371560Sjhb * Flags for the t_oobflags field.
24471560Sjhb */
24567352Sjhb#define	TCPOOB_HAVEDATA	0x01
24667352Sjhb#define	TCPOOB_HADDATA	0x02
24767352Sjhb
24871352Sjasone#ifdef TCP_SIGNATURE
24971352Sjasone/*
25071352Sjasone * Defines which are needed by the xform_tcp module and tcp_[in|out]put
25167352Sjhb * for SADB verification and lookup.
25267352Sjhb */
25367352Sjhb#define	TCP_SIGLEN	16	/* length of computed digest in bytes */
25467352Sjhb#define	TCP_KEYLEN_MIN	1	/* minimum length of TCP-MD5 key */
25567352Sjhb#define	TCP_KEYLEN_MAX	80	/* maximum length of TCP-MD5 key */
25667352Sjhb/*
25767352Sjhb * Only a single SA per host may be specified at this time. An SPI is
25867352Sjhb * needed in order for the KEY_ALLOCSA() lookup to work.
25967352Sjhb */
26067352Sjhb#define	TCP_SIG_SPI	0x1000
26167352Sjhb#endif /* TCP_SIGNATURE */
26267352Sjhb
26367352Sjhb/*
26467352Sjhb * Structure to hold TCP options that are only used during segment
26569376Sjhb * processing (in tcp_input), but not held in the tcpcb.
26667352Sjhb * It's basically used to reduce the number of parameters
26767352Sjhb * to tcp_dooptions and tcp_addoptions.
26867352Sjhb * The binary order of the to_flags is relevant for packing of the
26967352Sjhb * options in tcp_addoptions.
27067352Sjhb */
27167352Sjhbstruct tcpopt {
27267352Sjhb	u_int64_t	to_flags;	/* which options are present */
27367352Sjhb#define	TOF_MSS		0x0001		/* maximum segment size */
27467352Sjhb#define	TOF_SCALE	0x0002		/* window scaling */
27567352Sjhb#define	TOF_SACKPERM	0x0004		/* SACK permitted */
27667352Sjhb#define	TOF_TS		0x0010		/* timestamp */
27767352Sjhb#define	TOF_SIGNATURE	0x0040		/* TCP-MD5 signature option (RFC2385) */
27867352Sjhb#define	TOF_SACK	0x0080		/* Peer sent SACK option */
27967352Sjhb#define	TOF_MAXOPT	0x0100
28067352Sjhb	u_int32_t	to_tsval;	/* new timestamp */
28169376Sjhb	u_int32_t	to_tsecr;	/* reflected timestamp */
28267352Sjhb	u_char		*to_sacks;	/* pointer to the first SACK blocks */
28367352Sjhb	u_char		*to_signature;	/* pointer to the TCP-MD5 signature */
28469376Sjhb	u_int16_t	to_mss;		/* maximum segment size */
28567352Sjhb	u_int8_t	to_wscale;	/* window scaling */
28669376Sjhb	u_int8_t	to_nsacks;	/* number of SACK blocks */
28769376Sjhb};
28869376Sjhb
28969376Sjhb/*
29069376Sjhb * Flags for tcp_dooptions.
29167352Sjhb */
29267352Sjhb#define	TO_SYN		0x01		/* parse SYN-only options */
29369376Sjhb
29469376Sjhbstruct hc_metrics_lite {	/* must stay in sync with hc_metrics */
29569376Sjhb	u_long	rmx_mtu;	/* MTU for this path */
29669376Sjhb	u_long	rmx_ssthresh;	/* outbound gateway buffer limit */
29769376Sjhb	u_long	rmx_rtt;	/* estimated round trip time */
29869376Sjhb	u_long	rmx_rttvar;	/* estimated rtt variance */
29967352Sjhb	u_long	rmx_bandwidth;	/* estimated bandwidth */
30067352Sjhb	u_long	rmx_cwnd;	/* congestion window */
30167352Sjhb	u_long	rmx_sendpipe;   /* outbound delay-bandwidth product */
30269376Sjhb	u_long	rmx_recvpipe;   /* inbound delay-bandwidth product */
30367352Sjhb};
30469376Sjhb
30569376Sjhb#ifndef _NETINET_IN_PCB_H_
30669376Sjhbstruct in_conninfo;
30769376Sjhb#endif /* _NETINET_IN_PCB_H_ */
30869376Sjhb
30969376Sjhbstruct tcptw {
31069376Sjhb	struct inpcb	*tw_inpcb;	/* XXX back pointer to internet pcb */
31169376Sjhb	tcp_seq		snd_nxt;
31269376Sjhb	tcp_seq		rcv_nxt;
31367352Sjhb	tcp_seq		iss;
31467352Sjhb	tcp_seq		irs;
31567352Sjhb	u_short		last_win;	/* cached window value */
31667352Sjhb	u_short		tw_so_options;	/* copy of so_options */
31769376Sjhb	struct ucred	*tw_cred;	/* user credentials */
31869376Sjhb	u_int32_t	t_recent;
31967352Sjhb	u_int32_t	ts_offset;	/* our timestamp offset */
32067352Sjhb	u_int		t_starttime;
32167352Sjhb	int		tw_time;
32267352Sjhb	TAILQ_ENTRY(tcptw) tw_2msl;
32367352Sjhb};
32467352Sjhb
32567352Sjhb#define	intotcpcb(ip)	((struct tcpcb *)(ip)->inp_ppcb)
32669376Sjhb#define	intotw(ip)	((struct tcptw *)(ip)->inp_ppcb)
32767352Sjhb#define	sototcpcb(so)	(intotcpcb(sotoinpcb(so)))
32869376Sjhb
32969376Sjhb/*
33069376Sjhb * The smoothed round-trip time and estimated variance
33169376Sjhb * are stored as fixed point numbers scaled by the values below.
33267352Sjhb * For convenience, these scales are also used in smoothing the average
33367352Sjhb * (smoothed = (1/scale)sample + ((scale-1)/scale)smoothed).
33467352Sjhb * With these scales, srtt has 3 bits to the right of the binary point,
33567352Sjhb * and thus an "ALPHA" of 0.875.  rttvar has 2 bits to the right of the
33667352Sjhb * binary point, and is smoothed with an ALPHA of 0.75.
33767352Sjhb */
33867352Sjhb#define	TCP_RTT_SCALE		32	/* multiplier for srtt; 3 bits frac. */
33967352Sjhb#define	TCP_RTT_SHIFT		5	/* shift for srtt; 3 bits frac. */
34067352Sjhb#define	TCP_RTTVAR_SCALE	16	/* multiplier for rttvar; 2 bits */
34167352Sjhb#define	TCP_RTTVAR_SHIFT	4	/* shift for rttvar; 2 bits */
34267352Sjhb#define	TCP_DELTA_SHIFT		2	/* see tcp_input.c */
34367352Sjhb
34467352Sjhb/*
34569376Sjhb * The initial retransmission should happen at rtt + 4 * rttvar.
34669376Sjhb * Because of the way we do the smoothing, srtt and rttvar
34769376Sjhb * will each average +1/2 tick of bias.  When we compute
34869376Sjhb * the retransmit timer, we want 1/2 tick of rounding and
34969376Sjhb * 1 extra tick because of +-1/2 tick uncertainty in the
35069376Sjhb * firing of the timer.  The bias will give us exactly the
35169376Sjhb * 1.5 tick we need.  But, because the bias is
35267352Sjhb * statistical, we have to test that we don't drop below
35369376Sjhb * the minimum feasible timer (which is 2 ticks).
35467352Sjhb * This version of the macro adapted from a paper by Lawrence
35567352Sjhb * Brakmo and Larry Peterson which outlines a problem caused
35667352Sjhb * by insufficient precision in the original implementation,
35767352Sjhb * which results in inappropriately large RTO values for very
35869376Sjhb * fast networks.
35969376Sjhb */
36069376Sjhb#define	TCP_REXMTVAL(tp) \
36169376Sjhb	max((tp)->t_rttmin, (((tp)->t_srtt >> (TCP_RTT_SHIFT - TCP_DELTA_SHIFT))  \
36269376Sjhb	  + (tp)->t_rttvar) >> TCP_DELTA_SHIFT)
36367352Sjhb
36467352Sjhb/*
36567352Sjhb * TCP statistics.
36667352Sjhb * Many of these should be kept per connection,
36767352Sjhb * but that's inconvenient at the moment.
36867352Sjhb */
36967352Sjhbstruct	tcpstat {
37069376Sjhb	u_long	tcps_connattempt;	/* connections initiated */
37169376Sjhb	u_long	tcps_accepts;		/* connections accepted */
37267352Sjhb	u_long	tcps_connects;		/* connections established */
37371560Sjhb	u_long	tcps_drops;		/* connections dropped */
37467352Sjhb	u_long	tcps_conndrops;		/* embryonic connections dropped */
37567352Sjhb	u_long	tcps_minmssdrops;	/* average minmss too low drops */
37667352Sjhb	u_long	tcps_closed;		/* conn. closed (includes drops) */
37767352Sjhb	u_long	tcps_segstimed;		/* segs where we tried to get rtt */
37871352Sjasone	u_long	tcps_rttupdated;	/* times we succeeded */
37971352Sjasone	u_long	tcps_delack;		/* delayed acks sent */
38071352Sjasone	u_long	tcps_timeoutdrop;	/* conn. dropped in rxmt timeout */
38171352Sjasone	u_long	tcps_rexmttimeo;	/* retransmit timeouts */
38271352Sjasone	u_long	tcps_persisttimeo;	/* persist timeouts */
38371352Sjasone	u_long	tcps_keeptimeo;		/* keepalive timeouts */
38467352Sjhb	u_long	tcps_keepprobe;		/* keepalive probes sent */
38571352Sjasone	u_long	tcps_keepdrops;		/* connections dropped in keepalive */
38671352Sjasone
38771352Sjasone	u_long	tcps_sndtotal;		/* total packets sent */
38871352Sjasone	u_long	tcps_sndpack;		/* data packets sent */
38971352Sjasone	u_long	tcps_sndbyte;		/* data bytes sent */
39071352Sjasone	u_long	tcps_sndrexmitpack;	/* data packets retransmitted */
39171352Sjasone	u_long	tcps_sndrexmitbyte;	/* data bytes retransmitted */
39271352Sjasone	u_long	tcps_sndrexmitbad;	/* unnecessary packet retransmissions */
39371352Sjasone	u_long	tcps_sndacks;		/* ack-only packets sent */
39471352Sjasone	u_long	tcps_sndprobe;		/* window probes sent */
39571352Sjasone	u_long	tcps_sndurg;		/* packets sent with URG only */
39671352Sjasone	u_long	tcps_sndwinup;		/* window update-only packets sent */
39771352Sjasone	u_long	tcps_sndctrl;		/* control (SYN|FIN|RST) packets sent */
39871352Sjasone
39971352Sjasone	u_long	tcps_rcvtotal;		/* total packets received */
40071352Sjasone	u_long	tcps_rcvpack;		/* packets received in sequence */
40171352Sjasone	u_long	tcps_rcvbyte;		/* bytes received in sequence */
40271352Sjasone	u_long	tcps_rcvbadsum;		/* packets received with ccksum errs */
40371352Sjasone	u_long	tcps_rcvbadoff;		/* packets received with bad offset */
40471352Sjasone	u_long	tcps_rcvmemdrop;	/* packets dropped for lack of memory */
40571352Sjasone	u_long	tcps_rcvshort;		/* packets received too short */
40671352Sjasone	u_long	tcps_rcvduppack;	/* duplicate-only packets received */
40771352Sjasone	u_long	tcps_rcvdupbyte;	/* duplicate-only bytes received */
40871352Sjasone	u_long	tcps_rcvpartduppack;	/* packets with some duplicate data */
40971352Sjasone	u_long	tcps_rcvpartdupbyte;	/* dup. bytes in part-dup. packets */
41071352Sjasone	u_long	tcps_rcvoopack;		/* out-of-order packets received */
41171352Sjasone	u_long	tcps_rcvoobyte;		/* out-of-order bytes received */
41271352Sjasone	u_long	tcps_rcvpackafterwin;	/* packets with data after window */
41371352Sjasone	u_long	tcps_rcvbyteafterwin;	/* bytes rcvd after window */
41471352Sjasone	u_long	tcps_rcvafterclose;	/* packets rcvd after "close" */
41571352Sjasone	u_long	tcps_rcvwinprobe;	/* rcvd window probe packets */
41671352Sjasone	u_long	tcps_rcvdupack;		/* rcvd duplicate acks */
41771352Sjasone	u_long	tcps_rcvacktoomuch;	/* rcvd acks for unsent data */
41871352Sjasone	u_long	tcps_rcvackpack;	/* rcvd ack packets */
41971352Sjasone	u_long	tcps_rcvackbyte;	/* bytes acked by rcvd acks */
42071352Sjasone	u_long	tcps_rcvwinupd;		/* rcvd window update packets */
42171352Sjasone	u_long	tcps_pawsdrop;		/* segments dropped due to PAWS */
42271352Sjasone	u_long	tcps_predack;		/* times hdr predict ok for acks */
42371352Sjasone	u_long	tcps_preddat;		/* times hdr predict ok for data pkts */
42471352Sjasone	u_long	tcps_pcbcachemiss;
42571352Sjasone	u_long	tcps_cachedrtt;		/* times cached RTT in route updated */
42671352Sjasone	u_long	tcps_cachedrttvar;	/* times cached rttvar updated */
42771352Sjasone	u_long	tcps_cachedssthresh;	/* times cached ssthresh updated */
42871352Sjasone	u_long	tcps_usedrtt;		/* times RTT initialized from route */
42971352Sjasone	u_long	tcps_usedrttvar;	/* times RTTVAR initialized from rt */
43071352Sjasone	u_long	tcps_usedssthresh;	/* times ssthresh initialized from rt*/
43171352Sjasone	u_long	tcps_persistdrop;	/* timeout in persist state */
43271352Sjasone	u_long	tcps_badsyn;		/* bogus SYN, e.g. premature ACK */
43371352Sjasone	u_long	tcps_mturesent;		/* resends due to MTU discovery */
43471352Sjasone	u_long	tcps_listendrop;	/* listen queue overflows */
43571352Sjasone	u_long	tcps_badrst;		/* ignored RSTs in the window */
43671352Sjasone
43771352Sjasone	u_long	tcps_sc_added;		/* entry added to syncache */
43871352Sjasone	u_long	tcps_sc_retransmitted;	/* syncache entry was retransmitted */
43971352Sjasone	u_long	tcps_sc_dupsyn;		/* duplicate SYN packet */
44071352Sjasone	u_long	tcps_sc_dropped;	/* could not reply to packet */
44171352Sjasone	u_long	tcps_sc_completed;	/* successful extraction of entry */
44271352Sjasone	u_long	tcps_sc_bucketoverflow;	/* syncache per-bucket limit hit */
44371352Sjasone	u_long	tcps_sc_cacheoverflow;	/* syncache cache limit hit */
44471352Sjasone	u_long	tcps_sc_reset;		/* RST removed entry from syncache */
44571352Sjasone	u_long	tcps_sc_stale;		/* timed out or listen socket gone */
44671352Sjasone	u_long	tcps_sc_aborted;	/* syncache entry aborted */
44771352Sjasone	u_long	tcps_sc_badack;		/* removed due to bad ACK */
44871352Sjasone	u_long	tcps_sc_unreach;	/* ICMP unreachable received */
44971352Sjasone	u_long	tcps_sc_zonefail;	/* zalloc() failed */
45071352Sjasone	u_long	tcps_sc_sendcookie;	/* SYN cookie sent */
45171352Sjasone	u_long	tcps_sc_recvcookie;	/* SYN cookie received */
45271352Sjasone
45371352Sjasone	u_long	tcps_hc_added;		/* entry added to hostcache */
45471352Sjasone	u_long	tcps_hc_bucketoverflow;	/* hostcache per bucket limit hit */
45571352Sjasone
45671352Sjasone	u_long  tcps_finwait2_drops;    /* Drop FIN_WAIT_2 connection after time limit */
45771352Sjasone
45871352Sjasone	/* SACK related stats */
45971352Sjasone	u_long	tcps_sack_recovery_episode; /* SACK recovery episodes */
46071352Sjasone	u_long  tcps_sack_rexmits;	    /* SACK rexmit segments   */
46171352Sjasone	u_long  tcps_sack_rexmit_bytes;	    /* SACK rexmit bytes      */
46271352Sjasone	u_long  tcps_sack_rcv_blocks;	    /* SACK blocks (options) received */
46371352Sjasone	u_long  tcps_sack_send_blocks;	    /* SACK blocks (options) sent     */
46471352Sjasone	u_long  tcps_sack_sboverflow; 	    /* times scoreboard overflowed */
46571352Sjasone
46671352Sjasone	/* ECN related stats */
46771352Sjasone	u_long	tcps_ecn_ce;		/* ECN Congestion Experienced */
46871352Sjasone	u_long	tcps_ecn_ect0;		/* ECN Capable Transport */
46971352Sjasone	u_long	tcps_ecn_ect1;		/* ECN Capable Transport */
47071352Sjasone	u_long	tcps_ecn_shs;		/* ECN successful handshakes */
47171352Sjasone	u_long	tcps_ecn_rcwnd;		/* # times ECN reduced the cwnd */
47271352Sjasone
47371352Sjasone	u_long	_pad[12];		/* 6 UTO, 6 TBD */
47471352Sjasone};
47571352Sjasone
47671352Sjasone#ifdef _KERNEL
47771352Sjasone/*
47871352Sjasone * In-kernel consumers can use these accessor macros directly to update
47971352Sjasone * stats.
48071352Sjasone */
48171352Sjasone#define	TCPSTAT_ADD(name, val)	V_tcpstat.name += (val)
48271352Sjasone#define	TCPSTAT_INC(name)	TCPSTAT_ADD(name, 1)
48371352Sjasone
48471352Sjasone/*
48571352Sjasone * Kernel module consumers must use this accessor macro.
48671352Sjasone */
48771352Sjasonevoid	kmod_tcpstat_inc(int statnum);
48871352Sjasone#define	KMOD_TCPSTAT_INC(name)						\
48971352Sjasone	kmod_tcpstat_inc(offsetof(struct tcpstat, name) / sizeof(u_long))
49071352Sjasone#endif
49171352Sjasone
49271352Sjasone/*
49371352Sjasone * TCB structure exported to user-land via sysctl(3).
49471352Sjasone * Evil hack: declare only if in_pcb.h and sys/socketvar.h have been
49571352Sjasone * included.  Not all of our clients do.
49671352Sjasone */
49771352Sjasone#if defined(_NETINET_IN_PCB_H_) && defined(_SYS_SOCKETVAR_H_)
49871352Sjasonestruct	xtcpcb {
49971352Sjasone	size_t	xt_len;
50071352Sjasone	struct	inpcb	xt_inp;
50171352Sjasone	struct	tcpcb	xt_tp;
50271352Sjasone	struct	xsocket	xt_socket;
50371352Sjasone	u_quad_t	xt_alignment_hack;
50471352Sjasone};
50571352Sjasone#endif
50671352Sjasone
50771352Sjasone/*
50871352Sjasone * Names for TCP sysctl objects
50971352Sjasone */
51071352Sjasone#define	TCPCTL_DO_RFC1323	1	/* use RFC-1323 extensions */
51171352Sjasone#define	TCPCTL_MSSDFLT		3	/* MSS default */
51271352Sjasone#define TCPCTL_STATS		4	/* statistics (read-only) */
51371352Sjasone#define	TCPCTL_RTTDFLT		5	/* default RTT estimate */
51471352Sjasone#define	TCPCTL_KEEPIDLE		6	/* keepalive idle timer */
51571352Sjasone#define	TCPCTL_KEEPINTVL	7	/* interval to send keepalives */
51667352Sjhb#define	TCPCTL_SENDSPACE	8	/* send buffer space */
51767352Sjhb#define	TCPCTL_RECVSPACE	9	/* receive buffer space */
51867352Sjhb#define	TCPCTL_KEEPINIT		10	/* timeout for establishing syn */
51967352Sjhb#define	TCPCTL_PCBLIST		11	/* list of all outstanding PCBs */
52067352Sjhb#define	TCPCTL_DELACKTIME	12	/* time before sending delayed ACK */
52167352Sjhb#define	TCPCTL_V6MSSDFLT	13	/* MSS default for IPv6 */
52267352Sjhb#define	TCPCTL_SACK		14	/* Selective Acknowledgement,rfc 2018 */
52367352Sjhb#define	TCPCTL_DROP		15	/* drop tcp connection */
52467352Sjhb#define	TCPCTL_MAXID		16
52567352Sjhb#define TCPCTL_FINWAIT2_TIMEOUT        17
52671228Sbmilekic
52769998Sjhb#define TCPCTL_NAMES { \
52871560Sjhb	{ 0, 0 }, \
52967352Sjhb	{ "rfc1323", CTLTYPE_INT }, \
53067352Sjhb	{ "mssdflt", CTLTYPE_INT }, \
53169998Sjhb	{ "stats", CTLTYPE_STRUCT }, \
53269998Sjhb	{ "rttdflt", CTLTYPE_INT }, \
53371560Sjhb	{ "keepidle", CTLTYPE_INT }, \
53469998Sjhb	{ "keepintvl", CTLTYPE_INT }, \
53569376Sjhb	{ "sendspace", CTLTYPE_INT }, \
53669376Sjhb	{ "recvspace", CTLTYPE_INT }, \
53769376Sjhb	{ "keepinit", CTLTYPE_INT }, \
53869376Sjhb	{ "pcblist", CTLTYPE_STRUCT }, \
53969376Sjhb	{ "delacktime", CTLTYPE_INT }, \
54069376Sjhb	{ "v6mssdflt", CTLTYPE_INT }, \
54169376Sjhb	{ "maxid", CTLTYPE_INT }, \
54269376Sjhb}
54369376Sjhb
54469376Sjhb
54569376Sjhb#ifdef _KERNEL
54669376Sjhb#ifdef SYSCTL_DECL
54767352SjhbSYSCTL_DECL(_net_inet_tcp);
54867396SjhbSYSCTL_DECL(_net_inet_tcp_sack);
54967352SjhbMALLOC_DECLARE(M_TCPLOG);
55067352Sjhb#endif
55167352Sjhb
55267352Sjhbextern	int tcp_log_in_vain;
55367352Sjhb
55467352SjhbVNET_DECLARE(struct inpcbhead, tcb);		/* queue of active tcpcb's */
55567352SjhbVNET_DECLARE(struct inpcbinfo, tcbinfo);
55667352SjhbVNET_DECLARE(struct tcpstat, tcpstat);		/* tcp statistics */
55767352SjhbVNET_DECLARE(int, tcp_mssdflt);	/* XXX */
55867352SjhbVNET_DECLARE(int, tcp_minmss);
55967352SjhbVNET_DECLARE(int, tcp_delack_enabled);
56067352SjhbVNET_DECLARE(int, tcp_do_newreno);
56167352SjhbVNET_DECLARE(int, path_mtu_discovery);
56267352SjhbVNET_DECLARE(int, ss_fltsz);
56367352SjhbVNET_DECLARE(int, ss_fltsz_local);
56467352Sjhb
56567352Sjhb#define	V_tcb			VNET(tcb)
56667352Sjhb#define	V_tcbinfo		VNET(tcbinfo)
56767352Sjhb#define	V_tcpstat		VNET(tcpstat)
56867352Sjhb#define	V_tcp_mssdflt		VNET(tcp_mssdflt)
56967352Sjhb#define	V_tcp_minmss		VNET(tcp_minmss)
57067352Sjhb#define	V_tcp_delack_enabled	VNET(tcp_delack_enabled)
57167352Sjhb#define	V_tcp_do_newreno	VNET(tcp_do_newreno)
57267352Sjhb#define	V_path_mtu_discovery	VNET(path_mtu_discovery)
57367352Sjhb#define	V_ss_fltsz		VNET(ss_fltsz)
57467352Sjhb#define	V_ss_fltsz_local	VNET(ss_fltsz_local)
57567352Sjhb
57667352SjhbVNET_DECLARE(int, blackhole);
57767352SjhbVNET_DECLARE(int, drop_synfin);
57867352SjhbVNET_DECLARE(int, tcp_do_rfc3042);
57967352SjhbVNET_DECLARE(int, tcp_do_rfc3390);
58067352SjhbVNET_DECLARE(int, tcp_insecure_rst);
58167352SjhbVNET_DECLARE(int, tcp_do_autorcvbuf);
58267352SjhbVNET_DECLARE(int, tcp_autorcvbuf_inc);
58367352SjhbVNET_DECLARE(int, tcp_autorcvbuf_max);
58467352SjhbVNET_DECLARE(int, tcp_do_rfc3465);
58567352SjhbVNET_DECLARE(int, tcp_abc_l_var);
58667352Sjhb
58767352Sjhb#define	V_blackhole		VNET(blackhole)
58867352Sjhb#define	V_drop_synfin		VNET(drop_synfin)
58967352Sjhb#define	V_tcp_do_rfc3042	VNET(tcp_do_rfc3042)
59067352Sjhb#define	V_tcp_do_rfc3390	VNET(tcp_do_rfc3390)
59167352Sjhb#define	V_tcp_insecure_rst	VNET(tcp_insecure_rst)
59267352Sjhb#define	V_tcp_do_autorcvbuf	VNET(tcp_do_autorcvbuf)
59367352Sjhb#define	V_tcp_autorcvbuf_inc	VNET(tcp_autorcvbuf_inc)
59467352Sjhb#define	V_tcp_autorcvbuf_max	VNET(tcp_autorcvbuf_max)
59567352Sjhb#define	V_tcp_do_rfc3465	VNET(tcp_do_rfc3465)
59667352Sjhb#define	V_tcp_abc_l_var		VNET(tcp_abc_l_var)
59767352Sjhb
59867352SjhbVNET_DECLARE(int, tcp_do_tso);
59967352SjhbVNET_DECLARE(int, tcp_do_autosndbuf);
60069998SjhbVNET_DECLARE(int, tcp_autosndbuf_inc);
60169998SjhbVNET_DECLARE(int, tcp_autosndbuf_max);
60267352Sjhb
60369998Sjhb#define	V_tcp_do_tso		VNET(tcp_do_tso)
60467352Sjhb#define	V_tcp_do_autosndbuf	VNET(tcp_do_autosndbuf)
60567352Sjhb#define	V_tcp_autosndbuf_inc	VNET(tcp_autosndbuf_inc)
60667352Sjhb#define	V_tcp_autosndbuf_max	VNET(tcp_autosndbuf_max)
60767352Sjhb
60867352SjhbVNET_DECLARE(int, nolocaltimewait);
60967352Sjhb
61067352Sjhb#define	V_nolocaltimewait	VNET(nolocaltimewait)
61167352Sjhb
61267352SjhbVNET_DECLARE(int, tcp_do_sack);			/* SACK enabled/disabled */
61367352SjhbVNET_DECLARE(int, tcp_sack_maxholes);
61467352SjhbVNET_DECLARE(int, tcp_sack_globalmaxholes);
61567352SjhbVNET_DECLARE(int, tcp_sack_globalholes);
61667352SjhbVNET_DECLARE(int, tcp_sc_rst_sock_fail);	/* RST on sock alloc failure */
61767352SjhbVNET_DECLARE(int, tcp_do_ecn);			/* TCP ECN enabled/disabled */
61867352SjhbVNET_DECLARE(int, tcp_ecn_maxretries);
61967352Sjhb
62067352Sjhb#define	V_tcp_do_sack		VNET(tcp_do_sack)
62167352Sjhb#define	V_tcp_sack_maxholes	VNET(tcp_sack_maxholes)
62267352Sjhb#define	V_tcp_sack_globalmaxholes	VNET(tcp_sack_globalmaxholes)
62367352Sjhb#define	V_tcp_sack_globalholes	VNET(tcp_sack_globalholes)
62467352Sjhb#define	V_tcp_sc_rst_sock_fail	VNET(tcp_sc_rst_sock_fail)
62567352Sjhb#define	V_tcp_do_ecn		VNET(tcp_do_ecn)
62667352Sjhb#define	V_tcp_ecn_maxretries	VNET(tcp_ecn_maxretries)
62767352Sjhb
62869369Sjhbint	 tcp_addoptions(struct tcpopt *, u_char *);
62967352Sjhbstruct tcpcb *
63067352Sjhb	 tcp_close(struct tcpcb *);
63167352Sjhbvoid	 tcp_discardcb(struct tcpcb *);
63267352Sjhbvoid	 tcp_twstart(struct tcpcb *);
63369998Sjhb#if 0
63469998Sjhbint	 tcp_twrecycleable(struct tcptw *tw);
63571560Sjhb#endif
63669998Sjhbvoid	 tcp_twclose(struct tcptw *_tw, int _reuse);
63768808Sjhbvoid	 tcp_ctlinput(int, struct sockaddr *, void *);
63869998Sjhbint	 tcp_ctloutput(struct socket *, struct sockopt *);
63969998Sjhbstruct tcpcb *
64071560Sjhb	 tcp_drop(struct tcpcb *, int);
64169998Sjhbvoid	 tcp_drain(void);
64267352Sjhbvoid	 tcp_fasttimo(void);
64367352Sjhbvoid	 tcp_init(void);
64467352Sjhb#ifdef VIMAGE
64567352Sjhbvoid	 tcp_destroy(void);
64667352Sjhb#endif
64767352Sjhbvoid	 tcp_fini(void *);
64867352Sjhbchar 	*tcp_log_addrs(struct in_conninfo *, struct tcphdr *, void *,
64967352Sjhb	    const void *);
65067352Sjhbint	 tcp_reass(struct tcpcb *, struct tcphdr *, int *, struct mbuf *);
65167352Sjhbvoid	 tcp_reass_init(void);
65267352Sjhbvoid	 tcp_input(struct mbuf *, int);
65367352Sjhbu_long	 tcp_maxmtu(struct in_conninfo *, int *);
65467352Sjhbu_long	 tcp_maxmtu6(struct in_conninfo *, int *);
65569998Sjhbvoid	 tcp_mss_update(struct tcpcb *, int, struct hc_metrics_lite *, int *);
65669998Sjhbvoid	 tcp_mss(struct tcpcb *, int);
65767352Sjhbint	 tcp_mssopt(struct in_conninfo *);
65867352Sjhbstruct inpcb *
65967352Sjhb	 tcp_drop_syn_sent(struct inpcb *, int);
66067352Sjhbstruct inpcb *
66167352Sjhb	 tcp_mtudisc(struct inpcb *, int);
66267352Sjhbstruct tcpcb *
66367352Sjhb	 tcp_newtcpcb(struct inpcb *);
66467352Sjhbint	 tcp_output(struct tcpcb *);
66567352Sjhbvoid	 tcp_respond(struct tcpcb *, void *,
66667352Sjhb	    struct tcphdr *, struct mbuf *, tcp_seq, tcp_seq, int);
66767352Sjhbvoid	 tcp_tw_init(void);
66867352Sjhb#ifdef VIMAGE
66967352Sjhbvoid	 tcp_tw_destroy(void);
67067352Sjhb#endif
67171560Sjhbvoid	 tcp_tw_zone_change(void);
67267352Sjhbint	 tcp_twcheck(struct inpcb *, struct tcpopt *, struct tcphdr *,
67367352Sjhb	    struct mbuf *, int);
67467352Sjhbint	 tcp_twrespond(struct tcptw *, int);
67567352Sjhbvoid	 tcp_setpersist(struct tcpcb *);
67667352Sjhb#ifdef TCP_SIGNATURE
67767352Sjhbint	 tcp_signature_compute(struct mbuf *, int, int, int, u_char *, u_int);
67867352Sjhb#endif
67967352Sjhbvoid	 tcp_slowtimo(void);
68067352Sjhbstruct tcptemp *
68167352Sjhb	 tcpip_maketemplate(struct inpcb *);
68267352Sjhbvoid	 tcpip_fillheaders(struct inpcb *, void *, void *);
68369998Sjhbvoid	 tcp_timer_activate(struct tcpcb *, int, u_int);
68471560Sjhbint	 tcp_timer_active(struct tcpcb *, int);
68567352Sjhbvoid	 tcp_trace(short, short, struct tcpcb *, void *, struct tcphdr *, int);
68667352Sjhbvoid	 tcp_xmit_bandwidth_limit(struct tcpcb *tp, tcp_seq ack_seq);
68767352Sjhb/*
68867352Sjhb * All tcp_hc_* functions are IPv4 and IPv6 (via in_conninfo)
68967352Sjhb */
69067352Sjhbvoid	 tcp_hc_init(void);
69167352Sjhb#ifdef VIMAGE
69267352Sjhbvoid	 tcp_hc_destroy(void);
69367352Sjhb#endif
69467352Sjhbvoid	 tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *);
69567352Sjhbu_long	 tcp_hc_getmtu(struct in_conninfo *);
69667352Sjhbvoid	 tcp_hc_updatemtu(struct in_conninfo *, u_long);
69767352Sjhbvoid	 tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *);
69867352Sjhb
69967352Sjhbextern	struct pr_usrreqs tcp_usrreqs;
70067352Sjhbextern	u_long tcp_sendspace;
70171228Sbmilekicextern	u_long tcp_recvspace;
70267352Sjhbtcp_seq tcp_new_isn(struct tcpcb *);
70371228Sbmilekic
70469998Sjhbvoid	 tcp_sack_doack(struct tcpcb *, struct tcpopt *, tcp_seq);
70571560Sjhbvoid	 tcp_update_sack_list(struct tcpcb *tp, tcp_seq rcv_laststart, tcp_seq rcv_lastend);
70667352Sjhbvoid	 tcp_clean_sackreport(struct tcpcb *tp);
70767352Sjhbvoid	 tcp_sack_adjust(struct tcpcb *tp);
70867352Sjhbstruct sackhole *tcp_sack_output(struct tcpcb *tp, int *sack_bytes_rexmt);
70969998Sjhbvoid	 tcp_sack_partialack(struct tcpcb *, struct tcphdr *);
71071560Sjhbvoid	 tcp_free_sackholes(struct tcpcb *tp);
71167352Sjhbint	 tcp_newreno(struct tcpcb *, struct tcphdr *);
71267352Sjhbu_long	 tcp_seq_subtract(u_long, u_long );
71367352Sjhb
71467352Sjhb#endif /* _KERNEL */
71567352Sjhb
71667352Sjhb#endif /* _NETINET_TCP_VAR_H_ */
71767352Sjhb