tunables.h revision 5dd46ab5742d7db1cbb08dec7b64fa14930c02f7
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/*
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * CDDL HEADER START
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail *
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * The contents of this file are subject to the terms of the
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * Common Development and Distribution License (the "License").
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * You may not use this file except in compliance with the License.
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail *
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * or http://www.opensolaris.org/os/licensing.
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * See the License for the specific language governing permissions
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * and limitations under the License.
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail *
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * When distributing Covered Code, include this CDDL HEADER in each
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * If applicable, add the following below this CDDL HEADER, with the
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * fields enclosed by brackets "[]" replaced with your own identifying
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * information: Portions Copyright [yyyy] [name of copyright owner]
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail *
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * CDDL HEADER END
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/*
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * Copyright (c) 1990 Mentat Inc.
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#ifndef _INET_TUNABLES_H
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define _INET_TUNABLES_H
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#include <sys/types.h>
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#include <net/if.h>
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#ifdef _KERNEL
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#include <sys/netstack.h>
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#endif
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#ifdef __cplusplus
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbailextern "C" {
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#endif
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MAXPROPNAMELEN 64
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/*
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * The `mod_ioc_prop_s' datastructure is used as an IOCTL argument for
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * SIOCSETPROP and SIOCGETPROP ioctls. This datastructure identifies the
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * protocol (`mpr_proto') property (`mpr_name'), which needs to be modified
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * or retrieved (`mpr_valsize' and `mpr_val'). If the property applies to an
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * interface then `mpr_ifname' contains the name of the interface.
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbailtypedef struct mod_ioc_prop_s {
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint_t mpr_version;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint_t mpr_flags; /* see below */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail /* name of the interface (ill) for which property will be applied */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail char mpr_ifname[LIFNAMSIZ];
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint_t mpr_proto; /* see below */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail char mpr_name[MAXPROPNAMELEN]; /* property name */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint_t mpr_valsize; /* size of mpr_val */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail char mpr_val[1];
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail} mod_ioc_prop_t;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_VERSION 1
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/* permission flags for properties */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_PERM_READ 0x1
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_PERM_WRITE 0x2
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_PERM_RW (MOD_PROP_PERM_READ|MOD_PROP_PERM_WRITE)
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/* mpr_flags values */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_ACTIVE 0x01 /* current value of the property */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_DEFAULT 0x02 /* default value of the property */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_POSSIBLE 0x04 /* possible values for the property */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_PERM 0x08 /* read/write permission for property */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_APPEND 0x10 /* append to multi-valued property */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROP_REMOVE 0x20 /* remove from multi-valued property */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/* mpr_proto values */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROTO_NONE 0x00
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROTO_IPV4 0x01 /* property is applicable to IPV4 */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROTO_IPV6 0x02 /* property is applicable to IPV6 */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROTO_RAWIP 0x04 /* property is applicable to ICMP */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROTO_TCP 0x08 /* property is applicable to TCP */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROTO_UDP 0x10 /* property is applicable to UDP */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROTO_SCTP 0x20 /* property is applicable to SCTP */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/* property is applicable to both IPV[4|6] */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MOD_PROTO_IP (MOD_PROTO_IPV4|MOD_PROTO_IPV6)
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#ifdef _KERNEL
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbailtypedef struct mod_prop_info_s mod_prop_info_t;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/* set/get property callback functions */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbailtypedef int mod_prop_setf_t(void *, cred_t *, mod_prop_info_t *,
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail const char *, const void *, uint_t);
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbailtypedef int mod_prop_getf_t(void *, mod_prop_info_t *, const char *,
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail void *val, uint_t, uint_t);
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbailtypedef struct mod_propval_uint32_s {
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint32_t mod_propval_umin;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint32_t mod_propval_umax;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint32_t mod_propval_ucur;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail} mod_propval_uint32_t;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/*
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * protocol property information
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbailstruct mod_prop_info_s {
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail char *mpi_name; /* property name */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint_t mpi_proto; /* property protocol */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail mod_prop_setf_t *mpi_setf; /* sets the property value */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail mod_prop_getf_t *mpi_getf; /* gets the property value */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail /*
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * Holds the current value of the property. Whenever applicable
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * holds the min/max value too.
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail union {
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail mod_propval_uint32_t mpi_uval;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail boolean_t mpi_bval;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint64_t _pad[2];
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail } u;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail /*
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * Holds the default value of the property, that is value of
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail * the property at boot time.
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail union {
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail uint32_t mpi_def_uval;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail boolean_t mpi_def_bval;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail } u_def;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail};
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/* shortcuts to access current/default values */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define prop_min_uval u.mpi_uval.mod_propval_umin
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define prop_max_uval u.mpi_uval.mod_propval_umax
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define prop_cur_uval u.mpi_uval.mod_propval_ucur
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define prop_cur_bval u.mpi_bval
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define prop_def_uval u_def.mpi_def_uval
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define prop_def_bval u_def.mpi_def_bval
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MS 1L
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define SECONDS (1000 * MS)
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define MINUTES (60 * SECONDS)
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define HOURS (60 * MINUTES)
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define DAYS (24 * HOURS)
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
5dd46ab5742d7db1cbb08dec7b64fa14930c02f7Kacheong Poon#define MB (1024 * 1024)
5dd46ab5742d7db1cbb08dec7b64fa14930c02f7Kacheong Poon
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/* Largest TCP/UDP/SCTP port number */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define ULP_MAX_PORT (64 * 1024 - 1)
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/* extra privilege ports for upper layer protocols, tcp, sctp and udp */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define ULP_DEF_EPRIV_PORT1 2049
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#define ULP_DEF_EPRIV_PORT2 4045
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail/* generic function to set/get global module properties */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbailextern mod_prop_setf_t mod_set_boolean, mod_set_uint32,
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail mod_set_aligned, mod_set_extra_privports;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbailextern mod_prop_getf_t mod_get_boolean, mod_get_uint32,
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail mod_get_allprop, mod_get_extra_privports;
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhanextern int mod_uint32_value(const void *, mod_prop_info_t *, uint_t,
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan unsigned long *);
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#endif /* _KERNEL */
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan/*
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * End-system model definitions that include the weak/strong end-system
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * definitions in RFC 1122, Section 3.3.4.5. IP_WEAK_ES and IP_STRONG_ES
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * conform to the corresponding RFC 1122 definitions. The IP_SRC_PRI_ES
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * hostmodel is similar to IP_WEAK_ES with one additional enhancement: for
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * a packet with source S2, destination D2, the route selection algorithm
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * will first attempt to find a route for the destination that goes out
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * through an interface where S2 is configured and marked UP. If such
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * a route cannot be found, then the best-matching route for D2 will be
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * selected, ignoring any mismatches between S2 and the interface addresses
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan * on the outgoing interface implied by the route.
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan */
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhantypedef enum {
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan IP_WEAK_ES = 0,
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan IP_SRC_PRI_ES,
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan IP_STRONG_ES,
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan IP_MAXVAL_ES
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan} ip_hostmodel_t;
f1e9465bc27e0b59eff81249c9c2e3fd268727a6Sowmini Varadhan
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#ifdef __cplusplus
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail}
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#endif
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail
6e91bba0d6c6bdabbba62cefae583715a4a58e2aGirish Moodalbail#endif /* _INET_TUNABLES_H */