Print this page
3942 inject sanity into ipadm tcp buffer size properties
3943 _snd_lowat_fraction tcp tunable has no effect
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Peng Dai <peng.dai@delphix.com>


   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2011, Joyent Inc. All rights reserved.
  24  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.

  25  */
  26 /* Copyright (c) 1990 Mentat Inc. */
  27 
  28 #include <inet/ip.h>
  29 #include <inet/tcp_impl.h>
  30 #include <sys/multidata.h>
  31 #include <sys/sunddi.h>
  32 
  33 /* Max size IP datagram is 64k - 1 */
  34 #define TCP_MSS_MAX_IPV4 (IP_MAXPACKET - (sizeof (ipha_t) + sizeof (tcpha_t)))
  35 #define TCP_MSS_MAX_IPV6 (IP_MAXPACKET - (sizeof (ip6_t) + sizeof (tcpha_t)))
  36 
  37 /* Max of the above */
  38 #define TCP_MSS_MAX             TCP_MSS_MAX_IPV4
  39 
  40 #define TCP_XMIT_LOWATER        4096
  41 #define TCP_XMIT_HIWATER        49152
  42 #define TCP_RECV_LOWATER        2048
  43 #define TCP_RECV_HIWATER        128000
  44 
  45 /*
  46  * Set the RFC 1948 pass phrase
  47  */
  48 /* ARGSUSED */
  49 static int
  50 tcp_set_1948phrase(void *cbarg,  cred_t *cr, mod_prop_info_t *pinfo,
  51     const char *ifname, const void* pr_val, uint_t flags)
  52 {
  53         tcp_stack_t     *tcps = (tcp_stack_t *)cbarg;
  54 
  55         if (flags & MOD_PROP_DEFAULT)
  56                 return (ENOTSUP);
  57 
  58         /*
  59          * Basically, value contains a new pass phrase.  Pass it along!
  60          */
  61         tcp_iss_key_init((uint8_t *)pr_val, strlen(pr_val), tcps);

  62         return (0);
  63 }
  64 
  65 /*
  66  * returns the current list of listener limit configuration.
  67  */
  68 /* ARGSUSED */
  69 static int
  70 tcp_listener_conf_get(void *cbarg, mod_prop_info_t *pinfo, const char *ifname,
  71     void *val, uint_t psize, uint_t flags)
  72 {
  73         tcp_stack_t     *tcps = (tcp_stack_t *)cbarg;
  74         tcp_listener_t  *tl;
  75         char            *pval = val;
  76         size_t          nbytes = 0, tbytes = 0;
  77         uint_t          size;
  78         int             err = 0;
  79 
  80         bzero(pval, psize);
  81         size = psize;
  82 
  83         if (flags & (MOD_PROP_DEFAULT|MOD_PROP_PERM|MOD_PROP_POSSIBLE))
  84                 return (0);
  85 
  86         mutex_enter(&tcps->tcps_listener_conf_lock);
  87         for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL;
  88             tl = list_next(&tcps->tcps_listener_conf, tl)) {
  89                 if (psize == size)
  90                         nbytes = snprintf(pval, size, "%d:%d",  tl->tl_port,
  91                             tl->tl_ratio);
  92                 else
  93                         nbytes = snprintf(pval, size, ",%d:%d",  tl->tl_port,
  94                             tl->tl_ratio);
  95                 size -= nbytes;
  96                 pval += nbytes;
  97                 tbytes += nbytes;
  98                 if (tbytes >= psize) {
  99                         /* Buffer overflow, stop copying information */
 100                         err = ENOBUFS;
 101                         break;
 102                 }
 103         }
 104 
 105         mutex_exit(&tcps->tcps_listener_conf_lock);
 106         return (err);
 107 }
 108 
 109 /*
 110  * add a new listener limit configuration.
 111  */
 112 /* ARGSUSED */
 113 static int
 114 tcp_listener_conf_add(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
 115     const char *ifname, const void* pval, uint_t flags)
 116 {
 117         tcp_listener_t  *new_tl;
 118         tcp_listener_t  *tl;
 119         long            lport;
 120         long            ratio;
 121         char            *colon;
 122         tcp_stack_t     *tcps = (tcp_stack_t *)cbarg;
 123 
 124         if (flags & MOD_PROP_DEFAULT)
 125                 return (ENOTSUP);
 126 
 127         if (ddi_strtol(pval, &colon, 10, &lport) != 0 || lport <= 0 ||
 128             lport > USHRT_MAX || *colon != ':') {
 129                 return (EINVAL);
 130         }
 131         if (ddi_strtol(colon + 1, NULL, 10, &ratio) != 0 || ratio <= 0)
 132                 return (EINVAL);
 133 
 134         mutex_enter(&tcps->tcps_listener_conf_lock);
 135         for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL;
 136             tl = list_next(&tcps->tcps_listener_conf, tl)) {
 137                 /* There is an existing entry, so update its ratio value. */
 138                 if (tl->tl_port == lport) {
 139                         tl->tl_ratio = ratio;
 140                         mutex_exit(&tcps->tcps_listener_conf_lock);
 141                         return (0);
 142                 }
 143         }
 144 
 145         if ((new_tl = kmem_alloc(sizeof (tcp_listener_t), KM_NOSLEEP)) ==
 146             NULL) {
 147                 mutex_exit(&tcps->tcps_listener_conf_lock);
 148                 return (ENOMEM);
 149         }
 150 
 151         new_tl->tl_port = lport;
 152         new_tl->tl_ratio = ratio;
 153         list_insert_tail(&tcps->tcps_listener_conf, new_tl);
 154         mutex_exit(&tcps->tcps_listener_conf_lock);
 155         return (0);
 156 }
 157 
 158 /*
 159  * remove a listener limit configuration.
 160  */
 161 /* ARGSUSED */
 162 static int
 163 tcp_listener_conf_del(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
 164     const char *ifname, const void* pval, uint_t flags)
 165 {
 166         tcp_listener_t  *tl;
 167         long            lport;
 168         tcp_stack_t     *tcps = (tcp_stack_t *)cbarg;
 169 
 170         if (flags & MOD_PROP_DEFAULT)
 171                 return (ENOTSUP);
 172 
 173         if (ddi_strtol(pval, NULL, 10, &lport) != 0 || lport <= 0 ||
 174             lport > USHRT_MAX) {
 175                 return (EINVAL);
 176         }
 177         mutex_enter(&tcps->tcps_listener_conf_lock);
 178         for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL;
 179             tl = list_next(&tcps->tcps_listener_conf, tl)) {
 180                 if (tl->tl_port == lport) {
 181                         list_remove(&tcps->tcps_listener_conf, tl);
 182                         mutex_exit(&tcps->tcps_listener_conf_lock);
 183                         kmem_free(tl, sizeof (tcp_listener_t));
 184                         return (0);
 185                 }
 186         }
 187         mutex_exit(&tcps->tcps_listener_conf_lock);
 188         return (ESRCH);
 189 }
 190 
















 191 /*
 192  * Special checkers for smallest/largest anonymous port so they don't
 193  * ever happen to be (largest < smallest).
 194  */
 195 /* ARGSUSED */
 196 static int
 197 tcp_smallest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
 198     const char *ifname, const void *pval, uint_t flags)
 199 {
 200         unsigned long new_value;
 201         tcp_stack_t *tcps = (tcp_stack_t *)cbarg;
 202         int err;
 203 
 204         if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
 205                 return (err);
 206         /* mod_uint32_value() + pinfo guarantees we're in TCP port range. */
 207         if ((uint32_t)new_value > tcps->tcps_largest_anon_port)
 208                 return (ERANGE);
 209         pinfo->prop_cur_uval = (uint32_t)new_value;
 210         return (0);
 211 }
 212 
 213 /* ARGSUSED */
 214 static int
 215 tcp_largest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
 216     const char *ifname, const void *pval, uint_t flags)
 217 {
 218         unsigned long new_value;
 219         tcp_stack_t *tcps = (tcp_stack_t *)cbarg;
 220         int err;
 221 
 222         if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
 223                 return (err);
 224         /* mod_uint32_value() + pinfo guarantees we're in TCP port range. */
 225         if ((uint32_t)new_value < tcps->tcps_smallest_anon_port)
 226                 return (ERANGE);
 227         pinfo->prop_cur_uval = (uint32_t)new_value;
 228         return (0);
 229 }
 230 
 231 /*
 232  * All of these are alterable, within the min/max values given, at run time.
 233  *
 234  * Note: All those tunables which do not start with "_" are Committed and
 235  * therefore are public. See PSARC 2010/080.
 236  */
 237 mod_prop_info_t tcp_propinfo_tbl[] = {
 238         /* tunable - 0 */
 239         { "_time_wait_interval", MOD_PROTO_TCP,


 241             {1*SECONDS, 10*MINUTES, 1*MINUTES}, {1*MINUTES} },
 242 
 243         { "_conn_req_max_q", MOD_PROTO_TCP,
 244             mod_set_uint32, mod_get_uint32,
 245             {1, UINT32_MAX, 128}, {128} },
 246 
 247         { "_conn_req_max_q0", MOD_PROTO_TCP,
 248             mod_set_uint32, mod_get_uint32,
 249             {0, UINT32_MAX, 1024}, {1024} },
 250 
 251         { "_conn_req_min", MOD_PROTO_TCP,
 252             mod_set_uint32, mod_get_uint32,
 253             {1, 1024, 1}, {1} },
 254 
 255         { "_conn_grace_period", MOD_PROTO_TCP,
 256             mod_set_uint32, mod_get_uint32,
 257             {0*MS, 20*SECONDS, 0*MS}, {0*MS} },
 258 
 259         { "_cwnd_max", MOD_PROTO_TCP,
 260             mod_set_uint32, mod_get_uint32,
 261             {128, (1<<30), 1024*1024}, {1024*1024} },
 262 
 263         { "_debug", MOD_PROTO_TCP,
 264             mod_set_uint32, mod_get_uint32,
 265             {0, 10, 0}, {0} },
 266 
 267         { "smallest_nonpriv_port", MOD_PROTO_TCP,
 268             mod_set_uint32, mod_get_uint32,
 269             {1024, (32*1024), 1024}, {1024} },
 270 
 271         { "_ip_abort_cinterval", MOD_PROTO_TCP,
 272             mod_set_uint32, mod_get_uint32,
 273             {1*SECONDS, UINT32_MAX, 3*MINUTES}, {3*MINUTES} },
 274 
 275         { "_ip_abort_linterval", MOD_PROTO_TCP,
 276             mod_set_uint32, mod_get_uint32,
 277             {1*SECONDS, UINT32_MAX, 3*MINUTES}, {3*MINUTES} },
 278 
 279         /* tunable - 10 */
 280         { "_ip_abort_interval", MOD_PROTO_TCP,
 281             mod_set_uint32, mod_get_uint32,


 321 
 322         /* tunable - 20 */
 323         { "_rexmit_interval_initial", MOD_PROTO_TCP,
 324             mod_set_uint32, mod_get_uint32,
 325             {1*MS, 20*SECONDS, 1*SECONDS}, {1*SECONDS} },
 326 
 327         { "_rexmit_interval_max", MOD_PROTO_TCP,
 328             mod_set_uint32, mod_get_uint32,
 329             {1*MS, 2*HOURS, 60*SECONDS}, {60*SECONDS} },
 330 
 331         { "_rexmit_interval_min", MOD_PROTO_TCP,
 332             mod_set_uint32, mod_get_uint32,
 333             {1*MS, 2*HOURS, 400*MS}, {400*MS} },
 334 
 335         { "_deferred_ack_interval", MOD_PROTO_TCP,
 336             mod_set_uint32, mod_get_uint32,
 337             {1*MS, 1*MINUTES, 100*MS}, {100*MS} },
 338 
 339         { "_snd_lowat_fraction", MOD_PROTO_TCP,
 340             mod_set_uint32, mod_get_uint32,
 341             {0, 16, 0}, {0} },
 342 
 343         { "_dupack_fast_retransmit", MOD_PROTO_TCP,
 344             mod_set_uint32, mod_get_uint32,
 345             {1, 10000, 3}, {3} },
 346 
 347         { "_ignore_path_mtu", MOD_PROTO_TCP,
 348             mod_set_boolean, mod_get_boolean,
 349             {B_FALSE}, {B_FALSE} },
 350 
 351         { "smallest_anon_port", MOD_PROTO_TCP,
 352             tcp_smallest_anon_set, mod_get_uint32,
 353             {1024, ULP_MAX_PORT, 32*1024}, {32*1024} },
 354 
 355         { "largest_anon_port", MOD_PROTO_TCP,
 356             tcp_largest_anon_set, mod_get_uint32,
 357             {1024, ULP_MAX_PORT, ULP_MAX_PORT},
 358             {ULP_MAX_PORT} },
 359 
 360         { "send_maxbuf", MOD_PROTO_TCP,
 361             mod_set_uint32, mod_get_uint32,
 362             {TCP_XMIT_LOWATER, (1<<30), TCP_XMIT_HIWATER},
 363             {TCP_XMIT_HIWATER} },
 364 
 365         /* tunable - 30 */
 366         { "_xmit_lowat", MOD_PROTO_TCP,
 367             mod_set_uint32, mod_get_uint32,
 368             {TCP_XMIT_LOWATER, (1<<30), TCP_XMIT_LOWATER},
 369             {TCP_XMIT_LOWATER} },
 370 
 371         { "recv_maxbuf", MOD_PROTO_TCP,
 372             mod_set_uint32, mod_get_uint32,
 373             {TCP_RECV_LOWATER, (1<<30), TCP_RECV_HIWATER},
 374             {TCP_RECV_HIWATER} },
 375 
 376         { "_recv_hiwat_minmss", MOD_PROTO_TCP,
 377             mod_set_uint32, mod_get_uint32,
 378             {1, 65536, 4}, {4} },
 379 
 380         { "_fin_wait_2_flush_interval", MOD_PROTO_TCP,
 381             mod_set_uint32, mod_get_uint32,
 382             {1*SECONDS, 2*HOURS, 60*SECONDS},
 383             {60*SECONDS} },
 384 
 385         { "_max_buf", MOD_PROTO_TCP,
 386             mod_set_uint32, mod_get_uint32,
 387             {8192, (1<<30), 1024*1024}, {1024*1024} },
 388 
 389         /*
 390          * Question:  What default value should I set for tcp_strong_iss?
 391          */
 392         { "_strong_iss", MOD_PROTO_TCP,
 393             mod_set_uint32, mod_get_uint32,
 394             {0, 2, 1}, {1} },
 395 
 396         { "_rtt_updates", MOD_PROTO_TCP,
 397             mod_set_uint32, mod_get_uint32,
 398             {0, 65536, 20}, {20} },
 399 
 400         { "_wscale_always", MOD_PROTO_TCP,
 401             mod_set_boolean, mod_get_boolean,
 402             {B_TRUE}, {B_TRUE} },
 403 
 404         { "_tstamp_always", MOD_PROTO_TCP,
 405             mod_set_boolean, mod_get_boolean,
 406             {B_FALSE}, {B_FALSE} },
 407 




   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2011, Joyent Inc. All rights reserved.
  24  * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
  25  * Copyright (c) 2013 by Delphix. All rights reserved.
  26  */
  27 /* Copyright (c) 1990 Mentat Inc. */
  28 
  29 #include <inet/ip.h>
  30 #include <inet/tcp_impl.h>
  31 #include <sys/multidata.h>
  32 #include <sys/sunddi.h>
  33 
  34 /* Max size IP datagram is 64k - 1 */
  35 #define TCP_MSS_MAX_IPV4 (IP_MAXPACKET - (sizeof (ipha_t) + sizeof (tcpha_t)))
  36 #define TCP_MSS_MAX_IPV6 (IP_MAXPACKET - (sizeof (ip6_t) + sizeof (tcpha_t)))
  37 
  38 /* Max of the above */
  39 #define TCP_MSS_MAX             TCP_MSS_MAX_IPV4
  40 





  41 /*
  42  * Set the RFC 1948 pass phrase
  43  */
  44 /* ARGSUSED */
  45 static int
  46 tcp_set_1948phrase(netstack_t *stack,  cred_t *cr, mod_prop_info_t *pinfo,
  47     const char *ifname, const void* pr_val, uint_t flags)
  48 {


  49         if (flags & MOD_PROP_DEFAULT)
  50                 return (ENOTSUP);
  51 
  52         /*
  53          * Basically, value contains a new pass phrase.  Pass it along!
  54          */
  55         tcp_iss_key_init((uint8_t *)pr_val, strlen(pr_val),
  56             stack->netstack_tcp);
  57         return (0);
  58 }
  59 
  60 /*
  61  * returns the current list of listener limit configuration.
  62  */
  63 /* ARGSUSED */
  64 static int
  65 tcp_listener_conf_get(netstack_t *stack, mod_prop_info_t *pinfo,
  66     const char *ifname, void *val, uint_t psize, uint_t flags)
  67 {
  68         tcp_stack_t     *tcps = stack->netstack_tcp;
  69         tcp_listener_t  *tl;
  70         char            *pval = val;
  71         size_t          nbytes = 0, tbytes = 0;
  72         uint_t          size;
  73         int             err = 0;
  74 
  75         bzero(pval, psize);
  76         size = psize;
  77 
  78         if (flags & (MOD_PROP_DEFAULT|MOD_PROP_PERM|MOD_PROP_POSSIBLE))
  79                 return (0);
  80 
  81         mutex_enter(&tcps->tcps_listener_conf_lock);
  82         for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL;
  83             tl = list_next(&tcps->tcps_listener_conf, tl)) {
  84                 if (psize == size)
  85                         nbytes = snprintf(pval, size, "%d:%d",  tl->tl_port,
  86                             tl->tl_ratio);
  87                 else
  88                         nbytes = snprintf(pval, size, ",%d:%d",  tl->tl_port,
  89                             tl->tl_ratio);
  90                 size -= nbytes;
  91                 pval += nbytes;
  92                 tbytes += nbytes;
  93                 if (tbytes >= psize) {
  94                         /* Buffer overflow, stop copying information */
  95                         err = ENOBUFS;
  96                         break;
  97                 }
  98         }
  99 
 100         mutex_exit(&tcps->tcps_listener_conf_lock);
 101         return (err);
 102 }
 103 
 104 /*
 105  * add a new listener limit configuration.
 106  */
 107 /* ARGSUSED */
 108 static int
 109 tcp_listener_conf_add(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 110     const char *ifname, const void* pval, uint_t flags)
 111 {
 112         tcp_listener_t  *new_tl;
 113         tcp_listener_t  *tl;
 114         long            lport;
 115         long            ratio;
 116         char            *colon;
 117         tcp_stack_t     *tcps = stack->netstack_tcp;
 118 
 119         if (flags & MOD_PROP_DEFAULT)
 120                 return (ENOTSUP);
 121 
 122         if (ddi_strtol(pval, &colon, 10, &lport) != 0 || lport <= 0 ||
 123             lport > USHRT_MAX || *colon != ':') {
 124                 return (EINVAL);
 125         }
 126         if (ddi_strtol(colon + 1, NULL, 10, &ratio) != 0 || ratio <= 0)
 127                 return (EINVAL);
 128 
 129         mutex_enter(&tcps->tcps_listener_conf_lock);
 130         for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL;
 131             tl = list_next(&tcps->tcps_listener_conf, tl)) {
 132                 /* There is an existing entry, so update its ratio value. */
 133                 if (tl->tl_port == lport) {
 134                         tl->tl_ratio = ratio;
 135                         mutex_exit(&tcps->tcps_listener_conf_lock);
 136                         return (0);
 137                 }
 138         }
 139 
 140         if ((new_tl = kmem_alloc(sizeof (tcp_listener_t), KM_NOSLEEP)) ==
 141             NULL) {
 142                 mutex_exit(&tcps->tcps_listener_conf_lock);
 143                 return (ENOMEM);
 144         }
 145 
 146         new_tl->tl_port = lport;
 147         new_tl->tl_ratio = ratio;
 148         list_insert_tail(&tcps->tcps_listener_conf, new_tl);
 149         mutex_exit(&tcps->tcps_listener_conf_lock);
 150         return (0);
 151 }
 152 
 153 /*
 154  * remove a listener limit configuration.
 155  */
 156 /* ARGSUSED */
 157 static int
 158 tcp_listener_conf_del(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 159     const char *ifname, const void* pval, uint_t flags)
 160 {
 161         tcp_listener_t  *tl;
 162         long            lport;
 163         tcp_stack_t     *tcps = stack->netstack_tcp;
 164 
 165         if (flags & MOD_PROP_DEFAULT)
 166                 return (ENOTSUP);
 167 
 168         if (ddi_strtol(pval, NULL, 10, &lport) != 0 || lport <= 0 ||
 169             lport > USHRT_MAX) {
 170                 return (EINVAL);
 171         }
 172         mutex_enter(&tcps->tcps_listener_conf_lock);
 173         for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL;
 174             tl = list_next(&tcps->tcps_listener_conf, tl)) {
 175                 if (tl->tl_port == lport) {
 176                         list_remove(&tcps->tcps_listener_conf, tl);
 177                         mutex_exit(&tcps->tcps_listener_conf_lock);
 178                         kmem_free(tl, sizeof (tcp_listener_t));
 179                         return (0);
 180                 }
 181         }
 182         mutex_exit(&tcps->tcps_listener_conf_lock);
 183         return (ESRCH);
 184 }
 185 
 186 static int
 187 tcp_set_buf_prop(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 188     const char *ifname, const void *pval, uint_t flags)
 189 {
 190         return (mod_set_buf_prop(stack->netstack_tcp->tcps_propinfo_tbl, stack,
 191             cr, pinfo, ifname, pval, flags));
 192 }
 193 
 194 static int
 195 tcp_get_buf_prop(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname,
 196     void *val, uint_t psize, uint_t flags)
 197 {
 198         return (mod_get_buf_prop(stack->netstack_tcp->tcps_propinfo_tbl, stack,
 199             pinfo, ifname, val, psize, flags));
 200 }
 201 
 202 /*
 203  * Special checkers for smallest/largest anonymous port so they don't
 204  * ever happen to be (largest < smallest).
 205  */
 206 /* ARGSUSED */
 207 static int
 208 tcp_smallest_anon_set(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 209     const char *ifname, const void *pval, uint_t flags)
 210 {
 211         unsigned long new_value;
 212         tcp_stack_t *tcps = stack->netstack_tcp;
 213         int err;
 214 
 215         if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
 216                 return (err);
 217         /* mod_uint32_value() + pinfo guarantees we're in TCP port range. */
 218         if ((uint32_t)new_value > tcps->tcps_largest_anon_port)
 219                 return (ERANGE);
 220         pinfo->prop_cur_uval = (uint32_t)new_value;
 221         return (0);
 222 }
 223 
 224 /* ARGSUSED */
 225 static int
 226 tcp_largest_anon_set(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 227     const char *ifname, const void *pval, uint_t flags)
 228 {
 229         unsigned long new_value;
 230         tcp_stack_t *tcps = stack->netstack_tcp;
 231         int err;
 232 
 233         if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
 234                 return (err);
 235         /* mod_uint32_value() + pinfo guarantees we're in TCP port range. */
 236         if ((uint32_t)new_value < tcps->tcps_smallest_anon_port)
 237                 return (ERANGE);
 238         pinfo->prop_cur_uval = (uint32_t)new_value;
 239         return (0);
 240 }
 241 
 242 /*
 243  * All of these are alterable, within the min/max values given, at run time.
 244  *
 245  * Note: All those tunables which do not start with "_" are Committed and
 246  * therefore are public. See PSARC 2010/080.
 247  */
 248 mod_prop_info_t tcp_propinfo_tbl[] = {
 249         /* tunable - 0 */
 250         { "_time_wait_interval", MOD_PROTO_TCP,


 252             {1*SECONDS, 10*MINUTES, 1*MINUTES}, {1*MINUTES} },
 253 
 254         { "_conn_req_max_q", MOD_PROTO_TCP,
 255             mod_set_uint32, mod_get_uint32,
 256             {1, UINT32_MAX, 128}, {128} },
 257 
 258         { "_conn_req_max_q0", MOD_PROTO_TCP,
 259             mod_set_uint32, mod_get_uint32,
 260             {0, UINT32_MAX, 1024}, {1024} },
 261 
 262         { "_conn_req_min", MOD_PROTO_TCP,
 263             mod_set_uint32, mod_get_uint32,
 264             {1, 1024, 1}, {1} },
 265 
 266         { "_conn_grace_period", MOD_PROTO_TCP,
 267             mod_set_uint32, mod_get_uint32,
 268             {0*MS, 20*SECONDS, 0*MS}, {0*MS} },
 269 
 270         { "_cwnd_max", MOD_PROTO_TCP,
 271             mod_set_uint32, mod_get_uint32,
 272             {128, ULP_MAX_BUF, 1024*1024}, {1024*1024} },
 273 
 274         { "_debug", MOD_PROTO_TCP,
 275             mod_set_uint32, mod_get_uint32,
 276             {0, 10, 0}, {0} },
 277 
 278         { "smallest_nonpriv_port", MOD_PROTO_TCP,
 279             mod_set_uint32, mod_get_uint32,
 280             {1024, (32*1024), 1024}, {1024} },
 281 
 282         { "_ip_abort_cinterval", MOD_PROTO_TCP,
 283             mod_set_uint32, mod_get_uint32,
 284             {1*SECONDS, UINT32_MAX, 3*MINUTES}, {3*MINUTES} },
 285 
 286         { "_ip_abort_linterval", MOD_PROTO_TCP,
 287             mod_set_uint32, mod_get_uint32,
 288             {1*SECONDS, UINT32_MAX, 3*MINUTES}, {3*MINUTES} },
 289 
 290         /* tunable - 10 */
 291         { "_ip_abort_interval", MOD_PROTO_TCP,
 292             mod_set_uint32, mod_get_uint32,


 332 
 333         /* tunable - 20 */
 334         { "_rexmit_interval_initial", MOD_PROTO_TCP,
 335             mod_set_uint32, mod_get_uint32,
 336             {1*MS, 20*SECONDS, 1*SECONDS}, {1*SECONDS} },
 337 
 338         { "_rexmit_interval_max", MOD_PROTO_TCP,
 339             mod_set_uint32, mod_get_uint32,
 340             {1*MS, 2*HOURS, 60*SECONDS}, {60*SECONDS} },
 341 
 342         { "_rexmit_interval_min", MOD_PROTO_TCP,
 343             mod_set_uint32, mod_get_uint32,
 344             {1*MS, 2*HOURS, 400*MS}, {400*MS} },
 345 
 346         { "_deferred_ack_interval", MOD_PROTO_TCP,
 347             mod_set_uint32, mod_get_uint32,
 348             {1*MS, 1*MINUTES, 100*MS}, {100*MS} },
 349 
 350         { "_snd_lowat_fraction", MOD_PROTO_TCP,
 351             mod_set_uint32, mod_get_uint32,
 352             {0, 16, 10}, {10} },
 353 
 354         { "_dupack_fast_retransmit", MOD_PROTO_TCP,
 355             mod_set_uint32, mod_get_uint32,
 356             {1, 10000, 3}, {3} },
 357 
 358         { "_ignore_path_mtu", MOD_PROTO_TCP,
 359             mod_set_boolean, mod_get_boolean,
 360             {B_FALSE}, {B_FALSE} },
 361 
 362         { "smallest_anon_port", MOD_PROTO_TCP,
 363             tcp_smallest_anon_set, mod_get_uint32,
 364             {1024, ULP_MAX_PORT, 32*1024}, {32*1024} },
 365 
 366         { "largest_anon_port", MOD_PROTO_TCP,
 367             tcp_largest_anon_set, mod_get_uint32,
 368             {1024, ULP_MAX_PORT, ULP_MAX_PORT},
 369             {ULP_MAX_PORT} },
 370 
 371         { "send_buf", MOD_PROTO_TCP,
 372             tcp_set_buf_prop, tcp_get_buf_prop,
 373             {TCP_XMIT_LOWATER, ULP_MAX_BUF, TCP_XMIT_HIWATER},
 374             {TCP_XMIT_HIWATER} },
 375 
 376         /* tunable - 30 */
 377         { "_xmit_lowat", MOD_PROTO_TCP,
 378             mod_set_uint32, mod_get_uint32,
 379             {TCP_XMIT_LOWATER, ULP_MAX_BUF, TCP_XMIT_LOWATER},
 380             {TCP_XMIT_LOWATER} },
 381 
 382         { "recv_buf", MOD_PROTO_TCP,
 383             tcp_set_buf_prop, tcp_get_buf_prop,
 384             {TCP_RECV_LOWATER, ULP_MAX_BUF, TCP_RECV_HIWATER},
 385             {TCP_RECV_HIWATER} },
 386 
 387         { "_recv_hiwat_minmss", MOD_PROTO_TCP,
 388             mod_set_uint32, mod_get_uint32,
 389             {1, 65536, 4}, {4} },
 390 
 391         { "_fin_wait_2_flush_interval", MOD_PROTO_TCP,
 392             mod_set_uint32, mod_get_uint32,
 393             {1*SECONDS, 2*HOURS, 60*SECONDS},
 394             {60*SECONDS} },
 395 
 396         { "max_buf", MOD_PROTO_TCP,
 397             mod_set_uint32, mod_get_uint32,
 398             {8192, ULP_MAX_BUF, 1024*1024}, {1024*1024} },
 399 
 400         /*
 401          * Question:  What default value should I set for tcp_strong_iss?
 402          */
 403         { "_strong_iss", MOD_PROTO_TCP,
 404             mod_set_uint32, mod_get_uint32,
 405             {0, 2, 1}, {1} },
 406 
 407         { "_rtt_updates", MOD_PROTO_TCP,
 408             mod_set_uint32, mod_get_uint32,
 409             {0, 65536, 20}, {20} },
 410 
 411         { "_wscale_always", MOD_PROTO_TCP,
 412             mod_set_boolean, mod_get_boolean,
 413             {B_TRUE}, {B_TRUE} },
 414 
 415         { "_tstamp_always", MOD_PROTO_TCP,
 416             mod_set_boolean, mod_get_boolean,
 417             {B_FALSE}, {B_FALSE} },
 418