xref: /titanic_44/usr/src/uts/common/inet/tunables.h (revision 5dd46ab5742d7db1cbb08dec7b64fa14930c02f7)
16e91bba0SGirish Moodalbail /*
26e91bba0SGirish Moodalbail  * CDDL HEADER START
36e91bba0SGirish Moodalbail  *
46e91bba0SGirish Moodalbail  * The contents of this file are subject to the terms of the
56e91bba0SGirish Moodalbail  * Common Development and Distribution License (the "License").
66e91bba0SGirish Moodalbail  * You may not use this file except in compliance with the License.
76e91bba0SGirish Moodalbail  *
86e91bba0SGirish Moodalbail  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
96e91bba0SGirish Moodalbail  * or http://www.opensolaris.org/os/licensing.
106e91bba0SGirish Moodalbail  * See the License for the specific language governing permissions
116e91bba0SGirish Moodalbail  * and limitations under the License.
126e91bba0SGirish Moodalbail  *
136e91bba0SGirish Moodalbail  * When distributing Covered Code, include this CDDL HEADER in each
146e91bba0SGirish Moodalbail  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
156e91bba0SGirish Moodalbail  * If applicable, add the following below this CDDL HEADER, with the
166e91bba0SGirish Moodalbail  * fields enclosed by brackets "[]" replaced with your own identifying
176e91bba0SGirish Moodalbail  * information: Portions Copyright [yyyy] [name of copyright owner]
186e91bba0SGirish Moodalbail  *
196e91bba0SGirish Moodalbail  * CDDL HEADER END
206e91bba0SGirish Moodalbail  */
216e91bba0SGirish Moodalbail /*
22f1e9465bSSowmini Varadhan  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23f1e9465bSSowmini Varadhan  * Copyright (c) 1990 Mentat Inc.
246e91bba0SGirish Moodalbail  */
256e91bba0SGirish Moodalbail 
266e91bba0SGirish Moodalbail #ifndef _INET_TUNABLES_H
276e91bba0SGirish Moodalbail #define	_INET_TUNABLES_H
286e91bba0SGirish Moodalbail 
296e91bba0SGirish Moodalbail #include <sys/types.h>
306e91bba0SGirish Moodalbail #include <net/if.h>
316e91bba0SGirish Moodalbail #ifdef _KERNEL
326e91bba0SGirish Moodalbail #include <sys/netstack.h>
336e91bba0SGirish Moodalbail #endif
346e91bba0SGirish Moodalbail 
356e91bba0SGirish Moodalbail #ifdef	__cplusplus
366e91bba0SGirish Moodalbail extern "C" {
376e91bba0SGirish Moodalbail #endif
386e91bba0SGirish Moodalbail 
396e91bba0SGirish Moodalbail #define	MAXPROPNAMELEN	64
406e91bba0SGirish Moodalbail 
416e91bba0SGirish Moodalbail /*
426e91bba0SGirish Moodalbail  * The `mod_ioc_prop_s' datastructure is used as an IOCTL argument for
436e91bba0SGirish Moodalbail  * SIOCSETPROP and SIOCGETPROP ioctls. This datastructure identifies the
446e91bba0SGirish Moodalbail  * protocol (`mpr_proto') property (`mpr_name'), which needs to be modified
456e91bba0SGirish Moodalbail  * or retrieved (`mpr_valsize' and `mpr_val'). If the property applies to an
466e91bba0SGirish Moodalbail  * interface then `mpr_ifname' contains the name of the interface.
476e91bba0SGirish Moodalbail  */
486e91bba0SGirish Moodalbail typedef struct mod_ioc_prop_s {
496e91bba0SGirish Moodalbail 	uint_t		mpr_version;
506e91bba0SGirish Moodalbail 	uint_t		mpr_flags;			/* see below */
516e91bba0SGirish Moodalbail 	/* name of the interface (ill) for which property will be applied */
526e91bba0SGirish Moodalbail 	char		mpr_ifname[LIFNAMSIZ];
536e91bba0SGirish Moodalbail 	uint_t		mpr_proto;			/* see below */
546e91bba0SGirish Moodalbail 	char		mpr_name[MAXPROPNAMELEN];	/* property name */
556e91bba0SGirish Moodalbail 	uint_t		mpr_valsize;			/* size of mpr_val */
566e91bba0SGirish Moodalbail 	char		mpr_val[1];
576e91bba0SGirish Moodalbail } mod_ioc_prop_t;
586e91bba0SGirish Moodalbail 
596e91bba0SGirish Moodalbail #define	MOD_PROP_VERSION	1
606e91bba0SGirish Moodalbail 
616e91bba0SGirish Moodalbail /* permission flags for properties */
626e91bba0SGirish Moodalbail #define	MOD_PROP_PERM_READ	0x1
636e91bba0SGirish Moodalbail #define	MOD_PROP_PERM_WRITE	0x2
646e91bba0SGirish Moodalbail #define	MOD_PROP_PERM_RW	(MOD_PROP_PERM_READ|MOD_PROP_PERM_WRITE)
656e91bba0SGirish Moodalbail 
666e91bba0SGirish Moodalbail /* mpr_flags values */
676e91bba0SGirish Moodalbail #define	MOD_PROP_ACTIVE		0x01	/* current value of the property */
686e91bba0SGirish Moodalbail #define	MOD_PROP_DEFAULT	0x02	/* default value of the property */
696e91bba0SGirish Moodalbail #define	MOD_PROP_POSSIBLE	0x04	/* possible values for the property */
706e91bba0SGirish Moodalbail #define	MOD_PROP_PERM		0x08	/* read/write permission for property */
716e91bba0SGirish Moodalbail #define	MOD_PROP_APPEND		0x10	/* append to multi-valued property */
726e91bba0SGirish Moodalbail #define	MOD_PROP_REMOVE		0x20	/* remove from multi-valued property */
736e91bba0SGirish Moodalbail 
746e91bba0SGirish Moodalbail /* mpr_proto values */
756e91bba0SGirish Moodalbail #define	MOD_PROTO_NONE		0x00
766e91bba0SGirish Moodalbail #define	MOD_PROTO_IPV4		0x01	/* property is applicable to IPV4 */
776e91bba0SGirish Moodalbail #define	MOD_PROTO_IPV6		0x02	/* property is applicable to IPV6 */
786e91bba0SGirish Moodalbail #define	MOD_PROTO_RAWIP		0x04	/* property is applicable to ICMP */
796e91bba0SGirish Moodalbail #define	MOD_PROTO_TCP		0x08	/* property is applicable to TCP */
806e91bba0SGirish Moodalbail #define	MOD_PROTO_UDP		0x10	/* property is applicable to UDP */
816e91bba0SGirish Moodalbail #define	MOD_PROTO_SCTP		0x20	/* property is applicable to SCTP */
826e91bba0SGirish Moodalbail 
836e91bba0SGirish Moodalbail /* property is applicable to both IPV[4|6] */
846e91bba0SGirish Moodalbail #define	MOD_PROTO_IP		(MOD_PROTO_IPV4|MOD_PROTO_IPV6)
856e91bba0SGirish Moodalbail 
866e91bba0SGirish Moodalbail #ifdef	_KERNEL
876e91bba0SGirish Moodalbail 
886e91bba0SGirish Moodalbail typedef struct mod_prop_info_s mod_prop_info_t;
896e91bba0SGirish Moodalbail 
906e91bba0SGirish Moodalbail /* set/get property callback functions */
916e91bba0SGirish Moodalbail typedef int	mod_prop_setf_t(void *, cred_t *, mod_prop_info_t *,
926e91bba0SGirish Moodalbail 		    const char *, const void *, uint_t);
936e91bba0SGirish Moodalbail typedef int	mod_prop_getf_t(void *, mod_prop_info_t *, const char *,
946e91bba0SGirish Moodalbail 		    void *val, uint_t, uint_t);
956e91bba0SGirish Moodalbail 
966e91bba0SGirish Moodalbail typedef struct mod_propval_uint32_s {
976e91bba0SGirish Moodalbail 	uint32_t	mod_propval_umin;
986e91bba0SGirish Moodalbail 	uint32_t	mod_propval_umax;
996e91bba0SGirish Moodalbail 	uint32_t	mod_propval_ucur;
1006e91bba0SGirish Moodalbail } mod_propval_uint32_t;
1016e91bba0SGirish Moodalbail 
1026e91bba0SGirish Moodalbail /*
1036e91bba0SGirish Moodalbail  * protocol property information
1046e91bba0SGirish Moodalbail  */
1056e91bba0SGirish Moodalbail struct mod_prop_info_s {
1066e91bba0SGirish Moodalbail 	char			*mpi_name;	/* property name */
1076e91bba0SGirish Moodalbail 	uint_t			mpi_proto;	/* property protocol */
1086e91bba0SGirish Moodalbail 	mod_prop_setf_t		*mpi_setf;	/* sets the property value */
1096e91bba0SGirish Moodalbail 	mod_prop_getf_t		*mpi_getf;	/* gets the property value */
1106e91bba0SGirish Moodalbail 	/*
1116e91bba0SGirish Moodalbail 	 * Holds the current value of the property. Whenever applicable
1126e91bba0SGirish Moodalbail 	 * holds the min/max value too.
1136e91bba0SGirish Moodalbail 	 */
1146e91bba0SGirish Moodalbail 	union {
1156e91bba0SGirish Moodalbail 		mod_propval_uint32_t	mpi_uval;
1166e91bba0SGirish Moodalbail 		boolean_t		mpi_bval;
1176e91bba0SGirish Moodalbail 		uint64_t		_pad[2];
1186e91bba0SGirish Moodalbail 	} u;
1196e91bba0SGirish Moodalbail 	/*
1206e91bba0SGirish Moodalbail 	 * Holds the default value of the property, that is value of
1216e91bba0SGirish Moodalbail 	 * the property at boot time.
1226e91bba0SGirish Moodalbail 	 */
1236e91bba0SGirish Moodalbail 	union {
1246e91bba0SGirish Moodalbail 		uint32_t	mpi_def_uval;
1256e91bba0SGirish Moodalbail 		boolean_t	mpi_def_bval;
1266e91bba0SGirish Moodalbail 	} u_def;
1276e91bba0SGirish Moodalbail };
1286e91bba0SGirish Moodalbail 
1296e91bba0SGirish Moodalbail /* shortcuts to access current/default values */
1306e91bba0SGirish Moodalbail #define	prop_min_uval	u.mpi_uval.mod_propval_umin
1316e91bba0SGirish Moodalbail #define	prop_max_uval	u.mpi_uval.mod_propval_umax
1326e91bba0SGirish Moodalbail #define	prop_cur_uval	u.mpi_uval.mod_propval_ucur
1336e91bba0SGirish Moodalbail #define	prop_cur_bval	u.mpi_bval
1346e91bba0SGirish Moodalbail #define	prop_def_uval	u_def.mpi_def_uval
1356e91bba0SGirish Moodalbail #define	prop_def_bval	u_def.mpi_def_bval
1366e91bba0SGirish Moodalbail 
1376e91bba0SGirish Moodalbail #define	MS		1L
1386e91bba0SGirish Moodalbail #define	SECONDS		(1000 * MS)
1396e91bba0SGirish Moodalbail #define	MINUTES		(60 * SECONDS)
1406e91bba0SGirish Moodalbail #define	HOURS		(60 * MINUTES)
1416e91bba0SGirish Moodalbail #define	DAYS		(24 * HOURS)
1426e91bba0SGirish Moodalbail 
143*5dd46ab5SKacheong Poon #define	MB		(1024 * 1024)
144*5dd46ab5SKacheong Poon 
1456e91bba0SGirish Moodalbail /* Largest TCP/UDP/SCTP port number */
1466e91bba0SGirish Moodalbail #define	ULP_MAX_PORT	(64 * 1024 - 1)
1476e91bba0SGirish Moodalbail 
1486e91bba0SGirish Moodalbail /* extra privilege ports for upper layer protocols, tcp, sctp and udp */
1496e91bba0SGirish Moodalbail #define	ULP_DEF_EPRIV_PORT1	2049
1506e91bba0SGirish Moodalbail #define	ULP_DEF_EPRIV_PORT2	4045
1516e91bba0SGirish Moodalbail 
1526e91bba0SGirish Moodalbail /* generic function to set/get global module properties */
1536e91bba0SGirish Moodalbail extern mod_prop_setf_t	mod_set_boolean, mod_set_uint32,
1546e91bba0SGirish Moodalbail 			mod_set_aligned, mod_set_extra_privports;
1556e91bba0SGirish Moodalbail 
1566e91bba0SGirish Moodalbail extern mod_prop_getf_t	mod_get_boolean, mod_get_uint32,
1576e91bba0SGirish Moodalbail 			mod_get_allprop, mod_get_extra_privports;
1586e91bba0SGirish Moodalbail 
159f1e9465bSSowmini Varadhan extern int mod_uint32_value(const void *, mod_prop_info_t *, uint_t,
160f1e9465bSSowmini Varadhan     unsigned long *);
161f1e9465bSSowmini Varadhan 
1626e91bba0SGirish Moodalbail #endif	/* _KERNEL */
1636e91bba0SGirish Moodalbail 
164f1e9465bSSowmini Varadhan /*
165f1e9465bSSowmini Varadhan  * End-system model definitions that include the weak/strong end-system
166f1e9465bSSowmini Varadhan  * definitions in RFC 1122, Section 3.3.4.5. IP_WEAK_ES and IP_STRONG_ES
167f1e9465bSSowmini Varadhan  * conform to the corresponding  RFC 1122 definitions. The IP_SRC_PRI_ES
168f1e9465bSSowmini Varadhan  * hostmodel is similar to IP_WEAK_ES with one additional enhancement: for
169f1e9465bSSowmini Varadhan  * a packet with source S2, destination D2, the route selection algorithm
170f1e9465bSSowmini Varadhan  * will first attempt to find a route for the destination that goes out
171f1e9465bSSowmini Varadhan  * through an interface where S2 is configured and marked UP.  If such
172f1e9465bSSowmini Varadhan  * a route cannot be found, then the best-matching route for D2 will be
173f1e9465bSSowmini Varadhan  * selected, ignoring any mismatches between S2 and the interface addresses
174f1e9465bSSowmini Varadhan  * on the outgoing interface implied by the route.
175f1e9465bSSowmini Varadhan  */
176f1e9465bSSowmini Varadhan typedef enum {
177f1e9465bSSowmini Varadhan 	IP_WEAK_ES = 0,
178f1e9465bSSowmini Varadhan 	IP_SRC_PRI_ES,
179f1e9465bSSowmini Varadhan 	IP_STRONG_ES,
180f1e9465bSSowmini Varadhan 	IP_MAXVAL_ES
181f1e9465bSSowmini Varadhan } ip_hostmodel_t;
182f1e9465bSSowmini Varadhan 
1836e91bba0SGirish Moodalbail #ifdef	__cplusplus
1846e91bba0SGirish Moodalbail }
1856e91bba0SGirish Moodalbail #endif
1866e91bba0SGirish Moodalbail 
1876e91bba0SGirish Moodalbail #endif	/* _INET_TUNABLES_H */
188