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/lib/libipadm/common/ipadm_prop.c
          +++ new/usr/src/lib/libipadm/common/ipadm_prop.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) 2010, Oracle and/or its affiliates. All rights reserved.
       23 + * Copyright (c) 2013 by Delphix. All rights reserved.
  23   24   */
  24   25  
  25   26  /*
  26   27   * This file contains routines that are used to modify/retrieve protocol or
  27   28   * interface property values. It also holds all the supported properties for
  28   29   * both IP interface and protocols in `ipadm_prop_desc_t'. Following protocols
  29   30   * are supported: IP, IPv4, IPv6, TCP, SCTP, UDP and ICMP.
  30   31   *
  31   32   * This file also contains walkers, which walks through the property table and
  32   33   * calls the callback function, of the form `ipadm_prop_wfunc_t' , for every
↓ open down ↓ 48 lines elided ↑ open up ↑
  81   82  
  82   83  /* array of protocols we support */
  83   84  static int protocols[] = { MOD_PROTO_IP, MOD_PROTO_RAWIP,
  84   85                              MOD_PROTO_TCP, MOD_PROTO_UDP,
  85   86                              MOD_PROTO_SCTP };
  86   87  
  87   88  /*
  88   89   * Supported IP protocol properties.
  89   90   */
  90   91  static ipadm_prop_desc_t ipadm_ip_prop_table[] = {
  91      -        { "arp", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
       92 +        { "arp", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
  92   93              i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
  93   94              i_ipadm_get_ifprop_flags },
  94   95  
  95      -        { "forwarding", IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV4, 0,
       96 +        { "forwarding", NULL, IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV4, 0,
  96   97              i_ipadm_set_forwarding, i_ipadm_get_onoff,
  97   98              i_ipadm_get_forwarding },
  98   99  
  99      -        { "metric", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
      100 +        { "metric", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 100  101              i_ipadm_set_metric, NULL, i_ipadm_get_metric },
 101  102  
 102      -        { "mtu", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
      103 +        { "mtu", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 103  104              i_ipadm_set_mtu, i_ipadm_get_mtu, i_ipadm_get_mtu },
 104  105  
 105      -        { "exchange_routes", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
      106 +        { "exchange_routes", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 106  107              i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
 107  108              i_ipadm_get_ifprop_flags },
 108  109  
 109      -        { "usesrc", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
      110 +        { "usesrc", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 110  111              i_ipadm_set_usesrc, NULL, i_ipadm_get_usesrc },
 111  112  
 112      -        { "ttl", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0,
      113 +        { "ttl", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0,
 113  114              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 114  115  
 115      -        { "forwarding", IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV6, 0,
      116 +        { "forwarding", NULL, IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV6, 0,
 116  117              i_ipadm_set_forwarding, i_ipadm_get_onoff,
 117  118              i_ipadm_get_forwarding },
 118  119  
 119      -        { "hoplimit", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0,
      120 +        { "hoplimit", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0,
 120  121              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 121  122  
 122      -        { "metric", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
      123 +        { "metric", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 123  124              i_ipadm_set_metric, NULL, i_ipadm_get_metric },
 124  125  
 125      -        { "mtu", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
      126 +        { "mtu", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 126  127              i_ipadm_set_mtu, i_ipadm_get_mtu, i_ipadm_get_mtu },
 127  128  
 128      -        { "nud", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
      129 +        { "nud", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 129  130              i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
 130  131              i_ipadm_get_ifprop_flags },
 131  132  
 132      -        { "exchange_routes", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
      133 +        { "exchange_routes", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 133  134              i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
 134  135              i_ipadm_get_ifprop_flags },
 135  136  
 136      -        { "usesrc", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
      137 +        { "usesrc", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 137  138              i_ipadm_set_usesrc, NULL, i_ipadm_get_usesrc },
 138  139  
 139      -        { "hostmodel", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0,
      140 +        { "hostmodel", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0,
 140  141              i_ipadm_set_hostmodel, i_ipadm_get_hostmodel,
 141  142              i_ipadm_get_hostmodel },
 142  143  
 143      -        { "hostmodel", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0,
      144 +        { "hostmodel", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0,
 144  145              i_ipadm_set_hostmodel, i_ipadm_get_hostmodel,
 145  146              i_ipadm_get_hostmodel },
 146  147  
 147      -        { NULL, 0, 0, 0, NULL, NULL, NULL }
      148 +        { NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
 148  149  };
 149  150  
 150  151  /* possible values for TCP properties `ecn' and `sack' */
 151  152  static const char *ecn_sack_vals[] = {"never", "passive", "active", NULL};
 152  153  
 153  154  /* Supported TCP protocol properties */
 154  155  static ipadm_prop_desc_t ipadm_tcp_prop_table[] = {
 155      -        { "ecn", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
      156 +        { "ecn", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 156  157              i_ipadm_set_ecnsack, i_ipadm_get_ecnsack, i_ipadm_get_ecnsack },
 157  158  
 158      -        { "extra_priv_ports", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP,
      159 +        { "extra_priv_ports", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP,
 159  160              IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop,
 160  161              i_ipadm_get_prop },
 161  162  
 162      -        { "largest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
      163 +        { "largest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 163  164              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 164  165  
 165      -        { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
      166 +        { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 166  167              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 167  168  
 168      -        { "sack", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
      169 +        { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
      170 +            i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
      171 +
      172 +        { "sack", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 169  173              i_ipadm_set_ecnsack, i_ipadm_get_ecnsack, i_ipadm_get_ecnsack },
 170  174  
 171      -        { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
      175 +        { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 172  176              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 173  177  
 174      -        { "smallest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
      178 +        { "smallest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 175  179              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 176  180  
 177      -        { "smallest_nonpriv_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 178      -            i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
      181 +        { "smallest_nonpriv_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP,
      182 +            0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 179  183  
 180      -        { NULL, 0, 0, 0, NULL, NULL, NULL }
      184 +        { NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
 181  185  };
 182  186  
 183  187  /* Supported UDP protocol properties */
 184  188  static ipadm_prop_desc_t ipadm_udp_prop_table[] = {
 185      -        { "extra_priv_ports", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP,
      189 +        { "extra_priv_ports", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP,
 186  190              IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop,
 187  191              i_ipadm_get_prop },
 188  192  
 189      -        { "largest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
      193 +        { "largest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 190  194              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 191  195  
 192      -        { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
      196 +        { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 193  197              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 194  198  
 195      -        { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
      199 +        { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 196  200              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 197  201  
 198      -        { "smallest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
      202 +        { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 199  203              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 200  204  
 201      -        { "smallest_nonpriv_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
      205 +        { "smallest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 202  206              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 203  207  
 204      -        { NULL, 0, 0, 0, NULL, NULL, NULL }
      208 +        { "smallest_nonpriv_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP,
      209 +            0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
      210 +
      211 +        { NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
 205  212  };
 206  213  
 207  214  /* Supported SCTP protocol properties */
 208  215  static ipadm_prop_desc_t ipadm_sctp_prop_table[] = {
 209      -        { "extra_priv_ports", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP,
      216 +        { "extra_priv_ports", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP,
 210  217              IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop,
 211  218              i_ipadm_get_prop },
 212  219  
 213      -        { "largest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
      220 +        { "largest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 214  221              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 215  222  
 216      -        { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
      223 +        { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 217  224              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 218  225  
 219      -        { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
      226 +        { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 220  227              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 221  228  
 222      -        { "smallest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
      229 +        { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 223  230              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 224  231  
 225      -        { "smallest_nonpriv_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
      232 +        { "smallest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 226  233              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 227  234  
 228      -        { NULL, 0, 0, 0, NULL, NULL, NULL }
      235 +        { "smallest_nonpriv_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP,
      236 +            0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
      237 +
      238 +        { NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
 229  239  };
 230  240  
 231  241  /* Supported ICMP protocol properties */
 232  242  static ipadm_prop_desc_t ipadm_icmp_prop_table[] = {
 233      -        { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0,
      243 +        { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0,
 234  244              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 235  245  
 236      -        { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0,
      246 +        { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0,
 237  247              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 238  248  
 239      -        { NULL, 0, 0, 0, NULL, NULL, NULL }
      249 +        { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0,
      250 +            i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
      251 +
      252 +        { NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
 240  253  };
 241  254  
 242  255  /*
 243  256   * A dummy private property structure, used while handling private
 244  257   * protocol properties (properties not yet supported by libipadm).
 245  258   */
 246      -static ipadm_prop_desc_t        ipadm_privprop =\
 247      -        { NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_NONE, 0,
      259 +static ipadm_prop_desc_t ipadm_privprop =
      260 +        { NULL, NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_NONE, 0,
 248  261              i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop };
 249  262  
 250  263  /*
 251  264   * Returns the property description table, for the given protocol
 252  265   */
 253  266  static ipadm_prop_desc_t *
 254  267  i_ipadm_get_propdesc_table(uint_t proto)
 255  268  {
 256  269          switch (proto) {
 257  270          case MOD_PROTO_IP:
↓ open down ↓ 17 lines elided ↑ open up ↑
 275  288  i_ipadm_get_prop_desc(const char *pname, uint_t proto, int *errp)
 276  289  {
 277  290          int             err = 0;
 278  291          boolean_t       matched_name = B_FALSE;
 279  292          ipadm_prop_desc_t *ipdp = NULL, *ipdtbl;
 280  293  
 281  294          if ((ipdtbl = i_ipadm_get_propdesc_table(proto)) == NULL) {
 282  295                  err = EINVAL;
 283  296                  goto ret;
 284  297          }
      298 +
 285  299          for (ipdp = ipdtbl; ipdp->ipd_name != NULL; ipdp++) {
 286      -                if (strcmp(pname, ipdp->ipd_name) == 0) {
      300 +                if (strcmp(pname, ipdp->ipd_name) == 0 ||
      301 +                    (ipdp->ipd_old_name != NULL &&
      302 +                    strcmp(pname, ipdp->ipd_old_name) == 0)) {
 287  303                          matched_name = B_TRUE;
 288  304                          if (ipdp->ipd_proto == proto)
 289  305                                  break;
 290  306                  }
 291  307          }
      308 +
 292  309          if (ipdp->ipd_name == NULL) {
 293  310                  err = ENOENT;
 294  311                  /* if we matched name, but failed protocol check */
 295  312                  if (matched_name)
 296  313                          err = EPROTO;
 297  314                  ipdp = NULL;
 298  315          }
 299  316  ret:
 300  317          if (errp != NULL)
 301  318                  *errp = err;
↓ open down ↓ 1639 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX