1ff550d0eSmasputra /* 2ff550d0eSmasputra * CDDL HEADER START 3ff550d0eSmasputra * 4ff550d0eSmasputra * The contents of this file are subject to the terms of the 5a2036d4dSmeem * Common Development and Distribution License (the "License"). 6a2036d4dSmeem * You may not use this file except in compliance with the License. 7ff550d0eSmasputra * 8ff550d0eSmasputra * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9ff550d0eSmasputra * or http://www.opensolaris.org/os/licensing. 10ff550d0eSmasputra * See the License for the specific language governing permissions 11ff550d0eSmasputra * and limitations under the License. 12ff550d0eSmasputra * 13ff550d0eSmasputra * When distributing Covered Code, include this CDDL HEADER in each 14ff550d0eSmasputra * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15ff550d0eSmasputra * If applicable, add the following below this CDDL HEADER, with the 16ff550d0eSmasputra * fields enclosed by brackets "[]" replaced with your own identifying 17ff550d0eSmasputra * information: Portions Copyright [yyyy] [name of copyright owner] 18ff550d0eSmasputra * 19ff550d0eSmasputra * CDDL HEADER END 20ff550d0eSmasputra */ 21ff550d0eSmasputra /* 2266cd0f60SKacheong Poon * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. 23aec2a073SJerry Jelinek * Copyright (c) 2011, Joyent Inc. All rights reserved. 24e068a72aSTheo Schlossnagle * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. 25633fc3a6SSebastien Roy * Copyright (c) 2013, 2014 by Delphix. All rights reserved. 26ff550d0eSmasputra */ 27ff550d0eSmasputra 28ff550d0eSmasputra #ifndef _INET_TCP_IMPL_H 29ff550d0eSmasputra #define _INET_TCP_IMPL_H 30ff550d0eSmasputra 31ff550d0eSmasputra /* 32ff550d0eSmasputra * TCP implementation private declarations. These interfaces are 33ff550d0eSmasputra * used to build the IP module and are not meant to be accessed 34ff550d0eSmasputra * by any modules except IP itself. They are undocumented and are 35ff550d0eSmasputra * subject to change without notice. 36ff550d0eSmasputra */ 37ff550d0eSmasputra 38ff550d0eSmasputra #ifdef __cplusplus 39ff550d0eSmasputra extern "C" { 40ff550d0eSmasputra #endif 41ff550d0eSmasputra 42ff550d0eSmasputra #ifdef _KERNEL 43ff550d0eSmasputra 44721fffe3SKacheong Poon #include <sys/cpuvar.h> 45721fffe3SKacheong Poon #include <sys/clock_impl.h> /* For LBOLT_FASTPATH{,64} */ 460f1702c5SYu Xiangning #include <inet/optcom.h> 47ff550d0eSmasputra #include <inet/tcp.h> 486e91bba0SGirish Moodalbail #include <inet/tunables.h> 49ff550d0eSmasputra 50ff550d0eSmasputra #define TCP_MOD_ID 5105 51ff550d0eSmasputra 52721fffe3SKacheong Poon extern struct qinit tcp_sock_winit; 53721fffe3SKacheong Poon extern struct qinit tcp_winit; 54721fffe3SKacheong Poon 55721fffe3SKacheong Poon extern sock_downcalls_t sock_tcp_downcalls; 56721fffe3SKacheong Poon 57721fffe3SKacheong Poon /* 58299625c6SSebastien Roy * Note that by default, the _snd_lowat_fraction tunable controls the value of 59299625c6SSebastien Roy * the transmit low water mark. TCP_XMIT_LOWATER (and thus the _xmit_lowat 60299625c6SSebastien Roy * property) is only used if the administrator has disabled _snd_lowat_fraction 61299625c6SSebastien Roy * by setting it to 0. 62299625c6SSebastien Roy */ 63299625c6SSebastien Roy #define TCP_XMIT_LOWATER 4096 64299625c6SSebastien Roy #define TCP_XMIT_HIWATER 49152 65299625c6SSebastien Roy #define TCP_RECV_LOWATER 2048 66299625c6SSebastien Roy #define TCP_RECV_HIWATER 128000 67299625c6SSebastien Roy 68299625c6SSebastien Roy /* 69721fffe3SKacheong Poon * Bind hash list size and has function. It has to be a power of 2 for 70721fffe3SKacheong Poon * hashing. 71721fffe3SKacheong Poon */ 72aec2a073SJerry Jelinek #define TCP_BIND_FANOUT_SIZE 1024 73721fffe3SKacheong Poon #define TCP_BIND_HASH(lport) (ntohs(lport) & (TCP_BIND_FANOUT_SIZE - 1)) 74721fffe3SKacheong Poon 75721fffe3SKacheong Poon /* 76721fffe3SKacheong Poon * This implementation follows the 4.3BSD interpretation of the urgent 77721fffe3SKacheong Poon * pointer and not RFC 1122. Switching to RFC 1122 behavior would cause 78721fffe3SKacheong Poon * incompatible changes in protocols like telnet and rlogin. 79721fffe3SKacheong Poon */ 80721fffe3SKacheong Poon #define TCP_OLD_URP_INTERPRETATION 1 81721fffe3SKacheong Poon 82721fffe3SKacheong Poon /* TCP option length */ 83721fffe3SKacheong Poon #define TCPOPT_NOP_LEN 1 84721fffe3SKacheong Poon #define TCPOPT_MAXSEG_LEN 4 85721fffe3SKacheong Poon #define TCPOPT_WS_LEN 3 86721fffe3SKacheong Poon #define TCPOPT_REAL_WS_LEN (TCPOPT_WS_LEN+1) 87721fffe3SKacheong Poon #define TCPOPT_TSTAMP_LEN 10 88721fffe3SKacheong Poon #define TCPOPT_REAL_TS_LEN (TCPOPT_TSTAMP_LEN+2) 89721fffe3SKacheong Poon #define TCPOPT_SACK_OK_LEN 2 90721fffe3SKacheong Poon #define TCPOPT_REAL_SACK_OK_LEN (TCPOPT_SACK_OK_LEN+2) 91721fffe3SKacheong Poon #define TCPOPT_REAL_SACK_LEN 4 92721fffe3SKacheong Poon #define TCPOPT_MAX_SACK_LEN 36 93721fffe3SKacheong Poon #define TCPOPT_HEADER_LEN 2 94721fffe3SKacheong Poon 95721fffe3SKacheong Poon /* Round up the value to the nearest mss. */ 96721fffe3SKacheong Poon #define MSS_ROUNDUP(value, mss) ((((value) - 1) / (mss) + 1) * (mss)) 97721fffe3SKacheong Poon 98ff550d0eSmasputra /* 99ff550d0eSmasputra * Was this tcp created via socket() interface? 100ff550d0eSmasputra */ 101ff550d0eSmasputra #define TCP_IS_SOCKET(tcp) ((tcp)->tcp_issocket) 102ff550d0eSmasputra 103ff550d0eSmasputra /* 104ff550d0eSmasputra * Is this tcp not attached to any upper client? 105ff550d0eSmasputra */ 106ff550d0eSmasputra #define TCP_IS_DETACHED(tcp) ((tcp)->tcp_detached) 107ff550d0eSmasputra 108721fffe3SKacheong Poon /* TCP timers related data strucutres. Refer to tcp_timers.c. */ 109721fffe3SKacheong Poon typedef struct tcp_timer_s { 110721fffe3SKacheong Poon conn_t *connp; 111721fffe3SKacheong Poon void (*tcpt_proc)(void *); 112721fffe3SKacheong Poon callout_id_t tcpt_tid; 113721fffe3SKacheong Poon } tcp_timer_t; 114721fffe3SKacheong Poon 115721fffe3SKacheong Poon extern kmem_cache_t *tcp_timercache; 116721fffe3SKacheong Poon 117721fffe3SKacheong Poon /* 118721fffe3SKacheong Poon * Macro for starting various timers. Retransmission timer has its own macro, 11966cd0f60SKacheong Poon * TCP_TIMER_RESTART(). tim is in millisec. 120721fffe3SKacheong Poon */ 121ff550d0eSmasputra #define TCP_TIMER(tcp, f, tim) \ 122ff550d0eSmasputra tcp_timeout(tcp->tcp_connp, f, tim) 123ff550d0eSmasputra #define TCP_TIMER_CANCEL(tcp, id) \ 124ff550d0eSmasputra tcp_timeout_cancel(tcp->tcp_connp, id) 125ff550d0eSmasputra 126ff550d0eSmasputra /* 12766cd0f60SKacheong Poon * To restart the TCP retransmission timer. intvl is in millisec. 128ff550d0eSmasputra */ 129ff550d0eSmasputra #define TCP_TIMER_RESTART(tcp, intvl) { \ 130ff550d0eSmasputra if ((tcp)->tcp_timer_tid != 0) \ 131ff550d0eSmasputra (void) TCP_TIMER_CANCEL((tcp), (tcp)->tcp_timer_tid); \ 13266cd0f60SKacheong Poon (tcp)->tcp_timer_tid = TCP_TIMER((tcp), tcp_timer, (intvl)); \ 133ff550d0eSmasputra } 134ff550d0eSmasputra 135ff550d0eSmasputra /* 136721fffe3SKacheong Poon * For scalability, we must not run a timer for every TCP connection 137721fffe3SKacheong Poon * in TIME_WAIT state. To see why, consider (for time wait interval of 138721fffe3SKacheong Poon * 1 minutes): 139721fffe3SKacheong Poon * 10,000 connections/sec * 60 seconds/time wait = 600,000 active conn's 140721fffe3SKacheong Poon * 141721fffe3SKacheong Poon * This list is ordered by time, so you need only delete from the head 142721fffe3SKacheong Poon * until you get to entries which aren't old enough to delete yet. 143721fffe3SKacheong Poon * The list consists of only the detached TIME_WAIT connections. 144721fffe3SKacheong Poon * 145721fffe3SKacheong Poon * When a tcp_t enters TIME_WAIT state, a timer is started (timeout is 146721fffe3SKacheong Poon * tcps_time_wait_interval). When the tcp_t is detached (upper layer closes 147721fffe3SKacheong Poon * the end point), it is moved to the time wait list and another timer is 148721fffe3SKacheong Poon * started (expiry time is set at tcp_time_wait_expire, which is 149721fffe3SKacheong Poon * also calculated using tcps_time_wait_interval). This means that the 150721fffe3SKacheong Poon * TIME_WAIT state can be extended (up to doubled) if the tcp_t doesn't 151721fffe3SKacheong Poon * become detached for a long time. 152721fffe3SKacheong Poon * 153721fffe3SKacheong Poon * The list manipulations (including tcp_time_wait_next/prev) 154721fffe3SKacheong Poon * are protected by the tcp_time_wait_lock. The content of the 155721fffe3SKacheong Poon * detached TIME_WAIT connections is protected by the normal perimeters. 156721fffe3SKacheong Poon * 157721fffe3SKacheong Poon * This list is per squeue and squeues are shared across the tcp_stack_t's. 158721fffe3SKacheong Poon * Things on tcp_time_wait_head remain associated with the tcp_stack_t 159721fffe3SKacheong Poon * and conn_netstack. 160721fffe3SKacheong Poon * The tcp_t's that are added to tcp_free_list are disassociated and 161721fffe3SKacheong Poon * have NULL tcp_tcps and conn_netstack pointers. 162721fffe3SKacheong Poon */ 163721fffe3SKacheong Poon typedef struct tcp_squeue_priv_s { 164721fffe3SKacheong Poon kmutex_t tcp_time_wait_lock; 165721fffe3SKacheong Poon callout_id_t tcp_time_wait_tid; 166721fffe3SKacheong Poon tcp_t *tcp_time_wait_head; 167721fffe3SKacheong Poon tcp_t *tcp_time_wait_tail; 168721fffe3SKacheong Poon tcp_t *tcp_free_list; 169721fffe3SKacheong Poon uint_t tcp_free_list_cnt; 1700870f17bSKacheong Poon #ifdef DEBUG 1710870f17bSKacheong Poon /* 1720870f17bSKacheong Poon * For debugging purpose, true when tcp_time_wait_collector() is 1730870f17bSKacheong Poon * running. 1740870f17bSKacheong Poon */ 1750870f17bSKacheong Poon boolean_t tcp_time_wait_running; 1760870f17bSKacheong Poon #endif 177721fffe3SKacheong Poon } tcp_squeue_priv_t; 178721fffe3SKacheong Poon 179721fffe3SKacheong Poon /* 180721fffe3SKacheong Poon * Parameters for TCP Initial Send Sequence number (ISS) generation. When 181721fffe3SKacheong Poon * tcp_strong_iss is set to 1, which is the default, the ISS is calculated 182721fffe3SKacheong Poon * by adding three components: a time component which grows by 1 every 4096 183721fffe3SKacheong Poon * nanoseconds (versus every 4 microseconds suggested by RFC 793, page 27); 184721fffe3SKacheong Poon * a per-connection component which grows by 125000 for every new connection; 185721fffe3SKacheong Poon * and an "extra" component that grows by a random amount centered 186721fffe3SKacheong Poon * approximately on 64000. This causes the ISS generator to cycle every 187721fffe3SKacheong Poon * 4.89 hours if no TCP connections are made, and faster if connections are 188721fffe3SKacheong Poon * made. 189721fffe3SKacheong Poon * 190721fffe3SKacheong Poon * When tcp_strong_iss is set to 0, ISS is calculated by adding two 191721fffe3SKacheong Poon * components: a time component which grows by 250000 every second; and 192721fffe3SKacheong Poon * a per-connection component which grows by 125000 for every new connections. 193721fffe3SKacheong Poon * 194721fffe3SKacheong Poon * A third method, when tcp_strong_iss is set to 2, for generating ISS is 195721fffe3SKacheong Poon * prescribed by Steve Bellovin. This involves adding time, the 125000 per 196721fffe3SKacheong Poon * connection, and a one-way hash (MD5) of the connection ID <sport, dport, 197721fffe3SKacheong Poon * src, dst>, a "truly" random (per RFC 1750) number, and a console-entered 198721fffe3SKacheong Poon * password. 199721fffe3SKacheong Poon */ 200721fffe3SKacheong Poon #define ISS_INCR 250000 201721fffe3SKacheong Poon #define ISS_NSEC_SHT 12 202721fffe3SKacheong Poon 203721fffe3SKacheong Poon /* Macros for timestamp comparisons */ 204721fffe3SKacheong Poon #define TSTMP_GEQ(a, b) ((int32_t)((a)-(b)) >= 0) 205721fffe3SKacheong Poon #define TSTMP_LT(a, b) ((int32_t)((a)-(b)) < 0) 206721fffe3SKacheong Poon 207721fffe3SKacheong Poon /* 208721fffe3SKacheong Poon * Initialize cwnd according to RFC 3390. def_max_init_cwnd is 209721fffe3SKacheong Poon * either tcp_slow_start_initial or tcp_slow_start_after idle 210721fffe3SKacheong Poon * depending on the caller. If the upper layer has not used the 211721fffe3SKacheong Poon * TCP_INIT_CWND option to change the initial cwnd, tcp_init_cwnd 212721fffe3SKacheong Poon * should be 0 and we use the formula in RFC 3390 to set tcp_cwnd. 213721fffe3SKacheong Poon * If the upper layer has changed set the tcp_init_cwnd, just use 214721fffe3SKacheong Poon * it to calculate the tcp_cwnd. 215e068a72aSTheo Schlossnagle * 216e068a72aSTheo Schlossnagle * "An Argument for Increasing TCP's Initial Congestion Window" 217e068a72aSTheo Schlossnagle * ACM SIGCOMM Computer Communications Review, vol. 40 (2010), pp. 27-33 218e068a72aSTheo Schlossnagle * -- Nandita Dukkipati, Tiziana Refice, Yuchung Cheng, 219e068a72aSTheo Schlossnagle * Hsiao-keng Jerry Chu, Tom Herbert, Amit Agarwal, 220e068a72aSTheo Schlossnagle * Arvind Jain, Natalia Sutin 221e068a72aSTheo Schlossnagle * 222e068a72aSTheo Schlossnagle * "Based on the results from our experiments, we believe the 223e068a72aSTheo Schlossnagle * initial congestion window should be at least ten segments 224e068a72aSTheo Schlossnagle * and the same be investigated for standardization by the IETF." 225e068a72aSTheo Schlossnagle * 226e068a72aSTheo Schlossnagle * As such, the def_max_init_cwnd argument with which this macro is 227e068a72aSTheo Schlossnagle * invoked is either the tcps_slow_start_initial or 228e068a72aSTheo Schlossnagle * tcps_slow_start_after_idle which both default to 0 and will respect 229e068a72aSTheo Schlossnagle * RFC 3390 exactly. If the tunables are explicitly set by the operator, 230e068a72aSTheo Schlossnagle * then the initial congestion window should be set as the operator 231e068a72aSTheo Schlossnagle * demands, within reason. We shall arbitrarily define reason as a 232e068a72aSTheo Schlossnagle * maximum of 16 (same as used by the TCP_INIT_CWND setsockopt). 233721fffe3SKacheong Poon */ 234e068a72aSTheo Schlossnagle 235e068a72aSTheo Schlossnagle /* Maximum TCP initial cwin (start/restart). */ 236e068a72aSTheo Schlossnagle #define TCP_MAX_INIT_CWND 16 237e068a72aSTheo Schlossnagle 238721fffe3SKacheong Poon #define TCP_SET_INIT_CWND(tcp, mss, def_max_init_cwnd) \ 239721fffe3SKacheong Poon { \ 240721fffe3SKacheong Poon if ((tcp)->tcp_init_cwnd == 0) { \ 241e068a72aSTheo Schlossnagle if (def_max_init_cwnd == 0) { \ 242e068a72aSTheo Schlossnagle (tcp)->tcp_cwnd = MIN(4 * (mss), \ 243e068a72aSTheo Schlossnagle MAX(2 * (mss), 4380 / (mss) * (mss))); \ 244e068a72aSTheo Schlossnagle } else { \ 245e068a72aSTheo Schlossnagle (tcp)->tcp_cwnd = MIN(TCP_MAX_INIT_CWND * (mss),\ 246e068a72aSTheo Schlossnagle def_max_init_cwnd * (mss)); \ 247e068a72aSTheo Schlossnagle } \ 248721fffe3SKacheong Poon } else { \ 249721fffe3SKacheong Poon (tcp)->tcp_cwnd = (tcp)->tcp_init_cwnd * (mss); \ 250721fffe3SKacheong Poon } \ 251721fffe3SKacheong Poon tcp->tcp_cwnd_cnt = 0; \ 252721fffe3SKacheong Poon } 253721fffe3SKacheong Poon 254721fffe3SKacheong Poon /* 255721fffe3SKacheong Poon * Set ECN capable transport (ECT) code point in IP header. 256721fffe3SKacheong Poon * 257721fffe3SKacheong Poon * Note that there are 2 ECT code points '01' and '10', which are called 258721fffe3SKacheong Poon * ECT(1) and ECT(0) respectively. Here we follow the original ECT code 259721fffe3SKacheong Poon * point ECT(0) for TCP as described in RFC 2481. 260721fffe3SKacheong Poon */ 261721fffe3SKacheong Poon #define TCP_SET_ECT(tcp, iph) \ 262721fffe3SKacheong Poon if ((tcp)->tcp_connp->conn_ipversion == IPV4_VERSION) { \ 263721fffe3SKacheong Poon /* We need to clear the code point first. */ \ 264721fffe3SKacheong Poon ((ipha_t *)(iph))->ipha_type_of_service &= 0xFC; \ 265721fffe3SKacheong Poon ((ipha_t *)(iph))->ipha_type_of_service |= IPH_ECN_ECT0; \ 266721fffe3SKacheong Poon } else { \ 267721fffe3SKacheong Poon ((ip6_t *)(iph))->ip6_vcf &= htonl(0xFFCFFFFF); \ 268721fffe3SKacheong Poon ((ip6_t *)(iph))->ip6_vcf |= htonl(IPH_ECN_ECT0 << 20); \ 269721fffe3SKacheong Poon } 270721fffe3SKacheong Poon 271721fffe3SKacheong Poon /* 272707e74bcSKacheong Poon * Set tcp_rto with boundary checking. 273707e74bcSKacheong Poon */ 274707e74bcSKacheong Poon #define TCP_SET_RTO(tcp, rto) \ 275707e74bcSKacheong Poon if ((rto) < (tcp)->tcp_rto_min) \ 276707e74bcSKacheong Poon (tcp)->tcp_rto = (tcp)->tcp_rto_min; \ 277707e74bcSKacheong Poon else if ((rto) > (tcp)->tcp_rto_max) \ 278707e74bcSKacheong Poon (tcp)->tcp_rto = (tcp)->tcp_rto_max; \ 279707e74bcSKacheong Poon else \ 280707e74bcSKacheong Poon (tcp)->tcp_rto = (rto); 281707e74bcSKacheong Poon 282707e74bcSKacheong Poon /* 283721fffe3SKacheong Poon * TCP options struct returned from tcp_parse_options. 284721fffe3SKacheong Poon */ 285721fffe3SKacheong Poon typedef struct tcp_opt_s { 286721fffe3SKacheong Poon uint32_t tcp_opt_mss; 287721fffe3SKacheong Poon uint32_t tcp_opt_wscale; 288721fffe3SKacheong Poon uint32_t tcp_opt_ts_val; 289721fffe3SKacheong Poon uint32_t tcp_opt_ts_ecr; 290721fffe3SKacheong Poon tcp_t *tcp; 291721fffe3SKacheong Poon } tcp_opt_t; 292721fffe3SKacheong Poon 293721fffe3SKacheong Poon /* 294*1f183ba0SLauri Tirkkonen * Flags returned from tcp_parse_options. 295*1f183ba0SLauri Tirkkonen */ 296*1f183ba0SLauri Tirkkonen #define TCP_OPT_MSS_PRESENT 1 297*1f183ba0SLauri Tirkkonen #define TCP_OPT_WSCALE_PRESENT 2 298*1f183ba0SLauri Tirkkonen #define TCP_OPT_TSTAMP_PRESENT 4 299*1f183ba0SLauri Tirkkonen #define TCP_OPT_SACK_OK_PRESENT 8 300*1f183ba0SLauri Tirkkonen #define TCP_OPT_SACK_PRESENT 16 301*1f183ba0SLauri Tirkkonen 302*1f183ba0SLauri Tirkkonen /* 303ff550d0eSmasputra * Write-side flow-control is implemented via the per instance STREAMS 304ff550d0eSmasputra * write-side Q by explicitly setting QFULL to stop the flow of mblk_t(s) 305ff550d0eSmasputra * and clearing QFULL and calling qbackenable() to restart the flow based 306ff550d0eSmasputra * on the number of TCP unsent bytes (i.e. those not on the wire waiting 307ff550d0eSmasputra * for a remote ACK). 308ff550d0eSmasputra * 309ff550d0eSmasputra * This is different than a standard STREAMS kmod which when using the 310ff550d0eSmasputra * STREAMS Q the framework would automatictly flow-control based on the 311ff550d0eSmasputra * defined hiwat/lowat values as mblk_t's are enqueued/dequeued. 312ff550d0eSmasputra * 313ff550d0eSmasputra * As of FireEngine TCP write-side flow-control needs to take into account 314ff550d0eSmasputra * both the unsent tcp_xmit list bytes but also any squeue_t enqueued bytes 315ff550d0eSmasputra * (i.e. from tcp_wput() -> tcp_output()). 316ff550d0eSmasputra * 317ff550d0eSmasputra * This is accomplished by adding a new tcp_t fields, tcp_squeue_bytes, to 318ff550d0eSmasputra * count the number of bytes enqueued by tcp_wput() and the number of bytes 319ff550d0eSmasputra * dequeued and processed by tcp_output(). 320ff550d0eSmasputra * 321ff550d0eSmasputra * So, the total number of bytes unsent is (squeue_bytes + unsent) with all 322ff550d0eSmasputra * flow-control uses of unsent replaced with the macro TCP_UNSENT_BYTES. 323ff550d0eSmasputra */ 324ff550d0eSmasputra extern void tcp_clrqfull(tcp_t *); 325ff550d0eSmasputra extern void tcp_setqfull(tcp_t *); 326ff550d0eSmasputra 327ff550d0eSmasputra #define TCP_UNSENT_BYTES(tcp) \ 328ff550d0eSmasputra ((tcp)->tcp_squeue_bytes + (tcp)->tcp_unsent) 329ff550d0eSmasputra 330721fffe3SKacheong Poon /* 331721fffe3SKacheong Poon * Linked list struct to store listener connection limit configuration per 332721fffe3SKacheong Poon * IP stack. The list is stored at tcps_listener_conf in tcp_stack_t. 333721fffe3SKacheong Poon * 334721fffe3SKacheong Poon * tl_port: the listener port of this limit configuration 335721fffe3SKacheong Poon * tl_ratio: the maximum amount of memory consumed by all concurrent TCP 336721fffe3SKacheong Poon * connections created by a listener does not exceed 1/tl_ratio 337721fffe3SKacheong Poon * of the total system memory. Note that this is only an 338721fffe3SKacheong Poon * approximation. 339721fffe3SKacheong Poon * tl_link: linked list struct 340721fffe3SKacheong Poon */ 341721fffe3SKacheong Poon typedef struct tcp_listener_s { 342721fffe3SKacheong Poon in_port_t tl_port; 343721fffe3SKacheong Poon uint32_t tl_ratio; 344721fffe3SKacheong Poon list_node_t tl_link; 345721fffe3SKacheong Poon } tcp_listener_t; 346721fffe3SKacheong Poon 347721fffe3SKacheong Poon /* 348721fffe3SKacheong Poon * If there is a limit set on the number of connections allowed per each 349721fffe3SKacheong Poon * listener, the following struct is used to store that counter. It keeps 350721fffe3SKacheong Poon * the number of TCP connection created by a listener. Note that this needs 351721fffe3SKacheong Poon * to be separated from the listener since the listener can go away before 352721fffe3SKacheong Poon * all the connections are gone. 353721fffe3SKacheong Poon * 354721fffe3SKacheong Poon * When the struct is allocated, tlc_cnt is set to 1. When a new connection 355721fffe3SKacheong Poon * is created by the listener, tlc_cnt is incremented by 1. When a connection 356721fffe3SKacheong Poon * created by the listener goes away, tlc_count is decremented by 1. When the 357721fffe3SKacheong Poon * listener itself goes away, tlc_cnt is decremented by one. The last 358721fffe3SKacheong Poon * connection (or the listener) which decrements tlc_cnt to zero frees the 359721fffe3SKacheong Poon * struct. 360721fffe3SKacheong Poon * 3615dd46ab5SKacheong Poon * tlc_max is the maximum number of concurrent TCP connections created from a 3625dd46ab5SKacheong Poon * listner. It is calculated when the tcp_listen_cnt_t is allocated. 363721fffe3SKacheong Poon * 364721fffe3SKacheong Poon * tlc_report_time stores the time when cmn_err() is called to report that the 365721fffe3SKacheong Poon * max has been exceeeded. Report is done at most once every 366721fffe3SKacheong Poon * TCP_TLC_REPORT_INTERVAL mins for a listener. 367721fffe3SKacheong Poon * 368721fffe3SKacheong Poon * tlc_drop stores the number of connection attempt dropped because the 369721fffe3SKacheong Poon * limit has reached. 370721fffe3SKacheong Poon */ 371721fffe3SKacheong Poon typedef struct tcp_listen_cnt_s { 372721fffe3SKacheong Poon uint32_t tlc_max; 373721fffe3SKacheong Poon uint32_t tlc_cnt; 374721fffe3SKacheong Poon int64_t tlc_report_time; 375721fffe3SKacheong Poon uint32_t tlc_drop; 376721fffe3SKacheong Poon } tcp_listen_cnt_t; 377721fffe3SKacheong Poon 378721fffe3SKacheong Poon #define TCP_TLC_REPORT_INTERVAL (30 * MINUTES) 379721fffe3SKacheong Poon 380721fffe3SKacheong Poon #define TCP_DECR_LISTEN_CNT(tcp) \ 381721fffe3SKacheong Poon { \ 382721fffe3SKacheong Poon ASSERT((tcp)->tcp_listen_cnt->tlc_cnt > 0); \ 3831a5e258fSJosef 'Jeff' Sipek if (atomic_dec_32_nv(&(tcp)->tcp_listen_cnt->tlc_cnt) == 0) \ 384721fffe3SKacheong Poon kmem_free((tcp)->tcp_listen_cnt, sizeof (tcp_listen_cnt_t)); \ 385721fffe3SKacheong Poon (tcp)->tcp_listen_cnt = NULL; \ 386721fffe3SKacheong Poon } 387721fffe3SKacheong Poon 388721fffe3SKacheong Poon /* Increment and decrement the number of connections in tcp_stack_t. */ 389721fffe3SKacheong Poon #define TCPS_CONN_INC(tcps) \ 390721fffe3SKacheong Poon atomic_inc_64( \ 391721fffe3SKacheong Poon (uint64_t *)&(tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_conn_cnt) 392721fffe3SKacheong Poon 393721fffe3SKacheong Poon #define TCPS_CONN_DEC(tcps) \ 394721fffe3SKacheong Poon atomic_dec_64( \ 395721fffe3SKacheong Poon (uint64_t *)&(tcps)->tcps_sc[CPU->cpu_seqid]->tcp_sc_conn_cnt) 396721fffe3SKacheong Poon 397721fffe3SKacheong Poon /* 398721fffe3SKacheong Poon * When the system is under memory pressure, stack variable tcps_reclaim is 399721fffe3SKacheong Poon * true, we shorten the connection timeout abort interval to tcp_early_abort 400721fffe3SKacheong Poon * seconds. Defined in tcp.c. 401721fffe3SKacheong Poon */ 402721fffe3SKacheong Poon extern uint32_t tcp_early_abort; 403721fffe3SKacheong Poon 404721fffe3SKacheong Poon /* 405721fffe3SKacheong Poon * To reach to an eager in Q0 which can be dropped due to an incoming 406721fffe3SKacheong Poon * new SYN request when Q0 is full, a new doubly linked list is 407721fffe3SKacheong Poon * introduced. This list allows to select an eager from Q0 in O(1) time. 408721fffe3SKacheong Poon * This is needed to avoid spending too much time walking through the 409721fffe3SKacheong Poon * long list of eagers in Q0 when tcp_drop_q0() is called. Each member of 410721fffe3SKacheong Poon * this new list has to be a member of Q0. 411721fffe3SKacheong Poon * This list is headed by listener's tcp_t. When the list is empty, 412721fffe3SKacheong Poon * both the pointers - tcp_eager_next_drop_q0 and tcp_eager_prev_drop_q0, 413721fffe3SKacheong Poon * of listener's tcp_t point to listener's tcp_t itself. 414721fffe3SKacheong Poon * 415721fffe3SKacheong Poon * Given an eager in Q0 and a listener, MAKE_DROPPABLE() puts the eager 416721fffe3SKacheong Poon * in the list. MAKE_UNDROPPABLE() takes the eager out of the list. 417721fffe3SKacheong Poon * These macros do not affect the eager's membership to Q0. 418721fffe3SKacheong Poon */ 419721fffe3SKacheong Poon #define MAKE_DROPPABLE(listener, eager) \ 420721fffe3SKacheong Poon if ((eager)->tcp_eager_next_drop_q0 == NULL) { \ 421721fffe3SKacheong Poon (listener)->tcp_eager_next_drop_q0->tcp_eager_prev_drop_q0\ 422721fffe3SKacheong Poon = (eager); \ 423721fffe3SKacheong Poon (eager)->tcp_eager_prev_drop_q0 = (listener); \ 424721fffe3SKacheong Poon (eager)->tcp_eager_next_drop_q0 = \ 425721fffe3SKacheong Poon (listener)->tcp_eager_next_drop_q0; \ 426721fffe3SKacheong Poon (listener)->tcp_eager_next_drop_q0 = (eager); \ 427721fffe3SKacheong Poon } 428721fffe3SKacheong Poon 429721fffe3SKacheong Poon #define MAKE_UNDROPPABLE(eager) \ 430721fffe3SKacheong Poon if ((eager)->tcp_eager_next_drop_q0 != NULL) { \ 431721fffe3SKacheong Poon (eager)->tcp_eager_next_drop_q0->tcp_eager_prev_drop_q0 \ 432721fffe3SKacheong Poon = (eager)->tcp_eager_prev_drop_q0; \ 433721fffe3SKacheong Poon (eager)->tcp_eager_prev_drop_q0->tcp_eager_next_drop_q0 \ 434721fffe3SKacheong Poon = (eager)->tcp_eager_next_drop_q0; \ 435721fffe3SKacheong Poon (eager)->tcp_eager_prev_drop_q0 = NULL; \ 436721fffe3SKacheong Poon (eager)->tcp_eager_next_drop_q0 = NULL; \ 437721fffe3SKacheong Poon } 438721fffe3SKacheong Poon 439721fffe3SKacheong Poon /* 440721fffe3SKacheong Poon * The format argument to pass to tcp_display(). 441721fffe3SKacheong Poon * DISP_PORT_ONLY means that the returned string has only port info. 442721fffe3SKacheong Poon * DISP_ADDR_AND_PORT means that the returned string also contains the 443721fffe3SKacheong Poon * remote and local IP address. 444721fffe3SKacheong Poon */ 445721fffe3SKacheong Poon #define DISP_PORT_ONLY 1 446721fffe3SKacheong Poon #define DISP_ADDR_AND_PORT 2 447721fffe3SKacheong Poon 448721fffe3SKacheong Poon #define IP_ADDR_CACHE_SIZE 2048 449721fffe3SKacheong Poon #define IP_ADDR_CACHE_HASH(faddr) \ 450721fffe3SKacheong Poon (ntohl(faddr) & (IP_ADDR_CACHE_SIZE -1)) 451721fffe3SKacheong Poon 452721fffe3SKacheong Poon /* 453721fffe3SKacheong Poon * TCP reassembly macros. We hide starting and ending sequence numbers in 454721fffe3SKacheong Poon * b_next and b_prev of messages on the reassembly queue. The messages are 455721fffe3SKacheong Poon * chained using b_cont. These macros are used in tcp_reass() so we don't 456721fffe3SKacheong Poon * have to see the ugly casts and assignments. 457721fffe3SKacheong Poon */ 458721fffe3SKacheong Poon #define TCP_REASS_SEQ(mp) ((uint32_t)(uintptr_t)((mp)->b_next)) 459721fffe3SKacheong Poon #define TCP_REASS_SET_SEQ(mp, u) ((mp)->b_next = \ 460721fffe3SKacheong Poon (mblk_t *)(uintptr_t)(u)) 461721fffe3SKacheong Poon #define TCP_REASS_END(mp) ((uint32_t)(uintptr_t)((mp)->b_prev)) 462721fffe3SKacheong Poon #define TCP_REASS_SET_END(mp, u) ((mp)->b_prev = \ 463721fffe3SKacheong Poon (mblk_t *)(uintptr_t)(u)) 464721fffe3SKacheong Poon 4656e91bba0SGirish Moodalbail #define tcps_time_wait_interval tcps_propinfo_tbl[0].prop_cur_uval 4666e91bba0SGirish Moodalbail #define tcps_conn_req_max_q tcps_propinfo_tbl[1].prop_cur_uval 4676e91bba0SGirish Moodalbail #define tcps_conn_req_max_q0 tcps_propinfo_tbl[2].prop_cur_uval 4686e91bba0SGirish Moodalbail #define tcps_conn_req_min tcps_propinfo_tbl[3].prop_cur_uval 4696e91bba0SGirish Moodalbail #define tcps_conn_grace_period tcps_propinfo_tbl[4].prop_cur_uval 4706e91bba0SGirish Moodalbail #define tcps_cwnd_max_ tcps_propinfo_tbl[5].prop_cur_uval 4716e91bba0SGirish Moodalbail #define tcps_dbg tcps_propinfo_tbl[6].prop_cur_uval 4726e91bba0SGirish Moodalbail #define tcps_smallest_nonpriv_port tcps_propinfo_tbl[7].prop_cur_uval 4736e91bba0SGirish Moodalbail #define tcps_ip_abort_cinterval tcps_propinfo_tbl[8].prop_cur_uval 4746e91bba0SGirish Moodalbail #define tcps_ip_abort_linterval tcps_propinfo_tbl[9].prop_cur_uval 4756e91bba0SGirish Moodalbail #define tcps_ip_abort_interval tcps_propinfo_tbl[10].prop_cur_uval 4766e91bba0SGirish Moodalbail #define tcps_ip_notify_cinterval tcps_propinfo_tbl[11].prop_cur_uval 4776e91bba0SGirish Moodalbail #define tcps_ip_notify_interval tcps_propinfo_tbl[12].prop_cur_uval 4786e91bba0SGirish Moodalbail #define tcps_ipv4_ttl tcps_propinfo_tbl[13].prop_cur_uval 4796e91bba0SGirish Moodalbail #define tcps_keepalive_interval_high tcps_propinfo_tbl[14].prop_max_uval 4806e91bba0SGirish Moodalbail #define tcps_keepalive_interval tcps_propinfo_tbl[14].prop_cur_uval 4816e91bba0SGirish Moodalbail #define tcps_keepalive_interval_low tcps_propinfo_tbl[14].prop_min_uval 4826e91bba0SGirish Moodalbail #define tcps_maxpsz_multiplier tcps_propinfo_tbl[15].prop_cur_uval 4836e91bba0SGirish Moodalbail #define tcps_mss_def_ipv4 tcps_propinfo_tbl[16].prop_cur_uval 4846e91bba0SGirish Moodalbail #define tcps_mss_max_ipv4 tcps_propinfo_tbl[17].prop_cur_uval 4856e91bba0SGirish Moodalbail #define tcps_mss_min tcps_propinfo_tbl[18].prop_cur_uval 4866e91bba0SGirish Moodalbail #define tcps_naglim_def tcps_propinfo_tbl[19].prop_cur_uval 487707e74bcSKacheong Poon #define tcps_rexmit_interval_initial_high \ 488707e74bcSKacheong Poon tcps_propinfo_tbl[20].prop_max_uval 4896e91bba0SGirish Moodalbail #define tcps_rexmit_interval_initial tcps_propinfo_tbl[20].prop_cur_uval 490707e74bcSKacheong Poon #define tcps_rexmit_interval_initial_low \ 491707e74bcSKacheong Poon tcps_propinfo_tbl[20].prop_min_uval 492707e74bcSKacheong Poon #define tcps_rexmit_interval_max_high tcps_propinfo_tbl[21].prop_max_uval 4936e91bba0SGirish Moodalbail #define tcps_rexmit_interval_max tcps_propinfo_tbl[21].prop_cur_uval 494707e74bcSKacheong Poon #define tcps_rexmit_interval_max_low tcps_propinfo_tbl[21].prop_min_uval 495707e74bcSKacheong Poon #define tcps_rexmit_interval_min_high tcps_propinfo_tbl[22].prop_max_uval 4966e91bba0SGirish Moodalbail #define tcps_rexmit_interval_min tcps_propinfo_tbl[22].prop_cur_uval 497707e74bcSKacheong Poon #define tcps_rexmit_interval_min_low tcps_propinfo_tbl[22].prop_min_uval 4986e91bba0SGirish Moodalbail #define tcps_deferred_ack_interval tcps_propinfo_tbl[23].prop_cur_uval 4996e91bba0SGirish Moodalbail #define tcps_snd_lowat_fraction tcps_propinfo_tbl[24].prop_cur_uval 5006e91bba0SGirish Moodalbail #define tcps_dupack_fast_retransmit tcps_propinfo_tbl[25].prop_cur_uval 5016e91bba0SGirish Moodalbail #define tcps_ignore_path_mtu tcps_propinfo_tbl[26].prop_cur_bval 5026e91bba0SGirish Moodalbail #define tcps_smallest_anon_port tcps_propinfo_tbl[27].prop_cur_uval 5036e91bba0SGirish Moodalbail #define tcps_largest_anon_port tcps_propinfo_tbl[28].prop_cur_uval 5046e91bba0SGirish Moodalbail #define tcps_xmit_hiwat tcps_propinfo_tbl[29].prop_cur_uval 5056e91bba0SGirish Moodalbail #define tcps_xmit_lowat tcps_propinfo_tbl[30].prop_cur_uval 5066e91bba0SGirish Moodalbail #define tcps_recv_hiwat tcps_propinfo_tbl[31].prop_cur_uval 5076e91bba0SGirish Moodalbail #define tcps_recv_hiwat_minmss tcps_propinfo_tbl[32].prop_cur_uval 508707e74bcSKacheong Poon #define tcps_fin_wait_2_flush_interval_high \ 509707e74bcSKacheong Poon tcps_propinfo_tbl[33].prop_max_uval 5106e91bba0SGirish Moodalbail #define tcps_fin_wait_2_flush_interval tcps_propinfo_tbl[33].prop_cur_uval 511707e74bcSKacheong Poon #define tcps_fin_wait_2_flush_interval_low \ 512707e74bcSKacheong Poon tcps_propinfo_tbl[33].prop_min_uval 5136e91bba0SGirish Moodalbail #define tcps_max_buf tcps_propinfo_tbl[34].prop_cur_uval 5146e91bba0SGirish Moodalbail #define tcps_strong_iss tcps_propinfo_tbl[35].prop_cur_uval 5156e91bba0SGirish Moodalbail #define tcps_rtt_updates tcps_propinfo_tbl[36].prop_cur_uval 5166e91bba0SGirish Moodalbail #define tcps_wscale_always tcps_propinfo_tbl[37].prop_cur_bval 5176e91bba0SGirish Moodalbail #define tcps_tstamp_always tcps_propinfo_tbl[38].prop_cur_bval 5186e91bba0SGirish Moodalbail #define tcps_tstamp_if_wscale tcps_propinfo_tbl[39].prop_cur_bval 5196e91bba0SGirish Moodalbail #define tcps_rexmit_interval_extra tcps_propinfo_tbl[40].prop_cur_uval 5206e91bba0SGirish Moodalbail #define tcps_deferred_acks_max tcps_propinfo_tbl[41].prop_cur_uval 5216e91bba0SGirish Moodalbail #define tcps_slow_start_after_idle tcps_propinfo_tbl[42].prop_cur_uval 5226e91bba0SGirish Moodalbail #define tcps_slow_start_initial tcps_propinfo_tbl[43].prop_cur_uval 5236e91bba0SGirish Moodalbail #define tcps_sack_permitted tcps_propinfo_tbl[44].prop_cur_uval 5246e91bba0SGirish Moodalbail #define tcps_ipv6_hoplimit tcps_propinfo_tbl[45].prop_cur_uval 5256e91bba0SGirish Moodalbail #define tcps_mss_def_ipv6 tcps_propinfo_tbl[46].prop_cur_uval 5266e91bba0SGirish Moodalbail #define tcps_mss_max_ipv6 tcps_propinfo_tbl[47].prop_cur_uval 5276e91bba0SGirish Moodalbail #define tcps_rev_src_routes tcps_propinfo_tbl[48].prop_cur_bval 5286e91bba0SGirish Moodalbail #define tcps_local_dack_interval tcps_propinfo_tbl[49].prop_cur_uval 5296e91bba0SGirish Moodalbail #define tcps_local_dacks_max tcps_propinfo_tbl[50].prop_cur_uval 5306e91bba0SGirish Moodalbail #define tcps_ecn_permitted tcps_propinfo_tbl[51].prop_cur_uval 5316e91bba0SGirish Moodalbail #define tcps_rst_sent_rate_enabled tcps_propinfo_tbl[52].prop_cur_bval 5326e91bba0SGirish Moodalbail #define tcps_rst_sent_rate tcps_propinfo_tbl[53].prop_cur_uval 5336e91bba0SGirish Moodalbail #define tcps_push_timer_interval tcps_propinfo_tbl[54].prop_cur_uval 5346e91bba0SGirish Moodalbail #define tcps_use_smss_as_mss_opt tcps_propinfo_tbl[55].prop_cur_bval 5356e91bba0SGirish Moodalbail #define tcps_keepalive_abort_interval_high \ 5366e91bba0SGirish Moodalbail tcps_propinfo_tbl[56].prop_max_uval 5376e91bba0SGirish Moodalbail #define tcps_keepalive_abort_interval \ 5386e91bba0SGirish Moodalbail tcps_propinfo_tbl[56].prop_cur_uval 5396e91bba0SGirish Moodalbail #define tcps_keepalive_abort_interval_low \ 5406e91bba0SGirish Moodalbail tcps_propinfo_tbl[56].prop_min_uval 5416e91bba0SGirish Moodalbail #define tcps_wroff_xtra tcps_propinfo_tbl[57].prop_cur_uval 5426e91bba0SGirish Moodalbail #define tcps_dev_flow_ctl tcps_propinfo_tbl[58].prop_cur_bval 5436e91bba0SGirish Moodalbail #define tcps_reass_timeout tcps_propinfo_tbl[59].prop_cur_uval 544c0e6663fSJerry Jelinek #define tcps_iss_incr tcps_propinfo_tbl[65].prop_cur_uval 545721fffe3SKacheong Poon 5467b8f5432SAnders Persson extern struct qinit tcp_rinitv4, tcp_rinitv6; 547ff550d0eSmasputra extern boolean_t do_tcp_fusion; 548ff550d0eSmasputra 549fc80c0dfSnordmark /* 550fc80c0dfSnordmark * Object to represent database of options to search passed to 551fc80c0dfSnordmark * {sock,tpi}optcom_req() interface routine to take care of option 552fc80c0dfSnordmark * management and associated methods. 553fc80c0dfSnordmark */ 554fc80c0dfSnordmark extern optdb_obj_t tcp_opt_obj; 555fc80c0dfSnordmark extern uint_t tcp_max_optsize; 556fc80c0dfSnordmark 557721fffe3SKacheong Poon extern int tcp_squeue_flag; 558721fffe3SKacheong Poon 559721fffe3SKacheong Poon extern uint_t tcp_free_list_max_cnt; 560721fffe3SKacheong Poon 561721fffe3SKacheong Poon /* 562721fffe3SKacheong Poon * Functions in tcp.c. 563721fffe3SKacheong Poon */ 564721fffe3SKacheong Poon extern void tcp_acceptor_hash_insert(t_uscalar_t, tcp_t *); 565721fffe3SKacheong Poon extern tcp_t *tcp_acceptor_hash_lookup(t_uscalar_t, tcp_stack_t *); 566721fffe3SKacheong Poon extern void tcp_acceptor_hash_remove(tcp_t *); 567721fffe3SKacheong Poon extern mblk_t *tcp_ack_mp(tcp_t *); 568721fffe3SKacheong Poon extern int tcp_build_hdrs(tcp_t *); 569721fffe3SKacheong Poon extern void tcp_cleanup(tcp_t *); 570721fffe3SKacheong Poon extern int tcp_clean_death(tcp_t *, int); 571721fffe3SKacheong Poon extern void tcp_clean_death_wrapper(void *, mblk_t *, void *, 572721fffe3SKacheong Poon ip_recv_attr_t *); 573721fffe3SKacheong Poon extern void tcp_close_common(conn_t *, int); 574721fffe3SKacheong Poon extern void tcp_close_detached(tcp_t *); 575721fffe3SKacheong Poon extern void tcp_close_mpp(mblk_t **); 576721fffe3SKacheong Poon extern void tcp_closei_local(tcp_t *); 5770f1702c5SYu Xiangning extern sock_lower_handle_t tcp_create(int, int, int, sock_downcalls_t **, 5780f1702c5SYu Xiangning uint_t *, int *, int, cred_t *); 579721fffe3SKacheong Poon extern conn_t *tcp_create_common(cred_t *, boolean_t, boolean_t, int *); 580721fffe3SKacheong Poon extern void tcp_disconnect(tcp_t *, mblk_t *); 581721fffe3SKacheong Poon extern char *tcp_display(tcp_t *, char *, char); 582721fffe3SKacheong Poon extern int tcp_do_bind(conn_t *, struct sockaddr *, socklen_t, cred_t *, 583721fffe3SKacheong Poon boolean_t); 584721fffe3SKacheong Poon extern int tcp_do_connect(conn_t *, const struct sockaddr *, socklen_t, 585721fffe3SKacheong Poon cred_t *, pid_t); 586721fffe3SKacheong Poon extern int tcp_do_listen(conn_t *, struct sockaddr *, socklen_t, int, 587721fffe3SKacheong Poon cred_t *, boolean_t); 588721fffe3SKacheong Poon extern int tcp_do_unbind(conn_t *); 589721fffe3SKacheong Poon extern boolean_t tcp_eager_blowoff(tcp_t *, t_scalar_t); 590721fffe3SKacheong Poon extern void tcp_eager_cleanup(tcp_t *, boolean_t); 591721fffe3SKacheong Poon extern void tcp_eager_kill(void *, mblk_t *, void *, ip_recv_attr_t *); 592721fffe3SKacheong Poon extern void tcp_eager_unlink(tcp_t *); 593707e74bcSKacheong Poon extern void tcp_init_values(tcp_t *, tcp_t *); 594721fffe3SKacheong Poon extern void tcp_ipsec_cleanup(tcp_t *); 595721fffe3SKacheong Poon extern int tcp_maxpsz_set(tcp_t *, boolean_t); 596721fffe3SKacheong Poon extern void tcp_mss_set(tcp_t *, uint32_t); 597721fffe3SKacheong Poon extern void tcp_reinput(conn_t *, mblk_t *, ip_recv_attr_t *, ip_stack_t *); 598721fffe3SKacheong Poon extern void tcp_rsrv(queue_t *); 599721fffe3SKacheong Poon extern uint_t tcp_rwnd_reopen(tcp_t *); 600721fffe3SKacheong Poon extern int tcp_rwnd_set(tcp_t *, uint32_t); 601721fffe3SKacheong Poon extern int tcp_set_destination(tcp_t *); 602721fffe3SKacheong Poon extern void tcp_set_ws_value(tcp_t *); 603721fffe3SKacheong Poon extern void tcp_stop_lingering(tcp_t *); 604721fffe3SKacheong Poon extern void tcp_update_pmtu(tcp_t *, boolean_t); 605721fffe3SKacheong Poon extern mblk_t *tcp_zcopy_backoff(tcp_t *, mblk_t *, boolean_t); 606721fffe3SKacheong Poon extern boolean_t tcp_zcopy_check(tcp_t *); 607721fffe3SKacheong Poon extern void tcp_zcopy_notify(tcp_t *); 6083e95bd4aSAnders Persson extern void tcp_get_proto_props(tcp_t *, struct sock_proto_props *); 609721fffe3SKacheong Poon 610721fffe3SKacheong Poon /* 611721fffe3SKacheong Poon * Bind related functions in tcp_bind.c 612721fffe3SKacheong Poon */ 613721fffe3SKacheong Poon extern int tcp_bind_check(conn_t *, struct sockaddr *, socklen_t, 614721fffe3SKacheong Poon cred_t *, boolean_t); 615721fffe3SKacheong Poon extern void tcp_bind_hash_insert(tf_t *, tcp_t *, int); 616721fffe3SKacheong Poon extern void tcp_bind_hash_remove(tcp_t *); 617721fffe3SKacheong Poon extern in_port_t tcp_bindi(tcp_t *, in_port_t, const in6_addr_t *, 618721fffe3SKacheong Poon int, boolean_t, boolean_t, boolean_t); 619721fffe3SKacheong Poon extern in_port_t tcp_update_next_port(in_port_t, const tcp_t *, 620721fffe3SKacheong Poon boolean_t); 621721fffe3SKacheong Poon 622721fffe3SKacheong Poon /* 623721fffe3SKacheong Poon * Fusion related functions in tcp_fusion.c. 624721fffe3SKacheong Poon */ 625721fffe3SKacheong Poon extern void tcp_fuse(tcp_t *, uchar_t *, tcpha_t *); 626721fffe3SKacheong Poon extern void tcp_unfuse(tcp_t *); 627721fffe3SKacheong Poon extern boolean_t tcp_fuse_output(tcp_t *, mblk_t *, uint32_t); 628721fffe3SKacheong Poon extern void tcp_fuse_output_urg(tcp_t *, mblk_t *); 629721fffe3SKacheong Poon extern boolean_t tcp_fuse_rcv_drain(queue_t *, tcp_t *, mblk_t **); 630721fffe3SKacheong Poon extern size_t tcp_fuse_set_rcv_hiwat(tcp_t *, size_t); 631721fffe3SKacheong Poon extern int tcp_fuse_maxpsz(tcp_t *); 632721fffe3SKacheong Poon extern void tcp_fuse_backenable(tcp_t *); 6336e91bba0SGirish Moodalbail extern void tcp_iss_key_init(uint8_t *, int, tcp_stack_t *); 634721fffe3SKacheong Poon 635721fffe3SKacheong Poon /* 636721fffe3SKacheong Poon * Output related functions in tcp_output.c. 637721fffe3SKacheong Poon */ 638721fffe3SKacheong Poon extern void tcp_close_output(void *, mblk_t *, void *, ip_recv_attr_t *); 639721fffe3SKacheong Poon extern void tcp_output(void *, mblk_t *, void *, ip_recv_attr_t *); 640721fffe3SKacheong Poon extern void tcp_output_urgent(void *, mblk_t *, void *, ip_recv_attr_t *); 641721fffe3SKacheong Poon extern void tcp_rexmit_after_error(tcp_t *); 642721fffe3SKacheong Poon extern void tcp_sack_rexmit(tcp_t *, uint_t *); 643721fffe3SKacheong Poon extern void tcp_send_data(tcp_t *, mblk_t *); 644721fffe3SKacheong Poon extern void tcp_send_synack(void *, mblk_t *, void *, ip_recv_attr_t *); 645721fffe3SKacheong Poon extern void tcp_shutdown_output(void *, mblk_t *, void *, ip_recv_attr_t *); 646721fffe3SKacheong Poon extern void tcp_ss_rexmit(tcp_t *); 647721fffe3SKacheong Poon extern void tcp_update_xmit_tail(tcp_t *, uint32_t); 648721fffe3SKacheong Poon extern void tcp_wput(queue_t *, mblk_t *); 649721fffe3SKacheong Poon extern void tcp_wput_data(tcp_t *, mblk_t *, boolean_t); 650721fffe3SKacheong Poon extern void tcp_wput_sock(queue_t *, mblk_t *); 651721fffe3SKacheong Poon extern void tcp_wput_fallback(queue_t *, mblk_t *); 652721fffe3SKacheong Poon extern void tcp_xmit_ctl(char *, tcp_t *, uint32_t, uint32_t, int); 653721fffe3SKacheong Poon extern void tcp_xmit_listeners_reset(mblk_t *, ip_recv_attr_t *, 654721fffe3SKacheong Poon ip_stack_t *i, conn_t *); 655721fffe3SKacheong Poon extern mblk_t *tcp_xmit_mp(tcp_t *, mblk_t *, int32_t, int32_t *, 656721fffe3SKacheong Poon mblk_t **, uint32_t, boolean_t, uint32_t *, boolean_t); 657721fffe3SKacheong Poon 658721fffe3SKacheong Poon /* 659721fffe3SKacheong Poon * Input related functions in tcp_input.c. 660721fffe3SKacheong Poon */ 661721fffe3SKacheong Poon extern void tcp_icmp_input(void *, mblk_t *, void *, ip_recv_attr_t *); 662721fffe3SKacheong Poon extern void tcp_input_data(void *, mblk_t *, void *, ip_recv_attr_t *); 663721fffe3SKacheong Poon extern void tcp_input_listener_unbound(void *, mblk_t *, void *, 664721fffe3SKacheong Poon ip_recv_attr_t *); 665*1f183ba0SLauri Tirkkonen extern boolean_t tcp_paws_check(tcp_t *, const tcp_opt_t *); 666*1f183ba0SLauri Tirkkonen extern int tcp_parse_options(tcpha_t *, tcp_opt_t *); 667721fffe3SKacheong Poon extern uint_t tcp_rcv_drain(tcp_t *); 668721fffe3SKacheong Poon extern void tcp_rcv_enqueue(tcp_t *, mblk_t *, uint_t, cred_t *); 669721fffe3SKacheong Poon extern boolean_t tcp_verifyicmp(conn_t *, void *, icmph_t *, icmp6_t *, 670721fffe3SKacheong Poon ip_recv_attr_t *); 671721fffe3SKacheong Poon 672721fffe3SKacheong Poon /* 673721fffe3SKacheong Poon * Kernel socket related functions in tcp_socket.c. 674721fffe3SKacheong Poon */ 67541174437SAnders Persson extern int tcp_fallback(sock_lower_handle_t, queue_t *, boolean_t, 6763e95bd4aSAnders Persson so_proto_quiesced_cb_t, sock_quiesce_arg_t *); 6773e95bd4aSAnders Persson extern boolean_t tcp_newconn_notify(tcp_t *, ip_recv_attr_t *); 6780f1702c5SYu Xiangning 679721fffe3SKacheong Poon /* 680721fffe3SKacheong Poon * Timer related functions in tcp_timers.c. 681721fffe3SKacheong Poon */ 682721fffe3SKacheong Poon extern void tcp_ack_timer(void *); 683721fffe3SKacheong Poon extern void tcp_close_linger_timeout(void *); 684721fffe3SKacheong Poon extern void tcp_keepalive_timer(void *); 685721fffe3SKacheong Poon extern void tcp_push_timer(void *); 686721fffe3SKacheong Poon extern void tcp_reass_timer(void *); 687721fffe3SKacheong Poon extern mblk_t *tcp_timermp_alloc(int); 688721fffe3SKacheong Poon extern void tcp_timermp_free(tcp_t *); 68966cd0f60SKacheong Poon extern timeout_id_t tcp_timeout(conn_t *, void (*)(void *), hrtime_t); 690721fffe3SKacheong Poon extern clock_t tcp_timeout_cancel(conn_t *, timeout_id_t); 691721fffe3SKacheong Poon extern void tcp_timer(void *arg); 692721fffe3SKacheong Poon extern void tcp_timers_stop(tcp_t *); 6930f1702c5SYu Xiangning 694721fffe3SKacheong Poon /* 695721fffe3SKacheong Poon * TCP TPI related functions in tcp_tpi.c. 696721fffe3SKacheong Poon */ 697721fffe3SKacheong Poon extern void tcp_addr_req(tcp_t *, mblk_t *); 698721fffe3SKacheong Poon extern void tcp_capability_req(tcp_t *, mblk_t *); 699721fffe3SKacheong Poon extern boolean_t tcp_conn_con(tcp_t *, uchar_t *, mblk_t *, 700721fffe3SKacheong Poon mblk_t **, ip_recv_attr_t *); 701721fffe3SKacheong Poon extern void tcp_err_ack(tcp_t *, mblk_t *, int, int); 702721fffe3SKacheong Poon extern void tcp_err_ack_prim(tcp_t *, mblk_t *, int, int, int); 703721fffe3SKacheong Poon extern void tcp_info_req(tcp_t *, mblk_t *); 704721fffe3SKacheong Poon extern void tcp_send_conn_ind(void *, mblk_t *, void *); 705721fffe3SKacheong Poon extern void tcp_send_pending(void *, mblk_t *, void *, ip_recv_attr_t *); 706721fffe3SKacheong Poon extern void tcp_tpi_accept(queue_t *, mblk_t *); 707721fffe3SKacheong Poon extern void tcp_tpi_bind(tcp_t *, mblk_t *); 708721fffe3SKacheong Poon extern int tcp_tpi_close(queue_t *, int); 709721fffe3SKacheong Poon extern int tcp_tpi_close_accept(queue_t *); 710721fffe3SKacheong Poon extern void tcp_tpi_connect(tcp_t *, mblk_t *); 711bd670b35SErik Nordmark extern int tcp_tpi_opt_get(queue_t *, t_scalar_t, t_scalar_t, uchar_t *); 712bd670b35SErik Nordmark extern int tcp_tpi_opt_set(queue_t *, uint_t, int, int, uint_t, uchar_t *, 713bd670b35SErik Nordmark uint_t *, uchar_t *, void *, cred_t *); 714721fffe3SKacheong Poon extern void tcp_tpi_unbind(tcp_t *, mblk_t *); 715721fffe3SKacheong Poon extern void tcp_tli_accept(tcp_t *, mblk_t *); 716721fffe3SKacheong Poon extern void tcp_use_pure_tpi(tcp_t *); 7173e95bd4aSAnders Persson extern void tcp_do_capability_ack(tcp_t *, struct T_capability_ack *, 7183e95bd4aSAnders Persson t_uscalar_t); 719721fffe3SKacheong Poon 720721fffe3SKacheong Poon /* 721721fffe3SKacheong Poon * TCP option processing related functions in tcp_opt_data.c 722721fffe3SKacheong Poon */ 723721fffe3SKacheong Poon extern int tcp_opt_get(conn_t *, int, int, uchar_t *); 724721fffe3SKacheong Poon extern int tcp_opt_set(conn_t *, uint_t, int, int, uint_t, uchar_t *, 725721fffe3SKacheong Poon uint_t *, uchar_t *, void *, cred_t *); 726721fffe3SKacheong Poon 727721fffe3SKacheong Poon /* 728721fffe3SKacheong Poon * TCP time wait processing related functions in tcp_time_wait.c. 729721fffe3SKacheong Poon */ 730721fffe3SKacheong Poon extern void tcp_time_wait_append(tcp_t *); 731721fffe3SKacheong Poon extern void tcp_time_wait_collector(void *); 732721fffe3SKacheong Poon extern boolean_t tcp_time_wait_remove(tcp_t *, tcp_squeue_priv_t *); 733721fffe3SKacheong Poon extern void tcp_time_wait_processing(tcp_t *, mblk_t *, uint32_t, 734721fffe3SKacheong Poon uint32_t, int, tcpha_t *, ip_recv_attr_t *); 735721fffe3SKacheong Poon 736721fffe3SKacheong Poon /* 737721fffe3SKacheong Poon * Misc functions in tcp_misc.c. 738721fffe3SKacheong Poon */ 739721fffe3SKacheong Poon extern uint32_t tcp_find_listener_conf(tcp_stack_t *, in_port_t); 7405dd46ab5SKacheong Poon extern void tcp_ioctl_abort_conn(queue_t *, mblk_t *); 741721fffe3SKacheong Poon extern void tcp_listener_conf_cleanup(tcp_stack_t *); 7425dd46ab5SKacheong Poon extern void tcp_stack_cpu_add(tcp_stack_t *, processorid_t); 743bd670b35SErik Nordmark 744ff550d0eSmasputra #endif /* _KERNEL */ 745ff550d0eSmasputra 746ff550d0eSmasputra #ifdef __cplusplus 747ff550d0eSmasputra } 748ff550d0eSmasputra #endif 749ff550d0eSmasputra 750ff550d0eSmasputra #endif /* _INET_TCP_IMPL_H */ 751