Print this page
13175 Add support for IP_RECVTOS
13182 CMSG_ macros should have man pages
Change-ID: I784aa36cfd3c17e3cccbf1fd329fa7e69b663ef9
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/inet/ip_stack.h
+++ new/usr/src/uts/common/inet/ip_stack.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 *
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 *
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /*
28 28 * Copyright 2019 Joyent, Inc.
29 + * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
29 30 */
30 31
31 32 #ifndef _INET_IP_STACK_H
32 33 #define _INET_IP_STACK_H
33 34
34 35 #ifdef __cplusplus
35 36 extern "C" {
36 37 #endif
37 38
38 39 #include <sys/netstack.h>
39 40 #include <netinet/igmp_var.h>
40 41 #include <sys/modhash.h>
41 42
42 43 #ifdef _KERNEL
43 44 #include <sys/list.h>
44 45
45 46
46 47 /*
47 48 * IP statistics.
48 49 */
49 50 #define IP_STAT(ipst, x) ((ipst)->ips_ip_statistics.x.value.ui64++)
50 51 #define IP_STAT_UPDATE(ipst, x, n) \
51 52 ((ipst)->ips_ip_statistics.x.value.ui64 += (n))
52 53
53 54 typedef struct ip_stat {
54 55 kstat_named_t ip_udp_fannorm;
55 56 kstat_named_t ip_udp_fanmb;
56 57 kstat_named_t ip_recv_pullup;
57 58 kstat_named_t ip_db_ref;
58 59 kstat_named_t ip_notaligned;
59 60 kstat_named_t ip_multimblk;
60 61 kstat_named_t ip_opt;
61 62 kstat_named_t ipsec_proto_ahesp;
62 63 kstat_named_t ip_conn_flputbq;
63 64 kstat_named_t ip_conn_walk_drain;
64 65 kstat_named_t ip_out_sw_cksum;
65 66 kstat_named_t ip_out_sw_cksum_bytes;
66 67 kstat_named_t ip_in_sw_cksum;
67 68 kstat_named_t ip_ire_reclaim_calls;
68 69 kstat_named_t ip_ire_reclaim_deleted;
69 70 kstat_named_t ip_nce_reclaim_calls;
70 71 kstat_named_t ip_nce_reclaim_deleted;
71 72 kstat_named_t ip_nce_mcast_reclaim_calls;
72 73 kstat_named_t ip_nce_mcast_reclaim_deleted;
73 74 kstat_named_t ip_nce_mcast_reclaim_tqfail;
74 75 kstat_named_t ip_dce_reclaim_calls;
75 76 kstat_named_t ip_dce_reclaim_deleted;
76 77 kstat_named_t ip_tcp_in_full_hw_cksum_err;
77 78 kstat_named_t ip_tcp_in_part_hw_cksum_err;
↓ open down ↓ |
39 lines elided |
↑ open up ↑ |
78 79 kstat_named_t ip_tcp_in_sw_cksum_err;
79 80 kstat_named_t ip_udp_in_full_hw_cksum_err;
80 81 kstat_named_t ip_udp_in_part_hw_cksum_err;
81 82 kstat_named_t ip_udp_in_sw_cksum_err;
82 83 kstat_named_t conn_in_recvdstaddr;
83 84 kstat_named_t conn_in_recvopts;
84 85 kstat_named_t conn_in_recvif;
85 86 kstat_named_t conn_in_recvslla;
86 87 kstat_named_t conn_in_recvucred;
87 88 kstat_named_t conn_in_recvttl;
89 + kstat_named_t conn_in_recvtos;
88 90 kstat_named_t conn_in_recvhopopts;
89 91 kstat_named_t conn_in_recvhoplimit;
90 92 kstat_named_t conn_in_recvdstopts;
91 93 kstat_named_t conn_in_recvrthdrdstopts;
92 94 kstat_named_t conn_in_recvrthdr;
93 95 kstat_named_t conn_in_recvpktinfo;
94 96 kstat_named_t conn_in_recvtclass;
95 97 kstat_named_t conn_in_timestamp;
96 98 } ip_stat_t;
97 99
98 100
99 101 /*
100 102 * IP6 statistics.
101 103 */
102 104 #define IP6_STAT(ipst, x) ((ipst)->ips_ip6_statistics.x.value.ui64++)
103 105 #define IP6_STAT_UPDATE(ipst, x, n) \
104 106 ((ipst)->ips_ip6_statistics.x.value.ui64 += (n))
105 107
106 108 typedef struct ip6_stat {
107 109 kstat_named_t ip6_udp_fannorm;
108 110 kstat_named_t ip6_udp_fanmb;
109 111 kstat_named_t ip6_recv_pullup;
110 112 kstat_named_t ip6_db_ref;
111 113 kstat_named_t ip6_notaligned;
112 114 kstat_named_t ip6_multimblk;
113 115 kstat_named_t ipsec_proto_ahesp;
114 116 kstat_named_t ip6_out_sw_cksum;
115 117 kstat_named_t ip6_out_sw_cksum_bytes;
116 118 kstat_named_t ip6_in_sw_cksum;
117 119 kstat_named_t ip6_tcp_in_full_hw_cksum_err;
118 120 kstat_named_t ip6_tcp_in_part_hw_cksum_err;
119 121 kstat_named_t ip6_tcp_in_sw_cksum_err;
120 122 kstat_named_t ip6_udp_in_full_hw_cksum_err;
121 123 kstat_named_t ip6_udp_in_part_hw_cksum_err;
122 124 kstat_named_t ip6_udp_in_sw_cksum_err;
123 125 } ip6_stat_t;
124 126
125 127 typedef struct ire_stats {
126 128 uint64_t ire_stats_alloced; /* # of ires alloced */
127 129 uint64_t ire_stats_freed; /* # of ires freed */
128 130 uint64_t ire_stats_inserted; /* # of ires inserted in the bucket */
129 131 uint64_t ire_stats_deleted; /* # of ires deleted from the bucket */
130 132 } ire_stats_t;
131 133
132 134 #define TX_FANOUT_SIZE 128
133 135 #define IDLHASHINDEX(X) \
134 136 ((((uintptr_t)(X) >> 2) + ((uintptr_t)(X) >> 9)) & (TX_FANOUT_SIZE - 1))
135 137
136 138 /* Data structure to represent addresses */
137 139 typedef struct srcid_map {
138 140 struct srcid_map *sm_next;
139 141 in6_addr_t sm_addr; /* Local address */
140 142 uint_t sm_srcid; /* source id */
141 143 uint_t sm_refcnt; /* > 1 ipif with same addr? */
142 144 zoneid_t sm_zoneid; /* zone id */
143 145 } srcid_map_t;
144 146
145 147 /*
146 148 * IP stack instances
147 149 */
148 150 struct ip_stack {
149 151 netstack_t *ips_netstack; /* Common netstack */
150 152
151 153 uint_t ips_src_generation; /* Both IPv4 and IPv6 */
152 154
153 155 struct mod_prop_info_s *ips_propinfo_tbl; /* ip tunables table */
154 156
155 157 mib2_ipIfStatsEntry_t ips_ip_mib; /* SNMP fixed size info */
156 158 mib2_icmp_t ips_icmp_mib;
157 159 /*
158 160 * IPv6 mibs when the interface (ill) is not known.
159 161 * When the ill is known the per-interface mib in the ill is used.
160 162 */
161 163 mib2_ipIfStatsEntry_t ips_ip6_mib;
162 164 mib2_ipv6IfIcmpEntry_t ips_icmp6_mib;
163 165
164 166 struct igmpstat ips_igmpstat;
165 167
166 168 kstat_t *ips_ip_mibkp; /* kstat exporting ip_mib data */
167 169 kstat_t *ips_icmp_mibkp; /* kstat exporting icmp_mib data */
168 170 kstat_t *ips_ip_kstat;
169 171 ip_stat_t ips_ip_statistics;
170 172 kstat_t *ips_ip6_kstat;
171 173 ip6_stat_t ips_ip6_statistics;
172 174
173 175 /* ip.c */
174 176 kmutex_t ips_igmp_timer_lock;
175 177 kmutex_t ips_mld_timer_lock;
176 178 kmutex_t ips_ip_mi_lock;
177 179 kmutex_t ips_ip_addr_avail_lock;
178 180 krwlock_t ips_ill_g_lock;
179 181
180 182 krwlock_t ips_ill_g_usesrc_lock;
181 183
182 184 /* Taskq dispatcher for capability operations */
183 185 kmutex_t ips_capab_taskq_lock;
184 186 kcondvar_t ips_capab_taskq_cv;
185 187 mblk_t *ips_capab_taskq_head;
186 188 mblk_t *ips_capab_taskq_tail;
187 189 kthread_t *ips_capab_taskq_thread;
188 190 boolean_t ips_capab_taskq_quit;
189 191
190 192 /* ipclassifier.c - keep in ip_stack_t */
191 193 /* ipclassifier hash tables */
192 194 struct connf_s *ips_rts_clients;
193 195 struct connf_s *ips_ipcl_conn_fanout;
194 196 struct connf_s *ips_ipcl_bind_fanout;
195 197 struct connf_s *ips_ipcl_proto_fanout_v4;
196 198 struct connf_s *ips_ipcl_proto_fanout_v6;
197 199 struct connf_s *ips_ipcl_udp_fanout;
198 200 struct connf_s *ips_ipcl_raw_fanout; /* RAW SCTP sockets */
199 201 struct connf_s *ips_ipcl_iptun_fanout;
200 202 uint_t ips_ipcl_conn_fanout_size;
201 203 uint_t ips_ipcl_bind_fanout_size;
202 204 uint_t ips_ipcl_udp_fanout_size;
203 205 uint_t ips_ipcl_raw_fanout_size;
204 206 uint_t ips_ipcl_iptun_fanout_size;
205 207 struct connf_s *ips_ipcl_globalhash_fanout;
206 208 int ips_conn_g_index;
207 209
208 210 /* ip.c */
209 211 /* Following protected by igmp_timer_lock */
210 212 int ips_igmp_time_to_next; /* Time since last timeout */
211 213 int ips_igmp_timer_scheduled_last;
212 214 int ips_igmp_deferred_next;
213 215 timeout_id_t ips_igmp_timeout_id;
214 216 boolean_t ips_igmp_timer_setter_active;
215 217 boolean_t ips_igmp_timer_quiesce;
216 218
217 219 /* Following protected by mld_timer_lock */
218 220 int ips_mld_time_to_next; /* Time since last timeout */
219 221 int ips_mld_timer_scheduled_last;
220 222 int ips_mld_deferred_next;
221 223 timeout_id_t ips_mld_timeout_id;
222 224 boolean_t ips_mld_timer_setter_active;
223 225 boolean_t ips_mld_timer_quiesce;
224 226
225 227 /* Protected by igmp_slowtimeout_lock */
226 228 timeout_id_t ips_igmp_slowtimeout_id;
227 229 kmutex_t ips_igmp_slowtimeout_lock;
228 230 boolean_t ips_igmp_slowtimeout_quiesce;
229 231
230 232 /* Protected by mld_slowtimeout_lock */
231 233 timeout_id_t ips_mld_slowtimeout_id;
232 234 kmutex_t ips_mld_slowtimeout_lock;
233 235 boolean_t ips_mld_slowtimeout_quiesce;
234 236
235 237 /* IPv4 forwarding table */
236 238 struct radix_node_head *ips_ip_ftable;
237 239
238 240 #define IPV6_ABITS 128
239 241 #define IP6_MASK_TABLE_SIZE (IPV6_ABITS + 1) /* 129 ptrs */
240 242 struct irb *ips_ip_forwarding_table_v6[IP6_MASK_TABLE_SIZE];
241 243
242 244 /*
243 245 * ire_ft_init_lock is used while initializing ip_forwarding_table
244 246 * dynamically in ire_add.
245 247 */
246 248 kmutex_t ips_ire_ft_init_lock;
247 249
248 250 /*
249 251 * This is the IPv6 counterpart of RADIX_NODE_HEAD_LOCK. It is used
250 252 * to prevent adds and deletes while we are doing a ftable_lookup
251 253 * and extracting the ire_generation.
252 254 */
253 255 krwlock_t ips_ip6_ire_head_lock;
254 256
255 257 uint32_t ips_ip6_ftable_hash_size;
256 258
257 259 ire_stats_t ips_ire_stats_v4; /* IPv4 ire statistics */
258 260 ire_stats_t ips_ire_stats_v6; /* IPv6 ire statistics */
259 261
260 262 /* Count how many condemned objects for kmem_cache callbacks */
261 263 uint32_t ips_num_ire_condemned;
262 264 uint32_t ips_num_nce_condemned;
263 265 uint32_t ips_num_dce_condemned;
264 266
265 267 struct ire_s *ips_ire_reject_v4; /* For unreachable dests */
266 268 struct ire_s *ips_ire_reject_v6; /* For unreachable dests */
267 269 struct ire_s *ips_ire_blackhole_v4; /* For temporary failures */
268 270 struct ire_s *ips_ire_blackhole_v6; /* For temporary failures */
269 271
270 272 /* ips_ire_dep_lock protects ire_dep_* relationship between IREs */
271 273 krwlock_t ips_ire_dep_lock;
272 274
273 275 /* Destination Cache Entries */
274 276 struct dce_s *ips_dce_default;
275 277 uint_t ips_dce_hashsize;
276 278 struct dcb_s *ips_dce_hash_v4;
277 279 struct dcb_s *ips_dce_hash_v6;
278 280 uint_t ips_dce_reclaim_needed;
279 281
280 282 /* pending binds */
281 283 mblk_t *ips_ip6_asp_pending_ops;
282 284 mblk_t *ips_ip6_asp_pending_ops_tail;
283 285
284 286 /* Synchronize updates with table usage */
285 287 mblk_t *ips_ip6_asp_pending_update; /* pending table updates */
286 288
287 289 boolean_t ips_ip6_asp_uip; /* table update in progress */
288 290 kmutex_t ips_ip6_asp_lock; /* protect all the above */
289 291 uint32_t ips_ip6_asp_refcnt; /* outstanding references */
290 292
291 293 struct ip6_asp *ips_ip6_asp_table;
292 294 /* The number of policy entries in the table */
293 295 uint_t ips_ip6_asp_table_count;
294 296
295 297 struct conn_s *ips_ip_g_mrouter;
296 298
297 299 /* Time since last icmp_pkt_err */
298 300 clock_t ips_icmp_pkt_err_last;
299 301 /* Number of packets sent in burst */
300 302 uint_t ips_icmp_pkt_err_sent;
301 303
302 304 /* Protected by ip_mi_lock */
303 305 void *ips_ip_g_head; /* IP Instance Data List Head */
304 306 void *ips_arp_g_head; /* ARP Instance Data List Head */
305 307
306 308 /* Multirouting stuff */
307 309 /* Interval (in ms) between consecutive 'bad MTU' warnings */
308 310 hrtime_t ips_ip_multirt_log_interval;
309 311 /* Time since last warning issued. */
310 312 hrtime_t ips_multirt_bad_mtu_last_time;
311 313
312 314 /*
313 315 * CGTP hooks. Enabling and disabling of hooks is controlled by an
314 316 * IP tunable 'ips_ip_cgtp_filter'.
315 317 */
316 318 struct cgtp_filter_ops *ips_ip_cgtp_filter_ops;
317 319
318 320 struct ipsq_s *ips_ipsq_g_head;
319 321 uint_t ips_ill_index; /* Used to assign interface indicies */
320 322 /* When set search for unused index */
321 323 boolean_t ips_ill_index_wrap;
322 324
323 325 uint_t ips_loopback_packets;
324 326
325 327 /* NDP/NCE structures for IPv4 and IPv6 */
326 328 struct ndp_g_s *ips_ndp4;
327 329 struct ndp_g_s *ips_ndp6;
328 330
329 331 /* ip_mroute stuff */
330 332 kmutex_t ips_ip_g_mrouter_mutex;
331 333
332 334 struct mrtstat *ips_mrtstat; /* Stats for netstat */
333 335 int ips_saved_ip_forwarding;
334 336
335 337 /* numvifs is only a hint about the max interface being used. */
336 338 ushort_t ips_numvifs;
337 339 kmutex_t ips_numvifs_mutex;
338 340
339 341 struct vif *ips_vifs;
340 342 struct mfcb *ips_mfcs; /* kernel routing table */
341 343 struct tbf *ips_tbfs;
342 344 /*
343 345 * One-back cache used to locate a tunnel's vif,
344 346 * given a datagram's src ip address.
345 347 */
346 348 ipaddr_t ips_last_encap_src;
347 349 struct vif *ips_last_encap_vif;
348 350 kmutex_t ips_last_encap_lock; /* Protects the above */
349 351
350 352 /*
351 353 * reg_vif_num is protected by numvifs_mutex
352 354 */
353 355 /* Whether or not special PIM assert processing is enabled. */
354 356 ushort_t ips_reg_vif_num; /* Index to Register vif */
355 357 int ips_pim_assert;
356 358
357 359 union ill_g_head_u *ips_ill_g_heads; /* ILL List Head */
358 360
359 361 kstat_t *ips_loopback_ksp;
360 362
361 363 /* Array of conn drain lists */
362 364 struct idl_tx_list_s *ips_idl_tx_list;
363 365 uint_t ips_conn_drain_list_cnt; /* Count of conn_drain_list */
364 366
365 367 /*
366 368 * ID used to assign next free one.
367 369 * Increases by one. Once it wraps we search for an unused ID.
368 370 */
369 371 uint_t ips_ip_src_id;
370 372 boolean_t ips_srcid_wrapped;
371 373
372 374 struct srcid_map *ips_srcid_head;
373 375 krwlock_t ips_srcid_lock;
374 376
375 377 uint64_t ips_ipif_g_seqid; /* Used only for sctp_addr.c */
376 378 union phyint_list_u *ips_phyint_g_list; /* start of phyint list */
377 379
378 380 /* ip_netinfo.c */
379 381 hook_family_t ips_ipv4root;
380 382 hook_family_t ips_ipv6root;
381 383 hook_family_t ips_arproot;
382 384
383 385 net_handle_t ips_ipv4_net_data;
384 386 net_handle_t ips_ipv6_net_data;
385 387 net_handle_t ips_arp_net_data;
386 388
387 389 /*
388 390 * Hooks for firewalling
389 391 */
390 392 hook_event_t ips_ip4_physical_in_event;
391 393 hook_event_t ips_ip4_physical_out_event;
392 394 hook_event_t ips_ip4_forwarding_event;
393 395 hook_event_t ips_ip4_loopback_in_event;
394 396 hook_event_t ips_ip4_loopback_out_event;
395 397
396 398 hook_event_t ips_ip6_physical_in_event;
397 399 hook_event_t ips_ip6_physical_out_event;
398 400 hook_event_t ips_ip6_forwarding_event;
399 401 hook_event_t ips_ip6_loopback_in_event;
400 402 hook_event_t ips_ip6_loopback_out_event;
401 403
402 404 hook_event_t ips_arp_physical_in_event;
403 405 hook_event_t ips_arp_physical_out_event;
404 406 hook_event_t ips_arp_nic_events;
405 407
406 408 hook_event_token_t ips_ipv4firewall_physical_in;
407 409 hook_event_token_t ips_ipv4firewall_physical_out;
408 410 hook_event_token_t ips_ipv4firewall_forwarding;
409 411 hook_event_token_t ips_ipv4firewall_loopback_in;
410 412 hook_event_token_t ips_ipv4firewall_loopback_out;
411 413
412 414 hook_event_token_t ips_ipv6firewall_physical_in;
413 415 hook_event_token_t ips_ipv6firewall_physical_out;
414 416 hook_event_token_t ips_ipv6firewall_forwarding;
415 417 hook_event_token_t ips_ipv6firewall_loopback_in;
416 418 hook_event_token_t ips_ipv6firewall_loopback_out;
417 419
418 420 hook_event_t ips_ip4_nic_events;
419 421 hook_event_t ips_ip6_nic_events;
420 422 hook_event_token_t ips_ipv4nicevents;
421 423 hook_event_token_t ips_ipv6nicevents;
422 424
423 425 hook_event_token_t ips_arp_physical_in;
424 426 hook_event_token_t ips_arp_physical_out;
425 427 hook_event_token_t ips_arpnicevents;
426 428
427 429 net_handle_t ips_ip4_observe_pr;
428 430 net_handle_t ips_ip6_observe_pr;
429 431 hook_event_t ips_ip4_observe;
430 432 hook_event_t ips_ip6_observe;
431 433 hook_event_token_t ips_ipv4observing;
432 434 hook_event_token_t ips_ipv6observing;
433 435
434 436 struct __ldi_ident *ips_ldi_ident;
435 437
436 438 /* ipmp.c */
437 439 krwlock_t ips_ipmp_lock;
438 440 mod_hash_t *ips_ipmp_grp_hash;
439 441
440 442 };
441 443 typedef struct ip_stack ip_stack_t;
442 444
443 445 /* Finding an ip_stack_t */
444 446 #define CONNQ_TO_IPST(_q) (Q_TO_CONN(_q)->conn_netstack->netstack_ip)
445 447 #define ILLQ_TO_IPST(_q) (((ill_t *)(_q)->q_ptr)->ill_ipst)
446 448 #define PHYINT_TO_IPST(phyi) ((phyi)->phyint_ipsq->ipsq_ipst)
447 449
448 450 #else /* _KERNEL */
449 451 typedef int ip_stack_t;
450 452 #endif /* _KERNEL */
451 453
452 454 #ifdef __cplusplus
453 455 }
454 456 #endif
455 457
456 458 #endif /* _INET_IP_STACK_H */
↓ open down ↓ |
359 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX