xref: /titanic_52/usr/src/uts/common/inet/tunables.h (revision ba3594ba9b5dd4c846c472a8d657edcb7c8109ac)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
23  * Copyright (c) 1990 Mentat Inc.
24  * Copyright (c) 2013 by Delphix. All rights reserved.
25  */
26 
27 #ifndef _INET_TUNABLES_H
28 #define	_INET_TUNABLES_H
29 
30 #include <sys/types.h>
31 #include <net/if.h>
32 #ifdef _KERNEL
33 #include <sys/netstack.h>
34 #endif
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #define	MAXPROPNAMELEN	64
41 
42 /*
43  * The `mod_ioc_prop_s' datastructure is used as an IOCTL argument for
44  * SIOCSETPROP and SIOCGETPROP ioctls. This datastructure identifies the
45  * protocol (`mpr_proto') property (`mpr_name'), which needs to be modified
46  * or retrieved (`mpr_valsize' and `mpr_val'). If the property applies to an
47  * interface then `mpr_ifname' contains the name of the interface.
48  */
49 typedef struct mod_ioc_prop_s {
50 	uint_t		mpr_version;
51 	uint_t		mpr_flags;			/* see below */
52 	/* name of the interface (ill) for which property will be applied */
53 	char		mpr_ifname[LIFNAMSIZ];
54 	uint_t		mpr_proto;			/* see below */
55 	char		mpr_name[MAXPROPNAMELEN];	/* property name */
56 	uint_t		mpr_valsize;			/* size of mpr_val */
57 	char		mpr_val[1];
58 } mod_ioc_prop_t;
59 
60 #define	MOD_PROP_VERSION	1
61 
62 /* permission flags for properties */
63 #define	MOD_PROP_PERM_READ	0x1
64 #define	MOD_PROP_PERM_WRITE	0x2
65 #define	MOD_PROP_PERM_RW	(MOD_PROP_PERM_READ|MOD_PROP_PERM_WRITE)
66 
67 /* mpr_flags values */
68 #define	MOD_PROP_ACTIVE		0x01	/* current value of the property */
69 #define	MOD_PROP_DEFAULT	0x02	/* default value of the property */
70 #define	MOD_PROP_POSSIBLE	0x04	/* possible values for the property */
71 #define	MOD_PROP_PERM		0x08	/* read/write permission for property */
72 #define	MOD_PROP_APPEND		0x10	/* append to multi-valued property */
73 #define	MOD_PROP_REMOVE		0x20	/* remove from multi-valued property */
74 
75 /* mpr_proto values */
76 #define	MOD_PROTO_NONE		0x00
77 #define	MOD_PROTO_IPV4		0x01	/* property is applicable to IPV4 */
78 #define	MOD_PROTO_IPV6		0x02	/* property is applicable to IPV6 */
79 #define	MOD_PROTO_RAWIP		0x04	/* property is applicable to ICMP */
80 #define	MOD_PROTO_TCP		0x08	/* property is applicable to TCP */
81 #define	MOD_PROTO_UDP		0x10	/* property is applicable to UDP */
82 #define	MOD_PROTO_SCTP		0x20	/* property is applicable to SCTP */
83 
84 /* property is applicable to both IPV[4|6] */
85 #define	MOD_PROTO_IP		(MOD_PROTO_IPV4|MOD_PROTO_IPV6)
86 
87 #ifdef	_KERNEL
88 
89 typedef struct mod_prop_info_s mod_prop_info_t;
90 
91 /* set/get property callback functions */
92 typedef int	mod_prop_setf_t(netstack_t *, cred_t *, mod_prop_info_t *,
93 		    const char *, const void *, uint_t);
94 typedef int	mod_prop_getf_t(netstack_t *, mod_prop_info_t *, const char *,
95 		    void *, uint_t, uint_t);
96 
97 typedef struct mod_propval_uint32_s {
98 	uint32_t	mod_propval_umin;
99 	uint32_t	mod_propval_umax;
100 	uint32_t	mod_propval_ucur;
101 } mod_propval_uint32_t;
102 
103 /*
104  * protocol property information
105  */
106 struct mod_prop_info_s {
107 	char			*mpi_name;	/* property name */
108 	uint_t			mpi_proto;	/* property protocol */
109 	mod_prop_setf_t		*mpi_setf;	/* sets the property value */
110 	mod_prop_getf_t		*mpi_getf;	/* gets the property value */
111 	/*
112 	 * Holds the current value of the property. Whenever applicable
113 	 * holds the min/max value too.
114 	 */
115 	union {
116 		mod_propval_uint32_t	mpi_uval;
117 		boolean_t		mpi_bval;
118 		uint64_t		_pad[2];
119 	} u;
120 	/*
121 	 * Holds the default value of the property, that is value of
122 	 * the property at boot time.
123 	 */
124 	union {
125 		uint32_t	mpi_def_uval;
126 		boolean_t	mpi_def_bval;
127 	} u_def;
128 };
129 
130 /* shortcuts to access current/default values */
131 #define	prop_min_uval	u.mpi_uval.mod_propval_umin
132 #define	prop_max_uval	u.mpi_uval.mod_propval_umax
133 #define	prop_cur_uval	u.mpi_uval.mod_propval_ucur
134 #define	prop_cur_bval	u.mpi_bval
135 #define	prop_def_uval	u_def.mpi_def_uval
136 #define	prop_def_bval	u_def.mpi_def_bval
137 
138 #define	MS		1L
139 #define	SECONDS		(1000 * MS)
140 #define	MINUTES		(60 * SECONDS)
141 #define	HOURS		(60 * MINUTES)
142 #define	DAYS		(24 * HOURS)
143 
144 #define	MB		(1024 * 1024)
145 
146 /* Largest TCP/UDP/SCTP port number */
147 #define	ULP_MAX_PORT	(64 * 1024 - 1)
148 
149 /* extra privilege ports for upper layer protocols, tcp, sctp and udp */
150 #define	ULP_DEF_EPRIV_PORT1	2049
151 #define	ULP_DEF_EPRIV_PORT2	4045
152 
153 #define	ULP_MAX_BUF	(1<<30) /* Largest possible send/receive buffer */
154 
155 /* generic function to set/get global module properties */
156 extern mod_prop_setf_t	mod_set_boolean, mod_set_uint32,
157 			mod_set_aligned, mod_set_extra_privports;
158 
159 extern mod_prop_getf_t	mod_get_boolean, mod_get_uint32,
160 			mod_get_allprop, mod_get_extra_privports;
161 
162 extern int		mod_uint32_value(const void *, mod_prop_info_t *,
163     uint_t, unsigned long *);
164 extern mod_prop_info_t	*mod_prop_lookup(mod_prop_info_t[], const char *,
165     uint_t);
166 extern int		mod_set_buf_prop(mod_prop_info_t[], netstack_t *,
167     cred_t *cr, mod_prop_info_t *, const char *, const void *, uint_t);
168 extern int		mod_get_buf_prop(mod_prop_info_t[], netstack_t *,
169     mod_prop_info_t *, const char *, void *, uint_t, uint_t);
170 
171 #endif	/* _KERNEL */
172 
173 /*
174  * End-system model definitions that include the weak/strong end-system
175  * definitions in RFC 1122, Section 3.3.4.5. IP_WEAK_ES and IP_STRONG_ES
176  * conform to the corresponding  RFC 1122 definitions. The IP_SRC_PRI_ES
177  * hostmodel is similar to IP_WEAK_ES with one additional enhancement: for
178  * a packet with source S2, destination D2, the route selection algorithm
179  * will first attempt to find a route for the destination that goes out
180  * through an interface where S2 is configured and marked UP.  If such
181  * a route cannot be found, then the best-matching route for D2 will be
182  * selected, ignoring any mismatches between S2 and the interface addresses
183  * on the outgoing interface implied by the route.
184  */
185 typedef enum {
186 	IP_WEAK_ES = 0,
187 	IP_SRC_PRI_ES,
188 	IP_STRONG_ES,
189 	IP_MAXVAL_ES
190 } ip_hostmodel_t;
191 
192 #ifdef	__cplusplus
193 }
194 #endif
195 
196 #endif	/* _INET_TUNABLES_H */
197