Print this page
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/inet/udp_impl.h
+++ new/usr/src/uts/common/inet/udp_impl.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
23 - * Copyright 2015, Joyent, Inc.
24 23 */
25 24
26 25 #ifndef _UDP_IMPL_H
27 26 #define _UDP_IMPL_H
28 27
29 28 /*
30 29 * UDP implementation private declarations. These interfaces are
31 30 * used to build the IP module and are not meant to be accessed
32 31 * by any modules except IP itself. They are undocumented and are
33 32 * subject to change without notice.
34 33 */
35 34
36 35 #ifdef __cplusplus
37 36 extern "C" {
38 37 #endif
39 38
40 39 #ifdef _KERNEL
41 40
42 41 #include <sys/int_types.h>
43 42 #include <sys/netstack.h>
44 43
45 44 #include <netinet/in.h>
46 45 #include <netinet/ip6.h>
47 46
48 47 #include <inet/common.h>
49 48 #include <inet/ip.h>
50 49 #include <inet/optcom.h>
51 50 #include <inet/tunables.h>
52 51
53 52 #define UDP_MOD_ID 5607
54 53
55 54 /*
56 55 * Bind hash list size and hash function. It has to be a power of 2 for
57 56 * hashing.
58 57 */
59 58 #define UDP_BIND_FANOUT_SIZE 512
60 59 #define UDP_BIND_HASH(lport, size) \
61 60 ((ntohs((uint16_t)lport)) & (size - 1))
62 61
63 62 /* UDP bind fanout hash structure. */
64 63 typedef struct udp_fanout_s {
65 64 struct udp_s *uf_udp;
66 65 kmutex_t uf_lock;
67 66 #if defined(_LP64) || defined(_I32LPx)
68 67 char uf_pad[48];
69 68 #else
70 69 char uf_pad[56];
71 70 #endif
72 71 } udp_fanout_t;
73 72
74 73 /* Kstats */
75 74 typedef struct udp_stat { /* Class "net" kstats */
76 75 kstat_named_t udp_sock_fallback;
77 76 kstat_named_t udp_out_opt;
78 77 kstat_named_t udp_out_err_notconn;
79 78 kstat_named_t udp_out_err_output;
80 79 kstat_named_t udp_out_err_tudr;
81 80 #ifdef DEBUG
82 81 kstat_named_t udp_data_conn;
83 82 kstat_named_t udp_data_notconn;
84 83 kstat_named_t udp_out_lastdst;
85 84 kstat_named_t udp_out_diffdst;
86 85 kstat_named_t udp_out_ipv6;
87 86 kstat_named_t udp_out_mapped;
88 87 kstat_named_t udp_out_ipv4;
89 88 #endif
90 89 } udp_stat_t;
91 90
92 91 /*
93 92 * This struct contains only the counter part of udp_stat_t. It is used
94 93 * in udp_stats_cpu_t instead of udp_stat_t to save memory space.
95 94 */
96 95 typedef struct {
97 96 uint64_t udp_sock_fallback;
98 97 uint64_t udp_out_opt;
99 98 uint64_t udp_out_err_notconn;
100 99 uint64_t udp_out_err_output;
101 100 uint64_t udp_out_err_tudr;
102 101 #ifdef DEBUG
103 102 uint64_t udp_data_conn;
104 103 uint64_t udp_data_notconn;
105 104 uint64_t udp_out_lastdst;
106 105 uint64_t udp_out_diffdst;
107 106 uint64_t udp_out_ipv6;
108 107 uint64_t udp_out_mapped;
109 108 uint64_t udp_out_ipv4;
110 109 #endif
111 110 } udp_stat_counter_t;
112 111
113 112 /* Per CPU stats: UDP MIB2 and UDP kstat. */
114 113 typedef struct {
115 114 mib2_udp_t udp_sc_mib;
116 115 udp_stat_counter_t udp_sc_stats;
117 116 } udp_stats_cpu_t;
118 117
119 118 #define UDP_NUM_EPRIV_PORTS 64
120 119
121 120 /* Default buffer size and flow control wake up threshold. */
122 121 #define UDP_RECV_HIWATER (56 * 1024)
123 122 #define UDP_RECV_LOWATER 128
124 123 #define UDP_XMIT_HIWATER (56 * 1024)
125 124 #define UDP_XMIT_LOWATER 1024
126 125
127 126 /*
128 127 * UDP stack instances
129 128 */
130 129 struct udp_stack {
131 130 netstack_t *us_netstack; /* Common netstack */
132 131
133 132 uint_t us_bind_fanout_size;
134 133 udp_fanout_t *us_bind_fanout;
135 134
136 135 int us_num_epriv_ports;
137 136 in_port_t us_epriv_ports[UDP_NUM_EPRIV_PORTS];
138 137 kmutex_t us_epriv_port_lock;
139 138
140 139 /* Hint not protected by any lock */
141 140 in_port_t us_next_port_to_try;
142 141
143 142 /* UDP tunables table */
144 143 struct mod_prop_info_s *us_propinfo_tbl;
145 144
146 145 kstat_t *us_mibkp; /* kstats exporting mib data */
147 146 kstat_t *us_kstat;
148 147
149 148 /*
150 149 * The smallest anonymous port in the priviledged port range which UDP
151 150 * looks for free port. Use in the option UDP_ANONPRIVBIND.
152 151 */
153 152 in_port_t us_min_anonpriv_port;
154 153
155 154 ldi_ident_t us_ldi_ident;
156 155
157 156 udp_stats_cpu_t **us_sc;
158 157 int us_sc_cnt;
159 158 };
160 159
161 160 typedef struct udp_stack udp_stack_t;
162 161
163 162 /* Internal udp control structure, one per open stream */
164 163 typedef struct udp_s {
165 164 /*
166 165 * The addresses and ports in the conn_t and udp_state are protected by
167 166 * conn_lock and the fanout lock i.e. uf_lock. Need both locks to change
168 167 * the fields, either lock is sufficient for reading the field.
169 168 * conn_lock also protects the content of udp_t.
170 169 */
171 170 uint32_t udp_state; /* TPI state */
|
↓ open down ↓ |
138 lines elided |
↑ open up ↑ |
172 171
173 172 ip_pkt_t udp_recv_ipp; /* Used for IPv4 options received */
174 173
175 174 /* Written to only once at the time of opening the endpoint */
176 175 conn_t *udp_connp;
177 176
178 177 uint32_t
179 178 udp_issocket : 1, /* socket mode; sockfs is on top */
180 179 udp_nat_t_endpoint : 1, /* UDP_NAT_T_ENDPOINT option */
181 180 udp_rcvhdr : 1, /* UDP_RCVHDR option */
182 - udp_vxlanhash: 1, /* UDP_SRCPORT_HASH option */
183 - /* Because there's only VXLAN, cheat */
184 - /* and only use a single bit */
185 181 udp_snd_to_conn: 1, /* UDP_SND_TO_CONNECTED option */
186 182
187 - udp_pad_to_bit_31 : 27;
183 + udp_pad_to_bit_31 : 28;
188 184
189 185 /* Following 2 fields protected by the uf_lock */
190 186 struct udp_s *udp_bind_hash; /* Bind hash chain */
191 187 struct udp_s **udp_ptpbhn; /* Pointer to previous bind hash next. */
192 188
193 189 kmutex_t udp_recv_lock; /* recv lock */
194 190 size_t udp_rcv_disply_hiwat; /* user's view of rcvbuf */
195 191 size_t udp_rcv_hiwat; /* receive high watermark */
196 192
197 193 /* Set at open time and never changed */
198 194 udp_stack_t *udp_us; /* Stack instance for zone */
199 195
200 196 int udp_delayed_error;
201 197 mblk_t *udp_fallback_queue_head;
202 198 mblk_t *udp_fallback_queue_tail;
203 199 struct sockaddr_storage udp_delayed_addr;
204 200 } udp_t;
205 201
206 202 /* UDP Protocol header aligned */
207 203 typedef struct udpahdr_s {
208 204 in_port_t uha_src_port; /* Source port */
209 205 in_port_t uha_dst_port; /* Destination port */
210 206 uint16_t uha_length; /* UDP length */
211 207 uint16_t uha_checksum; /* UDP checksum */
212 208 } udpha_t;
213 209
214 210 #define us_wroff_extra us_propinfo_tbl[0].prop_cur_uval
215 211 #define us_ipv4_ttl us_propinfo_tbl[1].prop_cur_uval
216 212 #define us_ipv6_hoplimit us_propinfo_tbl[2].prop_cur_uval
217 213 #define us_smallest_nonpriv_port us_propinfo_tbl[3].prop_cur_uval
218 214 #define us_do_checksum us_propinfo_tbl[4].prop_cur_bval
219 215 #define us_smallest_anon_port us_propinfo_tbl[5].prop_cur_uval
220 216 #define us_largest_anon_port us_propinfo_tbl[6].prop_cur_uval
221 217 #define us_xmit_hiwat us_propinfo_tbl[7].prop_cur_uval
222 218 #define us_xmit_lowat us_propinfo_tbl[8].prop_cur_uval
223 219 #define us_recv_hiwat us_propinfo_tbl[9].prop_cur_uval
224 220 #define us_max_buf us_propinfo_tbl[10].prop_cur_uval
225 221 #define us_pmtu_discovery us_propinfo_tbl[11].prop_cur_bval
226 222 #define us_sendto_ignerr us_propinfo_tbl[12].prop_cur_bval
227 223
228 224 #define UDPS_BUMP_MIB(us, x) \
229 225 BUMP_MIB(&(us)->us_sc[CPU->cpu_seqid]->udp_sc_mib, x)
230 226
231 227 #define UDP_STAT(us, x) ((us)->us_sc[CPU->cpu_seqid]->udp_sc_stats.x++)
232 228 #define UDP_STAT_UPDATE(us, x, n) \
233 229 ((us)->us->sc[CPU->cpu_seqid]->udp_sc_stats.x.value.ui64 += (n))
234 230 #ifdef DEBUG
235 231 #define UDP_DBGSTAT(us, x) UDP_STAT(us, x)
236 232 #else
237 233 #define UDP_DBGSTAT(us, x)
238 234 #endif /* DEBUG */
239 235
240 236 extern int udp_opt_default(queue_t *, t_scalar_t, t_scalar_t, uchar_t *);
241 237 extern int udp_tpi_opt_get(queue_t *, t_scalar_t, t_scalar_t, uchar_t *);
242 238 extern int udp_tpi_opt_set(queue_t *, uint_t, int, int, uint_t, uchar_t *,
243 239 uint_t *, uchar_t *, void *, cred_t *);
244 240 extern mblk_t *udp_snmp_get(queue_t *, mblk_t *, boolean_t);
245 241 extern int udp_snmp_set(queue_t *, t_scalar_t, t_scalar_t, uchar_t *, int);
246 242 extern void udp_ddi_g_init(void);
247 243 extern void udp_ddi_g_destroy(void);
248 244 extern void udp_output(conn_t *connp, mblk_t *mp, struct sockaddr *addr,
249 245 socklen_t addrlen);
250 246 extern void udp_wput(queue_t *, mblk_t *);
251 247
252 248 extern void *udp_kstat_init(netstackid_t stackid);
253 249 extern void udp_kstat_fini(netstackid_t stackid, kstat_t *ksp);
254 250 extern void *udp_kstat2_init(netstackid_t stackid);
255 251 extern void udp_kstat2_fini(netstackid_t, kstat_t *);
256 252
257 253 extern void udp_stack_cpu_add(udp_stack_t *, processorid_t);
258 254
259 255 /*
260 256 * Object to represent database of options to search passed to
261 257 * {sock,tpi}optcom_req() interface routine to take care of option
262 258 * management and associated methods.
263 259 */
264 260 extern optdb_obj_t udp_opt_obj;
265 261 extern uint_t udp_max_optsize;
266 262
267 263 extern sock_lower_handle_t udp_create(int, int, int, sock_downcalls_t **,
268 264 uint_t *, int *, int, cred_t *);
269 265 extern int udp_fallback(sock_lower_handle_t, queue_t *, boolean_t,
270 266 so_proto_quiesced_cb_t, sock_quiesce_arg_t *);
271 267
272 268 extern sock_downcalls_t sock_udp_downcalls;
273 269
274 270 #endif /* _KERNEL */
275 271
276 272 #ifdef __cplusplus
277 273 }
278 274 #endif
279 275
280 276 #endif /* _UDP_IMPL_H */
|
↓ open down ↓ |
83 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX