# HG changeset patch # User Sebastien Roy # Date 1375408020 28800 # Node ID f0150cf47680381379ced5a6ea0043aedcb0494a # Parent 971fb4176acf303a4431040f1274f8e345c1afd7 3942 inject sanity into ipadm tcp buffer size properties 3943 _snd_lowat_fraction tcp tunable has no effect Reviewed by: Adam Leventhal Reviewed by: Peng Dai Reviewed by: Dan McDonald Reviewed by: Robert Mustacchi Approved by: Dan McDonald diff -r 971fb4176acf -r f0150cf47680 usr/src/lib/libipadm/common/ipadm_addr.c --- a/usr/src/lib/libipadm/common/ipadm_addr.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/lib/libipadm/common/ipadm_addr.c Thu Aug 01 17:47:00 2013 -0800 @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* @@ -96,30 +97,30 @@ /* address properties description table */ ipadm_prop_desc_t ipadm_addrprop_table[] = { - { "broadcast", IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, + { "broadcast", NULL, IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, NULL, NULL, i_ipadm_get_broadcast }, - { "deprecated", IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, + { "deprecated", NULL, IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, i_ipadm_set_addr_flag, i_ipadm_get_onoff, i_ipadm_get_addr_flag }, - { "prefixlen", IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, + { "prefixlen", NULL, IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, i_ipadm_set_prefixlen, i_ipadm_get_prefixlen, i_ipadm_get_prefixlen }, - { "private", IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, + { "private", NULL, IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, i_ipadm_set_addr_flag, i_ipadm_get_onoff, i_ipadm_get_addr_flag }, - { "transmit", IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, + { "transmit", NULL, IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, i_ipadm_set_addr_flag, i_ipadm_get_onoff, i_ipadm_get_addr_flag }, - { "zone", IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, + { "zone", NULL, IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, i_ipadm_set_zone, NULL, i_ipadm_get_zone }, - { NULL, 0, 0, 0, NULL, NULL, NULL } + { NULL, NULL, 0, 0, 0, NULL, NULL, NULL } }; -static ipadm_prop_desc_t up_addrprop = { "up", IPADMPROP_CLASS_ADDR, +static ipadm_prop_desc_t up_addrprop = { "up", NULL, IPADMPROP_CLASS_ADDR, MOD_PROTO_NONE, 0, NULL, NULL, NULL }; /* @@ -1376,7 +1377,9 @@ int i; for (i = 0; ipadm_addrprop_table[i].ipd_name != NULL; i++) { - if (strcmp(pname, ipadm_addrprop_table[i].ipd_name) == 0) + if (strcmp(pname, ipadm_addrprop_table[i].ipd_name) == 0 || + (ipadm_addrprop_table[i].ipd_old_name != NULL && + strcmp(pname, ipadm_addrprop_table[i].ipd_old_name) == 0)) return (&ipadm_addrprop_table[i]); } return (NULL); diff -r 971fb4176acf -r f0150cf47680 usr/src/lib/libipadm/common/ipadm_prop.c --- a/usr/src/lib/libipadm/common/ipadm_prop.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/lib/libipadm/common/ipadm_prop.c Thu Aug 01 17:47:00 2013 -0800 @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* @@ -88,63 +89,63 @@ * Supported IP protocol properties. */ static ipadm_prop_desc_t ipadm_ip_prop_table[] = { - { "arp", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, + { "arp", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, i_ipadm_set_ifprop_flags, i_ipadm_get_onoff, i_ipadm_get_ifprop_flags }, - { "forwarding", IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV4, 0, + { "forwarding", NULL, IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV4, 0, i_ipadm_set_forwarding, i_ipadm_get_onoff, i_ipadm_get_forwarding }, - { "metric", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, + { "metric", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, i_ipadm_set_metric, NULL, i_ipadm_get_metric }, - { "mtu", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, + { "mtu", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, i_ipadm_set_mtu, i_ipadm_get_mtu, i_ipadm_get_mtu }, - { "exchange_routes", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, + { "exchange_routes", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, i_ipadm_set_ifprop_flags, i_ipadm_get_onoff, i_ipadm_get_ifprop_flags }, - { "usesrc", IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, + { "usesrc", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV4, 0, i_ipadm_set_usesrc, NULL, i_ipadm_get_usesrc }, - { "ttl", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0, + { "ttl", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "forwarding", IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV6, 0, + { "forwarding", NULL, IPADMPROP_CLASS_MODIF, MOD_PROTO_IPV6, 0, i_ipadm_set_forwarding, i_ipadm_get_onoff, i_ipadm_get_forwarding }, - { "hoplimit", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0, + { "hoplimit", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "metric", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, + { "metric", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, i_ipadm_set_metric, NULL, i_ipadm_get_metric }, - { "mtu", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, + { "mtu", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, i_ipadm_set_mtu, i_ipadm_get_mtu, i_ipadm_get_mtu }, - { "nud", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, + { "nud", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, i_ipadm_set_ifprop_flags, i_ipadm_get_onoff, i_ipadm_get_ifprop_flags }, - { "exchange_routes", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, + { "exchange_routes", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, i_ipadm_set_ifprop_flags, i_ipadm_get_onoff, i_ipadm_get_ifprop_flags }, - { "usesrc", IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, + { "usesrc", NULL, IPADMPROP_CLASS_IF, MOD_PROTO_IPV6, 0, i_ipadm_set_usesrc, NULL, i_ipadm_get_usesrc }, - { "hostmodel", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0, + { "hostmodel", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV6, 0, i_ipadm_set_hostmodel, i_ipadm_get_hostmodel, i_ipadm_get_hostmodel }, - { "hostmodel", IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0, + { "hostmodel", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_IPV4, 0, i_ipadm_set_hostmodel, i_ipadm_get_hostmodel, i_ipadm_get_hostmodel }, - { NULL, 0, 0, 0, NULL, NULL, NULL } + { NULL, NULL, 0, 0, 0, NULL, NULL, NULL } }; /* possible values for TCP properties `ecn' and `sack' */ @@ -152,99 +153,111 @@ /* Supported TCP protocol properties */ static ipadm_prop_desc_t ipadm_tcp_prop_table[] = { - { "ecn", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, + { "ecn", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, i_ipadm_set_ecnsack, i_ipadm_get_ecnsack, i_ipadm_get_ecnsack }, - { "extra_priv_ports", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, + { "extra_priv_ports", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop, i_ipadm_get_prop }, - { "largest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, + { "largest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, + { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "sack", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, + { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, + i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, + + { "sack", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, i_ipadm_set_ecnsack, i_ipadm_get_ecnsack, i_ipadm_get_ecnsack }, - { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, + { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "smallest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, + { "smallest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "smallest_nonpriv_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, 0, - i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, + { "smallest_nonpriv_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_TCP, + 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { NULL, 0, 0, 0, NULL, NULL, NULL } + { NULL, NULL, 0, 0, 0, NULL, NULL, NULL } }; /* Supported UDP protocol properties */ static ipadm_prop_desc_t ipadm_udp_prop_table[] = { - { "extra_priv_ports", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, + { "extra_priv_ports", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop, i_ipadm_get_prop }, - { "largest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, + { "largest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, + { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, + i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, + + { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, + { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "smallest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, + { "smallest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "smallest_nonpriv_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, 0, - i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, + { "smallest_nonpriv_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_UDP, + 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { NULL, 0, 0, 0, NULL, NULL, NULL } + { NULL, NULL, 0, 0, 0, NULL, NULL, NULL } }; /* Supported SCTP protocol properties */ static ipadm_prop_desc_t ipadm_sctp_prop_table[] = { - { "extra_priv_ports", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, + { "extra_priv_ports", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, IPADMPROP_MULVAL, i_ipadm_set_eprivport, i_ipadm_get_prop, i_ipadm_get_prop }, - { "largest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, + { "largest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, + { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, + i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, + + { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, + { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "smallest_anon_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, + { "smallest_anon_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "smallest_nonpriv_port", IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, 0, - i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, + { "smallest_nonpriv_port", NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_SCTP, + 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { NULL, 0, 0, 0, NULL, NULL, NULL } + { NULL, NULL, 0, 0, 0, NULL, NULL, NULL } }; /* Supported ICMP protocol properties */ static ipadm_prop_desc_t ipadm_icmp_prop_table[] = { - { "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0, + { "max_buf", "_max_buf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0, + { "recv_buf", "recv_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, - { NULL, 0, 0, 0, NULL, NULL, NULL } + { "send_buf", "send_maxbuf", IPADMPROP_CLASS_MODULE, MOD_PROTO_RAWIP, 0, + i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }, + + { NULL, NULL, 0, 0, 0, NULL, NULL, NULL } }; /* * A dummy private property structure, used while handling private * protocol properties (properties not yet supported by libipadm). */ -static ipadm_prop_desc_t ipadm_privprop =\ - { NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_NONE, 0, +static ipadm_prop_desc_t ipadm_privprop = + { NULL, NULL, IPADMPROP_CLASS_MODULE, MOD_PROTO_NONE, 0, i_ipadm_set_prop, i_ipadm_get_prop, i_ipadm_get_prop }; /* @@ -282,13 +295,17 @@ err = EINVAL; goto ret; } + for (ipdp = ipdtbl; ipdp->ipd_name != NULL; ipdp++) { - if (strcmp(pname, ipdp->ipd_name) == 0) { + if (strcmp(pname, ipdp->ipd_name) == 0 || + (ipdp->ipd_old_name != NULL && + strcmp(pname, ipdp->ipd_old_name) == 0)) { matched_name = B_TRUE; if (ipdp->ipd_proto == proto) break; } } + if (ipdp->ipd_name == NULL) { err = ENOENT; /* if we matched name, but failed protocol check */ diff -r 971fb4176acf -r f0150cf47680 usr/src/lib/libipadm/common/libipadm_impl.h --- a/usr/src/lib/libipadm/common/libipadm_impl.h Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/lib/libipadm/common/libipadm_impl.h Thu Aug 01 17:47:00 2013 -0800 @@ -20,6 +20,7 @@ */ /* * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #ifndef _LIBIPADM_IMPL_H @@ -118,7 +119,8 @@ struct ipadm_prop_desc { char *ipd_name; /* property name */ - uint_t ipd_class; /* prop. class - global/perif/both */ + char *ipd_old_name; /* for backward compatibility */ + uint_t ipd_class; /* prop. class - global/perif/both */ uint_t ipd_proto; /* protocol to which property belongs */ uint_t ipd_flags; /* see below */ ipadm_pd_setf_t *ipd_set; /* set callback function */ diff -r 971fb4176acf -r f0150cf47680 usr/src/man/man1m/ipadm.1m --- a/usr/src/man/man1m/ipadm.1m Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/man/man1m/ipadm.1m Thu Aug 01 17:47:00 2013 -0800 @@ -1,5 +1,6 @@ '\" te .\" Copyright (c) 2012, Joyent, Inc. All Rights Reserved +.\" Copyright (c) 2013 by Delphix. All rights reserved. .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] @@ -1080,10 +1081,18 @@ Largest ephemeral port (SCTP, TCP or UDP) .RE -\fBrecv_maxbuf\fR +\fBmax_buf\fR .ad .RS 4n -Receive buffer size (ICMP, SCTP, TCP or UDP) +Maximum receive or send buffer size (ICMP, SCTP, TCP, or UDP). This also +sets the upper limit for the \fBrecv_buf\fB and \fBsend_buf\fB properties. +.RE + +\fBrecv_buf\fR +.ad +.RS 4n +Default receive buffer size (ICMP, SCTP, TCP, or UDP). The maximum value for +this property is controlled by the \fBmax_buf\fR property. .RE \fBsack\fR @@ -1093,10 +1102,11 @@ Can be "active", "passive" or "never". .RE -\fBsend_maxbuf\fR +\fBsend_buf\fR .ad .RS 4n -Send buffer size (ICMP, SCTP, TCP or UDP) +Default send buffer size (ICMP, SCTP, TCP, or UDP). The maximum value for +this property is controlled by the \fBmax_buf\fR property. .RE \fBsmallest_anon_port\fR diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/ip/icmp.c --- a/usr/src/uts/common/inet/ip/icmp.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/ip/icmp.c Thu Aug 01 17:47:00 2013 -0800 @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* Copyright (c) 1990 Mentat Inc. */ @@ -92,7 +93,6 @@ * it is possible to I_PUSH "icmp", but that results in pushing a passthrough * dummy module. */ - static void icmp_addr_req(queue_t *q, mblk_t *mp); static void icmp_tpi_bind(queue_t *q, mblk_t *mp); static void icmp_bind_proto(icmp_t *icmp); @@ -213,6 +213,22 @@ (XPG4_1|SENDZERO) /* PROVIDER_flag */ }; +static int +icmp_set_buf_prop(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, + const char *ifname, const void *pval, uint_t flags) +{ + return (mod_set_buf_prop(stack->netstack_icmp->is_propinfo_tbl, + stack, cr, pinfo, ifname, pval, flags)); +} + +static int +icmp_get_buf_prop(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, + void *val, uint_t psize, uint_t flags) +{ + return (mod_get_buf_prop(stack->netstack_icmp->is_propinfo_tbl, stack, + pinfo, ifname, val, psize, flags)); +} + /* * All of these are alterable, within the min/max values given, at run time. * @@ -238,21 +254,21 @@ mod_set_boolean, mod_get_boolean, {B_TRUE}, {B_TRUE} }, - { "send_maxbuf", MOD_PROTO_RAWIP, - mod_set_uint32, mod_get_uint32, + { "send_buf", MOD_PROTO_RAWIP, + icmp_set_buf_prop, icmp_get_buf_prop, {4096, 65536, 8192}, {8192} }, { "_xmit_lowat", MOD_PROTO_RAWIP, mod_set_uint32, mod_get_uint32, {0, 65536, 1024}, {1024} }, - { "recv_maxbuf", MOD_PROTO_RAWIP, - mod_set_uint32, mod_get_uint32, + { "recv_buf", MOD_PROTO_RAWIP, + icmp_set_buf_prop, icmp_get_buf_prop, {4096, 65536, 8192}, {8192} }, - { "_max_buf", MOD_PROTO_RAWIP, + { "max_buf", MOD_PROTO_RAWIP, mod_set_uint32, mod_get_uint32, - {65536, 1024*1024*1024, 256*1024}, {256 * 1024} }, + {65536, ULP_MAX_BUF, 256*1024}, {256*1024} }, { "_pmtu_discovery", MOD_PROTO_RAWIP, mod_set_boolean, mod_get_boolean, diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/ip/ip_if.c --- a/usr/src/uts/common/inet/ip/ip_if.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/ip/ip_if.c Thu Aug 01 17:47:00 2013 -0800 @@ -21,6 +21,7 @@ /* * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1990 Mentat Inc. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* @@ -8854,14 +8855,9 @@ mod_ioc_prop_t *pioc; mod_prop_info_t *ptbl = NULL, *pinfo = NULL; ip_stack_t *ipst; - icmp_stack_t *is; - tcp_stack_t *tcps; - sctp_stack_t *sctps; - udp_stack_t *us; netstack_t *stack; - void *cbarg; cred_t *cr; - boolean_t set; + boolean_t set; int err; ASSERT(q->q_next == NULL); @@ -8880,40 +8876,26 @@ case MOD_PROTO_IPV4: case MOD_PROTO_IPV6: ptbl = ipst->ips_propinfo_tbl; - cbarg = ipst; break; case MOD_PROTO_RAWIP: - is = stack->netstack_icmp; - ptbl = is->is_propinfo_tbl; - cbarg = is; + ptbl = stack->netstack_icmp->is_propinfo_tbl; break; case MOD_PROTO_TCP: - tcps = stack->netstack_tcp; - ptbl = tcps->tcps_propinfo_tbl; - cbarg = tcps; + ptbl = stack->netstack_tcp->tcps_propinfo_tbl; break; case MOD_PROTO_UDP: - us = stack->netstack_udp; - ptbl = us->us_propinfo_tbl; - cbarg = us; + ptbl = stack->netstack_udp->us_propinfo_tbl; break; case MOD_PROTO_SCTP: - sctps = stack->netstack_sctp; - ptbl = sctps->sctps_propinfo_tbl; - cbarg = sctps; + ptbl = stack->netstack_sctp->sctps_propinfo_tbl; break; default: miocnak(q, mp, 0, EINVAL); return; } - /* search for given property in respective protocol propinfo table */ - for (pinfo = ptbl; pinfo->mpi_name != NULL; pinfo++) { - if (strcmp(pinfo->mpi_name, pioc->mpr_name) == 0 && - pinfo->mpi_proto == pioc->mpr_proto) - break; - } - if (pinfo->mpi_name == NULL) { + pinfo = mod_prop_lookup(ptbl, pioc->mpr_name, pioc->mpr_proto); + if (pinfo == NULL) { miocnak(q, mp, 0, ENOENT); return; } @@ -8923,10 +8905,10 @@ cr = msg_getcred(mp, NULL); if (cr == NULL) cr = iocp->ioc_cr; - err = pinfo->mpi_setf(cbarg, cr, pinfo, pioc->mpr_ifname, + err = pinfo->mpi_setf(stack, cr, pinfo, pioc->mpr_ifname, pioc->mpr_val, pioc->mpr_flags); } else if (!set && pinfo->mpi_getf != NULL) { - err = pinfo->mpi_getf(cbarg, pinfo, pioc->mpr_ifname, + err = pinfo->mpi_getf(stack, pinfo, pioc->mpr_ifname, pioc->mpr_val, pioc->mpr_valsize, pioc->mpr_flags); } else { err = EPERM; @@ -8955,7 +8937,7 @@ mblk_t *mp1 = mp->b_cont; char *pname, *pval, *buf; uint_t bufsize, proto; - mod_prop_info_t *ptbl = NULL, *pinfo = NULL; + mod_prop_info_t *pinfo = NULL; ip_stack_t *ipst; int err = 0; @@ -8982,19 +8964,12 @@ return; } - ptbl = ipst->ips_propinfo_tbl; - for (pinfo = ptbl; pinfo->mpi_name != NULL; pinfo++) { - if (strcmp(pinfo->mpi_name, pname) == 0 && - pinfo->mpi_proto == proto) - break; - } - - ASSERT(pinfo->mpi_name != NULL); + pinfo = mod_prop_lookup(ipst->ips_propinfo_tbl, pname, proto); switch (iocp->ioc_cmd) { case ND_GET: - if ((err = pinfo->mpi_getf(ipst, pinfo, NULL, buf, bufsize, - 0)) == 0) { + if ((err = pinfo->mpi_getf(ipst->ips_netstack, pinfo, NULL, buf, + bufsize, 0)) == 0) { miocack(q, mp, iocp->ioc_count, 0); return; } @@ -9010,8 +8985,8 @@ if (!*pval || pval >= (char *)mp1->b_wptr) { err = EINVAL; - } else if ((err = pinfo->mpi_setf(ipst, NULL, pinfo, NULL, - pval, 0)) == 0) { + } else if ((err = pinfo->mpi_setf(ipst->ips_netstack, NULL, + pinfo, NULL, pval, 0)) == 0) { miocack(q, mp, 0, 0); return; } diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/ip/ip_tunables.c --- a/usr/src/uts/common/inet/ip/ip_tunables.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/ip/ip_tunables.c Thu Aug 01 17:47:00 2013 -0800 @@ -20,6 +20,7 @@ */ /* * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* Copyright (c) 1990 Mentat Inc. */ @@ -44,15 +45,15 @@ */ /* ARGSUSED */ static int -ip_set_forwarding(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +ip_set_forwarding(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { char *end; unsigned long new_value; - boolean_t per_ill, isv6; - ill_walk_context_t ctx; - ill_t *ill; - ip_stack_t *ipst = (ip_stack_t *)cbarg; + boolean_t per_ill, isv6; + ill_walk_context_t ctx; + ill_t *ill; + ip_stack_t *ipst = stack->netstack_ip; if (flags & MOD_PROP_DEFAULT) { new_value = pinfo->prop_def_bval; @@ -94,13 +95,13 @@ } static int -ip_get_forwarding(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, +ip_get_forwarding(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, void *pval, uint_t pr_size, uint_t flags) { - boolean_t value; - ill_walk_context_t ctx; - ill_t *ill; - ip_stack_t *ipst = (ip_stack_t *)cbarg; + boolean_t value; + ill_walk_context_t ctx; + ill_t *ill; + ip_stack_t *ipst = stack->netstack_ip; boolean_t get_def = (flags & MOD_PROP_DEFAULT); boolean_t get_perm = (flags & MOD_PROP_PERM); boolean_t isv6; @@ -156,10 +157,10 @@ */ /* ARGSUSED */ int -ip_set_debug(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +ip_set_debug(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { - unsigned long new_value; + unsigned long new_value; int err; if (cr != NULL && secpolicy_net_config(cr, B_FALSE) != 0) @@ -178,7 +179,7 @@ */ /* ARGSUSED */ int -ip_get_debug(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, +ip_get_debug(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, void *pval, uint_t psize, uint_t flags) { boolean_t get_def = (flags & MOD_PROP_DEFAULT); @@ -208,11 +209,11 @@ */ /* ARGSUSED */ static int -ip_set_cgtp_filter(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +ip_set_cgtp_filter(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { unsigned long new_value; - ip_stack_t *ipst = (ip_stack_t *)cbarg; + ip_stack_t *ipst = stack->netstack_ip; char *end; if (flags & MOD_PROP_DEFAULT) { @@ -265,12 +266,12 @@ * (IPV6_MIN_MTU/IP_MIN_MTU) and ill_max_frag. */ int -ip_get_mtu(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, +ip_get_mtu(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, void *pval, uint_t psize, uint_t flags) { - ill_walk_context_t ctx; - ill_t *ill; - ip_stack_t *ipst = (ip_stack_t *)cbarg; + ill_walk_context_t ctx; + ill_t *ill; + ip_stack_t *ipst = stack->netstack_ip; boolean_t isv6; uint32_t max_mtu, def_mtu; size_t nbytes = 0; @@ -352,12 +353,12 @@ /* ARGSUSED */ static int -ip_set_src_multihoming(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +ip_set_src_multihoming(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { - unsigned long new_value, old_value; + unsigned long new_value, old_value; boolean_t isv6; - ip_stack_t *ipst = (ip_stack_t *)cbarg; + ip_stack_t *ipst = stack->netstack_ip; int err; old_value = pinfo->prop_cur_uval; @@ -373,11 +374,11 @@ /* ARGSUSED */ static int -ip_set_hostmodel(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +ip_set_hostmodel(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { ip_hostmodel_t new_value, old_value; - ip_stack_t *ipst = (ip_stack_t *)cbarg; + ip_stack_t *ipst = stack->netstack_ip; uint32_t old_src_multihoming; int err; ulong_t tmp; @@ -446,11 +447,11 @@ /* ARGSUSED */ int -ip_get_hostmodel(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, +ip_get_hostmodel(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, void *pval, uint_t psize, uint_t flags) { boolean_t isv6 = (pinfo->mpi_proto == MOD_PROTO_IPV6); - ip_stack_t *ipst = cbarg; + ip_stack_t *ipst = stack->netstack_ip; ip_hostmodel_t hostmodel; if (psize < sizeof (hostmodel)) diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/sctp/sctp_tunables.c --- a/usr/src/uts/common/inet/sctp/sctp_tunables.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/sctp/sctp_tunables.c Thu Aug 01 17:47:00 2013 -0800 @@ -21,6 +21,7 @@ /* * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #include @@ -42,10 +43,10 @@ */ /* ARGSUSED */ static int -sctp_listener_conf_get(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, - void *val, uint_t psize, uint_t flags) +sctp_listener_conf_get(netstack_t *stack, mod_prop_info_t *pinfo, + const char *ifname, void *val, uint_t psize, uint_t flags) { - sctp_stack_t *sctps = (sctp_stack_t *)cbarg; + sctp_stack_t *sctps = stack->netstack_sctp; sctp_listener_t *sl; char *pval = val; size_t nbytes = 0, tbytes = 0; @@ -86,7 +87,7 @@ */ /* ARGSUSED */ static int -sctp_listener_conf_add(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +sctp_listener_conf_add(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { sctp_listener_t *new_sl; @@ -94,7 +95,7 @@ long lport; long ratio; char *colon; - sctp_stack_t *sctps = (sctp_stack_t *)cbarg; + sctp_stack_t *sctps = stack->netstack_sctp; if (flags & MOD_PROP_DEFAULT) return (ENOTSUP); @@ -135,12 +136,12 @@ */ /* ARGSUSED */ static int -sctp_listener_conf_del(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +sctp_listener_conf_del(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { sctp_listener_t *sl; long lport; - sctp_stack_t *sctps = (sctp_stack_t *)cbarg; + sctp_stack_t *sctps = stack->netstack_sctp; if (flags & MOD_PROP_DEFAULT) return (ENOTSUP); @@ -163,6 +164,22 @@ return (ESRCH); } +static int +sctp_set_buf_prop(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, + const char *ifname, const void *pval, uint_t flags) +{ + return (mod_set_buf_prop(stack->netstack_sctp->sctps_propinfo_tbl, + stack, cr, pinfo, ifname, pval, flags)); +} + +static int +sctp_get_buf_prop(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, + void *val, uint_t psize, uint_t flags) +{ + return (mod_get_buf_prop(stack->netstack_sctp->sctps_propinfo_tbl, + stack, pinfo, ifname, val, psize, flags)); +} + /* * All of these are alterable, within the min/max values given, at run time. * @@ -184,7 +201,7 @@ { "_cwnd_max", MOD_PROTO_SCTP, mod_set_uint32, mod_get_uint32, - {128, (1<<30), 1024*1024}, {1024*1024} }, + {128, ULP_MAX_BUF, 1024*1024}, {1024*1024} }, { "smallest_nonpriv_port", MOD_PROTO_SCTP, mod_set_uint32, mod_get_uint32, @@ -235,24 +252,24 @@ mod_set_uint32, mod_get_uint32, {1024, ULP_MAX_PORT, ULP_MAX_PORT}, {ULP_MAX_PORT} }, - { "send_maxbuf", MOD_PROTO_SCTP, - mod_set_uint32, mod_get_uint32, - {SCTP_XMIT_LOWATER, (1<<30), SCTP_XMIT_HIWATER}, + { "send_buf", MOD_PROTO_SCTP, + sctp_set_buf_prop, sctp_get_buf_prop, + {SCTP_XMIT_LOWATER, ULP_MAX_BUF, SCTP_XMIT_HIWATER}, {SCTP_XMIT_HIWATER} }, { "_xmit_lowat", MOD_PROTO_SCTP, mod_set_uint32, mod_get_uint32, - {SCTP_XMIT_LOWATER, (1<<30), SCTP_XMIT_LOWATER}, + {SCTP_XMIT_LOWATER, ULP_MAX_BUF, SCTP_XMIT_LOWATER}, {SCTP_XMIT_LOWATER} }, - { "recv_maxbuf", MOD_PROTO_SCTP, - mod_set_uint32, mod_get_uint32, - {SCTP_RECV_LOWATER, (1<<30), SCTP_RECV_HIWATER}, + { "recv_buf", MOD_PROTO_SCTP, + sctp_set_buf_prop, sctp_get_buf_prop, + {SCTP_RECV_LOWATER, ULP_MAX_BUF, SCTP_RECV_HIWATER}, {SCTP_RECV_HIWATER} }, - { "_max_buf", MOD_PROTO_SCTP, + { "max_buf", MOD_PROTO_SCTP, mod_set_uint32, mod_get_uint32, - {8192, (1<<30), 1024*1024}, {1024*1024} }, + {8192, ULP_MAX_BUF, 1024*1024}, {1024*1024} }, /* tunable - 20 */ { "_rtt_updates", MOD_PROTO_SCTP, diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/tcp/tcp.c --- a/usr/src/uts/common/inet/tcp/tcp.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/tcp/tcp.c Thu Aug 01 17:47:00 2013 -0800 @@ -23,6 +23,7 @@ * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, Joyent Inc. All rights reserved. * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* Copyright (c) 1990 Mentat Inc. */ @@ -232,11 +233,6 @@ */ uint_t tcp_free_list_max_cnt = 0; -#define TCP_XMIT_LOWATER 4096 -#define TCP_XMIT_HIWATER 49152 -#define TCP_RECV_LOWATER 2048 -#define TCP_RECV_HIWATER 128000 - #define TIDUSZ 4096 /* transport interface data unit size */ /* @@ -2718,7 +2714,12 @@ connp->conn_rcvbuf = tcps->tcps_recv_hiwat; connp->conn_sndbuf = tcps->tcps_xmit_hiwat; - connp->conn_sndlowat = tcps->tcps_xmit_lowat; + if (tcps->tcps_snd_lowat_fraction != 0) { + connp->conn_sndlowat = connp->conn_sndbuf / + tcps->tcps_snd_lowat_fraction; + } else { + connp->conn_sndlowat = tcps->tcps_xmit_lowat; + } connp->conn_so_type = SOCK_STREAM; connp->conn_wroff = connp->conn_ht_iphc_allocated + tcps->tcps_wroff_xtra; diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/tcp/tcp_tunables.c --- a/usr/src/uts/common/inet/tcp/tcp_tunables.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/tcp/tcp_tunables.c Thu Aug 01 17:47:00 2013 -0800 @@ -22,6 +22,7 @@ * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, Joyent Inc. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* Copyright (c) 1990 Mentat Inc. */ @@ -37,28 +38,22 @@ /* Max of the above */ #define TCP_MSS_MAX TCP_MSS_MAX_IPV4 -#define TCP_XMIT_LOWATER 4096 -#define TCP_XMIT_HIWATER 49152 -#define TCP_RECV_LOWATER 2048 -#define TCP_RECV_HIWATER 128000 - /* * Set the RFC 1948 pass phrase */ /* ARGSUSED */ static int -tcp_set_1948phrase(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +tcp_set_1948phrase(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pr_val, uint_t flags) { - tcp_stack_t *tcps = (tcp_stack_t *)cbarg; - if (flags & MOD_PROP_DEFAULT) return (ENOTSUP); /* * Basically, value contains a new pass phrase. Pass it along! */ - tcp_iss_key_init((uint8_t *)pr_val, strlen(pr_val), tcps); + tcp_iss_key_init((uint8_t *)pr_val, strlen(pr_val), + stack->netstack_tcp); return (0); } @@ -67,10 +62,10 @@ */ /* ARGSUSED */ static int -tcp_listener_conf_get(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, - void *val, uint_t psize, uint_t flags) +tcp_listener_conf_get(netstack_t *stack, mod_prop_info_t *pinfo, + const char *ifname, void *val, uint_t psize, uint_t flags) { - tcp_stack_t *tcps = (tcp_stack_t *)cbarg; + tcp_stack_t *tcps = stack->netstack_tcp; tcp_listener_t *tl; char *pval = val; size_t nbytes = 0, tbytes = 0; @@ -111,7 +106,7 @@ */ /* ARGSUSED */ static int -tcp_listener_conf_add(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +tcp_listener_conf_add(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { tcp_listener_t *new_tl; @@ -119,7 +114,7 @@ long lport; long ratio; char *colon; - tcp_stack_t *tcps = (tcp_stack_t *)cbarg; + tcp_stack_t *tcps = stack->netstack_tcp; if (flags & MOD_PROP_DEFAULT) return (ENOTSUP); @@ -160,12 +155,12 @@ */ /* ARGSUSED */ static int -tcp_listener_conf_del(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +tcp_listener_conf_del(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { tcp_listener_t *tl; long lport; - tcp_stack_t *tcps = (tcp_stack_t *)cbarg; + tcp_stack_t *tcps = stack->netstack_tcp; if (flags & MOD_PROP_DEFAULT) return (ENOTSUP); @@ -188,17 +183,33 @@ return (ESRCH); } +static int +tcp_set_buf_prop(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, + const char *ifname, const void *pval, uint_t flags) +{ + return (mod_set_buf_prop(stack->netstack_tcp->tcps_propinfo_tbl, stack, + cr, pinfo, ifname, pval, flags)); +} + +static int +tcp_get_buf_prop(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, + void *val, uint_t psize, uint_t flags) +{ + return (mod_get_buf_prop(stack->netstack_tcp->tcps_propinfo_tbl, stack, + pinfo, ifname, val, psize, flags)); +} + /* * Special checkers for smallest/largest anonymous port so they don't * ever happen to be (largest < smallest). */ /* ARGSUSED */ static int -tcp_smallest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +tcp_smallest_anon_set(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void *pval, uint_t flags) { unsigned long new_value; - tcp_stack_t *tcps = (tcp_stack_t *)cbarg; + tcp_stack_t *tcps = stack->netstack_tcp; int err; if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0) @@ -212,11 +223,11 @@ /* ARGSUSED */ static int -tcp_largest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +tcp_largest_anon_set(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void *pval, uint_t flags) { unsigned long new_value; - tcp_stack_t *tcps = (tcp_stack_t *)cbarg; + tcp_stack_t *tcps = stack->netstack_tcp; int err; if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0) @@ -258,7 +269,7 @@ { "_cwnd_max", MOD_PROTO_TCP, mod_set_uint32, mod_get_uint32, - {128, (1<<30), 1024*1024}, {1024*1024} }, + {128, ULP_MAX_BUF, 1024*1024}, {1024*1024} }, { "_debug", MOD_PROTO_TCP, mod_set_uint32, mod_get_uint32, @@ -338,7 +349,7 @@ { "_snd_lowat_fraction", MOD_PROTO_TCP, mod_set_uint32, mod_get_uint32, - {0, 16, 0}, {0} }, + {0, 16, 10}, {10} }, { "_dupack_fast_retransmit", MOD_PROTO_TCP, mod_set_uint32, mod_get_uint32, @@ -357,20 +368,20 @@ {1024, ULP_MAX_PORT, ULP_MAX_PORT}, {ULP_MAX_PORT} }, - { "send_maxbuf", MOD_PROTO_TCP, - mod_set_uint32, mod_get_uint32, - {TCP_XMIT_LOWATER, (1<<30), TCP_XMIT_HIWATER}, + { "send_buf", MOD_PROTO_TCP, + tcp_set_buf_prop, tcp_get_buf_prop, + {TCP_XMIT_LOWATER, ULP_MAX_BUF, TCP_XMIT_HIWATER}, {TCP_XMIT_HIWATER} }, /* tunable - 30 */ { "_xmit_lowat", MOD_PROTO_TCP, mod_set_uint32, mod_get_uint32, - {TCP_XMIT_LOWATER, (1<<30), TCP_XMIT_LOWATER}, + {TCP_XMIT_LOWATER, ULP_MAX_BUF, TCP_XMIT_LOWATER}, {TCP_XMIT_LOWATER} }, - { "recv_maxbuf", MOD_PROTO_TCP, - mod_set_uint32, mod_get_uint32, - {TCP_RECV_LOWATER, (1<<30), TCP_RECV_HIWATER}, + { "recv_buf", MOD_PROTO_TCP, + tcp_set_buf_prop, tcp_get_buf_prop, + {TCP_RECV_LOWATER, ULP_MAX_BUF, TCP_RECV_HIWATER}, {TCP_RECV_HIWATER} }, { "_recv_hiwat_minmss", MOD_PROTO_TCP, @@ -382,9 +393,9 @@ {1*SECONDS, 2*HOURS, 60*SECONDS}, {60*SECONDS} }, - { "_max_buf", MOD_PROTO_TCP, + { "max_buf", MOD_PROTO_TCP, mod_set_uint32, mod_get_uint32, - {8192, (1<<30), 1024*1024}, {1024*1024} }, + {8192, ULP_MAX_BUF, 1024*1024}, {1024*1024} }, /* * Question: What default value should I set for tcp_strong_iss? diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/tcp_impl.h --- a/usr/src/uts/common/inet/tcp_impl.h Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/tcp_impl.h Thu Aug 01 17:47:00 2013 -0800 @@ -22,6 +22,7 @@ * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, Joyent Inc. All rights reserved. * Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #ifndef _INET_TCP_IMPL_H @@ -54,6 +55,17 @@ extern sock_downcalls_t sock_tcp_downcalls; /* + * Note that by default, the _snd_lowat_fraction tunable controls the value of + * the transmit low water mark. TCP_XMIT_LOWATER (and thus the _xmit_lowat + * property) is only used if the administrator has disabled _snd_lowat_fraction + * by setting it to 0. + */ +#define TCP_XMIT_LOWATER 4096 +#define TCP_XMIT_HIWATER 49152 +#define TCP_RECV_LOWATER 2048 +#define TCP_RECV_HIWATER 128000 + +/* * Bind hash list size and has function. It has to be a power of 2 for * hashing. */ diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/tunables.c --- a/usr/src/uts/common/inet/tunables.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/tunables.c Thu Aug 01 17:47:00 2013 -0800 @@ -21,6 +21,7 @@ /* * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1990 Mentat Inc. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #include @@ -38,6 +39,24 @@ #include #include +mod_prop_info_t * +mod_prop_lookup(mod_prop_info_t ptbl[], const char *prop_name, uint_t proto) +{ + mod_prop_info_t *pinfo; + + /* + * Walk the ptbl array looking for a property that has the requested + * name and protocol number. Note that we assume that all protocol + * tables are terminated by an entry with a NULL property name. + */ + for (pinfo = ptbl; pinfo->mpi_name != NULL; pinfo++) { + if (strcmp(pinfo->mpi_name, prop_name) == 0 && + pinfo->mpi_proto == proto) + return (pinfo); + } + return (NULL); +} + static int prop_perm2const(mod_prop_info_t *pinfo) { @@ -54,11 +73,11 @@ */ /* ARGSUSED */ int -mod_set_boolean(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +mod_set_boolean(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { - char *end; - unsigned long new_value; + char *end; + unsigned long new_value; if (flags & MOD_PROP_DEFAULT) { pinfo->prop_cur_bval = pinfo->prop_def_bval; @@ -79,7 +98,7 @@ */ /* ARGSUSED */ int -mod_get_boolean(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, +mod_get_boolean(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, void *pval, uint_t psize, uint_t flags) { boolean_t get_def = (flags & MOD_PROP_DEFAULT); @@ -128,7 +147,7 @@ */ /* ARGSUSED */ int -mod_set_uint32(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +mod_set_uint32(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void *pval, uint_t flags) { unsigned long new_value; @@ -145,12 +164,12 @@ */ /* ARGSUSED */ int -mod_set_aligned(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +mod_set_aligned(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* pval, uint_t flags) { int err; - if ((err = mod_set_uint32(cbarg, cr, pinfo, ifname, pval, flags)) != 0) + if ((err = mod_set_uint32(stack, cr, pinfo, ifname, pval, flags)) != 0) return (err); /* if required, align the value to multiple of 8 */ @@ -168,7 +187,7 @@ */ /* ARGSUSED */ int -mod_get_uint32(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, +mod_get_uint32(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, void *pval, uint_t psize, uint_t flags) { boolean_t get_def = (flags & MOD_PROP_DEFAULT); @@ -192,21 +211,86 @@ } /* + * The range of the buffer size properties has a static lower bound configured + * in the property info structure of the property itself, and a dynamic upper + * bound. The upper bound is the current value of the "max_buf" property + * in the appropriate protocol property table. + */ +static void +mod_get_buf_prop_range(mod_prop_info_t ptbl[], mod_prop_info_t *pinfo, + uint32_t *min, uint32_t *max) +{ + mod_prop_info_t *maxbuf_pinfo = mod_prop_lookup(ptbl, "max_buf", + pinfo->mpi_proto); + + *min = pinfo->prop_min_uval; + *max = maxbuf_pinfo->prop_cur_uval; +} + +/* + * Modifies the value of the buffer size property to its default value or to + * the value specified by the user. This is similar to mod_set_uint32() except + * that the value has a dynamically bounded range (see mod_get_buf_prop_range() + * for details). + */ +/* ARGSUSED */ +int +mod_set_buf_prop(mod_prop_info_t ptbl[], netstack_t *stack, cred_t *cr, + mod_prop_info_t *pinfo, const char *ifname, const void *pval, uint_t flags) +{ + unsigned long new_value; + char *end; + uint32_t min, max; + + if (flags & MOD_PROP_DEFAULT) { + pinfo->prop_cur_uval = pinfo->prop_def_uval; + return (0); + } + + if (ddi_strtoul(pval, &end, 10, &new_value) != 0 || *end != '\0') + return (EINVAL); + + mod_get_buf_prop_range(ptbl, pinfo, &min, &max); + if (new_value < min || new_value > max) + return (ERANGE); + + pinfo->prop_cur_uval = new_value; + return (0); +} + +/* + * Retrieves property permissions, default value, current value, or possible + * values for buffer size properties. While these properties have integer + * values, they have a dynamic range (see mod_get_buf_prop_range() for + * details). As such, they need to be handled differently. + */ +int +mod_get_buf_prop(mod_prop_info_t ptbl[], netstack_t *stack, + mod_prop_info_t *pinfo, const char *ifname, void *pval, uint_t psize, + uint_t flags) +{ + size_t nbytes; + uint32_t min, max; + + if (flags & MOD_PROP_POSSIBLE) { + mod_get_buf_prop_range(ptbl, pinfo, &min, &max); + nbytes = snprintf(pval, psize, "%u-%u", min, max); + return (nbytes < psize ? 0 : ENOBUFS); + } + return (mod_get_uint32(stack, pinfo, ifname, pval, psize, flags)); +} + +/* * Implements /sbin/ndd -get /dev/ip ?, for all the modules. Needed for * backward compatibility with /sbin/ndd. */ /* ARGSUSED */ int -mod_get_allprop(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, +mod_get_allprop(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, void *val, uint_t psize, uint_t flags) { char *pval = val; mod_prop_info_t *ptbl, *prop; - ip_stack_t *ipst; - tcp_stack_t *tcps; - sctp_stack_t *sctps; - udp_stack_t *us; - icmp_stack_t *is; uint_t size; size_t nbytes = 0, tbytes = 0; @@ -217,24 +301,19 @@ case MOD_PROTO_IP: case MOD_PROTO_IPV4: case MOD_PROTO_IPV6: - ipst = (ip_stack_t *)cbarg; - ptbl = ipst->ips_propinfo_tbl; + ptbl = stack->netstack_ip->ips_propinfo_tbl; break; case MOD_PROTO_RAWIP: - is = (icmp_stack_t *)cbarg; - ptbl = is->is_propinfo_tbl; + ptbl = stack->netstack_icmp->is_propinfo_tbl; break; case MOD_PROTO_TCP: - tcps = (tcp_stack_t *)cbarg; - ptbl = tcps->tcps_propinfo_tbl; + ptbl = stack->netstack_tcp->tcps_propinfo_tbl; break; case MOD_PROTO_UDP: - us = (udp_stack_t *)cbarg; - ptbl = us->us_propinfo_tbl; + ptbl = stack->netstack_udp->us_propinfo_tbl; break; case MOD_PROTO_SCTP: - sctps = (sctp_stack_t *)cbarg; - ptbl = sctps->sctps_propinfo_tbl; + ptbl = stack->netstack_sctp->sctps_propinfo_tbl; break; default: return (EINVAL); @@ -264,7 +343,7 @@ */ /* ARGSUSED */ int -mod_set_extra_privports(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +mod_set_extra_privports(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void* val, uint_t flags) { uint_t proto = pinfo->mpi_proto; @@ -293,19 +372,19 @@ switch (proto) { case MOD_PROTO_TCP: - tcps = (tcp_stack_t *)cbarg; + tcps = stack->netstack_tcp; lock = &tcps->tcps_epriv_port_lock; ports = tcps->tcps_g_epriv_ports; nports = tcps->tcps_g_num_epriv_ports; break; case MOD_PROTO_UDP: - us = (udp_stack_t *)cbarg; + us = stack->netstack_udp; lock = &us->us_epriv_port_lock; ports = us->us_epriv_ports; nports = us->us_num_epriv_ports; break; case MOD_PROTO_SCTP: - sctps = (sctp_stack_t *)cbarg; + sctps = stack->netstack_sctp; lock = &sctps->sctps_epriv_port_lock; ports = sctps->sctps_g_epriv_ports; nports = sctps->sctps_g_num_epriv_ports; @@ -382,8 +461,8 @@ */ /* ARGSUSED */ int -mod_get_extra_privports(void *cbarg, mod_prop_info_t *pinfo, const char *ifname, - void *val, uint_t psize, uint_t flags) +mod_get_extra_privports(netstack_t *stack, mod_prop_info_t *pinfo, + const char *ifname, void *val, uint_t psize, uint_t flags) { uint_t proto = pinfo->mpi_proto; tcp_stack_t *tcps; @@ -411,17 +490,17 @@ switch (proto) { case MOD_PROTO_TCP: - tcps = (tcp_stack_t *)cbarg; + tcps = stack->netstack_tcp; ports = tcps->tcps_g_epriv_ports; nports = tcps->tcps_g_num_epriv_ports; break; case MOD_PROTO_UDP: - us = (udp_stack_t *)cbarg; + us = stack->netstack_udp; ports = us->us_epriv_ports; nports = us->us_num_epriv_ports; break; case MOD_PROTO_SCTP: - sctps = (sctp_stack_t *)cbarg; + sctps = stack->netstack_sctp; ports = sctps->sctps_g_epriv_ports; nports = sctps->sctps_g_num_epriv_ports; break; diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/tunables.h --- a/usr/src/uts/common/inet/tunables.h Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/tunables.h Thu Aug 01 17:47:00 2013 -0800 @@ -21,6 +21,7 @@ /* * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1990 Mentat Inc. + * Copyright (c) 2013 by Delphix. All rights reserved. */ #ifndef _INET_TUNABLES_H @@ -88,10 +89,10 @@ typedef struct mod_prop_info_s mod_prop_info_t; /* set/get property callback functions */ -typedef int mod_prop_setf_t(void *, cred_t *, mod_prop_info_t *, +typedef int mod_prop_setf_t(netstack_t *, cred_t *, mod_prop_info_t *, const char *, const void *, uint_t); -typedef int mod_prop_getf_t(void *, mod_prop_info_t *, const char *, - void *val, uint_t, uint_t); +typedef int mod_prop_getf_t(netstack_t *, mod_prop_info_t *, const char *, + void *, uint_t, uint_t); typedef struct mod_propval_uint32_s { uint32_t mod_propval_umin; @@ -149,6 +150,8 @@ #define ULP_DEF_EPRIV_PORT1 2049 #define ULP_DEF_EPRIV_PORT2 4045 +#define ULP_MAX_BUF (1<<30) /* Largest possible send/receive buffer */ + /* generic function to set/get global module properties */ extern mod_prop_setf_t mod_set_boolean, mod_set_uint32, mod_set_aligned, mod_set_extra_privports; @@ -156,8 +159,14 @@ extern mod_prop_getf_t mod_get_boolean, mod_get_uint32, mod_get_allprop, mod_get_extra_privports; -extern int mod_uint32_value(const void *, mod_prop_info_t *, uint_t, - unsigned long *); +extern int mod_uint32_value(const void *, mod_prop_info_t *, + uint_t, unsigned long *); +extern mod_prop_info_t *mod_prop_lookup(mod_prop_info_t[], const char *, + uint_t); +extern int mod_set_buf_prop(mod_prop_info_t[], netstack_t *, + cred_t *cr, mod_prop_info_t *, const char *, const void *, uint_t); +extern int mod_get_buf_prop(mod_prop_info_t[], netstack_t *, + mod_prop_info_t *, const char *, void *, uint_t, uint_t); #endif /* _KERNEL */ diff -r 971fb4176acf -r f0150cf47680 usr/src/uts/common/inet/udp/udp_tunables.c --- a/usr/src/uts/common/inet/udp/udp_tunables.c Tue Mar 19 00:16:09 2013 +0000 +++ b/usr/src/uts/common/inet/udp/udp_tunables.c Thu Aug 01 17:47:00 2013 -0800 @@ -21,6 +21,7 @@ /* * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2013 Nexenta Systems, Inc. All rights reserved. + * Copyright (c) 2013 by Delphix. All rights reserved. */ /* Copyright (c) 1990 Mentat Inc. */ @@ -29,17 +30,33 @@ #include #include +static int +udp_set_buf_prop(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, + const char *ifname, const void *pval, uint_t flags) +{ + return (mod_set_buf_prop(stack->netstack_udp->us_propinfo_tbl, stack, + cr, pinfo, ifname, pval, flags)); +} + +static int +udp_get_buf_prop(netstack_t *stack, mod_prop_info_t *pinfo, const char *ifname, + void *val, uint_t psize, uint_t flags) +{ + return (mod_get_buf_prop(stack->netstack_udp->us_propinfo_tbl, stack, + pinfo, ifname, val, psize, flags)); +} + /* * Special checkers for smallest/largest anonymous port so they don't * ever happen to be (largest < smallest). */ /* ARGSUSED */ static int -udp_smallest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +udp_smallest_anon_set(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void *pval, uint_t flags) { unsigned long new_value; - udp_stack_t *us = (udp_stack_t *)cbarg; + udp_stack_t *us = stack->netstack_udp; int err; if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0) @@ -53,11 +70,11 @@ /* ARGSUSED */ static int -udp_largest_anon_set(void *cbarg, cred_t *cr, mod_prop_info_t *pinfo, +udp_largest_anon_set(netstack_t *stack, cred_t *cr, mod_prop_info_t *pinfo, const char *ifname, const void *pval, uint_t flags) { unsigned long new_value; - udp_stack_t *us = (udp_stack_t *)cbarg; + udp_stack_t *us = stack->netstack_udp; int err; if ((err = mod_uint32_value(pval, pinfo, flags, &new_value)) != 0) @@ -105,25 +122,25 @@ udp_largest_anon_set, mod_get_uint32, {1024, ULP_MAX_PORT, ULP_MAX_PORT}, {ULP_MAX_PORT} }, - { "send_maxbuf", MOD_PROTO_UDP, - mod_set_uint32, mod_get_uint32, - {UDP_XMIT_LOWATER, (1<<30), UDP_XMIT_HIWATER}, + { "send_buf", MOD_PROTO_UDP, + udp_set_buf_prop, udp_get_buf_prop, + {UDP_XMIT_LOWATER, ULP_MAX_BUF, UDP_XMIT_HIWATER}, {UDP_XMIT_HIWATER} }, { "_xmit_lowat", MOD_PROTO_UDP, mod_set_uint32, mod_get_uint32, - {0, (1<<30), UDP_XMIT_LOWATER}, + {0, ULP_MAX_BUF, UDP_XMIT_LOWATER}, {UDP_XMIT_LOWATER} }, - { "recv_maxbuf", MOD_PROTO_UDP, - mod_set_uint32, mod_get_uint32, - {UDP_RECV_LOWATER, (1<<30), UDP_RECV_HIWATER}, + { "recv_buf", MOD_PROTO_UDP, + udp_set_buf_prop, udp_get_buf_prop, + {UDP_RECV_LOWATER, ULP_MAX_BUF, UDP_RECV_HIWATER}, {UDP_RECV_HIWATER} }, /* tunable - 10 */ - { "_max_buf", MOD_PROTO_UDP, + { "max_buf", MOD_PROTO_UDP, mod_set_uint32, mod_get_uint32, - {65536, (1<<30), 2*1024*1024}, {2*1024*1024} }, + {65536, ULP_MAX_BUF, 2*1024*1024}, {2*1024*1024} }, { "_pmtu_discovery", MOD_PROTO_UDP, mod_set_boolean, mod_get_boolean,