import openbsd kill(1)
[unleashed.git] / include / inet / ip.h
blob2ef1dff49877b62ec3bd851dd4fd4ee0d858fd81
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
23 * Copyright (c) 1990 Mentat Inc.
24 * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
25 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
26 * Copyright 2017 Nexenta Systems, Inc.
27 * Copyright 2017 OmniTI Computer Consulting, Inc. All rights reserved.
30 #ifndef _INET_IP_H
31 #define _INET_IP_H
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
37 #include <sys/isa_defs.h>
38 #include <sys/types.h>
39 #include <inet/mib2.h>
40 #include <inet/nd.h>
41 #include <sys/atomic.h>
42 #include <net/if_dl.h>
43 #include <net/if.h>
44 #include <netinet/ip.h>
45 #include <netinet/igmp.h>
46 #include <sys/neti.h>
47 #include <sys/hook.h>
48 #include <sys/hook_event.h>
49 #include <sys/hook_impl.h>
50 #include <inet/ip_stack.h>
52 #ifdef _KERNEL
53 #include <netinet/ip6.h>
54 #include <sys/avl.h>
55 #include <sys/list.h>
56 #include <sys/vmem.h>
57 #include <sys/squeue.h>
58 #include <net/route.h>
59 #include <sys/systm.h>
60 #include <net/radix.h>
61 #include <sys/modhash.h>
63 #ifdef DEBUG
64 #define CONN_DEBUG
65 #endif
67 #define IP_DEBUG
69 * The mt-streams(9F) flags for the IP module; put here so that other
70 * "drivers" that are actually IP (e.g., ICMP, UDP) can use the same set
71 * of flags.
73 #define IP_DEVMTFLAGS D_MP
74 #endif /* _KERNEL */
76 #define IP_MOD_NAME "ip"
77 #define IP_DEV_NAME "/dev/ip"
78 #define IP6_DEV_NAME "/dev/ip6"
80 #define UDP_MOD_NAME "udp"
81 #define UDP_DEV_NAME "/dev/udp"
82 #define UDP6_DEV_NAME "/dev/udp6"
84 #define TCP_MOD_NAME "tcp"
85 #define TCP_DEV_NAME "/dev/tcp"
86 #define TCP6_DEV_NAME "/dev/tcp6"
88 #define SCTP_MOD_NAME "sctp"
90 #ifndef _IPADDR_T
91 #define _IPADDR_T
92 typedef uint32_t ipaddr_t;
93 #endif
95 /* Number of bits in an address */
96 #define IP_ABITS 32
97 #define IPV4_ABITS IP_ABITS
98 #define IPV6_ABITS 128
99 #define IP_MAX_HW_LEN 40
101 #define IP_HOST_MASK (ipaddr_t)0xffffffffU
103 #define IP_CSUM(mp, off, sum) (~ip_cksum(mp, off, sum) & 0xFFFF)
104 #define IP_CSUM_PARTIAL(mp, off, sum) ip_cksum(mp, off, sum)
105 #define IP_BCSUM_PARTIAL(bp, len, sum) bcksum(bp, len, sum)
107 #define ILL_FRAG_HASH_TBL_COUNT ((unsigned int)64)
108 #define ILL_FRAG_HASH_TBL_SIZE (ILL_FRAG_HASH_TBL_COUNT * sizeof (ipfb_t))
110 #define IPV4_ADDR_LEN 4
111 #define IP_ADDR_LEN IPV4_ADDR_LEN
112 #define IP_ARP_PROTO_TYPE 0x0800
114 #define IPV4_VERSION 4
115 #define IP_VERSION IPV4_VERSION
116 #define IP_SIMPLE_HDR_LENGTH_IN_WORDS 5
117 #define IP_SIMPLE_HDR_LENGTH 20
118 #define IP_MAX_HDR_LENGTH 60
120 #define IP_MAX_OPT_LENGTH (IP_MAX_HDR_LENGTH-IP_SIMPLE_HDR_LENGTH)
122 #define IP_MIN_MTU (IP_MAX_HDR_LENGTH + 8) /* 68 bytes */
125 * XXX IP_MAXPACKET is defined in <netinet/ip.h> as well. At some point the
126 * 2 files should be cleaned up to remove all redundant definitions.
128 #define IP_MAXPACKET 65535
129 #define IP_SIMPLE_HDR_VERSION \
130 ((IP_VERSION << 4) | IP_SIMPLE_HDR_LENGTH_IN_WORDS)
132 #define UDPH_SIZE 8
135 * Constants and type definitions to support IP IOCTL commands
137 #define IP_IOCTL (('i'<<8)|'p')
138 #define IP_IOC_IRE_DELETE 4
139 #define IP_IOC_IRE_DELETE_NO_REPLY 5
140 #define IP_IOC_RTS_REQUEST 7
142 /* Common definitions used by IP IOCTL data structures */
143 typedef struct ipllcmd_s {
144 uint_t ipllc_cmd;
145 uint_t ipllc_name_offset;
146 uint_t ipllc_name_length;
147 } ipllc_t;
149 /* IP IRE Delete Command Structure. */
150 typedef struct ipid_s {
151 ipllc_t ipid_ipllc;
152 uint_t ipid_ire_type;
153 uint_t ipid_addr_offset;
154 uint_t ipid_addr_length;
155 uint_t ipid_mask_offset;
156 uint_t ipid_mask_length;
157 } ipid_t;
159 #define ipid_cmd ipid_ipllc.ipllc_cmd
161 #ifdef _KERNEL
163 * Temporary state for ip options parser.
165 typedef struct ipoptp_s
167 uint8_t *ipoptp_next; /* next option to look at */
168 uint8_t *ipoptp_end; /* end of options */
169 uint8_t *ipoptp_cur; /* start of current option */
170 uint8_t ipoptp_len; /* length of current option */
171 uint32_t ipoptp_flags;
172 } ipoptp_t;
175 * Flag(s) for ipoptp_flags
177 #define IPOPTP_ERROR 0x00000001
178 #endif /* _KERNEL */
180 /* Controls forwarding of IP packets, set via ipadm(8)/ndd(8) */
181 #define IP_FORWARD_NEVER 0
182 #define IP_FORWARD_ALWAYS 1
184 #define WE_ARE_FORWARDING(ipst) ((ipst)->ips_ip_forwarding == IP_FORWARD_ALWAYS)
186 #define IPH_HDR_LENGTH(ipha) \
187 ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length & 0xF) << 2)
189 #define IPH_HDR_VERSION(ipha) \
190 ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length) >> 4)
192 #ifdef _KERNEL
194 * IP reassembly macros. We hide starting and ending offsets in b_next and
195 * b_prev of messages on the reassembly queue. The messages are chained using
196 * b_cont. These macros are used in ip_reassemble() so we don't have to see
197 * the ugly casts and assignments.
198 * Note that the offsets are <= 64k i.e. a uint_t is sufficient to represent
199 * them.
201 #define IP_REASS_START(mp) ((uint_t)(uintptr_t)((mp)->b_next))
202 #define IP_REASS_SET_START(mp, u) \
203 ((mp)->b_next = (mblk_t *)(uintptr_t)(u))
204 #define IP_REASS_END(mp) ((uint_t)(uintptr_t)((mp)->b_prev))
205 #define IP_REASS_SET_END(mp, u) \
206 ((mp)->b_prev = (mblk_t *)(uintptr_t)(u))
208 #define IP_REASS_COMPLETE 0x1
209 #define IP_REASS_PARTIAL 0x2
210 #define IP_REASS_FAILED 0x4
213 * Test to determine whether this is a module instance of IP or a
214 * driver instance of IP.
216 #define CONN_Q(q) (WR(q)->q_next == NULL)
218 #define Q_TO_CONN(q) ((conn_t *)(q)->q_ptr)
219 #define Q_TO_TCP(q) (Q_TO_CONN((q))->conn_tcp)
220 #define Q_TO_UDP(q) (Q_TO_CONN((q))->conn_udp)
221 #define Q_TO_ICMP(q) (Q_TO_CONN((q))->conn_icmp)
222 #define Q_TO_RTS(q) (Q_TO_CONN((q))->conn_rts)
224 #define CONNP_TO_WQ(connp) ((connp)->conn_wq)
225 #define CONNP_TO_RQ(connp) ((connp)->conn_rq)
227 #define GRAB_CONN_LOCK(q) { \
228 if (q != NULL && CONN_Q(q)) \
229 mutex_enter(&(Q_TO_CONN(q))->conn_lock); \
232 #define RELEASE_CONN_LOCK(q) { \
233 if (q != NULL && CONN_Q(q)) \
234 mutex_exit(&(Q_TO_CONN(q))->conn_lock); \
238 * Ref counter macros for ioctls. This provides a guard for TCP to stop
239 * tcp_close from removing the rq/wq whilst an ioctl is still in flight on the
240 * stream. The ioctl could have been queued on e.g. an ipsq. tcp_close will wait
241 * until the ioctlref count is zero before proceeding.
242 * Ideally conn_oper_pending_ill would be used for this purpose. However, in the
243 * case where an ioctl is aborted or interrupted, it can be cleared prematurely.
244 * There are also some race possibilities between ip and the stream head which
245 * can also end up with conn_oper_pending_ill being cleared prematurely. So, to
246 * avoid these situations, we use a dedicated ref counter for ioctls which is
247 * used in addition to and in parallel with the normal conn_ref count.
249 #define CONN_INC_IOCTLREF_LOCKED(connp) { \
250 ASSERT(MUTEX_HELD(&(connp)->conn_lock)); \
251 DTRACE_PROBE1(conn__inc__ioctlref, conn_t *, (connp)); \
252 (connp)->conn_ioctlref++; \
253 mutex_exit(&(connp)->conn_lock); \
256 #define CONN_INC_IOCTLREF(connp) { \
257 mutex_enter(&(connp)->conn_lock); \
258 CONN_INC_IOCTLREF_LOCKED(connp); \
261 #define CONN_DEC_IOCTLREF(connp) { \
262 mutex_enter(&(connp)->conn_lock); \
263 DTRACE_PROBE1(conn__dec__ioctlref, conn_t *, (connp)); \
264 /* Make sure conn_ioctlref will not underflow. */ \
265 ASSERT((connp)->conn_ioctlref != 0); \
266 if ((--(connp)->conn_ioctlref == 0) && \
267 ((connp)->conn_state_flags & CONN_CLOSING)) { \
268 cv_broadcast(&(connp)->conn_cv); \
270 mutex_exit(&(connp)->conn_lock); \
275 * Complete the pending operation. Usually an ioctl. Can also
276 * be a bind or option management request that got enqueued
277 * in an ipsq_t. Called on completion of the operation.
279 #define CONN_OPER_PENDING_DONE(connp) { \
280 mutex_enter(&(connp)->conn_lock); \
281 (connp)->conn_oper_pending_ill = NULL; \
282 cv_broadcast(&(connp)->conn_refcv); \
283 mutex_exit(&(connp)->conn_lock); \
284 CONN_DEC_REF(connp); \
288 * Values for squeue switch:
290 #define IP_SQUEUE_ENTER_NODRAIN 1
291 #define IP_SQUEUE_ENTER 2
292 #define IP_SQUEUE_FILL 3
294 extern int ip_squeue_flag;
296 /* IP Fragmentation Reassembly Header */
297 typedef struct ipf_s {
298 struct ipf_s *ipf_hash_next;
299 struct ipf_s **ipf_ptphn; /* Pointer to previous hash next. */
300 uint32_t ipf_ident; /* Ident to match. */
301 uint8_t ipf_protocol; /* Protocol to match. */
302 uchar_t ipf_last_frag_seen : 1; /* Last fragment seen ? */
303 time_t ipf_timestamp; /* Reassembly start time. */
304 mblk_t *ipf_mp; /* mblk we live in. */
305 mblk_t *ipf_tail_mp; /* Frag queue tail pointer. */
306 int ipf_hole_cnt; /* Number of holes (hard-case). */
307 int ipf_end; /* Tail end offset (0 -> hard-case). */
308 uint_t ipf_gen; /* Frag queue generation */
309 size_t ipf_count; /* Count of bytes used by frag */
310 uint_t ipf_nf_hdr_len; /* Length of nonfragmented header */
311 in6_addr_t ipf_v6src; /* IPv6 source address */
312 in6_addr_t ipf_v6dst; /* IPv6 dest address */
313 uint_t ipf_prev_nexthdr_offset; /* Offset for nexthdr value */
314 uint8_t ipf_ecn; /* ECN info for the fragments */
315 uint8_t ipf_num_dups; /* Number of times dup frags recvd */
316 uint16_t ipf_checksum_flags; /* Hardware checksum flags */
317 uint32_t ipf_checksum; /* Partial checksum of fragment data */
318 } ipf_t;
321 * IPv4 Fragments
323 #define IS_V4_FRAGMENT(ipha_fragment_offset_and_flags) \
324 (((ntohs(ipha_fragment_offset_and_flags) & IPH_OFFSET) != 0) || \
325 ((ntohs(ipha_fragment_offset_and_flags) & IPH_MF) != 0))
327 #define ipf_src V4_PART_OF_V6(ipf_v6src)
328 #define ipf_dst V4_PART_OF_V6(ipf_v6dst)
330 #endif /* _KERNEL */
332 /* ICMP types */
333 #define ICMP_ECHO_REPLY 0
334 #define ICMP_DEST_UNREACHABLE 3
335 #define ICMP_SOURCE_QUENCH 4
336 #define ICMP_REDIRECT 5
337 #define ICMP_ECHO_REQUEST 8
338 #define ICMP_ROUTER_ADVERTISEMENT 9
339 #define ICMP_ROUTER_SOLICITATION 10
340 #define ICMP_TIME_EXCEEDED 11
341 #define ICMP_PARAM_PROBLEM 12
342 #define ICMP_TIME_STAMP_REQUEST 13
343 #define ICMP_TIME_STAMP_REPLY 14
344 #define ICMP_INFO_REQUEST 15
345 #define ICMP_INFO_REPLY 16
346 #define ICMP_ADDRESS_MASK_REQUEST 17
347 #define ICMP_ADDRESS_MASK_REPLY 18
349 /* Evaluates to true if the ICMP type is an ICMP error */
350 #define ICMP_IS_ERROR(type) ( \
351 (type) == ICMP_DEST_UNREACHABLE || \
352 (type) == ICMP_SOURCE_QUENCH || \
353 (type) == ICMP_TIME_EXCEEDED || \
354 (type) == ICMP_PARAM_PROBLEM)
356 /* ICMP_TIME_EXCEEDED codes */
357 #define ICMP_TTL_EXCEEDED 0
358 #define ICMP_REASSEMBLY_TIME_EXCEEDED 1
360 /* ICMP_DEST_UNREACHABLE codes */
361 #define ICMP_NET_UNREACHABLE 0
362 #define ICMP_HOST_UNREACHABLE 1
363 #define ICMP_PROTOCOL_UNREACHABLE 2
364 #define ICMP_PORT_UNREACHABLE 3
365 #define ICMP_FRAGMENTATION_NEEDED 4
366 #define ICMP_SOURCE_ROUTE_FAILED 5
367 #define ICMP_DEST_NET_UNKNOWN 6
368 #define ICMP_DEST_HOST_UNKNOWN 7
369 #define ICMP_SRC_HOST_ISOLATED 8
370 #define ICMP_DEST_NET_UNREACH_ADMIN 9
371 #define ICMP_DEST_HOST_UNREACH_ADMIN 10
372 #define ICMP_DEST_NET_UNREACH_TOS 11
373 #define ICMP_DEST_HOST_UNREACH_TOS 12
375 /* ICMP Header Structure */
376 typedef struct icmph_s {
377 uint8_t icmph_type;
378 uint8_t icmph_code;
379 uint16_t icmph_checksum;
380 union {
381 struct { /* ECHO request/response structure */
382 uint16_t u_echo_ident;
383 uint16_t u_echo_seqnum;
384 } u_echo;
385 struct { /* Destination unreachable structure */
386 uint16_t u_du_zero;
387 uint16_t u_du_mtu;
388 } u_du;
389 struct { /* Parameter problem structure */
390 uint8_t u_pp_ptr;
391 uint8_t u_pp_rsvd[3];
392 } u_pp;
393 struct { /* Redirect structure */
394 ipaddr_t u_rd_gateway;
395 } u_rd;
396 } icmph_u;
397 } icmph_t;
399 #define icmph_echo_ident icmph_u.u_echo.u_echo_ident
400 #define icmph_echo_seqnum icmph_u.u_echo.u_echo_seqnum
401 #define icmph_du_zero icmph_u.u_du.u_du_zero
402 #define icmph_du_mtu icmph_u.u_du.u_du_mtu
403 #define icmph_pp_ptr icmph_u.u_pp.u_pp_ptr
404 #define icmph_rd_gateway icmph_u.u_rd.u_rd_gateway
406 #define ICMPH_SIZE 8
409 * Minimum length of transport layer header included in an ICMP error
410 * message for it to be considered valid.
412 #define ICMP_MIN_TP_HDR_LEN 8
414 /* Aligned IP header */
415 typedef struct ipha_s {
416 uint8_t ipha_version_and_hdr_length;
417 uint8_t ipha_type_of_service;
418 uint16_t ipha_length;
419 uint16_t ipha_ident;
420 uint16_t ipha_fragment_offset_and_flags;
421 uint8_t ipha_ttl;
422 uint8_t ipha_protocol;
423 uint16_t ipha_hdr_checksum;
424 ipaddr_t ipha_src;
425 ipaddr_t ipha_dst;
426 } ipha_t;
429 * IP Flags
431 * Some of these constant names are copied for the DTrace IP provider in
432 * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept
433 * in sync.
435 #define IPH_DF 0x4000 /* Don't fragment */
436 #define IPH_MF 0x2000 /* More fragments to come */
437 #define IPH_OFFSET 0x1FFF /* Where the offset lives */
439 /* Byte-order specific values */
440 #ifdef _BIG_ENDIAN
441 #define IPH_DF_HTONS 0x4000 /* Don't fragment */
442 #define IPH_MF_HTONS 0x2000 /* More fragments to come */
443 #define IPH_OFFSET_HTONS 0x1FFF /* Where the offset lives */
444 #else
445 #define IPH_DF_HTONS 0x0040 /* Don't fragment */
446 #define IPH_MF_HTONS 0x0020 /* More fragments to come */
447 #define IPH_OFFSET_HTONS 0xFF1F /* Where the offset lives */
448 #endif
450 /* ECN code points for IPv4 TOS byte and IPv6 traffic class octet. */
451 #define IPH_ECN_NECT 0x0 /* Not ECN-Capable Transport */
452 #define IPH_ECN_ECT1 0x1 /* ECN-Capable Transport, ECT(1) */
453 #define IPH_ECN_ECT0 0x2 /* ECN-Capable Transport, ECT(0) */
454 #define IPH_ECN_CE 0x3 /* ECN-Congestion Experienced (CE) */
456 struct ill_s;
458 typedef void ip_v6intfid_func_t(struct ill_s *, in6_addr_t *);
459 typedef void ip_v6mapinfo_func_t(struct ill_s *, uchar_t *, uchar_t *);
460 typedef void ip_v4mapinfo_func_t(struct ill_s *, uchar_t *, uchar_t *);
462 /* IP Mac info structure */
463 typedef struct ip_m_s {
464 t_uscalar_t ip_m_mac_type; /* From <sys/dlpi.h> */
465 int ip_m_type; /* From <net/if_types.h> */
466 t_uscalar_t ip_m_ipv4sap;
467 t_uscalar_t ip_m_ipv6sap;
468 ip_v4mapinfo_func_t *ip_m_v4mapping;
469 ip_v6mapinfo_func_t *ip_m_v6mapping;
470 ip_v6intfid_func_t *ip_m_v6intfid;
471 ip_v6intfid_func_t *ip_m_v6destintfid;
472 } ip_m_t;
475 * The following functions attempt to reduce the link layer dependency
476 * of the IP stack. The current set of link specific operations are:
477 * a. map from IPv4 class D (224.0/4) multicast address range or the
478 * IPv6 multicast address range (ff00::/8) to the link layer multicast
479 * address.
480 * b. derive the default IPv6 interface identifier from the interface.
481 * c. derive the default IPv6 destination interface identifier from
482 * the interface (point-to-point only).
484 extern void ip_mcast_mapping(struct ill_s *, uchar_t *, uchar_t *);
485 /* ip_m_v6*intfid return void and are never NULL */
486 #define MEDIA_V6INTFID(ip_m, ill, v6ptr) (ip_m)->ip_m_v6intfid(ill, v6ptr)
487 #define MEDIA_V6DESTINTFID(ip_m, ill, v6ptr) \
488 (ip_m)->ip_m_v6destintfid(ill, v6ptr)
490 /* Router entry types */
491 #define IRE_BROADCAST 0x0001 /* Route entry for broadcast address */
492 #define IRE_DEFAULT 0x0002 /* Route entry for default gateway */
493 #define IRE_LOCAL 0x0004 /* Route entry for local address */
494 #define IRE_LOOPBACK 0x0008 /* Route entry for loopback address */
495 #define IRE_PREFIX 0x0010 /* Route entry for prefix routes */
496 #ifndef _KERNEL
497 /* Keep so user-level still compiles */
498 #define IRE_CACHE 0x0020 /* Cached Route entry */
499 #endif
500 #define IRE_IF_NORESOLVER 0x0040 /* Route entry for local interface */
501 /* net without any address mapping. */
502 #define IRE_IF_RESOLVER 0x0080 /* Route entry for local interface */
503 /* net with resolver. */
504 #define IRE_HOST 0x0100 /* Host route entry */
505 /* Keep so user-level still compiles */
506 #define IRE_HOST_REDIRECT 0x0200 /* only used for T_SVR4_OPTMGMT_REQ */
507 #define IRE_IF_CLONE 0x0400 /* Per host clone of IRE_IF */
508 #define IRE_MULTICAST 0x0800 /* Special - not in table */
509 #define IRE_NOROUTE 0x1000 /* Special - not in table */
511 #define IRE_INTERFACE (IRE_IF_NORESOLVER | IRE_IF_RESOLVER)
513 #define IRE_IF_ALL (IRE_IF_NORESOLVER | IRE_IF_RESOLVER | \
514 IRE_IF_CLONE)
515 #define IRE_OFFSUBNET (IRE_DEFAULT | IRE_PREFIX | IRE_HOST)
516 #define IRE_OFFLINK IRE_OFFSUBNET
518 * Note that we view IRE_NOROUTE as ONLINK since we can "send" to them without
519 * going through a router; the result of sending will be an error/icmp error.
521 #define IRE_ONLINK (IRE_IF_ALL|IRE_LOCAL|IRE_LOOPBACK| \
522 IRE_BROADCAST|IRE_MULTICAST|IRE_NOROUTE)
524 /* Arguments to ire_flush_cache() */
525 #define IRE_FLUSH_DELETE 0
526 #define IRE_FLUSH_ADD 1
527 #define IRE_FLUSH_GWCHANGE 2
530 * Flags to ire_route_recursive
532 #define IRR_NONE 0
533 #define IRR_ALLOCATE 1 /* OK to allocate IRE_IF_CLONE */
534 #define IRR_INCOMPLETE 2 /* OK to return incomplete chain */
537 * Open/close synchronization flags.
538 * These are kept in a separate field in the conn and the synchronization
539 * depends on the atomic 32 bit access to that field.
541 #define CONN_CLOSING 0x01 /* ip_close waiting for ip_wsrv */
542 #define CONN_CONDEMNED 0x02 /* conn is closing, no more refs */
543 #define CONN_INCIPIENT 0x04 /* conn not yet visible, no refs */
544 #define CONN_QUIESCED 0x08 /* conn is now quiescent */
545 #define CONN_UPDATE_ILL 0x10 /* conn_update_ill in progress */
548 * Flags for dce_flags field. Specifies which information has been set.
549 * dce_ident is always present, but the other ones are identified by the flags.
551 #define DCEF_DEFAULT 0x0001 /* Default DCE - no pmtu or uinfo */
552 #define DCEF_PMTU 0x0002 /* Different than interface MTU */
553 #define DCEF_UINFO 0x0004 /* dce_uinfo set */
554 #define DCEF_TOO_SMALL_PMTU 0x0008 /* Smaller than IPv4 MIN */
556 #ifdef _KERNEL
558 * Extra structures need for per-src-addr filtering (IGMPv3/MLDv2)
560 #define MAX_FILTER_SIZE 64
562 typedef struct slist_s {
563 int sl_numsrc;
564 in6_addr_t sl_addr[MAX_FILTER_SIZE];
565 } slist_t;
568 * Following struct is used to maintain retransmission state for
569 * a multicast group. One rtx_state_t struct is an in-line field
570 * of the ilm_t struct; the slist_ts in the rtx_state_t struct are
571 * alloc'd as needed.
573 typedef struct rtx_state_s {
574 uint_t rtx_timer; /* retrans timer */
575 int rtx_cnt; /* retrans count */
576 int rtx_fmode_cnt; /* retrans count for fmode change */
577 slist_t *rtx_allow;
578 slist_t *rtx_block;
579 } rtx_state_t;
582 * Used to construct list of multicast address records that will be
583 * sent in a single listener report.
585 typedef struct mrec_s {
586 struct mrec_s *mrec_next;
587 uint8_t mrec_type;
588 uint8_t mrec_auxlen; /* currently unused */
589 in6_addr_t mrec_group;
590 slist_t mrec_srcs;
591 } mrec_t;
593 /* Group membership list per upper conn */
596 * We record the multicast information from the socket option in
597 * ilg_ifaddr/ilg_ifindex. This allows rejoining the group in the case when
598 * the ifaddr (or ifindex) disappears and later reappears, potentially on
599 * a different ill. The IPv6 multicast socket options and ioctls all specify
600 * the interface using an ifindex. For IPv4 some socket options/ioctls use
601 * the interface address and others use the index. We record here the method
602 * that was actually used (and leave the other of ilg_ifaddr or ilg_ifindex)
603 * at zero so that we can rejoin the way the application intended.
605 * We track the ill on which we will or already have joined an ilm using
606 * ilg_ill. When we have succeeded joining the ilm and have a refhold on it
607 * then we set ilg_ilm. Thus intentionally there is a window where ilg_ill is
608 * set and ilg_ilm is not set. This allows clearing ilg_ill as a signal that
609 * the ill is being unplumbed and the ilm should be discarded.
611 * ilg records the state of multicast memberships of a socket end point.
612 * ilm records the state of multicast memberships with the driver and is
613 * maintained per interface.
615 * The ilg state is protected by conn_ilg_lock.
616 * The ilg will not be freed until ilg_refcnt drops to zero.
618 typedef struct ilg_s {
619 struct ilg_s *ilg_next;
620 struct ilg_s **ilg_ptpn;
621 struct conn_s *ilg_connp; /* Back pointer to get lock */
622 in6_addr_t ilg_v6group;
623 ipaddr_t ilg_ifaddr; /* For some IPv4 cases */
624 uint_t ilg_ifindex; /* IPv6 and some other IPv4 cases */
625 struct ill_s *ilg_ill; /* Where ilm is joined. No refhold */
626 struct ilm_s *ilg_ilm; /* With ilm_refhold */
627 uint_t ilg_refcnt;
628 mcast_record_t ilg_fmode; /* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */
629 slist_t *ilg_filter;
630 boolean_t ilg_condemned; /* Conceptually deleted */
631 } ilg_t;
634 * Multicast address list entry for ill.
635 * ilm_ill is used by IPv4 and IPv6
637 * The ilm state (and other multicast state on the ill) is protected by
638 * ill_mcast_lock. Operations that change state on both an ilg and ilm
639 * in addition use ill_mcast_serializer to ensure that we can't have
640 * interleaving between e.g., add and delete operations for the same conn_t,
641 * group, and ill. The ill_mcast_serializer is also used to ensure that
642 * multicast group joins do not occur on an interface that is in the process
643 * of joining an IPMP group.
645 * The comment below (and for other netstack_t references) refers
646 * to the fact that we only do netstack_hold in particular cases,
647 * such as the references from open endpoints (ill_t and conn_t's
648 * pointers). Internally within IP we rely on IP's ability to cleanup e.g.
649 * ire_t's when an ill goes away.
651 typedef struct ilm_s {
652 in6_addr_t ilm_v6addr;
653 int ilm_refcnt;
654 uint_t ilm_timer; /* IGMP/MLD query resp timer, in msec */
655 struct ilm_s *ilm_next; /* Linked list for each ill */
656 uint_t ilm_state; /* state of the membership */
657 struct ill_s *ilm_ill; /* Back pointer to ill - ill_ilm_cnt */
658 zoneid_t ilm_zoneid;
659 int ilm_no_ilg_cnt; /* number of joins w/ no ilg */
660 mcast_record_t ilm_fmode; /* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */
661 slist_t *ilm_filter; /* source filter list */
662 slist_t *ilm_pendsrcs; /* relevant src addrs for pending req */
663 rtx_state_t ilm_rtx; /* SCR retransmission state */
664 ipaddr_t ilm_ifaddr; /* For IPv4 netstat */
665 ip_stack_t *ilm_ipst; /* Does not have a netstack_hold */
666 } ilm_t;
668 #define ilm_addr V4_PART_OF_V6(ilm_v6addr)
671 * Soft reference to an IPsec SA.
673 * On relative terms, conn's can be persistent (living as long as the
674 * processes which create them), while SA's are ephemeral (dying when
675 * they hit their time-based or byte-based lifetimes).
677 * We could hold a hard reference to an SA from an ipsec_latch_t,
678 * but this would cause expired SA's to linger for a potentially
679 * unbounded time.
681 * Instead, we remember the hash bucket number and bucket generation
682 * in addition to the pointer. The bucket generation is incremented on
683 * each deletion.
685 typedef struct ipsa_ref_s
687 struct ipsa_s *ipsr_sa;
688 struct isaf_s *ipsr_bucket;
689 uint64_t ipsr_gen;
690 } ipsa_ref_t;
693 * IPsec "latching" state.
695 * In the presence of IPsec policy, fully-bound conn's bind a connection
696 * to more than just the 5-tuple, but also a specific IPsec action and
697 * identity-pair.
698 * The identity pair is accessed from both the receive and transmit side
699 * hence it is maintained in the ipsec_latch_t structure. conn_latch and
700 * ixa_ipsec_latch points to it.
701 * The policy and actions are stored in conn_latch_in_policy and
702 * conn_latch_in_action for the inbound side, and in ixa_ipsec_policy and
703 * ixa_ipsec_action for the transmit side.
705 * As an optimization, we also cache soft references to IPsec SA's in
706 * ip_xmit_attr_t so that we can fast-path around most of the work needed for
707 * outbound IPsec SA selection.
709 typedef struct ipsec_latch_s
711 kmutex_t ipl_lock;
712 uint32_t ipl_refcnt;
714 struct ipsid_s *ipl_local_cid;
715 struct ipsid_s *ipl_remote_cid;
716 unsigned int
717 ipl_ids_latched : 1,
719 ipl_pad_to_bit_31 : 31;
720 } ipsec_latch_t;
722 #define IPLATCH_REFHOLD(ipl) { \
723 atomic_inc_32(&(ipl)->ipl_refcnt); \
724 ASSERT((ipl)->ipl_refcnt != 0); \
727 #define IPLATCH_REFRELE(ipl) { \
728 ASSERT((ipl)->ipl_refcnt != 0); \
729 membar_exit(); \
730 if (atomic_dec_32_nv(&(ipl)->ipl_refcnt) == 0) \
731 iplatch_free(ipl); \
735 * peer identity structure.
737 typedef struct conn_s conn_t;
740 * This is used to match an inbound/outbound datagram with policy.
742 typedef struct ipsec_selector {
743 in6_addr_t ips_local_addr_v6;
744 in6_addr_t ips_remote_addr_v6;
745 uint16_t ips_local_port;
746 uint16_t ips_remote_port;
747 uint8_t ips_icmp_type;
748 uint8_t ips_icmp_code;
749 uint8_t ips_protocol;
750 uint8_t ips_isv4 : 1,
751 ips_is_icmp_inv_acq: 1;
752 } ipsec_selector_t;
755 * Note that we put v4 addresses in the *first* 32-bit word of the
756 * selector rather than the last to simplify the prefix match/mask code
757 * in spd.c
759 #define ips_local_addr_v4 ips_local_addr_v6.s6_addr32[0]
760 #define ips_remote_addr_v4 ips_remote_addr_v6.s6_addr32[0]
762 /* Values used in IP by IPSEC Code */
763 #define IPSEC_OUTBOUND B_TRUE
764 #define IPSEC_INBOUND B_FALSE
767 * There are two variants in policy failures. The packet may come in
768 * secure when not needed (IPSEC_POLICY_???_NOT_NEEDED) or it may not
769 * have the desired level of protection (IPSEC_POLICY_MISMATCH).
771 #define IPSEC_POLICY_NOT_NEEDED 0
772 #define IPSEC_POLICY_MISMATCH 1
773 #define IPSEC_POLICY_AUTH_NOT_NEEDED 2
774 #define IPSEC_POLICY_ENCR_NOT_NEEDED 3
775 #define IPSEC_POLICY_SE_NOT_NEEDED 4
776 #define IPSEC_POLICY_MAX 5 /* Always max + 1. */
779 * Check with IPSEC inbound policy if
781 * 1) per-socket policy is present - indicated by conn_in_enforce_policy.
782 * 2) Or if we have not cached policy on the conn and the global policy is
783 * non-empty.
785 #define CONN_INBOUND_POLICY_PRESENT(connp, ipss) \
786 ((connp)->conn_in_enforce_policy || \
787 (!((connp)->conn_policy_cached) && \
788 (ipss)->ipsec_inbound_v4_policy_present))
790 #define CONN_INBOUND_POLICY_PRESENT_V6(connp, ipss) \
791 ((connp)->conn_in_enforce_policy || \
792 (!(connp)->conn_policy_cached && \
793 (ipss)->ipsec_inbound_v6_policy_present))
795 #define CONN_OUTBOUND_POLICY_PRESENT(connp, ipss) \
796 ((connp)->conn_out_enforce_policy || \
797 (!((connp)->conn_policy_cached) && \
798 (ipss)->ipsec_outbound_v4_policy_present))
800 #define CONN_OUTBOUND_POLICY_PRESENT_V6(connp, ipss) \
801 ((connp)->conn_out_enforce_policy || \
802 (!(connp)->conn_policy_cached && \
803 (ipss)->ipsec_outbound_v6_policy_present))
806 * Information cached in IRE for upper layer protocol (ULP).
808 typedef struct iulp_s {
809 boolean_t iulp_set; /* Is any metric set? */
810 uint32_t iulp_ssthresh; /* Slow start threshold (TCP). */
811 clock_t iulp_rtt; /* Guestimate in millisecs. */
812 clock_t iulp_rtt_sd; /* Cached value of RTT variance. */
813 uint32_t iulp_spipe; /* Send pipe size. */
814 uint32_t iulp_rpipe; /* Receive pipe size. */
815 uint32_t iulp_rtomax; /* Max round trip timeout. */
816 uint32_t iulp_sack; /* Use SACK option (TCP)? */
817 uint32_t iulp_mtu; /* Setable with routing sockets */
819 uint32_t
820 iulp_tstamp_ok : 1, /* Use timestamp option (TCP)? */
821 iulp_wscale_ok : 1, /* Use window scale option (TCP)? */
822 iulp_ecn_ok : 1, /* Enable ECN (for TCP)? */
823 iulp_pmtud_ok : 1, /* Enable PMTUd? */
825 /* These three are passed out by ip_set_destination */
826 iulp_localnet: 1, /* IRE_ONLINK */
827 iulp_loopback: 1, /* IRE_LOOPBACK */
828 iulp_local: 1, /* IRE_LOCAL */
830 iulp_not_used : 25;
831 } iulp_t;
834 * The conn drain list structure (idl_t), protected by idl_lock. Each conn_t
835 * inserted in the list points back at this idl_t using conn_idl, and is
836 * chained by conn_drain_next and conn_drain_prev, which are also protected by
837 * idl_lock. When flow control is relieved, either ip_wsrv() (STREAMS) or
838 * ill_flow_enable() (non-STREAMS) will call conn_drain().
840 * The conn drain list, idl_t, itself is part of tx cookie list structure.
841 * A tx cookie list points to a blocked Tx ring and contains the list of
842 * all conn's that are blocked due to the flow-controlled Tx ring (via
843 * the idl drain list). Note that a link can have multiple Tx rings. The
844 * drain list will store the conn's blocked due to Tx ring being flow
845 * controlled.
848 typedef uintptr_t ip_mac_tx_cookie_t;
849 typedef struct idl_s idl_t;
850 typedef struct idl_tx_list_s idl_tx_list_t;
852 struct idl_tx_list_s {
853 ip_mac_tx_cookie_t txl_cookie;
854 kmutex_t txl_lock; /* Lock for this list */
855 idl_t *txl_drain_list;
856 int txl_drain_index;
859 struct idl_s {
860 conn_t *idl_conn; /* Head of drain list */
861 kmutex_t idl_lock; /* Lock for this list */
862 idl_tx_list_t *idl_itl;
866 * Interface route structure which holds the necessary information to recreate
867 * routes that are tied to an interface i.e. have ire_ill set.
869 * These routes which were initially created via a routing socket or via the
870 * SIOCADDRT ioctl may be gateway routes (RTF_GATEWAY being set) or may be
871 * traditional interface routes. When an ill comes back up after being
872 * down, this information will be used to recreate the routes. These
873 * are part of an mblk_t chain that hangs off of the ILL (ill_saved_ire_mp).
875 typedef struct ifrt_s {
876 ushort_t ifrt_type; /* Type of IRE */
877 in6_addr_t ifrt_v6addr; /* Address IRE represents. */
878 in6_addr_t ifrt_v6gateway_addr; /* Gateway if IRE_OFFLINK */
879 in6_addr_t ifrt_v6setsrc_addr; /* Src addr if RTF_SETSRC */
880 in6_addr_t ifrt_v6mask; /* Mask for matching IRE. */
881 uint32_t ifrt_flags; /* flags related to route */
882 iulp_t ifrt_metrics; /* Routing socket metrics */
883 zoneid_t ifrt_zoneid; /* zoneid for route */
884 } ifrt_t;
886 #define ifrt_addr V4_PART_OF_V6(ifrt_v6addr)
887 #define ifrt_gateway_addr V4_PART_OF_V6(ifrt_v6gateway_addr)
888 #define ifrt_mask V4_PART_OF_V6(ifrt_v6mask)
889 #define ifrt_setsrc_addr V4_PART_OF_V6(ifrt_v6setsrc_addr)
891 /* Number of IP addresses that can be hosted on a physical interface */
892 #define MAX_ADDRS_PER_IF 8192
894 * Number of Source addresses to be considered for source address
895 * selection. Used by ipif_select_source_v4/v6.
897 #define MAX_IPIF_SELECT_SOURCE 50
899 #ifdef IP_DEBUG
901 * Trace refholds and refreles for debugging.
903 #define TR_STACK_DEPTH 14
904 typedef struct tr_buf_s {
905 int tr_depth;
906 clock_t tr_time;
907 pc_t tr_stack[TR_STACK_DEPTH];
908 } tr_buf_t;
910 typedef struct th_trace_s {
911 int th_refcnt;
912 uint_t th_trace_lastref;
913 kthread_t *th_id;
914 #define TR_BUF_MAX 38
915 tr_buf_t th_trbuf[TR_BUF_MAX];
916 } th_trace_t;
918 typedef struct th_hash_s {
919 list_node_t thh_link;
920 mod_hash_t *thh_hash;
921 ip_stack_t *thh_ipst;
922 } th_hash_t;
923 #endif
925 /* The following are ipif_state_flags */
926 #define IPIF_CONDEMNED 0x1 /* The ipif is being removed */
927 #define IPIF_CHANGING 0x2 /* A critcal ipif field is changing */
928 #define IPIF_SET_LINKLOCAL 0x10 /* transient flag during bringup */
930 /* IP interface structure, one per local address */
931 typedef struct ipif_s {
932 struct ipif_s *ipif_next;
933 struct ill_s *ipif_ill; /* Back pointer to our ill */
934 int ipif_id; /* Logical unit number */
935 in6_addr_t ipif_v6lcl_addr; /* Local IP address for this if. */
936 in6_addr_t ipif_v6subnet; /* Subnet prefix for this if. */
937 in6_addr_t ipif_v6net_mask; /* Net mask for this interface. */
938 in6_addr_t ipif_v6brd_addr; /* Broadcast addr for this interface. */
939 in6_addr_t ipif_v6pp_dst_addr; /* Point-to-point dest address. */
940 uint64_t ipif_flags; /* Interface flags. */
941 uint_t ipif_ire_type; /* IRE_LOCAL or IRE_LOOPBACK */
944 * The packet count in the ipif contain the sum of the
945 * packet counts in dead IRE_LOCAL/LOOPBACK for this ipif.
947 uint_t ipif_ib_pkt_count; /* Inbound packets for our dead IREs */
949 /* Exclusive bit fields, protected by ipsq_t */
950 unsigned int
951 ipif_was_up : 1, /* ipif was up before */
952 ipif_addr_ready : 1, /* DAD is done */
953 ipif_was_dup : 1, /* DAD had failed */
954 ipif_added_nce : 1, /* nce added for local address */
956 ipif_pad_to_31 : 28;
958 ilm_t *ipif_allhosts_ilm; /* For all-nodes join */
959 ilm_t *ipif_solmulti_ilm; /* For IPv6 solicited multicast join */
961 uint_t ipif_seqid; /* unique index across all ills */
962 uint_t ipif_state_flags; /* See IPIF_* flag defs above */
963 uint_t ipif_refcnt; /* active consistent reader cnt */
965 zoneid_t ipif_zoneid; /* zone ID number */
966 timeout_id_t ipif_recovery_id; /* Timer for DAD recovery */
967 boolean_t ipif_trace_disable; /* True when alloc fails */
969 * For an IPMP interface, ipif_bound_ill tracks the ill whose hardware
970 * information this ipif is associated with via ARP/NDP. We can use
971 * an ill pointer (rather than an index) because only ills that are
972 * part of a group will be pointed to, and an ill cannot disappear
973 * while it's in a group.
975 struct ill_s *ipif_bound_ill;
976 struct ipif_s *ipif_bound_next; /* bound ipif chain */
977 boolean_t ipif_bound; /* B_TRUE if we successfully bound */
979 struct ire_s *ipif_ire_local; /* Our IRE_LOCAL or LOOPBACK */
980 struct ire_s *ipif_ire_if; /* Our IRE_INTERFACE */
981 } ipif_t;
984 * The following table lists the protection levels of the various members
985 * of the ipif_t. The following notation is used.
987 * Write once - Written to only once at the time of bringing up
988 * the interface and can be safely read after the bringup without any lock.
990 * ipsq - Need to execute in the ipsq to perform the indicated access.
992 * ill_lock - Need to hold this mutex to perform the indicated access.
994 * ill_g_lock - Need to hold this rw lock as reader/writer for read access or
995 * write access respectively.
997 * down ill - Written to only when the ill is down (i.e all ipifs are down)
998 * up ill - Read only when the ill is up (i.e. at least 1 ipif is up)
1000 * Table of ipif_t members and their protection
1002 * ipif_next ipsq + ill_lock + ipsq OR ill_lock OR
1003 * ill_g_lock ill_g_lock
1004 * ipif_ill ipsq + down ipif write once
1005 * ipif_id ipsq + down ipif write once
1006 * ipif_v6lcl_addr ipsq + down ipif up ipif
1007 * ipif_v6subnet ipsq + down ipif up ipif
1008 * ipif_v6net_mask ipsq + down ipif up ipif
1010 * ipif_v6brd_addr
1011 * ipif_v6pp_dst_addr
1012 * ipif_flags ill_lock ill_lock
1013 * ipif_ire_type ipsq + down ill up ill
1015 * ipif_ib_pkt_count Approx
1017 * bit fields ill_lock ill_lock
1019 * ipif_allhosts_ilm ipsq ipsq
1020 * ipif_solmulti_ilm ipsq ipsq
1022 * ipif_seqid ipsq Write once
1024 * ipif_state_flags ill_lock ill_lock
1025 * ipif_refcnt ill_lock ill_lock
1026 * ipif_bound_ill ipsq + ipmp_lock ipsq OR ipmp_lock
1027 * ipif_bound_next ipsq ipsq
1028 * ipif_bound ipsq ipsq
1030 * ipif_ire_local ipsq + ips_ill_g_lock ipsq OR ips_ill_g_lock
1031 * ipif_ire_if ipsq + ips_ill_g_lock ipsq OR ips_ill_g_lock
1035 * Return values from ip_laddr_verify_{v4,v6}
1037 typedef enum { IPVL_UNICAST_UP, IPVL_UNICAST_DOWN, IPVL_MCAST, IPVL_BCAST,
1038 IPVL_BAD} ip_laddr_t;
1041 #define IP_TR_HASH(tid) ((((uintptr_t)tid) >> 6) & (IP_TR_HASH_MAX - 1))
1043 #ifdef DEBUG
1044 #define IPIF_TRACE_REF(ipif) ipif_trace_ref(ipif)
1045 #define ILL_TRACE_REF(ill) ill_trace_ref(ill)
1046 #define IPIF_UNTRACE_REF(ipif) ipif_untrace_ref(ipif)
1047 #define ILL_UNTRACE_REF(ill) ill_untrace_ref(ill)
1048 #else
1049 #define IPIF_TRACE_REF(ipif)
1050 #define ILL_TRACE_REF(ill)
1051 #define IPIF_UNTRACE_REF(ipif)
1052 #define ILL_UNTRACE_REF(ill)
1053 #endif
1055 /* IPv4 compatibility macros */
1056 #define ipif_lcl_addr V4_PART_OF_V6(ipif_v6lcl_addr)
1057 #define ipif_subnet V4_PART_OF_V6(ipif_v6subnet)
1058 #define ipif_net_mask V4_PART_OF_V6(ipif_v6net_mask)
1059 #define ipif_brd_addr V4_PART_OF_V6(ipif_v6brd_addr)
1060 #define ipif_pp_dst_addr V4_PART_OF_V6(ipif_v6pp_dst_addr)
1062 /* Macros for easy backreferences to the ill. */
1063 #define ipif_isv6 ipif_ill->ill_isv6
1065 #define SIOCLIFADDR_NDX 112 /* ndx of SIOCLIFADDR in the ndx ioctl table */
1068 * mode value for ip_ioctl_finish for finishing an ioctl
1070 #define CONN_CLOSE 1 /* No mi_copy */
1071 #define COPYOUT 2 /* do an mi_copyout if needed */
1072 #define NO_COPYOUT 3 /* do an mi_copy_done */
1073 #define IPI2MODE(ipi) ((ipi)->ipi_flags & IPI_GET_CMD ? COPYOUT : NO_COPYOUT)
1076 * The IP-MT design revolves around the serialization objects ipsq_t (IPSQ)
1077 * and ipxop_t (exclusive operation or "xop"). Becoming "writer" on an IPSQ
1078 * ensures that no other threads can become "writer" on any IPSQs sharing that
1079 * IPSQ's xop until the writer thread is done.
1081 * Each phyint points to one IPSQ that remains fixed over the phyint's life.
1082 * Each IPSQ points to one xop that can change over the IPSQ's life. If a
1083 * phyint is *not* in an IPMP group, then its IPSQ will refer to the IPSQ's
1084 * "own" xop (ipsq_ownxop). If a phyint *is* part of an IPMP group, then its
1085 * IPSQ will refer to the "group" xop, which is shorthand for the xop of the
1086 * IPSQ of the IPMP meta-interface's phyint. Thus, all phyints that are part
1087 * of the same IPMP group will have their IPSQ's point to the group xop, and
1088 * thus becoming "writer" on any phyint in the group will prevent any other
1089 * writer on any other phyint in the group. All IPSQs sharing the same xop
1090 * are chained together through ipsq_next (in the degenerate common case,
1091 * ipsq_next simply refers to itself). Note that the group xop is guaranteed
1092 * to exist at least as long as there are members in the group, since the IPMP
1093 * meta-interface can only be destroyed if the group is empty.
1095 * Incoming exclusive operation requests are enqueued on the IPSQ they arrived
1096 * on rather than the xop. This makes switching xop's (as would happen when a
1097 * phyint leaves an IPMP group) simple, because after the phyint leaves the
1098 * group, any operations enqueued on its IPSQ can be safely processed with
1099 * respect to its new xop, and any operations enqueued on the IPSQs of its
1100 * former group can be processed with respect to their existing group xop.
1101 * Even so, switching xops is a subtle dance; see ipsq_dq() for details.
1103 * An IPSQ's "own" xop is embedded within the IPSQ itself since they have have
1104 * identical lifetimes, and because doing so simplifies pointer management.
1105 * While each phyint and IPSQ point to each other, it is not possible to free
1106 * the IPSQ when the phyint is freed, since we may still *inside* the IPSQ
1107 * when the phyint is being freed. Thus, ipsq_phyint is set to NULL when the
1108 * phyint is freed, and the IPSQ free is later done in ipsq_exit().
1110 * ipsq_t synchronization: read write
1112 * ipsq_xopq_mphead ipx_lock ipx_lock
1113 * ipsq_xopq_mptail ipx_lock ipx_lock
1114 * ipsq_xop_switch_mp ipsq_lock ipsq_lock
1115 * ipsq_phyint write once write once
1116 * ipsq_next RW_READER ill_g_lock RW_WRITER ill_g_lock
1117 * ipsq_xop ipsq_lock or ipsq ipsq_lock + ipsq
1118 * ipsq_swxop ipsq ipsq
1119 * ipsq_ownxop see ipxop_t see ipxop_t
1120 * ipsq_ipst write once write once
1122 * ipxop_t synchronization: read write
1124 * ipx_writer ipx_lock ipx_lock
1125 * ipx_xop_queued ipx_lock ipx_lock
1126 * ipx_mphead ipx_lock ipx_lock
1127 * ipx_mptail ipx_lock ipx_lock
1128 * ipx_ipsq write once write once
1129 * ips_ipsq_queued ipx_lock ipx_lock
1130 * ipx_waitfor ipsq or ipx_lock ipsq + ipx_lock
1131 * ipx_reentry_cnt ipsq or ipx_lock ipsq + ipx_lock
1132 * ipx_current_done ipsq ipsq
1133 * ipx_current_ioctl ipsq ipsq
1134 * ipx_current_ipif ipsq or ipx_lock ipsq + ipx_lock
1135 * ipx_pending_ipif ipsq or ipx_lock ipsq + ipx_lock
1136 * ipx_pending_mp ipsq or ipx_lock ipsq + ipx_lock
1137 * ipx_forced ipsq ipsq
1138 * ipx_depth ipsq ipsq
1139 * ipx_stack ipsq ipsq
1141 typedef struct ipxop_s {
1142 kmutex_t ipx_lock; /* see above */
1143 kthread_t *ipx_writer; /* current owner */
1144 mblk_t *ipx_mphead; /* messages tied to this op */
1145 mblk_t *ipx_mptail;
1146 struct ipsq_s *ipx_ipsq; /* associated ipsq */
1147 boolean_t ipx_ipsq_queued; /* ipsq using xop has queued op */
1148 int ipx_waitfor; /* waiting; values encoded below */
1149 int ipx_reentry_cnt;
1150 boolean_t ipx_current_done; /* is the current operation done? */
1151 int ipx_current_ioctl; /* current ioctl, or 0 if no ioctl */
1152 ipif_t *ipx_current_ipif; /* ipif for current op */
1153 ipif_t *ipx_pending_ipif; /* ipif for ipx_pending_mp */
1154 mblk_t *ipx_pending_mp; /* current ioctl mp while waiting */
1155 boolean_t ipx_forced; /* debugging aid */
1156 #ifdef DEBUG
1157 int ipx_depth; /* debugging aid */
1158 #define IPX_STACK_DEPTH 15
1159 pc_t ipx_stack[IPX_STACK_DEPTH]; /* debugging aid */
1160 #endif
1161 } ipxop_t;
1163 typedef struct ipsq_s {
1164 kmutex_t ipsq_lock; /* see above */
1165 mblk_t *ipsq_switch_mp; /* op to handle right after switch */
1166 mblk_t *ipsq_xopq_mphead; /* list of excl ops (mostly ioctls) */
1167 mblk_t *ipsq_xopq_mptail;
1168 struct phyint *ipsq_phyint; /* associated phyint */
1169 struct ipsq_s *ipsq_next; /* next ipsq sharing ipsq_xop */
1170 struct ipxop_s *ipsq_xop; /* current xop synchronization info */
1171 struct ipxop_s *ipsq_swxop; /* switch xop to on ipsq_exit() */
1172 struct ipxop_s ipsq_ownxop; /* our own xop (may not be in-use) */
1173 ip_stack_t *ipsq_ipst; /* does not have a netstack_hold */
1174 } ipsq_t;
1177 * ipx_waitfor values:
1179 enum {
1180 IPIF_DOWN = 1, /* ipif_down() waiting for refcnts to drop */
1181 ILL_DOWN, /* ill_down() waiting for refcnts to drop */
1182 IPIF_FREE, /* ipif_free() waiting for refcnts to drop */
1183 ILL_FREE /* ill unplumb waiting for refcnts to drop */
1186 /* Operation types for ipsq_try_enter() */
1187 #define CUR_OP 0 /* request writer within current operation */
1188 #define NEW_OP 1 /* request writer for a new operation */
1189 #define SWITCH_OP 2 /* request writer once IPSQ XOP switches */
1192 * Kstats tracked on each IPMP meta-interface. Order here must match
1193 * ipmp_kstats[] in ip/ipmp.c.
1195 enum {
1196 IPMP_KSTAT_OBYTES, IPMP_KSTAT_OBYTES64, IPMP_KSTAT_RBYTES,
1197 IPMP_KSTAT_RBYTES64, IPMP_KSTAT_OPACKETS, IPMP_KSTAT_OPACKETS64,
1198 IPMP_KSTAT_OERRORS, IPMP_KSTAT_IPACKETS, IPMP_KSTAT_IPACKETS64,
1199 IPMP_KSTAT_IERRORS, IPMP_KSTAT_MULTIRCV, IPMP_KSTAT_MULTIXMT,
1200 IPMP_KSTAT_BRDCSTRCV, IPMP_KSTAT_BRDCSTXMT, IPMP_KSTAT_LINK_UP,
1201 IPMP_KSTAT_MAX /* keep last */
1205 * phyint represents state that is common to both IPv4 and IPv6 interfaces.
1206 * There is a separate ill_t representing IPv4 and IPv6 which has a
1207 * backpointer to the phyint structure for accessing common state.
1209 typedef struct phyint {
1210 struct ill_s *phyint_illv4;
1211 struct ill_s *phyint_illv6;
1212 uint_t phyint_ifindex; /* SIOCSLIFINDEX */
1213 uint64_t phyint_flags;
1214 avl_node_t phyint_avl_by_index; /* avl tree by index */
1215 avl_node_t phyint_avl_by_name; /* avl tree by name */
1216 kmutex_t phyint_lock;
1217 struct ipsq_s *phyint_ipsq; /* back pointer to ipsq */
1218 struct ipmp_grp_s *phyint_grp; /* associated IPMP group */
1219 char phyint_name[LIFNAMSIZ]; /* physical interface name */
1220 uint64_t phyint_kstats0[IPMP_KSTAT_MAX]; /* baseline kstats */
1221 } phyint_t;
1223 #define CACHE_ALIGN_SIZE 64
1224 #define CACHE_ALIGN(align_struct) P2ROUNDUP(sizeof (struct align_struct),\
1225 CACHE_ALIGN_SIZE)
1226 struct _phyint_list_s_ {
1227 avl_tree_t phyint_list_avl_by_index; /* avl tree by index */
1228 avl_tree_t phyint_list_avl_by_name; /* avl tree by name */
1231 typedef union phyint_list_u {
1232 struct _phyint_list_s_ phyint_list_s;
1233 char phyint_list_filler[CACHE_ALIGN(_phyint_list_s_)];
1234 } phyint_list_t;
1236 #define phyint_list_avl_by_index phyint_list_s.phyint_list_avl_by_index
1237 #define phyint_list_avl_by_name phyint_list_s.phyint_list_avl_by_name
1240 * Fragmentation hash bucket
1242 typedef struct ipfb_s {
1243 struct ipf_s *ipfb_ipf; /* List of ... */
1244 size_t ipfb_count; /* Count of bytes used by frag(s) */
1245 kmutex_t ipfb_lock; /* Protect all ipf in list */
1246 uint_t ipfb_frag_pkts; /* num of distinct fragmented pkts */
1247 } ipfb_t;
1250 * IRE bucket structure. Usually there is an array of such structures,
1251 * each pointing to a linked list of ires. irb_refcnt counts the number
1252 * of walkers of a given hash bucket. Usually the reference count is
1253 * bumped up if the walker wants no IRES to be DELETED while walking the
1254 * list. Bumping up does not PREVENT ADDITION. This allows walking a given
1255 * hash bucket without stumbling up on a free pointer.
1257 * irb_t structures in ip_ftable are dynamically allocated and freed.
1258 * In order to identify the irb_t structures that can be safely kmem_free'd
1259 * we need to ensure that
1260 * - the irb_refcnt is quiescent, indicating no other walkers,
1261 * - no other threads or ire's are holding references to the irb,
1262 * i.e., irb_nire == 0,
1263 * - there are no active ire's in the bucket, i.e., irb_ire_cnt == 0
1265 typedef struct irb {
1266 struct ire_s *irb_ire; /* First ire in this bucket */
1267 /* Should be first in this struct */
1268 krwlock_t irb_lock; /* Protect this bucket */
1269 uint_t irb_refcnt; /* Protected by irb_lock */
1270 uchar_t irb_marks; /* CONDEMNED ires in this bucket ? */
1271 #define IRB_MARK_CONDEMNED 0x0001 /* Contains some IRE_IS_CONDEMNED */
1272 #define IRB_MARK_DYNAMIC 0x0002 /* Dynamically allocated */
1273 /* Once IPv6 uses radix then IRB_MARK_DYNAMIC will be always be set */
1274 uint_t irb_ire_cnt; /* Num of active IRE in this bucket */
1275 int irb_nire; /* Num of ftable ire's that ref irb */
1276 ip_stack_t *irb_ipst; /* Does not have a netstack_hold */
1277 } irb_t;
1280 * This is the structure used to store the multicast physical addresses
1281 * that an interface has joined.
1282 * The refcnt keeps track of the number of multicast IP addresses mapping
1283 * to a physical multicast address.
1285 typedef struct multiphysaddr_s {
1286 struct multiphysaddr_s *mpa_next;
1287 char mpa_addr[IP_MAX_HW_LEN];
1288 int mpa_refcnt;
1289 } multiphysaddr_t;
1291 #define IRB2RT(irb) (rt_t *)((caddr_t)(irb) - offsetof(rt_t, rt_irb))
1293 /* Forward declarations */
1294 struct dce_s;
1295 typedef struct dce_s dce_t;
1296 struct ire_s;
1297 typedef struct ire_s ire_t;
1298 struct ncec_s;
1299 typedef struct ncec_s ncec_t;
1300 struct nce_s;
1301 typedef struct nce_s nce_t;
1302 struct ip_recv_attr_s;
1303 typedef struct ip_recv_attr_s ip_recv_attr_t;
1304 struct ip_xmit_attr_s;
1305 typedef struct ip_xmit_attr_s ip_xmit_attr_t;
1308 * This is a structure for a one-element route cache that is passed
1309 * by reference between ip_input and ill_inputfn.
1311 typedef struct {
1312 ire_t *rtc_ire;
1313 ipaddr_t rtc_ipaddr;
1314 in6_addr_t rtc_ip6addr;
1315 } rtc_t;
1318 * Note: Temporarily use 64 bits, and will probably go back to 32 bits after
1319 * more cleanup work is done.
1321 typedef uint64_t iaflags_t;
1323 /* The ill input function pointer type */
1324 typedef void (*pfillinput_t)(mblk_t *, void *, void *, ip_recv_attr_t *,
1325 rtc_t *);
1327 /* The ire receive function pointer type */
1328 typedef void (*pfirerecv_t)(ire_t *, mblk_t *, void *, ip_recv_attr_t *);
1330 /* The ire send and postfrag function pointer types */
1331 typedef int (*pfiresend_t)(ire_t *, mblk_t *, void *,
1332 ip_xmit_attr_t *, uint32_t *);
1333 typedef int (*pfirepostfrag_t)(mblk_t *, nce_t *, iaflags_t, uint_t, uint32_t,
1334 zoneid_t, zoneid_t, uintptr_t *);
1337 #define IP_V4_G_HEAD 0
1338 #define IP_V6_G_HEAD 1
1340 #define MAX_G_HEADS 2
1343 * unpadded ill_if structure
1345 struct _ill_if_s_ {
1346 union ill_if_u *illif_next;
1347 union ill_if_u *illif_prev;
1348 avl_tree_t illif_avl_by_ppa; /* AVL tree sorted on ppa */
1349 vmem_t *illif_ppa_arena; /* ppa index space */
1350 uint16_t illif_mcast_v1; /* hints for */
1351 uint16_t illif_mcast_v2; /* [igmp|mld]_slowtimo */
1352 int illif_name_len; /* name length */
1353 char illif_name[LIFNAMSIZ]; /* name of interface type */
1356 /* cache aligned ill_if structure */
1357 typedef union ill_if_u {
1358 struct _ill_if_s_ ill_if_s;
1359 char illif_filler[CACHE_ALIGN(_ill_if_s_)];
1360 } ill_if_t;
1362 #define illif_next ill_if_s.illif_next
1363 #define illif_prev ill_if_s.illif_prev
1364 #define illif_avl_by_ppa ill_if_s.illif_avl_by_ppa
1365 #define illif_ppa_arena ill_if_s.illif_ppa_arena
1366 #define illif_mcast_v1 ill_if_s.illif_mcast_v1
1367 #define illif_mcast_v2 ill_if_s.illif_mcast_v2
1368 #define illif_name ill_if_s.illif_name
1369 #define illif_name_len ill_if_s.illif_name_len
1371 typedef struct ill_walk_context_s {
1372 int ctx_current_list; /* current list being searched */
1373 int ctx_last_list; /* last list to search */
1374 } ill_walk_context_t;
1377 * ill_g_heads structure, one for IPV4 and one for IPV6
1379 struct _ill_g_head_s_ {
1380 ill_if_t *ill_g_list_head;
1381 ill_if_t *ill_g_list_tail;
1384 typedef union ill_g_head_u {
1385 struct _ill_g_head_s_ ill_g_head_s;
1386 char ill_g_head_filler[CACHE_ALIGN(_ill_g_head_s_)];
1387 } ill_g_head_t;
1389 #define ill_g_list_head ill_g_head_s.ill_g_list_head
1390 #define ill_g_list_tail ill_g_head_s.ill_g_list_tail
1392 #define IP_V4_ILL_G_LIST(ipst) \
1393 (ipst)->ips_ill_g_heads[IP_V4_G_HEAD].ill_g_list_head
1394 #define IP_V6_ILL_G_LIST(ipst) \
1395 (ipst)->ips_ill_g_heads[IP_V6_G_HEAD].ill_g_list_head
1396 #define IP_VX_ILL_G_LIST(i, ipst) \
1397 (ipst)->ips_ill_g_heads[i].ill_g_list_head
1399 #define ILL_START_WALK_V4(ctx_ptr, ipst) \
1400 ill_first(IP_V4_G_HEAD, IP_V4_G_HEAD, ctx_ptr, ipst)
1401 #define ILL_START_WALK_V6(ctx_ptr, ipst) \
1402 ill_first(IP_V6_G_HEAD, IP_V6_G_HEAD, ctx_ptr, ipst)
1403 #define ILL_START_WALK_ALL(ctx_ptr, ipst) \
1404 ill_first(MAX_G_HEADS, MAX_G_HEADS, ctx_ptr, ipst)
1407 * Capabilities, possible flags for ill_capabilities.
1409 #define ILL_CAPAB_LSO 0x04 /* Large Send Offload */
1410 #define ILL_CAPAB_HCKSUM 0x08 /* Hardware checksumming */
1411 #define ILL_CAPAB_ZEROCOPY 0x10 /* Zero-copy */
1412 #define ILL_CAPAB_DLD 0x20 /* DLD capabilities */
1413 #define ILL_CAPAB_DLD_POLL 0x40 /* Polling */
1414 #define ILL_CAPAB_DLD_DIRECT 0x80 /* Direct function call */
1417 * Per-ill Hardware Checksumming capbilities.
1419 typedef struct ill_hcksum_capab_s ill_hcksum_capab_t;
1422 * Per-ill Zero-copy capabilities.
1424 typedef struct ill_zerocopy_capab_s ill_zerocopy_capab_t;
1427 * DLD capbilities.
1429 typedef struct ill_dld_capab_s ill_dld_capab_t;
1432 * Per-ill polling resource map.
1434 typedef struct ill_rx_ring ill_rx_ring_t;
1437 * Per-ill Large Send Offload capabilities.
1439 typedef struct ill_lso_capab_s ill_lso_capab_t;
1441 /* The following are ill_state_flags */
1442 #define ILL_LL_SUBNET_PENDING 0x01 /* Waiting for DL_INFO_ACK from drv */
1443 #define ILL_CONDEMNED 0x02 /* No more new ref's to the ILL */
1444 #define ILL_DL_UNBIND_IN_PROGRESS 0x04 /* UNBIND_REQ is sent */
1446 * ILL_DOWN_IN_PROGRESS is set to ensure the following:
1447 * - no packets are sent to the driver after the DL_UNBIND_REQ is sent,
1448 * - no longstanding references will be acquired on objects that are being
1449 * brought down.
1451 #define ILL_DOWN_IN_PROGRESS 0x08
1453 /* Is this an ILL whose source address is used by other ILL's ? */
1454 #define IS_USESRC_ILL(ill) \
1455 (((ill)->ill_usesrc_ifindex == 0) && \
1456 ((ill)->ill_usesrc_grp_next != NULL))
1458 /* Is this a client/consumer of the usesrc ILL ? */
1459 #define IS_USESRC_CLI_ILL(ill) \
1460 (((ill)->ill_usesrc_ifindex != 0) && \
1461 ((ill)->ill_usesrc_grp_next != NULL))
1463 /* Is this an virtual network interface (vni) ILL ? */
1464 #define IS_VNI(ill) \
1465 (((ill)->ill_phyint->phyint_flags & (PHYI_LOOPBACK|PHYI_VIRTUAL)) == \
1466 PHYI_VIRTUAL)
1468 /* Is this a loopback ILL? */
1469 #define IS_LOOPBACK(ill) \
1470 ((ill)->ill_phyint->phyint_flags & PHYI_LOOPBACK)
1472 /* Is this an IPMP meta-interface ILL? */
1473 #define IS_IPMP(ill) \
1474 ((ill)->ill_phyint->phyint_flags & PHYI_IPMP)
1476 /* Is this ILL under an IPMP meta-interface? (aka "in a group?") */
1477 #define IS_UNDER_IPMP(ill) \
1478 ((ill)->ill_grp != NULL && !IS_IPMP(ill))
1480 /* Is ill1 in the same illgrp as ill2? */
1481 #define IS_IN_SAME_ILLGRP(ill1, ill2) \
1482 ((ill1)->ill_grp != NULL && ((ill1)->ill_grp == (ill2)->ill_grp))
1484 /* Is ill1 on the same LAN as ill2? */
1485 #define IS_ON_SAME_LAN(ill1, ill2) \
1486 ((ill1) == (ill2) || IS_IN_SAME_ILLGRP(ill1, ill2))
1488 #define ILL_OTHER(ill) \
1489 ((ill)->ill_isv6 ? (ill)->ill_phyint->phyint_illv4 : \
1490 (ill)->ill_phyint->phyint_illv6)
1493 * IPMP group ILL state structure -- up to two per IPMP group (V4 and V6).
1494 * Created when the V4 and/or V6 IPMP meta-interface is I_PLINK'd. It is
1495 * guaranteed to persist while there are interfaces of that type in the group.
1496 * In general, most fields are accessed outside of the IPSQ (e.g., in the
1497 * datapath), and thus use locks in addition to the IPSQ for protection.
1499 * synchronization: read write
1501 * ig_if ipsq or ill_g_lock ipsq and ill_g_lock
1502 * ig_actif ipsq or ipmp_lock ipsq and ipmp_lock
1503 * ig_nactif ipsq or ipmp_lock ipsq and ipmp_lock
1504 * ig_next_ill ipsq or ipmp_lock ipsq and ipmp_lock
1505 * ig_ipmp_ill write once write once
1506 * ig_cast_ill ipsq or ipmp_lock ipsq and ipmp_lock
1507 * ig_arpent ipsq ipsq
1508 * ig_mtu ipsq ipsq
1509 * ig_mc_mtu ipsq ipsq
1511 typedef struct ipmp_illgrp_s {
1512 list_t ig_if; /* list of all interfaces */
1513 list_t ig_actif; /* list of active interfaces */
1514 uint_t ig_nactif; /* number of active interfaces */
1515 struct ill_s *ig_next_ill; /* next active interface to use */
1516 struct ill_s *ig_ipmp_ill; /* backpointer to IPMP meta-interface */
1517 struct ill_s *ig_cast_ill; /* nominated ill for multi/broadcast */
1518 list_t ig_arpent; /* list of ARP entries */
1519 uint_t ig_mtu; /* ig_ipmp_ill->ill_mtu */
1520 uint_t ig_mc_mtu; /* ig_ipmp_ill->ill_mc_mtu */
1521 } ipmp_illgrp_t;
1524 * IPMP group state structure -- one per IPMP group. Created when the
1525 * IPMP meta-interface is plumbed; it is guaranteed to persist while there
1526 * are interfaces in it.
1528 * ipmp_grp_t synchronization: read write
1530 * gr_name ipmp_lock ipmp_lock
1531 * gr_ifname write once write once
1532 * gr_mactype ipmp_lock ipmp_lock
1533 * gr_phyint write once write once
1534 * gr_nif ipmp_lock ipmp_lock
1535 * gr_nactif ipsq ipsq
1536 * gr_v4 ipmp_lock ipmp_lock
1537 * gr_v6 ipmp_lock ipmp_lock
1538 * gr_nv4 ipmp_lock ipmp_lock
1539 * gr_nv6 ipmp_lock ipmp_lock
1540 * gr_pendv4 ipmp_lock ipmp_lock
1541 * gr_pendv6 ipmp_lock ipmp_lock
1542 * gr_linkdownmp ipsq ipsq
1543 * gr_ksp ipmp_lock ipmp_lock
1544 * gr_kstats0 atomic atomic
1546 typedef struct ipmp_grp_s {
1547 char gr_name[LIFGRNAMSIZ]; /* group name */
1548 char gr_ifname[LIFNAMSIZ]; /* interface name */
1549 t_uscalar_t gr_mactype; /* DLPI mactype of group */
1550 phyint_t *gr_phyint; /* IPMP group phyint */
1551 uint_t gr_nif; /* number of interfaces in group */
1552 uint_t gr_nactif; /* number of active interfaces */
1553 ipmp_illgrp_t *gr_v4; /* V4 group information */
1554 ipmp_illgrp_t *gr_v6; /* V6 group information */
1555 uint_t gr_nv4; /* number of ills in V4 group */
1556 uint_t gr_nv6; /* number of ills in V6 group */
1557 uint_t gr_pendv4; /* number of pending ills in V4 group */
1558 uint_t gr_pendv6; /* number of pending ills in V6 group */
1559 mblk_t *gr_linkdownmp; /* message used to bring link down */
1560 kstat_t *gr_ksp; /* group kstat pointer */
1561 uint64_t gr_kstats0[IPMP_KSTAT_MAX]; /* baseline group kstats */
1562 } ipmp_grp_t;
1565 * IPMP ARP entry -- one per SIOCS*ARP entry tied to the group. Used to keep
1566 * ARP up-to-date as the active set of interfaces in the group changes.
1568 typedef struct ipmp_arpent_s {
1569 ipaddr_t ia_ipaddr; /* IP address for this entry */
1570 boolean_t ia_proxyarp; /* proxy ARP entry? */
1571 boolean_t ia_notified; /* ARP notified about this entry? */
1572 list_node_t ia_node; /* next ARP entry in list */
1573 uint16_t ia_flags; /* nce_flags for the address */
1574 size_t ia_lladdr_len;
1575 uchar_t *ia_lladdr;
1576 } ipmp_arpent_t;
1578 struct arl_s;
1581 * Per-ill capabilities.
1583 struct ill_hcksum_capab_s {
1584 uint_t ill_hcksum_version; /* interface version */
1585 uint_t ill_hcksum_txflags; /* capabilities on transmit */
1588 struct ill_zerocopy_capab_s {
1589 uint_t ill_zerocopy_version; /* interface version */
1590 uint_t ill_zerocopy_flags; /* capabilities */
1593 struct ill_lso_capab_s {
1594 uint_t ill_lso_flags; /* capabilities */
1595 uint_t ill_lso_max; /* maximum size of payload */
1599 * IP Lower level Structure.
1600 * Instance data structure in ip_open when there is a device below us.
1602 typedef struct ill_s {
1603 pfillinput_t ill_inputfn; /* Fast input function selector */
1604 ill_if_t *ill_ifptr; /* pointer to interface type */
1605 queue_t *ill_rq; /* Read queue. */
1606 queue_t *ill_wq; /* Write queue. */
1608 int ill_error; /* Error value sent up by device. */
1610 ipif_t *ill_ipif; /* Interface chain for this ILL. */
1612 uint_t ill_ipif_up_count; /* Number of IPIFs currently up. */
1613 uint_t ill_max_frag; /* Max IDU from DLPI. */
1614 uint_t ill_current_frag; /* Current IDU from DLPI. */
1615 uint_t ill_mtu; /* User-specified MTU; SIOCSLIFMTU */
1616 uint_t ill_mc_mtu; /* MTU for multi/broadcast */
1617 uint_t ill_metric; /* BSD if metric, for compatibility. */
1618 char *ill_name; /* Our name. */
1619 uint_t ill_ipif_dup_count; /* Number of duplicate addresses. */
1620 uint_t ill_name_length; /* Name length, incl. terminator. */
1621 uint_t ill_net_type; /* IRE_IF_RESOLVER/IRE_IF_NORESOLVER. */
1623 * Physical Point of Attachment num. If DLPI style 1 provider
1624 * then this is derived from the devname.
1626 uint_t ill_ppa;
1627 t_uscalar_t ill_sap;
1628 t_scalar_t ill_sap_length; /* Including sign (for position) */
1629 uint_t ill_phys_addr_length; /* Excluding the sap. */
1630 uint_t ill_bcast_addr_length; /* Only set when the DL provider */
1631 /* supports broadcast. */
1632 t_uscalar_t ill_mactype;
1633 uint8_t *ill_frag_ptr; /* Reassembly state. */
1634 timeout_id_t ill_frag_timer_id; /* timeout id for the frag timer */
1635 ipfb_t *ill_frag_hash_tbl; /* Fragment hash list head. */
1637 krwlock_t ill_mcast_lock; /* Protects multicast state */
1638 kmutex_t ill_mcast_serializer; /* Serialize across ilg and ilm state */
1639 ilm_t *ill_ilm; /* Multicast membership for ill */
1640 uint_t ill_global_timer; /* for IGMPv3/MLDv2 general queries */
1641 int ill_mcast_type; /* type of router which is querier */
1642 /* on this interface */
1643 uint16_t ill_mcast_v1_time; /* # slow timeouts since last v1 qry */
1644 uint16_t ill_mcast_v2_time; /* # slow timeouts since last v2 qry */
1645 uint8_t ill_mcast_v1_tset; /* 1 => timer is set; 0 => not set */
1646 uint8_t ill_mcast_v2_tset; /* 1 => timer is set; 0 => not set */
1648 uint8_t ill_mcast_rv; /* IGMPv3/MLDv2 robustness variable */
1649 int ill_mcast_qi; /* IGMPv3/MLDv2 query interval var */
1652 * All non-NULL cells between 'ill_first_mp_to_free' and
1653 * 'ill_last_mp_to_free' are freed in ill_delete.
1655 #define ill_first_mp_to_free ill_bcast_mp
1656 mblk_t *ill_bcast_mp; /* DLPI header for broadcasts. */
1657 mblk_t *ill_unbind_mp; /* unbind mp from ill_dl_up() */
1658 mblk_t *ill_promiscoff_mp; /* for ill_leave_allmulti() */
1659 mblk_t *ill_dlpi_deferred; /* b_next chain of control messages */
1660 mblk_t *ill_dest_addr_mp; /* mblk which holds ill_dest_addr */
1661 mblk_t *ill_replumb_mp; /* replumb mp from ill_replumb() */
1662 mblk_t *ill_phys_addr_mp; /* mblk which holds ill_phys_addr */
1663 mblk_t *ill_mcast_deferred; /* b_next chain of IGMP/MLD packets */
1664 #define ill_last_mp_to_free ill_mcast_deferred
1666 cred_t *ill_credp; /* opener's credentials */
1667 uint8_t *ill_phys_addr; /* ill_phys_addr_mp->b_rptr + off */
1668 uint8_t *ill_dest_addr; /* ill_dest_addr_mp->b_rptr + off */
1670 uint_t ill_state_flags; /* see ILL_* flags above */
1672 /* Following bit fields protected by ipsq_t */
1673 uint_t
1674 ill_needs_attach : 1,
1675 ill_reserved : 1,
1676 ill_isv6 : 1,
1677 ill_dlpi_style_set : 1,
1679 ill_ifname_pending : 1,
1680 ill_logical_down : 1,
1681 ill_dl_up : 1,
1682 ill_up_ipifs : 1,
1684 ill_note_link : 1, /* supports link-up notification */
1685 ill_capab_reneg : 1, /* capability renegotiation to be done */
1686 ill_dld_capab_inprog : 1, /* direct dld capab call in prog */
1687 ill_need_recover_multicast : 1,
1689 ill_replumbing : 1,
1690 ill_arl_dlpi_pending : 1,
1691 ill_grp_pending : 1,
1693 ill_pad_to_bit_31 : 17;
1695 /* Following bit fields protected by ill_lock */
1696 uint_t
1697 ill_fragtimer_executing : 1,
1698 ill_fragtimer_needrestart : 1,
1699 ill_manual_token : 1, /* system won't override ill_token */
1701 * ill_manual_linklocal : system will not change the
1702 * linklocal whenever ill_token changes.
1704 ill_manual_linklocal : 1,
1706 ill_manual_dst_linklocal : 1, /* same for pt-pt dst linklocal */
1708 ill_pad_bit_31 : 27;
1711 * Used in SIOCSIFMUXID and SIOCGIFMUXID for 'ifconfig unplumb'.
1713 int ill_muxid; /* muxid returned from plink */
1715 /* Used for IP frag reassembly throttling on a per ILL basis. */
1716 uint_t ill_ipf_gen; /* Generation of next fragment queue */
1717 uint_t ill_frag_count; /* Count of all reassembly mblk bytes */
1718 uint_t ill_frag_free_num_pkts; /* num of fragmented packets to free */
1719 clock_t ill_last_frag_clean_time; /* time when frag's were pruned */
1720 int ill_type; /* From <net/if_types.h> */
1721 uint_t ill_dlpi_multicast_state; /* See below IDS_* */
1722 uint_t ill_dlpi_fastpath_state; /* See below IDS_* */
1725 * Capabilities related fields.
1727 uint_t ill_dlpi_capab_state; /* State of capability query, IDCS_* */
1728 uint_t ill_capab_pending_cnt;
1729 uint64_t ill_capabilities; /* Enabled capabilities, ILL_CAPAB_* */
1730 ill_hcksum_capab_t *ill_hcksum_capab; /* H/W cksumming capabilities */
1731 ill_zerocopy_capab_t *ill_zerocopy_capab; /* Zero-copy capabilities */
1732 ill_dld_capab_t *ill_dld_capab; /* DLD capabilities */
1733 ill_lso_capab_t *ill_lso_capab; /* Large Segment Offload capabilities */
1734 mblk_t *ill_capab_reset_mp; /* Preallocated mblk for capab reset */
1736 uint8_t ill_max_hops; /* Maximum hops for any logical interface */
1737 uint_t ill_user_mtu; /* User-specified MTU via SIOCSLIFLNKINFO */
1738 uint32_t ill_reachable_time; /* Value for ND algorithm in msec */
1739 uint32_t ill_reachable_retrans_time; /* Value for ND algorithm msec */
1740 uint_t ill_max_buf; /* Max # of req to buffer for ND */
1741 in6_addr_t ill_token; /* IPv6 interface id */
1742 in6_addr_t ill_dest_token; /* Destination IPv6 interface id */
1743 uint_t ill_token_length;
1744 uint32_t ill_xmit_count; /* ndp max multicast xmits */
1745 mib2_ipIfStatsEntry_t *ill_ip_mib; /* ver indep. interface mib */
1746 mib2_ipv6IfIcmpEntry_t *ill_icmp6_mib; /* Per interface mib */
1748 phyint_t *ill_phyint;
1749 uint64_t ill_flags;
1751 kmutex_t ill_lock; /* Please see table below */
1753 * The ill_nd_lla* fields handle the link layer address option
1754 * from neighbor discovery. This is used for external IPv6
1755 * address resolution.
1757 mblk_t *ill_nd_lla_mp; /* mblk which holds ill_nd_lla */
1758 uint8_t *ill_nd_lla; /* Link Layer Address */
1759 uint_t ill_nd_lla_len; /* Link Layer Address length */
1761 * We have 4 phys_addr_req's sent down. This field keeps track
1762 * of which one is pending.
1764 t_uscalar_t ill_phys_addr_pend; /* which dl_phys_addr_req pending */
1766 * Used to save errors that occur during plumbing
1768 uint_t ill_ifname_pending_err;
1769 avl_node_t ill_avl_byppa; /* avl node based on ppa */
1770 list_t ill_nce; /* pointer to nce_s list */
1771 uint_t ill_refcnt; /* active refcnt by threads */
1772 uint_t ill_ire_cnt; /* ires associated with this ill */
1773 kcondvar_t ill_cv;
1774 uint_t ill_ncec_cnt; /* ncecs associated with this ill */
1775 uint_t ill_nce_cnt; /* nces associated with this ill */
1776 uint_t ill_waiters; /* threads waiting in ipsq_enter */
1778 * Contains the upper read queue pointer of the module immediately
1779 * beneath IP. This field allows IP to validate sub-capability
1780 * acknowledgments coming up from downstream.
1782 queue_t *ill_lmod_rq; /* read queue pointer of module below */
1783 uint_t ill_lmod_cnt; /* number of modules beneath IP */
1784 ip_m_t *ill_media; /* media specific params/functions */
1785 t_uscalar_t ill_dlpi_pending; /* Last DLPI primitive issued */
1786 uint_t ill_usesrc_ifindex; /* use src addr from this ILL */
1787 struct ill_s *ill_usesrc_grp_next; /* Next ILL in the usesrc group */
1788 boolean_t ill_trace_disable; /* True when alloc fails */
1789 zoneid_t ill_zoneid;
1790 ip_stack_t *ill_ipst; /* Corresponds to a netstack_hold */
1791 uint32_t ill_dhcpinit; /* IP_DHCPINIT_IFs for ill */
1792 void *ill_flownotify_mh; /* Tx flow ctl, mac cb handle */
1793 uint_t ill_ilm_cnt; /* ilms referencing this ill */
1794 uint_t ill_ipallmulti_cnt; /* ip_join_allmulti() calls */
1795 ilm_t *ill_ipallmulti_ilm;
1797 mblk_t *ill_saved_ire_mp; /* Allocated for each extra IRE */
1798 /* with ire_ill set so they can */
1799 /* survive the ill going down and up. */
1800 kmutex_t ill_saved_ire_lock; /* Protects ill_saved_ire_mp, cnt */
1801 uint_t ill_saved_ire_cnt; /* # entries */
1802 struct arl_ill_common_s *ill_common;
1803 ire_t *ill_ire_multicast; /* IRE_MULTICAST for ill */
1804 clock_t ill_defend_start; /* start of 1 hour period */
1805 uint_t ill_defend_count; /* # of announce/defends per ill */
1807 * IPMP fields.
1809 ipmp_illgrp_t *ill_grp; /* IPMP group information */
1810 list_node_t ill_actnode; /* next active ill in group */
1811 list_node_t ill_grpnode; /* next ill in group */
1812 ipif_t *ill_src_ipif; /* source address selection rotor */
1813 ipif_t *ill_move_ipif; /* ipif awaiting move to new ill */
1814 boolean_t ill_nom_cast; /* nominated for mcast/bcast */
1815 uint_t ill_bound_cnt; /* # of data addresses bound to ill */
1816 ipif_t *ill_bound_ipif; /* ipif chain bound to ill */
1817 timeout_id_t ill_refresh_tid; /* ill refresh retry timeout id */
1819 uint32_t ill_mrouter_cnt; /* mrouter allmulti joins */
1820 uint32_t ill_allowed_ips_cnt;
1821 in6_addr_t *ill_allowed_ips;
1823 /* list of multicast physical addresses joined on this ill */
1824 multiphysaddr_t *ill_mphysaddr_list;
1825 } ill_t;
1828 * ILL_FREE_OK() means that there are no incoming pointer references
1829 * to the ill.
1831 #define ILL_FREE_OK(ill) \
1832 ((ill)->ill_ire_cnt == 0 && (ill)->ill_ilm_cnt == 0 && \
1833 (ill)->ill_ncec_cnt == 0 && (ill)->ill_nce_cnt == 0)
1836 * An ipif/ill can be marked down only when the ire and ncec references
1837 * to that ipif/ill goes to zero. ILL_DOWN_OK() is a necessary condition
1838 * quiescence checks. See comments above IPIF_DOWN_OK for details
1839 * on why ires and nces are selectively considered for this macro.
1841 #define ILL_DOWN_OK(ill) \
1842 (ill->ill_ire_cnt == 0 && ill->ill_ncec_cnt == 0 && \
1843 ill->ill_nce_cnt == 0)
1846 * The following table lists the protection levels of the various members
1847 * of the ill_t. Same notation as that used for ipif_t above is used.
1849 * Write Read
1851 * ill_ifptr ill_g_lock + s Write once
1852 * ill_rq ipsq Write once
1853 * ill_wq ipsq Write once
1855 * ill_error ipsq None
1856 * ill_ipif ill_g_lock + ipsq ill_g_lock OR ipsq
1857 * ill_ipif_up_count ill_lock + ipsq ill_lock OR ipsq
1858 * ill_max_frag ill_lock ill_lock
1859 * ill_current_frag ill_lock ill_lock
1861 * ill_name ill_g_lock + ipsq Write once
1862 * ill_name_length ill_g_lock + ipsq Write once
1863 * ill_ndd_name ipsq Write once
1864 * ill_net_type ipsq Write once
1865 * ill_ppa ill_g_lock + ipsq Write once
1866 * ill_sap ipsq + down ill Write once
1867 * ill_sap_length ipsq + down ill Write once
1868 * ill_phys_addr_length ipsq + down ill Write once
1870 * ill_bcast_addr_length ipsq ipsq
1871 * ill_mactype ipsq ipsq
1872 * ill_frag_ptr ipsq ipsq
1874 * ill_frag_timer_id ill_lock ill_lock
1875 * ill_frag_hash_tbl ipsq up ill
1876 * ill_ilm ill_mcast_lock(WRITER) ill_mcast_lock(READER)
1877 * ill_global_timer ill_mcast_lock(WRITER) ill_mcast_lock(READER)
1878 * ill_mcast_type ill_mcast_lock(WRITER) ill_mcast_lock(READER)
1879 * ill_mcast_v1_time ill_mcast_lock(WRITER) ill_mcast_lock(READER)
1880 * ill_mcast_v2_time ill_mcast_lock(WRITER) ill_mcast_lock(READER)
1881 * ill_mcast_v1_tset ill_mcast_lock(WRITER) ill_mcast_lock(READER)
1882 * ill_mcast_v2_tset ill_mcast_lock(WRITER) ill_mcast_lock(READER)
1883 * ill_mcast_rv ill_mcast_lock(WRITER) ill_mcast_lock(READER)
1884 * ill_mcast_qi ill_mcast_lock(WRITER) ill_mcast_lock(READER)
1886 * ill_down_mp ipsq ipsq
1887 * ill_dlpi_deferred ill_lock ill_lock
1888 * ill_dlpi_pending ipsq + ill_lock ipsq or ill_lock or
1889 * absence of ipsq writer.
1890 * ill_phys_addr_mp ipsq + down ill only when ill is up
1891 * ill_mcast_deferred ill_lock ill_lock
1892 * ill_phys_addr ipsq + down ill only when ill is up
1893 * ill_dest_addr_mp ipsq + down ill only when ill is up
1894 * ill_dest_addr ipsq + down ill only when ill is up
1896 * ill_state_flags ill_lock ill_lock
1897 * exclusive bit flags ipsq_t ipsq_t
1898 * shared bit flags ill_lock ill_lock
1900 * ill_muxid ipsq Not atomic
1902 * ill_ipf_gen Not atomic
1903 * ill_frag_count atomics atomics
1904 * ill_type ipsq + down ill only when ill is up
1905 * ill_dlpi_multicast_state ill_lock ill_lock
1906 * ill_dlpi_fastpath_state ill_lock ill_lock
1907 * ill_dlpi_capab_state ipsq ipsq
1908 * ill_max_hops ipsq Not atomic
1910 * ill_mtu ill_lock None
1911 * ill_mc_mtu ill_lock None
1913 * ill_user_mtu ipsq + ill_lock ill_lock
1914 * ill_reachable_time ipsq + ill_lock ill_lock
1915 * ill_reachable_retrans_time ipsq + ill_lock ill_lock
1916 * ill_max_buf ipsq + ill_lock ill_lock
1918 * Next 2 fields need ill_lock because of the get ioctls. They should not
1919 * report partially updated results without executing in the ipsq.
1920 * ill_token ipsq + ill_lock ill_lock
1921 * ill_token_length ipsq + ill_lock ill_lock
1922 * ill_dest_token ipsq + down ill only when ill is up
1923 * ill_xmit_count ipsq + down ill write once
1924 * ill_ip6_mib ipsq + down ill only when ill is up
1925 * ill_icmp6_mib ipsq + down ill only when ill is up
1927 * ill_phyint ipsq, ill_g_lock, ill_lock Any of them
1928 * ill_flags ill_lock ill_lock
1929 * ill_nd_lla_mp ipsq + down ill only when ill is up
1930 * ill_nd_lla ipsq + down ill only when ill is up
1931 * ill_nd_lla_len ipsq + down ill only when ill is up
1932 * ill_phys_addr_pend ipsq + down ill only when ill is up
1933 * ill_ifname_pending_err ipsq ipsq
1934 * ill_avl_byppa ipsq, ill_g_lock write once
1936 * ill_fastpath_list ill_lock ill_lock
1937 * ill_refcnt ill_lock ill_lock
1938 * ill_ire_cnt ill_lock ill_lock
1939 * ill_cv ill_lock ill_lock
1940 * ill_ncec_cnt ill_lock ill_lock
1941 * ill_nce_cnt ill_lock ill_lock
1942 * ill_ilm_cnt ill_lock ill_lock
1943 * ill_src_ipif ill_g_lock ill_g_lock
1944 * ill_trace ill_lock ill_lock
1945 * ill_usesrc_grp_next ill_g_usesrc_lock ill_g_usesrc_lock
1946 * ill_dhcpinit atomics atomics
1947 * ill_flownotify_mh write once write once
1948 * ill_capab_pending_cnt ipsq ipsq
1949 * ill_ipallmulti_cnt ill_lock ill_lock
1950 * ill_ipallmulti_ilm ill_lock ill_lock
1951 * ill_saved_ire_mp ill_saved_ire_lock ill_saved_ire_lock
1952 * ill_saved_ire_cnt ill_saved_ire_lock ill_saved_ire_lock
1953 * ill_arl ??? ???
1954 * ill_ire_multicast ipsq + quiescent none
1955 * ill_bound_ipif ipsq ipsq
1956 * ill_actnode ipsq + ipmp_lock ipsq OR ipmp_lock
1957 * ill_grpnode ipsq + ill_g_lock ipsq OR ill_g_lock
1958 * ill_src_ipif ill_g_lock ill_g_lock
1959 * ill_move_ipif ipsq ipsq
1960 * ill_nom_cast ipsq ipsq OR advisory
1961 * ill_refresh_tid ill_lock ill_lock
1962 * ill_grp (for IPMP ill) write once write once
1963 * ill_grp (for underlying ill) ipsq + ill_g_lock ipsq OR ill_g_lock
1964 * ill_grp_pending ill_mcast_serializer ill_mcast_serializer
1965 * ill_mrouter_cnt atomics atomics
1966 * ill_mphysaddr_list ill_lock ill_lock
1968 * NOTE: It's OK to make heuristic decisions on an underlying interface
1969 * by using IS_UNDER_IPMP() or comparing ill_grp's raw pointer value.
1973 * For ioctl restart mechanism see ip_reprocess_ioctl()
1975 struct ip_ioctl_cmd_s;
1977 typedef int (*ifunc_t)(ipif_t *, struct sockaddr_in *, queue_t *, mblk_t *,
1978 struct ip_ioctl_cmd_s *, void *);
1980 typedef struct ip_ioctl_cmd_s {
1981 int ipi_cmd;
1982 size_t ipi_copyin_size;
1983 uint_t ipi_flags;
1984 uint_t ipi_cmd_type;
1985 ifunc_t ipi_func;
1986 ifunc_t ipi_func_restart;
1987 } ip_ioctl_cmd_t;
1990 * ipi_cmd_type:
1992 * IF_CMD 1 old style ifreq cmd
1993 * LIF_CMD 2 new style lifreq cmd
1994 * ARP_CMD 3 arpreq cmd
1995 * XARP_CMD 4 xarpreq cmd
1996 * MSFILT_CMD 5 multicast source filter cmd
1997 * MISC_CMD 6 misc cmd (not a more specific one above)
2000 enum { IF_CMD = 1, LIF_CMD, ARP_CMD, XARP_CMD, MSFILT_CMD, MISC_CMD };
2002 #define IPI_DONTCARE 0 /* For ioctl encoded values that don't matter */
2004 /* Flag values in ipi_flags */
2005 #define IPI_PRIV 0x1 /* Root only command */
2006 #define IPI_MODOK 0x2 /* Permitted on mod instance of IP */
2007 #define IPI_WR 0x4 /* Need to grab writer access */
2008 #define IPI_GET_CMD 0x8 /* branch to mi_copyout on success */
2009 /* unused 0x10 */
2010 #define IPI_NULL_BCONT 0x20 /* ioctl has not data and hence no b_cont */
2012 extern ip_ioctl_cmd_t ip_ndx_ioctl_table[];
2013 extern ip_ioctl_cmd_t ip_misc_ioctl_table[];
2014 extern int ip_ndx_ioctl_count;
2015 extern int ip_misc_ioctl_count;
2017 /* Passed down by ARP to IP during I_PLINK/I_PUNLINK */
2018 typedef struct ipmx_s {
2019 char ipmx_name[LIFNAMSIZ]; /* if name */
2020 uint_t
2021 ipmx_arpdev_stream : 1, /* This is the arp stream */
2022 ipmx_notused : 31;
2023 } ipmx_t;
2026 * State for detecting if a driver supports certain features.
2027 * Support for DL_ENABMULTI_REQ uses ill_dlpi_multicast_state.
2028 * Support for DLPI M_DATA fastpath uses ill_dlpi_fastpath_state.
2030 #define IDS_UNKNOWN 0 /* No DLPI request sent */
2031 #define IDS_INPROGRESS 1 /* DLPI request sent */
2032 #define IDS_OK 2 /* DLPI request completed successfully */
2033 #define IDS_FAILED 3 /* DLPI request failed */
2035 /* Support for DL_CAPABILITY_REQ uses ill_dlpi_capab_state. */
2036 enum {
2037 IDCS_UNKNOWN,
2038 IDCS_PROBE_SENT,
2039 IDCS_OK,
2040 IDCS_RESET_SENT,
2041 IDCS_RENEG,
2042 IDCS_FAILED
2045 /* Extended NDP Management Structure */
2046 typedef struct ipndp_s {
2047 ndgetf_t ip_ndp_getf;
2048 ndsetf_t ip_ndp_setf;
2049 caddr_t ip_ndp_data;
2050 char *ip_ndp_name;
2051 } ipndp_t;
2053 /* IXA Notification types */
2054 typedef enum {
2055 IXAN_LSO, /* LSO capability change */
2056 IXAN_PMTU, /* PMTU change */
2057 IXAN_ZCOPY /* ZEROCOPY capability change */
2058 } ixa_notify_type_t;
2060 typedef uint_t ixa_notify_arg_t;
2062 typedef void (*ixa_notify_t)(void *, ip_xmit_attr_t *ixa, ixa_notify_type_t,
2063 ixa_notify_arg_t);
2066 * Attribute flags that are common to the transmit and receive attributes
2068 #define IAF_IS_IPV4 0x80000000 /* ipsec_*_v4 */
2069 #define IAF_TRUSTED_ICMP 0x40000000 /* ipsec_*_icmp_loopback */
2070 #define IAF_NO_LOOP_ZONEID_SET 0x20000000 /* Zone that shouldn't have */
2071 /* a copy */
2072 #define IAF_LOOPBACK_COPY 0x10000000 /* For multi and broadcast */
2074 #define IAF_MASK 0xf0000000 /* Flags that are common */
2077 * Transmit side attributes used between the transport protocols and IP as
2078 * well as inside IP. It is also used to cache information in the conn_t i.e.
2079 * replaces conn_ire and the IPsec caching in the conn_t.
2081 struct ip_xmit_attr_s {
2082 iaflags_t ixa_flags; /* IXAF_*. See below */
2084 uint32_t ixa_free_flags; /* IXA_FREE_*. See below */
2085 uint32_t ixa_refcnt; /* Using atomics */
2088 * Always initialized independently of ixa_flags settings.
2089 * Used by ip_xmit so we keep them up front for cache locality.
2091 uint32_t ixa_xmit_hint; /* For ECMP and GLD TX ring fanout */
2092 uint_t ixa_pktlen; /* Always set. For frag and stats */
2093 zoneid_t ixa_zoneid; /* Assumed always set */
2095 /* Always set for conn_ip_output(); might be stale */
2097 * Since TCP keeps the conn_t around past the process going away
2098 * we need to use the "notr" (e.g, ire_refhold_notr) for ixa_ire,
2099 * ixa_nce, and ixa_dce.
2101 ire_t *ixa_ire; /* Forwarding table entry */
2102 uint_t ixa_ire_generation;
2103 nce_t *ixa_nce; /* Neighbor cache entry */
2104 dce_t *ixa_dce; /* Destination cache entry */
2105 uint_t ixa_dce_generation;
2106 uint_t ixa_src_generation; /* If IXAF_VERIFY_SOURCE */
2108 uint32_t ixa_src_preferences; /* prefs for src addr select */
2109 uint32_t ixa_pmtu; /* IXAF_VERIFY_PMTU */
2111 /* Set by ULP if IXAF_VERIFY_PMTU; otherwise set by IP */
2112 uint32_t ixa_fragsize;
2114 int8_t ixa_use_min_mtu; /* IXAF_USE_MIN_MTU values */
2116 pfirepostfrag_t ixa_postfragfn; /* Set internally in IP */
2118 in6_addr_t ixa_nexthop_v6; /* IXAF_NEXTHOP_SET */
2119 #define ixa_nexthop_v4 V4_PART_OF_V6(ixa_nexthop_v6)
2121 zoneid_t ixa_no_loop_zoneid; /* IXAF_NO_LOOP_ZONEID_SET */
2123 uint_t ixa_scopeid; /* For IPv6 link-locals */
2125 uint_t ixa_broadcast_ttl; /* IXAF_BROACAST_TTL_SET */
2127 uint_t ixa_multicast_ttl; /* Assumed set for multicast */
2128 uint_t ixa_multicast_ifindex; /* Assumed set for multicast */
2129 ipaddr_t ixa_multicast_ifaddr; /* Assumed set for multicast */
2131 int ixa_raw_cksum_offset; /* If IXAF_SET_RAW_CKSUM */
2133 uint32_t ixa_ident; /* For IPv6 fragment header */
2135 uint64_t ixa_conn_id; /* Used by DTrace */
2137 * Cached LSO information.
2139 ill_lso_capab_t ixa_lso_capab; /* Valid when IXAF_LSO_CAPAB */
2141 uint64_t ixa_ipsec_policy_gen; /* Generation from iph_gen */
2143 * The following IPsec fields are only initialized when
2144 * IXAF_IPSEC_SECURE is set. Otherwise they contain garbage.
2146 ipsec_latch_t *ixa_ipsec_latch; /* Just the ids */
2147 struct ipsa_s *ixa_ipsec_ah_sa; /* Hard reference SA for AH */
2148 struct ipsa_s *ixa_ipsec_esp_sa; /* Hard reference SA for ESP */
2149 struct ipsec_policy_s *ixa_ipsec_policy; /* why are we here? */
2150 struct ipsec_action_s *ixa_ipsec_action; /* For reflected packets */
2151 ipsa_ref_t ixa_ipsec_ref[2]; /* Soft reference to SA */
2152 /* 0: ESP, 1: AH */
2155 * The selectors here are potentially different than the SPD rule's
2156 * selectors, and we need to have both available for IKEv2.
2158 * NOTE: "Source" and "Dest" are w.r.t. outbound datagrams. Ports can
2159 * be zero, and the protocol number is needed to make the ports
2160 * significant.
2162 uint16_t ixa_ipsec_src_port; /* Source port number of d-gram. */
2163 uint16_t ixa_ipsec_dst_port; /* Destination port number of d-gram. */
2164 uint8_t ixa_ipsec_icmp_type; /* ICMP type of d-gram */
2165 uint8_t ixa_ipsec_icmp_code; /* ICMP code of d-gram */
2167 sa_family_t ixa_ipsec_inaf; /* Inner address family */
2168 #define IXA_MAX_ADDRLEN 4 /* Max addr len. (in 32-bit words) */
2169 uint32_t ixa_ipsec_insrc[IXA_MAX_ADDRLEN]; /* Inner src address */
2170 uint32_t ixa_ipsec_indst[IXA_MAX_ADDRLEN]; /* Inner dest address */
2171 uint8_t ixa_ipsec_insrcpfx; /* Inner source prefix */
2172 uint8_t ixa_ipsec_indstpfx; /* Inner destination prefix */
2174 uint8_t ixa_ipsec_proto; /* IP protocol number for d-gram. */
2176 /* Always initialized independently of ixa_flags settings */
2177 uint_t ixa_ifindex; /* Assumed always set */
2178 uint16_t ixa_ip_hdr_length; /* Points to ULP header */
2179 uint8_t ixa_protocol; /* Protocol number for ULP cksum */
2180 ip_stack_t *ixa_ipst; /* Always set */
2181 uint32_t ixa_extra_ident; /* Set if LSO */
2182 cred_t *ixa_cred; /* For getpeerucred */
2183 pid_t ixa_cpid; /* For getpeerucred */
2185 #ifdef DEBUG
2186 kthread_t *ixa_curthread; /* For serialization assert */
2187 #endif
2188 squeue_t *ixa_sqp; /* Set from conn_sqp as a hint */
2189 uintptr_t ixa_cookie; /* cookie to use for tx flow control */
2192 * Must be set by ULP if any of IXAF_VERIFY_LSO, IXAF_VERIFY_PMTU,
2193 * or IXAF_VERIFY_ZCOPY is set.
2195 ixa_notify_t ixa_notify; /* Registered upcall notify function */
2196 void *ixa_notify_cookie; /* ULP cookie for ixa_notify */
2198 uint_t ixa_tcpcleanup; /* Used by conn_ixa_cleanup */
2202 * Flags to indicate which transmit attributes are set.
2203 * Split into "xxx_SET" ones which indicate that the "xxx" field it set, and
2204 * single flags.
2206 #define IXAF_REACH_CONF 0x00000001 /* Reachability confirmation */
2207 #define IXAF_BROADCAST_TTL_SET 0x00000002 /* ixa_broadcast_ttl valid */
2208 #define IXAF_SET_SOURCE 0x00000004 /* Replace if broadcast */
2209 #define IXAF_USE_MIN_MTU 0x00000008 /* IPV6_USE_MIN_MTU */
2211 #define IXAF_DONTFRAG 0x00000010 /* IP*_DONTFRAG */
2212 #define IXAF_VERIFY_PMTU 0x00000020 /* ixa_pmtu/ixa_fragsize set */
2213 #define IXAF_PMTU_DISCOVERY 0x00000040 /* Create/use PMTU state */
2214 #define IXAF_MULTICAST_LOOP 0x00000080 /* IP_MULTICAST_LOOP */
2216 #define IXAF_IPSEC_SECURE 0x00000100 /* Need IPsec processing */
2217 #define IXAF_DONTROUTE 0x00000400 /* SO_DONTROUTE */
2218 #define IXAF_NO_IPSEC 0x00000800 /* Ignore policy */
2220 #define IXAF_PMTU_TOO_SMALL 0x00001000 /* PMTU too small */
2221 #define IXAF_SET_ULP_CKSUM 0x00002000 /* Calculate ULP checksum */
2222 #define IXAF_VERIFY_SOURCE 0x00004000 /* Check that source is ok */
2223 #define IXAF_NEXTHOP_SET 0x00008000 /* ixa_nexthop set */
2225 #define IXAF_PMTU_IPV4_DF 0x00010000 /* Set IPv4 DF */
2226 #define IXAF_NO_DEV_FLOW_CTL 0x00020000 /* Protocol needs no flow ctl */
2227 #define IXAF_NO_TTL_CHANGE 0x00040000 /* Internal to IP */
2228 #define IXAF_IPV6_ADD_FRAGHDR 0x00080000 /* Add fragment header */
2230 #define IXAF_IPSEC_TUNNEL 0x00100000 /* Tunnel mode */
2231 #define IXAF_NO_PFHOOK 0x00200000 /* Skip xmit pfhook */
2232 #define IXAF_NO_TRACE 0x00400000 /* When back from ARP/ND */
2233 #define IXAF_SCOPEID_SET 0x00800000 /* ixa_scopeid set */
2235 #define IXAF_NO_HW_CKSUM 0x02000000 /* Force software cksum */
2236 #define IXAF_SET_RAW_CKSUM 0x04000000 /* Use ixa_raw_cksum_offset */
2237 #define IXAF_IPSEC_GLOBAL_POLICY 0x08000000 /* Policy came from global */
2239 /* Note the following uses bits 0x10000000 through 0x80000000 */
2240 #define IXAF_IS_IPV4 IAF_IS_IPV4
2241 #define IXAF_TRUSTED_ICMP IAF_TRUSTED_ICMP
2242 #define IXAF_NO_LOOP_ZONEID_SET IAF_NO_LOOP_ZONEID_SET
2243 #define IXAF_LOOPBACK_COPY IAF_LOOPBACK_COPY
2245 /* Note: use the upper 32 bits */
2246 #define IXAF_VERIFY_LSO 0x100000000 /* Check LSO capability */
2247 #define IXAF_LSO_CAPAB 0x200000000 /* Capable of LSO */
2248 #define IXAF_VERIFY_ZCOPY 0x400000000 /* Check Zero Copy capability */
2249 #define IXAF_ZCOPY_CAPAB 0x800000000 /* Capable of ZEROCOPY */
2252 * The normal flags for sending packets e.g., icmp errors
2254 #define IXAF_BASIC_SIMPLE_V4 \
2255 (IXAF_SET_ULP_CKSUM | IXAF_IS_IPV4 | IXAF_VERIFY_SOURCE)
2256 #define IXAF_BASIC_SIMPLE_V6 (IXAF_SET_ULP_CKSUM | IXAF_VERIFY_SOURCE)
2259 * Normally these fields do not have a hold. But in some cases they do, for
2260 * instance when we've gone through ip_*_attr_to/from_mblk.
2261 * We use ixa_free_flags to indicate that they have a hold and need to be
2262 * released on cleanup.
2264 #define IXA_FREE_CRED 0x00000001 /* ixa_cred needs to be rele */
2267 * Trivial state machine used to synchronize IXA cleanup for TCP connections.
2268 * See conn_ixa_cleanup().
2270 #define IXATC_IDLE 0x00000000
2271 #define IXATC_INPROGRESS 0x00000001
2272 #define IXATC_COMPLETE 0x00000002
2275 * Simplistic way to set the ixa_xmit_hint for locally generated traffic
2276 * and forwarded traffic. The shift amount are based on the size of the
2277 * structs to discard the low order bits which don't have much if any variation
2278 * (coloring in kmem_cache_alloc might provide some variation).
2280 * Basing the locally generated hint on the address of the conn_t means that
2281 * the packets from the same socket/connection do not get reordered.
2282 * Basing the hint for forwarded traffic on the ill_ring_t means that
2283 * packets from the same NIC+ring are likely to use the same outbound ring
2284 * hence we get low contention on the ring in the transmitting driver.
2286 #define CONN_TO_XMIT_HINT(connp) ((uint32_t)(((uintptr_t)connp) >> 11))
2287 #define ILL_RING_TO_XMIT_HINT(ring) ((uint32_t)(((uintptr_t)ring) >> 7))
2290 * IP set Destination Flags used by function ip_set_destination,
2291 * ip_attr_connect, and conn_connect.
2293 #define IPDF_ALLOW_MCBC 0x1 /* Allow multi/broadcast */
2294 #define IPDF_VERIFY_DST 0x2 /* Verify destination addr */
2295 #define IPDF_SELECT_SRC 0x4 /* Select source address */
2296 #define IPDF_LSO 0x8 /* Try LSO */
2297 #define IPDF_IPSEC 0x10 /* Set IPsec policy */
2298 #define IPDF_ZONE_IS_GLOBAL 0x20 /* From conn_zone_is_global */
2299 #define IPDF_ZCOPY 0x40 /* Try ZEROCOPY */
2300 #define IPDF_UNIQUE_DCE 0x80 /* Get a per-destination DCE */
2303 * Receive side attributes used between the transport protocols and IP as
2304 * well as inside IP.
2306 struct ip_recv_attr_s {
2307 iaflags_t ira_flags; /* See below */
2309 uint32_t ira_free_flags; /* IRA_FREE_*. See below */
2312 * This is a hint for TCP SYN packets.
2313 * Always initialized independently of ira_flags settings
2315 squeue_t *ira_sqp;
2316 ill_rx_ring_t *ira_ring; /* Internal to IP */
2318 /* For ip_accept_tcp when IRAF_TARGET_SQP is set */
2319 squeue_t *ira_target_sqp;
2320 mblk_t *ira_target_sqp_mp;
2322 /* Always initialized independently of ira_flags settings */
2323 uint32_t ira_xmit_hint; /* For ECMP and GLD TX ring fanout */
2324 zoneid_t ira_zoneid; /* ALL_ZONES unless local delivery */
2325 uint_t ira_pktlen; /* Always set. For frag and stats */
2326 uint16_t ira_ip_hdr_length; /* Points to ULP header */
2327 uint8_t ira_protocol; /* Protocol number for ULP cksum */
2328 uint_t ira_rifindex; /* Received ifindex */
2329 uint_t ira_ruifindex; /* Received upper ifindex */
2331 * ira_rill and ira_ill is set inside IP, but not when conn_recv is
2332 * called; ULPs should use ira_ruifindex instead.
2334 ill_t *ira_rill; /* ill where packet came */
2335 ill_t *ira_ill; /* ill where IP address hosted */
2336 cred_t *ira_cred; /* For getpeerucred */
2337 pid_t ira_cpid; /* For getpeerucred */
2339 /* Used when IRAF_VERIFIED_SRC is set; this source was ok */
2340 ipaddr_t ira_verified_src;
2343 * The following IPsec fields are only initialized when
2344 * IRAF_IPSEC_SECURE is set. Otherwise they contain garbage.
2346 struct ipsec_action_s *ira_ipsec_action; /* how we made it in.. */
2347 struct ipsa_s *ira_ipsec_ah_sa; /* SA for AH */
2348 struct ipsa_s *ira_ipsec_esp_sa; /* SA for ESP */
2350 ipaddr_t ira_mroute_tunnel; /* IRAF_MROUTE_TUNNEL_SET */
2352 zoneid_t ira_no_loop_zoneid; /* IRAF_NO_LOOP_ZONEID_SET */
2354 uint32_t ira_esp_udp_ports; /* IRAF_ESP_UDP_PORTS */
2357 * For IP_RECVSLLA and ip_ndp_conflict/find_solicitation.
2358 * Same size as max for sockaddr_dl
2360 #define IRA_L2SRC_SIZE 244
2361 uint8_t ira_l2src[IRA_L2SRC_SIZE]; /* If IRAF_L2SRC_SET */
2364 * Local handle that we use to do lazy setting of ira_l2src.
2365 * We defer setting l2src until needed but we do before any
2366 * ip_input pullupmsg or copymsg.
2368 struct mac_header_info_s *ira_mhip; /* Could be NULL */
2372 * Flags to indicate which receive attributes are set.
2374 #define IRAF_IPV4_OPTIONS 0x00000002 /* Performance */
2375 #define IRAF_MULTICAST 0x00000004 /* Was multicast at L3 */
2376 #define IRAF_BROADCAST 0x00000008 /* Was broadcast at L3 */
2377 #define IRAF_MULTIBROADCAST (IRAF_MULTICAST|IRAF_BROADCAST)
2379 #define IRAF_LOOPBACK 0x00000010 /* Looped back by IP */
2380 #define IRAF_VERIFY_IP_CKSUM 0x00000020 /* Need to verify IP */
2381 #define IRAF_VERIFY_ULP_CKSUM 0x00000040 /* Need to verify TCP,UDP,etc */
2382 #define IRAF_SCTP_CSUM_ERR 0x00000080 /* sctp pkt has failed chksum */
2384 #define IRAF_IPSEC_SECURE 0x00000100 /* Passed AH and/or ESP */
2385 #define IRAF_DHCP_UNICAST 0x00000200
2386 #define IRAF_IPSEC_DECAPS 0x00000400 /* Was packet decapsulated */
2387 /* from a matching inner packet? */
2388 #define IRAF_TARGET_SQP 0x00000800 /* ira_target_sqp is set */
2389 #define IRAF_VERIFIED_SRC 0x00001000 /* ira_verified_src set */
2390 #define IRAF_RSVP 0x00002000 /* RSVP packet for rsvpd */
2391 #define IRAF_MROUTE_TUNNEL_SET 0x00004000 /* From ip_mroute_decap */
2392 #define IRAF_PIM_REGISTER 0x00008000 /* From register_mforward */
2394 #define IRAF_TX_MAC_EXEMPTABLE 0x00010000 /* Allow MAC_EXEMPT readdown */
2395 #define IRAF_TX_SHARED_ADDR 0x00020000 /* Arrived on ALL_ZONES addr */
2396 #define IRAF_ESP_UDP_PORTS 0x00040000 /* NAT-traversal packet */
2397 #define IRAF_NO_HW_CKSUM 0x00080000 /* Force software cksum */
2399 #define IRAF_ICMP_ERROR 0x00100000 /* Send to conn_recvicmp */
2400 #define IRAF_ROUTER_ALERT 0x00200000 /* IPv6 router alert */
2401 #define IRAF_L2SRC_SET 0x00400000 /* ira_l2src has been set */
2402 #define IRAF_L2SRC_LOOPBACK 0x00800000 /* Came from us */
2404 #define IRAF_L2DST_MULTICAST 0x01000000 /* Multicast at L2 */
2405 #define IRAF_L2DST_BROADCAST 0x02000000 /* Broadcast at L2 */
2406 /* Unused 0x04000000 */
2407 /* Unused 0x08000000 */
2409 /* Below starts with 0x10000000 */
2410 #define IRAF_IS_IPV4 IAF_IS_IPV4
2411 #define IRAF_TRUSTED_ICMP IAF_TRUSTED_ICMP
2412 #define IRAF_NO_LOOP_ZONEID_SET IAF_NO_LOOP_ZONEID_SET
2413 #define IRAF_LOOPBACK_COPY IAF_LOOPBACK_COPY
2416 * Normally these fields do not have a hold. But in some cases they do, for
2417 * instance when we've gone through ip_*_attr_to/from_mblk.
2418 * We use ira_free_flags to indicate that they have a hold and need to be
2419 * released on cleanup.
2421 #define IRA_FREE_CRED 0x00000001 /* ira_cred needs to be rele */
2424 * Optional destination cache entry for path MTU information,
2425 * and ULP metrics.
2427 struct dce_s {
2428 uint_t dce_generation; /* Changed since cached? */
2429 uint_t dce_flags; /* See below */
2430 uint_t dce_ipversion; /* IPv4/IPv6 version */
2431 uint32_t dce_pmtu; /* Path MTU if DCEF_PMTU */
2432 uint32_t dce_ident; /* Per destination IP ident. */
2433 iulp_t dce_uinfo; /* Metrics if DCEF_UINFO */
2435 struct dce_s *dce_next;
2436 struct dce_s **dce_ptpn;
2437 struct dcb_s *dce_bucket;
2439 union {
2440 in6_addr_t dceu_v6addr;
2441 ipaddr_t dceu_v4addr;
2442 } dce_u;
2443 #define dce_v4addr dce_u.dceu_v4addr
2444 #define dce_v6addr dce_u.dceu_v6addr
2445 /* Note that for IPv6+IPMP we use the ifindex for the upper interface */
2446 uint_t dce_ifindex; /* For IPv6 link-locals */
2448 kmutex_t dce_lock;
2449 uint_t dce_refcnt;
2450 uint64_t dce_last_change_time; /* Path MTU. In seconds */
2452 ip_stack_t *dce_ipst; /* Does not have a netstack_hold */
2456 * Values for dce_generation.
2458 * If a DCE has DCE_GENERATION_CONDEMNED, the last dce_refrele should delete
2459 * it.
2461 * DCE_GENERATION_VERIFY is never stored in dce_generation but it is
2462 * stored in places that cache DCE (such as ixa_dce_generation).
2463 * It is used as a signal that the cache is stale and needs to be reverified.
2465 #define DCE_GENERATION_CONDEMNED 0
2466 #define DCE_GENERATION_VERIFY 1
2467 #define DCE_GENERATION_INITIAL 2
2468 #define DCE_IS_CONDEMNED(dce) \
2469 ((dce)->dce_generation == DCE_GENERATION_CONDEMNED)
2473 * Values for ips_src_generation.
2475 * SRC_GENERATION_VERIFY is never stored in ips_src_generation but it is
2476 * stored in places that cache IREs (ixa_src_generation). It is used as a
2477 * signal that the cache is stale and needs to be reverified.
2479 #define SRC_GENERATION_VERIFY 0
2480 #define SRC_GENERATION_INITIAL 1
2482 void irb_refrele_ftable(irb_t *);
2484 extern struct kmem_cache *rt_entry_cache;
2486 typedef struct ire4 {
2487 ipaddr_t ire4_mask; /* Mask for matching this IRE. */
2488 ipaddr_t ire4_addr; /* Address this IRE represents. */
2489 ipaddr_t ire4_gateway_addr; /* Gateway including for IRE_ONLINK */
2490 ipaddr_t ire4_setsrc_addr; /* RTF_SETSRC */
2491 } ire4_t;
2493 typedef struct ire6 {
2494 in6_addr_t ire6_mask; /* Mask for matching this IRE. */
2495 in6_addr_t ire6_addr; /* Address this IRE represents. */
2496 in6_addr_t ire6_gateway_addr; /* Gateway including for IRE_ONLINK */
2497 in6_addr_t ire6_setsrc_addr; /* RTF_SETSRC */
2498 } ire6_t;
2500 typedef union ire_addr {
2501 ire6_t ire6_u;
2502 ire4_t ire4_u;
2503 } ire_addr_u_t;
2506 * Internet Routing Entry
2507 * When we have multiple identical IREs we logically add them by manipulating
2508 * ire_identical_ref and ire_delete first decrements
2509 * that and when it reaches 1 we know it is the last IRE.
2510 * "identical" is defined as being the same for:
2511 * ire_addr, ire_netmask, ire_gateway, ire_ill, ire_zoneid, and ire_type
2512 * For instance, multiple IRE_BROADCASTs for the same subnet number are
2513 * viewed as identical, and so are the IRE_INTERFACEs when there are
2514 * multiple logical interfaces (on the same ill) with the same subnet prefix.
2516 struct ire_s {
2517 struct ire_s *ire_next; /* The hash chain must be first. */
2518 struct ire_s **ire_ptpn; /* Pointer to previous next. */
2519 uint32_t ire_refcnt; /* Number of references */
2520 ill_t *ire_ill;
2521 uint32_t ire_identical_ref; /* IRE_INTERFACE, IRE_BROADCAST */
2522 uchar_t ire_ipversion; /* IPv4/IPv6 version */
2523 ushort_t ire_type; /* Type of IRE */
2524 uint_t ire_generation; /* Generation including CONDEMNED */
2525 uint_t ire_ib_pkt_count; /* Inbound packets for ire_addr */
2526 uint_t ire_ob_pkt_count; /* Outbound packets to ire_addr */
2527 time_t ire_create_time; /* Time (in secs) IRE was created. */
2528 uint32_t ire_flags; /* flags related to route (RTF_*) */
2530 * ire_testhidden is TRUE for INTERFACE IREs of IS_UNDER_IPMP(ill)
2531 * interfaces
2533 boolean_t ire_testhidden;
2534 pfirerecv_t ire_recvfn; /* Receive side handling */
2535 pfiresend_t ire_sendfn; /* Send side handling */
2536 pfirepostfrag_t ire_postfragfn; /* Bottom end of send handling */
2538 uint_t ire_masklen; /* # bits in ire_mask{,_v6} */
2539 ire_addr_u_t ire_u; /* IPv4/IPv6 address info. */
2541 irb_t *ire_bucket; /* Hash bucket when ire_ptphn is set */
2542 kmutex_t ire_lock;
2543 clock_t ire_last_used_time; /* For IRE_LOCAL reception */
2544 zoneid_t ire_zoneid;
2547 * Cached information of where to send packets that match this route.
2548 * The ire_dep_* information is used to determine when ire_nce_cache
2549 * needs to be updated.
2550 * ire_nce_cache is the fastpath for the Neighbor Cache Entry
2551 * for IPv6; arp info for IPv4
2552 * Since this is a cache setup and torn down independently of
2553 * applications we need to use nce_ref{rele,hold}_notr for it.
2555 nce_t *ire_nce_cache;
2558 * Quick check whether the ire_type and ire_masklen indicates
2559 * that the IRE can have ire_nce_cache set i.e., whether it is
2560 * IRE_ONLINK and for a single destination.
2562 boolean_t ire_nce_capable;
2565 * Dependency tracking so we can safely cache IRE and NCE pointers
2566 * in offlink and onlink IREs.
2567 * These are locked under the ips_ire_dep_lock rwlock. Write held
2568 * when modifying the linkage.
2569 * ire_dep_parent (Also chain towards IRE for nexthop)
2570 * ire_dep_parent_generation: ire_generation of ire_dep_parent
2571 * ire_dep_children (From parent to first child)
2572 * ire_dep_sib_next (linked list of siblings)
2573 * ire_dep_sib_ptpn (linked list of siblings)
2575 * The parent has a ire_refhold on each child, and each child has
2576 * an ire_refhold on its parent.
2577 * Since ire_dep_parent is a cache setup and torn down independently of
2578 * applications we need to use ire_ref{rele,hold}_notr for it.
2580 ire_t *ire_dep_parent;
2581 ire_t *ire_dep_children;
2582 ire_t *ire_dep_sib_next;
2583 ire_t **ire_dep_sib_ptpn; /* Pointer to previous next */
2584 uint_t ire_dep_parent_generation;
2586 uint_t ire_badcnt; /* Number of times ND_UNREACHABLE */
2587 uint64_t ire_last_badcnt; /* In seconds */
2589 /* ire_defense* and ire_last_used_time are only used on IRE_LOCALs */
2590 uint_t ire_defense_count; /* number of ARP conflicts */
2591 uint_t ire_defense_time; /* last time defended (secs) */
2593 boolean_t ire_trace_disable; /* True when alloc fails */
2594 ip_stack_t *ire_ipst; /* Does not have a netstack_hold */
2595 iulp_t ire_metrics;
2597 * default and prefix routes that are added without explicitly
2598 * specifying the interface are termed "unbound" routes, and will
2599 * have ire_unbound set to true.
2601 boolean_t ire_unbound;
2604 /* IPv4 compatibility macros */
2605 #define ire_mask ire_u.ire4_u.ire4_mask
2606 #define ire_addr ire_u.ire4_u.ire4_addr
2607 #define ire_gateway_addr ire_u.ire4_u.ire4_gateway_addr
2608 #define ire_setsrc_addr ire_u.ire4_u.ire4_setsrc_addr
2610 #define ire_mask_v6 ire_u.ire6_u.ire6_mask
2611 #define ire_addr_v6 ire_u.ire6_u.ire6_addr
2612 #define ire_gateway_addr_v6 ire_u.ire6_u.ire6_gateway_addr
2613 #define ire_setsrc_addr_v6 ire_u.ire6_u.ire6_setsrc_addr
2616 * Values for ire_generation.
2618 * If an IRE is marked with IRE_IS_CONDEMNED, the last walker of
2619 * the bucket should delete this IRE from this bucket.
2621 * IRE_GENERATION_VERIFY is never stored in ire_generation but it is
2622 * stored in places that cache IREs (such as ixa_ire_generation and
2623 * ire_dep_parent_generation). It is used as a signal that the cache is
2624 * stale and needs to be reverified.
2626 #define IRE_GENERATION_CONDEMNED 0
2627 #define IRE_GENERATION_VERIFY 1
2628 #define IRE_GENERATION_INITIAL 2
2629 #define IRE_IS_CONDEMNED(ire) \
2630 ((ire)->ire_generation == IRE_GENERATION_CONDEMNED)
2632 /* Convenient typedefs for sockaddrs */
2633 typedef struct sockaddr_in sin_t;
2634 typedef struct sockaddr_in6 sin6_t;
2636 /* Name/Value Descriptor. */
2637 typedef struct nv_s {
2638 uint64_t nv_value;
2639 char *nv_name;
2640 } nv_t;
2642 #define ILL_FRAG_HASH(s, i) \
2643 ((ntohl(s) ^ ((i) ^ ((i) >> 8))) % ILL_FRAG_HASH_TBL_COUNT)
2646 * The MAX number of allowed fragmented packets per hash bucket
2647 * calculation is based on the most common mtu size of 1500. This limit
2648 * will work well for other mtu sizes as well.
2650 #define COMMON_IP_MTU 1500
2651 #define MAX_FRAG_MIN 10
2652 #define MAX_FRAG_PKTS(ipst) \
2653 MAX(MAX_FRAG_MIN, (2 * (ipst->ips_ip_reass_queue_bytes / \
2654 (COMMON_IP_MTU * ILL_FRAG_HASH_TBL_COUNT))))
2657 * Maximum dups allowed per packet.
2659 extern uint_t ip_max_frag_dups;
2662 * Per-packet information for received packets and transmitted.
2663 * Used by the transport protocols when converting between the packet
2664 * and ancillary data and socket options.
2666 * Note: This private data structure and related IPPF_* constant
2667 * definitions are exposed to enable compilation of some debugging tools
2668 * like lsof which use struct tcp_t in <inet/tcp.h>. This is intended to be
2669 * a temporary hack and long term alternate interfaces should be defined
2670 * to support the needs of such tools and private definitions moved to
2671 * private headers.
2673 struct ip_pkt_s {
2674 uint_t ipp_fields; /* Which fields are valid */
2675 in6_addr_t ipp_addr; /* pktinfo src/dst addr */
2676 #define ipp_addr_v4 V4_PART_OF_V6(ipp_addr)
2677 uint_t ipp_unicast_hops; /* IPV6_UNICAST_HOPS, IP_TTL */
2678 uint_t ipp_hoplimit; /* IPV6_HOPLIMIT */
2679 uint_t ipp_hopoptslen;
2680 uint_t ipp_rthdrdstoptslen;
2681 uint_t ipp_rthdrlen;
2682 uint_t ipp_dstoptslen;
2683 uint_t ipp_fraghdrlen;
2684 ip6_hbh_t *ipp_hopopts;
2685 ip6_dest_t *ipp_rthdrdstopts;
2686 ip6_rthdr_t *ipp_rthdr;
2687 ip6_dest_t *ipp_dstopts;
2688 ip6_frag_t *ipp_fraghdr;
2689 uint8_t ipp_tclass; /* IPV6_TCLASS */
2690 uint8_t ipp_type_of_service; /* IP_TOS */
2691 uint_t ipp_ipv4_options_len; /* Len of IPv4 options */
2692 uint8_t *ipp_ipv4_options; /* Ptr to IPv4 options */
2694 typedef struct ip_pkt_s ip_pkt_t;
2696 extern void ip_pkt_free(ip_pkt_t *); /* free storage inside ip_pkt_t */
2697 extern ipaddr_t ip_pkt_source_route_v4(const ip_pkt_t *);
2698 extern in6_addr_t *ip_pkt_source_route_v6(const ip_pkt_t *);
2699 extern int ip_pkt_copy(ip_pkt_t *, ip_pkt_t *, int);
2700 extern void ip_pkt_source_route_reverse_v4(ip_pkt_t *);
2702 /* ipp_fields values */
2703 #define IPPF_ADDR 0x0001 /* Part of in6_pktinfo: src/dst addr */
2704 #define IPPF_HOPLIMIT 0x0002 /* Overrides unicast and multicast */
2705 #define IPPF_TCLASS 0x0004 /* Overrides class in sin6_flowinfo */
2707 #define IPPF_HOPOPTS 0x0010 /* ipp_hopopts set */
2708 #define IPPF_RTHDR 0x0020 /* ipp_rthdr set */
2709 #define IPPF_RTHDRDSTOPTS 0x0040 /* ipp_rthdrdstopts set */
2710 #define IPPF_DSTOPTS 0x0080 /* ipp_dstopts set */
2712 #define IPPF_IPV4_OPTIONS 0x0100 /* ipp_ipv4_options set */
2714 #define IPPF_FRAGHDR 0x0800 /* Used for IPsec receive side */
2717 * Data structure which is passed to conn_opt_get/set.
2718 * The conn_t is included even though it can be inferred from queue_t.
2719 * setsockopt and getsockopt use conn_ixa and conn_xmit_ipp. However,
2720 * when handling ancillary data we use separate ixa and ipps.
2722 typedef struct conn_opt_arg_s {
2723 conn_t *coa_connp;
2724 ip_xmit_attr_t *coa_ixa;
2725 ip_pkt_t *coa_ipp;
2726 boolean_t coa_ancillary; /* Ancillary data and not setsockopt */
2727 uint_t coa_changed; /* See below */
2728 } conn_opt_arg_t;
2731 * Flags for what changed.
2732 * If we want to be more efficient in the future we can have more fine
2733 * grained flags e.g., a flag for just IP_TOS changing.
2734 * For now we either call ip_set_destination (for "route changed")
2735 * and/or conn_build_hdr_template/conn_prepend_hdr (for "header changed").
2737 #define COA_HEADER_CHANGED 0x0001
2738 #define COA_ROUTE_CHANGED 0x0002
2739 #define COA_RCVBUF_CHANGED 0x0004 /* SO_RCVBUF */
2740 #define COA_SNDBUF_CHANGED 0x0008 /* SO_SNDBUF */
2741 #define COA_WROFF_CHANGED 0x0010 /* Header size changed */
2742 #define COA_ICMP_BIND_NEEDED 0x0020
2743 #define COA_OOBINLINE_CHANGED 0x0040
2745 #define TCP_PORTS_OFFSET 0
2746 #define UDP_PORTS_OFFSET 0
2749 * lookups return the ill/ipif only if the flags are clear OR Iam writer.
2750 * ill / ipif lookup functions increment the refcnt on the ill / ipif only
2751 * after calling these macros. This ensures that the refcnt on the ipif or
2752 * ill will eventually drop down to zero.
2754 #define ILL_LOOKUP_FAILED 1 /* Used as error code */
2755 #define IPIF_LOOKUP_FAILED 2 /* Used as error code */
2757 #define ILL_CAN_LOOKUP(ill) \
2758 (!((ill)->ill_state_flags & ILL_CONDEMNED) || \
2759 IAM_WRITER_ILL(ill))
2761 #define ILL_IS_CONDEMNED(ill) \
2762 ((ill)->ill_state_flags & ILL_CONDEMNED)
2764 #define IPIF_CAN_LOOKUP(ipif) \
2765 (!((ipif)->ipif_state_flags & IPIF_CONDEMNED) || \
2766 IAM_WRITER_IPIF(ipif))
2768 #define IPIF_IS_CONDEMNED(ipif) \
2769 ((ipif)->ipif_state_flags & IPIF_CONDEMNED)
2771 #define IPIF_IS_CHANGING(ipif) \
2772 ((ipif)->ipif_state_flags & IPIF_CHANGING)
2774 /* Macros used to assert that this thread is a writer */
2775 #define IAM_WRITER_IPSQ(ipsq) ((ipsq)->ipsq_xop->ipx_writer == curthread)
2776 #define IAM_WRITER_ILL(ill) IAM_WRITER_IPSQ((ill)->ill_phyint->phyint_ipsq)
2777 #define IAM_WRITER_IPIF(ipif) IAM_WRITER_ILL((ipif)->ipif_ill)
2780 * Grab ill locks in the proper order. The order is highest addressed
2781 * ill is locked first.
2783 #define GRAB_ILL_LOCKS(ill_1, ill_2) \
2785 if ((ill_1) > (ill_2)) { \
2786 if (ill_1 != NULL) \
2787 mutex_enter(&(ill_1)->ill_lock); \
2788 if (ill_2 != NULL) \
2789 mutex_enter(&(ill_2)->ill_lock); \
2790 } else { \
2791 if (ill_2 != NULL) \
2792 mutex_enter(&(ill_2)->ill_lock); \
2793 if (ill_1 != NULL && ill_1 != ill_2) \
2794 mutex_enter(&(ill_1)->ill_lock); \
2798 #define RELEASE_ILL_LOCKS(ill_1, ill_2) \
2800 if (ill_1 != NULL) \
2801 mutex_exit(&(ill_1)->ill_lock); \
2802 if (ill_2 != NULL && ill_2 != ill_1) \
2803 mutex_exit(&(ill_2)->ill_lock); \
2806 /* Get the other protocol instance ill */
2807 #define ILL_OTHER(ill) \
2808 ((ill)->ill_isv6 ? (ill)->ill_phyint->phyint_illv4 : \
2809 (ill)->ill_phyint->phyint_illv6)
2811 /* ioctl command info: Ioctl properties extracted and stored in here */
2812 typedef struct cmd_info_s
2814 ipif_t *ci_ipif; /* ipif associated with [l]ifreq ioctl's */
2815 sin_t *ci_sin; /* the sin struct passed down */
2816 sin6_t *ci_sin6; /* the sin6_t struct passed down */
2817 struct lifreq *ci_lifr; /* the lifreq struct passed down */
2818 } cmd_info_t;
2820 extern struct kmem_cache *ire_cache;
2822 extern ipaddr_t ip_g_all_ones;
2824 extern uint_t ip_loopback_mtu; /* /etc/system */
2825 extern uint_t ip_loopback_mtuplus;
2826 extern uint_t ip_loopback_mtu_v6plus;
2828 extern vmem_t *ip_minor_arena_sa;
2829 extern vmem_t *ip_minor_arena_la;
2832 * ip_g_forward controls IP forwarding. It takes two values:
2833 * 0: IP_FORWARD_NEVER Don't forward packets ever.
2834 * 1: IP_FORWARD_ALWAYS Forward packets for elsewhere.
2836 * RFC1122 says there must be a configuration switch to control forwarding,
2837 * but that the default MUST be to not forward packets ever. Implicit
2838 * control based on configuration of multiple interfaces MUST NOT be
2839 * implemented (Section 3.1). SunOS 4.1 did provide the "automatic" capability
2840 * and, in fact, it was the default. That capability is now provided in the
2841 * /etc/rc2.d/S69inet script.
2844 #define ips_ip_respond_to_address_mask_broadcast \
2845 ips_propinfo_tbl[0].prop_cur_bval
2846 #define ips_ip_g_resp_to_echo_bcast ips_propinfo_tbl[1].prop_cur_bval
2847 #define ips_ip_g_resp_to_echo_mcast ips_propinfo_tbl[2].prop_cur_bval
2848 #define ips_ip_g_resp_to_timestamp ips_propinfo_tbl[3].prop_cur_bval
2849 #define ips_ip_g_resp_to_timestamp_bcast ips_propinfo_tbl[4].prop_cur_bval
2850 #define ips_ip_g_send_redirects ips_propinfo_tbl[5].prop_cur_bval
2851 #define ips_ip_g_forward_directed_bcast ips_propinfo_tbl[6].prop_cur_bval
2852 #define ips_ip_mrtdebug ips_propinfo_tbl[7].prop_cur_uval
2853 #define ips_ip_ire_reclaim_fraction ips_propinfo_tbl[8].prop_cur_uval
2854 #define ips_ip_nce_reclaim_fraction ips_propinfo_tbl[9].prop_cur_uval
2855 #define ips_ip_dce_reclaim_fraction ips_propinfo_tbl[10].prop_cur_uval
2856 #define ips_ip_def_ttl ips_propinfo_tbl[11].prop_cur_uval
2857 #define ips_ip_forward_src_routed ips_propinfo_tbl[12].prop_cur_bval
2858 #define ips_ip_wroff_extra ips_propinfo_tbl[13].prop_cur_uval
2859 #define ips_ip_pathmtu_interval ips_propinfo_tbl[14].prop_cur_uval
2860 #define ips_ip_icmp_return ips_propinfo_tbl[15].prop_cur_uval
2861 #define ips_ip_path_mtu_discovery ips_propinfo_tbl[16].prop_cur_bval
2862 #define ips_ip_pmtu_min ips_propinfo_tbl[17].prop_cur_uval
2863 #define ips_ip_ignore_redirect ips_propinfo_tbl[18].prop_cur_bval
2864 #define ips_ip_arp_icmp_error ips_propinfo_tbl[19].prop_cur_bval
2865 #define ips_ip_broadcast_ttl ips_propinfo_tbl[20].prop_cur_uval
2866 #define ips_ip_icmp_err_interval ips_propinfo_tbl[21].prop_cur_uval
2867 #define ips_ip_icmp_err_burst ips_propinfo_tbl[22].prop_cur_uval
2868 #define ips_ip_reass_queue_bytes ips_propinfo_tbl[23].prop_cur_uval
2869 #define ips_ip_strict_dst_multihoming ips_propinfo_tbl[24].prop_cur_uval
2870 #define ips_ip_addrs_per_if ips_propinfo_tbl[25].prop_cur_uval
2871 #define ips_ipsec_override_persocket_policy ips_propinfo_tbl[26].prop_cur_bval
2872 #define ips_icmp_accept_clear_messages ips_propinfo_tbl[27].prop_cur_bval
2873 #define ips_igmp_accept_clear_messages ips_propinfo_tbl[28].prop_cur_bval
2875 /* IPv6 configuration knobs */
2876 #define ips_delay_first_probe_time ips_propinfo_tbl[29].prop_cur_uval
2877 #define ips_max_unicast_solicit ips_propinfo_tbl[30].prop_cur_uval
2878 #define ips_ipv6_def_hops ips_propinfo_tbl[31].prop_cur_uval
2879 #define ips_ipv6_icmp_return ips_propinfo_tbl[32].prop_cur_uval
2880 #define ips_ipv6_forward_src_routed ips_propinfo_tbl[33].prop_cur_bval
2881 #define ips_ipv6_resp_echo_mcast ips_propinfo_tbl[34].prop_cur_bval
2882 #define ips_ipv6_send_redirects ips_propinfo_tbl[35].prop_cur_bval
2883 #define ips_ipv6_ignore_redirect ips_propinfo_tbl[36].prop_cur_bval
2884 #define ips_ipv6_strict_dst_multihoming ips_propinfo_tbl[37].prop_cur_uval
2885 #define ips_src_check ips_propinfo_tbl[38].prop_cur_uval
2886 #define ips_ipsec_policy_log_interval ips_propinfo_tbl[39].prop_cur_uval
2887 #define ips_pim_accept_clear_messages ips_propinfo_tbl[40].prop_cur_bval
2888 #define ips_ip_ndp_unsolicit_interval ips_propinfo_tbl[41].prop_cur_uval
2889 #define ips_ip_ndp_unsolicit_count ips_propinfo_tbl[42].prop_cur_uval
2890 #define ips_ipv6_ignore_home_address_opt ips_propinfo_tbl[43].prop_cur_bval
2892 /* Misc IP configuration knobs */
2893 #define ips_ip_policy_mask ips_propinfo_tbl[44].prop_cur_uval
2894 #define ips_ip_ecmp_behavior ips_propinfo_tbl[45].prop_cur_uval
2895 #define ips_ip_ire_badcnt_lifetime ips_propinfo_tbl[46].prop_cur_uval
2896 #define ips_ip_max_temp_idle ips_propinfo_tbl[47].prop_cur_uval
2897 #define ips_ip_max_temp_defend ips_propinfo_tbl[48].prop_cur_uval
2898 #define ips_ip_max_defend ips_propinfo_tbl[49].prop_cur_uval
2899 #define ips_ip_defend_interval ips_propinfo_tbl[50].prop_cur_uval
2900 #define ips_ip_dup_recovery ips_propinfo_tbl[51].prop_cur_uval
2901 #define ips_ip_restrict_interzone_loopback ips_propinfo_tbl[52].prop_cur_bval
2902 #define ips_ip_lso_outbound ips_propinfo_tbl[53].prop_cur_bval
2903 #define ips_igmp_max_version ips_propinfo_tbl[54].prop_cur_uval
2904 #define ips_mld_max_version ips_propinfo_tbl[55].prop_cur_uval
2905 #define ips_ip_forwarding ips_propinfo_tbl[56].prop_cur_bval
2906 #define ips_ipv6_forwarding ips_propinfo_tbl[57].prop_cur_bval
2907 #define ips_ip_reassembly_timeout ips_propinfo_tbl[58].prop_cur_uval
2908 #define ips_ipv6_reassembly_timeout ips_propinfo_tbl[59].prop_cur_uval
2909 #define ips_arp_probe_delay ips_propinfo_tbl[60].prop_cur_uval
2910 #define ips_arp_fastprobe_delay ips_propinfo_tbl[61].prop_cur_uval
2911 #define ips_arp_probe_interval ips_propinfo_tbl[62].prop_cur_uval
2912 #define ips_arp_fastprobe_interval ips_propinfo_tbl[63].prop_cur_uval
2913 #define ips_arp_probe_count ips_propinfo_tbl[64].prop_cur_uval
2914 #define ips_arp_fastprobe_count ips_propinfo_tbl[65].prop_cur_uval
2915 #define ips_ipv4_dad_announce_interval ips_propinfo_tbl[66].prop_cur_uval
2916 #define ips_ipv6_dad_announce_interval ips_propinfo_tbl[67].prop_cur_uval
2917 #define ips_arp_defend_interval ips_propinfo_tbl[68].prop_cur_uval
2918 #define ips_arp_defend_rate ips_propinfo_tbl[69].prop_cur_uval
2919 #define ips_ndp_defend_interval ips_propinfo_tbl[70].prop_cur_uval
2920 #define ips_ndp_defend_rate ips_propinfo_tbl[71].prop_cur_uval
2921 #define ips_arp_defend_period ips_propinfo_tbl[72].prop_cur_uval
2922 #define ips_ndp_defend_period ips_propinfo_tbl[73].prop_cur_uval
2923 #define ips_ipv4_icmp_return_pmtu ips_propinfo_tbl[74].prop_cur_bval
2924 #define ips_ipv6_icmp_return_pmtu ips_propinfo_tbl[75].prop_cur_bval
2925 #define ips_ip_arp_publish_count ips_propinfo_tbl[76].prop_cur_uval
2926 #define ips_ip_arp_publish_interval ips_propinfo_tbl[77].prop_cur_uval
2927 #define ips_ip_strict_src_multihoming ips_propinfo_tbl[78].prop_cur_uval
2928 #define ips_ipv6_strict_src_multihoming ips_propinfo_tbl[79].prop_cur_uval
2929 #define ips_ipv6_drop_inbound_icmpv6 ips_propinfo_tbl[80].prop_cur_bval
2930 #define ips_ip_dce_reclaim_threshold ips_propinfo_tbl[81].prop_cur_uval
2932 extern int dohwcksum; /* use h/w cksum if supported by the h/w */
2933 #ifdef ZC_TEST
2934 extern int noswcksum;
2935 #endif
2937 extern char ipif_loopback_name[];
2939 extern nv_t *ire_nv_tbl;
2941 extern struct module_info ip_mod_info;
2943 #define HOOKS4_INTERESTED_PHYSICAL_IN(ipst) \
2944 ((ipst)->ips_ip4_physical_in_event.he_interested)
2945 #define HOOKS6_INTERESTED_PHYSICAL_IN(ipst) \
2946 ((ipst)->ips_ip6_physical_in_event.he_interested)
2947 #define HOOKS4_INTERESTED_PHYSICAL_OUT(ipst) \
2948 ((ipst)->ips_ip4_physical_out_event.he_interested)
2949 #define HOOKS6_INTERESTED_PHYSICAL_OUT(ipst) \
2950 ((ipst)->ips_ip6_physical_out_event.he_interested)
2951 #define HOOKS4_INTERESTED_FORWARDING(ipst) \
2952 ((ipst)->ips_ip4_forwarding_event.he_interested)
2953 #define HOOKS6_INTERESTED_FORWARDING(ipst) \
2954 ((ipst)->ips_ip6_forwarding_event.he_interested)
2955 #define HOOKS4_INTERESTED_LOOPBACK_IN(ipst) \
2956 ((ipst)->ips_ip4_loopback_in_event.he_interested)
2957 #define HOOKS6_INTERESTED_LOOPBACK_IN(ipst) \
2958 ((ipst)->ips_ip6_loopback_in_event.he_interested)
2959 #define HOOKS4_INTERESTED_LOOPBACK_OUT(ipst) \
2960 ((ipst)->ips_ip4_loopback_out_event.he_interested)
2961 #define HOOKS6_INTERESTED_LOOPBACK_OUT(ipst) \
2962 ((ipst)->ips_ip6_loopback_out_event.he_interested)
2964 * Hooks marcos used inside of ip
2965 * The callers use the above INTERESTED macros first, hence
2966 * the he_interested check is superflous.
2968 #define FW_HOOKS(_hook, _event, _ilp, _olp, _iph, _fm, _m, _llm, ipst, _err) \
2969 if ((_hook).he_interested) { \
2970 hook_pkt_event_t info; \
2972 _NOTE(CONSTCOND) \
2973 ASSERT((_ilp != NULL) || (_olp != NULL)); \
2975 FW_SET_ILL_INDEX(info.hpe_ifp, (ill_t *)_ilp); \
2976 FW_SET_ILL_INDEX(info.hpe_ofp, (ill_t *)_olp); \
2977 info.hpe_protocol = ipst->ips_ipv4_net_data; \
2978 info.hpe_hdr = _iph; \
2979 info.hpe_mp = &(_fm); \
2980 info.hpe_mb = _m; \
2981 info.hpe_flags = _llm; \
2982 _err = hook_run(ipst->ips_ipv4_net_data->netd_hooks, \
2983 _event, (hook_data_t)&info); \
2984 if (_err != 0) { \
2985 ip2dbg(("%s hook dropped mblk chain %p hdr %p\n",\
2986 (_hook).he_name, (void *)_fm, (void *)_m)); \
2987 if (_fm != NULL) { \
2988 freemsg(_fm); \
2989 _fm = NULL; \
2991 _iph = NULL; \
2992 _m = NULL; \
2993 } else { \
2994 _iph = info.hpe_hdr; \
2995 _m = info.hpe_mb; \
2999 #define FW_HOOKS6(_hook, _event, _ilp, _olp, _iph, _fm, _m, _llm, ipst, _err) \
3000 if ((_hook).he_interested) { \
3001 hook_pkt_event_t info; \
3003 _NOTE(CONSTCOND) \
3004 ASSERT((_ilp != NULL) || (_olp != NULL)); \
3006 FW_SET_ILL_INDEX(info.hpe_ifp, (ill_t *)_ilp); \
3007 FW_SET_ILL_INDEX(info.hpe_ofp, (ill_t *)_olp); \
3008 info.hpe_protocol = ipst->ips_ipv6_net_data; \
3009 info.hpe_hdr = _iph; \
3010 info.hpe_mp = &(_fm); \
3011 info.hpe_mb = _m; \
3012 info.hpe_flags = _llm; \
3013 _err = hook_run(ipst->ips_ipv6_net_data->netd_hooks, \
3014 _event, (hook_data_t)&info); \
3015 if (_err != 0) { \
3016 ip2dbg(("%s hook dropped mblk chain %p hdr %p\n",\
3017 (_hook).he_name, (void *)_fm, (void *)_m)); \
3018 if (_fm != NULL) { \
3019 freemsg(_fm); \
3020 _fm = NULL; \
3022 _iph = NULL; \
3023 _m = NULL; \
3024 } else { \
3025 _iph = info.hpe_hdr; \
3026 _m = info.hpe_mb; \
3030 #define FW_SET_ILL_INDEX(fp, ill) \
3031 _NOTE(CONSTCOND) \
3032 if ((ill) == NULL || (ill)->ill_phyint == NULL) { \
3033 (fp) = 0; \
3034 _NOTE(CONSTCOND) \
3035 } else if (IS_UNDER_IPMP(ill)) { \
3036 (fp) = ipmp_ill_get_ipmp_ifindex(ill); \
3037 } else { \
3038 (fp) = (ill)->ill_phyint->phyint_ifindex; \
3042 * Network byte order macros
3044 #ifdef _BIG_ENDIAN
3045 #define N_IN_CLASSA_NET IN_CLASSA_NET
3046 #define N_IN_CLASSD_NET IN_CLASSD_NET
3047 #define N_INADDR_UNSPEC_GROUP INADDR_UNSPEC_GROUP
3048 #define N_IN_LOOPBACK_NET (ipaddr_t)0x7f000000U
3049 #else /* _BIG_ENDIAN */
3050 #define N_IN_CLASSA_NET (ipaddr_t)0x000000ffU
3051 #define N_IN_CLASSD_NET (ipaddr_t)0x000000f0U
3052 #define N_INADDR_UNSPEC_GROUP (ipaddr_t)0x000000e0U
3053 #define N_IN_LOOPBACK_NET (ipaddr_t)0x0000007fU
3054 #endif /* _BIG_ENDIAN */
3055 #define CLASSD(addr) (((addr) & N_IN_CLASSD_NET) == N_INADDR_UNSPEC_GROUP)
3056 #define CLASSE(addr) (((addr) & N_IN_CLASSD_NET) == N_IN_CLASSD_NET)
3057 #define IP_LOOPBACK_ADDR(addr) \
3058 (((addr) & N_IN_CLASSA_NET == N_IN_LOOPBACK_NET))
3060 extern int ip_debug;
3061 extern uint_t ip_thread_data;
3062 extern krwlock_t ip_thread_rwlock;
3063 extern list_t ip_thread_list;
3065 #ifdef IP_DEBUG
3066 #include <sys/debug.h>
3067 #include <sys/promif.h>
3069 #define ip0dbg(a) printf a
3070 #define ip1dbg(a) if (ip_debug > 2) printf a
3071 #define ip2dbg(a) if (ip_debug > 3) printf a
3072 #define ip3dbg(a) if (ip_debug > 4) printf a
3073 #else
3074 #define ip0dbg(a) /* */
3075 #define ip1dbg(a) /* */
3076 #define ip2dbg(a) /* */
3077 #define ip3dbg(a) /* */
3078 #endif /* IP_DEBUG */
3080 /* Default MAC-layer address string length for mac_colon_addr */
3081 #define MAC_STR_LEN 128
3083 struct mac_header_info_s;
3085 extern void ill_frag_timer(void *);
3086 extern ill_t *ill_first(int, int, ill_walk_context_t *, ip_stack_t *);
3087 extern ill_t *ill_next(ill_walk_context_t *, ill_t *);
3088 extern void ill_frag_timer_start(ill_t *);
3089 extern void ill_nic_event_dispatch(ill_t *, lif_if_t, nic_event_t,
3090 nic_event_data_t, size_t);
3091 extern mblk_t *ip_carve_mp(mblk_t **, ssize_t);
3092 extern mblk_t *ip_dlpi_alloc(size_t, t_uscalar_t);
3093 extern mblk_t *ip_dlnotify_alloc(uint_t, uint_t);
3094 extern mblk_t *ip_dlnotify_alloc2(uint_t, uint_t, uint_t);
3095 extern char *ip_dot_addr(ipaddr_t, char *);
3096 extern const char *mac_colon_addr(const uint8_t *, size_t, char *, size_t);
3097 extern void ip_lwput(queue_t *, mblk_t *);
3098 extern boolean_t icmp_err_rate_limit(ip_stack_t *);
3099 extern void icmp_frag_needed(mblk_t *, int, ip_recv_attr_t *);
3100 extern mblk_t *icmp_inbound_v4(mblk_t *, ip_recv_attr_t *);
3101 extern void icmp_time_exceeded(mblk_t *, uint8_t, ip_recv_attr_t *);
3102 extern void icmp_unreachable(mblk_t *, uint8_t, ip_recv_attr_t *);
3103 extern boolean_t ip_ipsec_policy_inherit(conn_t *, conn_t *, ip_recv_attr_t *);
3104 extern void *ip_pullup(mblk_t *, ssize_t, ip_recv_attr_t *);
3105 extern void ip_setl2src(mblk_t *, ip_recv_attr_t *, ill_t *);
3106 extern mblk_t *ip_check_and_align_header(mblk_t *, uint_t, ip_recv_attr_t *);
3107 extern mblk_t *ip_check_length(mblk_t *, uchar_t *, ssize_t, uint_t, uint_t,
3108 ip_recv_attr_t *);
3109 extern mblk_t *ip_check_optlen(mblk_t *, ipha_t *, uint_t, uint_t,
3110 ip_recv_attr_t *);
3111 extern mblk_t *ip_fix_dbref(mblk_t *, ip_recv_attr_t *);
3112 extern uint_t ip_cksum(mblk_t *, int, uint32_t);
3113 extern int ip_close(queue_t *, int);
3114 extern uint16_t ip_csum_hdr(ipha_t *);
3115 extern void ip_forward_xmit_v4(nce_t *, ill_t *, mblk_t *, ipha_t *,
3116 ip_recv_attr_t *, uint32_t, uint32_t);
3117 extern boolean_t ip_forward_options(mblk_t *, ipha_t *, ill_t *,
3118 ip_recv_attr_t *);
3119 extern int ip_fragment_v4(mblk_t *, nce_t *, iaflags_t, uint_t, uint32_t,
3120 uint32_t, zoneid_t, zoneid_t, pfirepostfrag_t postfragfn,
3121 uintptr_t *cookie);
3122 extern void ip_proto_not_sup(mblk_t *, ip_recv_attr_t *);
3123 extern void ip_ire_g_fini(void);
3124 extern void ip_ire_g_init(void);
3125 extern void ip_ire_fini(ip_stack_t *);
3126 extern void ip_ire_init(ip_stack_t *);
3127 extern void ip_mdata_to_mhi(ill_t *, mblk_t *, struct mac_header_info_s *);
3128 extern int ip_openv4(queue_t *q, dev_t *devp, int flag, int sflag,
3129 cred_t *credp);
3130 extern int ip_openv6(queue_t *q, dev_t *devp, int flag, int sflag,
3131 cred_t *credp);
3132 extern int ip_reassemble(mblk_t *, ipf_t *, uint_t, boolean_t, ill_t *,
3133 size_t);
3134 extern void ip_rput(queue_t *, mblk_t *);
3135 extern void ip_input(ill_t *, ill_rx_ring_t *, mblk_t *,
3136 struct mac_header_info_s *);
3137 extern void ip_input_v6(ill_t *, ill_rx_ring_t *, mblk_t *,
3138 struct mac_header_info_s *);
3139 extern mblk_t *ip_input_common_v4(ill_t *, ill_rx_ring_t *, mblk_t *,
3140 struct mac_header_info_s *, squeue_t *, mblk_t **, uint_t *);
3141 extern mblk_t *ip_input_common_v6(ill_t *, ill_rx_ring_t *, mblk_t *,
3142 struct mac_header_info_s *, squeue_t *, mblk_t **, uint_t *);
3143 extern void ill_input_full_v4(mblk_t *, void *, void *,
3144 ip_recv_attr_t *, rtc_t *);
3145 extern void ill_input_short_v4(mblk_t *, void *, void *,
3146 ip_recv_attr_t *, rtc_t *);
3147 extern void ill_input_full_v6(mblk_t *, void *, void *,
3148 ip_recv_attr_t *, rtc_t *);
3149 extern void ill_input_short_v6(mblk_t *, void *, void *,
3150 ip_recv_attr_t *, rtc_t *);
3151 extern ipaddr_t ip_input_options(ipha_t *, ipaddr_t, mblk_t *,
3152 ip_recv_attr_t *, int *);
3153 extern boolean_t ip_input_local_options(mblk_t *, ipha_t *, ip_recv_attr_t *);
3154 extern mblk_t *ip_input_fragment(mblk_t *, ipha_t *, ip_recv_attr_t *);
3155 extern mblk_t *ip_input_fragment_v6(mblk_t *, ip6_t *, ip6_frag_t *, uint_t,
3156 ip_recv_attr_t *);
3157 extern void ip_input_post_ipsec(mblk_t *, ip_recv_attr_t *);
3158 extern void ip_fanout_v4(mblk_t *, ipha_t *, ip_recv_attr_t *);
3159 extern void ip_fanout_v6(mblk_t *, ip6_t *, ip_recv_attr_t *);
3160 extern void ip_fanout_proto_conn(conn_t *, mblk_t *, ipha_t *, ip6_t *,
3161 ip_recv_attr_t *);
3162 extern void ip_fanout_proto_v4(mblk_t *, ipha_t *, ip_recv_attr_t *);
3163 extern void ip_fanout_send_icmp_v4(mblk_t *, uint_t, uint_t,
3164 ip_recv_attr_t *);
3165 extern void ip_fanout_udp_conn(conn_t *, mblk_t *, ipha_t *, ip6_t *,
3166 ip_recv_attr_t *);
3167 extern void ip_fanout_udp_multi_v4(mblk_t *, ipha_t *, uint16_t, uint16_t,
3168 ip_recv_attr_t *);
3169 extern mblk_t *zero_spi_check(mblk_t *, ip_recv_attr_t *);
3170 extern void ip_build_hdrs_v4(uchar_t *, uint_t, const ip_pkt_t *, uint8_t);
3171 extern int ip_find_hdr_v4(ipha_t *, ip_pkt_t *, boolean_t);
3172 extern int ip_total_hdrs_len_v4(const ip_pkt_t *);
3174 extern mblk_t *ip_accept_tcp(ill_t *, ill_rx_ring_t *, squeue_t *,
3175 mblk_t *, mblk_t **, uint_t *cnt);
3176 extern void ip_rput_dlpi(ill_t *, mblk_t *);
3177 extern void ip_rput_notdata(ill_t *, mblk_t *);
3179 extern void ip_mib2_add_ip_stats(mib2_ipIfStatsEntry_t *,
3180 mib2_ipIfStatsEntry_t *);
3181 extern void ip_mib2_add_icmp6_stats(mib2_ipv6IfIcmpEntry_t *,
3182 mib2_ipv6IfIcmpEntry_t *);
3183 extern void ip_rput_other(ipsq_t *, queue_t *, mblk_t *, void *);
3184 extern ire_t *ip_check_multihome(void *, ire_t *, ill_t *);
3185 extern void ip_send_potential_redirect_v4(mblk_t *, ipha_t *, ire_t *,
3186 ip_recv_attr_t *);
3187 extern int ip_set_destination_v4(ipaddr_t *, ipaddr_t, ipaddr_t,
3188 ip_xmit_attr_t *, iulp_t *, uint32_t);
3189 extern int ip_set_destination_v6(in6_addr_t *, const in6_addr_t *,
3190 const in6_addr_t *, ip_xmit_attr_t *, iulp_t *, uint32_t);
3192 extern int ip_output_simple(mblk_t *, ip_xmit_attr_t *);
3193 extern int ip_output_simple_v4(mblk_t *, ip_xmit_attr_t *);
3194 extern int ip_output_simple_v6(mblk_t *, ip_xmit_attr_t *);
3195 extern int ip_output_options(mblk_t *, ipha_t *, ip_xmit_attr_t *,
3196 ill_t *);
3197 extern void ip_output_local_options(ipha_t *, ip_stack_t *);
3199 extern ip_xmit_attr_t *conn_get_ixa(conn_t *, boolean_t);
3200 extern ip_xmit_attr_t *conn_get_ixa_tryhard(conn_t *, boolean_t);
3201 extern ip_xmit_attr_t *conn_replace_ixa(conn_t *, ip_xmit_attr_t *);
3202 extern ip_xmit_attr_t *conn_get_ixa_exclusive(conn_t *);
3203 extern ip_xmit_attr_t *ip_xmit_attr_duplicate(ip_xmit_attr_t *);
3204 extern void ixa_inactive(ip_xmit_attr_t *);
3205 extern void ixa_refrele(ip_xmit_attr_t *);
3206 extern boolean_t ixa_check_drain_insert(conn_t *, ip_xmit_attr_t *);
3207 extern void ixa_cleanup(ip_xmit_attr_t *);
3208 extern void ira_cleanup(ip_recv_attr_t *, boolean_t);
3209 extern void ixa_safe_copy(ip_xmit_attr_t *, ip_xmit_attr_t *);
3211 extern int conn_ip_output(mblk_t *, ip_xmit_attr_t *);
3212 extern boolean_t ip_output_verify_local(ip_xmit_attr_t *);
3213 extern mblk_t *ip_output_process_local(mblk_t *, ip_xmit_attr_t *, boolean_t,
3214 boolean_t, conn_t *);
3216 extern int conn_opt_get(conn_opt_arg_t *, t_scalar_t, t_scalar_t,
3217 uchar_t *);
3218 extern int conn_opt_set(conn_opt_arg_t *, t_scalar_t, t_scalar_t, uint_t,
3219 uchar_t *, boolean_t, cred_t *);
3220 extern boolean_t conn_same_as_last_v4(conn_t *, sin_t *);
3221 extern boolean_t conn_same_as_last_v6(conn_t *, sin6_t *);
3223 extern int ip_opt_set_multicast_group(conn_t *, t_scalar_t,
3224 uchar_t *, boolean_t, boolean_t);
3225 extern int ip_opt_set_multicast_sources(conn_t *, t_scalar_t,
3226 uchar_t *, boolean_t, boolean_t);
3227 extern int conn_getsockname(conn_t *, struct sockaddr *, uint_t *);
3228 extern int conn_getpeername(conn_t *, struct sockaddr *, uint_t *);
3230 extern int conn_build_hdr_template(conn_t *, uint_t, uint_t,
3231 const in6_addr_t *, const in6_addr_t *, uint32_t);
3232 extern mblk_t *conn_prepend_hdr(ip_xmit_attr_t *, const ip_pkt_t *,
3233 const in6_addr_t *, const in6_addr_t *, uint8_t, uint32_t, uint_t,
3234 mblk_t *, uint_t, uint_t, uint32_t *, int *);
3235 extern void ip_attr_newdst(ip_xmit_attr_t *);
3236 extern void ip_attr_nexthop(const ip_pkt_t *, const ip_xmit_attr_t *,
3237 const in6_addr_t *, in6_addr_t *);
3238 extern int conn_connect(conn_t *, iulp_t *, uint32_t);
3239 extern int ip_attr_connect(const conn_t *, ip_xmit_attr_t *,
3240 const in6_addr_t *, const in6_addr_t *, const in6_addr_t *, in_port_t,
3241 in6_addr_t *, iulp_t *, uint32_t);
3242 extern int conn_inherit_parent(conn_t *, conn_t *);
3244 extern void conn_ixa_cleanup(conn_t *connp, void *arg);
3246 extern boolean_t conn_wantpacket(conn_t *, ip_recv_attr_t *, ipha_t *);
3247 extern uint_t ip_type_v4(ipaddr_t, ip_stack_t *);
3248 extern uint_t ip_type_v6(const in6_addr_t *, ip_stack_t *);
3250 extern void ip_wput_nondata(queue_t *, mblk_t *);
3251 extern void ip_wsrv(queue_t *);
3252 extern char *ip_nv_lookup(nv_t *, int);
3253 extern boolean_t ip_local_addr_ok_v6(const in6_addr_t *, const in6_addr_t *);
3254 extern boolean_t ip_remote_addr_ok_v6(const in6_addr_t *, const in6_addr_t *);
3255 extern ipaddr_t ip_massage_options(ipha_t *, netstack_t *);
3256 extern ipaddr_t ip_net_mask(ipaddr_t);
3257 extern void arp_bringup_done(ill_t *, int);
3258 extern void arp_replumb_done(ill_t *, int);
3260 extern struct qinit iprinitv6;
3262 extern void ipmp_init(ip_stack_t *);
3263 extern void ipmp_destroy(ip_stack_t *);
3264 extern ipmp_grp_t *ipmp_grp_create(const char *, phyint_t *);
3265 extern void ipmp_grp_destroy(ipmp_grp_t *);
3266 extern void ipmp_grp_info(const ipmp_grp_t *, lifgroupinfo_t *);
3267 extern int ipmp_grp_rename(ipmp_grp_t *, const char *);
3268 extern ipmp_grp_t *ipmp_grp_lookup(const char *, ip_stack_t *);
3269 extern int ipmp_grp_vet_phyint(ipmp_grp_t *, phyint_t *);
3270 extern ipmp_illgrp_t *ipmp_illgrp_create(ill_t *);
3271 extern void ipmp_illgrp_destroy(ipmp_illgrp_t *);
3272 extern ill_t *ipmp_illgrp_add_ipif(ipmp_illgrp_t *, ipif_t *);
3273 extern void ipmp_illgrp_del_ipif(ipmp_illgrp_t *, ipif_t *);
3274 extern ill_t *ipmp_illgrp_next_ill(ipmp_illgrp_t *);
3275 extern ill_t *ipmp_illgrp_hold_next_ill(ipmp_illgrp_t *);
3276 extern ill_t *ipmp_illgrp_hold_cast_ill(ipmp_illgrp_t *);
3277 extern ill_t *ipmp_illgrp_ipmp_ill(ipmp_illgrp_t *);
3278 extern void ipmp_illgrp_refresh_mtu(ipmp_illgrp_t *);
3279 extern ipmp_arpent_t *ipmp_illgrp_create_arpent(ipmp_illgrp_t *,
3280 boolean_t, ipaddr_t, uchar_t *, size_t, uint16_t);
3281 extern void ipmp_illgrp_destroy_arpent(ipmp_illgrp_t *, ipmp_arpent_t *);
3282 extern ipmp_arpent_t *ipmp_illgrp_lookup_arpent(ipmp_illgrp_t *, ipaddr_t *);
3283 extern void ipmp_illgrp_refresh_arpent(ipmp_illgrp_t *);
3284 extern void ipmp_illgrp_mark_arpent(ipmp_illgrp_t *, ipmp_arpent_t *);
3285 extern ill_t *ipmp_illgrp_find_ill(ipmp_illgrp_t *, uchar_t *, uint_t);
3286 extern void ipmp_illgrp_link_grp(ipmp_illgrp_t *, ipmp_grp_t *);
3287 extern int ipmp_illgrp_unlink_grp(ipmp_illgrp_t *);
3288 extern uint_t ipmp_ill_get_ipmp_ifindex(const ill_t *);
3289 extern void ipmp_ill_join_illgrp(ill_t *, ipmp_illgrp_t *);
3290 extern void ipmp_ill_leave_illgrp(ill_t *);
3291 extern ill_t *ipmp_ill_hold_ipmp_ill(ill_t *);
3292 extern ill_t *ipmp_ill_hold_xmit_ill(ill_t *, boolean_t);
3293 extern boolean_t ipmp_ill_is_active(ill_t *);
3294 extern void ipmp_ill_refresh_active(ill_t *);
3295 extern void ipmp_phyint_join_grp(phyint_t *, ipmp_grp_t *);
3296 extern void ipmp_phyint_leave_grp(phyint_t *);
3297 extern void ipmp_phyint_refresh_active(phyint_t *);
3298 extern ill_t *ipmp_ipif_bound_ill(const ipif_t *);
3299 extern ill_t *ipmp_ipif_hold_bound_ill(const ipif_t *);
3300 extern boolean_t ipmp_ipif_is_dataaddr(const ipif_t *);
3301 extern boolean_t ipmp_ipif_is_stubaddr(const ipif_t *);
3302 extern boolean_t ipmp_packet_is_probe(mblk_t *, ill_t *);
3303 extern void ipmp_ncec_delete_nce(ncec_t *);
3304 extern void ipmp_ncec_refresh_nce(ncec_t *);
3306 extern void conn_drain_insert(conn_t *, idl_tx_list_t *);
3307 extern void conn_setqfull(conn_t *, boolean_t *);
3308 extern void conn_clrqfull(conn_t *, boolean_t *);
3309 extern int conn_ipsec_length(conn_t *);
3310 extern ipaddr_t ip_get_dst(ipha_t *);
3311 extern uint_t ip_get_pmtu(ip_xmit_attr_t *);
3312 extern uint_t ip_get_base_mtu(ill_t *, ire_t *);
3313 extern mblk_t *ip_output_attach_policy(mblk_t *, ipha_t *, ip6_t *,
3314 const conn_t *, ip_xmit_attr_t *);
3315 extern int ipsec_out_extra_length(ip_xmit_attr_t *);
3316 extern int ipsec_out_process(mblk_t *, ip_xmit_attr_t *);
3317 extern int ip_output_post_ipsec(mblk_t *, ip_xmit_attr_t *);
3318 extern void ipsec_out_to_in(ip_xmit_attr_t *, ill_t *ill,
3319 ip_recv_attr_t *);
3321 extern void ire_cleanup(ire_t *);
3322 extern void ire_inactive(ire_t *);
3323 extern boolean_t irb_inactive(irb_t *);
3324 extern ire_t *ire_unlink(irb_t *);
3326 #ifdef DEBUG
3327 extern boolean_t th_trace_ref(const void *, ip_stack_t *);
3328 extern void th_trace_unref(const void *);
3329 extern void th_trace_cleanup(const void *, boolean_t);
3330 extern void ire_trace_ref(ire_t *);
3331 extern void ire_untrace_ref(ire_t *);
3332 #endif
3334 extern int ip_srcid_insert(const in6_addr_t *, zoneid_t, ip_stack_t *);
3335 extern int ip_srcid_remove(const in6_addr_t *, zoneid_t, ip_stack_t *);
3336 extern boolean_t ip_srcid_find_id(uint_t, in6_addr_t *, zoneid_t, boolean_t,
3337 netstack_t *);
3338 extern uint_t ip_srcid_find_addr(const in6_addr_t *, zoneid_t, netstack_t *);
3340 extern uint8_t ipoptp_next(ipoptp_t *);
3341 extern uint8_t ipoptp_first(ipoptp_t *, ipha_t *);
3342 extern int ip_opt_get_user(conn_t *, uchar_t *);
3343 extern int ipsec_req_from_conn(conn_t *, ipsec_req_t *, int);
3344 extern int ip_snmp_get(queue_t *q, mblk_t *mctl, int level, boolean_t);
3345 extern int ip_snmp_set(queue_t *q, int, int, uchar_t *, int);
3346 extern void ip_process_ioctl(ipsq_t *, queue_t *, mblk_t *, void *);
3347 extern void ip_quiesce_conn(conn_t *);
3348 extern void ip_reprocess_ioctl(ipsq_t *, queue_t *, mblk_t *, void *);
3349 extern void ip_ioctl_finish(queue_t *, mblk_t *, int, int, ipsq_t *);
3351 extern boolean_t ip_cmpbuf(const void *, uint_t, boolean_t, const void *,
3352 uint_t);
3353 extern boolean_t ip_allocbuf(void **, uint_t *, boolean_t, const void *,
3354 uint_t);
3355 extern void ip_savebuf(void **, uint_t *, boolean_t, const void *, uint_t);
3357 extern boolean_t ipsq_pending_mp_cleanup(ill_t *, conn_t *);
3358 extern void conn_ioctl_cleanup(conn_t *);
3360 extern void ip_unbind(conn_t *);
3362 extern void tnet_init(void);
3363 extern void tnet_fini(void);
3367 * rr_ring_state cycles in the order shown below from RR_FREE through
3368 * RR_FREE_IN_PROG and back to RR_FREE.
3370 typedef enum {
3371 RR_FREE, /* Free slot */
3372 RR_SQUEUE_UNBOUND, /* Ring's squeue is unbound */
3373 RR_SQUEUE_BIND_INPROG, /* Ring's squeue bind in progress */
3374 RR_SQUEUE_BOUND, /* Ring's squeue bound to cpu */
3375 RR_FREE_INPROG /* Ring is being freed */
3376 } ip_ring_state_t;
3378 #define ILL_MAX_RINGS 256 /* Max num of rx rings we can manage */
3379 #define ILL_POLLING 0x01 /* Polling in use */
3382 * These functions pointer types are exported by the mac/dls layer.
3383 * we need to duplicate the definitions here because we cannot
3384 * include mac/dls header files here.
3386 typedef boolean_t (*ip_mac_intr_disable_t)(void *);
3387 typedef void (*ip_mac_intr_enable_t)(void *);
3388 typedef ip_mac_tx_cookie_t (*ip_dld_tx_t)(void *, mblk_t *,
3389 uint64_t, uint16_t);
3390 typedef void (*ip_flow_enable_t)(void *, ip_mac_tx_cookie_t);
3391 typedef void *(*ip_dld_callb_t)(void *,
3392 ip_flow_enable_t, void *);
3393 typedef boolean_t (*ip_dld_fctl_t)(void *, ip_mac_tx_cookie_t);
3394 typedef int (*ip_capab_func_t)(void *, uint_t,
3395 void *, uint_t);
3398 * POLLING README
3399 * sq_get_pkts() is called to pick packets from softring in poll mode. It
3400 * calls rr_rx to get the chain and process it with rr_ip_accept.
3401 * rr_rx = mac_soft_ring_poll() to pick packets
3402 * rr_ip_accept = ip_accept_tcp() to process packets
3406 * XXX: With protocol, service specific squeues, they will have
3407 * specific acceptor functions.
3409 typedef mblk_t *(*ip_mac_rx_t)(void *, size_t);
3410 typedef mblk_t *(*ip_accept_t)(ill_t *, ill_rx_ring_t *,
3411 squeue_t *, mblk_t *, mblk_t **, uint_t *);
3414 * rr_intr_enable, rr_intr_disable, rr_rx_handle, rr_rx:
3415 * May be accessed while in the squeue AND after checking that SQS_POLL_CAPAB
3416 * is set.
3418 * rr_ring_state: Protected by ill_lock.
3420 struct ill_rx_ring {
3421 ip_mac_intr_disable_t rr_intr_disable; /* Interrupt disabling func */
3422 ip_mac_intr_enable_t rr_intr_enable; /* Interrupt enabling func */
3423 void *rr_intr_handle; /* Handle interrupt funcs */
3424 ip_mac_rx_t rr_rx; /* Driver receive function */
3425 ip_accept_t rr_ip_accept; /* IP accept function */
3426 void *rr_rx_handle; /* Handle for Rx ring */
3427 squeue_t *rr_sqp; /* Squeue the ring is bound to */
3428 ill_t *rr_ill; /* back pointer to ill */
3429 ip_ring_state_t rr_ring_state; /* State of this ring */
3433 * IP - DLD direct function call capability
3434 * Suffixes, df - dld function, dh - dld handle,
3435 * cf - client (IP) function, ch - client handle
3437 typedef struct ill_dld_direct_s { /* DLD provided driver Tx */
3438 ip_dld_tx_t idd_tx_df; /* str_mdata_fastpath_put */
3439 void *idd_tx_dh; /* dld_str_t *dsp */
3440 ip_dld_callb_t idd_tx_cb_df; /* mac_tx_srs_notify */
3441 void *idd_tx_cb_dh; /* mac_client_handle_t *mch */
3442 ip_dld_fctl_t idd_tx_fctl_df; /* mac_tx_is_flow_blocked */
3443 void *idd_tx_fctl_dh; /* mac_client_handle */
3444 } ill_dld_direct_t;
3446 /* IP - DLD polling capability */
3447 typedef struct ill_dld_poll_s {
3448 ill_rx_ring_t idp_ring_tbl[ILL_MAX_RINGS];
3449 } ill_dld_poll_t;
3451 /* Describes ill->ill_dld_capab */
3452 struct ill_dld_capab_s {
3453 ip_capab_func_t idc_capab_df; /* dld_capab_func */
3454 void *idc_capab_dh; /* dld_str_t *dsp */
3455 ill_dld_direct_t idc_direct;
3456 ill_dld_poll_t idc_poll;
3460 * IP squeues exports
3462 extern boolean_t ip_squeue_fanout;
3464 #define IP_SQUEUE_GET(hint) ip_squeue_random(hint)
3466 extern void ip_squeue_init(void (*)(squeue_t *));
3467 extern squeue_t *ip_squeue_random(uint_t);
3468 extern squeue_t *ip_squeue_get(ill_rx_ring_t *);
3469 extern squeue_t *ip_squeue_getfree(pri_t);
3470 extern int ip_squeue_cpu_move(squeue_t *, processorid_t);
3471 extern void *ip_squeue_add_ring(ill_t *, void *);
3472 extern void ip_squeue_bind_ring(ill_t *, ill_rx_ring_t *, processorid_t);
3473 extern void ip_squeue_clean_ring(ill_t *, ill_rx_ring_t *);
3474 extern void ip_squeue_quiesce_ring(ill_t *, ill_rx_ring_t *);
3475 extern void ip_squeue_restart_ring(ill_t *, ill_rx_ring_t *);
3476 extern void ip_squeue_clean_all(ill_t *);
3477 extern boolean_t ip_source_routed(ipha_t *, ip_stack_t *);
3479 extern void tcp_wput(queue_t *, mblk_t *);
3481 extern int ip_fill_mtuinfo(conn_t *, ip_xmit_attr_t *,
3482 struct ip6_mtuinfo *);
3483 extern hook_t *ipobs_register_hook(netstack_t *, pfv_t);
3484 extern void ipobs_unregister_hook(netstack_t *, hook_t *);
3485 extern void ipobs_hook(mblk_t *, int, zoneid_t, zoneid_t, const ill_t *,
3486 ip_stack_t *);
3487 typedef void (*ipsq_func_t)(ipsq_t *, queue_t *, mblk_t *, void *);
3489 extern void dce_g_init(void);
3490 extern void dce_g_destroy(void);
3491 extern void dce_stack_init(ip_stack_t *);
3492 extern void dce_stack_destroy(ip_stack_t *);
3493 extern void dce_cleanup(uint_t, ip_stack_t *);
3494 extern dce_t *dce_get_default(ip_stack_t *);
3495 extern dce_t *dce_lookup_pkt(mblk_t *, ip_xmit_attr_t *, uint_t *);
3496 extern dce_t *dce_lookup_v4(ipaddr_t, ip_stack_t *, uint_t *);
3497 extern dce_t *dce_lookup_v6(const in6_addr_t *, uint_t, ip_stack_t *,
3498 uint_t *);
3499 extern dce_t *dce_lookup_and_add_v4(ipaddr_t, ip_stack_t *);
3500 extern dce_t *dce_lookup_and_add_v6(const in6_addr_t *, uint_t,
3501 ip_stack_t *);
3502 extern int dce_update_uinfo_v4(ipaddr_t, iulp_t *, ip_stack_t *);
3503 extern int dce_update_uinfo_v6(const in6_addr_t *, uint_t, iulp_t *,
3504 ip_stack_t *);
3505 extern int dce_update_uinfo(const in6_addr_t *, uint_t, iulp_t *,
3506 ip_stack_t *);
3507 extern void dce_increment_generation(dce_t *);
3508 extern void dce_increment_all_generations(boolean_t, ip_stack_t *);
3509 extern void dce_refrele(dce_t *);
3510 extern void dce_refhold(dce_t *);
3511 extern void dce_refrele_notr(dce_t *);
3512 extern void dce_refhold_notr(dce_t *);
3513 mblk_t *ip_snmp_get_mib2_ip_dce(queue_t *, mblk_t *, ip_stack_t *ipst);
3515 extern ip_laddr_t ip_laddr_verify_v4(ipaddr_t, zoneid_t,
3516 ip_stack_t *, boolean_t);
3517 extern ip_laddr_t ip_laddr_verify_v6(const in6_addr_t *, zoneid_t,
3518 ip_stack_t *, boolean_t, uint_t);
3519 extern int ip_laddr_fanout_insert(conn_t *);
3521 extern boolean_t ip_verify_src(mblk_t *, ip_xmit_attr_t *, uint_t *);
3522 extern int ip_verify_ire(mblk_t *, ip_xmit_attr_t *);
3524 extern mblk_t *ip_xmit_attr_to_mblk(ip_xmit_attr_t *);
3525 extern boolean_t ip_xmit_attr_from_mblk(mblk_t *, ip_xmit_attr_t *);
3526 extern mblk_t *ip_xmit_attr_free_mblk(mblk_t *);
3527 extern mblk_t *ip_recv_attr_to_mblk(ip_recv_attr_t *);
3528 extern boolean_t ip_recv_attr_from_mblk(mblk_t *, ip_recv_attr_t *);
3529 extern mblk_t *ip_recv_attr_free_mblk(mblk_t *);
3530 extern boolean_t ip_recv_attr_is_mblk(mblk_t *);
3532 #ifdef __PRAGMA_REDEFINE_EXTNAME
3533 #pragma redefine_extname inet_ntop _inet_ntop
3534 #pragma redefine_extname inet_pton _inet_pton
3535 #else
3536 #define inet_ntop _inet_ntop
3537 #define inet_pton _inet_pton
3538 #endif /* __PRAGMA_REDEFINE_EXTNAME */
3540 extern char *inet_ntop(int, const void *, char *, int);
3541 extern int inet_pton(int, char *, void *);
3544 * Squeue tags. Tags only need to be unique when the callback function is the
3545 * same to distinguish between different calls, but we use unique tags for
3546 * convenience anyway.
3548 #define SQTAG_IP_INPUT 1
3549 #define SQTAG_TCP_INPUT_ICMP_ERR 2
3550 #define SQTAG_TCP6_INPUT_ICMP_ERR 3
3551 #define SQTAG_IP_TCP_INPUT 4
3552 #define SQTAG_IP6_TCP_INPUT 5
3553 #define SQTAG_IP_TCP_CLOSE 6
3554 #define SQTAG_TCP_OUTPUT 7
3555 #define SQTAG_TCP_TIMER 8
3556 #define SQTAG_TCP_TIMEWAIT 9
3557 #define SQTAG_TCP_ACCEPT_FINISH 10
3558 #define SQTAG_TCP_ACCEPT_FINISH_Q0 11
3559 #define SQTAG_TCP_ACCEPT_PENDING 12
3560 #define SQTAG_TCP_LISTEN_DISCON 13
3561 #define SQTAG_TCP_CONN_REQ_1 14
3562 #define SQTAG_TCP_EAGER_BLOWOFF 15
3563 #define SQTAG_TCP_EAGER_CLEANUP 16
3564 #define SQTAG_TCP_EAGER_CLEANUP_Q0 17
3565 #define SQTAG_TCP_CONN_IND 18
3566 #define SQTAG_TCP_RSRV 19
3567 #define SQTAG_TCP_ABORT_BUCKET 20
3568 #define SQTAG_TCP_REINPUT 21
3569 #define SQTAG_TCP_REINPUT_EAGER 22
3570 #define SQTAG_TCP_INPUT_MCTL 23
3571 #define SQTAG_TCP_RPUTOTHER 24
3572 #define SQTAG_IP_PROTO_AGAIN 25
3573 #define SQTAG_IP_FANOUT_TCP 26
3574 #define SQTAG_IPSQ_CLEAN_RING 27
3575 #define SQTAG_TCP_WPUT_OTHER 28
3576 #define SQTAG_TCP_CONN_REQ_UNBOUND 29
3577 #define SQTAG_TCP_SEND_PENDING 30
3578 #define SQTAG_BIND_RETRY 31
3579 #define SQTAG_UDP_FANOUT 32
3580 #define SQTAG_UDP_INPUT 33
3581 #define SQTAG_UDP_WPUT 34
3582 #define SQTAG_UDP_OUTPUT 35
3583 #define SQTAG_TCP_KSSL_INPUT 36
3584 #define SQTAG_TCP_DROP_Q0 37
3585 #define SQTAG_TCP_CONN_REQ_2 38
3586 #define SQTAG_IP_INPUT_RX_RING 39
3587 #define SQTAG_SQUEUE_CHANGE 40
3588 #define SQTAG_CONNECT_FINISH 41
3589 #define SQTAG_SYNCHRONOUS_OP 42
3590 #define SQTAG_TCP_SHUTDOWN_OUTPUT 43
3591 #define SQTAG_TCP_IXA_CLEANUP 44
3592 #define SQTAG_TCP_SEND_SYNACK 45
3594 extern sin_t sin_null; /* Zero address for quick clears */
3595 extern sin6_t sin6_null; /* Zero address for quick clears */
3597 #endif /* _KERNEL */
3599 #ifdef __cplusplus
3601 #endif
3603 #endif /* _INET_IP_H */