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>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/tcp/tcp_tunables.c
          +++ new/usr/src/uts/common/inet/tcp/tcp_tunables.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  23   23   * Copyright (c) 2011, Joyent Inc. All rights reserved.
  24   24   * Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
       25 + * Copyright (c) 2013 by Delphix. All rights reserved.
  25   26   */
  26   27  /* Copyright (c) 1990 Mentat Inc. */
  27   28  
  28   29  #include <inet/ip.h>
  29   30  #include <inet/tcp_impl.h>
  30   31  #include <sys/multidata.h>
  31   32  #include <sys/sunddi.h>
  32   33  
  33   34  /* Max size IP datagram is 64k - 1 */
  34   35  #define TCP_MSS_MAX_IPV4 (IP_MAXPACKET - (sizeof (ipha_t) + sizeof (tcpha_t)))
  35   36  #define TCP_MSS_MAX_IPV6 (IP_MAXPACKET - (sizeof (ip6_t) + sizeof (tcpha_t)))
  36   37  
  37   38  /* Max of the above */
  38   39  #define TCP_MSS_MAX             TCP_MSS_MAX_IPV4
  39   40  
  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   41  /*
  46   42   * Set the RFC 1948 pass phrase
  47   43   */
  48   44  /* ARGSUSED */
  49   45  static int
  50      -tcp_set_1948phrase(void *cbarg,  cred_t *cr, mod_prop_info_t *pinfo,
       46 +tcp_set_1948phrase(netstack_t *stack,  cred_t *cr, mod_prop_info_t *pinfo,
  51   47      const char *ifname, const void* pr_val, uint_t flags)
  52   48  {
  53      -        tcp_stack_t     *tcps = (tcp_stack_t *)cbarg;
  54      -
  55   49          if (flags & MOD_PROP_DEFAULT)
  56   50                  return (ENOTSUP);
  57   51  
  58   52          /*
  59   53           * Basically, value contains a new pass phrase.  Pass it along!
  60   54           */
  61      -        tcp_iss_key_init((uint8_t *)pr_val, strlen(pr_val), tcps);
       55 +        tcp_iss_key_init((uint8_t *)pr_val, strlen(pr_val),
       56 +            stack->netstack_tcp);
  62   57          return (0);
  63   58  }
  64   59  
  65   60  /*
  66   61   * returns the current list of listener limit configuration.
  67   62   */
  68   63  /* ARGSUSED */
  69   64  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)
       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)
  72   67  {
  73      -        tcp_stack_t     *tcps = (tcp_stack_t *)cbarg;
       68 +        tcp_stack_t     *tcps = stack->netstack_tcp;
  74   69          tcp_listener_t  *tl;
  75   70          char            *pval = val;
  76   71          size_t          nbytes = 0, tbytes = 0;
  77   72          uint_t          size;
  78   73          int             err = 0;
  79   74  
  80   75          bzero(pval, psize);
  81   76          size = psize;
  82   77  
  83   78          if (flags & (MOD_PROP_DEFAULT|MOD_PROP_PERM|MOD_PROP_POSSIBLE))
↓ open down ↓ 20 lines elided ↑ open up ↑
 104   99  
 105  100          mutex_exit(&tcps->tcps_listener_conf_lock);
 106  101          return (err);
 107  102  }
 108  103  
 109  104  /*
 110  105   * add a new listener limit configuration.
 111  106   */
 112  107  /* ARGSUSED */
 113  108  static int
 114      -tcp_listener_conf_add(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
      109 +tcp_listener_conf_add(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 115  110      const char *ifname, const void* pval, uint_t flags)
 116  111  {
 117  112          tcp_listener_t  *new_tl;
 118  113          tcp_listener_t  *tl;
 119  114          long            lport;
 120  115          long            ratio;
 121  116          char            *colon;
 122      -        tcp_stack_t     *tcps = (tcp_stack_t *)cbarg;
      117 +        tcp_stack_t     *tcps = stack->netstack_tcp;
 123  118  
 124  119          if (flags & MOD_PROP_DEFAULT)
 125  120                  return (ENOTSUP);
 126  121  
 127  122          if (ddi_strtol(pval, &colon, 10, &lport) != 0 || lport <= 0 ||
 128  123              lport > USHRT_MAX || *colon != ':') {
 129  124                  return (EINVAL);
 130  125          }
 131  126          if (ddi_strtol(colon + 1, NULL, 10, &ratio) != 0 || ratio <= 0)
 132  127                  return (EINVAL);
↓ open down ↓ 20 lines elided ↑ open up ↑
 153  148          list_insert_tail(&tcps->tcps_listener_conf, new_tl);
 154  149          mutex_exit(&tcps->tcps_listener_conf_lock);
 155  150          return (0);
 156  151  }
 157  152  
 158  153  /*
 159  154   * remove a listener limit configuration.
 160  155   */
 161  156  /* ARGSUSED */
 162  157  static int
 163      -tcp_listener_conf_del(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
      158 +tcp_listener_conf_del(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 164  159      const char *ifname, const void* pval, uint_t flags)
 165  160  {
 166  161          tcp_listener_t  *tl;
 167  162          long            lport;
 168      -        tcp_stack_t     *tcps = (tcp_stack_t *)cbarg;
      163 +        tcp_stack_t     *tcps = stack->netstack_tcp;
 169  164  
 170  165          if (flags & MOD_PROP_DEFAULT)
 171  166                  return (ENOTSUP);
 172  167  
 173  168          if (ddi_strtol(pval, NULL, 10, &lport) != 0 || lport <= 0 ||
 174  169              lport > USHRT_MAX) {
 175  170                  return (EINVAL);
 176  171          }
 177  172          mutex_enter(&tcps->tcps_listener_conf_lock);
 178  173          for (tl = list_head(&tcps->tcps_listener_conf); tl != NULL;
↓ open down ↓ 2 lines elided ↑ open up ↑
 181  176                          list_remove(&tcps->tcps_listener_conf, tl);
 182  177                          mutex_exit(&tcps->tcps_listener_conf_lock);
 183  178                          kmem_free(tl, sizeof (tcp_listener_t));
 184  179                          return (0);
 185  180                  }
 186  181          }
 187  182          mutex_exit(&tcps->tcps_listener_conf_lock);
 188  183          return (ESRCH);
 189  184  }
 190  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 +
 191  202  /*
 192  203   * Special checkers for smallest/largest anonymous port so they don't
 193  204   * ever happen to be (largest < smallest).
 194  205   */
 195  206  /* ARGSUSED */
 196  207  static int
 197      -tcp_smallest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
      208 +tcp_smallest_anon_set(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 198  209      const char *ifname, const void *pval, uint_t flags)
 199  210  {
 200  211          unsigned long new_value;
 201      -        tcp_stack_t *tcps = (tcp_stack_t *)cbarg;
      212 +        tcp_stack_t *tcps = stack->netstack_tcp;
 202  213          int err;
 203  214  
 204  215          if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
 205  216                  return (err);
 206  217          /* mod_uint32_value() + pinfo guarantees we're in TCP port range. */
 207  218          if ((uint32_t)new_value > tcps->tcps_largest_anon_port)
 208  219                  return (ERANGE);
 209  220          pinfo->prop_cur_uval = (uint32_t)new_value;
 210  221          return (0);
 211  222  }
 212  223  
 213  224  /* ARGSUSED */
 214  225  static int
 215      -tcp_largest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
      226 +tcp_largest_anon_set(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 216  227      const char *ifname, const void *pval, uint_t flags)
 217  228  {
 218  229          unsigned long new_value;
 219      -        tcp_stack_t *tcps = (tcp_stack_t *)cbarg;
      230 +        tcp_stack_t *tcps = stack->netstack_tcp;
 220  231          int err;
 221  232  
 222  233          if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
 223  234                  return (err);
 224  235          /* mod_uint32_value() + pinfo guarantees we're in TCP port range. */
 225  236          if ((uint32_t)new_value < tcps->tcps_smallest_anon_port)
 226  237                  return (ERANGE);
 227  238          pinfo->prop_cur_uval = (uint32_t)new_value;
 228  239          return (0);
 229  240  }
↓ open down ↓ 21 lines elided ↑ open up ↑
 251  262          { "_conn_req_min", MOD_PROTO_TCP,
 252  263              mod_set_uint32, mod_get_uint32,
 253  264              {1, 1024, 1}, {1} },
 254  265  
 255  266          { "_conn_grace_period", MOD_PROTO_TCP,
 256  267              mod_set_uint32, mod_get_uint32,
 257  268              {0*MS, 20*SECONDS, 0*MS}, {0*MS} },
 258  269  
 259  270          { "_cwnd_max", MOD_PROTO_TCP,
 260  271              mod_set_uint32, mod_get_uint32,
 261      -            {128, (1<<30), 1024*1024}, {1024*1024} },
      272 +            {128, ULP_MAX_BUF, 1024*1024}, {1024*1024} },
 262  273  
 263  274          { "_debug", MOD_PROTO_TCP,
 264  275              mod_set_uint32, mod_get_uint32,
 265  276              {0, 10, 0}, {0} },
 266  277  
 267  278          { "smallest_nonpriv_port", MOD_PROTO_TCP,
 268  279              mod_set_uint32, mod_get_uint32,
 269  280              {1024, (32*1024), 1024}, {1024} },
 270  281  
 271  282          { "_ip_abort_cinterval", MOD_PROTO_TCP,
↓ open down ↓ 59 lines elided ↑ open up ↑
 331  342          { "_rexmit_interval_min", MOD_PROTO_TCP,
 332  343              mod_set_uint32, mod_get_uint32,
 333  344              {1*MS, 2*HOURS, 400*MS}, {400*MS} },
 334  345  
 335  346          { "_deferred_ack_interval", MOD_PROTO_TCP,
 336  347              mod_set_uint32, mod_get_uint32,
 337  348              {1*MS, 1*MINUTES, 100*MS}, {100*MS} },
 338  349  
 339  350          { "_snd_lowat_fraction", MOD_PROTO_TCP,
 340  351              mod_set_uint32, mod_get_uint32,
 341      -            {0, 16, 0}, {0} },
      352 +            {0, 16, 10}, {10} },
 342  353  
 343  354          { "_dupack_fast_retransmit", MOD_PROTO_TCP,
 344  355              mod_set_uint32, mod_get_uint32,
 345  356              {1, 10000, 3}, {3} },
 346  357  
 347  358          { "_ignore_path_mtu", MOD_PROTO_TCP,
 348  359              mod_set_boolean, mod_get_boolean,
 349  360              {B_FALSE}, {B_FALSE} },
 350  361  
 351  362          { "smallest_anon_port", MOD_PROTO_TCP,
 352  363              tcp_smallest_anon_set, mod_get_uint32,
 353  364              {1024, ULP_MAX_PORT, 32*1024}, {32*1024} },
 354  365  
 355  366          { "largest_anon_port", MOD_PROTO_TCP,
 356  367              tcp_largest_anon_set, mod_get_uint32,
 357  368              {1024, ULP_MAX_PORT, ULP_MAX_PORT},
 358  369              {ULP_MAX_PORT} },
 359  370  
 360      -        { "send_maxbuf", MOD_PROTO_TCP,
 361      -            mod_set_uint32, mod_get_uint32,
 362      -            {TCP_XMIT_LOWATER, (1<<30), TCP_XMIT_HIWATER},
      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},
 363  374              {TCP_XMIT_HIWATER} },
 364  375  
 365  376          /* tunable - 30 */
 366  377          { "_xmit_lowat", MOD_PROTO_TCP,
 367  378              mod_set_uint32, mod_get_uint32,
 368      -            {TCP_XMIT_LOWATER, (1<<30), TCP_XMIT_LOWATER},
      379 +            {TCP_XMIT_LOWATER, ULP_MAX_BUF, TCP_XMIT_LOWATER},
 369  380              {TCP_XMIT_LOWATER} },
 370  381  
 371      -        { "recv_maxbuf", MOD_PROTO_TCP,
 372      -            mod_set_uint32, mod_get_uint32,
 373      -            {TCP_RECV_LOWATER, (1<<30), TCP_RECV_HIWATER},
      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},
 374  385              {TCP_RECV_HIWATER} },
 375  386  
 376  387          { "_recv_hiwat_minmss", MOD_PROTO_TCP,
 377  388              mod_set_uint32, mod_get_uint32,
 378  389              {1, 65536, 4}, {4} },
 379  390  
 380  391          { "_fin_wait_2_flush_interval", MOD_PROTO_TCP,
 381  392              mod_set_uint32, mod_get_uint32,
 382  393              {1*SECONDS, 2*HOURS, 60*SECONDS},
 383  394              {60*SECONDS} },
 384  395  
 385      -        { "_max_buf", MOD_PROTO_TCP,
      396 +        { "max_buf", MOD_PROTO_TCP,
 386  397              mod_set_uint32, mod_get_uint32,
 387      -            {8192, (1<<30), 1024*1024}, {1024*1024} },
      398 +            {8192, ULP_MAX_BUF, 1024*1024}, {1024*1024} },
 388  399  
 389  400          /*
 390  401           * Question:  What default value should I set for tcp_strong_iss?
 391  402           */
 392  403          { "_strong_iss", MOD_PROTO_TCP,
 393  404              mod_set_uint32, mod_get_uint32,
 394  405              {0, 2, 1}, {1} },
 395  406  
 396  407          { "_rtt_updates", MOD_PROTO_TCP,
 397  408              mod_set_uint32, mod_get_uint32,
↓ open down ↓ 130 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX