xref: /titanic_51/usr/src/uts/common/inet/tunables.h (revision 299625c6492013aa7bd163862f0d181854f69b3c)
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.
24*299625c6SSebastien Roy  * Copyright (c) 2013 by Delphix. All rights reserved.
256e91bba0SGirish Moodalbail  */
266e91bba0SGirish Moodalbail 
276e91bba0SGirish Moodalbail #ifndef _INET_TUNABLES_H
286e91bba0SGirish Moodalbail #define	_INET_TUNABLES_H
296e91bba0SGirish Moodalbail 
306e91bba0SGirish Moodalbail #include <sys/types.h>
316e91bba0SGirish Moodalbail #include <net/if.h>
326e91bba0SGirish Moodalbail #ifdef _KERNEL
336e91bba0SGirish Moodalbail #include <sys/netstack.h>
346e91bba0SGirish Moodalbail #endif
356e91bba0SGirish Moodalbail 
366e91bba0SGirish Moodalbail #ifdef	__cplusplus
376e91bba0SGirish Moodalbail extern "C" {
386e91bba0SGirish Moodalbail #endif
396e91bba0SGirish Moodalbail 
406e91bba0SGirish Moodalbail #define	MAXPROPNAMELEN	64
416e91bba0SGirish Moodalbail 
426e91bba0SGirish Moodalbail /*
436e91bba0SGirish Moodalbail  * The `mod_ioc_prop_s' datastructure is used as an IOCTL argument for
446e91bba0SGirish Moodalbail  * SIOCSETPROP and SIOCGETPROP ioctls. This datastructure identifies the
456e91bba0SGirish Moodalbail  * protocol (`mpr_proto') property (`mpr_name'), which needs to be modified
466e91bba0SGirish Moodalbail  * or retrieved (`mpr_valsize' and `mpr_val'). If the property applies to an
476e91bba0SGirish Moodalbail  * interface then `mpr_ifname' contains the name of the interface.
486e91bba0SGirish Moodalbail  */
496e91bba0SGirish Moodalbail typedef struct mod_ioc_prop_s {
506e91bba0SGirish Moodalbail 	uint_t		mpr_version;
516e91bba0SGirish Moodalbail 	uint_t		mpr_flags;			/* see below */
526e91bba0SGirish Moodalbail 	/* name of the interface (ill) for which property will be applied */
536e91bba0SGirish Moodalbail 	char		mpr_ifname[LIFNAMSIZ];
546e91bba0SGirish Moodalbail 	uint_t		mpr_proto;			/* see below */
556e91bba0SGirish Moodalbail 	char		mpr_name[MAXPROPNAMELEN];	/* property name */
566e91bba0SGirish Moodalbail 	uint_t		mpr_valsize;			/* size of mpr_val */
576e91bba0SGirish Moodalbail 	char		mpr_val[1];
586e91bba0SGirish Moodalbail } mod_ioc_prop_t;
596e91bba0SGirish Moodalbail 
606e91bba0SGirish Moodalbail #define	MOD_PROP_VERSION	1
616e91bba0SGirish Moodalbail 
626e91bba0SGirish Moodalbail /* permission flags for properties */
636e91bba0SGirish Moodalbail #define	MOD_PROP_PERM_READ	0x1
646e91bba0SGirish Moodalbail #define	MOD_PROP_PERM_WRITE	0x2
656e91bba0SGirish Moodalbail #define	MOD_PROP_PERM_RW	(MOD_PROP_PERM_READ|MOD_PROP_PERM_WRITE)
666e91bba0SGirish Moodalbail 
676e91bba0SGirish Moodalbail /* mpr_flags values */
686e91bba0SGirish Moodalbail #define	MOD_PROP_ACTIVE		0x01	/* current value of the property */
696e91bba0SGirish Moodalbail #define	MOD_PROP_DEFAULT	0x02	/* default value of the property */
706e91bba0SGirish Moodalbail #define	MOD_PROP_POSSIBLE	0x04	/* possible values for the property */
716e91bba0SGirish Moodalbail #define	MOD_PROP_PERM		0x08	/* read/write permission for property */
726e91bba0SGirish Moodalbail #define	MOD_PROP_APPEND		0x10	/* append to multi-valued property */
736e91bba0SGirish Moodalbail #define	MOD_PROP_REMOVE		0x20	/* remove from multi-valued property */
746e91bba0SGirish Moodalbail 
756e91bba0SGirish Moodalbail /* mpr_proto values */
766e91bba0SGirish Moodalbail #define	MOD_PROTO_NONE		0x00
776e91bba0SGirish Moodalbail #define	MOD_PROTO_IPV4		0x01	/* property is applicable to IPV4 */
786e91bba0SGirish Moodalbail #define	MOD_PROTO_IPV6		0x02	/* property is applicable to IPV6 */
796e91bba0SGirish Moodalbail #define	MOD_PROTO_RAWIP		0x04	/* property is applicable to ICMP */
806e91bba0SGirish Moodalbail #define	MOD_PROTO_TCP		0x08	/* property is applicable to TCP */
816e91bba0SGirish Moodalbail #define	MOD_PROTO_UDP		0x10	/* property is applicable to UDP */
826e91bba0SGirish Moodalbail #define	MOD_PROTO_SCTP		0x20	/* property is applicable to SCTP */
836e91bba0SGirish Moodalbail 
846e91bba0SGirish Moodalbail /* property is applicable to both IPV[4|6] */
856e91bba0SGirish Moodalbail #define	MOD_PROTO_IP		(MOD_PROTO_IPV4|MOD_PROTO_IPV6)
866e91bba0SGirish Moodalbail 
876e91bba0SGirish Moodalbail #ifdef	_KERNEL
886e91bba0SGirish Moodalbail 
896e91bba0SGirish Moodalbail typedef struct mod_prop_info_s mod_prop_info_t;
906e91bba0SGirish Moodalbail 
916e91bba0SGirish Moodalbail /* set/get property callback functions */
92*299625c6SSebastien Roy typedef int	mod_prop_setf_t(netstack_t *, cred_t *, mod_prop_info_t *,
936e91bba0SGirish Moodalbail 		    const char *, const void *, uint_t);
94*299625c6SSebastien Roy typedef int	mod_prop_getf_t(netstack_t *, mod_prop_info_t *, const char *,
95*299625c6SSebastien Roy 		    void *, uint_t, uint_t);
966e91bba0SGirish Moodalbail 
976e91bba0SGirish Moodalbail typedef struct mod_propval_uint32_s {
986e91bba0SGirish Moodalbail 	uint32_t	mod_propval_umin;
996e91bba0SGirish Moodalbail 	uint32_t	mod_propval_umax;
1006e91bba0SGirish Moodalbail 	uint32_t	mod_propval_ucur;
1016e91bba0SGirish Moodalbail } mod_propval_uint32_t;
1026e91bba0SGirish Moodalbail 
1036e91bba0SGirish Moodalbail /*
1046e91bba0SGirish Moodalbail  * protocol property information
1056e91bba0SGirish Moodalbail  */
1066e91bba0SGirish Moodalbail struct mod_prop_info_s {
1076e91bba0SGirish Moodalbail 	char			*mpi_name;	/* property name */
1086e91bba0SGirish Moodalbail 	uint_t			mpi_proto;	/* property protocol */
1096e91bba0SGirish Moodalbail 	mod_prop_setf_t		*mpi_setf;	/* sets the property value */
1106e91bba0SGirish Moodalbail 	mod_prop_getf_t		*mpi_getf;	/* gets the property value */
1116e91bba0SGirish Moodalbail 	/*
1126e91bba0SGirish Moodalbail 	 * Holds the current value of the property. Whenever applicable
1136e91bba0SGirish Moodalbail 	 * holds the min/max value too.
1146e91bba0SGirish Moodalbail 	 */
1156e91bba0SGirish Moodalbail 	union {
1166e91bba0SGirish Moodalbail 		mod_propval_uint32_t	mpi_uval;
1176e91bba0SGirish Moodalbail 		boolean_t		mpi_bval;
1186e91bba0SGirish Moodalbail 		uint64_t		_pad[2];
1196e91bba0SGirish Moodalbail 	} u;
1206e91bba0SGirish Moodalbail 	/*
1216e91bba0SGirish Moodalbail 	 * Holds the default value of the property, that is value of
1226e91bba0SGirish Moodalbail 	 * the property at boot time.
1236e91bba0SGirish Moodalbail 	 */
1246e91bba0SGirish Moodalbail 	union {
1256e91bba0SGirish Moodalbail 		uint32_t	mpi_def_uval;
1266e91bba0SGirish Moodalbail 		boolean_t	mpi_def_bval;
1276e91bba0SGirish Moodalbail 	} u_def;
1286e91bba0SGirish Moodalbail };
1296e91bba0SGirish Moodalbail 
1306e91bba0SGirish Moodalbail /* shortcuts to access current/default values */
1316e91bba0SGirish Moodalbail #define	prop_min_uval	u.mpi_uval.mod_propval_umin
1326e91bba0SGirish Moodalbail #define	prop_max_uval	u.mpi_uval.mod_propval_umax
1336e91bba0SGirish Moodalbail #define	prop_cur_uval	u.mpi_uval.mod_propval_ucur
1346e91bba0SGirish Moodalbail #define	prop_cur_bval	u.mpi_bval
1356e91bba0SGirish Moodalbail #define	prop_def_uval	u_def.mpi_def_uval
1366e91bba0SGirish Moodalbail #define	prop_def_bval	u_def.mpi_def_bval
1376e91bba0SGirish Moodalbail 
1386e91bba0SGirish Moodalbail #define	MS		1L
1396e91bba0SGirish Moodalbail #define	SECONDS		(1000 * MS)
1406e91bba0SGirish Moodalbail #define	MINUTES		(60 * SECONDS)
1416e91bba0SGirish Moodalbail #define	HOURS		(60 * MINUTES)
1426e91bba0SGirish Moodalbail #define	DAYS		(24 * HOURS)
1436e91bba0SGirish Moodalbail 
1445dd46ab5SKacheong Poon #define	MB		(1024 * 1024)
1455dd46ab5SKacheong Poon 
1466e91bba0SGirish Moodalbail /* Largest TCP/UDP/SCTP port number */
1476e91bba0SGirish Moodalbail #define	ULP_MAX_PORT	(64 * 1024 - 1)
1486e91bba0SGirish Moodalbail 
1496e91bba0SGirish Moodalbail /* extra privilege ports for upper layer protocols, tcp, sctp and udp */
1506e91bba0SGirish Moodalbail #define	ULP_DEF_EPRIV_PORT1	2049
1516e91bba0SGirish Moodalbail #define	ULP_DEF_EPRIV_PORT2	4045
1526e91bba0SGirish Moodalbail 
153*299625c6SSebastien Roy #define	ULP_MAX_BUF	(1<<30) /* Largest possible send/receive buffer */
154*299625c6SSebastien Roy 
1556e91bba0SGirish Moodalbail /* generic function to set/get global module properties */
1566e91bba0SGirish Moodalbail extern mod_prop_setf_t	mod_set_boolean, mod_set_uint32,
1576e91bba0SGirish Moodalbail 			mod_set_aligned, mod_set_extra_privports;
1586e91bba0SGirish Moodalbail 
1596e91bba0SGirish Moodalbail extern mod_prop_getf_t	mod_get_boolean, mod_get_uint32,
1606e91bba0SGirish Moodalbail 			mod_get_allprop, mod_get_extra_privports;
1616e91bba0SGirish Moodalbail 
162*299625c6SSebastien Roy extern int		mod_uint32_value(const void *, mod_prop_info_t *,
163*299625c6SSebastien Roy     uint_t, unsigned long *);
164*299625c6SSebastien Roy extern mod_prop_info_t	*mod_prop_lookup(mod_prop_info_t[], const char *,
165*299625c6SSebastien Roy     uint_t);
166*299625c6SSebastien Roy extern int		mod_set_buf_prop(mod_prop_info_t[], netstack_t *,
167*299625c6SSebastien Roy     cred_t *cr, mod_prop_info_t *, const char *, const void *, uint_t);
168*299625c6SSebastien Roy extern int		mod_get_buf_prop(mod_prop_info_t[], netstack_t *,
169*299625c6SSebastien Roy     mod_prop_info_t *, const char *, void *, uint_t, uint_t);
170f1e9465bSSowmini Varadhan 
1716e91bba0SGirish Moodalbail #endif	/* _KERNEL */
1726e91bba0SGirish Moodalbail 
173f1e9465bSSowmini Varadhan /*
174f1e9465bSSowmini Varadhan  * End-system model definitions that include the weak/strong end-system
175f1e9465bSSowmini Varadhan  * definitions in RFC 1122, Section 3.3.4.5. IP_WEAK_ES and IP_STRONG_ES
176f1e9465bSSowmini Varadhan  * conform to the corresponding  RFC 1122 definitions. The IP_SRC_PRI_ES
177f1e9465bSSowmini Varadhan  * hostmodel is similar to IP_WEAK_ES with one additional enhancement: for
178f1e9465bSSowmini Varadhan  * a packet with source S2, destination D2, the route selection algorithm
179f1e9465bSSowmini Varadhan  * will first attempt to find a route for the destination that goes out
180f1e9465bSSowmini Varadhan  * through an interface where S2 is configured and marked UP.  If such
181f1e9465bSSowmini Varadhan  * a route cannot be found, then the best-matching route for D2 will be
182f1e9465bSSowmini Varadhan  * selected, ignoring any mismatches between S2 and the interface addresses
183f1e9465bSSowmini Varadhan  * on the outgoing interface implied by the route.
184f1e9465bSSowmini Varadhan  */
185f1e9465bSSowmini Varadhan typedef enum {
186f1e9465bSSowmini Varadhan 	IP_WEAK_ES = 0,
187f1e9465bSSowmini Varadhan 	IP_SRC_PRI_ES,
188f1e9465bSSowmini Varadhan 	IP_STRONG_ES,
189f1e9465bSSowmini Varadhan 	IP_MAXVAL_ES
190f1e9465bSSowmini Varadhan } ip_hostmodel_t;
191f1e9465bSSowmini Varadhan 
1926e91bba0SGirish Moodalbail #ifdef	__cplusplus
1936e91bba0SGirish Moodalbail }
1946e91bba0SGirish Moodalbail #endif
1956e91bba0SGirish Moodalbail 
1966e91bba0SGirish Moodalbail #endif	/* _INET_TUNABLES_H */
197