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>


   3  *
   4  * The contents of this file are subject to the terms of the
   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) 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 /*
  26  * This file contains routines that are used to modify/retrieve protocol or
  27  * interface property values. It also holds all the supported properties for
  28  * both IP interface and protocols in `ipadm_prop_desc_t'. Following protocols
  29  * are supported: IP, IPv4, IPv6, TCP, SCTP, UDP and ICMP.
  30  *
  31  * This file also contains walkers, which walks through the property table and
  32  * calls the callback function, of the form `ipadm_prop_wfunc_t' , for every
  33  * property in the table.
  34  */
  35 
  36 #include <unistd.h>
  37 #include <errno.h>
  38 #include <ctype.h>
  39 #include <fcntl.h>
  40 #include <strings.h>
  41 #include <stdlib.h>
  42 #include <netinet/in.h>


  71 /*
  72  * Callback function to set property values. These functions translate the
  73  * values to a format suitable for kernel consumption, allocates the necessary
  74  * ioctl buffers and then invokes ioctl().
  75  */
  76 static ipadm_pd_setf_t  i_ipadm_set_prop, i_ipadm_set_mtu,
  77                         i_ipadm_set_ifprop_flags,
  78                         i_ipadm_set_metric, i_ipadm_set_usesrc,
  79                         i_ipadm_set_forwarding, i_ipadm_set_eprivport,
  80                         i_ipadm_set_ecnsack, i_ipadm_set_hostmodel;
  81 
  82 /* array of protocols we support */
  83 static int protocols[] = { MOD_PROTO_IP, MOD_PROTO_RAWIP,
  84                             MOD_PROTO_TCP, MOD_PROTO_UDP,
  85                             MOD_PROTO_SCTP };
  86 
  87 /*
  88  * Supported IP protocol properties.
  89  */
  90 static ipadm_prop_desc_t ipadm_ip_prop_table[] = {
  91         { "arp", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
  92             i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
  93             i_ipadm_get_ifprop_flags },
  94 
  95         { "forwarding", IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV4, 0,
  96             i_ipadm_set_forwarding, i_ipadm_get_onoff,
  97             i_ipadm_get_forwarding },
  98 
  99         { "metric", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 100             i_ipadm_set_metric, NULL, i_ipadm_get_metric },
 101 
 102         { "mtu", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 103             i_ipadm_set_mtu, i_ipadm_get_mtu, i_ipadm_get_mtu },
 104 
 105         { "exchange_routes", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 106             i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
 107             i_ipadm_get_ifprop_flags },
 108 
 109         { "usesrc", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 110             i_ipadm_set_usesrc, NULL, i_ipadm_get_usesrc },
 111 
 112         { "ttl", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0,
 113             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 114 
 115         { "forwarding", IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV6, 0,
 116             i_ipadm_set_forwarding, i_ipadm_get_onoff,
 117             i_ipadm_get_forwarding },
 118 
 119         { "hoplimit", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0,
 120             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 121 
 122         { "metric", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 123             i_ipadm_set_metric, NULL, i_ipadm_get_metric },
 124 
 125         { "mtu", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 126             i_ipadm_set_mtu, i_ipadm_get_mtu, i_ipadm_get_mtu },
 127 
 128         { "nud", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 129             i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
 130             i_ipadm_get_ifprop_flags },
 131 
 132         { "exchange_routes", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 133             i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
 134             i_ipadm_get_ifprop_flags },
 135 
 136         { "usesrc", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 137             i_ipadm_set_usesrc, NULL, i_ipadm_get_usesrc },
 138 
 139         { "hostmodel", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0,
 140             i_ipadm_set_hostmodel, i_ipadm_get_hostmodel,
 141             i_ipadm_get_hostmodel },
 142 
 143         { "hostmodel", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0,
 144             i_ipadm_set_hostmodel, i_ipadm_get_hostmodel,
 145             i_ipadm_get_hostmodel },
 146 
 147         { NULL, 0, 0, 0, NULL, NULL, NULL }
 148 };
 149 
 150 /* possible values for TCP properties `ecn' and `sack' */
 151 static const char *ecn_sack_vals[] = {"never", "passive", "active", NULL};
 152 
 153 /* Supported TCP protocol properties */
 154 static ipadm_prop_desc_t ipadm_tcp_prop_table[] = {
 155         { "ecn", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 156             i_ipadm_set_ecnsack, i_ipadm_get_ecnsack, i_ipadm_get_ecnsack },
 157 
 158         { "extra_priv_ports", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP,
 159             IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop,
 160             i_ipadm_get_prop },
 161 
 162         { "largest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 163             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 164 
 165         { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 166             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 167 
 168         { "sack", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,



 169             i_ipadm_set_ecnsack, i_ipadm_get_ecnsack, i_ipadm_get_ecnsack },
 170 
 171         { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 172             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 173 
 174         { "smallest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 175             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 176 
 177         { "smallest_nonpriv_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 178             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 179 
 180         { NULL, 0, 0, 0, NULL, NULL, NULL }
 181 };
 182 
 183 /* Supported UDP protocol properties */
 184 static ipadm_prop_desc_t ipadm_udp_prop_table[] = {
 185         { "extra_priv_ports", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP,
 186             IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop,
 187             i_ipadm_get_prop },
 188 
 189         { "largest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 190             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 191 
 192         { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 193             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 194 
 195         { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 196             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 197 
 198         { "smallest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 199             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 200 
 201         { "smallest_nonpriv_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 202             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 203 
 204         { NULL, 0, 0, 0, NULL, NULL, NULL }



 205 };
 206 
 207 /* Supported SCTP protocol properties */
 208 static ipadm_prop_desc_t ipadm_sctp_prop_table[] = {
 209         { "extra_priv_ports", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP,
 210             IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop,
 211             i_ipadm_get_prop },
 212 
 213         { "largest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 214             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 215 
 216         { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 217             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 218 
 219         { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 220             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 221 
 222         { "smallest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 223             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 224 
 225         { "smallest_nonpriv_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 226             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 227 
 228         { NULL, 0, 0, 0, NULL, NULL, NULL }



 229 };
 230 
 231 /* Supported ICMP protocol properties */
 232 static ipadm_prop_desc_t ipadm_icmp_prop_table[] = {
 233         { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0,
 234             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 235 
 236         { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0,
 237             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 238 
 239         { NULL, 0, 0, 0, NULL, NULL, NULL }



 240 };
 241 
 242 /*
 243  * A dummy private property structure, used while handling private
 244  * protocol properties (properties not yet supported by libipadm).
 245  */
 246 static ipadm_prop_desc_t        ipadm_privprop =\
 247         { NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_NONE, 0,
 248             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop };
 249 
 250 /*
 251  * Returns the property description table, for the given protocol
 252  */
 253 static ipadm_prop_desc_t *
 254 i_ipadm_get_propdesc_table(uint_t proto)
 255 {
 256         switch (proto) {
 257         case MOD_PROTO_IP:
 258         case MOD_PROTO_IPV4:
 259         case MOD_PROTO_IPV6:
 260                 return (ipadm_ip_prop_table);
 261         case MOD_PROTO_RAWIP:
 262                 return (ipadm_icmp_prop_table);
 263         case MOD_PROTO_TCP:
 264                 return (ipadm_tcp_prop_table);
 265         case MOD_PROTO_UDP:
 266                 return (ipadm_udp_prop_table);
 267         case MOD_PROTO_SCTP:
 268                 return (ipadm_sctp_prop_table);
 269         }
 270 
 271         return (NULL);
 272 }
 273 
 274 static ipadm_prop_desc_t *
 275 i_ipadm_get_prop_desc(const char *pname, uint_t proto, int *errp)
 276 {
 277         int             err = 0;
 278         boolean_t       matched_name = B_FALSE;
 279         ipadm_prop_desc_t *ipdp = NULL, *ipdtbl;
 280 
 281         if ((ipdtbl = i_ipadm_get_propdesc_table(proto)) == NULL) {
 282                 err = EINVAL;
 283                 goto ret;
 284         }

 285         for (ipdp = ipdtbl; ipdp->ipd_name != NULL; ipdp++) {
 286                 if (strcmp(pname, ipdp->ipd_name) == 0) {


 287                         matched_name = B_TRUE;
 288                         if (ipdp->ipd_proto == proto)
 289                                 break;
 290                 }
 291         }

 292         if (ipdp->ipd_name == NULL) {
 293                 err = ENOENT;
 294                 /* if we matched name, but failed protocol check */
 295                 if (matched_name)
 296                         err = EPROTO;
 297                 ipdp = NULL;
 298         }
 299 ret:
 300         if (errp != NULL)
 301                 *errp = err;
 302         return (ipdp);
 303 }
 304 
 305 char *
 306 ipadm_proto2str(uint_t proto)
 307 {
 308         switch (proto) {
 309         case MOD_PROTO_IP:
 310                 return ("ip");
 311         case MOD_PROTO_IPV4:




   3  *
   4  * The contents of this file are subject to the terms of the
   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) 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2013 by Delphix. All rights reserved.
  24  */
  25 
  26 /*
  27  * This file contains routines that are used to modify/retrieve protocol or
  28  * interface property values. It also holds all the supported properties for
  29  * both IP interface and protocols in `ipadm_prop_desc_t'. Following protocols
  30  * are supported: IP, IPv4, IPv6, TCP, SCTP, UDP and ICMP.
  31  *
  32  * This file also contains walkers, which walks through the property table and
  33  * calls the callback function, of the form `ipadm_prop_wfunc_t' , for every
  34  * property in the table.
  35  */
  36 
  37 #include <unistd.h>
  38 #include <errno.h>
  39 #include <ctype.h>
  40 #include <fcntl.h>
  41 #include <strings.h>
  42 #include <stdlib.h>
  43 #include <netinet/in.h>


  72 /*
  73  * Callback function to set property values. These functions translate the
  74  * values to a format suitable for kernel consumption, allocates the necessary
  75  * ioctl buffers and then invokes ioctl().
  76  */
  77 static ipadm_pd_setf_t  i_ipadm_set_prop, i_ipadm_set_mtu,
  78                         i_ipadm_set_ifprop_flags,
  79                         i_ipadm_set_metric, i_ipadm_set_usesrc,
  80                         i_ipadm_set_forwarding, i_ipadm_set_eprivport,
  81                         i_ipadm_set_ecnsack, i_ipadm_set_hostmodel;
  82 
  83 /* array of protocols we support */
  84 static int protocols[] = { MOD_PROTO_IP, MOD_PROTO_RAWIP,
  85                             MOD_PROTO_TCP, MOD_PROTO_UDP,
  86                             MOD_PROTO_SCTP };
  87 
  88 /*
  89  * Supported IP protocol properties.
  90  */
  91 static ipadm_prop_desc_t ipadm_ip_prop_table[] = {
  92         { "arp", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
  93             i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
  94             i_ipadm_get_ifprop_flags },
  95 
  96         { "forwarding", NULL, IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV4, 0,
  97             i_ipadm_set_forwarding, i_ipadm_get_onoff,
  98             i_ipadm_get_forwarding },
  99 
 100         { "metric", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 101             i_ipadm_set_metric, NULL, i_ipadm_get_metric },
 102 
 103         { "mtu", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 104             i_ipadm_set_mtu, i_ipadm_get_mtu, i_ipadm_get_mtu },
 105 
 106         { "exchange_routes", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 107             i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
 108             i_ipadm_get_ifprop_flags },
 109 
 110         { "usesrc", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0,
 111             i_ipadm_set_usesrc, NULL, i_ipadm_get_usesrc },
 112 
 113         { "ttl", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0,
 114             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 115 
 116         { "forwarding", NULL, IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV6, 0,
 117             i_ipadm_set_forwarding, i_ipadm_get_onoff,
 118             i_ipadm_get_forwarding },
 119 
 120         { "hoplimit", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0,
 121             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 122 
 123         { "metric", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 124             i_ipadm_set_metric, NULL, i_ipadm_get_metric },
 125 
 126         { "mtu", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 127             i_ipadm_set_mtu, i_ipadm_get_mtu, i_ipadm_get_mtu },
 128 
 129         { "nud", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 130             i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
 131             i_ipadm_get_ifprop_flags },
 132 
 133         { "exchange_routes", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 134             i_ipadm_set_ifprop_flags, i_ipadm_get_onoff,
 135             i_ipadm_get_ifprop_flags },
 136 
 137         { "usesrc", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0,
 138             i_ipadm_set_usesrc, NULL, i_ipadm_get_usesrc },
 139 
 140         { "hostmodel", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0,
 141             i_ipadm_set_hostmodel, i_ipadm_get_hostmodel,
 142             i_ipadm_get_hostmodel },
 143 
 144         { "hostmodel", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0,
 145             i_ipadm_set_hostmodel, i_ipadm_get_hostmodel,
 146             i_ipadm_get_hostmodel },
 147 
 148         { NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
 149 };
 150 
 151 /* possible values for TCP properties `ecn' and `sack' */
 152 static const char *ecn_sack_vals[] = {"never", "passive", "active", NULL};
 153 
 154 /* Supported TCP protocol properties */
 155 static ipadm_prop_desc_t ipadm_tcp_prop_table[] = {
 156         { "ecn", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 157             i_ipadm_set_ecnsack, i_ipadm_get_ecnsack, i_ipadm_get_ecnsack },
 158 
 159         { "extra_priv_ports", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP,
 160             IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop,
 161             i_ipadm_get_prop },
 162 
 163         { "largest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 164             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 165 
 166         { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 167             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 168 
 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,
 173             i_ipadm_set_ecnsack, i_ipadm_get_ecnsack, i_ipadm_get_ecnsack },
 174 
 175         { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 176             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 177 
 178         { "smallest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0,
 179             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 180 
 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 },
 183 
 184         { NULL, NULL, 0, 0, 0, NULL, NULL, NULL }
 185 };
 186 
 187 /* Supported UDP protocol properties */
 188 static ipadm_prop_desc_t ipadm_udp_prop_table[] = {
 189         { "extra_priv_ports", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP,
 190             IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop,
 191             i_ipadm_get_prop },
 192 
 193         { "largest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 194             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 195 
 196         { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 197             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 198 
 199         { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 200             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 201 
 202         { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 203             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 204 
 205         { "smallest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0,
 206             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 207 
 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 }
 212 };
 213 
 214 /* Supported SCTP protocol properties */
 215 static ipadm_prop_desc_t ipadm_sctp_prop_table[] = {
 216         { "extra_priv_ports", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP,
 217             IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop,
 218             i_ipadm_get_prop },
 219 
 220         { "largest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 221             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 222 
 223         { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 224             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 225 
 226         { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 227             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 228 
 229         { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 230             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 231 
 232         { "smallest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0,
 233             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 234 
 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 }
 239 };
 240 
 241 /* Supported ICMP protocol properties */
 242 static ipadm_prop_desc_t ipadm_icmp_prop_table[] = {
 243         { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0,
 244             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 245 
 246         { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0,
 247             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop },
 248 
 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 }
 253 };
 254 
 255 /*
 256  * A dummy private property structure, used while handling private
 257  * protocol properties (properties not yet supported by libipadm).
 258  */
 259 static ipadm_prop_desc_t ipadm_privprop =
 260         { NULL, NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_NONE, 0,
 261             i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop };
 262 
 263 /*
 264  * Returns the property description table, for the given protocol
 265  */
 266 static ipadm_prop_desc_t *
 267 i_ipadm_get_propdesc_table(uint_t proto)
 268 {
 269         switch (proto) {
 270         case MOD_PROTO_IP:
 271         case MOD_PROTO_IPV4:
 272         case MOD_PROTO_IPV6:
 273                 return (ipadm_ip_prop_table);
 274         case MOD_PROTO_RAWIP:
 275                 return (ipadm_icmp_prop_table);
 276         case MOD_PROTO_TCP:
 277                 return (ipadm_tcp_prop_table);
 278         case MOD_PROTO_UDP:
 279                 return (ipadm_udp_prop_table);
 280         case MOD_PROTO_SCTP:
 281                 return (ipadm_sctp_prop_table);
 282         }
 283 
 284         return (NULL);
 285 }
 286 
 287 static ipadm_prop_desc_t *
 288 i_ipadm_get_prop_desc(const char *pname, uint_t proto, int *errp)
 289 {
 290         int             err = 0;
 291         boolean_t       matched_name = B_FALSE;
 292         ipadm_prop_desc_t *ipdp = NULL, *ipdtbl;
 293 
 294         if ((ipdtbl = i_ipadm_get_propdesc_table(proto)) == NULL) {
 295                 err = EINVAL;
 296                 goto ret;
 297         }
 298 
 299         for (ipdp = ipdtbl; ipdp->ipd_name != NULL; ipdp++) {
 300                 if (strcmp(pname, ipdp->ipd_name) == 0 ||
 301                     (ipdp->ipd_old_name != NULL &&
 302                     strcmp(pname, ipdp->ipd_old_name) == 0)) {
 303                         matched_name = B_TRUE;
 304                         if (ipdp->ipd_proto == proto)
 305                                 break;
 306                 }
 307         }
 308 
 309         if (ipdp->ipd_name == NULL) {
 310                 err = ENOENT;
 311                 /* if we matched name, but failed protocol check */
 312                 if (matched_name)
 313                         err = EPROTO;
 314                 ipdp = NULL;
 315         }
 316 ret:
 317         if (errp != NULL)
 318                 *errp = err;
 319         return (ipdp);
 320 }
 321 
 322 char *
 323 ipadm_proto2str(uint_t proto)
 324 {
 325         switch (proto) {
 326         case MOD_PROTO_IP:
 327                 return ("ip");
 328         case MOD_PROTO_IPV4: