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/ip/ip_tunables.c
          +++ new/usr/src/uts/common/inet/ip/ip_tunables.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  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 + * Copyright (c) 2013 by Delphix. All rights reserved.
  23   24   */
  24   25  /* Copyright (c) 1990 Mentat Inc. */
  25   26  
  26   27  #include <inet/ip.h>
  27   28  #include <inet/ip6.h>
  28   29  #include <inet/ip_if.h>
  29   30  #include <inet/ip_ire.h>
  30   31  #include <inet/ipclassifier.h>
  31   32  #include <inet/ip_impl.h>
  32   33  #include <inet/tunables.h>
↓ open down ↓ 4 lines elided ↑ open up ↑
  37   38  #define IP_REASM_TIMEOUT        15
  38   39  #define IPV6_REASM_TIMEOUT      60
  39   40  
  40   41  /*
  41   42   * Set ip{,6}_forwarding values. If the value is being set on an ill,
  42   43   * find the ill and set the value on it. On the other hand if we are modifying
  43   44   * global property, modify the global value and set the value on all the ills.
  44   45   */
  45   46  /* ARGSUSED */
  46   47  static int
  47      -ip_set_forwarding(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
       48 +ip_set_forwarding(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
  48   49      const char *ifname, const void* pval, uint_t flags)
  49   50  {
  50   51          char                    *end;
  51   52          unsigned long           new_value;
  52      -        boolean_t               per_ill, isv6;
  53      -        ill_walk_context_t      ctx;
  54      -        ill_t                   *ill;
  55      -        ip_stack_t              *ipst = (ip_stack_t *)cbarg;
       53 +        boolean_t               per_ill, isv6;
       54 +        ill_walk_context_t      ctx;
       55 +        ill_t                   *ill;
       56 +        ip_stack_t              *ipst = stack->netstack_ip;
  56   57  
  57   58          if (flags & MOD_PROP_DEFAULT) {
  58   59                  new_value = pinfo->prop_def_bval;
  59   60          } else {
  60   61                  if (ddi_strtoul(pval, &end, 10, &new_value) != 0 ||
  61   62                      *end != '\0')
  62   63                          return (EINVAL);
  63   64                  if (new_value != B_TRUE && new_value != B_FALSE)
  64   65                          return (EINVAL);
  65   66          }
↓ open down ↓ 21 lines elided ↑ open up ↑
  87   88                  if (per_ill && strcmp(ifname, ill->ill_name) != 0)
  88   89                          continue;
  89   90                  (void) ill_forward_set(ill, new_value != 0);
  90   91          }
  91   92          rw_exit(&ipst->ips_ill_g_lock);
  92   93  
  93   94          return (0);
  94   95  }
  95   96  
  96   97  static int
  97      -ip_get_forwarding(void *cbarg, mod_prop_info_t *pinfo, const char *ifname,
       98 +ip_get_forwarding(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname,
  98   99      void *pval, uint_t pr_size, uint_t flags)
  99  100  {
 100      -        boolean_t               value;
 101      -        ill_walk_context_t      ctx;
 102      -        ill_t                   *ill;
 103      -        ip_stack_t              *ipst =  (ip_stack_t *)cbarg;
      101 +        boolean_t               value;
      102 +        ill_walk_context_t      ctx;
      103 +        ill_t                   *ill;
      104 +        ip_stack_t              *ipst = stack->netstack_ip;
 104  105          boolean_t               get_def = (flags & MOD_PROP_DEFAULT);
 105  106          boolean_t               get_perm = (flags & MOD_PROP_PERM);
 106  107          boolean_t               isv6;
 107  108          size_t                  nbytes = 0;
 108  109  
 109  110          if (get_perm) {
 110  111                  nbytes = snprintf(pval, pr_size, "%d", MOD_PROP_PERM_RW);
 111  112                  goto ret;
 112  113          } else if (get_def) {
 113  114                  nbytes = snprintf(pval, pr_size, "%d", pinfo->prop_def_bval);
↓ open down ↓ 35 lines elided ↑ open up ↑
 149  150                  return (ENOBUFS);
 150  151          return (0);
 151  152  }
 152  153  
 153  154  /*
 154  155   * `ip_debug' is a global variable. So, we will be modifying the global
 155  156   * variable here.
 156  157   */
 157  158  /* ARGSUSED */
 158  159  int
 159      -ip_set_debug(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
      160 +ip_set_debug(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 160  161      const char *ifname, const void* pval, uint_t flags)
 161  162  {
 162      -        unsigned long   new_value;
      163 +        unsigned long   new_value;
 163  164          int             err;
 164  165  
 165  166          if (cr != NULL && secpolicy_net_config(cr, B_FALSE) != 0)
 166  167                  return (EPERM);
 167  168  
 168  169          if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
 169  170                  return (err);
 170  171          ip_debug = (uint32_t)new_value;
 171  172          return (0);
 172  173  }
 173  174  
 174  175  /*
 175  176   * ip_debug is a global property. For default, permission and value range
 176  177   * we retrieve the value from `pinfo'. However for the current value we
 177  178   * retrieve the value from the global variable `ip_debug'
 178  179   */
 179  180  /* ARGSUSED */
 180  181  int
 181      -ip_get_debug(void *cbarg, mod_prop_info_t *pinfo, const char *ifname,
      182 +ip_get_debug(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname,
 182  183      void *pval, uint_t psize, uint_t flags)
 183  184  {
 184  185          boolean_t       get_def = (flags & MOD_PROP_DEFAULT);
 185  186          boolean_t       get_perm = (flags & MOD_PROP_PERM);
 186  187          boolean_t       get_range = (flags & MOD_PROP_POSSIBLE);
 187  188          size_t          nbytes;
 188  189  
 189  190          bzero(pval, psize);
 190  191          if (get_perm)
 191  192                  nbytes = snprintf(pval, psize, "%u", MOD_PROP_PERM_RW);
↓ open down ↓ 9 lines elided ↑ open up ↑
 201  202          return (0);
 202  203  }
 203  204  
 204  205  /*
 205  206   * Set the CGTP (multirouting) filtering status. If the status is changed
 206  207   * from active to transparent or from transparent to active, forward the
 207  208   * new status to the filtering module (if loaded).
 208  209   */
 209  210  /* ARGSUSED */
 210  211  static int
 211      -ip_set_cgtp_filter(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
      212 +ip_set_cgtp_filter(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 212  213      const char *ifname, const void* pval, uint_t flags)
 213  214  {
 214  215          unsigned long   new_value;
 215      -        ip_stack_t      *ipst = (ip_stack_t *)cbarg;
      216 +        ip_stack_t      *ipst = stack->netstack_ip;
 216  217          char            *end;
 217  218  
 218  219          if (flags & MOD_PROP_DEFAULT) {
 219  220                  new_value = pinfo->prop_def_bval;
 220  221          } else {
 221  222                  if (ddi_strtoul(pval, &end, 10, &new_value) != 0 ||
 222  223                      *end != '\0' || new_value > 1) {
 223  224                          return (EINVAL);
 224  225                  }
 225  226          }
↓ open down ↓ 32 lines elided ↑ open up ↑
 258  259   *     to begin with. However it is dynamically computed for some link-types
 259  260   *     like tunnels, based on the tunnel PMTU.
 260  261   *
 261  262   *  -- ill_mtu is the user set MTU using SIOCSLIFMTU and must lie between
 262  263   *     (IPV6_MIN_MTU/IP_MIN_MTU) and ill_max_frag.
 263  264   *
 264  265   *  -- ill_user_mtu is set by in.ndpd using SIOCSLIFLNKINFO and must lie between
 265  266   *     (IPV6_MIN_MTU/IP_MIN_MTU) and ill_max_frag.
 266  267   */
 267  268  int
 268      -ip_get_mtu(void *cbarg, mod_prop_info_t *pinfo, const char *ifname,
      269 +ip_get_mtu(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname,
 269  270      void *pval, uint_t psize, uint_t flags)
 270  271  {
 271      -        ill_walk_context_t      ctx;
 272      -        ill_t                   *ill;
 273      -        ip_stack_t              *ipst =  (ip_stack_t *)cbarg;
      272 +        ill_walk_context_t      ctx;
      273 +        ill_t                   *ill;
      274 +        ip_stack_t              *ipst = stack->netstack_ip;
 274  275          boolean_t               isv6;
 275  276          uint32_t                max_mtu, def_mtu;
 276  277          size_t                  nbytes = 0;
 277  278  
 278  279          if (!(flags & (MOD_PROP_DEFAULT|MOD_PROP_POSSIBLE)))
 279  280                  return (ENOTSUP);
 280  281  
 281  282          if (ifname == NULL || ifname[0] == '\0')
 282  283                  return (ENOTSUP);
 283  284  
↓ open down ↓ 61 lines elided ↑ open up ↑
 345  346                                  ire_walk_v6(ip_ire_unbind_walker, NULL,
 346  347                                      ALL_ZONES, ipst);
 347  348                          }
 348  349                          ipcl_walk(conn_ire_revalidate, (void *)B_TRUE, ipst);
 349  350                  }
 350  351          }
 351  352  }
 352  353  
 353  354  /* ARGSUSED */
 354  355  static int
 355      -ip_set_src_multihoming(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
      356 +ip_set_src_multihoming(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 356  357      const char *ifname, const void* pval, uint_t flags)
 357  358  {
 358      -        unsigned long   new_value, old_value;
      359 +        unsigned long   new_value, old_value;
 359  360          boolean_t       isv6;
 360      -        ip_stack_t      *ipst = (ip_stack_t *)cbarg;
      361 +        ip_stack_t      *ipst = stack->netstack_ip;
 361  362          int             err;
 362  363  
 363  364          old_value = pinfo->prop_cur_uval;
 364  365  
 365  366          if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0)
 366  367                  return (err);
 367  368          pinfo->prop_cur_uval = new_value;
 368  369          isv6 = (strcmp(pinfo->mpi_name, "ip6_strict_src_multihoming") == 0);
 369  370          ip_set_src_multihoming_common(new_value, old_value, isv6, ipst);
 370  371          return (0);
 371  372  }
 372  373  
 373  374  
 374  375  /* ARGSUSED */
 375  376  static int
 376      -ip_set_hostmodel(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo,
      377 +ip_set_hostmodel(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo,
 377  378      const char *ifname, const void* pval, uint_t flags)
 378  379  {
 379  380          ip_hostmodel_t  new_value, old_value;
 380      -        ip_stack_t      *ipst = (ip_stack_t *)cbarg;
      381 +        ip_stack_t      *ipst = stack->netstack_ip;
 381  382          uint32_t        old_src_multihoming;
 382  383          int             err;
 383  384          ulong_t         tmp;
 384  385          boolean_t       isv6;
 385  386  
 386  387          old_value = pinfo->prop_cur_uval;
 387  388  
 388  389          if ((err = mod_uint32_value(pval, pinfo, flags, &tmp)) != 0)
 389  390                  return (err);
 390  391          new_value = tmp;
↓ open down ↓ 48 lines elided ↑ open up ↑
 439  440                          break;
 440  441                  default:
 441  442                          return (EINVAL);
 442  443                  }
 443  444          }
 444  445          return (0);
 445  446  }
 446  447  
 447  448  /* ARGSUSED */
 448  449  int
 449      -ip_get_hostmodel(void *cbarg, mod_prop_info_t *pinfo, const char *ifname,
      450 +ip_get_hostmodel(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname,
 450  451      void *pval, uint_t psize, uint_t flags)
 451  452  {
 452  453          boolean_t       isv6 = (pinfo->mpi_proto == MOD_PROTO_IPV6);
 453      -        ip_stack_t      *ipst = cbarg;
      454 +        ip_stack_t      *ipst = stack->netstack_ip;
 454  455          ip_hostmodel_t  hostmodel;
 455  456  
 456  457          if (psize < sizeof (hostmodel))
 457  458                  return (ENOBUFS);
 458  459          bzero(pval, psize);
 459  460          if (!isv6) {
 460  461                  if (ipst->ips_ip_strict_src_multihoming == 0 &&
 461  462                      ipst->ips_ip_strict_dst_multihoming == 0)
 462  463                          hostmodel = IP_WEAK_ES;
 463  464                  else if (ipst->ips_ip_strict_src_multihoming == 1 &&
↓ open down ↓ 472 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX