xref: /onnv-gate/usr/src/uts/common/inet/tunables.h (revision 12869:fb36eaeb6ee0)
112016SGirish.Moodalbail@Sun.COM /*
212016SGirish.Moodalbail@Sun.COM  * CDDL HEADER START
312016SGirish.Moodalbail@Sun.COM  *
412016SGirish.Moodalbail@Sun.COM  * The contents of this file are subject to the terms of the
512016SGirish.Moodalbail@Sun.COM  * Common Development and Distribution License (the "License").
612016SGirish.Moodalbail@Sun.COM  * You may not use this file except in compliance with the License.
712016SGirish.Moodalbail@Sun.COM  *
812016SGirish.Moodalbail@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
912016SGirish.Moodalbail@Sun.COM  * or http://www.opensolaris.org/os/licensing.
1012016SGirish.Moodalbail@Sun.COM  * See the License for the specific language governing permissions
1112016SGirish.Moodalbail@Sun.COM  * and limitations under the License.
1212016SGirish.Moodalbail@Sun.COM  *
1312016SGirish.Moodalbail@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
1412016SGirish.Moodalbail@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1512016SGirish.Moodalbail@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
1612016SGirish.Moodalbail@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
1712016SGirish.Moodalbail@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
1812016SGirish.Moodalbail@Sun.COM  *
1912016SGirish.Moodalbail@Sun.COM  * CDDL HEADER END
2012016SGirish.Moodalbail@Sun.COM  */
2112016SGirish.Moodalbail@Sun.COM /*
2212313SSowmini.Varadhan@Sun.COM  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
2312313SSowmini.Varadhan@Sun.COM  * Copyright (c) 1990 Mentat Inc.
2412016SGirish.Moodalbail@Sun.COM  */
2512016SGirish.Moodalbail@Sun.COM 
2612016SGirish.Moodalbail@Sun.COM #ifndef _INET_TUNABLES_H
2712016SGirish.Moodalbail@Sun.COM #define	_INET_TUNABLES_H
2812016SGirish.Moodalbail@Sun.COM 
2912016SGirish.Moodalbail@Sun.COM #include <sys/types.h>
3012016SGirish.Moodalbail@Sun.COM #include <net/if.h>
3112016SGirish.Moodalbail@Sun.COM #ifdef _KERNEL
3212016SGirish.Moodalbail@Sun.COM #include <sys/netstack.h>
3312016SGirish.Moodalbail@Sun.COM #endif
3412016SGirish.Moodalbail@Sun.COM 
3512016SGirish.Moodalbail@Sun.COM #ifdef	__cplusplus
3612016SGirish.Moodalbail@Sun.COM extern "C" {
3712016SGirish.Moodalbail@Sun.COM #endif
3812016SGirish.Moodalbail@Sun.COM 
3912016SGirish.Moodalbail@Sun.COM #define	MAXPROPNAMELEN	64
4012016SGirish.Moodalbail@Sun.COM 
4112016SGirish.Moodalbail@Sun.COM /*
4212016SGirish.Moodalbail@Sun.COM  * The `mod_ioc_prop_s' datastructure is used as an IOCTL argument for
4312016SGirish.Moodalbail@Sun.COM  * SIOCSETPROP and SIOCGETPROP ioctls. This datastructure identifies the
4412016SGirish.Moodalbail@Sun.COM  * protocol (`mpr_proto') property (`mpr_name'), which needs to be modified
4512016SGirish.Moodalbail@Sun.COM  * or retrieved (`mpr_valsize' and `mpr_val'). If the property applies to an
4612016SGirish.Moodalbail@Sun.COM  * interface then `mpr_ifname' contains the name of the interface.
4712016SGirish.Moodalbail@Sun.COM  */
4812016SGirish.Moodalbail@Sun.COM typedef struct mod_ioc_prop_s {
4912016SGirish.Moodalbail@Sun.COM 	uint_t		mpr_version;
5012016SGirish.Moodalbail@Sun.COM 	uint_t		mpr_flags;			/* see below */
5112016SGirish.Moodalbail@Sun.COM 	/* name of the interface (ill) for which property will be applied */
5212016SGirish.Moodalbail@Sun.COM 	char		mpr_ifname[LIFNAMSIZ];
5312016SGirish.Moodalbail@Sun.COM 	uint_t		mpr_proto;			/* see below */
5412016SGirish.Moodalbail@Sun.COM 	char		mpr_name[MAXPROPNAMELEN];	/* property name */
5512016SGirish.Moodalbail@Sun.COM 	uint_t		mpr_valsize;			/* size of mpr_val */
5612016SGirish.Moodalbail@Sun.COM 	char		mpr_val[1];
5712016SGirish.Moodalbail@Sun.COM } mod_ioc_prop_t;
5812016SGirish.Moodalbail@Sun.COM 
5912016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_VERSION	1
6012016SGirish.Moodalbail@Sun.COM 
6112016SGirish.Moodalbail@Sun.COM /* permission flags for properties */
6212016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_PERM_READ	0x1
6312016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_PERM_WRITE	0x2
6412016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_PERM_RW	(MOD_PROP_PERM_READ|MOD_PROP_PERM_WRITE)
6512016SGirish.Moodalbail@Sun.COM 
6612016SGirish.Moodalbail@Sun.COM /* mpr_flags values */
6712016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_ACTIVE		0x01	/* current value of the property */
6812016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_DEFAULT	0x02	/* default value of the property */
6912016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_POSSIBLE	0x04	/* possible values for the property */
7012016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_PERM		0x08	/* read/write permission for property */
7112016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_APPEND		0x10	/* append to multi-valued property */
7212016SGirish.Moodalbail@Sun.COM #define	MOD_PROP_REMOVE		0x20	/* remove from multi-valued property */
7312016SGirish.Moodalbail@Sun.COM 
7412016SGirish.Moodalbail@Sun.COM /* mpr_proto values */
7512016SGirish.Moodalbail@Sun.COM #define	MOD_PROTO_NONE		0x00
7612016SGirish.Moodalbail@Sun.COM #define	MOD_PROTO_IPV4		0x01	/* property is applicable to IPV4 */
7712016SGirish.Moodalbail@Sun.COM #define	MOD_PROTO_IPV6		0x02	/* property is applicable to IPV6 */
7812016SGirish.Moodalbail@Sun.COM #define	MOD_PROTO_RAWIP		0x04	/* property is applicable to ICMP */
7912016SGirish.Moodalbail@Sun.COM #define	MOD_PROTO_TCP		0x08	/* property is applicable to TCP */
8012016SGirish.Moodalbail@Sun.COM #define	MOD_PROTO_UDP		0x10	/* property is applicable to UDP */
8112016SGirish.Moodalbail@Sun.COM #define	MOD_PROTO_SCTP		0x20	/* property is applicable to SCTP */
8212016SGirish.Moodalbail@Sun.COM 
8312016SGirish.Moodalbail@Sun.COM /* property is applicable to both IPV[4|6] */
8412016SGirish.Moodalbail@Sun.COM #define	MOD_PROTO_IP		(MOD_PROTO_IPV4|MOD_PROTO_IPV6)
8512016SGirish.Moodalbail@Sun.COM 
8612016SGirish.Moodalbail@Sun.COM #ifdef	_KERNEL
8712016SGirish.Moodalbail@Sun.COM 
8812016SGirish.Moodalbail@Sun.COM typedef struct mod_prop_info_s mod_prop_info_t;
8912016SGirish.Moodalbail@Sun.COM 
9012016SGirish.Moodalbail@Sun.COM /* set/get property callback functions */
9112016SGirish.Moodalbail@Sun.COM typedef int	mod_prop_setf_t(void *, cred_t *, mod_prop_info_t *,
9212016SGirish.Moodalbail@Sun.COM 		    const char *, const void *, uint_t);
9312016SGirish.Moodalbail@Sun.COM typedef int	mod_prop_getf_t(void *, mod_prop_info_t *, const char *,
9412016SGirish.Moodalbail@Sun.COM 		    void *val, uint_t, uint_t);
9512016SGirish.Moodalbail@Sun.COM 
9612016SGirish.Moodalbail@Sun.COM typedef struct mod_propval_uint32_s {
9712016SGirish.Moodalbail@Sun.COM 	uint32_t	mod_propval_umin;
9812016SGirish.Moodalbail@Sun.COM 	uint32_t	mod_propval_umax;
9912016SGirish.Moodalbail@Sun.COM 	uint32_t	mod_propval_ucur;
10012016SGirish.Moodalbail@Sun.COM } mod_propval_uint32_t;
10112016SGirish.Moodalbail@Sun.COM 
10212016SGirish.Moodalbail@Sun.COM /*
10312016SGirish.Moodalbail@Sun.COM  * protocol property information
10412016SGirish.Moodalbail@Sun.COM  */
10512016SGirish.Moodalbail@Sun.COM struct mod_prop_info_s {
10612016SGirish.Moodalbail@Sun.COM 	char			*mpi_name;	/* property name */
10712016SGirish.Moodalbail@Sun.COM 	uint_t			mpi_proto;	/* property protocol */
10812016SGirish.Moodalbail@Sun.COM 	mod_prop_setf_t		*mpi_setf;	/* sets the property value */
10912016SGirish.Moodalbail@Sun.COM 	mod_prop_getf_t		*mpi_getf;	/* gets the property value */
11012016SGirish.Moodalbail@Sun.COM 	/*
11112016SGirish.Moodalbail@Sun.COM 	 * Holds the current value of the property. Whenever applicable
11212016SGirish.Moodalbail@Sun.COM 	 * holds the min/max value too.
11312016SGirish.Moodalbail@Sun.COM 	 */
11412016SGirish.Moodalbail@Sun.COM 	union {
11512016SGirish.Moodalbail@Sun.COM 		mod_propval_uint32_t	mpi_uval;
11612016SGirish.Moodalbail@Sun.COM 		boolean_t		mpi_bval;
11712016SGirish.Moodalbail@Sun.COM 		uint64_t		_pad[2];
11812016SGirish.Moodalbail@Sun.COM 	} u;
11912016SGirish.Moodalbail@Sun.COM 	/*
12012016SGirish.Moodalbail@Sun.COM 	 * Holds the default value of the property, that is value of
12112016SGirish.Moodalbail@Sun.COM 	 * the property at boot time.
12212016SGirish.Moodalbail@Sun.COM 	 */
12312016SGirish.Moodalbail@Sun.COM 	union {
12412016SGirish.Moodalbail@Sun.COM 		uint32_t	mpi_def_uval;
12512016SGirish.Moodalbail@Sun.COM 		boolean_t	mpi_def_bval;
12612016SGirish.Moodalbail@Sun.COM 	} u_def;
12712016SGirish.Moodalbail@Sun.COM };
12812016SGirish.Moodalbail@Sun.COM 
12912016SGirish.Moodalbail@Sun.COM /* shortcuts to access current/default values */
13012016SGirish.Moodalbail@Sun.COM #define	prop_min_uval	u.mpi_uval.mod_propval_umin
13112016SGirish.Moodalbail@Sun.COM #define	prop_max_uval	u.mpi_uval.mod_propval_umax
13212016SGirish.Moodalbail@Sun.COM #define	prop_cur_uval	u.mpi_uval.mod_propval_ucur
13312016SGirish.Moodalbail@Sun.COM #define	prop_cur_bval	u.mpi_bval
13412016SGirish.Moodalbail@Sun.COM #define	prop_def_uval	u_def.mpi_def_uval
13512016SGirish.Moodalbail@Sun.COM #define	prop_def_bval	u_def.mpi_def_bval
13612016SGirish.Moodalbail@Sun.COM 
13712016SGirish.Moodalbail@Sun.COM #define	MS		1L
13812016SGirish.Moodalbail@Sun.COM #define	SECONDS		(1000 * MS)
13912016SGirish.Moodalbail@Sun.COM #define	MINUTES		(60 * SECONDS)
14012016SGirish.Moodalbail@Sun.COM #define	HOURS		(60 * MINUTES)
14112016SGirish.Moodalbail@Sun.COM #define	DAYS		(24 * HOURS)
14212016SGirish.Moodalbail@Sun.COM 
143*12869SKacheong.Poon@Sun.COM #define	MB		(1024 * 1024)
144*12869SKacheong.Poon@Sun.COM 
14512016SGirish.Moodalbail@Sun.COM /* Largest TCP/UDP/SCTP port number */
14612016SGirish.Moodalbail@Sun.COM #define	ULP_MAX_PORT	(64 * 1024 - 1)
14712016SGirish.Moodalbail@Sun.COM 
14812016SGirish.Moodalbail@Sun.COM /* extra privilege ports for upper layer protocols, tcp, sctp and udp */
14912016SGirish.Moodalbail@Sun.COM #define	ULP_DEF_EPRIV_PORT1	2049
15012016SGirish.Moodalbail@Sun.COM #define	ULP_DEF_EPRIV_PORT2	4045
15112016SGirish.Moodalbail@Sun.COM 
15212016SGirish.Moodalbail@Sun.COM /* generic function to set/get global module properties */
15312016SGirish.Moodalbail@Sun.COM extern mod_prop_setf_t	mod_set_boolean, mod_set_uint32,
15412016SGirish.Moodalbail@Sun.COM 			mod_set_aligned, mod_set_extra_privports;
15512016SGirish.Moodalbail@Sun.COM 
15612016SGirish.Moodalbail@Sun.COM extern mod_prop_getf_t	mod_get_boolean, mod_get_uint32,
15712016SGirish.Moodalbail@Sun.COM 			mod_get_allprop, mod_get_extra_privports;
15812016SGirish.Moodalbail@Sun.COM 
15912313SSowmini.Varadhan@Sun.COM extern int mod_uint32_value(const void *, mod_prop_info_t *, uint_t,
16012313SSowmini.Varadhan@Sun.COM     unsigned long *);
16112313SSowmini.Varadhan@Sun.COM 
16212016SGirish.Moodalbail@Sun.COM #endif	/* _KERNEL */
16312016SGirish.Moodalbail@Sun.COM 
16412313SSowmini.Varadhan@Sun.COM /*
16512313SSowmini.Varadhan@Sun.COM  * End-system model definitions that include the weak/strong end-system
16612313SSowmini.Varadhan@Sun.COM  * definitions in RFC 1122, Section 3.3.4.5. IP_WEAK_ES and IP_STRONG_ES
16712313SSowmini.Varadhan@Sun.COM  * conform to the corresponding  RFC 1122 definitions. The IP_SRC_PRI_ES
16812313SSowmini.Varadhan@Sun.COM  * hostmodel is similar to IP_WEAK_ES with one additional enhancement: for
16912313SSowmini.Varadhan@Sun.COM  * a packet with source S2, destination D2, the route selection algorithm
17012313SSowmini.Varadhan@Sun.COM  * will first attempt to find a route for the destination that goes out
17112313SSowmini.Varadhan@Sun.COM  * through an interface where S2 is configured and marked UP.  If such
17212313SSowmini.Varadhan@Sun.COM  * a route cannot be found, then the best-matching route for D2 will be
17312313SSowmini.Varadhan@Sun.COM  * selected, ignoring any mismatches between S2 and the interface addresses
17412313SSowmini.Varadhan@Sun.COM  * on the outgoing interface implied by the route.
17512313SSowmini.Varadhan@Sun.COM  */
17612313SSowmini.Varadhan@Sun.COM typedef enum {
17712313SSowmini.Varadhan@Sun.COM 	IP_WEAK_ES = 0,
17812313SSowmini.Varadhan@Sun.COM 	IP_SRC_PRI_ES,
17912313SSowmini.Varadhan@Sun.COM 	IP_STRONG_ES,
18012313SSowmini.Varadhan@Sun.COM 	IP_MAXVAL_ES
18112313SSowmini.Varadhan@Sun.COM } ip_hostmodel_t;
18212313SSowmini.Varadhan@Sun.COM 
18312016SGirish.Moodalbail@Sun.COM #ifdef	__cplusplus
18412016SGirish.Moodalbail@Sun.COM }
18512016SGirish.Moodalbail@Sun.COM #endif
18612016SGirish.Moodalbail@Sun.COM 
18712016SGirish.Moodalbail@Sun.COM #endif	/* _INET_TUNABLES_H */
188