tunables.c revision 299625c6492013aa7bd163862f0d181854f69b3c
/*
* CDDL HEADER START
*
* 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
* 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]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1990 Mentat Inc.
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <inet/tunables.h>
#include <inet/ip_stack.h>
#include <inet/rawip_impl.h>
#include <inet/tcp_stack.h>
#include <inet/tcp_impl.h>
#include <inet/udp_impl.h>
#include <inet/tunables.h>
{
/*
* 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.
*/
return (pinfo);
}
return (NULL);
}
static int
{
return (MOD_PROP_PERM_READ);
return (MOD_PROP_PERM_WRITE);
return (MOD_PROP_PERM_RW);
}
/*
* Modifies the value of the property to default value or to the `pval'
* specified by the user.
*/
/* ARGSUSED */
int
{
char *end;
unsigned long new_value;
if (flags & MOD_PROP_DEFAULT) {
return (0);
}
return (EINVAL);
return (EINVAL);
return (0);
}
/*
* Retrieves property permission, default value, current value or possible
* values for those properties whose value type is boolean_t.
*/
/* ARGSUSED */
int
{
if (get_perm)
else if (get_range)
else if (get_def)
else
return (ENOBUFS);
return (0);
}
int
{
char *end;
if (flags & MOD_PROP_DEFAULT) {
return (0);
}
*end != '\0')
return (EINVAL);
return (ERANGE);
}
return (0);
}
/*
* Modifies the value of the property to default value or to the `pval'
* specified by the user.
*/
/* ARGSUSED */
int
{
unsigned long new_value;
int err;
return (err);
return (0);
}
/*
* Rounds up the value to make it multiple of 8.
*/
/* ARGSUSED */
int
{
int err;
return (err);
/* if required, align the value to multiple of 8 */
}
return (0);
}
/*
* Retrieves property permission, default value, current value or possible
* values for those properties whose value type is uint32_t.
*/
/* ARGSUSED */
int
{
if (get_perm)
else if (get_range)
else if (get_def)
else
return (ENOBUFS);
return (0);
}
/*
* 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
{
}
/*
* 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
{
unsigned long new_value;
char *end;
if (flags & MOD_PROP_DEFAULT) {
return (0);
}
return (EINVAL);
return (ERANGE);
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
{
if (flags & MOD_PROP_POSSIBLE) {
}
}
/*
*/
/* ARGSUSED */
int
{
case MOD_PROTO_IP:
case MOD_PROTO_IPV4:
case MOD_PROTO_IPV6:
break;
case MOD_PROTO_RAWIP:
break;
case MOD_PROTO_TCP:
break;
case MOD_PROTO_UDP:
break;
case MOD_PROTO_SCTP:
break;
default:
return (EINVAL);
}
continue;
}
/* Buffer overflow, stop copying information */
return (ENOBUFS);
}
}
return (0);
}
/*
* Hold a lock while changing *_epriv_ports to prevent multiple
* threads from changing it at the same time.
*/
/* ARGSUSED */
int
{
unsigned long new_value;
char *end;
if (!def) {
*end != '\0') {
return (EINVAL);
}
return (ERANGE);
}
}
switch (proto) {
case MOD_PROTO_TCP:
break;
case MOD_PROTO_UDP:
break;
case MOD_PROTO_SCTP:
break;
default:
return (ENOTSUP);
}
/* if MOD_PROP_DEFAULT is set then reset the ports list to default */
if (def) {
for (i = 0; i < nports; i++)
ports[i] = 0;
ports[0] = ULP_DEF_EPRIV_PORT1;
return (0);
}
/* Check if the value is already in the list */
for (i = 0; i < nports; i++) {
break;
}
if (flags & MOD_PROP_REMOVE) {
if (i == nports) {
return (ESRCH);
}
/* Clear the value */
ports[i] = 0;
} else if (flags & MOD_PROP_APPEND) {
if (i != nports) {
return (EEXIST);
}
/* Find an empty slot */
for (i = 0; i < nports; i++) {
if (ports[i] == 0)
break;
}
if (i == nports) {
return (EOVERFLOW);
}
/* Set the new value */
} else {
/*
* If the user used 'assignment' modifier.
* For eg:
* # ipadm set-prop -p extra_priv_ports=3001 tcp
*
* We clear all the ports and then just add 3001.
*/
for (i = 0; i < nports; i++)
ports[i] = 0;
}
return (0);
}
/*
* Note: No locks are held when inspecting *_epriv_ports
* but instead the code relies on:
* - the fact that the address of the array and its size never changes
* - the atomic assignment of the elements of the array
*/
/* ARGSUSED */
int
{
if (get_def) {
goto ret;
} else if (get_perm) {
goto ret;
}
switch (proto) {
case MOD_PROTO_TCP:
break;
case MOD_PROTO_UDP:
break;
case MOD_PROTO_SCTP:
break;
default:
return (ENOTSUP);
}
if (get_range) {
goto ret;
}
for (i = 0; i < nports; i++) {
if (ports[i] != 0) {
else
return (ENOBUFS);
}
}
return (0);
ret:
return (ENOBUFS);
return (0);
}