xref: /freebsd/sys/netinet/tcp_log_buf.h (revision 69c7c81190580ade16e608c6edaaa9f63dcd9052)
12529f56eSJonathan T. Looney /*-
22529f56eSJonathan T. Looney  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
32529f56eSJonathan T. Looney  *
4*69c7c811SRandall Stewart  * Copyright (c) 2016-2020 Netflix, Inc.
52529f56eSJonathan T. Looney  *
62529f56eSJonathan T. Looney  * Redistribution and use in source and binary forms, with or without
72529f56eSJonathan T. Looney  * modification, are permitted provided that the following conditions
82529f56eSJonathan T. Looney  * are met:
92529f56eSJonathan T. Looney  * 1. Redistributions of source code must retain the above copyright
102529f56eSJonathan T. Looney  *    notice, this list of conditions and the following disclaimer.
112529f56eSJonathan T. Looney  * 2. Redistributions in binary form must reproduce the above copyright
122529f56eSJonathan T. Looney  *    notice, this list of conditions and the following disclaimer in the
132529f56eSJonathan T. Looney  *    documentation and/or other materials provided with the distribution.
142529f56eSJonathan T. Looney  *
152529f56eSJonathan T. Looney  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
162529f56eSJonathan T. Looney  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
172529f56eSJonathan T. Looney  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
182529f56eSJonathan T. Looney  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
192529f56eSJonathan T. Looney  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
202529f56eSJonathan T. Looney  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
212529f56eSJonathan T. Looney  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
222529f56eSJonathan T. Looney  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
232529f56eSJonathan T. Looney  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
242529f56eSJonathan T. Looney  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
252529f56eSJonathan T. Looney  * SUCH DAMAGE.
262529f56eSJonathan T. Looney  *
272529f56eSJonathan T. Looney  * $FreeBSD$
282529f56eSJonathan T. Looney  */
292529f56eSJonathan T. Looney 
302529f56eSJonathan T. Looney #ifndef __tcp_log_buf_h__
312529f56eSJonathan T. Looney #define __tcp_log_buf_h__
322529f56eSJonathan T. Looney 
332529f56eSJonathan T. Looney #define	TCP_LOG_REASON_LEN	32
34a9a08eceSRandall Stewart #define	TCP_LOG_TAG_LEN		32
35e854dd38SRandall Stewart #define	TCP_LOG_BUF_VER		(9)
362529f56eSJonathan T. Looney 
372529f56eSJonathan T. Looney /*
382529f56eSJonathan T. Looney  * Because the (struct tcp_log_buffer) includes 8-byte uint64_t's, it requires
392529f56eSJonathan T. Looney  * 8-byte alignment to work properly on all platforms. Therefore, we will
402529f56eSJonathan T. Looney  * enforce 8-byte alignment for all the structures that may appear by
412529f56eSJonathan T. Looney  * themselves (instead of being embedded in another structure) in a data
422529f56eSJonathan T. Looney  * stream.
432529f56eSJonathan T. Looney  */
442529f56eSJonathan T. Looney #define	ALIGN_TCP_LOG		__aligned(8)
452529f56eSJonathan T. Looney 
462529f56eSJonathan T. Looney /* Information about the socketbuffer state. */
472529f56eSJonathan T. Looney struct tcp_log_sockbuf
482529f56eSJonathan T. Looney {
492529f56eSJonathan T. Looney 	uint32_t	tls_sb_acc;	/* available chars (sb->sb_acc) */
502529f56eSJonathan T. Looney 	uint32_t	tls_sb_ccc;	/* claimed chars (sb->sb_ccc) */
512529f56eSJonathan T. Looney 	uint32_t	tls_sb_spare;	/* spare */
522529f56eSJonathan T. Looney };
532529f56eSJonathan T. Looney 
542529f56eSJonathan T. Looney /* Optional, verbose information that may be appended to an event log. */
552529f56eSJonathan T. Looney struct tcp_log_verbose
562529f56eSJonathan T. Looney {
572529f56eSJonathan T. Looney #define	TCP_FUNC_LEN	32
582529f56eSJonathan T. Looney 	char		tlv_snd_frm[TCP_FUNC_LEN]; /* tcp_output() caller */
592529f56eSJonathan T. Looney 	char		tlv_trace_func[TCP_FUNC_LEN]; /* Function that
602529f56eSJonathan T. Looney 							 generated trace */
612529f56eSJonathan T. Looney 	uint32_t	tlv_trace_line;	/* Line number that generated trace */
622529f56eSJonathan T. Looney 	uint8_t		_pad[4];
632529f56eSJonathan T. Looney } ALIGN_TCP_LOG;
642529f56eSJonathan T. Looney 
652529f56eSJonathan T. Looney /* Internal RACK state variables. */
662529f56eSJonathan T. Looney struct tcp_log_rack
672529f56eSJonathan T. Looney {
682529f56eSJonathan T. Looney 	uint32_t	tlr_rack_rtt;		/* rc_rack_rtt */
692529f56eSJonathan T. Looney 	uint8_t		tlr_state;		/* Internal RACK state */
702529f56eSJonathan T. Looney 	uint8_t		_pad[3];		/* Padding */
712529f56eSJonathan T. Looney };
722529f56eSJonathan T. Looney 
732529f56eSJonathan T. Looney struct tcp_log_bbr {
742529f56eSJonathan T. Looney 	uint64_t cur_del_rate;
752529f56eSJonathan T. Looney 	uint64_t delRate;
762529f56eSJonathan T. Looney 	uint64_t rttProp;
772529f56eSJonathan T. Looney 	uint64_t bw_inuse;
782529f56eSJonathan T. Looney 	uint32_t inflight;
792529f56eSJonathan T. Looney 	uint32_t applimited;
802529f56eSJonathan T. Looney 	uint32_t delivered;
812529f56eSJonathan T. Looney 	uint32_t timeStamp;
822529f56eSJonathan T. Looney 	uint32_t epoch;
832529f56eSJonathan T. Looney 	uint32_t lt_epoch;
842529f56eSJonathan T. Looney 	uint32_t pkts_out;
852529f56eSJonathan T. Looney 	uint32_t flex1;
862529f56eSJonathan T. Looney 	uint32_t flex2;
872529f56eSJonathan T. Looney 	uint32_t flex3;
882529f56eSJonathan T. Looney 	uint32_t flex4;
892529f56eSJonathan T. Looney 	uint32_t flex5;
902529f56eSJonathan T. Looney 	uint32_t flex6;
912529f56eSJonathan T. Looney 	uint32_t lost;
922529f56eSJonathan T. Looney 	uint16_t pacing_gain;
932529f56eSJonathan T. Looney 	uint16_t cwnd_gain;
942529f56eSJonathan T. Looney 	uint16_t flex7;
952529f56eSJonathan T. Looney 	uint8_t bbr_state;
962529f56eSJonathan T. Looney 	uint8_t bbr_substate;
9789e560f4SRandall Stewart 	uint8_t inhpts;
98a370832bSGleb Smirnoff 	uint8_t __spare;
992529f56eSJonathan T. Looney 	uint8_t use_lt_bw;
1002529f56eSJonathan T. Looney 	uint8_t flex8;
1012529f56eSJonathan T. Looney 	uint32_t pkt_epoch;
1022529f56eSJonathan T. Looney };
1032529f56eSJonathan T. Looney 
104*69c7c811SRandall Stewart /* shadows tcp_log_bbr struct element sizes */
105*69c7c811SRandall Stewart struct tcp_log_raw {
106*69c7c811SRandall Stewart 	uint64_t u64_flex[4];
107*69c7c811SRandall Stewart 	uint32_t u32_flex[14];
108*69c7c811SRandall Stewart 	uint16_t u16_flex[3];
109*69c7c811SRandall Stewart 	uint8_t u8_flex[6];
110*69c7c811SRandall Stewart 	uint32_t u32_flex2[1];
111*69c7c811SRandall Stewart };
112*69c7c811SRandall Stewart 
113*69c7c811SRandall Stewart struct tcp_log_uint64 {
114*69c7c811SRandall Stewart 	uint64_t u64_flex[13];
115*69c7c811SRandall Stewart };
116*69c7c811SRandall Stewart 
117*69c7c811SRandall Stewart struct tcp_log_sendfile {
118*69c7c811SRandall Stewart 	uint64_t offset;
119*69c7c811SRandall Stewart 	uint64_t length;
120*69c7c811SRandall Stewart 	uint32_t flags;
121*69c7c811SRandall Stewart };
122*69c7c811SRandall Stewart 
123*69c7c811SRandall Stewart /*
124*69c7c811SRandall Stewart  * tcp_log_stackspecific is currently being used as "event specific" log
125*69c7c811SRandall Stewart  * info by all stacks (i.e. struct tcp_log_bbr is used for generic event
126*69c7c811SRandall Stewart  * logging). Until this is cleaned up more generically and throughout,
127*69c7c811SRandall Stewart  * allow events to use the same space in the union.
128*69c7c811SRandall Stewart  */
1292529f56eSJonathan T. Looney union tcp_log_stackspecific
1302529f56eSJonathan T. Looney {
1312529f56eSJonathan T. Looney 	struct tcp_log_rack u_rack;
1322529f56eSJonathan T. Looney 	struct tcp_log_bbr u_bbr;
133*69c7c811SRandall Stewart 	struct tcp_log_sendfile u_sf;
134*69c7c811SRandall Stewart 	struct tcp_log_raw u_raw;	/* "raw" log access */
135*69c7c811SRandall Stewart 	struct tcp_log_uint64 u64_raw;	/* just u64's - used by process info */
1362529f56eSJonathan T. Looney };
1372529f56eSJonathan T. Looney 
138*69c7c811SRandall Stewart typedef union tcp_log_stackspecific tcp_log_eventspecific_t;
139*69c7c811SRandall Stewart 
1402529f56eSJonathan T. Looney struct tcp_log_buffer
1412529f56eSJonathan T. Looney {
1422529f56eSJonathan T. Looney 	/* Event basics */
1432529f56eSJonathan T. Looney 	struct timeval	tlb_tv;		/* Timestamp of trace */
1442529f56eSJonathan T. Looney 	uint32_t	tlb_ticks;	/* Timestamp of trace */
1452529f56eSJonathan T. Looney 	uint32_t	tlb_sn;		/* Serial number */
1462529f56eSJonathan T. Looney 	uint8_t		tlb_stackid;	/* Stack ID */
1472529f56eSJonathan T. Looney 	uint8_t		tlb_eventid;	/* Event ID */
1482529f56eSJonathan T. Looney 	uint16_t	tlb_eventflags;	/* Flags for the record */
1492529f56eSJonathan T. Looney #define	TLB_FLAG_RXBUF		0x0001	/* Includes receive buffer info */
1502529f56eSJonathan T. Looney #define	TLB_FLAG_TXBUF		0x0002	/* Includes send buffer info */
1512529f56eSJonathan T. Looney #define	TLB_FLAG_HDR		0x0004	/* Includes a TCP header */
1522529f56eSJonathan T. Looney #define	TLB_FLAG_VERBOSE	0x0008	/* Includes function/line numbers */
1532529f56eSJonathan T. Looney #define	TLB_FLAG_STACKINFO	0x0010	/* Includes stack-specific info */
1542529f56eSJonathan T. Looney 	int		tlb_errno;	/* Event error (if any) */
1552529f56eSJonathan T. Looney 
1562529f56eSJonathan T. Looney 	/* Internal session state */
1572529f56eSJonathan T. Looney 	struct tcp_log_sockbuf tlb_rxbuf; /* Receive buffer */
1582529f56eSJonathan T. Looney 	struct tcp_log_sockbuf tlb_txbuf; /* Send buffer */
1592529f56eSJonathan T. Looney 
1602529f56eSJonathan T. Looney 	int		tlb_state;	/* TCPCB t_state */
1612529f56eSJonathan T. Looney 	uint32_t	tlb_starttime;	/* TCPCB t_starttime */
1622529f56eSJonathan T. Looney 	uint32_t	tlb_iss;	/* TCPCB iss */
1632529f56eSJonathan T. Looney 	uint32_t	tlb_flags;	/* TCPCB flags */
1642529f56eSJonathan T. Looney 	uint32_t	tlb_snd_una;	/* TCPCB snd_una */
1652529f56eSJonathan T. Looney 	uint32_t	tlb_snd_max;	/* TCPCB snd_max */
1662529f56eSJonathan T. Looney 	uint32_t	tlb_snd_cwnd;	/* TCPCB snd_cwnd */
1672529f56eSJonathan T. Looney 	uint32_t	tlb_snd_nxt;	/* TCPCB snd_nxt */
1682529f56eSJonathan T. Looney 	uint32_t	tlb_snd_recover;/* TCPCB snd_recover */
1692529f56eSJonathan T. Looney 	uint32_t	tlb_snd_wnd;	/* TCPCB snd_wnd */
1702529f56eSJonathan T. Looney 	uint32_t	tlb_snd_ssthresh; /* TCPCB snd_ssthresh */
1712529f56eSJonathan T. Looney 	uint32_t	tlb_srtt;	/* TCPCB t_srtt */
1722529f56eSJonathan T. Looney 	uint32_t	tlb_rttvar;	/* TCPCB t_rttvar */
1732529f56eSJonathan T. Looney 	uint32_t	tlb_rcv_up;	/* TCPCB rcv_up */
1742529f56eSJonathan T. Looney 	uint32_t	tlb_rcv_adv;	/* TCPCB rcv_adv */
175e854dd38SRandall Stewart 	uint32_t	tlb_flags2;	/* TCPCB t_flags2 */
1762529f56eSJonathan T. Looney 	uint32_t	tlb_rcv_nxt;	/* TCPCB rcv_nxt */
1772529f56eSJonathan T. Looney 	uint32_t	tlb_rcv_wnd;	/* TCPCB rcv_wnd */
1782529f56eSJonathan T. Looney 	uint32_t	tlb_dupacks;	/* TCPCB t_dupacks */
1792529f56eSJonathan T. Looney 	int		tlb_segqlen;	/* TCPCB segqlen */
1802529f56eSJonathan T. Looney 	int		tlb_snd_numholes; /* TCPCB snd_numholes */
1812529f56eSJonathan T. Looney 	uint32_t	tlb_flex1;	/* Event specific information */
1822529f56eSJonathan T. Looney 	uint32_t	tlb_flex2;	/* Event specific information */
183e854dd38SRandall Stewart 	uint32_t	tlb_fbyte_in;	/* TCPCB first byte in time */
184e854dd38SRandall Stewart 	uint32_t	tlb_fbyte_out;	/* TCPCB first byte out time */
1852529f56eSJonathan T. Looney 	uint8_t		tlb_snd_scale:4, /* TCPCB snd_scale */
1862529f56eSJonathan T. Looney 			tlb_rcv_scale:4; /* TCPCB rcv_scale */
1872529f56eSJonathan T. Looney 	uint8_t		_pad[3];	/* Padding */
1882529f56eSJonathan T. Looney 	/* Per-stack info */
1892529f56eSJonathan T. Looney 	union tcp_log_stackspecific tlb_stackinfo;
1902529f56eSJonathan T. Looney #define	tlb_rack	tlb_stackinfo.u_rack
1912529f56eSJonathan T. Looney 
1922529f56eSJonathan T. Looney 	/* The packet */
1932529f56eSJonathan T. Looney 	uint32_t	tlb_len;	/* The packet's data length */
1942529f56eSJonathan T. Looney 	struct tcphdr	tlb_th;		/* The TCP header */
1952529f56eSJonathan T. Looney 	uint8_t		tlb_opts[TCP_MAXOLEN]; /* The TCP options */
1962529f56eSJonathan T. Looney 
1972529f56eSJonathan T. Looney 	/* Verbose information (optional) */
1982529f56eSJonathan T. Looney 	struct tcp_log_verbose tlb_verbose[0];
1992529f56eSJonathan T. Looney } ALIGN_TCP_LOG;
2002529f56eSJonathan T. Looney 
2012529f56eSJonathan T. Looney enum tcp_log_events {
2022529f56eSJonathan T. Looney 	TCP_LOG_IN = 1,		/* Incoming packet                   1 */
2032529f56eSJonathan T. Looney 	TCP_LOG_OUT,		/* Transmit (without other event)    2 */
2042529f56eSJonathan T. Looney 	TCP_LOG_RTO,		/* Retransmit timeout                3 */
2055d8fd932SRandall Stewart 	TCP_LOG_SB_WAKE,	/* Awaken socket buffer              4 */
2062529f56eSJonathan T. Looney 	TCP_LOG_BAD_RETRAN,	/* Detected bad retransmission       5 */
2072529f56eSJonathan T. Looney 	TCP_LOG_PRR,		/* Doing PRR                         6 */
2082529f56eSJonathan T. Looney 	TCP_LOG_REORDER,	/* Detected reorder                  7 */
2093b0b41e6SRandall Stewart 	TCP_LOG_HPTS,		/* Hpts sending a packet             8 */
2102529f56eSJonathan T. Looney 	BBR_LOG_BBRUPD,		/* We updated BBR info               9 */
2112529f56eSJonathan T. Looney 	BBR_LOG_BBRSND,		/* We did a slot calculation and sending is done 10 */
2122529f56eSJonathan T. Looney 	BBR_LOG_ACKCLEAR,	/* A ack clears all outstanding     11 */
2132529f56eSJonathan T. Looney 	BBR_LOG_INQUEUE,	/* The tcb had a packet input to it 12 */
2142529f56eSJonathan T. Looney 	BBR_LOG_TIMERSTAR,	/* Start a timer                    13 */
2152529f56eSJonathan T. Looney 	BBR_LOG_TIMERCANC,	/* Cancel a timer                   14 */
2162529f56eSJonathan T. Looney 	BBR_LOG_ENTREC,		/* Entered recovery                 15 */
2172529f56eSJonathan T. Looney 	BBR_LOG_EXITREC,	/* Exited recovery                  16 */
2182529f56eSJonathan T. Looney 	BBR_LOG_CWND,		/* Cwnd change                      17 */
2192529f56eSJonathan T. Looney 	BBR_LOG_BWSAMP,		/* LT B/W sample has been made      18 */
2202529f56eSJonathan T. Looney 	BBR_LOG_MSGSIZE,	/* We received a EMSGSIZE error     19 */
2212529f56eSJonathan T. Looney 	BBR_LOG_BBRRTT,		/* BBR RTT is updated               20 */
2222529f56eSJonathan T. Looney 	BBR_LOG_JUSTRET,	/* We just returned out of output   21 */
2235666643aSGordon Bergling 	BBR_LOG_STATE,		/* A BBR state change occurred      22 */
2245666643aSGordon Bergling 	BBR_LOG_PKT_EPOCH,      /* A BBR packet epoch occurred      23 */
2252529f56eSJonathan T. Looney 	BBR_LOG_PERSIST,        /* BBR changed to/from a persists   24 */
2262529f56eSJonathan T. Looney 	TCP_LOG_FLOWEND,        /* End of a flow                    25 */
2272529f56eSJonathan T. Looney 	BBR_LOG_RTO,            /* BBR's timeout includes BBR info  26 */
2283b0b41e6SRandall Stewart 	BBR_LOG_DOSEG_DONE,     /* hpts do_segment completes        27 */
2293b0b41e6SRandall Stewart 	BBR_LOG_EXIT_GAIN,      /* hpts do_segment completes        28 */
2302529f56eSJonathan T. Looney 	BBR_LOG_THRESH_CALC,    /* Doing threshold calculation      29 */
2315d8fd932SRandall Stewart 	TCP_LOG_MAPCHG,		/* Map Changes to the sendmap       30 */
2322529f56eSJonathan T. Looney 	TCP_LOG_USERSEND, 	/* User level sends data            31 */
2333b0b41e6SRandall Stewart 	BBR_RSM_CLEARED,	/* RSM cleared of ACK flags         32 */
2343b0b41e6SRandall Stewart 	BBR_LOG_STATE_TARGET, 	/* Log of target at state           33 */
2355666643aSGordon Bergling 	BBR_LOG_TIME_EPOCH, 	/* A timed based Epoch occurred     34 */
2362529f56eSJonathan T. Looney 	BBR_LOG_TO_PROCESS,	/* A to was processed               35 */
2372529f56eSJonathan T. Looney 	BBR_LOG_BBRTSO,		/* TSO update                       36 */
2383b0b41e6SRandall Stewart 	BBR_LOG_HPTSDIAG,	/* Hpts diag insert                 37 */
2392529f56eSJonathan T. Looney 	BBR_LOG_LOWGAIN,	/* Low gain accounting              38 */
2402529f56eSJonathan T. Looney 	BBR_LOG_PROGRESS,	/* Progress timer event             39 */
2412529f56eSJonathan T. Looney 	TCP_LOG_SOCKET_OPT,	/* A socket option is set           40 */
2422529f56eSJonathan T. Looney 	BBR_LOG_TIMERPREP,	/* A BBR var to debug out TLP issues  41 */
2432529f56eSJonathan T. Looney 	BBR_LOG_ENOBUF_JMP,	/* We had a enobuf jump             42 */
2443b0b41e6SRandall Stewart 	BBR_LOG_HPTSI_CALC,	/* calc the hptsi time              43 */
2452529f56eSJonathan T. Looney 	BBR_LOG_RTT_SHRINKS,	/* We had a log reduction of rttProp 44 */
2462529f56eSJonathan T. Looney 	BBR_LOG_BW_RED_EV,	/* B/W reduction events             45 */
2472529f56eSJonathan T. Looney 	BBR_LOG_REDUCE,		/* old bbr log reduce for 4.1 and earlier 46*/
2482529f56eSJonathan T. Looney 	TCP_LOG_RTT,		/* A rtt (in useconds) is being sampled and applied to the srtt algo 47 */
2492529f56eSJonathan T. Looney 	BBR_LOG_SETTINGS_CHG,	/* Settings changed for loss response 48 */
2503b0b41e6SRandall Stewart 	BBR_LOG_SRTT_GAIN_EVENT, /* SRTT gaining -- now not used    49 */
251c28440dbSRandall Stewart 	TCP_LOG_REASS,		/* Reassembly buffer logging        50 */
2521a714ff2SRandall Stewart 	TCP_HDWR_PACE_SIZE,	/*  TCP pacing size set (rl and rack uses this)  51 */
2533b0b41e6SRandall Stewart 	BBR_LOG_HDWR_PACE,	/* TCP Hardware pacing log          52 */
2543b0b41e6SRandall Stewart 	BBR_LOG_TSTMP_VAL,	/* Temp debug timestamp validation  53 */
2553b0b41e6SRandall Stewart 	TCP_LOG_CONNEND,	/* End of connection                54 */
2563b0b41e6SRandall Stewart 	TCP_LOG_LRO,		/* LRO entry                        55 */
2573b0b41e6SRandall Stewart 	TCP_SACK_FILTER_RES,	/* Results of SACK Filter           56 */
2583b0b41e6SRandall Stewart 	TCP_SAD_DETECTION,	/* Sack Attack Detection            57 */
259e570d231SRandall Stewart 	TCP_TIMELY_WORK,	/* Logs regarding Timely CC tweaks  58 */
260e570d231SRandall Stewart 	TCP_LOG_USER_EVENT,	/* User space event data            59 */
261e570d231SRandall Stewart 	TCP_LOG_SENDFILE,	/* sendfile() logging for TCP connections 60 */
262e570d231SRandall Stewart 	TCP_LOG_HTTP_T,		/* logging of http request tracking 61 */
2635d8fd932SRandall Stewart 	TCP_LOG_ACCOUNTING,	/* Log of TCP Accounting data 62 */
2645d8fd932SRandall Stewart 	TCP_LOG_FSB,		/* FSB information 63 */
2655baf32c9SRandall Stewart 	RACK_DSACK_HANDLING,	/* Handling of DSACK in rack for reordering window 64 */
2664e4c84f8SRandall Stewart 	TCP_HYSTART,		/* TCP Hystart logging 65 */
26762ce18fcSRandall Stewart 	TCP_CHG_QUERY,		/* Change query during fnc_init() 66 */
26862ce18fcSRandall Stewart 	TCP_RACK_LOG_COLLAPSE,	/* Window collapse by peer 67 */
269b16a37edSMichael Tuexen 	TCP_RACK_TP_TRIGGERED,	/* A rack tracepoint is triggered 68 */
270b16a37edSMichael Tuexen 	TCP_HYBRID_PACING_LOG,	/* Hybrid pacing log 69 */
27100812bbdSMichael Tuexen 	TCP_LOG_PRU,		/* TCP protocol user request        70 */
27200812bbdSMichael Tuexen 	TCP_LOG_END		/* End (keep at end)                71 */
2732529f56eSJonathan T. Looney };
2742529f56eSJonathan T. Looney 
2752529f56eSJonathan T. Looney enum tcp_log_states {
276*69c7c811SRandall Stewart 	TCP_LOG_STATE_RATIO_OFF = -2,	/* Log ratio evaluation yielded an OFF
277*69c7c811SRandall Stewart 					   result. Only used for tlb_logstate */
278*69c7c811SRandall Stewart 	TCP_LOG_STATE_CLEAR = -1,	/* Deactivate and clear tracing. Passed
279*69c7c811SRandall Stewart 					   to tcp_log_state_change() but never
280*69c7c811SRandall Stewart 					   stored in any logstate variable */
2812529f56eSJonathan T. Looney 	TCP_LOG_STATE_OFF = 0,		/* Pause */
282*69c7c811SRandall Stewart 
283*69c7c811SRandall Stewart 	/* Positively numbered states represent active logging modes */
2842529f56eSJonathan T. Looney 	TCP_LOG_STATE_TAIL=1,		/* Keep the trailing events */
2852529f56eSJonathan T. Looney 	TCP_LOG_STATE_HEAD=2,		/* Keep the leading events */
2862529f56eSJonathan T. Looney 	TCP_LOG_STATE_HEAD_AUTO=3,	/* Keep the leading events, and
2872529f56eSJonathan T. Looney 					   automatically dump them to the
2882529f56eSJonathan T. Looney 					   device  */
2892529f56eSJonathan T. Looney 	TCP_LOG_STATE_CONTINUAL=4,	/* Continually dump the data when full */
2902529f56eSJonathan T. Looney 	TCP_LOG_STATE_TAIL_AUTO=5,	/* Keep the trailing events, and
2912529f56eSJonathan T. Looney 					   automatically dump them when the
2922529f56eSJonathan T. Looney 					   session ends */
293*69c7c811SRandall Stewart 	TCP_LOG_VIA_BBPOINTS=6		/* Log only if the BB point has been configured */
2942529f56eSJonathan T. Looney };
2952529f56eSJonathan T. Looney 
2962529f56eSJonathan T. Looney /* Use this if we don't know whether the operation succeeded. */
2972529f56eSJonathan T. Looney #define	ERRNO_UNK	(-1)
2982529f56eSJonathan T. Looney 
2992529f56eSJonathan T. Looney /*
3002529f56eSJonathan T. Looney  * If the user included dev/tcp_log/tcp_log_dev.h, then include our private
3012529f56eSJonathan T. Looney  * headers. Otherwise, there is no reason to pollute all the files with an
3022529f56eSJonathan T. Looney  * additional include.
3032529f56eSJonathan T. Looney  *
3042529f56eSJonathan T. Looney  * This structure is aligned to an 8-byte boundary to match the alignment
3052529f56eSJonathan T. Looney  * requirements of (struct tcp_log_buffer).
3062529f56eSJonathan T. Looney  */
3072529f56eSJonathan T. Looney #ifdef __tcp_log_dev_h__
3082529f56eSJonathan T. Looney struct tcp_log_header {
3092529f56eSJonathan T. Looney 	struct tcp_log_common_header tlh_common;
3102529f56eSJonathan T. Looney #define	tlh_version	tlh_common.tlch_version
3112529f56eSJonathan T. Looney #define	tlh_type	tlh_common.tlch_type
3122529f56eSJonathan T. Looney #define	tlh_length	tlh_common.tlch_length
3132529f56eSJonathan T. Looney 	struct in_endpoints	tlh_ie;
3142529f56eSJonathan T. Looney 	struct timeval		tlh_offset;	/* Uptime -> UTC offset */
3152529f56eSJonathan T. Looney 	char			tlh_id[TCP_LOG_ID_LEN];
3162529f56eSJonathan T. Looney 	char			tlh_reason[TCP_LOG_REASON_LEN];
317a9a08eceSRandall Stewart 	char			tlh_tag[TCP_LOG_TAG_LEN];
3182529f56eSJonathan T. Looney 	uint8_t		tlh_af;
3192529f56eSJonathan T. Looney 	uint8_t		_pad[7];
3202529f56eSJonathan T. Looney } ALIGN_TCP_LOG;
3212529f56eSJonathan T. Looney 
3222529f56eSJonathan T. Looney #ifdef _KERNEL
3232529f56eSJonathan T. Looney struct tcp_log_dev_log_queue {
3242529f56eSJonathan T. Looney 	struct tcp_log_dev_queue tldl_common;
3252529f56eSJonathan T. Looney 	char			tldl_id[TCP_LOG_ID_LEN];
3262529f56eSJonathan T. Looney 	char			tldl_reason[TCP_LOG_REASON_LEN];
327a9a08eceSRandall Stewart 	char			tldl_tag[TCP_LOG_TAG_LEN];
3282529f56eSJonathan T. Looney 	struct in_endpoints	tldl_ie;
3292529f56eSJonathan T. Looney 	struct tcp_log_stailq	tldl_entries;
3302529f56eSJonathan T. Looney 	int			tldl_count;
3312529f56eSJonathan T. Looney 	uint8_t			tldl_af;
3322529f56eSJonathan T. Looney };
3332529f56eSJonathan T. Looney #endif /* _KERNEL */
3342529f56eSJonathan T. Looney #endif /* __tcp_log_dev_h__ */
3352529f56eSJonathan T. Looney 
336*69c7c811SRandall Stewart /*
337*69c7c811SRandall Stewart  * Defined BBPOINTS that can be used
338*69c7c811SRandall Stewart  * with TCP_LOG_VIA_BBPOINTS.
339*69c7c811SRandall Stewart  */
340*69c7c811SRandall Stewart #define TCP_BBPOINT_NONE		0
341*69c7c811SRandall Stewart #define TCP_BBPOINT_REQ_LEVEL_LOGGING	1
342*69c7c811SRandall Stewart 
343*69c7c811SRandall Stewart /*********************/
344*69c7c811SRandall Stewart /* TCP Trace points */
345*69c7c811SRandall Stewart /*********************/
346*69c7c811SRandall Stewart /*
347*69c7c811SRandall Stewart  * TCP trace points are interesting points within
348*69c7c811SRandall Stewart  * the TCP code that the author/debugger may want
349*69c7c811SRandall Stewart  * to have BB logging enabled if we hit that point.
350*69c7c811SRandall Stewart  * In order to enable a trace point you set the
351*69c7c811SRandall Stewart  * sysctl var net.inet.tcp.bb.tp.number to
352*69c7c811SRandall Stewart  * one of the numbers listed below. You also
353*69c7c811SRandall Stewart  * must make sure net.inet.tcp.bb.tp.bbmode is
354*69c7c811SRandall Stewart  * non-zero, the default is 4 for continuous tracing.
355*69c7c811SRandall Stewart  * You also set in the number of connections you want
356*69c7c811SRandall Stewart  * have get BB logs in net.inet.tcp.bb.tp.count.
357*69c7c811SRandall Stewart  *
358*69c7c811SRandall Stewart  * Count will decrement every time BB logging is assigned
359*69c7c811SRandall Stewart  * to a connection that hit your tracepoint.
360*69c7c811SRandall Stewart  *
361*69c7c811SRandall Stewart  * You can enable all trace points by setting the number
362*69c7c811SRandall Stewart  * to 0xffffffff. You can disable all trace points by
363*69c7c811SRandall Stewart  * setting number to zero (or count to 0).
364*69c7c811SRandall Stewart  *
365*69c7c811SRandall Stewart  * Below are the enumerated list of tracepoints that
366*69c7c811SRandall Stewart  * have currently been defined in the code. Add more
367*69c7c811SRandall Stewart  * as you add a call to rack_trace_point(rack, <name>);
368*69c7c811SRandall Stewart  * where <name> is defined below.
369*69c7c811SRandall Stewart  */
370*69c7c811SRandall Stewart #define TCP_TP_HWENOBUF		0x00000001	/* When we are doing hardware pacing and hit enobufs */
371*69c7c811SRandall Stewart #define TCP_TP_ENOBUF		0x00000002	/* When we hit enobufs with software pacing */
372*69c7c811SRandall Stewart #define TCP_TP_COLLAPSED_WND	0x00000003	/* When a peer to collapses its rwnd on us */
373*69c7c811SRandall Stewart #define TCP_TP_COLLAPSED_RXT	0x00000004	/* When we actually retransmit a collapsed window rsm */
374*69c7c811SRandall Stewart #define TCP_TP_HTTP_LOG_FAIL	0x00000005	/* We tried to allocate a HTTP log but had no space */
375*69c7c811SRandall Stewart #define TCP_TP_RESET_RCV	0x00000006	/* Triggers when we receive a RST */
376*69c7c811SRandall Stewart #define TCP_TP_EXCESS_RXT	0x00000007	/* When we get excess RXT's clamping the cwnd */
377*69c7c811SRandall Stewart #define TCP_TP_SAD_TRIGGERED	0x00000008	/* Sack Attack Detection triggers */
378*69c7c811SRandall Stewart 
379*69c7c811SRandall Stewart #define TCP_TP_SAD_SUSPECT	0x0000000a	/* A sack has supicious information in it */
380*69c7c811SRandall Stewart 
3812529f56eSJonathan T. Looney #ifdef _KERNEL
3822529f56eSJonathan T. Looney 
383*69c7c811SRandall Stewart extern uint32_t tcp_trace_point_config;
384*69c7c811SRandall Stewart extern uint32_t tcp_trace_point_bb_mode;
385*69c7c811SRandall Stewart extern int32_t tcp_trace_point_count;
386*69c7c811SRandall Stewart 
387*69c7c811SRandall Stewart /*
388*69c7c811SRandall Stewart  * Returns true if any sort of BB logging is enabled,
389*69c7c811SRandall Stewart  * commonly used throughout the codebase.
390*69c7c811SRandall Stewart  */
391*69c7c811SRandall Stewart static inline int
392*69c7c811SRandall Stewart tcp_bblogging_on(struct tcpcb *tp)
393*69c7c811SRandall Stewart {
394*69c7c811SRandall Stewart 	if (tp->_t_logstate <= TCP_LOG_STATE_OFF)
395*69c7c811SRandall Stewart 		return (0);
396*69c7c811SRandall Stewart 	if (tp->_t_logstate == TCP_LOG_VIA_BBPOINTS)
397*69c7c811SRandall Stewart 		return (0);
398*69c7c811SRandall Stewart 	return (1);
399*69c7c811SRandall Stewart }
400*69c7c811SRandall Stewart 
401*69c7c811SRandall Stewart /*
402*69c7c811SRandall Stewart  * Returns true if we match a specific bbpoint when
403*69c7c811SRandall Stewart  * in TCP_LOG_VIA_BBPOINTS, but also returns true
404*69c7c811SRandall Stewart  * for all the other logging states.
405*69c7c811SRandall Stewart  */
406*69c7c811SRandall Stewart static inline int
407*69c7c811SRandall Stewart tcp_bblogging_point_on(struct tcpcb *tp, uint8_t bbpoint)
408*69c7c811SRandall Stewart {
409*69c7c811SRandall Stewart 	if (tp->_t_logstate <= TCP_LOG_STATE_OFF)
410*69c7c811SRandall Stewart 		return (0);
411*69c7c811SRandall Stewart 	if ((tp->_t_logstate == TCP_LOG_VIA_BBPOINTS) &&
412*69c7c811SRandall Stewart 	    (tp->_t_logpoint == bbpoint))
413*69c7c811SRandall Stewart 		return (1);
414*69c7c811SRandall Stewart 	else if (tp->_t_logstate == TCP_LOG_VIA_BBPOINTS)
415*69c7c811SRandall Stewart 		return (0);
416*69c7c811SRandall Stewart 	return (1);
417*69c7c811SRandall Stewart }
418*69c7c811SRandall Stewart 
419*69c7c811SRandall Stewart static inline void
420*69c7c811SRandall Stewart tcp_set_bblog_state(struct tcpcb *tp, uint8_t ls, uint8_t bbpoint)
421*69c7c811SRandall Stewart {
422*69c7c811SRandall Stewart 	if ((ls == TCP_LOG_VIA_BBPOINTS) &&
423*69c7c811SRandall Stewart 	    (tp->_t_logstate <= TCP_LOG_STATE_OFF)){
424*69c7c811SRandall Stewart 		/*
425*69c7c811SRandall Stewart 		 * We don't allow a BBPOINTS set to override
426*69c7c811SRandall Stewart 		 * other types of BB logging set by other means such
427*69c7c811SRandall Stewart 		 * as the bb_ratio/bb_state URL parameters. In other
428*69c7c811SRandall Stewart 		 * words BBlogging must be *off* in order to turn on
429*69c7c811SRandall Stewart 		 * a BBpoint.
430*69c7c811SRandall Stewart 		 */
431*69c7c811SRandall Stewart 		tp->_t_logpoint = bbpoint;
432*69c7c811SRandall Stewart 		tp->_t_logstate = ls;
433*69c7c811SRandall Stewart 	} else if (ls != TCP_LOG_VIA_BBPOINTS) {
434*69c7c811SRandall Stewart 		tp->_t_logpoint = 0;
435*69c7c811SRandall Stewart 		if ((ls >= TCP_LOG_STATE_OFF) &&
436*69c7c811SRandall Stewart 		    (ls < TCP_LOG_VIA_BBPOINTS))
437*69c7c811SRandall Stewart 			tp->_t_logstate = ls;
438*69c7c811SRandall Stewart 	}
439*69c7c811SRandall Stewart }
440*69c7c811SRandall Stewart 
441*69c7c811SRandall Stewart static inline uint32_t
442*69c7c811SRandall Stewart tcp_get_bblog_state(struct tcpcb *tp)
443*69c7c811SRandall Stewart {
444*69c7c811SRandall Stewart 	return (tp->_t_logstate);
445*69c7c811SRandall Stewart }
446*69c7c811SRandall Stewart 
447*69c7c811SRandall Stewart static inline void
448*69c7c811SRandall Stewart tcp_trace_point(struct tcpcb *tp, int num)
449*69c7c811SRandall Stewart {
450*69c7c811SRandall Stewart 	if (((tcp_trace_point_config == num)  ||
451*69c7c811SRandall Stewart 	     (tcp_trace_point_config == 0xffffffff)) &&
452*69c7c811SRandall Stewart 	    (tcp_trace_point_bb_mode != 0) &&
453*69c7c811SRandall Stewart 	    (tcp_trace_point_count > 0) &&
454*69c7c811SRandall Stewart 	    (tcp_bblogging_on(tp) == 0)) {
455*69c7c811SRandall Stewart 		int res;
456*69c7c811SRandall Stewart 		res = atomic_fetchadd_int(&tcp_trace_point_count, -1);
457*69c7c811SRandall Stewart 		if (res > 0) {
458*69c7c811SRandall Stewart 			tcp_set_bblog_state(tp, tcp_trace_point_bb_mode, TCP_BBPOINT_NONE);
459*69c7c811SRandall Stewart 		} else {
460*69c7c811SRandall Stewart 			/* Loss a race assure its zero now */
461*69c7c811SRandall Stewart 			tcp_trace_point_count = 0;
462*69c7c811SRandall Stewart 		}
463*69c7c811SRandall Stewart 	}
464*69c7c811SRandall Stewart }
465*69c7c811SRandall Stewart 
4663b0b41e6SRandall Stewart #define	TCP_LOG_BUF_DEFAULT_SESSION_LIMIT	5000
4673b0b41e6SRandall Stewart #define	TCP_LOG_BUF_DEFAULT_GLOBAL_LIMIT	5000000
4682529f56eSJonathan T. Looney 
4692529f56eSJonathan T. Looney /*
4702529f56eSJonathan T. Looney  * TCP_LOG_EVENT_VERBOSE: The same as TCP_LOG_EVENT, except it always
4712529f56eSJonathan T. Looney  * tries to record verbose information.
4722529f56eSJonathan T. Looney  */
4732529f56eSJonathan T. Looney #define	TCP_LOG_EVENT_VERBOSE(tp, th, rxbuf, txbuf, eventid, errornum, len, stackinfo, th_hostorder, tv) \
4742529f56eSJonathan T. Looney 	do {								\
475*69c7c811SRandall Stewart 		if (tcp_bblogging_on(tp)) \
476*69c7c811SRandall Stewart 			tcp_log_event(tp, th, rxbuf, txbuf, eventid,	\
4772529f56eSJonathan T. Looney 			    errornum, len, stackinfo, th_hostorder,	\
4782529f56eSJonathan T. Looney 			    tp->t_output_caller, __func__, __LINE__, tv);\
4792529f56eSJonathan T. Looney 	} while (0)
4802529f56eSJonathan T. Looney 
4812529f56eSJonathan T. Looney /*
4822529f56eSJonathan T. Looney  * TCP_LOG_EVENT: This is a macro so we can capture function/line
483*69c7c811SRandall Stewart  * information when needed. You can use the macro when you are not
484*69c7c811SRandall Stewart  * doing a lot of prep in the stack specific information i.e. you
485*69c7c811SRandall Stewart  * don't add extras (stackinfo). If you are adding extras which
486*69c7c811SRandall Stewart  * means filling out a stack variable instead use the tcp_log_event()
487*69c7c811SRandall Stewart  * function but enclose the call to the log (and all the setup) in a
488*69c7c811SRandall Stewart  * if (tcp_bblogging_on(tp)) {
489*69c7c811SRandall Stewart  *   ... setup and logging call ...
490*69c7c811SRandall Stewart  * }
491*69c7c811SRandall Stewart  *
492*69c7c811SRandall Stewart  * Always use the macro tcp_bblogging_on() since sometimes the defintions
493*69c7c811SRandall Stewart  * do change.
494*69c7c811SRandall Stewart  *
495*69c7c811SRandall Stewart  * BBlogging also supports the concept of a BBpoint. The idea behind this
496*69c7c811SRandall Stewart  * is that when you set a specific BBpoint on and turn the logging into
497*69c7c811SRandall Stewart  * the BBpoint mode (TCP_LOG_VIA_BBPOINTS) you will be defining very very
498*69c7c811SRandall Stewart  * few of these points to come out. The point is specific to a code you
499*69c7c811SRandall Stewart  * want tied to that one BB logging. This allows you to turn on a much broader
500*69c7c811SRandall Stewart  * scale set of limited logging on more connections without overwhelming the
501*69c7c811SRandall Stewart  * I/O system with too much BBlogs. This of course means you need to be quite
502*69c7c811SRandall Stewart  * careful on how many BBlogs go with each point, but you can have multiple points
503*69c7c811SRandall Stewart  * only one of which is active at a time.
504*69c7c811SRandall Stewart  *
505*69c7c811SRandall Stewart  * To define a point you add it above under the define for TCP_BBPOINT_NONE (which
506*69c7c811SRandall Stewart  * is the default i.e. no point is defined. You then, for your point use the
507*69c7c811SRandall Stewart  * tcp_bblogging_point_on(struct tcpcb *tp, uint8_t bbpoint) inline to enclose
508*69c7c811SRandall Stewart  * your call to tcp_log_event.  Do not use one of the TCP_LOGGING macros else
509*69c7c811SRandall Stewart  * your point will never come out. You specify your defined point in the bbpoint
510*69c7c811SRandall Stewart  * side of the inline. An example of this you can find in rack where the
511*69c7c811SRandall Stewart  * TCP_BBPOINT_REQ_LEVEL_LOGGING is used. There a specific set of logs are generated
512*69c7c811SRandall Stewart  * for each http request that rack is tracking.
513*69c7c811SRandall Stewart  *
514*69c7c811SRandall Stewart  * When turning on BB logging use the inline:
515*69c7c811SRandall Stewart  * tcp_set_bblog_state(struct tcpcb *tp, uint8_t ls, uint8_t bbpoint)
516*69c7c811SRandall Stewart  * the ls field is the logging state TCP_LOG_STATE_CONTINUAL etc. The
517*69c7c811SRandall Stewart  * bbpoint field is ignored unless the ls field is set to TCP_LOG_VIA_BBPOINTS.
518*69c7c811SRandall Stewart  * Currently there is only a socket option that turns on the non-BBPOINT
519*69c7c811SRandall Stewart  * logging.
5202529f56eSJonathan T. Looney  *
5212529f56eSJonathan T. Looney  * Prototype:
5222529f56eSJonathan T. Looney  * TCP_LOG_EVENT(struct tcpcb *tp, struct tcphdr *th, struct sockbuf *rxbuf,
5232529f56eSJonathan T. Looney  *     struct sockbuf *txbuf, uint8_t eventid, int errornum,
5242529f56eSJonathan T. Looney  *     union tcp_log_stackspecific *stackinfo)
5252529f56eSJonathan T. Looney  *
5262529f56eSJonathan T. Looney  * tp is mandatory and must be write locked.
5272529f56eSJonathan T. Looney  * th is optional; if present, it will appear in the record.
5282529f56eSJonathan T. Looney  * rxbuf and txbuf are optional; if present, they will appear in the record.
5292529f56eSJonathan T. Looney  * eventid is mandatory.
5302529f56eSJonathan T. Looney  * errornum is mandatory (it indicates the success or failure of the
5312529f56eSJonathan T. Looney  *     operation associated with the event).
5322529f56eSJonathan T. Looney  * len indicates the length of the packet. If no packet, use 0.
5332529f56eSJonathan T. Looney  * stackinfo is optional; if present, it will appear in the record.
5342529f56eSJonathan T. Looney  */
535326f4556SGleb Smirnoff struct tcpcb;
5362529f56eSJonathan T. Looney #ifdef TCP_LOG_FORCEVERBOSE
5372529f56eSJonathan T. Looney #define	TCP_LOG_EVENT	TCP_LOG_EVENT_VERBOSE
5382529f56eSJonathan T. Looney #else
5392529f56eSJonathan T. Looney #define	TCP_LOG_EVENT(tp, th, rxbuf, txbuf, eventid, errornum, len, stackinfo, th_hostorder) \
5402529f56eSJonathan T. Looney 	do {								\
5412529f56eSJonathan T. Looney 		if (tcp_log_verbose)					\
5422529f56eSJonathan T. Looney 			TCP_LOG_EVENT_VERBOSE(tp, th, rxbuf, txbuf,	\
5432529f56eSJonathan T. Looney 			    eventid, errornum, len, stackinfo,		\
5442529f56eSJonathan T. Looney 			    th_hostorder, NULL);			\
545*69c7c811SRandall Stewart 		else if (tcp_bblogging_on(tp))				\
546*69c7c811SRandall Stewart 			tcp_log_event(tp, th, rxbuf, txbuf, eventid,	\
5472529f56eSJonathan T. Looney 			    errornum, len, stackinfo, th_hostorder,	\
5482529f56eSJonathan T. Looney 			    NULL, NULL, 0, NULL);			\
5492529f56eSJonathan T. Looney 	} while (0)
5502529f56eSJonathan T. Looney #endif /* TCP_LOG_FORCEVERBOSE */
5512529f56eSJonathan T. Looney #define	TCP_LOG_EVENTP(tp, th, rxbuf, txbuf, eventid, errornum, len, stackinfo, th_hostorder, tv) \
5522529f56eSJonathan T. Looney 	do {								\
553*69c7c811SRandall Stewart 		if (tcp_bblogging_on(tp))				\
554*69c7c811SRandall Stewart 			tcp_log_event(tp, th, rxbuf, txbuf, eventid,	\
5552529f56eSJonathan T. Looney 			    errornum, len, stackinfo, th_hostorder,	\
5562529f56eSJonathan T. Looney 			    NULL, NULL, 0, tv);				\
5572529f56eSJonathan T. Looney 	} while (0)
5582529f56eSJonathan T. Looney 
559e24e5683SJonathan T. Looney #ifdef TCP_BLACKBOX
5602529f56eSJonathan T. Looney extern bool tcp_log_verbose;
5612529f56eSJonathan T. Looney void tcp_log_drain(struct tcpcb *tp);
5622529f56eSJonathan T. Looney int tcp_log_dump_tp_logbuf(struct tcpcb *tp, char *reason, int how, bool force);
5632529f56eSJonathan T. Looney void tcp_log_dump_tp_bucket_logbufs(struct tcpcb *tp, char *reason);
564*69c7c811SRandall Stewart struct tcp_log_buffer *tcp_log_event(struct tcpcb *tp, struct tcphdr *th, struct sockbuf *rxbuf,
5652529f56eSJonathan T. Looney     struct sockbuf *txbuf, uint8_t eventid, int errornum, uint32_t len,
5662529f56eSJonathan T. Looney     union tcp_log_stackspecific *stackinfo, int th_hostorder,
5672529f56eSJonathan T. Looney     const char *output_caller, const char *func, int line, const struct timeval *tv);
5682529f56eSJonathan T. Looney size_t tcp_log_get_id(struct tcpcb *tp, char *buf);
569a9a08eceSRandall Stewart size_t tcp_log_get_tag(struct tcpcb *tp, char *buf);
5702529f56eSJonathan T. Looney u_int tcp_log_get_id_cnt(struct tcpcb *tp);
5712529f56eSJonathan T. Looney int tcp_log_getlogbuf(struct sockopt *sopt, struct tcpcb *tp);
5722529f56eSJonathan T. Looney void tcp_log_init(void);
5732529f56eSJonathan T. Looney int tcp_log_set_id(struct tcpcb *tp, char *id);
574a9a08eceSRandall Stewart int tcp_log_set_tag(struct tcpcb *tp, char *tag);
5752529f56eSJonathan T. Looney int tcp_log_state_change(struct tcpcb *tp, int state);
5762529f56eSJonathan T. Looney void tcp_log_tcpcbinit(struct tcpcb *tp);
5772529f56eSJonathan T. Looney void tcp_log_tcpcbfini(struct tcpcb *tp);
5782529f56eSJonathan T. Looney void tcp_log_flowend(struct tcpcb *tp);
579*69c7c811SRandall Stewart void tcp_log_sendfile(struct socket *so, off_t offset, size_t nbytes,
580*69c7c811SRandall Stewart     int flags);
581*69c7c811SRandall Stewart int tcp_log_apply_ratio(struct tcpcb *tp, int ratio);
582e24e5683SJonathan T. Looney #else /* !TCP_BLACKBOX */
583e24e5683SJonathan T. Looney #define tcp_log_verbose	(false)
584e24e5683SJonathan T. Looney 
585e24e5683SJonathan T. Looney static inline struct tcp_log_buffer *
586*69c7c811SRandall Stewart tcp_log_event(struct tcpcb *tp, struct tcphdr *th, struct sockbuf *rxbuf,
587e24e5683SJonathan T. Looney     struct sockbuf *txbuf, uint8_t eventid, int errornum, uint32_t len,
588e24e5683SJonathan T. Looney     union tcp_log_stackspecific *stackinfo, int th_hostorder,
589e24e5683SJonathan T. Looney     const char *output_caller, const char *func, int line,
590e24e5683SJonathan T. Looney     const struct timeval *tv)
591e24e5683SJonathan T. Looney {
592e24e5683SJonathan T. Looney 
593e24e5683SJonathan T. Looney 	return (NULL);
594e24e5683SJonathan T. Looney }
595e24e5683SJonathan T. Looney #endif /* TCP_BLACKBOX */
5962529f56eSJonathan T. Looney 
5972529f56eSJonathan T. Looney #endif	/* _KERNEL */
5982529f56eSJonathan T. Looney #endif	/* __tcp_log_buf_h__ */
599