tunables.c revision 8887b57dc579de11464fc6c74163d2595ce073af
/*
* 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.
*/
#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>
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);
}
/*
*/
/* 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);
}