xref: /titanic_44/usr/src/uts/common/inet/ip.h (revision 45916cd2fec6e79bca5dee0421bd39e3c2910d1e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
55dddb8baSkcpoon  * Common Development and Distribution License (the "License").
65dddb8baSkcpoon  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
215dddb8baSkcpoon 
227c478bd9Sstevel@tonic-gate /*
235dddb8baSkcpoon  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate /* Copyright (c) 1990 Mentat Inc. */
277c478bd9Sstevel@tonic-gate 
287c478bd9Sstevel@tonic-gate #ifndef	_INET_IP_H
297c478bd9Sstevel@tonic-gate #define	_INET_IP_H
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
347c478bd9Sstevel@tonic-gate extern "C" {
357c478bd9Sstevel@tonic-gate #endif
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h>
387c478bd9Sstevel@tonic-gate #include <sys/types.h>
397c478bd9Sstevel@tonic-gate #include <inet/mib2.h>
407c478bd9Sstevel@tonic-gate #include <inet/nd.h>
417c478bd9Sstevel@tonic-gate #include <sys/atomic.h>
427c478bd9Sstevel@tonic-gate #include <sys/socket.h>
437c478bd9Sstevel@tonic-gate #include <net/if_dl.h>
447c478bd9Sstevel@tonic-gate #include <net/if.h>
457c478bd9Sstevel@tonic-gate #include <netinet/ip.h>
467c478bd9Sstevel@tonic-gate #include <sys/dlpi.h>
477c478bd9Sstevel@tonic-gate #include <netinet/igmp.h>
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #ifdef _KERNEL
507c478bd9Sstevel@tonic-gate #include <netinet/ip6.h>
517c478bd9Sstevel@tonic-gate #include <sys/avl.h>
527c478bd9Sstevel@tonic-gate #include <sys/vmem.h>
537c478bd9Sstevel@tonic-gate #include <sys/squeue.h>
54*45916cd2Sjpk #include <net/route.h>
557c478bd9Sstevel@tonic-gate #include <sys/systm.h>
56ff550d0eSmasputra #include <sys/multidata.h>
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate #ifdef DEBUG
597c478bd9Sstevel@tonic-gate #define	ILL_DEBUG
607c478bd9Sstevel@tonic-gate #define	IRE_DEBUG
617c478bd9Sstevel@tonic-gate #define	NCE_DEBUG
627c478bd9Sstevel@tonic-gate #define	CONN_DEBUG
637c478bd9Sstevel@tonic-gate #endif
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate #define	IP_DEBUG
667c478bd9Sstevel@tonic-gate /*
677c478bd9Sstevel@tonic-gate  * The mt-streams(9F) flags for the IP module; put here so that other
687c478bd9Sstevel@tonic-gate  * "drivers" that are actually IP (e.g., ICMP, UDP) can use the same set
697c478bd9Sstevel@tonic-gate  * of flags.
707c478bd9Sstevel@tonic-gate  */
717c478bd9Sstevel@tonic-gate #define	IP_DEVMTFLAGS D_MP
72ff550d0eSmasputra #endif	/* _KERNEL */
73ff550d0eSmasputra 
74ff550d0eSmasputra #define	IP_MOD_NAME	"ip"
75ff550d0eSmasputra #define	IP_DEV_NAME	"/dev/ip"
76ff550d0eSmasputra #define	IP6_DEV_NAME	"/dev/ip6"
77ff550d0eSmasputra 
78ff550d0eSmasputra #define	UDP_MOD_NAME	"udp"
79ff550d0eSmasputra #define	UDP_DEV_NAME	"/dev/udp"
80ff550d0eSmasputra #define	UDP6_DEV_NAME	"/dev/udp6"
81ff550d0eSmasputra 
82ff550d0eSmasputra #define	TCP_MOD_NAME	"tcp"
83ff550d0eSmasputra #define	TCP_DEV_NAME	"/dev/tcp"
84ff550d0eSmasputra #define	TCP6_DEV_NAME	"/dev/tcp6"
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate /* Minor numbers */
877c478bd9Sstevel@tonic-gate #define	IPV4_MINOR	0
887c478bd9Sstevel@tonic-gate #define	IPV6_MINOR	1
897c478bd9Sstevel@tonic-gate #define	TCP_MINOR	2
907c478bd9Sstevel@tonic-gate #define	TCP_MINOR6	3
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate #ifndef	_IPADDR_T
937c478bd9Sstevel@tonic-gate #define	_IPADDR_T
947c478bd9Sstevel@tonic-gate typedef uint32_t ipaddr_t;
957c478bd9Sstevel@tonic-gate #endif
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate /* Number of bits in an address */
987c478bd9Sstevel@tonic-gate #define	IP_ABITS		32
997c478bd9Sstevel@tonic-gate #define	IPV6_ABITS		128
1007c478bd9Sstevel@tonic-gate 
1017c478bd9Sstevel@tonic-gate #define	IP_HOST_MASK		(ipaddr_t)0xffffffffU
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #define	IP_CSUM(mp, off, sum)		(~ip_cksum(mp, off, sum) & 0xFFFF)
1047c478bd9Sstevel@tonic-gate #define	IP_CSUM_PARTIAL(mp, off, sum)	ip_cksum(mp, off, sum)
1057c478bd9Sstevel@tonic-gate #define	IP_BCSUM_PARTIAL(bp, len, sum)	bcksum(bp, len, sum)
1067c478bd9Sstevel@tonic-gate #define	IP_MD_CSUM(pd, off, sum)	(~ip_md_cksum(pd, off, sum) & 0xffff)
1077c478bd9Sstevel@tonic-gate #define	IP_MD_CSUM_PARTIAL(pd, off, sum) ip_md_cksum(pd, off, sum)
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate /*
1107c478bd9Sstevel@tonic-gate  * Flag to IP write side to indicate that the appln has sent in a pre-built
1117c478bd9Sstevel@tonic-gate  * IP header. Stored in ipha_ident (which is otherwise zero).
1127c478bd9Sstevel@tonic-gate  */
1137c478bd9Sstevel@tonic-gate #define	IP_HDR_INCLUDED			0xFFFF
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate #define	ILL_FRAG_HASH_TBL_COUNT	((unsigned int)64)
1167c478bd9Sstevel@tonic-gate #define	ILL_FRAG_HASH_TBL_SIZE	(ILL_FRAG_HASH_TBL_COUNT * sizeof (ipfb_t))
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #define	IPV4_ADDR_LEN			4
1197c478bd9Sstevel@tonic-gate #define	IP_ADDR_LEN			IPV4_ADDR_LEN
1207c478bd9Sstevel@tonic-gate #define	IP_ARP_PROTO_TYPE		0x0800
1217c478bd9Sstevel@tonic-gate 
1227c478bd9Sstevel@tonic-gate #define	IPV4_VERSION			4
1237c478bd9Sstevel@tonic-gate #define	IP_VERSION			IPV4_VERSION
1247c478bd9Sstevel@tonic-gate #define	IP_SIMPLE_HDR_LENGTH_IN_WORDS	5
1257c478bd9Sstevel@tonic-gate #define	IP_SIMPLE_HDR_LENGTH		20
1267c478bd9Sstevel@tonic-gate #define	IP_MAX_HDR_LENGTH		60
1277c478bd9Sstevel@tonic-gate 
128*45916cd2Sjpk #define	IP_MAX_OPT_LENGTH (IP_MAX_HDR_LENGTH-IP_SIMPLE_HDR_LENGTH)
129*45916cd2Sjpk 
1307c478bd9Sstevel@tonic-gate #define	IP_MIN_MTU			(IP_MAX_HDR_LENGTH + 8)	/* 68 bytes */
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate /*
1337c478bd9Sstevel@tonic-gate  * XXX IP_MAXPACKET is defined in <netinet/ip.h> as well. At some point the
1347c478bd9Sstevel@tonic-gate  * 2 files should be cleaned up to remove all redundant definitions.
1357c478bd9Sstevel@tonic-gate  */
1367c478bd9Sstevel@tonic-gate #define	IP_MAXPACKET			65535
1377c478bd9Sstevel@tonic-gate #define	IP_SIMPLE_HDR_VERSION \
1387c478bd9Sstevel@tonic-gate 	((IP_VERSION << 4) | IP_SIMPLE_HDR_LENGTH_IN_WORDS)
1397c478bd9Sstevel@tonic-gate 
140*45916cd2Sjpk #define	UDPH_SIZE			8
141*45916cd2Sjpk 
1427c478bd9Sstevel@tonic-gate /*
1437c478bd9Sstevel@tonic-gate  * Constants and type definitions to support IP IOCTL commands
1447c478bd9Sstevel@tonic-gate  */
1457c478bd9Sstevel@tonic-gate #define	IP_IOCTL			(('i'<<8)|'p')
1467c478bd9Sstevel@tonic-gate #define	IP_IOC_IRE_DELETE		4
1477c478bd9Sstevel@tonic-gate #define	IP_IOC_IRE_DELETE_NO_REPLY	5
1487c478bd9Sstevel@tonic-gate #define	IP_IOC_IRE_ADVISE_NO_REPLY	6
1497c478bd9Sstevel@tonic-gate #define	IP_IOC_RTS_REQUEST		7
1507c478bd9Sstevel@tonic-gate 
1517c478bd9Sstevel@tonic-gate /* Common definitions used by IP IOCTL data structures */
1527c478bd9Sstevel@tonic-gate typedef struct ipllcmd_s {
1537c478bd9Sstevel@tonic-gate 	uint_t	ipllc_cmd;
1547c478bd9Sstevel@tonic-gate 	uint_t	ipllc_name_offset;
1557c478bd9Sstevel@tonic-gate 	uint_t	ipllc_name_length;
1567c478bd9Sstevel@tonic-gate } ipllc_t;
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate /* IP IRE Change Command Structure. */
1597c478bd9Sstevel@tonic-gate typedef struct ipic_s {
1607c478bd9Sstevel@tonic-gate 	ipllc_t	ipic_ipllc;
1617c478bd9Sstevel@tonic-gate 	uint_t	ipic_ire_type;
1627c478bd9Sstevel@tonic-gate 	uint_t	ipic_max_frag;
1637c478bd9Sstevel@tonic-gate 	uint_t	ipic_addr_offset;
1647c478bd9Sstevel@tonic-gate 	uint_t	ipic_addr_length;
1657c478bd9Sstevel@tonic-gate 	uint_t	ipic_mask_offset;
1667c478bd9Sstevel@tonic-gate 	uint_t	ipic_mask_length;
1677c478bd9Sstevel@tonic-gate 	uint_t	ipic_src_addr_offset;
1687c478bd9Sstevel@tonic-gate 	uint_t	ipic_src_addr_length;
1697c478bd9Sstevel@tonic-gate 	uint_t	ipic_ll_hdr_offset;
1707c478bd9Sstevel@tonic-gate 	uint_t	ipic_ll_hdr_length;
1717c478bd9Sstevel@tonic-gate 	uint_t	ipic_gateway_addr_offset;
1727c478bd9Sstevel@tonic-gate 	uint_t	ipic_gateway_addr_length;
1737c478bd9Sstevel@tonic-gate 	clock_t	ipic_rtt;
1747c478bd9Sstevel@tonic-gate 	uint32_t ipic_ssthresh;
1757c478bd9Sstevel@tonic-gate 	clock_t	ipic_rtt_sd;
1767c478bd9Sstevel@tonic-gate 	uchar_t ipic_ire_marks;
1777c478bd9Sstevel@tonic-gate } ipic_t;
1787c478bd9Sstevel@tonic-gate 
1797c478bd9Sstevel@tonic-gate #define	ipic_cmd		ipic_ipllc.ipllc_cmd
1807c478bd9Sstevel@tonic-gate #define	ipic_ll_name_length	ipic_ipllc.ipllc_name_length
1817c478bd9Sstevel@tonic-gate #define	ipic_ll_name_offset	ipic_ipllc.ipllc_name_offset
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate /* IP IRE Delete Command Structure. */
1847c478bd9Sstevel@tonic-gate typedef struct ipid_s {
1857c478bd9Sstevel@tonic-gate 	ipllc_t	ipid_ipllc;
1867c478bd9Sstevel@tonic-gate 	uint_t	ipid_ire_type;
1877c478bd9Sstevel@tonic-gate 	uint_t	ipid_addr_offset;
1887c478bd9Sstevel@tonic-gate 	uint_t	ipid_addr_length;
1897c478bd9Sstevel@tonic-gate 	uint_t	ipid_mask_offset;
1907c478bd9Sstevel@tonic-gate 	uint_t	ipid_mask_length;
1917c478bd9Sstevel@tonic-gate } ipid_t;
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate #define	ipid_cmd		ipid_ipllc.ipllc_cmd
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate #ifdef _KERNEL
1967c478bd9Sstevel@tonic-gate /*
1977c478bd9Sstevel@tonic-gate  * Temporary state for ip options parser.
1987c478bd9Sstevel@tonic-gate  */
1997c478bd9Sstevel@tonic-gate typedef struct ipoptp_s
2007c478bd9Sstevel@tonic-gate {
2017c478bd9Sstevel@tonic-gate 	uint8_t		*ipoptp_next;	/* next option to look at */
2027c478bd9Sstevel@tonic-gate 	uint8_t		*ipoptp_end;	/* end of options */
2037c478bd9Sstevel@tonic-gate 	uint8_t		*ipoptp_cur;	/* start of current option */
2047c478bd9Sstevel@tonic-gate 	uint8_t		ipoptp_len;	/* length of current option */
2057c478bd9Sstevel@tonic-gate 	uint32_t	ipoptp_flags;
2067c478bd9Sstevel@tonic-gate } ipoptp_t;
2077c478bd9Sstevel@tonic-gate 
2087c478bd9Sstevel@tonic-gate /*
2097c478bd9Sstevel@tonic-gate  * Flag(s) for ipoptp_flags
2107c478bd9Sstevel@tonic-gate  */
2117c478bd9Sstevel@tonic-gate #define	IPOPTP_ERROR	0x00000001
2127c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
2137c478bd9Sstevel@tonic-gate 
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /* Controls forwarding of IP packets, set via ndd */
2167c478bd9Sstevel@tonic-gate #define	IP_FORWARD_NEVER	0
2177c478bd9Sstevel@tonic-gate #define	IP_FORWARD_ALWAYS	1
2187c478bd9Sstevel@tonic-gate 
2197c478bd9Sstevel@tonic-gate #define	WE_ARE_FORWARDING	(ip_g_forward == IP_FORWARD_ALWAYS)
2207c478bd9Sstevel@tonic-gate 
2217c478bd9Sstevel@tonic-gate #define	IPH_HDR_LENGTH(ipha)						\
2227c478bd9Sstevel@tonic-gate 	((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length & 0xF) << 2)
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate #define	IPH_HDR_VERSION(ipha)						\
2257c478bd9Sstevel@tonic-gate 	((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length) >> 4)
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate #ifdef _KERNEL
2287c478bd9Sstevel@tonic-gate /*
2297c478bd9Sstevel@tonic-gate  * IP reassembly macros.  We hide starting and ending offsets in b_next and
2307c478bd9Sstevel@tonic-gate  * b_prev of messages on the reassembly queue.	The messages are chained using
2317c478bd9Sstevel@tonic-gate  * b_cont.  These macros are used in ip_reassemble() so we don't have to see
2327c478bd9Sstevel@tonic-gate  * the ugly casts and assignments.
2337c478bd9Sstevel@tonic-gate  * Note that the offsets are <= 64k i.e. a uint_t is sufficient to represent
2347c478bd9Sstevel@tonic-gate  * them.
2357c478bd9Sstevel@tonic-gate  */
2367c478bd9Sstevel@tonic-gate #define	IP_REASS_START(mp)		((uint_t)(uintptr_t)((mp)->b_next))
2377c478bd9Sstevel@tonic-gate #define	IP_REASS_SET_START(mp, u)	\
2387c478bd9Sstevel@tonic-gate 	((mp)->b_next = (mblk_t *)(uintptr_t)(u))
2397c478bd9Sstevel@tonic-gate #define	IP_REASS_END(mp)		((uint_t)(uintptr_t)((mp)->b_prev))
2407c478bd9Sstevel@tonic-gate #define	IP_REASS_SET_END(mp, u)		\
2417c478bd9Sstevel@tonic-gate 	((mp)->b_prev = (mblk_t *)(uintptr_t)(u))
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate #define	IP_REASS_COMPLETE	0x1
2447c478bd9Sstevel@tonic-gate #define	IP_REASS_PARTIAL	0x2
2457c478bd9Sstevel@tonic-gate #define	IP_REASS_FAILED		0x4
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate /*
2487c478bd9Sstevel@tonic-gate  * Test to determine whether this is a module instance of IP or a
2497c478bd9Sstevel@tonic-gate  * driver instance of IP.
2507c478bd9Sstevel@tonic-gate  */
2517c478bd9Sstevel@tonic-gate #define	CONN_Q(q)	(WR(q)->q_next == NULL)
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate #define	Q_TO_CONN(q)	((conn_t *)(q)->q_ptr)
2547c478bd9Sstevel@tonic-gate #define	Q_TO_TCP(q)	(Q_TO_CONN((q))->conn_tcp)
255ff550d0eSmasputra #define	Q_TO_UDP(q)	(Q_TO_CONN((q))->conn_udp)
2567c478bd9Sstevel@tonic-gate 
2577c478bd9Sstevel@tonic-gate /*
2587c478bd9Sstevel@tonic-gate  * The following two macros are used by IP to get the appropriate
2597c478bd9Sstevel@tonic-gate  * wq and rq for a conn. If it is a TCP conn, then we need
2607c478bd9Sstevel@tonic-gate  * tcp_wq/tcp_rq else, conn_wq/conn_rq. IP can use conn_wq and conn_rq
2617c478bd9Sstevel@tonic-gate  * from a conn directly if it knows that the conn is not TCP.
2627c478bd9Sstevel@tonic-gate  */
2637c478bd9Sstevel@tonic-gate #define	CONNP_TO_WQ(connp)	\
264ff550d0eSmasputra 	(IPCL_IS_TCP(connp) ? (connp)->conn_tcp->tcp_wq : (connp)->conn_wq)
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate #define	CONNP_TO_RQ(connp)	RD(CONNP_TO_WQ(connp))
2677c478bd9Sstevel@tonic-gate 
2687c478bd9Sstevel@tonic-gate #define	GRAB_CONN_LOCK(q)	{				\
2697c478bd9Sstevel@tonic-gate 	if (q != NULL && CONN_Q(q))				\
2707c478bd9Sstevel@tonic-gate 		mutex_enter(&(Q_TO_CONN(q))->conn_lock);	\
2717c478bd9Sstevel@tonic-gate }
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate #define	RELEASE_CONN_LOCK(q)	{				\
2747c478bd9Sstevel@tonic-gate 	if (q != NULL && CONN_Q(q))				\
2757c478bd9Sstevel@tonic-gate 		mutex_exit(&(Q_TO_CONN(q))->conn_lock);		\
2767c478bd9Sstevel@tonic-gate }
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate /* "Congestion controlled" protocol */
2797c478bd9Sstevel@tonic-gate #define	IP_FLOW_CONTROLLED_ULP(p)   ((p) == IPPROTO_TCP || (p) == IPPROTO_SCTP)
2807c478bd9Sstevel@tonic-gate 
2817c478bd9Sstevel@tonic-gate /*
2827c478bd9Sstevel@tonic-gate  * Complete the pending operation. Usually an ioctl. Can also
2837c478bd9Sstevel@tonic-gate  * be a bind or option management request that got enqueued
2847c478bd9Sstevel@tonic-gate  * in an ipsq_t. Called on completion of the operation.
2857c478bd9Sstevel@tonic-gate  */
2867c478bd9Sstevel@tonic-gate #define	CONN_OPER_PENDING_DONE(connp)	{			\
2877c478bd9Sstevel@tonic-gate 	mutex_enter(&(connp)->conn_lock);			\
2887c478bd9Sstevel@tonic-gate 	(connp)->conn_oper_pending_ill = NULL;			\
2897c478bd9Sstevel@tonic-gate 	cv_broadcast(&(connp)->conn_refcv);			\
2907c478bd9Sstevel@tonic-gate 	mutex_exit(&(connp)->conn_lock);			\
2917c478bd9Sstevel@tonic-gate 	CONN_DEC_REF(connp);					\
2927c478bd9Sstevel@tonic-gate }
2937c478bd9Sstevel@tonic-gate 
2947c478bd9Sstevel@tonic-gate /* Get the credential of an IP queue of unknown type */
2957c478bd9Sstevel@tonic-gate #define	GET_QUEUE_CRED(wq)						\
2967c478bd9Sstevel@tonic-gate 	((wq)->q_next ? (((ill_t *)(wq)->q_ptr)->ill_credp) \
2977c478bd9Sstevel@tonic-gate 	    : ((Q_TO_CONN((wq)))->conn_cred))
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate /*
3007c478bd9Sstevel@tonic-gate  * Flags for the various ip_fanout_* routines.
3017c478bd9Sstevel@tonic-gate  */
3027c478bd9Sstevel@tonic-gate #define	IP_FF_SEND_ICMP		0x01	/* Send an ICMP error */
3037c478bd9Sstevel@tonic-gate #define	IP_FF_HDR_COMPLETE	0x02	/* Call ip_hdr_complete if error */
3047c478bd9Sstevel@tonic-gate #define	IP_FF_CKSUM		0x04	/* Recompute ipha_cksum if error */
3057c478bd9Sstevel@tonic-gate #define	IP_FF_RAWIP		0x08	/* Use rawip mib variable */
3067c478bd9Sstevel@tonic-gate #define	IP_FF_SRC_QUENCH	0x10	/* OK to send ICMP_SOURCE_QUENCH */
3077c478bd9Sstevel@tonic-gate #define	IP_FF_SYN_ADDIRE	0x20	/* Add IRE if TCP syn packet */
3087c478bd9Sstevel@tonic-gate #define	IP_FF_IP6INFO		0x80	/* Add ip6i_t if needed */
3097c478bd9Sstevel@tonic-gate #define	IP_FF_SEND_SLLA		0x100	/* Send source link layer info ? */
3107c478bd9Sstevel@tonic-gate #define	IPV6_REACHABILITY_CONFIRMATION	0x200	/* Flags for ip_xmit_v6 */
3117c478bd9Sstevel@tonic-gate #define	IP_FF_NO_MCAST_LOOP	0x400	/* No multicasts for sending zone */
3127c478bd9Sstevel@tonic-gate 
3137c478bd9Sstevel@tonic-gate /*
3147c478bd9Sstevel@tonic-gate  * Following flags are used by IPQoS to determine if policy processing is
3157c478bd9Sstevel@tonic-gate  * required.
3167c478bd9Sstevel@tonic-gate  */
3177c478bd9Sstevel@tonic-gate #define	IP6_NO_IPPOLICY		0x800	/* Don't do IPQoS processing */
3187c478bd9Sstevel@tonic-gate #define	IP6_IN_LLMCAST		0x1000	/* Multicast */
3197c478bd9Sstevel@tonic-gate 
320ff550d0eSmasputra #define	IP_FF_LOOPBACK		0x2000	/* Loopback fanout */
3217c478bd9Sstevel@tonic-gate 
3227c478bd9Sstevel@tonic-gate #ifndef	IRE_DB_TYPE
3237c478bd9Sstevel@tonic-gate #define	IRE_DB_TYPE	M_SIG
3247c478bd9Sstevel@tonic-gate #endif
3257c478bd9Sstevel@tonic-gate 
3267c478bd9Sstevel@tonic-gate #ifndef	IRE_DB_REQ_TYPE
3277c478bd9Sstevel@tonic-gate #define	IRE_DB_REQ_TYPE	M_PCSIG
3287c478bd9Sstevel@tonic-gate #endif
3297c478bd9Sstevel@tonic-gate 
3307c478bd9Sstevel@tonic-gate /*
3317c478bd9Sstevel@tonic-gate  * Values for squeue switch:
3327c478bd9Sstevel@tonic-gate  */
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate #define	IP_SQUEUE_ENTER_NODRAIN	1
3357c478bd9Sstevel@tonic-gate #define	IP_SQUEUE_ENTER	2
3367c478bd9Sstevel@tonic-gate /*
3377c478bd9Sstevel@tonic-gate  * This is part of the interface between Transport provider and
3387c478bd9Sstevel@tonic-gate  * IP which can be used to set policy information. This is usually
3397c478bd9Sstevel@tonic-gate  * accompanied with O_T_BIND_REQ/T_BIND_REQ.ip_bind assumes that
3407c478bd9Sstevel@tonic-gate  * only IPSEC_POLICY_SET is there when it is found in the chain.
3417c478bd9Sstevel@tonic-gate  * The information contained is an struct ipsec_req_t. On success
3427c478bd9Sstevel@tonic-gate  * or failure, either the T_BIND_ACK or the T_ERROR_ACK is returned.
3437c478bd9Sstevel@tonic-gate  * IPSEC_POLICY_SET is never returned.
3447c478bd9Sstevel@tonic-gate  */
3457c478bd9Sstevel@tonic-gate #define	IPSEC_POLICY_SET	M_SETOPTS
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate #define	IRE_IS_LOCAL(ire)	((ire != NULL) && \
3487c478bd9Sstevel@tonic-gate 				((ire)->ire_type & (IRE_LOCAL | IRE_LOOPBACK)))
3497c478bd9Sstevel@tonic-gate 
3507c478bd9Sstevel@tonic-gate #define	IRE_IS_TARGET(ire)	((ire != NULL) && \
3517c478bd9Sstevel@tonic-gate 				((ire)->ire_type != IRE_BROADCAST))
3527c478bd9Sstevel@tonic-gate 
3537c478bd9Sstevel@tonic-gate /* IP Fragmentation Reassembly Header */
3547c478bd9Sstevel@tonic-gate typedef struct ipf_s {
3557c478bd9Sstevel@tonic-gate 	struct ipf_s	*ipf_hash_next;
3567c478bd9Sstevel@tonic-gate 	struct ipf_s	**ipf_ptphn;	/* Pointer to previous hash next. */
3577c478bd9Sstevel@tonic-gate 	uint32_t	ipf_ident;	/* Ident to match. */
3587c478bd9Sstevel@tonic-gate 	uint8_t		ipf_protocol;	/* Protocol to match. */
3597c478bd9Sstevel@tonic-gate 	uchar_t		ipf_last_frag_seen : 1;	/* Last fragment seen ? */
3607c478bd9Sstevel@tonic-gate 	time_t		ipf_timestamp;	/* Reassembly start time. */
3617c478bd9Sstevel@tonic-gate 	mblk_t		*ipf_mp;	/* mblk we live in. */
3627c478bd9Sstevel@tonic-gate 	mblk_t		*ipf_tail_mp;	/* Frag queue tail pointer. */
3637c478bd9Sstevel@tonic-gate 	int		ipf_hole_cnt;	/* Number of holes (hard-case). */
3647c478bd9Sstevel@tonic-gate 	int		ipf_end;	/* Tail end offset (0 -> hard-case). */
3657c478bd9Sstevel@tonic-gate 	uint_t		ipf_gen;	/* Frag queue generation */
3667c478bd9Sstevel@tonic-gate 	size_t		ipf_count;	/* Count of bytes used by frag */
3677c478bd9Sstevel@tonic-gate 	uint_t		ipf_nf_hdr_len; /* Length of nonfragmented header */
3687c478bd9Sstevel@tonic-gate 	in6_addr_t	ipf_v6src;	/* IPv6 source address */
3697c478bd9Sstevel@tonic-gate 	in6_addr_t	ipf_v6dst;	/* IPv6 dest address */
3707c478bd9Sstevel@tonic-gate 	uint_t		ipf_prev_nexthdr_offset; /* Offset for nexthdr value */
3717c478bd9Sstevel@tonic-gate 	uint8_t		ipf_ecn;	/* ECN info for the fragments */
3727c478bd9Sstevel@tonic-gate 	uint8_t		ipf_num_dups;	/* Number of times dup frags recvd */
373ff550d0eSmasputra 	uint16_t	ipf_checksum_flags; /* Hardware checksum flags */
374ff550d0eSmasputra 	uint32_t	ipf_checksum;	/* Partial checksum of fragment data */
3757c478bd9Sstevel@tonic-gate } ipf_t;
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate #define	ipf_src	V4_PART_OF_V6(ipf_v6src)
3787c478bd9Sstevel@tonic-gate #define	ipf_dst	V4_PART_OF_V6(ipf_v6dst)
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate typedef enum {
3817c478bd9Sstevel@tonic-gate 	IB_PKT =  0x01,
3827c478bd9Sstevel@tonic-gate 	OB_PKT = 0x02
3837c478bd9Sstevel@tonic-gate } ip_pkt_t;
3847c478bd9Sstevel@tonic-gate 
3857c478bd9Sstevel@tonic-gate #define	UPDATE_IB_PKT_COUNT(ire)\
3867c478bd9Sstevel@tonic-gate 	{ \
3877c478bd9Sstevel@tonic-gate 	(ire)->ire_ib_pkt_count++; \
3887c478bd9Sstevel@tonic-gate 	if ((ire)->ire_ipif != NULL) { \
3897c478bd9Sstevel@tonic-gate 		/* \
3907c478bd9Sstevel@tonic-gate 		 * forwarding packet \
3917c478bd9Sstevel@tonic-gate 		 */ \
3927c478bd9Sstevel@tonic-gate 		if ((ire)->ire_type & (IRE_LOCAL|IRE_BROADCAST)) \
3937c478bd9Sstevel@tonic-gate 			atomic_add_32(&(ire)->ire_ipif->ipif_ib_pkt_count, 1);\
3947c478bd9Sstevel@tonic-gate 		else \
3957c478bd9Sstevel@tonic-gate 			atomic_add_32(&(ire)->ire_ipif->ipif_fo_pkt_count, 1);\
3967c478bd9Sstevel@tonic-gate 	} \
3977c478bd9Sstevel@tonic-gate 	}
3987c478bd9Sstevel@tonic-gate #define	UPDATE_OB_PKT_COUNT(ire)\
3997c478bd9Sstevel@tonic-gate 	{ \
4007c478bd9Sstevel@tonic-gate 	(ire)->ire_ob_pkt_count++;\
4017c478bd9Sstevel@tonic-gate 	if ((ire)->ire_ipif != NULL) { \
4027c478bd9Sstevel@tonic-gate 		atomic_add_32(&(ire)->ire_ipif->ipif_ob_pkt_count, 1); \
4037c478bd9Sstevel@tonic-gate 	} \
4047c478bd9Sstevel@tonic-gate 	}
4057c478bd9Sstevel@tonic-gate 
4067c478bd9Sstevel@tonic-gate 
4077c478bd9Sstevel@tonic-gate #define	IP_RPUT_LOCAL(q, mp, ipha, ire, recv_ill) \
4087c478bd9Sstevel@tonic-gate { \
4097c478bd9Sstevel@tonic-gate 	switch (ipha->ipha_protocol) { \
4107c478bd9Sstevel@tonic-gate 		case IPPROTO_UDP: \
4117c478bd9Sstevel@tonic-gate 			ip_udp_input(q, mp, ipha, ire, recv_ill); \
4127c478bd9Sstevel@tonic-gate 			break; \
4137c478bd9Sstevel@tonic-gate 		default: \
4147c478bd9Sstevel@tonic-gate 			ip_proto_input(q, mp, ipha, ire, recv_ill); \
4157c478bd9Sstevel@tonic-gate 			break; \
4167c478bd9Sstevel@tonic-gate 	} \
4177c478bd9Sstevel@tonic-gate }
4187c478bd9Sstevel@tonic-gate 
4197c478bd9Sstevel@tonic-gate 
4207c478bd9Sstevel@tonic-gate #endif /* _KERNEL */
4217c478bd9Sstevel@tonic-gate 
4227c478bd9Sstevel@tonic-gate /* ICMP types */
4237c478bd9Sstevel@tonic-gate #define	ICMP_ECHO_REPLY			0
4247c478bd9Sstevel@tonic-gate #define	ICMP_DEST_UNREACHABLE		3
4257c478bd9Sstevel@tonic-gate #define	ICMP_SOURCE_QUENCH		4
4267c478bd9Sstevel@tonic-gate #define	ICMP_REDIRECT			5
4277c478bd9Sstevel@tonic-gate #define	ICMP_ECHO_REQUEST		8
4287c478bd9Sstevel@tonic-gate #define	ICMP_ROUTER_ADVERTISEMENT	9
4297c478bd9Sstevel@tonic-gate #define	ICMP_ROUTER_SOLICITATION	10
4307c478bd9Sstevel@tonic-gate #define	ICMP_TIME_EXCEEDED		11
4317c478bd9Sstevel@tonic-gate #define	ICMP_PARAM_PROBLEM		12
4327c478bd9Sstevel@tonic-gate #define	ICMP_TIME_STAMP_REQUEST		13
4337c478bd9Sstevel@tonic-gate #define	ICMP_TIME_STAMP_REPLY		14
4347c478bd9Sstevel@tonic-gate #define	ICMP_INFO_REQUEST		15
4357c478bd9Sstevel@tonic-gate #define	ICMP_INFO_REPLY			16
4367c478bd9Sstevel@tonic-gate #define	ICMP_ADDRESS_MASK_REQUEST	17
4377c478bd9Sstevel@tonic-gate #define	ICMP_ADDRESS_MASK_REPLY		18
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate /* ICMP_TIME_EXCEEDED codes */
4407c478bd9Sstevel@tonic-gate #define	ICMP_TTL_EXCEEDED		0
4417c478bd9Sstevel@tonic-gate #define	ICMP_REASSEMBLY_TIME_EXCEEDED	1
4427c478bd9Sstevel@tonic-gate 
4437c478bd9Sstevel@tonic-gate /* ICMP_DEST_UNREACHABLE codes */
4447c478bd9Sstevel@tonic-gate #define	ICMP_NET_UNREACHABLE		0
4457c478bd9Sstevel@tonic-gate #define	ICMP_HOST_UNREACHABLE		1
4467c478bd9Sstevel@tonic-gate #define	ICMP_PROTOCOL_UNREACHABLE	2
4477c478bd9Sstevel@tonic-gate #define	ICMP_PORT_UNREACHABLE		3
4487c478bd9Sstevel@tonic-gate #define	ICMP_FRAGMENTATION_NEEDED	4
4497c478bd9Sstevel@tonic-gate #define	ICMP_SOURCE_ROUTE_FAILED	5
4507c478bd9Sstevel@tonic-gate #define	ICMP_DEST_NET_UNKNOWN		6
4517c478bd9Sstevel@tonic-gate #define	ICMP_DEST_HOST_UNKNOWN		7
4527c478bd9Sstevel@tonic-gate #define	ICMP_SRC_HOST_ISOLATED		8
4537c478bd9Sstevel@tonic-gate #define	ICMP_DEST_NET_UNREACH_ADMIN	9
4547c478bd9Sstevel@tonic-gate #define	ICMP_DEST_HOST_UNREACH_ADMIN	10
4557c478bd9Sstevel@tonic-gate #define	ICMP_DEST_NET_UNREACH_TOS	11
4567c478bd9Sstevel@tonic-gate #define	ICMP_DEST_HOST_UNREACH_TOS	12
4577c478bd9Sstevel@tonic-gate 
4587c478bd9Sstevel@tonic-gate /* ICMP Header Structure */
4597c478bd9Sstevel@tonic-gate typedef struct icmph_s {
4607c478bd9Sstevel@tonic-gate 	uint8_t		icmph_type;
4617c478bd9Sstevel@tonic-gate 	uint8_t		icmph_code;
4627c478bd9Sstevel@tonic-gate 	uint16_t	icmph_checksum;
4637c478bd9Sstevel@tonic-gate 	union {
4647c478bd9Sstevel@tonic-gate 		struct { /* ECHO request/response structure */
4657c478bd9Sstevel@tonic-gate 			uint16_t	u_echo_ident;
4667c478bd9Sstevel@tonic-gate 			uint16_t	u_echo_seqnum;
4677c478bd9Sstevel@tonic-gate 		} u_echo;
4687c478bd9Sstevel@tonic-gate 		struct { /* Destination unreachable structure */
4697c478bd9Sstevel@tonic-gate 			uint16_t	u_du_zero;
4707c478bd9Sstevel@tonic-gate 			uint16_t	u_du_mtu;
4717c478bd9Sstevel@tonic-gate 		} u_du;
4727c478bd9Sstevel@tonic-gate 		struct { /* Parameter problem structure */
4737c478bd9Sstevel@tonic-gate 			uint8_t		u_pp_ptr;
4747c478bd9Sstevel@tonic-gate 			uint8_t		u_pp_rsvd[3];
4757c478bd9Sstevel@tonic-gate 		} u_pp;
4767c478bd9Sstevel@tonic-gate 		struct { /* Redirect structure */
4777c478bd9Sstevel@tonic-gate 			ipaddr_t	u_rd_gateway;
4787c478bd9Sstevel@tonic-gate 		} u_rd;
4797c478bd9Sstevel@tonic-gate 	} icmph_u;
4807c478bd9Sstevel@tonic-gate } icmph_t;
4817c478bd9Sstevel@tonic-gate 
4827c478bd9Sstevel@tonic-gate #define	icmph_echo_ident	icmph_u.u_echo.u_echo_ident
4837c478bd9Sstevel@tonic-gate #define	icmph_echo_seqnum	icmph_u.u_echo.u_echo_seqnum
4847c478bd9Sstevel@tonic-gate #define	icmph_du_zero		icmph_u.u_du.u_du_zero
4857c478bd9Sstevel@tonic-gate #define	icmph_du_mtu		icmph_u.u_du.u_du_mtu
4867c478bd9Sstevel@tonic-gate #define	icmph_pp_ptr		icmph_u.u_pp.u_pp_ptr
4877c478bd9Sstevel@tonic-gate #define	icmph_rd_gateway	icmph_u.u_rd.u_rd_gateway
4887c478bd9Sstevel@tonic-gate 
4897c478bd9Sstevel@tonic-gate #define	ICMPH_SIZE	8
4907c478bd9Sstevel@tonic-gate 
4917c478bd9Sstevel@tonic-gate /*
4927c478bd9Sstevel@tonic-gate  * Minimum length of transport layer header included in an ICMP error
4937c478bd9Sstevel@tonic-gate  * message for it to be considered valid.
4947c478bd9Sstevel@tonic-gate  */
4957c478bd9Sstevel@tonic-gate #define	ICMP_MIN_TP_HDR_LEN	8
4967c478bd9Sstevel@tonic-gate 
4977c478bd9Sstevel@tonic-gate /* Aligned IP header */
4987c478bd9Sstevel@tonic-gate typedef struct ipha_s {
4997c478bd9Sstevel@tonic-gate 	uint8_t		ipha_version_and_hdr_length;
5007c478bd9Sstevel@tonic-gate 	uint8_t		ipha_type_of_service;
5017c478bd9Sstevel@tonic-gate 	uint16_t	ipha_length;
5027c478bd9Sstevel@tonic-gate 	uint16_t	ipha_ident;
5037c478bd9Sstevel@tonic-gate 	uint16_t	ipha_fragment_offset_and_flags;
5047c478bd9Sstevel@tonic-gate 	uint8_t		ipha_ttl;
5057c478bd9Sstevel@tonic-gate 	uint8_t		ipha_protocol;
5067c478bd9Sstevel@tonic-gate 	uint16_t	ipha_hdr_checksum;
5077c478bd9Sstevel@tonic-gate 	ipaddr_t	ipha_src;
5087c478bd9Sstevel@tonic-gate 	ipaddr_t	ipha_dst;
5097c478bd9Sstevel@tonic-gate } ipha_t;
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate #define	IPH_DF		0x4000	/* Don't fragment */
5127c478bd9Sstevel@tonic-gate #define	IPH_MF		0x2000	/* More fragments to come */
5137c478bd9Sstevel@tonic-gate #define	IPH_OFFSET	0x1FFF	/* Where the offset lives */
5147c478bd9Sstevel@tonic-gate #define	IPH_FRAG_HDR	0x8000	/* IPv6 don't fragment bit */
5157c478bd9Sstevel@tonic-gate 
5167c478bd9Sstevel@tonic-gate /* ECN code points for IPv4 TOS byte and IPv6 traffic class octet. */
5177c478bd9Sstevel@tonic-gate #define	IPH_ECN_NECT	0x0	/* Not ECN-Capabable Transport */
5187c478bd9Sstevel@tonic-gate #define	IPH_ECN_ECT1	0x1	/* ECN-Capable Transport, ECT(1) */
5197c478bd9Sstevel@tonic-gate #define	IPH_ECN_ECT0	0x2	/* ECN-Capable Transport, ECT(0) */
5207c478bd9Sstevel@tonic-gate #define	IPH_ECN_CE	0x3	/* ECN-Congestion Experienced (CE) */
5217c478bd9Sstevel@tonic-gate 
5227c478bd9Sstevel@tonic-gate /* IP Mac info structure */
5237c478bd9Sstevel@tonic-gate typedef struct ip_m_s {
5247c478bd9Sstevel@tonic-gate 	t_uscalar_t	ip_m_mac_type;	/* From <sys/dlpi.h> */
5257c478bd9Sstevel@tonic-gate 	int		ip_m_type;	/* From <net/if_types.h> */
5267c478bd9Sstevel@tonic-gate 	boolean_t	(*ip_m_v4mapinfo)(uint_t, uint8_t *, uint8_t *,
5277c478bd9Sstevel@tonic-gate 			    uint32_t *, ipaddr_t *);
5287c478bd9Sstevel@tonic-gate 	boolean_t	(*ip_m_v6mapinfo)(uint_t, uint8_t *, uint8_t *,
5297c478bd9Sstevel@tonic-gate 			    uint32_t *, in6_addr_t *);
5307c478bd9Sstevel@tonic-gate 	boolean_t	(*ip_m_v6intfid)(uint_t, uint8_t *, in6_addr_t *);
5317c478bd9Sstevel@tonic-gate } ip_m_t;
5327c478bd9Sstevel@tonic-gate 
5337c478bd9Sstevel@tonic-gate /*
5347c478bd9Sstevel@tonic-gate  * The following functions attempt to reduce the link layer dependency
5357c478bd9Sstevel@tonic-gate  * of the IP stack. The current set of link specific operations are:
5367c478bd9Sstevel@tonic-gate  * a. map from IPv4 class D (224.0/4) multicast address range to the link
5377c478bd9Sstevel@tonic-gate  * layer multicast address range.
5387c478bd9Sstevel@tonic-gate  * b. map from IPv6 multicast address range (ff00::/8) to the link
5397c478bd9Sstevel@tonic-gate  * layer multicast address range.
5407c478bd9Sstevel@tonic-gate  * c. derive the default IPv6 interface identifier from the link layer
5417c478bd9Sstevel@tonic-gate  * address.
5427c478bd9Sstevel@tonic-gate  */
5437c478bd9Sstevel@tonic-gate #define	MEDIA_V4MINFO(ip_m, plen, bphys, maddr, hwxp, v4ptr) \
5447c478bd9Sstevel@tonic-gate 	(((ip_m)->ip_m_v4mapinfo != NULL) && \
5457c478bd9Sstevel@tonic-gate 	(*(ip_m)->ip_m_v4mapinfo)(plen, bphys, maddr, hwxp, v4ptr))
5467c478bd9Sstevel@tonic-gate #define	MEDIA_V6INTFID(ip_m, plen, phys, v6ptr) \
5477c478bd9Sstevel@tonic-gate 	(((ip_m)->ip_m_v6intfid != NULL) && \
5487c478bd9Sstevel@tonic-gate 	(*(ip_m)->ip_m_v6intfid)(plen, phys, v6ptr))
5497c478bd9Sstevel@tonic-gate #define	MEDIA_V6MINFO(ip_m, plen, bphys, maddr, hwxp, v6ptr) \
5507c478bd9Sstevel@tonic-gate 	(((ip_m)->ip_m_v6mapinfo != NULL) && \
5517c478bd9Sstevel@tonic-gate 	(*(ip_m)->ip_m_v6mapinfo)(plen, bphys, maddr, hwxp, v6ptr))
5527c478bd9Sstevel@tonic-gate 
5537c478bd9Sstevel@tonic-gate /* Router entry types */
5547c478bd9Sstevel@tonic-gate #define	IRE_BROADCAST		0x0001	/* Route entry for broadcast address */
5557c478bd9Sstevel@tonic-gate #define	IRE_DEFAULT		0x0002	/* Route entry for default gateway */
5567c478bd9Sstevel@tonic-gate #define	IRE_LOCAL		0x0004	/* Route entry for local address */
5577c478bd9Sstevel@tonic-gate #define	IRE_LOOPBACK		0x0008	/* Route entry for loopback address */
5587c478bd9Sstevel@tonic-gate #define	IRE_PREFIX		0x0010	/* Route entry for prefix routes */
5597c478bd9Sstevel@tonic-gate #define	IRE_CACHE		0x0020	/* Cached Route entry */
5607c478bd9Sstevel@tonic-gate #define	IRE_IF_NORESOLVER	0x0040	/* Route entry for local interface */
5617c478bd9Sstevel@tonic-gate 					/* net without any address mapping. */
5627c478bd9Sstevel@tonic-gate #define	IRE_IF_RESOLVER		0x0080	/* Route entry for local interface */
5637c478bd9Sstevel@tonic-gate 					/* net with resolver. */
5647c478bd9Sstevel@tonic-gate #define	IRE_HOST		0x0100	/* Host route entry */
5657c478bd9Sstevel@tonic-gate #define	IRE_HOST_REDIRECT	0x0200	/* Host route entry from redirects */
5667c478bd9Sstevel@tonic-gate 
5677c478bd9Sstevel@tonic-gate /*
5687c478bd9Sstevel@tonic-gate  * IRE_MIPRTUN is only set on the ires in the ip_mrtun_table.
5697c478bd9Sstevel@tonic-gate  * This ire_type must not be set for ftable and ctable routing entries.
5707c478bd9Sstevel@tonic-gate  */
5717c478bd9Sstevel@tonic-gate #define	IRE_MIPRTUN		0x0400	/* Reverse tunnel route entry */
5727c478bd9Sstevel@tonic-gate 
5737c478bd9Sstevel@tonic-gate #define	IRE_INTERFACE		(IRE_IF_NORESOLVER | IRE_IF_RESOLVER)
5747c478bd9Sstevel@tonic-gate #define	IRE_OFFSUBNET		(IRE_DEFAULT | IRE_PREFIX | IRE_HOST | \
5757c478bd9Sstevel@tonic-gate 				IRE_HOST_REDIRECT)
5767c478bd9Sstevel@tonic-gate #define	IRE_CACHETABLE		(IRE_CACHE | IRE_BROADCAST | IRE_LOCAL | \
5777c478bd9Sstevel@tonic-gate 				IRE_LOOPBACK)
5787c478bd9Sstevel@tonic-gate #define	IRE_FORWARDTABLE	(IRE_INTERFACE | IRE_OFFSUBNET)
5797c478bd9Sstevel@tonic-gate 
5807c478bd9Sstevel@tonic-gate /*
5817c478bd9Sstevel@tonic-gate  * If an IRE is marked with IRE_MARK_CONDEMNED, the last walker of
5827c478bd9Sstevel@tonic-gate  * the bucket should delete this IRE from this bucket.
5837c478bd9Sstevel@tonic-gate  */
5847c478bd9Sstevel@tonic-gate #define	IRE_MARK_CONDEMNED	0x0001
5857c478bd9Sstevel@tonic-gate /*
5867c478bd9Sstevel@tonic-gate  * If a broadcast IRE is marked with IRE_MARK_NORECV, ip_rput will drop the
5877c478bd9Sstevel@tonic-gate  * broadcast packets received on that interface. This is marked only
5887c478bd9Sstevel@tonic-gate  * on broadcast ires. Employed by IPMP, where we have multiple NICs on the
5897c478bd9Sstevel@tonic-gate  * same subnet receiving the same broadcast packet.
5907c478bd9Sstevel@tonic-gate  */
5917c478bd9Sstevel@tonic-gate #define	IRE_MARK_NORECV		0x0002
5927c478bd9Sstevel@tonic-gate /*
5937c478bd9Sstevel@tonic-gate  * IRE_CACHE marked this way won't be returned by ire_cache_lookup. Need
5947c478bd9Sstevel@tonic-gate  * to look specifically using MATCH_IRE_MARK_HIDDEN. Used by IPMP.
5957c478bd9Sstevel@tonic-gate  */
5967c478bd9Sstevel@tonic-gate #define	IRE_MARK_HIDDEN		0x0004	/* Typically Used by in.mpathd */
5977c478bd9Sstevel@tonic-gate 
5987c478bd9Sstevel@tonic-gate /*
5997c478bd9Sstevel@tonic-gate  * ire with IRE_MARK_NOADD is  created in ip_newroute_ipif, when outgoing
6007c478bd9Sstevel@tonic-gate  * interface is specified by IP_XMIT_IF socket option. This ire is not
6017c478bd9Sstevel@tonic-gate  * added in IRE_CACHE.  For example, this is used by mipagent to prevent
6027c478bd9Sstevel@tonic-gate  * any entry to be added in the cache table. We do not want to add any
6037c478bd9Sstevel@tonic-gate  * entry for a mobile-node in the routing table for foreign agent originated
6047c478bd9Sstevel@tonic-gate  * packets. Adding routes in cache table in this case, may run the risks of
6057c478bd9Sstevel@tonic-gate  * incorrect routing path in case of private overlapping addresses.
6067c478bd9Sstevel@tonic-gate  */
6077c478bd9Sstevel@tonic-gate #define	IRE_MARK_NOADD		0x0008	/* Mark not to add ire in cache */
6087c478bd9Sstevel@tonic-gate 
6097c478bd9Sstevel@tonic-gate /*
6107c478bd9Sstevel@tonic-gate  * IRE marked with IRE_MARK_TEMPORARY means that this IRE has been used
6117c478bd9Sstevel@tonic-gate  * either for forwarding a packet or has not been used for sending
6127c478bd9Sstevel@tonic-gate  * traffic on TCP connections terminated on this system.  In both
6137c478bd9Sstevel@tonic-gate  * cases, this IRE is the first to go when IRE is being cleaned up.
6147c478bd9Sstevel@tonic-gate  */
6157c478bd9Sstevel@tonic-gate #define	IRE_MARK_TEMPORARY	0x0010
6167c478bd9Sstevel@tonic-gate 
6177c478bd9Sstevel@tonic-gate /*
6187c478bd9Sstevel@tonic-gate  * IRE marked with IRE_MARK_USESRC_CHECK means that while adding an IRE with
6197c478bd9Sstevel@tonic-gate  * this mark, additional atomic checks need to be performed. For eg: by the
6207c478bd9Sstevel@tonic-gate  * time an IRE_CACHE is created, sent up to ARP and then comes back to IP; the
6217c478bd9Sstevel@tonic-gate  * usesrc grouping could have changed in which case we want to fail adding
6227c478bd9Sstevel@tonic-gate  * the IRE_CACHE entry
6237c478bd9Sstevel@tonic-gate  */
6247c478bd9Sstevel@tonic-gate #define	IRE_MARK_USESRC_CHECK	0x0020
6257c478bd9Sstevel@tonic-gate 
62643d18f1cSpriyanka /*
62743d18f1cSpriyanka  * IRE_MARK_PRIVATE_ADDR is used for IP_NEXTHOP. When IP_NEXTHOP is set, the
62843d18f1cSpriyanka  * routing table lookup for the destination is bypassed and the packet is
62943d18f1cSpriyanka  * sent directly to the specified nexthop. The associated IRE_CACHE entries
63043d18f1cSpriyanka  * should be marked with IRE_MARK_PRIVATE_ADDR flag so that they don't show up
63143d18f1cSpriyanka  * in regular ire cache lookups.
63243d18f1cSpriyanka  */
63343d18f1cSpriyanka #define	IRE_MARK_PRIVATE_ADDR	0x0040
63443d18f1cSpriyanka 
6357c478bd9Sstevel@tonic-gate /* Flags with ire_expire routine */
6367c478bd9Sstevel@tonic-gate #define	FLUSH_ARP_TIME		0x0001	/* ARP info potentially stale timer */
6377c478bd9Sstevel@tonic-gate #define	FLUSH_REDIRECT_TIME	0x0002	/* Redirects potentially stale */
6387c478bd9Sstevel@tonic-gate #define	FLUSH_MTU_TIME		0x0004	/* Include path MTU per RFC 1191 */
6397c478bd9Sstevel@tonic-gate 
6407c478bd9Sstevel@tonic-gate /* Arguments to ire_flush_cache() */
6417c478bd9Sstevel@tonic-gate #define	IRE_FLUSH_DELETE	0
6427c478bd9Sstevel@tonic-gate #define	IRE_FLUSH_ADD		1
6437c478bd9Sstevel@tonic-gate 
6447c478bd9Sstevel@tonic-gate /*
6457c478bd9Sstevel@tonic-gate  * Open/close synchronization flags.
6467c478bd9Sstevel@tonic-gate  * These are kept in a separate field in the conn and the synchronization
6477c478bd9Sstevel@tonic-gate  * depends on the atomic 32 bit access to that field.
6487c478bd9Sstevel@tonic-gate  */
6497c478bd9Sstevel@tonic-gate #define	CONN_CLOSING		0x01	/* ip_close waiting for ip_wsrv */
650ff550d0eSmasputra #define	CONN_IPSEC_LOAD_WAIT	0x02	/* waiting for load */
651ff550d0eSmasputra #define	CONN_CONDEMNED		0x04	/* conn is closing, no more refs */
652ff550d0eSmasputra #define	CONN_INCIPIENT		0x08	/* conn not yet visible, no refs */
653ff550d0eSmasputra #define	CONN_QUIESCED		0x10	/* conn is now quiescent */
6547c478bd9Sstevel@tonic-gate 
6557c478bd9Sstevel@tonic-gate /*
6567c478bd9Sstevel@tonic-gate  * Parameter to ip_output giving the identity of the caller.
6577c478bd9Sstevel@tonic-gate  * IP_WSRV means the packet was enqueued in the STREAMS queue
6587c478bd9Sstevel@tonic-gate  * due to flow control and is now being reprocessed in the context of
6597c478bd9Sstevel@tonic-gate  * the STREAMS service procedure, consequent to flow control relief.
6607c478bd9Sstevel@tonic-gate  * IRE_SEND means the packet is being reprocessed consequent to an
6617c478bd9Sstevel@tonic-gate  * ire cache creation and addition and this may or may not be happening
6627c478bd9Sstevel@tonic-gate  * in the service procedure context. Anything other than the above 2
6637c478bd9Sstevel@tonic-gate  * cases is identified as IP_WPUT. Most commonly this is the case of
6647c478bd9Sstevel@tonic-gate  * packets coming down from the application.
6657c478bd9Sstevel@tonic-gate  */
6667c478bd9Sstevel@tonic-gate #ifdef _KERNEL
6677c478bd9Sstevel@tonic-gate #define	IP_WSRV			1	/* Called from ip_wsrv */
6687c478bd9Sstevel@tonic-gate #define	IP_WPUT			2	/* Called from ip_wput */
6697c478bd9Sstevel@tonic-gate #define	IRE_SEND		3	/* Called from ire_send */
6707c478bd9Sstevel@tonic-gate 
6717c478bd9Sstevel@tonic-gate /*
6727c478bd9Sstevel@tonic-gate  * Extra structures need for per-src-addr filtering (IGMPv3/MLDv2)
6737c478bd9Sstevel@tonic-gate  */
6747c478bd9Sstevel@tonic-gate #define	MAX_FILTER_SIZE	64
6757c478bd9Sstevel@tonic-gate 
6767c478bd9Sstevel@tonic-gate typedef struct slist_s {
6777c478bd9Sstevel@tonic-gate 	int		sl_numsrc;
6787c478bd9Sstevel@tonic-gate 	in6_addr_t	sl_addr[MAX_FILTER_SIZE];
6797c478bd9Sstevel@tonic-gate } slist_t;
6807c478bd9Sstevel@tonic-gate 
6817c478bd9Sstevel@tonic-gate /*
6827c478bd9Sstevel@tonic-gate  * Following struct is used to maintain retransmission state for
6837c478bd9Sstevel@tonic-gate  * a multicast group.  One rtx_state_t struct is an in-line field
6847c478bd9Sstevel@tonic-gate  * of the ilm_t struct; the slist_ts in the rtx_state_t struct are
6857c478bd9Sstevel@tonic-gate  * alloc'd as needed.
6867c478bd9Sstevel@tonic-gate  */
6877c478bd9Sstevel@tonic-gate typedef struct rtx_state_s {
6887c478bd9Sstevel@tonic-gate 	uint_t		rtx_timer;	/* retrans timer */
6897c478bd9Sstevel@tonic-gate 	int		rtx_cnt;	/* retrans count */
6907c478bd9Sstevel@tonic-gate 	int		rtx_fmode_cnt;	/* retrans count for fmode change */
6917c478bd9Sstevel@tonic-gate 	slist_t		*rtx_allow;
6927c478bd9Sstevel@tonic-gate 	slist_t		*rtx_block;
6937c478bd9Sstevel@tonic-gate } rtx_state_t;
6947c478bd9Sstevel@tonic-gate 
6957c478bd9Sstevel@tonic-gate /*
6967c478bd9Sstevel@tonic-gate  * Used to construct list of multicast address records that will be
6977c478bd9Sstevel@tonic-gate  * sent in a single listener report.
6987c478bd9Sstevel@tonic-gate  */
6997c478bd9Sstevel@tonic-gate typedef struct mrec_s {
7007c478bd9Sstevel@tonic-gate 	struct mrec_s	*mrec_next;
7017c478bd9Sstevel@tonic-gate 	uint8_t		mrec_type;
7027c478bd9Sstevel@tonic-gate 	uint8_t		mrec_auxlen;	/* currently unused */
7037c478bd9Sstevel@tonic-gate 	in6_addr_t	mrec_group;
7047c478bd9Sstevel@tonic-gate 	slist_t		mrec_srcs;
7057c478bd9Sstevel@tonic-gate } mrec_t;
7067c478bd9Sstevel@tonic-gate 
7077c478bd9Sstevel@tonic-gate /* Group membership list per upper conn */
7087c478bd9Sstevel@tonic-gate /*
7097c478bd9Sstevel@tonic-gate  * XXX add ilg info for ifaddr/ifindex.
7107c478bd9Sstevel@tonic-gate  * XXX can we make ilg survive an ifconfig unplumb + plumb
7117c478bd9Sstevel@tonic-gate  * by setting the ipif/ill to NULL and recover that later?
7127c478bd9Sstevel@tonic-gate  *
7137c478bd9Sstevel@tonic-gate  * ilg_ipif is used by IPv4 as multicast groups are joined using an interface
7147c478bd9Sstevel@tonic-gate  * address (ipif).
7157c478bd9Sstevel@tonic-gate  * ilg_ill is used by IPv6 as multicast groups are joined using an interface
7167c478bd9Sstevel@tonic-gate  * index (phyint->phyint_ifindex).
7177c478bd9Sstevel@tonic-gate  * ilg_ill is NULL for IPv4 and ilg_ipif is NULL for IPv6.
7187c478bd9Sstevel@tonic-gate  *
7197c478bd9Sstevel@tonic-gate  * ilg records the state of multicast memberships of a socket end point.
7207c478bd9Sstevel@tonic-gate  * ilm records the state of multicast memberships with the driver and is
7217c478bd9Sstevel@tonic-gate  * maintained per interface.
7227c478bd9Sstevel@tonic-gate  *
7237c478bd9Sstevel@tonic-gate  * Notes :
7247c478bd9Sstevel@tonic-gate  *
7257c478bd9Sstevel@tonic-gate  * 1) There is no direct link between a given ilg and ilm. If the
7267c478bd9Sstevel@tonic-gate  *    application has joined a group G with ifindex I, we will have
7277c478bd9Sstevel@tonic-gate  *    an ilg with ilg_v6group and ilg_ill. There will be a corresponding
7287c478bd9Sstevel@tonic-gate  *    ilm with ilm_ill/ilm_v6addr recording the multicast membership.
7297c478bd9Sstevel@tonic-gate  *    To delete the membership,
7307c478bd9Sstevel@tonic-gate  *
7317c478bd9Sstevel@tonic-gate  *		a) Search for ilg matching on G and I with ilg_v6group
7327c478bd9Sstevel@tonic-gate  *		   and ilg_ill. Delete ilg_ill.
7337c478bd9Sstevel@tonic-gate  *		b) Search the corresponding ilm matching on G and I with
7347c478bd9Sstevel@tonic-gate  *		   ilm_v6addr and ilm_ill. Delete ilm.
7357c478bd9Sstevel@tonic-gate  *
7367c478bd9Sstevel@tonic-gate  *    In IPv4, the only difference is, we look using ipifs instead of
7377c478bd9Sstevel@tonic-gate  *    ills.
7387c478bd9Sstevel@tonic-gate  *
7397c478bd9Sstevel@tonic-gate  * 2) With IP multipathing, we want to keep receiving even after the
7407c478bd9Sstevel@tonic-gate  *    interface has failed. We do this by moving multicast memberships
7417c478bd9Sstevel@tonic-gate  *    to a new_ill within the group. This is acheived by sending
7427c478bd9Sstevel@tonic-gate  *    DL_DISABMULTI_REQS on ilg_ill/ilm_ill and sending DL_ENABMULTIREQS
7437c478bd9Sstevel@tonic-gate  *    on the new_ill and changing ilg_ill/ilm_ill to new_ill. But, we
7447c478bd9Sstevel@tonic-gate  *    need to be able to delete memberships which will still come down
7457c478bd9Sstevel@tonic-gate  *    with the ifindex of the old ill which is what the application
7467c478bd9Sstevel@tonic-gate  *    knows of. Thus we store the ilm_/ilg_orig_ifindex to keep track
7477c478bd9Sstevel@tonic-gate  *    of where we joined initially so that we can lookup even after we
7487c478bd9Sstevel@tonic-gate  *    moved the membership. It is also used for moving back the membership
7497c478bd9Sstevel@tonic-gate  *    when the old ill has been repaired. This is done by looking up for
7507c478bd9Sstevel@tonic-gate  *    ilms with ilm_orig_ifindex matching on the old ill's ifindex. Only
7517c478bd9Sstevel@tonic-gate  *    ilms actually move from old ill to new ill. ilgs don't move (just
7527c478bd9Sstevel@tonic-gate  *    the ilg_ill is changed when it moves) as it just records the state
7537c478bd9Sstevel@tonic-gate  *    of the application that has joined a group G where as ilm records
7547c478bd9Sstevel@tonic-gate  *    the state joined with the driver. Thus when we send DL_XXXMULTI_REQs
7557c478bd9Sstevel@tonic-gate  *    we also need to keep the ilm in the right ill.
7567c478bd9Sstevel@tonic-gate  *
7577c478bd9Sstevel@tonic-gate  *    In IPv4, as ipifs move from old ill to new_ill, ilgs and ilms move
7587c478bd9Sstevel@tonic-gate  *    implicitly as we use only ipifs in IPv4. Thus, one can always lookup
7597c478bd9Sstevel@tonic-gate  *    a given ilm/ilg even after it fails without the support of
7607c478bd9Sstevel@tonic-gate  *    orig_ifindex. We move ilms still to record the driver state as
7617c478bd9Sstevel@tonic-gate  *    mentioned above.
7627c478bd9Sstevel@tonic-gate  */
7637c478bd9Sstevel@tonic-gate 
7647c478bd9Sstevel@tonic-gate /*
7657c478bd9Sstevel@tonic-gate  * The ilg_t and ilm_t members are protected by ipsq. They can be changed only
7667c478bd9Sstevel@tonic-gate  * by a thread executing in the ipsq. In other words add/delete of a
7677c478bd9Sstevel@tonic-gate  * multicast group has to execute in the ipsq.
7687c478bd9Sstevel@tonic-gate  */
7697c478bd9Sstevel@tonic-gate #define	ILG_DELETED	0x1		/* ilg_flags */
7707c478bd9Sstevel@tonic-gate typedef struct ilg_s {
7717c478bd9Sstevel@tonic-gate 	in6_addr_t	ilg_v6group;
7727c478bd9Sstevel@tonic-gate 	struct ipif_s	*ilg_ipif;	/* Logical interface we are member on */
7737c478bd9Sstevel@tonic-gate 	struct ill_s	*ilg_ill;	/* Used by IPv6 */
7747c478bd9Sstevel@tonic-gate 	int		ilg_orig_ifindex; /* Interface originally joined on */
7757c478bd9Sstevel@tonic-gate 	uint_t		ilg_flags;
7767c478bd9Sstevel@tonic-gate 	mcast_record_t	ilg_fmode;	/* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */
7777c478bd9Sstevel@tonic-gate 	slist_t		*ilg_filter;
7787c478bd9Sstevel@tonic-gate } ilg_t;
7797c478bd9Sstevel@tonic-gate 
7807c478bd9Sstevel@tonic-gate 
7817c478bd9Sstevel@tonic-gate /*
7827c478bd9Sstevel@tonic-gate  * Multicast address list entry for lower ill.
7837c478bd9Sstevel@tonic-gate  * ilm_ipif is used by IPv4 as multicast groups are joined using ipif.
7847c478bd9Sstevel@tonic-gate  * ilm_ill is used by IPv6 as multicast groups are joined using ill.
7857c478bd9Sstevel@tonic-gate  * ilm_ill is NULL for IPv4 and ilm_ipif is NULL for IPv6.
7867c478bd9Sstevel@tonic-gate  */
7877c478bd9Sstevel@tonic-gate #define	ILM_DELETED	0x1		/* ilm_flags */
7887c478bd9Sstevel@tonic-gate typedef struct ilm_s {
7897c478bd9Sstevel@tonic-gate 	in6_addr_t	ilm_v6addr;
7907c478bd9Sstevel@tonic-gate 	int		ilm_refcnt;
7917c478bd9Sstevel@tonic-gate 	uint_t		ilm_timer;	/* IGMP/MLD query resp timer, in msec */
7927c478bd9Sstevel@tonic-gate 	struct ipif_s	*ilm_ipif;	/* Back pointer to ipif for IPv4 */
7937c478bd9Sstevel@tonic-gate 	struct ilm_s	*ilm_next;	/* Linked list for each ill */
7947c478bd9Sstevel@tonic-gate 	uint_t		ilm_state;	/* state of the membership */
7957c478bd9Sstevel@tonic-gate 	struct ill_s	*ilm_ill;	/* Back pointer to ill for IPv6 */
7967c478bd9Sstevel@tonic-gate 	int		ilm_orig_ifindex;  /* V6_MULTICAST_IF/ilm_ipif index */
7977c478bd9Sstevel@tonic-gate 	uint_t		ilm_flags;
7987c478bd9Sstevel@tonic-gate 	boolean_t	ilm_is_new;	/* new ilm */
7997c478bd9Sstevel@tonic-gate 	boolean_t	ilm_notify_driver; /* Need to notify the driver */
8007c478bd9Sstevel@tonic-gate 	zoneid_t	ilm_zoneid;
8017c478bd9Sstevel@tonic-gate 	int		ilm_no_ilg_cnt;	/* number of joins w/ no ilg */
8027c478bd9Sstevel@tonic-gate 	mcast_record_t	ilm_fmode;	/* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */
8037c478bd9Sstevel@tonic-gate 	slist_t		*ilm_filter;	/* source filter list */
8047c478bd9Sstevel@tonic-gate 	slist_t		*ilm_pendsrcs;	/* relevant src addrs for pending req */
8057c478bd9Sstevel@tonic-gate 	rtx_state_t	ilm_rtx;	/* SCR retransmission state */
8067c478bd9Sstevel@tonic-gate } ilm_t;
8077c478bd9Sstevel@tonic-gate 
8087c478bd9Sstevel@tonic-gate #define	ilm_addr	V4_PART_OF_V6(ilm_v6addr)
8097c478bd9Sstevel@tonic-gate 
8107c478bd9Sstevel@tonic-gate /*
8117c478bd9Sstevel@tonic-gate  * ilm_walker_cleanup needs to execute when the ilm_walker_cnt goes down to
8127c478bd9Sstevel@tonic-gate  * zero. In addition it needs to block new walkers while it is unlinking ilm's
8137c478bd9Sstevel@tonic-gate  * from the list. Thus simple atomics for the ill_ilm_walker_cnt don't suffice.
8147c478bd9Sstevel@tonic-gate  */
8157c478bd9Sstevel@tonic-gate #define	ILM_WALKER_HOLD(ill)    {               \
8167c478bd9Sstevel@tonic-gate 	mutex_enter(&(ill)->ill_lock);          \
8177c478bd9Sstevel@tonic-gate 	ill->ill_ilm_walker_cnt++;              \
8187c478bd9Sstevel@tonic-gate 	mutex_exit(&(ill)->ill_lock);           \
8197c478bd9Sstevel@tonic-gate }
8207c478bd9Sstevel@tonic-gate 
8217c478bd9Sstevel@tonic-gate #define	ILM_WALKER_RELE(ill)	{ 		\
8227c478bd9Sstevel@tonic-gate 	mutex_enter(&(ill)->ill_lock);		\
8237c478bd9Sstevel@tonic-gate 	(ill)->ill_ilm_walker_cnt--;		\
8247c478bd9Sstevel@tonic-gate 	if ((ill)->ill_ilm_walker_cnt == 0 && (ill)->ill_ilm_cleanup_reqd) \
8257c478bd9Sstevel@tonic-gate 		ilm_walker_cleanup(ill);	\
8267c478bd9Sstevel@tonic-gate 	mutex_exit(&(ill)->ill_lock);		\
8277c478bd9Sstevel@tonic-gate }
8287c478bd9Sstevel@tonic-gate 
8297c478bd9Sstevel@tonic-gate /*
8307c478bd9Sstevel@tonic-gate  * Soft reference to an IPsec SA.
8317c478bd9Sstevel@tonic-gate  *
8327c478bd9Sstevel@tonic-gate  * On relative terms, conn's can be persistant (living as long as the
8337c478bd9Sstevel@tonic-gate  * processes which create them), while SA's are ephemeral (dying when
8347c478bd9Sstevel@tonic-gate  * they hit their time-based or byte-based lifetimes).
8357c478bd9Sstevel@tonic-gate  *
8367c478bd9Sstevel@tonic-gate  * We could hold a hard reference to an SA from an ipsec_latch_t,
8377c478bd9Sstevel@tonic-gate  * but this would cause expired SA's to linger for a potentially
8387c478bd9Sstevel@tonic-gate  * unbounded time.
8397c478bd9Sstevel@tonic-gate  *
8407c478bd9Sstevel@tonic-gate  * Instead, we remember the hash bucket number and bucket generation
8417c478bd9Sstevel@tonic-gate  * in addition to the pointer.  The bucket generation is incremented on
8427c478bd9Sstevel@tonic-gate  * each deletion.
8437c478bd9Sstevel@tonic-gate  */
8447c478bd9Sstevel@tonic-gate typedef struct ipsa_ref_s
8457c478bd9Sstevel@tonic-gate {
8467c478bd9Sstevel@tonic-gate 	struct ipsa_s	*ipsr_sa;
8477c478bd9Sstevel@tonic-gate 	struct isaf_s	*ipsr_bucket;
8487c478bd9Sstevel@tonic-gate 	uint64_t	ipsr_gen;
8497c478bd9Sstevel@tonic-gate } ipsa_ref_t;
8507c478bd9Sstevel@tonic-gate 
8517c478bd9Sstevel@tonic-gate /*
8527c478bd9Sstevel@tonic-gate  * IPsec "latching" state.
8537c478bd9Sstevel@tonic-gate  *
8547c478bd9Sstevel@tonic-gate  * In the presence of IPsec policy, fully-bound conn's bind a connection
8557c478bd9Sstevel@tonic-gate  * to more than just the 5-tuple, but also a specific IPsec action and
8567c478bd9Sstevel@tonic-gate  * identity-pair.
8577c478bd9Sstevel@tonic-gate  *
8587c478bd9Sstevel@tonic-gate  * As an optimization, we also cache soft references to IPsec SA's
8597c478bd9Sstevel@tonic-gate  * here so that we can fast-path around most of the work needed for
8607c478bd9Sstevel@tonic-gate  * outbound IPsec SA selection.
8617c478bd9Sstevel@tonic-gate  *
8627c478bd9Sstevel@tonic-gate  * Were it not for TCP's detached connections, this state would be
8637c478bd9Sstevel@tonic-gate  * in-line in conn_t; instead, this is in a separate structure so it
8647c478bd9Sstevel@tonic-gate  * can be handed off to TCP when a connection is detached.
8657c478bd9Sstevel@tonic-gate  */
8667c478bd9Sstevel@tonic-gate typedef struct ipsec_latch_s
8677c478bd9Sstevel@tonic-gate {
8687c478bd9Sstevel@tonic-gate 	kmutex_t	ipl_lock;
8697c478bd9Sstevel@tonic-gate 	uint32_t	ipl_refcnt;
8707c478bd9Sstevel@tonic-gate 
8717c478bd9Sstevel@tonic-gate 	uint64_t	ipl_unique;
8727c478bd9Sstevel@tonic-gate 	struct ipsec_policy_s	*ipl_in_policy; /* latched policy (in) */
8737c478bd9Sstevel@tonic-gate 	struct ipsec_policy_s	*ipl_out_policy; /* latched policy (out) */
8747c478bd9Sstevel@tonic-gate 	struct ipsec_action_s	*ipl_in_action;	/* latched action (in) */
8757c478bd9Sstevel@tonic-gate 	struct ipsec_action_s	*ipl_out_action; /* latched action (out) */
8767c478bd9Sstevel@tonic-gate 	cred_t		*ipl_local_id;
8777c478bd9Sstevel@tonic-gate 	struct ipsid_s	*ipl_local_cid;
8787c478bd9Sstevel@tonic-gate 	struct ipsid_s	*ipl_remote_cid;
8797c478bd9Sstevel@tonic-gate 	unsigned int
8807c478bd9Sstevel@tonic-gate 			ipl_out_action_latched : 1,
8817c478bd9Sstevel@tonic-gate 			ipl_in_action_latched : 1,
8827c478bd9Sstevel@tonic-gate 			ipl_out_policy_latched : 1,
8837c478bd9Sstevel@tonic-gate 			ipl_in_policy_latched : 1,
8847c478bd9Sstevel@tonic-gate 
8857c478bd9Sstevel@tonic-gate 			ipl_ids_latched : 1,
8867c478bd9Sstevel@tonic-gate 
8877c478bd9Sstevel@tonic-gate 			ipl_pad_to_bit_31 : 27;
8887c478bd9Sstevel@tonic-gate 
8897c478bd9Sstevel@tonic-gate 	ipsa_ref_t	ipl_ref[2]; /* 0: ESP, 1: AH */
8907c478bd9Sstevel@tonic-gate 
8917c478bd9Sstevel@tonic-gate } ipsec_latch_t;
8927c478bd9Sstevel@tonic-gate 
8937c478bd9Sstevel@tonic-gate #define	IPLATCH_REFHOLD(ipl) { \
8947c478bd9Sstevel@tonic-gate 	atomic_add_32(&(ipl)->ipl_refcnt, 1);		\
8957c478bd9Sstevel@tonic-gate 	ASSERT((ipl)->ipl_refcnt != 0);			\
8967c478bd9Sstevel@tonic-gate }
8977c478bd9Sstevel@tonic-gate 
8987c478bd9Sstevel@tonic-gate #define	IPLATCH_REFRELE(ipl) {					\
8997c478bd9Sstevel@tonic-gate 	ASSERT((ipl)->ipl_refcnt != 0);				\
9007c478bd9Sstevel@tonic-gate 	membar_exit();						\
9017c478bd9Sstevel@tonic-gate 	if (atomic_add_32_nv(&(ipl)->ipl_refcnt, -1) == 0)	\
9027c478bd9Sstevel@tonic-gate 		iplatch_free(ipl);				\
9037c478bd9Sstevel@tonic-gate }
9047c478bd9Sstevel@tonic-gate 
9057c478bd9Sstevel@tonic-gate /*
9067c478bd9Sstevel@tonic-gate  * peer identity structure.
9077c478bd9Sstevel@tonic-gate  */
9087c478bd9Sstevel@tonic-gate 
9097c478bd9Sstevel@tonic-gate typedef struct conn_s conn_t;
9107c478bd9Sstevel@tonic-gate 
9117c478bd9Sstevel@tonic-gate /*
9127c478bd9Sstevel@tonic-gate  * The old IP client structure "ipc_t" is gone. All the data is stored in the
9137c478bd9Sstevel@tonic-gate  * connection structure "conn_t" now. The mapping of old and new fields looks
9147c478bd9Sstevel@tonic-gate  * like this:
9157c478bd9Sstevel@tonic-gate  *
9167c478bd9Sstevel@tonic-gate  * ipc_ulp			conn_ulp
9177c478bd9Sstevel@tonic-gate  * ipc_rq			conn_rq
9187c478bd9Sstevel@tonic-gate  * ipc_wq			conn_wq
9197c478bd9Sstevel@tonic-gate  *
9207c478bd9Sstevel@tonic-gate  * ipc_laddr			conn_src
9217c478bd9Sstevel@tonic-gate  * ipc_faddr			conn_rem
9227c478bd9Sstevel@tonic-gate  * ipc_v6laddr			conn_srcv6
9237c478bd9Sstevel@tonic-gate  * ipc_v6faddr			conn_remv6
9247c478bd9Sstevel@tonic-gate  *
9257c478bd9Sstevel@tonic-gate  * ipc_lport			conn_lport
9267c478bd9Sstevel@tonic-gate  * ipc_fport			conn_fport
9277c478bd9Sstevel@tonic-gate  * ipc_ports			conn_ports
9287c478bd9Sstevel@tonic-gate  *
9297c478bd9Sstevel@tonic-gate  * ipc_policy			conn_policy
9307c478bd9Sstevel@tonic-gate  * ipc_latch			conn_latch
9317c478bd9Sstevel@tonic-gate  *
9327c478bd9Sstevel@tonic-gate  * ipc_irc_lock			conn_lock
9337c478bd9Sstevel@tonic-gate  * ipc_ire_cache		conn_ire_cache
9347c478bd9Sstevel@tonic-gate  *
9357c478bd9Sstevel@tonic-gate  * ipc_state_flags		conn_state_flags
9367c478bd9Sstevel@tonic-gate  * ipc_outgoing_ill		conn_outgoing_ill
9377c478bd9Sstevel@tonic-gate  *
9387c478bd9Sstevel@tonic-gate  * ipc_dontroute 		conn_dontroute
9397c478bd9Sstevel@tonic-gate  * ipc_loopback 		conn_loopback
9407c478bd9Sstevel@tonic-gate  * ipc_broadcast		conn_broadcast
9417c478bd9Sstevel@tonic-gate  * ipc_reuseaddr		conn_reuseaddr
9427c478bd9Sstevel@tonic-gate  *
9437c478bd9Sstevel@tonic-gate  * ipc_multicast_loop		conn_multicast_loop
9447c478bd9Sstevel@tonic-gate  * ipc_multi_router		conn_multi_router
9457c478bd9Sstevel@tonic-gate  * ipc_priv_stream 		conn_priv_stream
9467c478bd9Sstevel@tonic-gate  * ipc_draining 		conn_draining
9477c478bd9Sstevel@tonic-gate  *
9487c478bd9Sstevel@tonic-gate  * ipc_did_putbq		conn_did_putbq
9497c478bd9Sstevel@tonic-gate  * ipc_unspec_src		conn_unspec_src
9507c478bd9Sstevel@tonic-gate  * ipc_policy_cached		conn_policy_cached
9517c478bd9Sstevel@tonic-gate  *
9527c478bd9Sstevel@tonic-gate  * ipc_in_enforce_policy 	conn_in_enforce_policy
9537c478bd9Sstevel@tonic-gate  * ipc_out_enforce_policy 	conn_out_enforce_policy
9547c478bd9Sstevel@tonic-gate  * ipc_af_isv6			conn_af_isv6
9557c478bd9Sstevel@tonic-gate  * ipc_pkt_isv6			conn_pkt_isv6
9567c478bd9Sstevel@tonic-gate  *
9577c478bd9Sstevel@tonic-gate  * ipc_ipv6_recvpktinfo		conn_ipv6_recvpktinfo
9587c478bd9Sstevel@tonic-gate  *
9597c478bd9Sstevel@tonic-gate  * ipc_ipv6_recvhoplimit	conn_ipv6_recvhoplimit
9607c478bd9Sstevel@tonic-gate  * ipc_ipv6_recvhopopts		conn_ipv6_recvhopopts
9617c478bd9Sstevel@tonic-gate  * ipc_ipv6_recvdstopts		conn_ipv6_recvdstopts
9627c478bd9Sstevel@tonic-gate  *
9637c478bd9Sstevel@tonic-gate  * ipc_ipv6_recvrthdr 		conn_ipv6_recvrthdr
9647c478bd9Sstevel@tonic-gate  * ipc_ipv6_recvrtdstopts	conn_ipv6_recvrtdstopts
9657c478bd9Sstevel@tonic-gate  * ipc_fully_bound		conn_fully_bound
9667c478bd9Sstevel@tonic-gate  *
9677c478bd9Sstevel@tonic-gate  * ipc_recvif			conn_recvif
9687c478bd9Sstevel@tonic-gate  *
9697c478bd9Sstevel@tonic-gate  * ipc_recvslla 		conn_recvslla
9707c478bd9Sstevel@tonic-gate  * ipc_acking_unbind 		conn_acking_unbind
9717c478bd9Sstevel@tonic-gate  * ipc_pad_to_bit_31 		conn_pad_to_bit_31
9727c478bd9Sstevel@tonic-gate  *
9737c478bd9Sstevel@tonic-gate  * ipc_xmit_if_ill		conn_xmit_if_ill
9747c478bd9Sstevel@tonic-gate  * ipc_nofailover_ill		conn_nofailover_ill
9757c478bd9Sstevel@tonic-gate  *
9767c478bd9Sstevel@tonic-gate  * ipc_proto			conn_proto
9777c478bd9Sstevel@tonic-gate  * ipc_incoming_ill		conn_incoming_ill
9787c478bd9Sstevel@tonic-gate  * ipc_outgoing_pill		conn_outgoing_pill
9797c478bd9Sstevel@tonic-gate  * ipc_pending_ill		conn_pending_ill
9807c478bd9Sstevel@tonic-gate  * ipc_unbind_mp		conn_unbind_mp
9817c478bd9Sstevel@tonic-gate  * ipc_ilg			conn_ilg
9827c478bd9Sstevel@tonic-gate  * ipc_ilg_allocated		conn_ilg_allocated
9837c478bd9Sstevel@tonic-gate  * ipc_ilg_inuse		conn_ilg_inuse
9847c478bd9Sstevel@tonic-gate  * ipc_ilg_walker_cnt		conn_ilg_walker_cnt
9857c478bd9Sstevel@tonic-gate  * ipc_refcv			conn_refcv
9867c478bd9Sstevel@tonic-gate  * ipc_multicast_ipif		conn_multicast_ipif
9877c478bd9Sstevel@tonic-gate  * ipc_multicast_ill		conn_multicast_ill
9887c478bd9Sstevel@tonic-gate  * ipc_orig_bound_ifindex	conn_orig_bound_ifindex
9897c478bd9Sstevel@tonic-gate  * ipc_orig_multicast_ifindex	conn_orig_multicast_ifindex
9907c478bd9Sstevel@tonic-gate  * ipc_orig_xmit_ifindex	conn_orig_xmit_ifindex
9917c478bd9Sstevel@tonic-gate  * ipc_drain_next		conn_drain_next
9927c478bd9Sstevel@tonic-gate  * ipc_drain_prev		conn_drain_prev
9937c478bd9Sstevel@tonic-gate  * ipc_idl			conn_idl
9947c478bd9Sstevel@tonic-gate  */
9957c478bd9Sstevel@tonic-gate 
9967c478bd9Sstevel@tonic-gate /*
9977c478bd9Sstevel@tonic-gate  * This is used to match an inbound/outbound datagram with
9987c478bd9Sstevel@tonic-gate  * policy.
9997c478bd9Sstevel@tonic-gate  */
10007c478bd9Sstevel@tonic-gate 
10017c478bd9Sstevel@tonic-gate typedef	struct ipsec_selector {
10027c478bd9Sstevel@tonic-gate 	in6_addr_t	ips_local_addr_v6;
10037c478bd9Sstevel@tonic-gate 	in6_addr_t	ips_remote_addr_v6;
10047c478bd9Sstevel@tonic-gate 	uint16_t	ips_local_port;
10057c478bd9Sstevel@tonic-gate 	uint16_t	ips_remote_port;
10067c478bd9Sstevel@tonic-gate 	uint8_t		ips_icmp_type;
10077c478bd9Sstevel@tonic-gate 	uint8_t		ips_icmp_code;
10087c478bd9Sstevel@tonic-gate 	uint8_t		ips_protocol;
10097c478bd9Sstevel@tonic-gate 	uint8_t		ips_isv4 : 1,
10107c478bd9Sstevel@tonic-gate 			ips_is_icmp_inv_acq: 1;
10117c478bd9Sstevel@tonic-gate } ipsec_selector_t;
10127c478bd9Sstevel@tonic-gate 
10137c478bd9Sstevel@tonic-gate /*
10147c478bd9Sstevel@tonic-gate  * Note that we put v4 addresses in the *first* 32-bit word of the
10157c478bd9Sstevel@tonic-gate  * selector rather than the last to simplify the prefix match/mask code
10167c478bd9Sstevel@tonic-gate  * in spd.c
10177c478bd9Sstevel@tonic-gate  */
10187c478bd9Sstevel@tonic-gate #define	ips_local_addr_v4 ips_local_addr_v6.s6_addr32[0]
10197c478bd9Sstevel@tonic-gate #define	ips_remote_addr_v4 ips_remote_addr_v6.s6_addr32[0]
10207c478bd9Sstevel@tonic-gate 
10217c478bd9Sstevel@tonic-gate /* Values used in IP by IPSEC Code */
10227c478bd9Sstevel@tonic-gate #define		IPSEC_OUTBOUND		B_TRUE
10237c478bd9Sstevel@tonic-gate #define		IPSEC_INBOUND		B_FALSE
10247c478bd9Sstevel@tonic-gate 
10257c478bd9Sstevel@tonic-gate /*
10267c478bd9Sstevel@tonic-gate  * There are two variants in policy failures. The packet may come in
10277c478bd9Sstevel@tonic-gate  * secure when not needed (IPSEC_POLICY_???_NOT_NEEDED) or it may not
10287c478bd9Sstevel@tonic-gate  * have the desired level of protection (IPSEC_POLICY_MISMATCH).
10297c478bd9Sstevel@tonic-gate  */
10307c478bd9Sstevel@tonic-gate #define	IPSEC_POLICY_NOT_NEEDED		0
10317c478bd9Sstevel@tonic-gate #define	IPSEC_POLICY_MISMATCH		1
10327c478bd9Sstevel@tonic-gate #define	IPSEC_POLICY_AUTH_NOT_NEEDED	2
10337c478bd9Sstevel@tonic-gate #define	IPSEC_POLICY_ENCR_NOT_NEEDED	3
10347c478bd9Sstevel@tonic-gate #define	IPSEC_POLICY_SE_NOT_NEEDED	4
10357c478bd9Sstevel@tonic-gate #define	IPSEC_POLICY_MAX		5	/* Always max + 1. */
10367c478bd9Sstevel@tonic-gate 
10377c478bd9Sstevel@tonic-gate /*
10387c478bd9Sstevel@tonic-gate  * Folowing macro is used whenever the code does not know whether there
10397c478bd9Sstevel@tonic-gate  * is a M_CTL present in the front and it needs to examine the actual mp
10407c478bd9Sstevel@tonic-gate  * i.e the IP header. As a M_CTL message could be in the front, this
10417c478bd9Sstevel@tonic-gate  * extracts the packet into mp and the M_CTL mp into first_mp. If M_CTL
10427c478bd9Sstevel@tonic-gate  * mp is not present, both first_mp and mp point to the same message.
10437c478bd9Sstevel@tonic-gate  */
10447c478bd9Sstevel@tonic-gate #define	EXTRACT_PKT_MP(mp, first_mp, mctl_present)	\
10457c478bd9Sstevel@tonic-gate 	(first_mp) = (mp);				\
10467c478bd9Sstevel@tonic-gate 	if ((mp)->b_datap->db_type == M_CTL) {		\
10477c478bd9Sstevel@tonic-gate 		(mp) = (mp)->b_cont;			\
10487c478bd9Sstevel@tonic-gate 		(mctl_present) = B_TRUE;		\
10497c478bd9Sstevel@tonic-gate 	} else {					\
10507c478bd9Sstevel@tonic-gate 		(mctl_present) = B_FALSE;		\
10517c478bd9Sstevel@tonic-gate 	}
10527c478bd9Sstevel@tonic-gate 
10537c478bd9Sstevel@tonic-gate /*
10547c478bd9Sstevel@tonic-gate  * Check with IPSEC inbound policy if
10557c478bd9Sstevel@tonic-gate  *
10567c478bd9Sstevel@tonic-gate  * 1) per-socket policy is present - indicated by conn_in_enforce_policy.
10577c478bd9Sstevel@tonic-gate  * 2) Or if we have not cached policy on the conn and the global policy is
10587c478bd9Sstevel@tonic-gate  *    non-empty.
10597c478bd9Sstevel@tonic-gate  */
10607c478bd9Sstevel@tonic-gate #define	CONN_INBOUND_POLICY_PRESENT(connp)	\
10617c478bd9Sstevel@tonic-gate 	((connp)->conn_in_enforce_policy ||	\
10627c478bd9Sstevel@tonic-gate 	(!((connp)->conn_policy_cached) &&	\
10637c478bd9Sstevel@tonic-gate 	ipsec_inbound_v4_policy_present))
10647c478bd9Sstevel@tonic-gate 
10657c478bd9Sstevel@tonic-gate #define	CONN_INBOUND_POLICY_PRESENT_V6(connp)	\
10667c478bd9Sstevel@tonic-gate 	((connp)->conn_in_enforce_policy ||	\
10677c478bd9Sstevel@tonic-gate 	(!(connp)->conn_policy_cached &&	\
10687c478bd9Sstevel@tonic-gate 	ipsec_inbound_v6_policy_present))
10697c478bd9Sstevel@tonic-gate 
10707c478bd9Sstevel@tonic-gate #define	CONN_OUTBOUND_POLICY_PRESENT(connp)	\
10717c478bd9Sstevel@tonic-gate 	((connp)->conn_out_enforce_policy ||	\
10727c478bd9Sstevel@tonic-gate 	(!((connp)->conn_policy_cached) &&	\
10737c478bd9Sstevel@tonic-gate 	ipsec_outbound_v4_policy_present))
10747c478bd9Sstevel@tonic-gate 
10757c478bd9Sstevel@tonic-gate #define	CONN_OUTBOUND_POLICY_PRESENT_V6(connp)	\
10767c478bd9Sstevel@tonic-gate 	((connp)->conn_out_enforce_policy ||	\
10777c478bd9Sstevel@tonic-gate 	(!(connp)->conn_policy_cached &&	\
10787c478bd9Sstevel@tonic-gate 	ipsec_outbound_v6_policy_present))
10797c478bd9Sstevel@tonic-gate 
10807c478bd9Sstevel@tonic-gate /*
10817c478bd9Sstevel@tonic-gate  * Information cached in IRE for upper layer protocol (ULP).
10827c478bd9Sstevel@tonic-gate  *
10837c478bd9Sstevel@tonic-gate  * Notice that ire_max_frag is not included in the iulp_t structure, which
10847c478bd9Sstevel@tonic-gate  * it may seem that it should.  But ire_max_frag cannot really be cached.  It
10857c478bd9Sstevel@tonic-gate  * is fixed for each interface.  For MTU found by PMTUd, we may want to cache
10867c478bd9Sstevel@tonic-gate  * it.  But currently, we do not do that.
10877c478bd9Sstevel@tonic-gate  */
10887c478bd9Sstevel@tonic-gate typedef struct iulp_s {
10897c478bd9Sstevel@tonic-gate 	boolean_t	iulp_set;	/* Is any metric set? */
10907c478bd9Sstevel@tonic-gate 	uint32_t	iulp_ssthresh;	/* Slow start threshold (TCP). */
10917c478bd9Sstevel@tonic-gate 	clock_t		iulp_rtt;	/* Guestimate in millisecs. */
10927c478bd9Sstevel@tonic-gate 	clock_t		iulp_rtt_sd;	/* Cached value of RTT variance. */
10937c478bd9Sstevel@tonic-gate 	uint32_t	iulp_spipe;	/* Send pipe size. */
10947c478bd9Sstevel@tonic-gate 	uint32_t	iulp_rpipe;	/* Receive pipe size. */
10957c478bd9Sstevel@tonic-gate 	uint32_t	iulp_rtomax;	/* Max round trip timeout. */
10967c478bd9Sstevel@tonic-gate 	uint32_t	iulp_sack;	/* Use SACK option (TCP)? */
10977c478bd9Sstevel@tonic-gate 	uint32_t
10987c478bd9Sstevel@tonic-gate 		iulp_tstamp_ok : 1,	/* Use timestamp option (TCP)? */
10997c478bd9Sstevel@tonic-gate 		iulp_wscale_ok : 1,	/* Use window scale option (TCP)? */
11007c478bd9Sstevel@tonic-gate 		iulp_ecn_ok : 1,	/* Enable ECN (for TCP)? */
11017c478bd9Sstevel@tonic-gate 		iulp_pmtud_ok : 1,	/* Enable PMTUd? */
11027c478bd9Sstevel@tonic-gate 
11037c478bd9Sstevel@tonic-gate 		iulp_not_used : 28;
11047c478bd9Sstevel@tonic-gate } iulp_t;
11057c478bd9Sstevel@tonic-gate 
11067c478bd9Sstevel@tonic-gate /* Zero iulp_t. */
11077c478bd9Sstevel@tonic-gate extern const iulp_t ire_uinfo_null;
11087c478bd9Sstevel@tonic-gate 
11097c478bd9Sstevel@tonic-gate /*
11107c478bd9Sstevel@tonic-gate  * The conn drain list structure.
11117c478bd9Sstevel@tonic-gate  * The list is protected by idl_lock. Each conn_t inserted in the list
11127c478bd9Sstevel@tonic-gate  * points back at this idl_t using conn_idl. IP primes the draining of the
11137c478bd9Sstevel@tonic-gate  * conns queued in these lists, by qenabling the 1st conn of each list. This
11147c478bd9Sstevel@tonic-gate  * occurs when STREAMS backenables ip_wsrv on the IP module. Each conn instance
11157c478bd9Sstevel@tonic-gate  * of ip_wsrv successively qenables the next conn in the list.
11167c478bd9Sstevel@tonic-gate  * idl_lock protects all other members of idl_t and conn_drain_next
11177c478bd9Sstevel@tonic-gate  * and conn_drain_prev of conn_t. The conn_lock protects IPCF_DRAIN_DISABLED
11187c478bd9Sstevel@tonic-gate  * flag of the conn_t and conn_idl.
11197c478bd9Sstevel@tonic-gate  */
11207c478bd9Sstevel@tonic-gate typedef struct idl_s {
11217c478bd9Sstevel@tonic-gate 	conn_t		*idl_conn;		/* Head of drain list */
11227c478bd9Sstevel@tonic-gate 	kmutex_t	idl_lock;		/* Lock for this list */
11237c478bd9Sstevel@tonic-gate 	conn_t		*idl_conn_draining;	/* conn that is draining */
11247c478bd9Sstevel@tonic-gate 	uint32_t
11257c478bd9Sstevel@tonic-gate 		idl_repeat : 1,			/* Last conn must re-enable */
11267c478bd9Sstevel@tonic-gate 						/* drain list again */
11277c478bd9Sstevel@tonic-gate 		idl_unused : 31;
11287c478bd9Sstevel@tonic-gate } idl_t;
11297c478bd9Sstevel@tonic-gate 
11307c478bd9Sstevel@tonic-gate #define	CONN_DRAIN_LIST_LOCK(connp)	(&((connp)->conn_idl->idl_lock))
11317c478bd9Sstevel@tonic-gate /*
11327c478bd9Sstevel@tonic-gate  * Interface route structure which holds the necessary information to recreate
11337c478bd9Sstevel@tonic-gate  * routes that are tied to an interface (namely where ire_ipif != NULL).
11347c478bd9Sstevel@tonic-gate  * These routes which were initially created via a routing socket or via the
11357c478bd9Sstevel@tonic-gate  * SIOCADDRT ioctl may be gateway routes (RTF_GATEWAY being set) or may be
11367c478bd9Sstevel@tonic-gate  * traditional interface routes.  When an interface comes back up after being
11377c478bd9Sstevel@tonic-gate  * marked down, this information will be used to recreate the routes.  These
11387c478bd9Sstevel@tonic-gate  * are part of an mblk_t chain that hangs off of the IPIF (ipif_saved_ire_mp).
11397c478bd9Sstevel@tonic-gate  */
11407c478bd9Sstevel@tonic-gate typedef struct ifrt_s {
11417c478bd9Sstevel@tonic-gate 	ushort_t	ifrt_type;		/* Type of IRE */
11427c478bd9Sstevel@tonic-gate 	in6_addr_t	ifrt_v6addr;		/* Address IRE represents. */
11437c478bd9Sstevel@tonic-gate 	in6_addr_t	ifrt_v6gateway_addr;	/* Gateway if IRE_OFFSUBNET */
11447c478bd9Sstevel@tonic-gate 	in6_addr_t	ifrt_v6src_addr;	/* Src addr if RTF_SETSRC */
11457c478bd9Sstevel@tonic-gate 	in6_addr_t	ifrt_v6mask;		/* Mask for matching IRE. */
11467c478bd9Sstevel@tonic-gate 	uint32_t	ifrt_flags;		/* flags related to route */
11477c478bd9Sstevel@tonic-gate 	uint_t		ifrt_max_frag;		/* MTU (next hop or path). */
11487c478bd9Sstevel@tonic-gate 	iulp_t		ifrt_iulp_info;		/* Cached IRE ULP info. */
11497c478bd9Sstevel@tonic-gate } ifrt_t;
11507c478bd9Sstevel@tonic-gate 
11517c478bd9Sstevel@tonic-gate #define	ifrt_addr		V4_PART_OF_V6(ifrt_v6addr)
11527c478bd9Sstevel@tonic-gate #define	ifrt_gateway_addr	V4_PART_OF_V6(ifrt_v6gateway_addr)
11537c478bd9Sstevel@tonic-gate #define	ifrt_src_addr		V4_PART_OF_V6(ifrt_v6src_addr)
11547c478bd9Sstevel@tonic-gate #define	ifrt_mask		V4_PART_OF_V6(ifrt_v6mask)
11557c478bd9Sstevel@tonic-gate 
11567c478bd9Sstevel@tonic-gate /* Number of IP addresses that can be hosted on a physical interface */
11577c478bd9Sstevel@tonic-gate #define	MAX_ADDRS_PER_IF	8192
11587c478bd9Sstevel@tonic-gate /*
11597c478bd9Sstevel@tonic-gate  * Number of Source addresses to be considered for source address
11607c478bd9Sstevel@tonic-gate  * selection. Used by ipif_select_source[_v6].
11617c478bd9Sstevel@tonic-gate  */
11627c478bd9Sstevel@tonic-gate #define	MAX_IPIF_SELECT_SOURCE	50
11637c478bd9Sstevel@tonic-gate 
11647c478bd9Sstevel@tonic-gate #ifdef IP_DEBUG
11657c478bd9Sstevel@tonic-gate /*
11667c478bd9Sstevel@tonic-gate  * Tracing refholds and refreleases for debugging. Existing tracing mechanisms
11677c478bd9Sstevel@tonic-gate  * do not allow the granularity need to trace refrences to ipif/ill/ire's. This
11687c478bd9Sstevel@tonic-gate  * mechanism should be revisited once dtrace is available.
11697c478bd9Sstevel@tonic-gate  */
11707c478bd9Sstevel@tonic-gate #define	IP_STACK_DEPTH	15
11717c478bd9Sstevel@tonic-gate typedef struct tr_buf_s {
11727c478bd9Sstevel@tonic-gate 	int	tr_depth;
11737c478bd9Sstevel@tonic-gate 	pc_t	tr_stack[IP_STACK_DEPTH];
11747c478bd9Sstevel@tonic-gate } tr_buf_t;
11757c478bd9Sstevel@tonic-gate 
11767c478bd9Sstevel@tonic-gate typedef struct th_trace_s {
11777c478bd9Sstevel@tonic-gate 	struct	th_trace_s *th_next;
11787c478bd9Sstevel@tonic-gate 	struct	th_trace_s **th_prev;
11797c478bd9Sstevel@tonic-gate 	kthread_t	*th_id;
11807c478bd9Sstevel@tonic-gate 	int	th_refcnt;
11817c478bd9Sstevel@tonic-gate 	uint_t	th_trace_lastref;
11827c478bd9Sstevel@tonic-gate #define	TR_BUF_MAX	38
11837c478bd9Sstevel@tonic-gate 	tr_buf_t th_trbuf[TR_BUF_MAX];
11847c478bd9Sstevel@tonic-gate } th_trace_t;
11857c478bd9Sstevel@tonic-gate #endif
11867c478bd9Sstevel@tonic-gate 
11877c478bd9Sstevel@tonic-gate /* The following are ipif_state_flags */
11887c478bd9Sstevel@tonic-gate #define	IPIF_CONDEMNED		0x1	/* The ipif is being removed */
11897c478bd9Sstevel@tonic-gate #define	IPIF_CHANGING		0x2	/* A critcal ipif field is changing */
11907c478bd9Sstevel@tonic-gate #define	IPIF_MOVING		0x8	/* The ipif is being moved */
11917c478bd9Sstevel@tonic-gate #define	IPIF_SET_LINKLOCAL	0x10	/* transient flag during bringup */
11927c478bd9Sstevel@tonic-gate #define	IPIF_ZERO_SOURCE	0x20	/* transient flag during bringup */
11937c478bd9Sstevel@tonic-gate 
11947c478bd9Sstevel@tonic-gate /* IP interface structure, one per local address */
11957c478bd9Sstevel@tonic-gate typedef struct ipif_s {
11967c478bd9Sstevel@tonic-gate 	struct	ipif_s	*ipif_next;
11977c478bd9Sstevel@tonic-gate 	struct	ill_s	*ipif_ill;	/* Back pointer to our ill */
11987c478bd9Sstevel@tonic-gate 	int	ipif_id;		/* Logical unit number */
11997c478bd9Sstevel@tonic-gate 	uint_t	ipif_mtu;		/* Starts at ipif_ill->ill_max_frag */
12007c478bd9Sstevel@tonic-gate 	uint_t	ipif_saved_mtu;		/* Save of mtu during ipif_move() */
12017c478bd9Sstevel@tonic-gate 	in6_addr_t ipif_v6lcl_addr;	/* Local IP address for this if. */
12027c478bd9Sstevel@tonic-gate 	in6_addr_t ipif_v6src_addr;	/* Source IP address for this if. */
12037c478bd9Sstevel@tonic-gate 	in6_addr_t ipif_v6subnet;	/* Subnet prefix for this if. */
12047c478bd9Sstevel@tonic-gate 	in6_addr_t ipif_v6net_mask;	/* Net mask for this interface. */
12057c478bd9Sstevel@tonic-gate 	in6_addr_t ipif_v6brd_addr;	/* Broadcast addr for this interface. */
12067c478bd9Sstevel@tonic-gate 	in6_addr_t ipif_v6pp_dst_addr;	/* Point-to-point dest address. */
12077c478bd9Sstevel@tonic-gate 	uint64_t ipif_flags;		/* Interface flags. */
12087c478bd9Sstevel@tonic-gate 	uint_t	ipif_metric;		/* BSD if metric, for compatibility. */
12097c478bd9Sstevel@tonic-gate 	uint_t	ipif_ire_type;		/* IRE_LOCAL or IRE_LOOPBACK */
12107c478bd9Sstevel@tonic-gate 	mblk_t	*ipif_arp_del_mp;	/* Allocated at time arp comes up, to */
12117c478bd9Sstevel@tonic-gate 					/* prevent awkward out of mem */
12127c478bd9Sstevel@tonic-gate 					/* condition later */
12137c478bd9Sstevel@tonic-gate 	mblk_t	*ipif_saved_ire_mp;	/* Allocated for each extra */
12147c478bd9Sstevel@tonic-gate 					/* IRE_IF_NORESOLVER/IRE_IF_RESOLVER */
12157c478bd9Sstevel@tonic-gate 					/* on this interface so that they */
12167c478bd9Sstevel@tonic-gate 					/* can survive ifconfig down. */
12177c478bd9Sstevel@tonic-gate 	kmutex_t ipif_saved_ire_lock;	/* Protects ipif_saved_ire_mp */
12187c478bd9Sstevel@tonic-gate 
12197c478bd9Sstevel@tonic-gate 	mrec_t	*ipif_igmp_rpt;		/* List of group memberships which */
12207c478bd9Sstevel@tonic-gate 					/* will be reported on.  Used when */
12217c478bd9Sstevel@tonic-gate 					/* handling an igmp timeout.	   */
12227c478bd9Sstevel@tonic-gate 
12237c478bd9Sstevel@tonic-gate 	/*
12247c478bd9Sstevel@tonic-gate 	 * The packet counts in the ipif contain the sum of the
12257c478bd9Sstevel@tonic-gate 	 * packet counts in dead IREs that were affiliated with
12267c478bd9Sstevel@tonic-gate 	 * this ipif.
12277c478bd9Sstevel@tonic-gate 	 */
12287c478bd9Sstevel@tonic-gate 	uint_t	ipif_fo_pkt_count;	/* Forwarded thru our dead IREs */
12297c478bd9Sstevel@tonic-gate 	uint_t	ipif_ib_pkt_count;	/* Inbound packets for our dead IREs */
12307c478bd9Sstevel@tonic-gate 	uint_t	ipif_ob_pkt_count;	/* Outbound packets to our dead IREs */
12317c478bd9Sstevel@tonic-gate 	/* Exclusive bit fields, protected by ipsq_t */
12327c478bd9Sstevel@tonic-gate 	unsigned int
12337c478bd9Sstevel@tonic-gate 		ipif_multicast_up : 1,	/* We have joined the allhosts group */
12347c478bd9Sstevel@tonic-gate 		ipif_solmcast_up : 1,	/* We joined solicited node mcast */
12357c478bd9Sstevel@tonic-gate 		ipif_replace_zero : 1,	/* Replacement for zero */
12367c478bd9Sstevel@tonic-gate 		ipif_was_up : 1,	/* ipif was up before */
12377c478bd9Sstevel@tonic-gate 
12387c478bd9Sstevel@tonic-gate 		ipif_pad_to_31 : 28;
12397c478bd9Sstevel@tonic-gate 
12407c478bd9Sstevel@tonic-gate 	int	ipif_orig_ifindex;	/* ifindex before SLIFFAILOVER */
12417c478bd9Sstevel@tonic-gate 	uint_t	ipif_seqid;		/* unique index across all ills */
12427c478bd9Sstevel@tonic-gate 	uint_t	ipif_orig_ipifid;	/* ipif_id before SLIFFAILOVER */
12437c478bd9Sstevel@tonic-gate 	uint_t	ipif_state_flags;	/* See IPIF_* flag defs above */
12447c478bd9Sstevel@tonic-gate 	uint_t	ipif_refcnt;		/* active consistent reader cnt */
12457c478bd9Sstevel@tonic-gate 	uint_t	ipif_ire_cnt;		/* Number of ire's referencing ipif */
12467c478bd9Sstevel@tonic-gate 	uint_t	ipif_saved_ire_cnt;
12477c478bd9Sstevel@tonic-gate 	zoneid_t
12487c478bd9Sstevel@tonic-gate 		ipif_zoneid;		/* zone ID number */
12497c478bd9Sstevel@tonic-gate #ifdef ILL_DEBUG
12507c478bd9Sstevel@tonic-gate #define	IP_TR_HASH_MAX	64
12517c478bd9Sstevel@tonic-gate 	th_trace_t *ipif_trace[IP_TR_HASH_MAX];
12527c478bd9Sstevel@tonic-gate 	boolean_t	ipif_trace_disable;	/* True when alloc fails */
12537c478bd9Sstevel@tonic-gate #endif
12547c478bd9Sstevel@tonic-gate } ipif_t;
12557c478bd9Sstevel@tonic-gate 
12567c478bd9Sstevel@tonic-gate /*
12577c478bd9Sstevel@tonic-gate  * The following table lists the protection levels of the various members
12587c478bd9Sstevel@tonic-gate  * of the ipif_t. The following notation is used.
12597c478bd9Sstevel@tonic-gate  *
12607c478bd9Sstevel@tonic-gate  * Write once - Written to only once at the time of bringing up
12617c478bd9Sstevel@tonic-gate  * the interface and can be safely read after the bringup without any lock.
12627c478bd9Sstevel@tonic-gate  *
12637c478bd9Sstevel@tonic-gate  * ipsq - Need to execute in the ipsq to perform the indicated access.
12647c478bd9Sstevel@tonic-gate  *
12657c478bd9Sstevel@tonic-gate  * ill_lock - Need to hold this mutex to perform the indicated access.
12667c478bd9Sstevel@tonic-gate  *
12677c478bd9Sstevel@tonic-gate  * ill_g_lock - Need to hold this rw lock as reader/writer for read access or
12687c478bd9Sstevel@tonic-gate  * write access respectively.
12697c478bd9Sstevel@tonic-gate  *
12707c478bd9Sstevel@tonic-gate  * down ill - Written to only when the ill is down (i.e all ipifs are down)
12717c478bd9Sstevel@tonic-gate  * up ill - Read only when the ill is up (i.e. at least 1 ipif is up)
12727c478bd9Sstevel@tonic-gate  *
12737c478bd9Sstevel@tonic-gate  *		 Table of ipif_t members and their protection
12747c478bd9Sstevel@tonic-gate  *
12757c478bd9Sstevel@tonic-gate  * ipif_next		ill_g_lock		ill_g_lock
12767c478bd9Sstevel@tonic-gate  * ipif_ill		ipsq + down ipif		write once
12777c478bd9Sstevel@tonic-gate  * ipif_id		ipsq + down ipif		write once
12787c478bd9Sstevel@tonic-gate  * ipif_mtu		ipsq
12797c478bd9Sstevel@tonic-gate  * ipif_v6lcl_addr	ipsq + down ipif		up ipif
12807c478bd9Sstevel@tonic-gate  * ipif_v6src_addr	ipsq + down ipif		up ipif
12817c478bd9Sstevel@tonic-gate  * ipif_v6subnet	ipsq + down ipif		up ipif
12827c478bd9Sstevel@tonic-gate  * ipif_v6net_mask	ipsq + down ipif		up ipif
12837c478bd9Sstevel@tonic-gate  *
12847c478bd9Sstevel@tonic-gate  * ipif_v6brd_addr
12857c478bd9Sstevel@tonic-gate  * ipif_v6pp_dst_addr
12867c478bd9Sstevel@tonic-gate  * ipif_flags		ill_lock		ill_lock
12877c478bd9Sstevel@tonic-gate  * ipif_metric
12887c478bd9Sstevel@tonic-gate  * ipif_ire_type	ipsq + down ill		up ill
12897c478bd9Sstevel@tonic-gate  *
12907c478bd9Sstevel@tonic-gate  * ipif_arp_del_mp	ipsq			ipsq
12917c478bd9Sstevel@tonic-gate  * ipif_saved_ire_mp	ipif_saved_ire_lock	ipif_saved_ire_lock
12927c478bd9Sstevel@tonic-gate  * ipif_igmp_rpt	ipsq			ipsq
12937c478bd9Sstevel@tonic-gate  *
12947c478bd9Sstevel@tonic-gate  * ipif_fo_pkt_count	Approx
12957c478bd9Sstevel@tonic-gate  * ipif_ib_pkt_count	Approx
12967c478bd9Sstevel@tonic-gate  * ipif_ob_pkt_count	Approx
12977c478bd9Sstevel@tonic-gate  *
12987c478bd9Sstevel@tonic-gate  * bit fields		ill_lock		ill_lock
12997c478bd9Sstevel@tonic-gate  *
13007c478bd9Sstevel@tonic-gate  * ipif_orig_ifindex	ipsq			None
13017c478bd9Sstevel@tonic-gate  * ipif_orig_ipifid	ipsq			None
13027c478bd9Sstevel@tonic-gate  * ipif_seqid		ipsq			Write once
13037c478bd9Sstevel@tonic-gate  *
13047c478bd9Sstevel@tonic-gate  * ipif_state_flags	ill_lock		ill_lock
13057c478bd9Sstevel@tonic-gate  * ipif_refcnt		ill_lock		ill_lock
13067c478bd9Sstevel@tonic-gate  * ipif_ire_cnt		ill_lock		ill_lock
13077c478bd9Sstevel@tonic-gate  * ipif_saved_ire_cnt
13087c478bd9Sstevel@tonic-gate  */
13097c478bd9Sstevel@tonic-gate 
13107c478bd9Sstevel@tonic-gate #define	IP_TR_HASH(tid)	((((uintptr_t)tid) >> 6) & (IP_TR_HASH_MAX - 1))
13117c478bd9Sstevel@tonic-gate 
13127c478bd9Sstevel@tonic-gate #ifdef ILL_DEBUG
13137c478bd9Sstevel@tonic-gate #define	IPIF_TRACE_REF(ipif)	ipif_trace_ref(ipif)
13147c478bd9Sstevel@tonic-gate #define	ILL_TRACE_REF(ill)	ill_trace_ref(ill)
13157c478bd9Sstevel@tonic-gate #define	IPIF_UNTRACE_REF(ipif)	ipif_untrace_ref(ipif)
13167c478bd9Sstevel@tonic-gate #define	ILL_UNTRACE_REF(ill)	ill_untrace_ref(ill)
13177c478bd9Sstevel@tonic-gate #define	ILL_TRACE_CLEANUP(ill)	ill_trace_cleanup(ill)
13187c478bd9Sstevel@tonic-gate #define	IPIF_TRACE_CLEANUP(ipif)	ipif_trace_cleanup(ipif)
13197c478bd9Sstevel@tonic-gate #else
13207c478bd9Sstevel@tonic-gate #define	IPIF_TRACE_REF(ipif)
13217c478bd9Sstevel@tonic-gate #define	ILL_TRACE_REF(ill)
13227c478bd9Sstevel@tonic-gate #define	IPIF_UNTRACE_REF(ipif)
13237c478bd9Sstevel@tonic-gate #define	ILL_UNTRACE_REF(ill)
13247c478bd9Sstevel@tonic-gate #define	ILL_TRACE_CLEANUP(ill)
13257c478bd9Sstevel@tonic-gate #define	IPIF_TRACE_CLEANUP(ipif)
13267c478bd9Sstevel@tonic-gate #endif
13277c478bd9Sstevel@tonic-gate 
13287c478bd9Sstevel@tonic-gate /* IPv4 compatability macros */
13297c478bd9Sstevel@tonic-gate #define	ipif_lcl_addr		V4_PART_OF_V6(ipif_v6lcl_addr)
13307c478bd9Sstevel@tonic-gate #define	ipif_src_addr		V4_PART_OF_V6(ipif_v6src_addr)
13317c478bd9Sstevel@tonic-gate #define	ipif_subnet		V4_PART_OF_V6(ipif_v6subnet)
13327c478bd9Sstevel@tonic-gate #define	ipif_net_mask		V4_PART_OF_V6(ipif_v6net_mask)
13337c478bd9Sstevel@tonic-gate #define	ipif_brd_addr		V4_PART_OF_V6(ipif_v6brd_addr)
13347c478bd9Sstevel@tonic-gate #define	ipif_pp_dst_addr	V4_PART_OF_V6(ipif_v6pp_dst_addr)
13357c478bd9Sstevel@tonic-gate 
13367c478bd9Sstevel@tonic-gate /* Macros for easy backreferences to the ill. */
13377c478bd9Sstevel@tonic-gate #define	ipif_wq			ipif_ill->ill_wq
13387c478bd9Sstevel@tonic-gate #define	ipif_rq			ipif_ill->ill_rq
13397c478bd9Sstevel@tonic-gate #define	ipif_net_type		ipif_ill->ill_net_type
13407c478bd9Sstevel@tonic-gate #define	ipif_resolver_mp	ipif_ill->ill_resolver_mp
13417c478bd9Sstevel@tonic-gate #define	ipif_ipif_up_count	ipif_ill->ill_ipif_up_count
13427c478bd9Sstevel@tonic-gate #define	ipif_bcast_mp		ipif_ill->ill_bcast_mp
13437c478bd9Sstevel@tonic-gate #define	ipif_type		ipif_ill->ill_type
13447c478bd9Sstevel@tonic-gate #define	ipif_isv6		ipif_ill->ill_isv6
13457c478bd9Sstevel@tonic-gate 
13467c478bd9Sstevel@tonic-gate #define	SIOCLIFADDR_NDX 112	/* ndx of SIOCLIFADDR in the ndx ioctl table */
13477c478bd9Sstevel@tonic-gate 
13487c478bd9Sstevel@tonic-gate /*
13497c478bd9Sstevel@tonic-gate  * mode value for ip_ioctl_finish for finishing an ioctl
13507c478bd9Sstevel@tonic-gate  */
13517c478bd9Sstevel@tonic-gate #define	CONN_CLOSE	1		/* No mi_copy */
13527c478bd9Sstevel@tonic-gate #define	COPYOUT		2		/* do an mi_copyout if needed */
13537c478bd9Sstevel@tonic-gate #define	NO_COPYOUT	3		/* do an mi_copy_done */
13547c478bd9Sstevel@tonic-gate 
13557c478bd9Sstevel@tonic-gate /*
13567c478bd9Sstevel@tonic-gate  * The IP-MT design revolves around the serialization object ipsq_t.
13577c478bd9Sstevel@tonic-gate  * It is associated with an IPMP group. If IPMP is not enabled, there is
13587c478bd9Sstevel@tonic-gate  * 1 ipsq_t per phyint. Eg. an ipsq_t would cover both hme0's IPv4 stream
13597c478bd9Sstevel@tonic-gate  *
13607c478bd9Sstevel@tonic-gate  * ipsq_lock protects
13617c478bd9Sstevel@tonic-gate  *	ipsq_reentry_cnt, ipsq_writer, ipsq_xopq_mphead, ipsq_xopq_mptail,
13627c478bd9Sstevel@tonic-gate  *	ipsq_mphead, ipsq_mptail, ipsq_split
13637c478bd9Sstevel@tonic-gate  *
13647c478bd9Sstevel@tonic-gate  *	ipsq_pending_ipif, ipsq_current_ipif, ipsq_pending_mp, ipsq_flags,
13657c478bd9Sstevel@tonic-gate  *	ipsq_waitfor
13667c478bd9Sstevel@tonic-gate  *
13677c478bd9Sstevel@tonic-gate  * The fields in the last line above below are set mostly by a writer thread
13687c478bd9Sstevel@tonic-gate  * But there is an exception in the last call to ipif_ill_refrele_tail which
13697c478bd9Sstevel@tonic-gate  * could also race with a conn close which could be cleaning up the
13707c478bd9Sstevel@tonic-gate  * fields. So we choose to protect using ipsq_lock instead of depending on
13717c478bd9Sstevel@tonic-gate  * the property of the writer.
13727c478bd9Sstevel@tonic-gate  * ill_g_lock protects
13737c478bd9Sstevel@tonic-gate  *	ipsq_refs, ipsq_phyint_list
13747c478bd9Sstevel@tonic-gate  */
13757c478bd9Sstevel@tonic-gate typedef struct ipsq_s {
13767c478bd9Sstevel@tonic-gate 	kmutex_t ipsq_lock;
13777c478bd9Sstevel@tonic-gate 	int	ipsq_reentry_cnt;
13787c478bd9Sstevel@tonic-gate 	kthread_t	*ipsq_writer;	/* current owner (thread id) */
13797c478bd9Sstevel@tonic-gate 	int	ipsq_flags;
13807c478bd9Sstevel@tonic-gate 	mblk_t	*ipsq_xopq_mphead;	/* list of excl ops mostly ioctls */
13817c478bd9Sstevel@tonic-gate 	mblk_t	*ipsq_xopq_mptail;
13827c478bd9Sstevel@tonic-gate 	mblk_t	*ipsq_mphead;		/* msgs on ipsq linked thru b_next */
13837c478bd9Sstevel@tonic-gate 	mblk_t	*ipsq_mptail;		/* msgs on ipsq linked thru b_next */
13847c478bd9Sstevel@tonic-gate 	ipif_t	*ipsq_pending_ipif;	/* ipif associated w. ipsq_pending_mp */
13857c478bd9Sstevel@tonic-gate 	ipif_t	*ipsq_current_ipif;	/* ipif associated with current ioctl */
13867c478bd9Sstevel@tonic-gate 	mblk_t	*ipsq_pending_mp;	/* current ioctl mp while waiting for */
13877c478bd9Sstevel@tonic-gate 					/* response from another module */
13887c478bd9Sstevel@tonic-gate 	struct	ipsq_s	*ipsq_next;	/* list of all syncq's (ipsq_g_list) */
13897c478bd9Sstevel@tonic-gate 	uint_t		ipsq_refs;	/* Number of phyints on this ipsq */
13907c478bd9Sstevel@tonic-gate 	struct phyint	*ipsq_phyint_list; /* List of phyints on this ipsq */
13917c478bd9Sstevel@tonic-gate 	boolean_t	ipsq_split;	/* ipsq may need to be split */
13927c478bd9Sstevel@tonic-gate 	int		ipsq_waitfor;	/* Values encoded below */
13937c478bd9Sstevel@tonic-gate 	char		ipsq_name[LIFNAMSIZ+1];	/* same as phyint_groupname */
13947c478bd9Sstevel@tonic-gate 	int		ipsq_last_cmd;	/* debugging aid */
13957c478bd9Sstevel@tonic-gate #ifdef ILL_DEBUG
13967c478bd9Sstevel@tonic-gate 	int		ipsq_depth;	/* debugging aid */
13977c478bd9Sstevel@tonic-gate 	pc_t		ipsq_stack[IP_STACK_DEPTH];	/* debugging aid */
13987c478bd9Sstevel@tonic-gate #endif
13997c478bd9Sstevel@tonic-gate } ipsq_t;
14007c478bd9Sstevel@tonic-gate 
14017c478bd9Sstevel@tonic-gate /* ipsq_flags */
14027c478bd9Sstevel@tonic-gate #define	IPSQ_GROUP	0x1	/* This ipsq belongs to an IPMP group */
14037c478bd9Sstevel@tonic-gate 
14047c478bd9Sstevel@tonic-gate /*
14057c478bd9Sstevel@tonic-gate  * ipsq_waitfor:
14067c478bd9Sstevel@tonic-gate  *
14077c478bd9Sstevel@tonic-gate  * IPIF_DOWN	1	ipif_down waiting for refcnts to drop
14087c478bd9Sstevel@tonic-gate  * ILL_DOWN	2	ill_down waiting for refcnts to drop
14097c478bd9Sstevel@tonic-gate  * IPIF_FREE	3	ipif_free waiting for refcnts to drop
14107c478bd9Sstevel@tonic-gate  * ILL_FREE	4	ill unplumb waiting for refcnts to drop
14117c478bd9Sstevel@tonic-gate  * ILL_MOVE_OK	5	failover waiting for refcnts to drop
14127c478bd9Sstevel@tonic-gate  */
14137c478bd9Sstevel@tonic-gate 
14147c478bd9Sstevel@tonic-gate enum { IPIF_DOWN = 1, ILL_DOWN, IPIF_FREE, ILL_FREE, ILL_MOVE_OK };
14157c478bd9Sstevel@tonic-gate 
14167c478bd9Sstevel@tonic-gate /* Flags passed to ipsq_try_enter */
14177c478bd9Sstevel@tonic-gate #define	CUR_OP 0		/* Current ioctl continuing again */
14187c478bd9Sstevel@tonic-gate #define	NEW_OP 1		/* New ioctl starting afresh */
14197c478bd9Sstevel@tonic-gate 
14207c478bd9Sstevel@tonic-gate /*
14217c478bd9Sstevel@tonic-gate  * phyint represents state that is common to both IPv4 and IPv6 interfaces.
14227c478bd9Sstevel@tonic-gate  * There is a separate ill_t representing IPv4 and IPv6 which has a
14237c478bd9Sstevel@tonic-gate  * backpointer to the phyint structure for acessing common state.
14247c478bd9Sstevel@tonic-gate  *
14257c478bd9Sstevel@tonic-gate  * NOTE : It just stores the group name as there is only one name for
14267c478bd9Sstevel@tonic-gate  *	  IPv4 and IPv6 i.e it is a underlying link property. Actually
14277c478bd9Sstevel@tonic-gate  *        IPv4 and IPv6 ill are grouped together when their phyints have
14287c478bd9Sstevel@tonic-gate  *        the same name.
14297c478bd9Sstevel@tonic-gate  */
14307c478bd9Sstevel@tonic-gate typedef struct phyint {
14317c478bd9Sstevel@tonic-gate 	struct ill_s	*phyint_illv4;
14327c478bd9Sstevel@tonic-gate 	struct ill_s	*phyint_illv6;
14337c478bd9Sstevel@tonic-gate 	uint_t		phyint_ifindex;		/* SIOCLSLIFINDEX */
14347c478bd9Sstevel@tonic-gate 	uint_t		phyint_notify_delay;	/* SIOCSLIFNOTIFYDELAY */
14357c478bd9Sstevel@tonic-gate 	char		*phyint_groupname;	/* SIOCSLIFGROUPNAME */
14367c478bd9Sstevel@tonic-gate 	uint_t		phyint_groupname_len;
14377c478bd9Sstevel@tonic-gate 	uint64_t	phyint_flags;
14387c478bd9Sstevel@tonic-gate 	avl_node_t	phyint_avl_by_index;	/* avl tree by index */
14397c478bd9Sstevel@tonic-gate 	avl_node_t	phyint_avl_by_name;	/* avl tree by name */
14407c478bd9Sstevel@tonic-gate 	kmutex_t	phyint_lock;
14417c478bd9Sstevel@tonic-gate 	struct ipsq_s	*phyint_ipsq;		/* back pointer to ipsq */
14427c478bd9Sstevel@tonic-gate 	struct phyint	*phyint_ipsq_next;	/* phyint list on this ipsq */
14437c478bd9Sstevel@tonic-gate } phyint_t;
14447c478bd9Sstevel@tonic-gate 
14457c478bd9Sstevel@tonic-gate #define	CACHE_ALIGN_SIZE 64
14467c478bd9Sstevel@tonic-gate 
14477c478bd9Sstevel@tonic-gate #define	CACHE_ALIGN(align_struct)	P2ROUNDUP(sizeof (struct align_struct),\
14487c478bd9Sstevel@tonic-gate 							CACHE_ALIGN_SIZE)
14497c478bd9Sstevel@tonic-gate struct _phyint_list_s_ {
14507c478bd9Sstevel@tonic-gate 	avl_tree_t	phyint_list_avl_by_index;	/* avl tree by index */
14517c478bd9Sstevel@tonic-gate 	avl_tree_t	phyint_list_avl_by_name;	/* avl tree by name */
14527c478bd9Sstevel@tonic-gate };
14537c478bd9Sstevel@tonic-gate 
14547c478bd9Sstevel@tonic-gate typedef union phyint_list_u {
14557c478bd9Sstevel@tonic-gate 	struct	_phyint_list_s_ phyint_list_s;
14567c478bd9Sstevel@tonic-gate 	char	phyint_list_filler[CACHE_ALIGN(_phyint_list_s_)];
14577c478bd9Sstevel@tonic-gate } phyint_list_t;
14587c478bd9Sstevel@tonic-gate 
14597c478bd9Sstevel@tonic-gate #define	phyint_list_avl_by_index	phyint_list_s.phyint_list_avl_by_index
14607c478bd9Sstevel@tonic-gate #define	phyint_list_avl_by_name		phyint_list_s.phyint_list_avl_by_name
14617c478bd9Sstevel@tonic-gate /*
14627c478bd9Sstevel@tonic-gate  * ILL groups. We group ills,
14637c478bd9Sstevel@tonic-gate  *
14647c478bd9Sstevel@tonic-gate  * - if the ills have the same group name. (New way)
14657c478bd9Sstevel@tonic-gate  *
14667c478bd9Sstevel@tonic-gate  * ill_group locking notes:
14677c478bd9Sstevel@tonic-gate  *
14687c478bd9Sstevel@tonic-gate  * illgrp_lock protects ill_grp_ill_schednext.
14697c478bd9Sstevel@tonic-gate  *
14707c478bd9Sstevel@tonic-gate  * ill_g_lock protects ill_grp_next, illgrp_ill, illgrp_ill_count.
14717c478bd9Sstevel@tonic-gate  * Holding ill_g_lock freezes the memberships of ills in IPMP groups.
14727c478bd9Sstevel@tonic-gate  * It also freezes the global list of ills and all ipifs in all ills.
14737c478bd9Sstevel@tonic-gate  *
14747c478bd9Sstevel@tonic-gate  * To remove an ipif from the linked list of ipifs of that ill ipif_free_tail
14757c478bd9Sstevel@tonic-gate  * holds both ill_g_lock, and ill_lock. Similarly to remove an ill from the
14767c478bd9Sstevel@tonic-gate  * global list of ills, ill_delete_glist holds ill_g_lock as writer.
14777c478bd9Sstevel@tonic-gate  * This simplifies things for ipif_select_source, illgrp_scheduler etc.
14787c478bd9Sstevel@tonic-gate  * that need to walk the members of an illgrp. They just hold ill_g_lock
14797c478bd9Sstevel@tonic-gate  * as reader to do the walk.
14807c478bd9Sstevel@tonic-gate  *
14817c478bd9Sstevel@tonic-gate  */
14827c478bd9Sstevel@tonic-gate typedef	struct ill_group {
14837c478bd9Sstevel@tonic-gate 	kmutex_t	illgrp_lock;
14847c478bd9Sstevel@tonic-gate 	struct ill_group *illgrp_next;		/* Next ill_group */
14857c478bd9Sstevel@tonic-gate 	struct ill_s	*illgrp_ill_schednext;	/* Next ill to be scheduled */
14867c478bd9Sstevel@tonic-gate 	struct ill_s	*illgrp_ill;		/* First ill in the group */
14877c478bd9Sstevel@tonic-gate 	int		illgrp_ill_count;
14887c478bd9Sstevel@tonic-gate } ill_group_t;
14897c478bd9Sstevel@tonic-gate 
14907c478bd9Sstevel@tonic-gate extern	ill_group_t	*illgrp_head_v6;
14917c478bd9Sstevel@tonic-gate 
14927c478bd9Sstevel@tonic-gate /*
14937c478bd9Sstevel@tonic-gate  * Fragmentation hash bucket
14947c478bd9Sstevel@tonic-gate  */
14957c478bd9Sstevel@tonic-gate typedef struct ipfb_s {
14967c478bd9Sstevel@tonic-gate 	struct ipf_s	*ipfb_ipf;	/* List of ... */
14977c478bd9Sstevel@tonic-gate 	size_t		ipfb_count;	/* Count of bytes used by frag(s) */
14987c478bd9Sstevel@tonic-gate 	kmutex_t	ipfb_lock;	/* Protect all ipf in list */
14997c478bd9Sstevel@tonic-gate 	uint_t		ipfb_frag_pkts; /* num of distinct fragmented pkts */
15007c478bd9Sstevel@tonic-gate } ipfb_t;
15017c478bd9Sstevel@tonic-gate 
15027c478bd9Sstevel@tonic-gate /*
15037c478bd9Sstevel@tonic-gate  * IRE bucket structure. Usually there is an array of such structures,
15047c478bd9Sstevel@tonic-gate  * each pointing to a linked list of ires. irb_refcnt counts the number
15057c478bd9Sstevel@tonic-gate  * of walkers of a given hash bucket. Usually the reference count is
15067c478bd9Sstevel@tonic-gate  * bumped up if the walker wants no IRES to be DELETED while walking the
15077c478bd9Sstevel@tonic-gate  * list. Bumping up does not PREVENT ADDITION. This allows walking a given
15087c478bd9Sstevel@tonic-gate  * hash bucket without stumbling up on a free pointer.
15097c478bd9Sstevel@tonic-gate  */
15107c478bd9Sstevel@tonic-gate typedef struct irb {
15117c478bd9Sstevel@tonic-gate 	struct ire_s	*irb_ire;	/* First ire in this bucket */
15127c478bd9Sstevel@tonic-gate 					/* Should be first in this struct */
15137c478bd9Sstevel@tonic-gate 	krwlock_t	irb_lock;	/* Protect this bucket */
15147c478bd9Sstevel@tonic-gate 	uint_t		irb_refcnt;	/* Protected by irb_lock */
15157c478bd9Sstevel@tonic-gate 	uchar_t		irb_marks;	/* CONDEMNED ires in this bucket ? */
15167c478bd9Sstevel@tonic-gate 	uint_t		irb_ire_cnt;	/* Num of IRE in this bucket */
15177c478bd9Sstevel@tonic-gate 	uint_t		irb_tmp_ire_cnt; /* Num of temporary IRE */
15187c478bd9Sstevel@tonic-gate } irb_t;
15197c478bd9Sstevel@tonic-gate 
15207c478bd9Sstevel@tonic-gate #define	IP_V4_G_HEAD	0
15217c478bd9Sstevel@tonic-gate #define	IP_V6_G_HEAD	1
15227c478bd9Sstevel@tonic-gate 
15237c478bd9Sstevel@tonic-gate #define	MAX_G_HEADS	2
15247c478bd9Sstevel@tonic-gate 
15257c478bd9Sstevel@tonic-gate /*
15267c478bd9Sstevel@tonic-gate  * unpadded ill_if structure
15277c478bd9Sstevel@tonic-gate  */
15287c478bd9Sstevel@tonic-gate struct 	_ill_if_s_ {
15297c478bd9Sstevel@tonic-gate 	union ill_if_u	*illif_next;
15307c478bd9Sstevel@tonic-gate 	union ill_if_u	*illif_prev;
15317c478bd9Sstevel@tonic-gate 	avl_tree_t	illif_avl_by_ppa;	/* AVL tree sorted on ppa */
15327c478bd9Sstevel@tonic-gate 	vmem_t		*illif_ppa_arena;	/* ppa index space */
15337c478bd9Sstevel@tonic-gate 	uint16_t	illif_mcast_v1;		/* hints for		  */
15347c478bd9Sstevel@tonic-gate 	uint16_t	illif_mcast_v2;		/* [igmp|mld]_slowtimo	  */
15357c478bd9Sstevel@tonic-gate 	int		illif_name_len;		/* name length */
15367c478bd9Sstevel@tonic-gate 	char		illif_name[LIFNAMSIZ];	/* name of interface type */
15377c478bd9Sstevel@tonic-gate };
15387c478bd9Sstevel@tonic-gate 
15397c478bd9Sstevel@tonic-gate /* cache aligned ill_if structure */
15407c478bd9Sstevel@tonic-gate typedef union 	ill_if_u {
15417c478bd9Sstevel@tonic-gate 	struct  _ill_if_s_ ill_if_s;
15427c478bd9Sstevel@tonic-gate 	char 	illif_filler[CACHE_ALIGN(_ill_if_s_)];
15437c478bd9Sstevel@tonic-gate } ill_if_t;
15447c478bd9Sstevel@tonic-gate 
15457c478bd9Sstevel@tonic-gate 
15467c478bd9Sstevel@tonic-gate #define	illif_next		ill_if_s.illif_next
15477c478bd9Sstevel@tonic-gate #define	illif_prev		ill_if_s.illif_prev
15487c478bd9Sstevel@tonic-gate #define	illif_avl_by_ppa	ill_if_s.illif_avl_by_ppa
15497c478bd9Sstevel@tonic-gate #define	illif_ppa_arena		ill_if_s.illif_ppa_arena
15507c478bd9Sstevel@tonic-gate #define	illif_mcast_v1		ill_if_s.illif_mcast_v1
15517c478bd9Sstevel@tonic-gate #define	illif_mcast_v2		ill_if_s.illif_mcast_v2
15527c478bd9Sstevel@tonic-gate #define	illif_name		ill_if_s.illif_name
15537c478bd9Sstevel@tonic-gate #define	illif_name_len		ill_if_s.illif_name_len
15547c478bd9Sstevel@tonic-gate 
15557c478bd9Sstevel@tonic-gate typedef struct ill_walk_context_s {
15567c478bd9Sstevel@tonic-gate 	int	ctx_current_list; /* current list being searched */
15577c478bd9Sstevel@tonic-gate 	int	ctx_last_list;	 /* last list to search */
15587c478bd9Sstevel@tonic-gate } ill_walk_context_t;
15597c478bd9Sstevel@tonic-gate 
15607c478bd9Sstevel@tonic-gate /*
15617c478bd9Sstevel@tonic-gate  * ill_gheads structure, one for IPV4 and one for IPV6
15627c478bd9Sstevel@tonic-gate  */
15637c478bd9Sstevel@tonic-gate struct _ill_g_head_s_ {
15647c478bd9Sstevel@tonic-gate 	ill_if_t	*ill_g_list_head;
15657c478bd9Sstevel@tonic-gate 	ill_if_t	*ill_g_list_tail;
15667c478bd9Sstevel@tonic-gate };
15677c478bd9Sstevel@tonic-gate 
15687c478bd9Sstevel@tonic-gate typedef union ill_g_head_u {
15697c478bd9Sstevel@tonic-gate 	struct _ill_g_head_s_ ill_g_head_s;
15707c478bd9Sstevel@tonic-gate 	char	ill_g_head_filler[CACHE_ALIGN(_ill_g_head_s_)];
15717c478bd9Sstevel@tonic-gate } ill_g_head_t;
15727c478bd9Sstevel@tonic-gate 
15737c478bd9Sstevel@tonic-gate #define	ill_g_list_head	ill_g_head_s.ill_g_list_head
15747c478bd9Sstevel@tonic-gate #define	ill_g_list_tail	ill_g_head_s.ill_g_list_tail
15757c478bd9Sstevel@tonic-gate 
15767c478bd9Sstevel@tonic-gate #pragma align CACHE_ALIGN_SIZE(ill_g_heads)
15777c478bd9Sstevel@tonic-gate extern ill_g_head_t	ill_g_heads[];	/* ILL List Head */
15787c478bd9Sstevel@tonic-gate 
15797c478bd9Sstevel@tonic-gate 
15807c478bd9Sstevel@tonic-gate #define	IP_V4_ILL_G_LIST	ill_g_heads[IP_V4_G_HEAD].ill_g_list_head
15817c478bd9Sstevel@tonic-gate #define	IP_V6_ILL_G_LIST	ill_g_heads[IP_V6_G_HEAD].ill_g_list_head
15827c478bd9Sstevel@tonic-gate #define	IP_VX_ILL_G_LIST(i)	ill_g_heads[i].ill_g_list_head
15837c478bd9Sstevel@tonic-gate 
15847c478bd9Sstevel@tonic-gate #define	ILL_START_WALK_V4(ctx_ptr)	ill_first(IP_V4_G_HEAD, IP_V4_G_HEAD, \
15857c478bd9Sstevel@tonic-gate 					ctx_ptr)
15867c478bd9Sstevel@tonic-gate #define	ILL_START_WALK_V6(ctx_ptr)	ill_first(IP_V6_G_HEAD, IP_V6_G_HEAD, \
15877c478bd9Sstevel@tonic-gate 					ctx_ptr)
15887c478bd9Sstevel@tonic-gate #define	ILL_START_WALK_ALL(ctx_ptr)	ill_first(MAX_G_HEADS, MAX_G_HEADS, \
15897c478bd9Sstevel@tonic-gate 					ctx_ptr)
15907c478bd9Sstevel@tonic-gate 
15917c478bd9Sstevel@tonic-gate /*
15927c478bd9Sstevel@tonic-gate  * Capabilities, possible flags for ill_capabilities.
15937c478bd9Sstevel@tonic-gate  */
15947c478bd9Sstevel@tonic-gate 
15957c478bd9Sstevel@tonic-gate #define	ILL_CAPAB_AH		0x01		/* IPsec AH acceleration */
15967c478bd9Sstevel@tonic-gate #define	ILL_CAPAB_ESP		0x02		/* IPsec ESP acceleration */
15977c478bd9Sstevel@tonic-gate #define	ILL_CAPAB_MDT		0x04		/* Multidata Transmit */
15987c478bd9Sstevel@tonic-gate #define	ILL_CAPAB_HCKSUM	0x08		/* Hardware checksumming */
15997c478bd9Sstevel@tonic-gate #define	ILL_CAPAB_ZEROCOPY	0x10		/* Zero-copy */
16007c478bd9Sstevel@tonic-gate #define	ILL_CAPAB_POLL		0x20		/* Polling Toggle */
16014b46d1efSkrgopi #define	ILL_CAPAB_SOFT_RING	0x40		/* Soft_Ring capability */
16027c478bd9Sstevel@tonic-gate 
16037c478bd9Sstevel@tonic-gate /*
16047c478bd9Sstevel@tonic-gate  * Per-ill Multidata Transmit capabilities.
16057c478bd9Sstevel@tonic-gate  */
16067c478bd9Sstevel@tonic-gate typedef struct ill_mdt_capab_s ill_mdt_capab_t;
16077c478bd9Sstevel@tonic-gate 
16087c478bd9Sstevel@tonic-gate /*
16097c478bd9Sstevel@tonic-gate  * Per-ill IPsec capabilities.
16107c478bd9Sstevel@tonic-gate  */
16117c478bd9Sstevel@tonic-gate typedef struct ill_ipsec_capab_s ill_ipsec_capab_t;
16127c478bd9Sstevel@tonic-gate 
16137c478bd9Sstevel@tonic-gate /*
16147c478bd9Sstevel@tonic-gate  * Per-ill Hardware Checksumming capbilities.
16157c478bd9Sstevel@tonic-gate  */
16167c478bd9Sstevel@tonic-gate typedef struct ill_hcksum_capab_s ill_hcksum_capab_t;
16177c478bd9Sstevel@tonic-gate 
16187c478bd9Sstevel@tonic-gate /*
16197c478bd9Sstevel@tonic-gate  * Per-ill Zero-copy capabilities.
16207c478bd9Sstevel@tonic-gate  */
16217c478bd9Sstevel@tonic-gate typedef struct ill_zerocopy_capab_s ill_zerocopy_capab_t;
16227c478bd9Sstevel@tonic-gate 
16237c478bd9Sstevel@tonic-gate /*
16244b46d1efSkrgopi  * Per-ill Polling/soft ring capbilities.
16257c478bd9Sstevel@tonic-gate  */
16264b46d1efSkrgopi typedef struct ill_dls_capab_s ill_dls_capab_t;
16277c478bd9Sstevel@tonic-gate 
16287c478bd9Sstevel@tonic-gate /*
16297c478bd9Sstevel@tonic-gate  * Per-ill polling resource map.
16307c478bd9Sstevel@tonic-gate  */
16317c478bd9Sstevel@tonic-gate typedef struct ill_rx_ring ill_rx_ring_t;
16327c478bd9Sstevel@tonic-gate 
16337c478bd9Sstevel@tonic-gate /* The following are ill_state_flags */
16347c478bd9Sstevel@tonic-gate #define	ILL_LL_SUBNET_PENDING	0x01	/* Waiting for DL_INFO_ACK from drv */
16357c478bd9Sstevel@tonic-gate #define	ILL_CONDEMNED		0x02	/* No more new ref's to the ILL */
16367c478bd9Sstevel@tonic-gate #define	ILL_CHANGING		0x04	/* ILL not globally visible */
1637a5e428f7Skrgopi #define	ILL_DL_UNBIND_IN_PROGRESS	0x08	/* UNBIND_REQ is sent */
16384b46d1efSkrgopi #define	ILL_SOFT_RING_ASSIGN	0x10	/* Makeing soft ring assigment */
16397c478bd9Sstevel@tonic-gate 
16407c478bd9Sstevel@tonic-gate /* Is this an ILL whose source address is used by other ILL's ? */
16417c478bd9Sstevel@tonic-gate #define	IS_USESRC_ILL(ill)			\
16427c478bd9Sstevel@tonic-gate 	(((ill)->ill_usesrc_ifindex == 0) &&	\
16435dddb8baSkcpoon 	((ill)->ill_usesrc_grp_next != NULL))
16447c478bd9Sstevel@tonic-gate 
16457c478bd9Sstevel@tonic-gate /* Is this a client/consumer of the usesrc ILL ? */
16467c478bd9Sstevel@tonic-gate #define	IS_USESRC_CLI_ILL(ill)			\
16477c478bd9Sstevel@tonic-gate 	(((ill)->ill_usesrc_ifindex != 0) &&	\
16485dddb8baSkcpoon 	((ill)->ill_usesrc_grp_next != NULL))
16497c478bd9Sstevel@tonic-gate 
16507c478bd9Sstevel@tonic-gate /* Is this an virtual network interface (vni) ILL ? */
16517c478bd9Sstevel@tonic-gate #define	IS_VNI(ill)							\
16527c478bd9Sstevel@tonic-gate 	(((ill) != NULL) && !((ill)->ill_phyint->phyint_flags &		\
16537c478bd9Sstevel@tonic-gate 	PHYI_LOOPBACK) && ((ill)->ill_phyint->phyint_flags &		\
16545dddb8baSkcpoon 	PHYI_VIRTUAL))
16557c478bd9Sstevel@tonic-gate 
16567c478bd9Sstevel@tonic-gate /*
16577c478bd9Sstevel@tonic-gate  * IP Lower level Structure.
16587c478bd9Sstevel@tonic-gate  * Instance data structure in ip_open when there is a device below us.
16597c478bd9Sstevel@tonic-gate  */
16607c478bd9Sstevel@tonic-gate typedef struct ill_s {
16617c478bd9Sstevel@tonic-gate 	ill_if_t *ill_ifptr;		/* pointer to interface type */
16627c478bd9Sstevel@tonic-gate 	queue_t	*ill_rq;		/* Read queue. */
16637c478bd9Sstevel@tonic-gate 	queue_t	*ill_wq;		/* Write queue. */
16647c478bd9Sstevel@tonic-gate 
16657c478bd9Sstevel@tonic-gate 	int	ill_error;		/* Error value sent up by device. */
16667c478bd9Sstevel@tonic-gate 
16677c478bd9Sstevel@tonic-gate 	ipif_t	*ill_ipif;		/* Interface chain for this ILL. */
16687c478bd9Sstevel@tonic-gate 
16697c478bd9Sstevel@tonic-gate 	uint_t	ill_ipif_up_count;	/* Number of IPIFs currently up. */
16707c478bd9Sstevel@tonic-gate 	uint_t	ill_max_frag;		/* Max IDU from DLPI. */
16717c478bd9Sstevel@tonic-gate 	char	*ill_name;		/* Our name. */
16727c478bd9Sstevel@tonic-gate 	uint_t	ill_name_length;	/* Name length, incl. terminator. */
16737c478bd9Sstevel@tonic-gate 	char	*ill_ndd_name;		/* Name + ":ip?_forwarding" for NDD. */
16747c478bd9Sstevel@tonic-gate 	uint_t	ill_net_type;		/* IRE_IF_RESOLVER/IRE_IF_NORESOLVER. */
16757c478bd9Sstevel@tonic-gate 	/*
16767c478bd9Sstevel@tonic-gate 	 * Physical Point of Attachment num.  If DLPI style 1 provider
16777c478bd9Sstevel@tonic-gate 	 * then this is derived from the devname.
16787c478bd9Sstevel@tonic-gate 	 */
16797c478bd9Sstevel@tonic-gate 	uint_t	ill_ppa;
16807c478bd9Sstevel@tonic-gate 	t_uscalar_t	ill_sap;
16817c478bd9Sstevel@tonic-gate 	t_scalar_t	ill_sap_length;	/* Including sign (for position) */
16827c478bd9Sstevel@tonic-gate 	uint_t	ill_phys_addr_length;	/* Excluding the sap. */
16837c478bd9Sstevel@tonic-gate 	uint_t	ill_bcast_addr_length;	/* Only set when the DL provider */
16847c478bd9Sstevel@tonic-gate 					/* supports broadcast. */
16857c478bd9Sstevel@tonic-gate 	t_uscalar_t	ill_mactype;
16867c478bd9Sstevel@tonic-gate 	uint8_t	*ill_frag_ptr;		/* Reassembly state. */
16877c478bd9Sstevel@tonic-gate 	timeout_id_t ill_frag_timer_id; /* timeout id for the frag timer */
16887c478bd9Sstevel@tonic-gate 	ipfb_t	*ill_frag_hash_tbl;	/* Fragment hash list head. */
16897c478bd9Sstevel@tonic-gate 	ipif_t	*ill_pending_ipif;	/* IPIF waiting for DL operation. */
16907c478bd9Sstevel@tonic-gate 
16917c478bd9Sstevel@tonic-gate 	ilm_t	*ill_ilm;		/* Multicast mebership for lower ill */
16927c478bd9Sstevel@tonic-gate 	uint_t	ill_global_timer;	/* for IGMPv3/MLDv2 general queries */
16937c478bd9Sstevel@tonic-gate 	int	ill_mcast_type;		/* type of router which is querier */
16947c478bd9Sstevel@tonic-gate 					/* on this interface */
16957c478bd9Sstevel@tonic-gate 	uint16_t ill_mcast_v1_time;	/* # slow timeouts since last v1 qry */
16967c478bd9Sstevel@tonic-gate 	uint16_t ill_mcast_v2_time;	/* # slow timeouts since last v2 qry */
16977c478bd9Sstevel@tonic-gate 	uint8_t	ill_mcast_v1_tset;	/* 1 => timer is set; 0 => not set */
16987c478bd9Sstevel@tonic-gate 	uint8_t	ill_mcast_v2_tset;	/* 1 => timer is set; 0 => not set */
16997c478bd9Sstevel@tonic-gate 
17007c478bd9Sstevel@tonic-gate 	uint8_t	ill_mcast_rv;		/* IGMPv3/MLDv2 robustness variable */
17017c478bd9Sstevel@tonic-gate 	int	ill_mcast_qi;		/* IGMPv3/MLDv2 query interval var */
17027c478bd9Sstevel@tonic-gate 
17037c478bd9Sstevel@tonic-gate 	mblk_t	*ill_pending_mp;	/* IOCTL/DLPI awaiting completion. */
17047c478bd9Sstevel@tonic-gate 	/*
17057c478bd9Sstevel@tonic-gate 	 * All non-NULL cells between 'ill_first_mp_to_free' and
17067c478bd9Sstevel@tonic-gate 	 * 'ill_last_mp_to_free' are freed in ill_delete.
17077c478bd9Sstevel@tonic-gate 	 */
17087c478bd9Sstevel@tonic-gate #define	ill_first_mp_to_free	ill_bcast_mp
17097c478bd9Sstevel@tonic-gate 	mblk_t	*ill_bcast_mp;		/* DLPI header for broadcasts. */
17107c478bd9Sstevel@tonic-gate 	mblk_t	*ill_resolver_mp;	/* Resolver template. */
17117c478bd9Sstevel@tonic-gate 	mblk_t	*ill_detach_mp;		/* detach mp, or NULL if style1 */
17127c478bd9Sstevel@tonic-gate 	mblk_t	*ill_unbind_mp;		/* unbind mp from ill_dl_up() */
17137c478bd9Sstevel@tonic-gate 	mblk_t	*ill_dlpi_deferred;	/* b_next chain of control messages */
17147c478bd9Sstevel@tonic-gate 	mblk_t	*ill_phys_addr_mp;	/* mblk which holds ill_phys_addr */
17157c478bd9Sstevel@tonic-gate #define	ill_last_mp_to_free	ill_phys_addr_mp
17167c478bd9Sstevel@tonic-gate 
17177c478bd9Sstevel@tonic-gate 	cred_t	*ill_credp;		/* opener's credentials */
17187c478bd9Sstevel@tonic-gate 	uint8_t	*ill_phys_addr;		/* ill_phys_addr_mp->b_rptr + off */
17197c478bd9Sstevel@tonic-gate 
17207c478bd9Sstevel@tonic-gate 	uint_t	ill_state_flags;	/* see ILL_* flags above */
17217c478bd9Sstevel@tonic-gate 
17227c478bd9Sstevel@tonic-gate 	/* Following bit fields protected by ipsq_t */
17237c478bd9Sstevel@tonic-gate 	uint_t
17247c478bd9Sstevel@tonic-gate 		ill_needs_attach : 1,
17257c478bd9Sstevel@tonic-gate 		ill_reserved : 1,
17267c478bd9Sstevel@tonic-gate 		ill_isv6 : 1,
17277c478bd9Sstevel@tonic-gate 		ill_dlpi_style_set : 1,
17287c478bd9Sstevel@tonic-gate 
17297c478bd9Sstevel@tonic-gate 		ill_ifname_pending : 1,
17307c478bd9Sstevel@tonic-gate 		ill_move_in_progress : 1, /* FAILOVER/FAILBACK in progress */
17317c478bd9Sstevel@tonic-gate 		ill_join_allmulti : 1,
17327c478bd9Sstevel@tonic-gate 		ill_logical_down : 1,
17337c478bd9Sstevel@tonic-gate 
17347c478bd9Sstevel@tonic-gate 		ill_is_6to4tun : 1,	/* Interface is a 6to4 tunnel */
17357c478bd9Sstevel@tonic-gate 		ill_promisc_on_phys : 1, /* phys interface in promisc mode */
17367c478bd9Sstevel@tonic-gate 		ill_dl_up : 1,
17377c478bd9Sstevel@tonic-gate 		ill_up_ipifs : 1,
17387c478bd9Sstevel@tonic-gate 
17397c478bd9Sstevel@tonic-gate 		ill_pad_to_bit_31 : 20;
17407c478bd9Sstevel@tonic-gate 
17417c478bd9Sstevel@tonic-gate 	/* Following bit fields protected by ill_lock */
17427c478bd9Sstevel@tonic-gate 	uint_t
17437c478bd9Sstevel@tonic-gate 		ill_fragtimer_executing : 1,
17447c478bd9Sstevel@tonic-gate 		ill_fragtimer_needrestart : 1,
17457c478bd9Sstevel@tonic-gate 		ill_ilm_cleanup_reqd : 1,
17467c478bd9Sstevel@tonic-gate 		ill_arp_closing : 1,
17477c478bd9Sstevel@tonic-gate 
17487c478bd9Sstevel@tonic-gate 		ill_arp_bringup_pending : 1,
17497c478bd9Sstevel@tonic-gate 		ill_mtu_userspecified : 1, /* SIOCSLNKINFO has set the mtu */
17507c478bd9Sstevel@tonic-gate 		ill_pad_bit_31 : 26;
17517c478bd9Sstevel@tonic-gate 
17527c478bd9Sstevel@tonic-gate 	/*
17537c478bd9Sstevel@tonic-gate 	 * Used in SIOCSIFMUXID and SIOCGIFMUXID for 'ifconfig unplumb'.
17547c478bd9Sstevel@tonic-gate 	 */
17557c478bd9Sstevel@tonic-gate 	int	ill_arp_muxid;		/* muxid returned from plink for arp */
17567c478bd9Sstevel@tonic-gate 	int	ill_ip_muxid;		/* muxid returned from plink for ip */
17577c478bd9Sstevel@tonic-gate 
17587c478bd9Sstevel@tonic-gate 	/*
17597c478bd9Sstevel@tonic-gate 	 * Used for IP frag reassembly throttling on a per ILL basis.
17607c478bd9Sstevel@tonic-gate 	 *
17617c478bd9Sstevel@tonic-gate 	 * Note: frag_count is approximate, its added to and subtracted from
17627c478bd9Sstevel@tonic-gate 	 *	 without any locking, so simultaneous load/modify/stores can
17637c478bd9Sstevel@tonic-gate 	 *	 collide, also ill_frag_purge() recalculates its value by
17647c478bd9Sstevel@tonic-gate 	 *	 summing all the ipfb_count's without locking out updates
17657c478bd9Sstevel@tonic-gate 	 *	 to the ipfb's.
17667c478bd9Sstevel@tonic-gate 	 */
17677c478bd9Sstevel@tonic-gate 	uint_t	ill_ipf_gen;		/* Generation of next fragment queue */
17687c478bd9Sstevel@tonic-gate 	uint_t	ill_frag_count;		/* Approx count of all mblk bytes */
17697c478bd9Sstevel@tonic-gate 	uint_t	ill_frag_free_num_pkts;	 /* num of fragmented packets to free */
17707c478bd9Sstevel@tonic-gate 	clock_t	ill_last_frag_clean_time; /* time when frag's were pruned */
17717c478bd9Sstevel@tonic-gate 	int	ill_type;		/* From <net/if_types.h> */
17727c478bd9Sstevel@tonic-gate 	uint_t	ill_dlpi_multicast_state;	/* See below IDMS_* */
17737c478bd9Sstevel@tonic-gate 	uint_t	ill_dlpi_fastpath_state;	/* See below IDMS_* */
17747c478bd9Sstevel@tonic-gate 
17757c478bd9Sstevel@tonic-gate 	/*
17767c478bd9Sstevel@tonic-gate 	 * Capabilities related fields.
17777c478bd9Sstevel@tonic-gate 	 */
17787c478bd9Sstevel@tonic-gate 	uint_t  ill_capab_state;	/* State of capability query, IDMS_* */
17797c478bd9Sstevel@tonic-gate 	uint64_t ill_capabilities;	/* Enabled capabilities, ILL_CAPAB_* */
17807c478bd9Sstevel@tonic-gate 	ill_mdt_capab_t	*ill_mdt_capab;	/* Multidata Transmit capabilities */
17817c478bd9Sstevel@tonic-gate 	ill_ipsec_capab_t *ill_ipsec_capab_ah;	/* IPsec AH capabilities */
17827c478bd9Sstevel@tonic-gate 	ill_ipsec_capab_t *ill_ipsec_capab_esp;	/* IPsec ESP capabilities */
17837c478bd9Sstevel@tonic-gate 	ill_hcksum_capab_t *ill_hcksum_capab; /* H/W cksumming capabilities */
17847c478bd9Sstevel@tonic-gate 	ill_zerocopy_capab_t *ill_zerocopy_capab; /* Zero-copy capabilities */
17854b46d1efSkrgopi 	ill_dls_capab_t *ill_dls_capab; /* Polling, soft ring capabilities */
17867c478bd9Sstevel@tonic-gate 
17877c478bd9Sstevel@tonic-gate 	/*
17887c478bd9Sstevel@tonic-gate 	 * New fields for IPv6
17897c478bd9Sstevel@tonic-gate 	 */
17907c478bd9Sstevel@tonic-gate 	uint8_t	ill_max_hops;	/* Maximum hops for any logical interface */
17917c478bd9Sstevel@tonic-gate 	uint_t	ill_max_mtu;	/* Maximum MTU for any logical interface */
17927c478bd9Sstevel@tonic-gate 	uint32_t ill_reachable_time;	/* Value for ND algorithm in msec */
17937c478bd9Sstevel@tonic-gate 	uint32_t ill_reachable_retrans_time; /* Value for ND algorithm msec */
17947c478bd9Sstevel@tonic-gate 	uint_t	ill_max_buf;		/* Max # of req to buffer for ND */
17957c478bd9Sstevel@tonic-gate 	in6_addr_t	ill_token;
17967c478bd9Sstevel@tonic-gate 	uint_t		ill_token_length;
17977c478bd9Sstevel@tonic-gate 	uint32_t	ill_xmit_count;		/* ndp max multicast xmits */
17987c478bd9Sstevel@tonic-gate 	mib2_ipv6IfStatsEntry_t	*ill_ip6_mib;	/* Per interface mib */
17997c478bd9Sstevel@tonic-gate 	mib2_ipv6IfIcmpEntry_t	*ill_icmp6_mib;	/* Per interface mib */
18007c478bd9Sstevel@tonic-gate 	/*
18017c478bd9Sstevel@tonic-gate 	 * Following two mblks are allocated common to all
18027c478bd9Sstevel@tonic-gate 	 * the ipifs when the first interface is coming up.
18037c478bd9Sstevel@tonic-gate 	 * It is sent up to arp when the last ipif is coming
18047c478bd9Sstevel@tonic-gate 	 * down.
18057c478bd9Sstevel@tonic-gate 	 */
18067c478bd9Sstevel@tonic-gate 	mblk_t			*ill_arp_down_mp;
18077c478bd9Sstevel@tonic-gate 	mblk_t			*ill_arp_del_mapping_mp;
18087c478bd9Sstevel@tonic-gate 	/*
18097c478bd9Sstevel@tonic-gate 	 * Used for implementing IFF_NOARP. As IFF_NOARP is used
18107c478bd9Sstevel@tonic-gate 	 * to turn off for all the logicals, it is here instead
18117c478bd9Sstevel@tonic-gate 	 * of the ipif.
18127c478bd9Sstevel@tonic-gate 	 */
18137c478bd9Sstevel@tonic-gate 	mblk_t			*ill_arp_on_mp;
18147c478bd9Sstevel@tonic-gate 	/* Peer ill of an IPMP move operation */
18157c478bd9Sstevel@tonic-gate 	struct ill_s		*ill_move_peer;
18167c478bd9Sstevel@tonic-gate 
18177c478bd9Sstevel@tonic-gate 	phyint_t		*ill_phyint;
18187c478bd9Sstevel@tonic-gate 	uint64_t		ill_flags;
18197c478bd9Sstevel@tonic-gate 	ill_group_t		*ill_group;
18207c478bd9Sstevel@tonic-gate 	struct ill_s		*ill_group_next;
18217c478bd9Sstevel@tonic-gate 	/*
18227c478bd9Sstevel@tonic-gate 	 * Reverse tunnel related count. This count
18237c478bd9Sstevel@tonic-gate 	 * determines how many mobile nodes are using this
18247c478bd9Sstevel@tonic-gate 	 * ill to send packet to reverse tunnel via foreign
18257c478bd9Sstevel@tonic-gate 	 * agent. A non-zero count specifies presence of
18267c478bd9Sstevel@tonic-gate 	 * mobile node(s) using reverse tunnel through this
18277c478bd9Sstevel@tonic-gate 	 * interface.
18287c478bd9Sstevel@tonic-gate 	 */
18297c478bd9Sstevel@tonic-gate 	uint32_t		ill_mrtun_refcnt;
18307c478bd9Sstevel@tonic-gate 
18317c478bd9Sstevel@tonic-gate 	/*
18327c478bd9Sstevel@tonic-gate 	 * This count is bumped up when a route is added with
18337c478bd9Sstevel@tonic-gate 	 * RTA_SRCIFP bit flag using routing socket.
18347c478bd9Sstevel@tonic-gate 	 */
18357c478bd9Sstevel@tonic-gate 	uint32_t		ill_srcif_refcnt;
18367c478bd9Sstevel@tonic-gate 	/*
18377c478bd9Sstevel@tonic-gate 	 * Pointer to the special interface based routing table.
18387c478bd9Sstevel@tonic-gate 	 * This routing table is created dynamically when RTA_SRCIFP
18397c478bd9Sstevel@tonic-gate 	 * is set by the routing socket.
18407c478bd9Sstevel@tonic-gate 	 */
18417c478bd9Sstevel@tonic-gate 	irb_t			*ill_srcif_table;
18427c478bd9Sstevel@tonic-gate 	kmutex_t	ill_lock;	/* Please see table below */
18437c478bd9Sstevel@tonic-gate 	/*
18447c478bd9Sstevel@tonic-gate 	 * The ill_nd_lla* fields handle the link layer address option
18457c478bd9Sstevel@tonic-gate 	 * from neighbor discovery. This is used for external IPv6
18467c478bd9Sstevel@tonic-gate 	 * address resolution.
18477c478bd9Sstevel@tonic-gate 	 */
18487c478bd9Sstevel@tonic-gate 	mblk_t		*ill_nd_lla_mp;	/* mblk which holds ill_nd_lla */
18497c478bd9Sstevel@tonic-gate 	uint8_t		*ill_nd_lla;	/* Link Layer Address */
18507c478bd9Sstevel@tonic-gate 	uint_t		ill_nd_lla_len;	/* Link Layer Address length */
18517c478bd9Sstevel@tonic-gate 	/*
18527c478bd9Sstevel@tonic-gate 	 * We now have 3 phys_addr_req's sent down. This field keeps track
18537c478bd9Sstevel@tonic-gate 	 * of which one is pending.
18547c478bd9Sstevel@tonic-gate 	 */
18557c478bd9Sstevel@tonic-gate 	t_uscalar_t	ill_phys_addr_pend; /* which dl_phys_addr_req pending */
18567c478bd9Sstevel@tonic-gate 	/*
18577c478bd9Sstevel@tonic-gate 	 * Used to save errors that occur during plumbing
18587c478bd9Sstevel@tonic-gate 	 */
18597c478bd9Sstevel@tonic-gate 	uint_t		ill_ifname_pending_err;
18607c478bd9Sstevel@tonic-gate 	avl_node_t	ill_avl_byppa; /* avl node based on ppa */
18617c478bd9Sstevel@tonic-gate 	void		*ill_fastpath_list; /* both ire and nce hang off this */
18627c478bd9Sstevel@tonic-gate 	uint_t		ill_refcnt;	/* active refcnt by threads */
18637c478bd9Sstevel@tonic-gate 	uint_t		ill_ire_cnt;	/* ires associated with this ill */
18647c478bd9Sstevel@tonic-gate 	kcondvar_t	ill_cv;
18657c478bd9Sstevel@tonic-gate 	uint_t		ill_ilm_walker_cnt;	/* snmp ilm walkers */
18667c478bd9Sstevel@tonic-gate 	uint_t		ill_nce_cnt;	/* nces associated with this ill */
18677c478bd9Sstevel@tonic-gate 	uint_t		ill_waiters;	/* threads waiting in ipsq_enter */
18687c478bd9Sstevel@tonic-gate 	/*
18697c478bd9Sstevel@tonic-gate 	 * Contains the upper read queue pointer of the module immediately
18707c478bd9Sstevel@tonic-gate 	 * beneath IP.  This field allows IP to validate sub-capability
18717c478bd9Sstevel@tonic-gate 	 * acknowledgments coming up from downstream.
18727c478bd9Sstevel@tonic-gate 	 */
18737c478bd9Sstevel@tonic-gate 	queue_t		*ill_lmod_rq;	/* read queue pointer of module below */
18747c478bd9Sstevel@tonic-gate 	uint_t		ill_lmod_cnt;	/* number of modules beneath IP */
18757c478bd9Sstevel@tonic-gate 	ip_m_t		*ill_media;	/* media specific params/functions */
18767c478bd9Sstevel@tonic-gate 	t_uscalar_t	ill_dlpi_pending; /* Last DLPI primitive issued */
18777c478bd9Sstevel@tonic-gate 	uint_t		ill_usesrc_ifindex; /* use src addr from this ILL */
18787c478bd9Sstevel@tonic-gate 	struct ill_s	*ill_usesrc_grp_next; /* Next ILL in the usesrc group */
18797c478bd9Sstevel@tonic-gate #ifdef ILL_DEBUG
18807c478bd9Sstevel@tonic-gate 	th_trace_t	*ill_trace[IP_TR_HASH_MAX];
18817c478bd9Sstevel@tonic-gate 	boolean_t	ill_trace_disable;	/* True when alloc fails */
18827c478bd9Sstevel@tonic-gate #endif
18837c478bd9Sstevel@tonic-gate } ill_t;
18847c478bd9Sstevel@tonic-gate 
18857c478bd9Sstevel@tonic-gate extern	void	ill_delete_glist(ill_t *);
18867c478bd9Sstevel@tonic-gate 
18877c478bd9Sstevel@tonic-gate /*
18887c478bd9Sstevel@tonic-gate  * The following table lists the protection levels of the various members
18897c478bd9Sstevel@tonic-gate  * of the ill_t. Same notation as that used for ipif_t above is used.
18907c478bd9Sstevel@tonic-gate  *
18917c478bd9Sstevel@tonic-gate  *				Write			Read
18927c478bd9Sstevel@tonic-gate  *
18937c478bd9Sstevel@tonic-gate  * ill_ifptr			ill_g_lock + s		Write once
18947c478bd9Sstevel@tonic-gate  * ill_rq			ipsq			Write once
18957c478bd9Sstevel@tonic-gate  * ill_wq			ipsq			Write once
18967c478bd9Sstevel@tonic-gate  *
18977c478bd9Sstevel@tonic-gate  * ill_error			ipsq			None
18987c478bd9Sstevel@tonic-gate  * ill_ipif			ill_g_lock + ipsq	ill_g_lock OR ipsq
18997c478bd9Sstevel@tonic-gate  * ill_ipif_up_count		ill_lock + ipsq		ill_lock
19007c478bd9Sstevel@tonic-gate  * ill_max_frag			ipsq			Write once
19017c478bd9Sstevel@tonic-gate  *
19027c478bd9Sstevel@tonic-gate  * ill_name			ill_g_lock + ipsq		Write once
19037c478bd9Sstevel@tonic-gate  * ill_name_length		ill_g_lock + ipsq		Write once
19047c478bd9Sstevel@tonic-gate  * ill_ndd_name			ipsq			Write once
19057c478bd9Sstevel@tonic-gate  * ill_net_type			ipsq			Write once
19067c478bd9Sstevel@tonic-gate  * ill_ppa			ill_g_lock + ipsq		Write once
19077c478bd9Sstevel@tonic-gate  * ill_sap			ipsq + down ill		Write once
19087c478bd9Sstevel@tonic-gate  * ill_sap_length		ipsq + down ill		Write once
19097c478bd9Sstevel@tonic-gate  * ill_phys_addr_length		ipsq + down ill		Write once
19107c478bd9Sstevel@tonic-gate  *
19117c478bd9Sstevel@tonic-gate  * ill_bcast_addr_length	ipsq			ipsq
19127c478bd9Sstevel@tonic-gate  * ill_mactype			ipsq			ipsq
19137c478bd9Sstevel@tonic-gate  * ill_frag_ptr			ipsq			ipsq
19147c478bd9Sstevel@tonic-gate  *
19157c478bd9Sstevel@tonic-gate  * ill_frag_timer_id		ill_lock		ill_lock
19167c478bd9Sstevel@tonic-gate  * ill_frag_hash_tbl		ipsq			up ill
19177c478bd9Sstevel@tonic-gate  * ill_ilm			ipsq + ill_lock		ill_lock
19187c478bd9Sstevel@tonic-gate  * ill_mcast_type		ill_lock		ill_lock
19197c478bd9Sstevel@tonic-gate  * ill_mcast_v1_time		ill_lock		ill_lock
19207c478bd9Sstevel@tonic-gate  * ill_mcast_v2_time		ill_lock		ill_lock
19217c478bd9Sstevel@tonic-gate  * ill_mcast_v1_tset		ill_lock		ill_lock
19227c478bd9Sstevel@tonic-gate  * ill_mcast_v2_tset		ill_lock		ill_lock
19237c478bd9Sstevel@tonic-gate  * ill_mcast_rv			ill_lock		ill_lock
19247c478bd9Sstevel@tonic-gate  * ill_mcast_qi			ill_lock		ill_lock
19257c478bd9Sstevel@tonic-gate  * ill_pending_mp		ill_lock		ill_lock
19267c478bd9Sstevel@tonic-gate  *
19277c478bd9Sstevel@tonic-gate  * ill_bcast_mp			ipsq			ipsq
19287c478bd9Sstevel@tonic-gate  * ill_resolver_mp		ipsq			only when ill is up
19297c478bd9Sstevel@tonic-gate  * ill_down_mp			ipsq			ipsq
19307c478bd9Sstevel@tonic-gate  * ill_dlpi_deferred		ipsq			ipsq
19317c478bd9Sstevel@tonic-gate  * ill_phys_addr_mp		ipsq			ipsq
19327c478bd9Sstevel@tonic-gate  * ill_phys_addr		ipsq			up ill
19337c478bd9Sstevel@tonic-gate  * ill_ick			ipsq + down ill		only when ill is up
19347c478bd9Sstevel@tonic-gate  *
19357c478bd9Sstevel@tonic-gate  * ill_state_flags		ill_lock		ill_lock
19367c478bd9Sstevel@tonic-gate  * exclusive bit flags		ipsq_t			ipsq_t
19377c478bd9Sstevel@tonic-gate  * shared bit flags		ill_lock		ill_lock
19387c478bd9Sstevel@tonic-gate  *
19397c478bd9Sstevel@tonic-gate  * ill_arp_muxid		ipsq			Not atomic
19407c478bd9Sstevel@tonic-gate  * ill_ip_muxid			ipsq			Not atomic
19417c478bd9Sstevel@tonic-gate  *
19427c478bd9Sstevel@tonic-gate  * ill_ipf_gen			Not atomic
19437c478bd9Sstevel@tonic-gate  * ill_frag_count		Approx. not protected
19447c478bd9Sstevel@tonic-gate  * ill_type			ipsq + down ill		only when ill is up
19457c478bd9Sstevel@tonic-gate  * ill_dlpi_multicast_state	ill_lock		ill_lock
19467c478bd9Sstevel@tonic-gate  * ill_dlpi_fastpath_state	ill_lock		ill_lock
19477c478bd9Sstevel@tonic-gate  * ill_max_hops			ipsq			Not atomic
19487c478bd9Sstevel@tonic-gate  *
19497c478bd9Sstevel@tonic-gate  * ill_max_mtu
19507c478bd9Sstevel@tonic-gate  *
19517c478bd9Sstevel@tonic-gate  * ill_reachable_time		ipsq + ill_lock		ill_lock
19527c478bd9Sstevel@tonic-gate  * ill_reachable_retrans_time	ipsq  + ill_lock		ill_lock
19537c478bd9Sstevel@tonic-gate  * ill_max_buf			ipsq + ill_lock		ill_lock
19547c478bd9Sstevel@tonic-gate  *
19557c478bd9Sstevel@tonic-gate  * Next 2 fields need ill_lock because of the get ioctls. They should not
19567c478bd9Sstevel@tonic-gate  * report partially updated results without executing in the ipsq.
19577c478bd9Sstevel@tonic-gate  * ill_token			ipsq + ill_lock		ill_lock
19587c478bd9Sstevel@tonic-gate  * ill_token_length		ipsq + ill_lock		ill_lock
19597c478bd9Sstevel@tonic-gate  * ill_xmit_count		ipsq + down ill		write once
19607c478bd9Sstevel@tonic-gate  * ill_ip6_mib			ipsq + down ill		only when ill is up
19617c478bd9Sstevel@tonic-gate  * ill_icmp6_mib		ipsq + down ill		only when ill is up
19627c478bd9Sstevel@tonic-gate  * ill_arp_down_mp		ipsq			ipsq
19637c478bd9Sstevel@tonic-gate  * ill_arp_del_mapping_mp	ipsq			ipsq
19647c478bd9Sstevel@tonic-gate  * ill_arp_on_mp		ipsq			ipsq
19657c478bd9Sstevel@tonic-gate  * ill_move_peer		ipsq			ipsq
19667c478bd9Sstevel@tonic-gate  *
19677c478bd9Sstevel@tonic-gate  * ill_phyint			ipsq, ill_g_lock, ill_lock	Any of them
19687c478bd9Sstevel@tonic-gate  * ill_flags			ill_lock		ill_lock
19697c478bd9Sstevel@tonic-gate  * ill_group			ipsq, ill_g_lock, ill_lock	Any of them
19707c478bd9Sstevel@tonic-gate  * ill_group_next		ipsq, ill_g_lock, ill_lock	Any of them
19717c478bd9Sstevel@tonic-gate  * ill_mrtun_refcnt		ill_lock		ill_lock
19727c478bd9Sstevel@tonic-gate  * ill_srcif_refcnt		ill_lock		ill_lock
19737c478bd9Sstevel@tonic-gate  * ill_srcif_table		ill_lock		ill_lock
19747c478bd9Sstevel@tonic-gate  * ill_nd_lla_mp		ill_lock		ill_lock
19757c478bd9Sstevel@tonic-gate  * ill_nd_lla			ill_lock		ill_lock
19767c478bd9Sstevel@tonic-gate  * ill_nd_lla_len		ill_lock		ill_lock
19777c478bd9Sstevel@tonic-gate  * ill_phys_addr_pend		ipsq + down ill		only when ill is up
19787c478bd9Sstevel@tonic-gate  * ill_ifname_pending_err	ipsq			ipsq
19797c478bd9Sstevel@tonic-gate  * ill_avl_byppa		ipsq, ill_g_lock		Write once
19807c478bd9Sstevel@tonic-gate  *
19817c478bd9Sstevel@tonic-gate  * ill_fastpath_list		ill_lock		ill_lock
19827c478bd9Sstevel@tonic-gate  * ill_refcnt			ill_lock		ill_lock
19837c478bd9Sstevel@tonic-gate  * ill_ire_cnt			ill_lock		ill_lock
19847c478bd9Sstevel@tonic-gate  * ill_cv			ill_lock		ill_lock
19857c478bd9Sstevel@tonic-gate  * ill_ilm_walker_cnt		ill_lock		ill_lock
19867c478bd9Sstevel@tonic-gate  * ill_nce_cnt			ill_lock		ill_lock
19877c478bd9Sstevel@tonic-gate  * ill_trace			ill_lock		ill_lock
19887c478bd9Sstevel@tonic-gate  * ill_usesrc_grp_next		ill_g_usesrc_lock	ill_g_usesrc_lock
19897c478bd9Sstevel@tonic-gate  */
19907c478bd9Sstevel@tonic-gate 
19917c478bd9Sstevel@tonic-gate /*
19927c478bd9Sstevel@tonic-gate  * For ioctl restart mechanism see ip_reprocess_ioctl()
19937c478bd9Sstevel@tonic-gate  */
19947c478bd9Sstevel@tonic-gate struct ip_ioctl_cmd_s;
19957c478bd9Sstevel@tonic-gate 
19967c478bd9Sstevel@tonic-gate typedef	int (*ifunc_t)(ipif_t *, struct sockaddr_in *, queue_t *, mblk_t *,
19977c478bd9Sstevel@tonic-gate     struct ip_ioctl_cmd_s *, void *);
19987c478bd9Sstevel@tonic-gate 
19997c478bd9Sstevel@tonic-gate typedef struct ip_ioctl_cmd_s {
20007c478bd9Sstevel@tonic-gate 	int	ipi_cmd;
20017c478bd9Sstevel@tonic-gate 	size_t	ipi_copyin_size;
20027c478bd9Sstevel@tonic-gate 	uint_t	ipi_flags;
20037c478bd9Sstevel@tonic-gate 	uint_t	ipi_cmd_type;
20047c478bd9Sstevel@tonic-gate 	ifunc_t	ipi_func;
20057c478bd9Sstevel@tonic-gate 	ifunc_t	ipi_func_restart;
20067c478bd9Sstevel@tonic-gate } ip_ioctl_cmd_t;
20077c478bd9Sstevel@tonic-gate 
20087c478bd9Sstevel@tonic-gate /*
20097c478bd9Sstevel@tonic-gate  * ipi_cmd_type:
20107c478bd9Sstevel@tonic-gate  *
20117c478bd9Sstevel@tonic-gate  * IF_CMD		1	old style ifreq cmd
20127c478bd9Sstevel@tonic-gate  * LIF_CMD		2	new style lifreq cmd
20137c478bd9Sstevel@tonic-gate  * MISC_CMD		3	Misc. (non [l]ifreq, tun) cmds
20147c478bd9Sstevel@tonic-gate  * TUN_CMD		4	tunnel related
20157c478bd9Sstevel@tonic-gate  */
20167c478bd9Sstevel@tonic-gate 
20177c478bd9Sstevel@tonic-gate enum { IF_CMD = 1, LIF_CMD, MISC_CMD, TUN_CMD };
20187c478bd9Sstevel@tonic-gate 
20197c478bd9Sstevel@tonic-gate #define	IPI_DONTCARE	0	/* For ioctl encoded values that don't matter */
20207c478bd9Sstevel@tonic-gate 
20217c478bd9Sstevel@tonic-gate /* Flag values in ipi_flags */
20227c478bd9Sstevel@tonic-gate #define	IPI_PRIV	0x1		/* Root only command */
20237c478bd9Sstevel@tonic-gate #define	IPI_MODOK	0x2		/* Permitted on mod instance of IP */
20247c478bd9Sstevel@tonic-gate #define	IPI_WR		0x4		/* Need to grab writer access */
20257c478bd9Sstevel@tonic-gate #define	IPI_GET_CMD	0x8		/* branch to mi_copyout on success */
20267c478bd9Sstevel@tonic-gate #define	IPI_REPL	0x10	/* valid for replacement ipif created in MOVE */
20277c478bd9Sstevel@tonic-gate #define	IPI_NULL_BCONT	0x20	/* ioctl has not data and hence no b_cont */
20287c478bd9Sstevel@tonic-gate #define	IPI_PASS_DOWN	0x40	/* pass this ioctl down when a module only */
20297c478bd9Sstevel@tonic-gate 
20307c478bd9Sstevel@tonic-gate extern ip_ioctl_cmd_t	ip_ndx_ioctl_table[];
20317c478bd9Sstevel@tonic-gate extern ip_ioctl_cmd_t	ip_misc_ioctl_table[];
20327c478bd9Sstevel@tonic-gate extern int ip_ndx_ioctl_count;
20337c478bd9Sstevel@tonic-gate extern int ip_misc_ioctl_count;
20347c478bd9Sstevel@tonic-gate 
20357c478bd9Sstevel@tonic-gate #define	ILL_CLEAR_MOVE(ill) {				\
20367c478bd9Sstevel@tonic-gate 	ill_t *peer_ill;				\
20377c478bd9Sstevel@tonic-gate 							\
20387c478bd9Sstevel@tonic-gate 	peer_ill = (ill)->ill_move_peer;		\
20397c478bd9Sstevel@tonic-gate 	ASSERT(peer_ill != NULL);			\
20407c478bd9Sstevel@tonic-gate 	(ill)->ill_move_in_progress = B_FALSE;		\
20417c478bd9Sstevel@tonic-gate 	peer_ill->ill_move_in_progress = B_FALSE;	\
20427c478bd9Sstevel@tonic-gate 	(ill)->ill_move_peer = NULL;			\
20437c478bd9Sstevel@tonic-gate 	peer_ill->ill_move_peer = NULL;			\
20447c478bd9Sstevel@tonic-gate }
20457c478bd9Sstevel@tonic-gate 
20467c478bd9Sstevel@tonic-gate /* Passed down by ARP to IP during I_PLINK/I_PUNLINK */
20477c478bd9Sstevel@tonic-gate typedef struct ipmx_s {
20487c478bd9Sstevel@tonic-gate 	char	ipmx_name[LIFNAMSIZ];		/* if name */
20497c478bd9Sstevel@tonic-gate 	uint_t
20507c478bd9Sstevel@tonic-gate 		ipmx_arpdev_stream : 1,		/* This is the arp stream */
20517c478bd9Sstevel@tonic-gate 		ipmx_notused : 31;
20527c478bd9Sstevel@tonic-gate } ipmx_t;
20537c478bd9Sstevel@tonic-gate 
20547c478bd9Sstevel@tonic-gate /*
20557c478bd9Sstevel@tonic-gate  * State for detecting if a driver supports certain features.
20567c478bd9Sstevel@tonic-gate  * Support for DL_ENABMULTI_REQ uses ill_dlpi_multicast_state.
20577c478bd9Sstevel@tonic-gate  * Support for DLPI M_DATA fastpath uses ill_dlpi_fastpath_state.
20587c478bd9Sstevel@tonic-gate  */
20597c478bd9Sstevel@tonic-gate #define	IDMS_UNKNOWN	0	/* No DL_ENABMULTI_REQ sent */
20607c478bd9Sstevel@tonic-gate #define	IDMS_INPROGRESS	1	/* Sent DL_ENABMULTI_REQ */
20617c478bd9Sstevel@tonic-gate #define	IDMS_OK		2	/* DL_ENABMULTI_REQ ok */
20627c478bd9Sstevel@tonic-gate #define	IDMS_FAILED	3	/* DL_ENABMULTI_REQ failed */
20637c478bd9Sstevel@tonic-gate #define	IDMS_RENEG	4	/* Driver asked for a renegotiation */
20647c478bd9Sstevel@tonic-gate 
20657c478bd9Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */
20667c478bd9Sstevel@tonic-gate typedef struct ipparam_s {
20677c478bd9Sstevel@tonic-gate 	uint_t	ip_param_min;
20687c478bd9Sstevel@tonic-gate 	uint_t	ip_param_max;
20697c478bd9Sstevel@tonic-gate 	uint_t	ip_param_value;
20707c478bd9Sstevel@tonic-gate 	char	*ip_param_name;
20717c478bd9Sstevel@tonic-gate } ipparam_t;
20727c478bd9Sstevel@tonic-gate 
20737c478bd9Sstevel@tonic-gate /* Extended NDP Management Structure */
20747c478bd9Sstevel@tonic-gate typedef struct ipndp_s {
20757c478bd9Sstevel@tonic-gate 	ndgetf_t	ip_ndp_getf;
20767c478bd9Sstevel@tonic-gate 	ndsetf_t	ip_ndp_setf;
20777c478bd9Sstevel@tonic-gate 	caddr_t		ip_ndp_data;
20787c478bd9Sstevel@tonic-gate 	char		*ip_ndp_name;
20797c478bd9Sstevel@tonic-gate } ipndp_t;
20807c478bd9Sstevel@tonic-gate 
20817c478bd9Sstevel@tonic-gate /*
2082*45916cd2Sjpk  * The kernel stores security attributes of all gateways in a database made
2083*45916cd2Sjpk  * up of one or more tsol_gcdb_t elements.  Each tsol_gcdb_t contains the
2084*45916cd2Sjpk  * security-related credentials of the gateway.  More than one gateways may
2085*45916cd2Sjpk  * share entries in the database.
2086*45916cd2Sjpk  *
2087*45916cd2Sjpk  * The tsol_gc_t structure represents the gateway to credential association,
2088*45916cd2Sjpk  * and refers to an entry in the database.  One or more tsol_gc_t entities are
2089*45916cd2Sjpk  * grouped together to form one or more tsol_gcgrp_t, each representing the
2090*45916cd2Sjpk  * list of security attributes specific to the gateway.  A gateway may be
2091*45916cd2Sjpk  * associated with at most one credentials group.
2092*45916cd2Sjpk  */
2093*45916cd2Sjpk struct tsol_gcgrp_s;
2094*45916cd2Sjpk 
2095*45916cd2Sjpk extern uchar_t	ip6opt_ls;	/* TX IPv6 enabler */
2096*45916cd2Sjpk 
2097*45916cd2Sjpk /*
2098*45916cd2Sjpk  * Gateway security credential record.
2099*45916cd2Sjpk  */
2100*45916cd2Sjpk typedef struct tsol_gcdb_s {
2101*45916cd2Sjpk 	uint_t		gcdb_refcnt;	/* reference count */
2102*45916cd2Sjpk 	struct rtsa_s	gcdb_attr;	/* security attributes */
2103*45916cd2Sjpk #define	gcdb_mask	gcdb_attr.rtsa_mask
2104*45916cd2Sjpk #define	gcdb_doi	gcdb_attr.rtsa_doi
2105*45916cd2Sjpk #define	gcdb_slrange	gcdb_attr.rtsa_slrange
2106*45916cd2Sjpk } tsol_gcdb_t;
2107*45916cd2Sjpk 
2108*45916cd2Sjpk /*
2109*45916cd2Sjpk  * Gateway to credential association.
2110*45916cd2Sjpk  */
2111*45916cd2Sjpk typedef struct tsol_gc_s {
2112*45916cd2Sjpk 	uint_t		gc_refcnt;	/* reference count */
2113*45916cd2Sjpk 	struct tsol_gcgrp_s *gc_grp;	/* pointer to group */
2114*45916cd2Sjpk 	struct tsol_gc_s *gc_prev;	/* previous in list */
2115*45916cd2Sjpk 	struct tsol_gc_s *gc_next;	/* next in list */
2116*45916cd2Sjpk 	tsol_gcdb_t	*gc_db;		/* pointer to actual credentials */
2117*45916cd2Sjpk } tsol_gc_t;
2118*45916cd2Sjpk 
2119*45916cd2Sjpk /*
2120*45916cd2Sjpk  * Gateway credentials group address.
2121*45916cd2Sjpk  */
2122*45916cd2Sjpk typedef struct tsol_gcgrp_addr_s {
2123*45916cd2Sjpk 	int		ga_af;		/* address family */
2124*45916cd2Sjpk 	in6_addr_t	ga_addr;	/* IPv4 mapped or IPv6 address */
2125*45916cd2Sjpk } tsol_gcgrp_addr_t;
2126*45916cd2Sjpk 
2127*45916cd2Sjpk /*
2128*45916cd2Sjpk  * Gateway credentials group.
2129*45916cd2Sjpk  */
2130*45916cd2Sjpk typedef struct tsol_gcgrp_s {
2131*45916cd2Sjpk 	uint_t		gcgrp_refcnt;	/* reference count */
2132*45916cd2Sjpk 	krwlock_t	gcgrp_rwlock;	/* lock to protect following */
2133*45916cd2Sjpk 	uint_t		gcgrp_count;	/* number of credentials */
2134*45916cd2Sjpk 	tsol_gc_t	*gcgrp_head;	/* first credential in list */
2135*45916cd2Sjpk 	tsol_gc_t	*gcgrp_tail;	/* last credential in list */
2136*45916cd2Sjpk 	tsol_gcgrp_addr_t gcgrp_addr;	/* next-hop gateway address */
2137*45916cd2Sjpk } tsol_gcgrp_t;
2138*45916cd2Sjpk 
2139*45916cd2Sjpk extern kmutex_t gcgrp_lock;
2140*45916cd2Sjpk 
2141*45916cd2Sjpk #define	GC_REFRELE(p) {				\
2142*45916cd2Sjpk 	ASSERT((p)->gc_grp != NULL);		\
2143*45916cd2Sjpk 	rw_enter(&(p)->gc_grp->gcgrp_rwlock, RW_WRITER); \
2144*45916cd2Sjpk 	ASSERT((p)->gc_refcnt > 0);		\
2145*45916cd2Sjpk 	if (--((p)->gc_refcnt) == 0)		\
2146*45916cd2Sjpk 		gc_inactive(p);			\
2147*45916cd2Sjpk 	else					\
2148*45916cd2Sjpk 		rw_exit(&(p)->gc_grp->gcgrp_rwlock); \
2149*45916cd2Sjpk }
2150*45916cd2Sjpk 
2151*45916cd2Sjpk #define	GCGRP_REFHOLD(p) {			\
2152*45916cd2Sjpk 	mutex_enter(&gcgrp_lock);		\
2153*45916cd2Sjpk 	++((p)->gcgrp_refcnt);			\
2154*45916cd2Sjpk 	ASSERT((p)->gcgrp_refcnt != 0);		\
2155*45916cd2Sjpk 	mutex_exit(&gcgrp_lock);		\
2156*45916cd2Sjpk }
2157*45916cd2Sjpk 
2158*45916cd2Sjpk #define	GCGRP_REFRELE(p) {			\
2159*45916cd2Sjpk 	mutex_enter(&gcgrp_lock);		\
2160*45916cd2Sjpk 	ASSERT((p)->gcgrp_refcnt > 0);		\
2161*45916cd2Sjpk 	if (--((p)->gcgrp_refcnt) == 0)		\
2162*45916cd2Sjpk 		gcgrp_inactive(p);		\
2163*45916cd2Sjpk 	ASSERT(MUTEX_HELD(&gcgrp_lock));	\
2164*45916cd2Sjpk 	mutex_exit(&gcgrp_lock);		\
2165*45916cd2Sjpk }
2166*45916cd2Sjpk 
2167*45916cd2Sjpk /*
2168*45916cd2Sjpk  * IRE gateway security attributes structure, pointed to by tsol_ire_gw_secattr
2169*45916cd2Sjpk  */
2170*45916cd2Sjpk struct tsol_tnrhc;
2171*45916cd2Sjpk 
2172*45916cd2Sjpk typedef struct tsol_ire_gw_secattr_s {
2173*45916cd2Sjpk 	kmutex_t	igsa_lock;	/* lock to protect following */
2174*45916cd2Sjpk 	struct tsol_tnrhc *igsa_rhc;	/* host entry for gateway */
2175*45916cd2Sjpk 	tsol_gc_t	*igsa_gc;	/* for prefix IREs */
2176*45916cd2Sjpk 	tsol_gcgrp_t	*igsa_gcgrp;	/* for cache IREs */
2177*45916cd2Sjpk } tsol_ire_gw_secattr_t;
2178*45916cd2Sjpk 
2179*45916cd2Sjpk /*
21807c478bd9Sstevel@tonic-gate  * Following are the macros to increment/decrement the reference
21817c478bd9Sstevel@tonic-gate  * count of the IREs and IRBs (ire bucket).
21827c478bd9Sstevel@tonic-gate  *
21837c478bd9Sstevel@tonic-gate  * 1) We bump up the reference count of an IRE to make sure that
21847c478bd9Sstevel@tonic-gate  *    it does not get deleted and freed while we are using it.
21857c478bd9Sstevel@tonic-gate  *    Typically all the lookup functions hold the bucket lock,
21867c478bd9Sstevel@tonic-gate  *    and look for the IRE. If it finds an IRE, it bumps up the
21877c478bd9Sstevel@tonic-gate  *    reference count before dropping the lock. Sometimes we *may* want
21887c478bd9Sstevel@tonic-gate  *    to bump up the reference count after we *looked* up i.e without
21897c478bd9Sstevel@tonic-gate  *    holding the bucket lock. So, the IRE_REFHOLD macro does not assert
21907c478bd9Sstevel@tonic-gate  *    on the bucket lock being held. Any thread trying to delete from
21917c478bd9Sstevel@tonic-gate  *    the hash bucket can still do so but cannot free the IRE if
21927c478bd9Sstevel@tonic-gate  *    ire_refcnt is not 0.
21937c478bd9Sstevel@tonic-gate  *
21947c478bd9Sstevel@tonic-gate  * 2) We bump up the reference count on the bucket where the IRE resides
21957c478bd9Sstevel@tonic-gate  *    (IRB), when we want to prevent the IREs getting deleted from a given
21967c478bd9Sstevel@tonic-gate  *    hash bucket. This makes life easier for ire_walk type functions which
21977c478bd9Sstevel@tonic-gate  *    wants to walk the IRE list, call a function, but needs to drop
21987c478bd9Sstevel@tonic-gate  *    the bucket lock to prevent recursive rw_enters. While the
21997c478bd9Sstevel@tonic-gate  *    lock is dropped, the list could be changed by other threads or
22007c478bd9Sstevel@tonic-gate  *    the same thread could end up deleting the ire or the ire pointed by
22017c478bd9Sstevel@tonic-gate  *    ire_next. IRE_REFHOLDing the ire or ire_next is not sufficient as
22027c478bd9Sstevel@tonic-gate  *    a delete will still remove the ire from the bucket while we have
22037c478bd9Sstevel@tonic-gate  *    dropped the lock and hence the ire_next would be NULL. Thus, we
22047c478bd9Sstevel@tonic-gate  *    need a mechanism to prevent deletions from a given bucket.
22057c478bd9Sstevel@tonic-gate  *
22067c478bd9Sstevel@tonic-gate  *    To prevent deletions, we bump up the reference count on the
22077c478bd9Sstevel@tonic-gate  *    bucket. If the bucket is held, ire_delete just marks IRE_MARK_CONDEMNED
22087c478bd9Sstevel@tonic-gate  *    both on the ire's ire_marks and the bucket's irb_marks. When the
22097c478bd9Sstevel@tonic-gate  *    reference count on the bucket drops to zero, all the CONDEMNED ires
22107c478bd9Sstevel@tonic-gate  *    are deleted. We don't have to bump up the reference count on the
22117c478bd9Sstevel@tonic-gate  *    bucket if we are walking the bucket and never have to drop the bucket
22127c478bd9Sstevel@tonic-gate  *    lock. Note that IRB_REFHOLD does not prevent addition of new ires
22137c478bd9Sstevel@tonic-gate  *    in the list. It is okay because addition of new ires will not cause
22147c478bd9Sstevel@tonic-gate  *    ire_next to point to freed memory. We do IRB_REFHOLD only when
22157c478bd9Sstevel@tonic-gate  *    all of the 3 conditions are true :
22167c478bd9Sstevel@tonic-gate  *
22177c478bd9Sstevel@tonic-gate  *    1) The code needs to walk the IRE bucket from start to end.
22187c478bd9Sstevel@tonic-gate  *    2) It may have to drop the bucket lock sometimes while doing (1)
22197c478bd9Sstevel@tonic-gate  *    3) It does not want any ires to be deleted meanwhile.
22207c478bd9Sstevel@tonic-gate  */
22217c478bd9Sstevel@tonic-gate 
22227c478bd9Sstevel@tonic-gate /*
22237c478bd9Sstevel@tonic-gate  * Bump up the reference count on the IRE. We cannot assert that the
22247c478bd9Sstevel@tonic-gate  * bucket lock is being held as it is legal to bump up the reference
22257c478bd9Sstevel@tonic-gate  * count after the first lookup has returned the IRE without
22267c478bd9Sstevel@tonic-gate  * holding the lock. Currently ip_wput does this for caching IRE_CACHEs.
22277c478bd9Sstevel@tonic-gate  */
22287c478bd9Sstevel@tonic-gate 
22297c478bd9Sstevel@tonic-gate #ifndef IRE_DEBUG
22307c478bd9Sstevel@tonic-gate 
22317c478bd9Sstevel@tonic-gate #define	IRE_REFHOLD_NOTR(ire)	IRE_REFHOLD(ire)
22327c478bd9Sstevel@tonic-gate #define	IRE_UNTRACE_REF(ire)
22337c478bd9Sstevel@tonic-gate #define	IRE_TRACE_REF(ire)
22347c478bd9Sstevel@tonic-gate 
22357c478bd9Sstevel@tonic-gate #else
22367c478bd9Sstevel@tonic-gate 
22377c478bd9Sstevel@tonic-gate #define	IRE_REFHOLD_NOTR(ire) {				\
22387c478bd9Sstevel@tonic-gate 	atomic_add_32(&(ire)->ire_refcnt, 1);		\
22397c478bd9Sstevel@tonic-gate 	ASSERT((ire)->ire_refcnt != 0);			\
22407c478bd9Sstevel@tonic-gate }
22417c478bd9Sstevel@tonic-gate 
22427c478bd9Sstevel@tonic-gate #define	IRE_UNTRACE_REF(ire)	ire_untrace_ref(ire);
22437c478bd9Sstevel@tonic-gate #define	IRE_TRACE_REF(ire)	ire_trace_ref(ire);
22447c478bd9Sstevel@tonic-gate #endif
22457c478bd9Sstevel@tonic-gate 
22467c478bd9Sstevel@tonic-gate #define	IRE_REFHOLD(ire) {				\
22477c478bd9Sstevel@tonic-gate 	atomic_add_32(&(ire)->ire_refcnt, 1);		\
22487c478bd9Sstevel@tonic-gate 	ASSERT((ire)->ire_refcnt != 0);			\
22497c478bd9Sstevel@tonic-gate 	IRE_TRACE_REF(ire);				\
22507c478bd9Sstevel@tonic-gate }
22517c478bd9Sstevel@tonic-gate 
22527c478bd9Sstevel@tonic-gate #define	IRE_REFHOLD_LOCKED(ire)	{			\
22537c478bd9Sstevel@tonic-gate 	IRE_TRACE_REF(ire);				\
22547c478bd9Sstevel@tonic-gate 	(ire)->ire_refcnt++;				\
22557c478bd9Sstevel@tonic-gate }
22567c478bd9Sstevel@tonic-gate 
22577c478bd9Sstevel@tonic-gate /*
22587c478bd9Sstevel@tonic-gate  * Decrement the reference count on the IRE.
22597c478bd9Sstevel@tonic-gate  * In architectures e.g sun4u, where atomic_add_32_nv is just
22607c478bd9Sstevel@tonic-gate  * a cas, we need to maintain the right memory barrier semantics
22617c478bd9Sstevel@tonic-gate  * as that of mutex_exit i.e all the loads and stores should complete
22627c478bd9Sstevel@tonic-gate  * before the cas is executed. membar_exit() does that here.
22637c478bd9Sstevel@tonic-gate  *
22647c478bd9Sstevel@tonic-gate  * NOTE : This macro is used only in places where we want performance.
22657c478bd9Sstevel@tonic-gate  *	  To avoid bloating the code, we use the function "ire_refrele"
22667c478bd9Sstevel@tonic-gate  *	  which essentially calls the macro.
22677c478bd9Sstevel@tonic-gate  */
22687c478bd9Sstevel@tonic-gate #ifndef IRE_DEBUG
22697c478bd9Sstevel@tonic-gate #define	IRE_REFRELE(ire) {					\
22707c478bd9Sstevel@tonic-gate 	ASSERT((ire)->ire_refcnt != 0);				\
22717c478bd9Sstevel@tonic-gate 	membar_exit();						\
22727c478bd9Sstevel@tonic-gate 	if (atomic_add_32_nv(&(ire)->ire_refcnt, -1) == 0)	\
22737c478bd9Sstevel@tonic-gate 		ire_inactive(ire);				\
22747c478bd9Sstevel@tonic-gate }
22757c478bd9Sstevel@tonic-gate #define	IRE_REFRELE_NOTR(ire)	IRE_REFRELE(ire)
22767c478bd9Sstevel@tonic-gate #else
22777c478bd9Sstevel@tonic-gate #define	IRE_REFRELE(ire) {					\
22787c478bd9Sstevel@tonic-gate 	if (ire->ire_bucket != NULL)				\
22797c478bd9Sstevel@tonic-gate 		ire_untrace_ref(ire);				\
22807c478bd9Sstevel@tonic-gate 	ASSERT((ire)->ire_refcnt != 0);				\
22817c478bd9Sstevel@tonic-gate 	membar_exit();						\
22827c478bd9Sstevel@tonic-gate 	if (atomic_add_32_nv(&(ire)->ire_refcnt, -1) == 0)	\
22837c478bd9Sstevel@tonic-gate 		ire_inactive(ire);				\
22847c478bd9Sstevel@tonic-gate }
22857c478bd9Sstevel@tonic-gate #define	IRE_REFRELE_NOTR(ire) {					\
22867c478bd9Sstevel@tonic-gate 	ASSERT((ire)->ire_refcnt != 0);				\
22877c478bd9Sstevel@tonic-gate 	membar_exit();						\
22887c478bd9Sstevel@tonic-gate 	if (atomic_add_32_nv(&(ire)->ire_refcnt, -1) == 0)	\
22897c478bd9Sstevel@tonic-gate 		ire_inactive(ire);				\
22907c478bd9Sstevel@tonic-gate }
22917c478bd9Sstevel@tonic-gate #endif
22927c478bd9Sstevel@tonic-gate 
22937c478bd9Sstevel@tonic-gate /*
22947c478bd9Sstevel@tonic-gate  * Bump up the reference count on the hash bucket - IRB to
22957c478bd9Sstevel@tonic-gate  * prevent ires from being deleted in this bucket.
22967c478bd9Sstevel@tonic-gate  */
22977c478bd9Sstevel@tonic-gate #define	IRB_REFHOLD(irb) {				\
22987c478bd9Sstevel@tonic-gate 	rw_enter(&(irb)->irb_lock, RW_WRITER);		\
22997c478bd9Sstevel@tonic-gate 	(irb)->irb_refcnt++;				\
23007c478bd9Sstevel@tonic-gate 	ASSERT((irb)->irb_refcnt != 0);			\
23017c478bd9Sstevel@tonic-gate 	rw_exit(&(irb)->irb_lock);			\
23027c478bd9Sstevel@tonic-gate }
23037c478bd9Sstevel@tonic-gate 
23047c478bd9Sstevel@tonic-gate #define	IRB_REFRELE(irb) {				\
23057c478bd9Sstevel@tonic-gate 	rw_enter(&(irb)->irb_lock, RW_WRITER);		\
23067c478bd9Sstevel@tonic-gate 	ASSERT((irb)->irb_refcnt != 0);			\
23077c478bd9Sstevel@tonic-gate 	if (--(irb)->irb_refcnt	== 0 &&			\
23087c478bd9Sstevel@tonic-gate 	    ((irb)->irb_marks & IRE_MARK_CONDEMNED)) {	\
23097c478bd9Sstevel@tonic-gate 		ire_t *ire_list;			\
23107c478bd9Sstevel@tonic-gate 							\
23117c478bd9Sstevel@tonic-gate 		ire_list = ire_unlink(irb);		\
23127c478bd9Sstevel@tonic-gate 		rw_exit(&(irb)->irb_lock);		\
23137c478bd9Sstevel@tonic-gate 		ASSERT(ire_list != NULL);		\
23147c478bd9Sstevel@tonic-gate 		ire_cleanup(ire_list);			\
23157c478bd9Sstevel@tonic-gate 	} else {					\
23167c478bd9Sstevel@tonic-gate 		rw_exit(&(irb)->irb_lock);		\
23177c478bd9Sstevel@tonic-gate 	}						\
23187c478bd9Sstevel@tonic-gate }
23197c478bd9Sstevel@tonic-gate 
23207c478bd9Sstevel@tonic-gate /*
23217c478bd9Sstevel@tonic-gate  * Lock the fast path mp for access, since the ire_fp_mp can be deleted
23227c478bd9Sstevel@tonic-gate  * due a DL_NOTE_FASTPATH_FLUSH in the case of IRE_BROADCAST and IRE_MIPRTUN
23237c478bd9Sstevel@tonic-gate  */
23247c478bd9Sstevel@tonic-gate 
23257c478bd9Sstevel@tonic-gate #define	LOCK_IRE_FP_MP(ire) {				\
23267c478bd9Sstevel@tonic-gate 		if ((ire)->ire_type == IRE_BROADCAST ||	\
23277c478bd9Sstevel@tonic-gate 		    (ire)->ire_type == IRE_MIPRTUN)	\
23287c478bd9Sstevel@tonic-gate 			mutex_enter(&ire->ire_lock);	\
23297c478bd9Sstevel@tonic-gate 	}
23307c478bd9Sstevel@tonic-gate #define	UNLOCK_IRE_FP_MP(ire) {				\
23317c478bd9Sstevel@tonic-gate 		if ((ire)->ire_type == IRE_BROADCAST ||	\
23327c478bd9Sstevel@tonic-gate 		    (ire)->ire_type == IRE_MIPRTUN)	\
23337c478bd9Sstevel@tonic-gate 			mutex_exit(&ire->ire_lock);	\
23347c478bd9Sstevel@tonic-gate 	}
23357c478bd9Sstevel@tonic-gate 
23367c478bd9Sstevel@tonic-gate typedef struct ire4 {
23377c478bd9Sstevel@tonic-gate 	ipaddr_t ire4_src_addr;		/* Source address to use. */
23387c478bd9Sstevel@tonic-gate 	ipaddr_t ire4_mask;		/* Mask for matching this IRE. */
23397c478bd9Sstevel@tonic-gate 	ipaddr_t ire4_addr;		/* Address this IRE represents. */
23407c478bd9Sstevel@tonic-gate 	ipaddr_t ire4_gateway_addr;	/* Gateway if IRE_CACHE/IRE_OFFSUBNET */
23417c478bd9Sstevel@tonic-gate 	ipaddr_t ire4_cmask;		/* Mask from parent prefix route */
23427c478bd9Sstevel@tonic-gate } ire4_t;
23437c478bd9Sstevel@tonic-gate 
23447c478bd9Sstevel@tonic-gate typedef struct ire6 {
23457c478bd9Sstevel@tonic-gate 	in6_addr_t ire6_src_addr;	/* Source address to use. */
23467c478bd9Sstevel@tonic-gate 	in6_addr_t ire6_mask;		/* Mask for matching this IRE. */
23477c478bd9Sstevel@tonic-gate 	in6_addr_t ire6_addr;		/* Address this IRE represents. */
23487c478bd9Sstevel@tonic-gate 	in6_addr_t ire6_gateway_addr;	/* Gateway if IRE_CACHE/IRE_OFFSUBNET */
23497c478bd9Sstevel@tonic-gate 	in6_addr_t ire6_cmask;		/* Mask from parent prefix route */
23507c478bd9Sstevel@tonic-gate } ire6_t;
23517c478bd9Sstevel@tonic-gate 
23527c478bd9Sstevel@tonic-gate typedef union ire_addr {
23537c478bd9Sstevel@tonic-gate 	ire6_t	ire6_u;
23547c478bd9Sstevel@tonic-gate 	ire4_t	ire4_u;
23557c478bd9Sstevel@tonic-gate } ire_addr_u_t;
23567c478bd9Sstevel@tonic-gate 
23577c478bd9Sstevel@tonic-gate /* Internet Routing Entry */
23587c478bd9Sstevel@tonic-gate typedef struct ire_s {
23597c478bd9Sstevel@tonic-gate 	struct	ire_s	*ire_next;	/* The hash chain must be first. */
23607c478bd9Sstevel@tonic-gate 	struct	ire_s	**ire_ptpn;	/* Pointer to previous next. */
23617c478bd9Sstevel@tonic-gate 	uint32_t	ire_refcnt;	/* Number of references */
23627c478bd9Sstevel@tonic-gate 	mblk_t		*ire_mp;	/* Non-null if allocated as mblk */
23637c478bd9Sstevel@tonic-gate 	mblk_t		*ire_fp_mp;	/* Fast path header */
23647c478bd9Sstevel@tonic-gate 	queue_t		*ire_rfq;	/* recv from this queue */
23657c478bd9Sstevel@tonic-gate 	queue_t		*ire_stq;	/* send to this queue */
23667c478bd9Sstevel@tonic-gate 	union {
23677c478bd9Sstevel@tonic-gate 		uint_t	*max_fragp;	/* Used only during ire creation */
23687c478bd9Sstevel@tonic-gate 		uint_t	max_frag;	/* MTU (next hop or path). */
23697c478bd9Sstevel@tonic-gate 	} imf_u;
23707c478bd9Sstevel@tonic-gate #define	ire_max_frag	imf_u.max_frag
23717c478bd9Sstevel@tonic-gate #define	ire_max_fragp	imf_u.max_fragp
23727c478bd9Sstevel@tonic-gate 	uint32_t	ire_frag_flag;	/* IPH_DF or zero. */
23737c478bd9Sstevel@tonic-gate 	uint32_t	ire_ident;	/* Per IRE IP ident. */
23747c478bd9Sstevel@tonic-gate 	uint32_t	ire_tire_mark;	/* Used for reclaim of unused. */
23757c478bd9Sstevel@tonic-gate 	uchar_t		ire_ipversion;	/* IPv4/IPv6 version */
23767c478bd9Sstevel@tonic-gate 	uchar_t		ire_marks;	/* IRE_MARK_CONDEMNED etc. */
23777c478bd9Sstevel@tonic-gate 	ushort_t	ire_type;	/* Type of IRE */
23787c478bd9Sstevel@tonic-gate 	uint_t	ire_ib_pkt_count;	/* Inbound packets for ire_addr */
23797c478bd9Sstevel@tonic-gate 	uint_t	ire_ob_pkt_count;	/* Outbound packets to ire_addr */
23807c478bd9Sstevel@tonic-gate 	uint_t	ire_ll_hdr_length;	/* Non-zero if we do M_DATA prepends */
23817c478bd9Sstevel@tonic-gate 	time_t	ire_create_time;	/* Time (in secs) IRE was created. */
23827c478bd9Sstevel@tonic-gate 	mblk_t		*ire_dlureq_mp;	/* DL_UNIT_DATA_REQ/RESOLVER mp */
23837c478bd9Sstevel@tonic-gate 	uint32_t	ire_phandle;	/* Associate prefix IREs to cache */
23847c478bd9Sstevel@tonic-gate 	uint32_t	ire_ihandle;	/* Associate interface IREs to cache */
23857c478bd9Sstevel@tonic-gate 	ipif_t		*ire_ipif;	/* the interface that this ire uses */
23867c478bd9Sstevel@tonic-gate 	uint32_t	ire_flags;	/* flags related to route (RTF_*) */
23877c478bd9Sstevel@tonic-gate 	uint_t	ire_ipsec_overhead;	/* IPSEC overhead */
23887c478bd9Sstevel@tonic-gate 	struct	nce_s	*ire_nce;	/* Neighbor Cache Entry for IPv6 */
23897c478bd9Sstevel@tonic-gate 	uint_t		ire_masklen;	/* # bits in ire_mask{,_v6} */
23907c478bd9Sstevel@tonic-gate 	ire_addr_u_t	ire_u;		/* IPv4/IPv6 address info. */
23917c478bd9Sstevel@tonic-gate 
23927c478bd9Sstevel@tonic-gate 	irb_t		*ire_bucket;	/* Hash bucket when ire_ptphn is set */
23937c478bd9Sstevel@tonic-gate 	iulp_t		ire_uinfo;	/* Upper layer protocol info. */
23947c478bd9Sstevel@tonic-gate 	/*
23957c478bd9Sstevel@tonic-gate 	 * Protects ire_uinfo, ire_max_frag, and ire_frag_flag.
23967c478bd9Sstevel@tonic-gate 	 */
23977c478bd9Sstevel@tonic-gate 	kmutex_t	ire_lock;
23987c478bd9Sstevel@tonic-gate 	uint_t		ire_ipif_seqid; /* ipif_seqid of ire_ipif */
23997c478bd9Sstevel@tonic-gate 	/*
24007c478bd9Sstevel@tonic-gate 	 * For regular routes in forwarding table and cache table the
24017c478bd9Sstevel@tonic-gate 	 * the following entries are NULL/zero. Only reverse tunnel
24027c478bd9Sstevel@tonic-gate 	 * table and interface based forwarding table use these fields.
24037c478bd9Sstevel@tonic-gate 	 * Routes added with RTA_SRCIFP and RTA_SRC respectively have
24047c478bd9Sstevel@tonic-gate 	 * non-zero values for the following fields.
24057c478bd9Sstevel@tonic-gate 	 */
24067c478bd9Sstevel@tonic-gate 	ill_t		*ire_in_ill;	/* Incoming ill interface */
24077c478bd9Sstevel@tonic-gate 	ipaddr_t	ire_in_src_addr;
24087c478bd9Sstevel@tonic-gate 					/* source ip-addr of incoming packet */
24097c478bd9Sstevel@tonic-gate 	clock_t		ire_last_used_time;	/* Last used time */
24107c478bd9Sstevel@tonic-gate 	struct ire_s 	*ire_fastpath;	/* Pointer to next ire in fastpath */
24117c478bd9Sstevel@tonic-gate 	zoneid_t	ire_zoneid;	/* for local address discrimination */
2412*45916cd2Sjpk 	tsol_ire_gw_secattr_t *ire_gw_secattr; /* gateway security attributes */
24137c478bd9Sstevel@tonic-gate #ifdef IRE_DEBUG
24147c478bd9Sstevel@tonic-gate 	th_trace_t	*ire_trace[IP_TR_HASH_MAX];
24157c478bd9Sstevel@tonic-gate 	boolean_t	ire_trace_disable;	/* True when alloc fails */
24167c478bd9Sstevel@tonic-gate #endif
24177c478bd9Sstevel@tonic-gate } ire_t;
24187c478bd9Sstevel@tonic-gate 
24197c478bd9Sstevel@tonic-gate /* IPv4 compatiblity macros */
24207c478bd9Sstevel@tonic-gate #define	ire_src_addr		ire_u.ire4_u.ire4_src_addr
24217c478bd9Sstevel@tonic-gate #define	ire_mask		ire_u.ire4_u.ire4_mask
24227c478bd9Sstevel@tonic-gate #define	ire_addr		ire_u.ire4_u.ire4_addr
24237c478bd9Sstevel@tonic-gate #define	ire_gateway_addr	ire_u.ire4_u.ire4_gateway_addr
24247c478bd9Sstevel@tonic-gate #define	ire_cmask		ire_u.ire4_u.ire4_cmask
24257c478bd9Sstevel@tonic-gate 
24267c478bd9Sstevel@tonic-gate #define	ire_src_addr_v6		ire_u.ire6_u.ire6_src_addr
24277c478bd9Sstevel@tonic-gate #define	ire_mask_v6		ire_u.ire6_u.ire6_mask
24287c478bd9Sstevel@tonic-gate #define	ire_addr_v6		ire_u.ire6_u.ire6_addr
24297c478bd9Sstevel@tonic-gate #define	ire_gateway_addr_v6	ire_u.ire6_u.ire6_gateway_addr
24307c478bd9Sstevel@tonic-gate #define	ire_cmask_v6		ire_u.ire6_u.ire6_cmask
24317c478bd9Sstevel@tonic-gate 
24327c478bd9Sstevel@tonic-gate /* Convenient typedefs for sockaddrs */
24337c478bd9Sstevel@tonic-gate typedef	struct sockaddr_in	sin_t;
24347c478bd9Sstevel@tonic-gate typedef	struct sockaddr_in6	sin6_t;
24357c478bd9Sstevel@tonic-gate 
24367c478bd9Sstevel@tonic-gate /* Address structure used for internal bind with IP */
24377c478bd9Sstevel@tonic-gate typedef struct ipa_conn_s {
24387c478bd9Sstevel@tonic-gate 	ipaddr_t	ac_laddr;
24397c478bd9Sstevel@tonic-gate 	ipaddr_t	ac_faddr;
24407c478bd9Sstevel@tonic-gate 	uint16_t	ac_fport;
24417c478bd9Sstevel@tonic-gate 	uint16_t	ac_lport;
24427c478bd9Sstevel@tonic-gate } ipa_conn_t;
24437c478bd9Sstevel@tonic-gate 
24447c478bd9Sstevel@tonic-gate typedef struct ipa6_conn_s {
24457c478bd9Sstevel@tonic-gate 	in6_addr_t	ac6_laddr;
24467c478bd9Sstevel@tonic-gate 	in6_addr_t	ac6_faddr;
24477c478bd9Sstevel@tonic-gate 	uint16_t	ac6_fport;
24487c478bd9Sstevel@tonic-gate 	uint16_t	ac6_lport;
24497c478bd9Sstevel@tonic-gate } ipa6_conn_t;
24507c478bd9Sstevel@tonic-gate 
24517c478bd9Sstevel@tonic-gate /*
24527c478bd9Sstevel@tonic-gate  * Using ipa_conn_x_t or ipa6_conn_x_t allows us to modify the behavior of IP's
24537c478bd9Sstevel@tonic-gate  * bind handler.
24547c478bd9Sstevel@tonic-gate  */
24557c478bd9Sstevel@tonic-gate typedef struct ipa_conn_extended_s {
24567c478bd9Sstevel@tonic-gate 	uint64_t	acx_flags;
24577c478bd9Sstevel@tonic-gate 	ipa_conn_t	acx_conn;
24587c478bd9Sstevel@tonic-gate } ipa_conn_x_t;
24597c478bd9Sstevel@tonic-gate 
24607c478bd9Sstevel@tonic-gate typedef struct ipa6_conn_extended_s {
24617c478bd9Sstevel@tonic-gate 	uint64_t	ac6x_flags;
24627c478bd9Sstevel@tonic-gate 	ipa6_conn_t	ac6x_conn;
24637c478bd9Sstevel@tonic-gate } ipa6_conn_x_t;
24647c478bd9Sstevel@tonic-gate 
24657c478bd9Sstevel@tonic-gate /* flag values for ipa_conn_x_t and ipa6_conn_x_t. */
24667c478bd9Sstevel@tonic-gate #define	ACX_VERIFY_DST	0x1ULL	/* verify destination address is reachable */
24677c478bd9Sstevel@tonic-gate 
24687c478bd9Sstevel@tonic-gate /* Name/Value Descriptor. */
24697c478bd9Sstevel@tonic-gate typedef struct nv_s {
24707c478bd9Sstevel@tonic-gate 	uint64_t nv_value;
24717c478bd9Sstevel@tonic-gate 	char	*nv_name;
24727c478bd9Sstevel@tonic-gate } nv_t;
24737c478bd9Sstevel@tonic-gate 
24747c478bd9Sstevel@tonic-gate /* IP Forwarding Ticket */
24757c478bd9Sstevel@tonic-gate typedef	struct ipftk_s {
24767c478bd9Sstevel@tonic-gate 	queue_t	*ipftk_queue;
24777c478bd9Sstevel@tonic-gate 	ipaddr_t ipftk_dst;
24787c478bd9Sstevel@tonic-gate } ipftk_t;
24797c478bd9Sstevel@tonic-gate 
24807c478bd9Sstevel@tonic-gate typedef struct ipt_s {
24817c478bd9Sstevel@tonic-gate 	pfv_t	func;		/* Routine to call */
24827c478bd9Sstevel@tonic-gate 	uchar_t	*arg;		/* ire or nce passed in */
24837c478bd9Sstevel@tonic-gate } ipt_t;
24847c478bd9Sstevel@tonic-gate 
24857c478bd9Sstevel@tonic-gate #define	ILL_FRAG_HASH(s, i) \
24867c478bd9Sstevel@tonic-gate 	((ntohl(s) ^ ((i) ^ ((i) >> 8))) % ILL_FRAG_HASH_TBL_COUNT)
24877c478bd9Sstevel@tonic-gate 
24887c478bd9Sstevel@tonic-gate /*
24897c478bd9Sstevel@tonic-gate  * The MAX number of allowed fragmented packets per hash bucket
24907c478bd9Sstevel@tonic-gate  * calculation is based on the most common mtu size of 1500. This limit
24917c478bd9Sstevel@tonic-gate  * will work well for other mtu sizes as well.
24927c478bd9Sstevel@tonic-gate  */
24937c478bd9Sstevel@tonic-gate #define	COMMON_IP_MTU 1500
24947c478bd9Sstevel@tonic-gate #define	MAX_FRAG_MIN 10
24957c478bd9Sstevel@tonic-gate #define	MAX_FRAG_PKTS	\
24967c478bd9Sstevel@tonic-gate 	MAX(MAX_FRAG_MIN, (2 * (ip_reass_queue_bytes / \
24977c478bd9Sstevel@tonic-gate 	    (COMMON_IP_MTU * ILL_FRAG_HASH_TBL_COUNT))))
24987c478bd9Sstevel@tonic-gate 
24997c478bd9Sstevel@tonic-gate /*
25007c478bd9Sstevel@tonic-gate  * Maximum dups allowed per packet.
25017c478bd9Sstevel@tonic-gate  */
25027c478bd9Sstevel@tonic-gate extern uint_t ip_max_frag_dups;
25037c478bd9Sstevel@tonic-gate 
25047c478bd9Sstevel@tonic-gate /*
25057c478bd9Sstevel@tonic-gate  * Per-packet information for received packets and transmitted.
25067c478bd9Sstevel@tonic-gate  * Used by the transport protocols when converting between the packet
25077c478bd9Sstevel@tonic-gate  * and ancillary data and socket options.
25087c478bd9Sstevel@tonic-gate  *
25097c478bd9Sstevel@tonic-gate  * Note: This private data structure and related IPPF_* constant
25107c478bd9Sstevel@tonic-gate  * definitions are exposed to enable compilation of some debugging tools
25117c478bd9Sstevel@tonic-gate  * like lsof which use struct tcp_t in <inet/tcp.h>. This is intended to be
25127c478bd9Sstevel@tonic-gate  * a temporary hack and long term alternate interfaces should be defined
25137c478bd9Sstevel@tonic-gate  * to support the needs of such tools and private definitions moved to
25147c478bd9Sstevel@tonic-gate  * private headers.
25157c478bd9Sstevel@tonic-gate  */
25167c478bd9Sstevel@tonic-gate struct ip6_pkt_s {
25177c478bd9Sstevel@tonic-gate 	uint_t		ipp_fields;		/* Which fields are valid */
25187c478bd9Sstevel@tonic-gate 	uint_t		ipp_sticky_ignored;	/* sticky fields to ignore */
25197c478bd9Sstevel@tonic-gate 	uint_t		ipp_ifindex;		/* pktinfo ifindex */
25207c478bd9Sstevel@tonic-gate 	in6_addr_t	ipp_addr;		/* pktinfo src/dst addr */
2521b3d0fa4fSseb 	uint_t		ipp_unicast_hops;	/* IPV6_UNICAST_HOPS */
2522b3d0fa4fSseb 	uint_t		ipp_multicast_hops;	/* IPV6_MULTICAST_HOPS */
2523b3d0fa4fSseb 	uint_t		ipp_hoplimit;		/* IPV6_HOPLIMIT */
25247c478bd9Sstevel@tonic-gate 	uint_t		ipp_hopoptslen;
25257c478bd9Sstevel@tonic-gate 	uint_t		ipp_rtdstoptslen;
25267c478bd9Sstevel@tonic-gate 	uint_t		ipp_rthdrlen;
25277c478bd9Sstevel@tonic-gate 	uint_t		ipp_dstoptslen;
25287c478bd9Sstevel@tonic-gate 	uint_t		ipp_pathmtulen;
25297c478bd9Sstevel@tonic-gate 	ip6_hbh_t	*ipp_hopopts;
25307c478bd9Sstevel@tonic-gate 	ip6_dest_t	*ipp_rtdstopts;
25317c478bd9Sstevel@tonic-gate 	ip6_rthdr_t	*ipp_rthdr;
25327c478bd9Sstevel@tonic-gate 	ip6_dest_t	*ipp_dstopts;
25337c478bd9Sstevel@tonic-gate 	struct ip6_mtuinfo *ipp_pathmtu;
25347c478bd9Sstevel@tonic-gate 	in6_addr_t	ipp_nexthop;		/* Transmit only */
25357c478bd9Sstevel@tonic-gate 	uint8_t		ipp_tclass;
25367c478bd9Sstevel@tonic-gate 	int8_t		ipp_use_min_mtu;
25377c478bd9Sstevel@tonic-gate };
25387c478bd9Sstevel@tonic-gate typedef struct ip6_pkt_s ip6_pkt_t;
25397c478bd9Sstevel@tonic-gate 
2540*45916cd2Sjpk extern void ip6_pkt_free(ip6_pkt_t *);	/* free storage inside ip6_pkt_t */
2541*45916cd2Sjpk 
25427c478bd9Sstevel@tonic-gate /*
25437c478bd9Sstevel@tonic-gate  * This structure is used to convey information from IP and the ULP.
25447c478bd9Sstevel@tonic-gate  * Currently used for the IP_RECVSLLA and IP_RECVIF options. The
25457c478bd9Sstevel@tonic-gate  * type of information field is set to IN_PKTINFO (i.e inbound pkt info)
25467c478bd9Sstevel@tonic-gate  */
25477c478bd9Sstevel@tonic-gate typedef struct in_pktinfo {
25487c478bd9Sstevel@tonic-gate 	uint32_t		in_pkt_ulp_type;	/* type of info sent */
25497c478bd9Sstevel@tonic-gate 							/* to UDP */
25507c478bd9Sstevel@tonic-gate 	uint32_t		in_pkt_flags;	/* what is sent up by IP */
25517c478bd9Sstevel@tonic-gate 	uint32_t		in_pkt_ifindex;	/* inbound interface index */
25527c478bd9Sstevel@tonic-gate 	struct sockaddr_dl	in_pkt_slla;	/* has source link layer addr */
25537c478bd9Sstevel@tonic-gate } in_pktinfo_t;
25547c478bd9Sstevel@tonic-gate 
25557c478bd9Sstevel@tonic-gate /*
2556*45916cd2Sjpk  * flags to tell UDP what IP is sending; in_pkt_flags
25577c478bd9Sstevel@tonic-gate  */
25587c478bd9Sstevel@tonic-gate #define	IPF_RECVIF	0x01	/* inbound interface index */
25597c478bd9Sstevel@tonic-gate #define	IPF_RECVSLLA	0x02	/* source link layer address */
25607c478bd9Sstevel@tonic-gate 
25617c478bd9Sstevel@tonic-gate /* ipp_fields values */
25627c478bd9Sstevel@tonic-gate #define	IPPF_IFINDEX	0x0001	/* Part of in6_pktinfo: ifindex */
25637c478bd9Sstevel@tonic-gate #define	IPPF_ADDR	0x0002	/* Part of in6_pktinfo: src/dst addr */
25647c478bd9Sstevel@tonic-gate #define	IPPF_SCOPE_ID	0x0004	/* Add xmit ip6i_t for sin6_scope_id */
25657c478bd9Sstevel@tonic-gate #define	IPPF_NO_CKSUM	0x0008	/* Add xmit ip6i_t for IP6I_NO_*_CKSUM */
25667c478bd9Sstevel@tonic-gate 
25677c478bd9Sstevel@tonic-gate #define	IPPF_RAW_CKSUM	0x0010	/* Add xmit ip6i_t for IP6I_RAW_CHECKSUM */
25687c478bd9Sstevel@tonic-gate #define	IPPF_HOPLIMIT	0x0020
25697c478bd9Sstevel@tonic-gate #define	IPPF_HOPOPTS	0x0040
25707c478bd9Sstevel@tonic-gate #define	IPPF_RTHDR	0x0080
25717c478bd9Sstevel@tonic-gate 
25727c478bd9Sstevel@tonic-gate #define	IPPF_RTDSTOPTS	0x0100
25737c478bd9Sstevel@tonic-gate #define	IPPF_DSTOPTS	0x0200
25747c478bd9Sstevel@tonic-gate #define	IPPF_NEXTHOP	0x0400
25757c478bd9Sstevel@tonic-gate #define	IPPF_PATHMTU	0x0800
25767c478bd9Sstevel@tonic-gate 
25777c478bd9Sstevel@tonic-gate #define	IPPF_TCLASS	0x1000
25787c478bd9Sstevel@tonic-gate #define	IPPF_DONTFRAG	0x2000
2579b3d0fa4fSseb #define	IPPF_USE_MIN_MTU	0x04000
2580b3d0fa4fSseb #define	IPPF_MULTICAST_HOPS	0x08000
2581b3d0fa4fSseb #define	IPPF_UNICAST_HOPS	0x10000
25827c478bd9Sstevel@tonic-gate 
25837c478bd9Sstevel@tonic-gate #define	IPPF_HAS_IP6I \
25847c478bd9Sstevel@tonic-gate 	(IPPF_IFINDEX|IPPF_ADDR|IPPF_NEXTHOP|IPPF_SCOPE_ID| \
25857c478bd9Sstevel@tonic-gate 	IPPF_NO_CKSUM|IPPF_RAW_CKSUM|IPPF_HOPLIMIT|IPPF_DONTFRAG| \
2586b3d0fa4fSseb 	IPPF_USE_MIN_MTU|IPPF_MULTICAST_HOPS|IPPF_UNICAST_HOPS)
25877c478bd9Sstevel@tonic-gate 
25887c478bd9Sstevel@tonic-gate #define	TCP_PORTS_OFFSET	0
25897c478bd9Sstevel@tonic-gate #define	UDP_PORTS_OFFSET	0
25907c478bd9Sstevel@tonic-gate 
25917c478bd9Sstevel@tonic-gate /*
25927c478bd9Sstevel@tonic-gate  * lookups return the ill/ipif only if the flags are clear OR Iam writer.
25937c478bd9Sstevel@tonic-gate  * ill / ipif lookup functions increment the refcnt on the ill / ipif only
25947c478bd9Sstevel@tonic-gate  * after calling these macros. This ensures that the refcnt on the ipif or
25957c478bd9Sstevel@tonic-gate  * ill will eventually drop down to zero.
25967c478bd9Sstevel@tonic-gate  */
25977c478bd9Sstevel@tonic-gate #define	ILL_LOOKUP_FAILED	1	/* Used as error code */
25987c478bd9Sstevel@tonic-gate #define	IPIF_LOOKUP_FAILED	2	/* Used as error code */
25997c478bd9Sstevel@tonic-gate 
26007c478bd9Sstevel@tonic-gate #define	ILL_CAN_LOOKUP(ill) 						\
26017c478bd9Sstevel@tonic-gate 	(!((ill)->ill_state_flags & (ILL_CONDEMNED | ILL_CHANGING)) ||	\
26027c478bd9Sstevel@tonic-gate 	IAM_WRITER_ILL(ill))
26037c478bd9Sstevel@tonic-gate 
26047c478bd9Sstevel@tonic-gate #define	ILL_CAN_WAIT(ill, q)	\
26057c478bd9Sstevel@tonic-gate 	(((q) != NULL) && !((ill)->ill_state_flags & (ILL_CONDEMNED)))
26067c478bd9Sstevel@tonic-gate 
26077c478bd9Sstevel@tonic-gate #define	ILL_CAN_LOOKUP_WALKER(ill)	\
26087c478bd9Sstevel@tonic-gate 	(!((ill)->ill_state_flags & ILL_CONDEMNED))
26097c478bd9Sstevel@tonic-gate 
26107c478bd9Sstevel@tonic-gate #define	IPIF_CAN_LOOKUP(ipif)						\
26117c478bd9Sstevel@tonic-gate 	(!((ipif)->ipif_state_flags & (IPIF_CONDEMNED | IPIF_CHANGING)) || \
26127c478bd9Sstevel@tonic-gate 	IAM_WRITER_IPIF(ipif))
26137c478bd9Sstevel@tonic-gate 
26147c478bd9Sstevel@tonic-gate /*
26157c478bd9Sstevel@tonic-gate  * If the parameter 'q' is NULL, the caller is not interested in wait and
26167c478bd9Sstevel@tonic-gate  * restart of the operation if the ILL or IPIF cannot be looked up when it is
26177c478bd9Sstevel@tonic-gate  * marked as 'CHANGING'. Typically a thread that tries to send out data  will
26187c478bd9Sstevel@tonic-gate  * end up passing NULLs as the last 4 parameters to ill_lookup_on_ifindex and
26197c478bd9Sstevel@tonic-gate  * in this case 'q' is NULL
26207c478bd9Sstevel@tonic-gate  */
26217c478bd9Sstevel@tonic-gate #define	IPIF_CAN_WAIT(ipif, q)	\
26227c478bd9Sstevel@tonic-gate 	(((q) != NULL) && !((ipif)->ipif_state_flags & (IPIF_CONDEMNED)))
26237c478bd9Sstevel@tonic-gate 
26247c478bd9Sstevel@tonic-gate #define	IPIF_CAN_LOOKUP_WALKER(ipif)					\
26257c478bd9Sstevel@tonic-gate 	(!((ipif)->ipif_state_flags & (IPIF_CONDEMNED)) ||		\
26267c478bd9Sstevel@tonic-gate 	IAM_WRITER_IPIF(ipif))
26277c478bd9Sstevel@tonic-gate 
26287c478bd9Sstevel@tonic-gate /*
26297c478bd9Sstevel@tonic-gate  * These macros are used by critical set ioctls and failover ioctls to
26307c478bd9Sstevel@tonic-gate  * mark the ipif appropriately before starting the operation and to clear the
26317c478bd9Sstevel@tonic-gate  * marks after completing the operation.
26327c478bd9Sstevel@tonic-gate  */
26337c478bd9Sstevel@tonic-gate #define	IPIF_UNMARK_MOVING(ipif)                                \
26347c478bd9Sstevel@tonic-gate 	(ipif)->ipif_state_flags &= ~IPIF_MOVING & ~IPIF_CHANGING;
26357c478bd9Sstevel@tonic-gate 
26367c478bd9Sstevel@tonic-gate #define	ILL_UNMARK_CHANGING(ill)                                \
26377c478bd9Sstevel@tonic-gate 	(ill)->ill_state_flags &= ~ILL_CHANGING;
26387c478bd9Sstevel@tonic-gate 
26397c478bd9Sstevel@tonic-gate /* Macros used to assert that this thread is a writer  */
26407c478bd9Sstevel@tonic-gate #define	IAM_WRITER_IPSQ(ipsq)	((ipsq)->ipsq_writer == curthread)
26417c478bd9Sstevel@tonic-gate #define	IAM_WRITER_ILL(ill)					\
26427c478bd9Sstevel@tonic-gate 	((ill)->ill_phyint->phyint_ipsq->ipsq_writer == curthread)
26437c478bd9Sstevel@tonic-gate #define	IAM_WRITER_IPIF(ipif)					\
26447c478bd9Sstevel@tonic-gate 	((ipif)->ipif_ill->ill_phyint->phyint_ipsq->ipsq_writer == curthread)
26457c478bd9Sstevel@tonic-gate 
26467c478bd9Sstevel@tonic-gate /*
26477c478bd9Sstevel@tonic-gate  * Grab ill locks in the proper order. The order is highest addressed
26487c478bd9Sstevel@tonic-gate  * ill is locked first.
26497c478bd9Sstevel@tonic-gate  */
26507c478bd9Sstevel@tonic-gate #define	GRAB_ILL_LOCKS(ill_1, ill_2)				\
26517c478bd9Sstevel@tonic-gate {								\
26527c478bd9Sstevel@tonic-gate 	if ((ill_1) > (ill_2)) {				\
26537c478bd9Sstevel@tonic-gate 		if (ill_1 != NULL)				\
26547c478bd9Sstevel@tonic-gate 			mutex_enter(&(ill_1)->ill_lock);	\
26557c478bd9Sstevel@tonic-gate 		if (ill_2 != NULL)				\
26567c478bd9Sstevel@tonic-gate 			mutex_enter(&(ill_2)->ill_lock);	\
26577c478bd9Sstevel@tonic-gate 	} else {						\
26587c478bd9Sstevel@tonic-gate 		if (ill_2 != NULL)				\
26597c478bd9Sstevel@tonic-gate 			mutex_enter(&(ill_2)->ill_lock);	\
26607c478bd9Sstevel@tonic-gate 		if (ill_1 != NULL && ill_1 != ill_2)		\
26617c478bd9Sstevel@tonic-gate 			mutex_enter(&(ill_1)->ill_lock);	\
26627c478bd9Sstevel@tonic-gate 	}							\
26637c478bd9Sstevel@tonic-gate }
26647c478bd9Sstevel@tonic-gate 
26657c478bd9Sstevel@tonic-gate #define	RELEASE_ILL_LOCKS(ill_1, ill_2)		\
26667c478bd9Sstevel@tonic-gate {						\
26677c478bd9Sstevel@tonic-gate 	if (ill_1 != NULL)			\
26687c478bd9Sstevel@tonic-gate 		mutex_exit(&(ill_1)->ill_lock);	\
26697c478bd9Sstevel@tonic-gate 	if (ill_2 != NULL && ill_2 != ill_1)	\
26707c478bd9Sstevel@tonic-gate 		mutex_exit(&(ill_2)->ill_lock);	\
26717c478bd9Sstevel@tonic-gate }
26727c478bd9Sstevel@tonic-gate 
26737c478bd9Sstevel@tonic-gate /* Get the other protocol instance ill */
26747c478bd9Sstevel@tonic-gate #define	ILL_OTHER(ill)						\
26757c478bd9Sstevel@tonic-gate 	((ill)->ill_isv6 ? (ill)->ill_phyint->phyint_illv4 :	\
26767c478bd9Sstevel@tonic-gate 	    (ill)->ill_phyint->phyint_illv6)
26777c478bd9Sstevel@tonic-gate 
26787c478bd9Sstevel@tonic-gate #define	MATCH_V4_ONLY	0x1
26797c478bd9Sstevel@tonic-gate #define	MATCH_V6_ONLY	0x2
26807c478bd9Sstevel@tonic-gate #define	MATCH_ILL_ONLY	0x4
26817c478bd9Sstevel@tonic-gate 
26827c478bd9Sstevel@tonic-gate /* ioctl command info: Ioctl properties extracted and stored in here */
26837c478bd9Sstevel@tonic-gate typedef struct cmd_info_s
26847c478bd9Sstevel@tonic-gate {
26857c478bd9Sstevel@tonic-gate 	char    ci_groupname[LIFNAMSIZ + 1];	/* SIOCSLIFGROUPNAME */
26867c478bd9Sstevel@tonic-gate 	ipif_t  *ci_ipif;	/* ipif associated with [l]ifreq ioctl's */
26877c478bd9Sstevel@tonic-gate 	sin_t	*ci_sin;	/* the sin struct passed down */
26887c478bd9Sstevel@tonic-gate 	sin6_t	*ci_sin6;	/* the sin6_t struct passed down */
26897c478bd9Sstevel@tonic-gate 	struct lifreq *ci_lifr;	/* the lifreq struct passed down */
26907c478bd9Sstevel@tonic-gate } cmd_info_t;
26917c478bd9Sstevel@tonic-gate 
26927c478bd9Sstevel@tonic-gate extern krwlock_t ill_g_lock;
26937c478bd9Sstevel@tonic-gate extern kmutex_t ip_addr_avail_lock;
26947c478bd9Sstevel@tonic-gate extern ipsq_t	*ipsq_g_head;
26957c478bd9Sstevel@tonic-gate 
26967c478bd9Sstevel@tonic-gate extern ill_t	*ip_timer_ill;		/* ILL for IRE expiration timer. */
26977c478bd9Sstevel@tonic-gate extern timeout_id_t ip_ire_expire_id;	/* IRE expiration timeout id. */
26987c478bd9Sstevel@tonic-gate extern timeout_id_t ip_ire_reclaim_id;	/* IRE recalaim timeout id. */
26997c478bd9Sstevel@tonic-gate 
27007c478bd9Sstevel@tonic-gate extern kmutex_t	ip_mi_lock;
27017c478bd9Sstevel@tonic-gate extern krwlock_t ip_g_nd_lock;		/* For adding/removing nd variables */
27027c478bd9Sstevel@tonic-gate extern kmutex_t ip_trash_timer_lock;	/* Protects ip_ire_expire_id */
27037c478bd9Sstevel@tonic-gate 
27047c478bd9Sstevel@tonic-gate extern kmutex_t igmp_timer_lock;	/* Protects the igmp timer */
27057c478bd9Sstevel@tonic-gate extern kmutex_t mld_timer_lock;		/* Protects the mld timer */
27067c478bd9Sstevel@tonic-gate 
27077c478bd9Sstevel@tonic-gate extern krwlock_t ill_g_usesrc_lock;	/* Protects usesrc related fields */
27087c478bd9Sstevel@tonic-gate 
27097c478bd9Sstevel@tonic-gate extern struct kmem_cache *ire_cache;
27107c478bd9Sstevel@tonic-gate 
27117c478bd9Sstevel@tonic-gate extern uint_t	ip_ire_default_count;	/* Number of IPv4 IRE_DEFAULT entries */
27127c478bd9Sstevel@tonic-gate extern uint_t	ip_ire_default_index;	/* Walking index used to mod in */
27137c478bd9Sstevel@tonic-gate 
27147c478bd9Sstevel@tonic-gate extern ipaddr_t	ip_g_all_ones;
27157c478bd9Sstevel@tonic-gate extern caddr_t	ip_g_nd;		/* Named Dispatch List Head */
27167c478bd9Sstevel@tonic-gate 
27177c478bd9Sstevel@tonic-gate extern uint_t	ip_loopback_mtu;
27187c478bd9Sstevel@tonic-gate 
27197c478bd9Sstevel@tonic-gate extern ipparam_t	*ip_param_arr;
27207c478bd9Sstevel@tonic-gate 
27217c478bd9Sstevel@tonic-gate extern int ip_g_forward;
27227c478bd9Sstevel@tonic-gate extern int ipv6_forward;
2723ff550d0eSmasputra extern vmem_t *ip_minor_arena;
27247c478bd9Sstevel@tonic-gate 
27257c478bd9Sstevel@tonic-gate #define	ip_respond_to_address_mask_broadcast ip_param_arr[0].ip_param_value
27267c478bd9Sstevel@tonic-gate #define	ip_g_send_redirects		ip_param_arr[5].ip_param_value
27277c478bd9Sstevel@tonic-gate #define	ip_debug			ip_param_arr[7].ip_param_value
27287c478bd9Sstevel@tonic-gate #define	ip_mrtdebug			ip_param_arr[8].ip_param_value
27297c478bd9Sstevel@tonic-gate #define	ip_timer_interval		ip_param_arr[9].ip_param_value
27307c478bd9Sstevel@tonic-gate #define	ip_ire_arp_interval		ip_param_arr[10].ip_param_value
27317c478bd9Sstevel@tonic-gate #define	ip_def_ttl			ip_param_arr[12].ip_param_value
27327c478bd9Sstevel@tonic-gate #define	ip_wroff_extra			ip_param_arr[14].ip_param_value
27337c478bd9Sstevel@tonic-gate #define	ip_path_mtu_discovery		ip_param_arr[17].ip_param_value
27347c478bd9Sstevel@tonic-gate #define	ip_ignore_delete_time		ip_param_arr[18].ip_param_value
27357c478bd9Sstevel@tonic-gate #define	ip_output_queue			ip_param_arr[20].ip_param_value
27367c478bd9Sstevel@tonic-gate #define	ip_broadcast_ttl		ip_param_arr[21].ip_param_value
27377c478bd9Sstevel@tonic-gate #define	ip_icmp_err_interval		ip_param_arr[22].ip_param_value
27387c478bd9Sstevel@tonic-gate #define	ip_icmp_err_burst		ip_param_arr[23].ip_param_value
27397c478bd9Sstevel@tonic-gate #define	ip_reass_queue_bytes		ip_param_arr[24].ip_param_value
27407c478bd9Sstevel@tonic-gate #define	ip_addrs_per_if			ip_param_arr[26].ip_param_value
27417c478bd9Sstevel@tonic-gate #define	ipsec_override_persocket_policy	ip_param_arr[27].ip_param_value
27427c478bd9Sstevel@tonic-gate #define	icmp_accept_clear_messages	ip_param_arr[28].ip_param_value
27437c478bd9Sstevel@tonic-gate #define	delay_first_probe_time		ip_param_arr[30].ip_param_value
27447c478bd9Sstevel@tonic-gate #define	max_unicast_solicit		ip_param_arr[31].ip_param_value
27457c478bd9Sstevel@tonic-gate #define	ipv6_def_hops			ip_param_arr[32].ip_param_value
27467c478bd9Sstevel@tonic-gate #define	ipv6_icmp_return		ip_param_arr[33].ip_param_value
27477c478bd9Sstevel@tonic-gate #define	ipv6_forward_src_routed		ip_param_arr[34].ip_param_value
27487c478bd9Sstevel@tonic-gate #define	ipv6_resp_echo_mcast		ip_param_arr[35].ip_param_value
27497c478bd9Sstevel@tonic-gate #define	ipv6_send_redirects		ip_param_arr[36].ip_param_value
27507c478bd9Sstevel@tonic-gate #define	ipv6_ignore_redirect		ip_param_arr[37].ip_param_value
27517c478bd9Sstevel@tonic-gate #define	ipv6_strict_dst_multihoming	ip_param_arr[38].ip_param_value
27527c478bd9Sstevel@tonic-gate #define	ip_ire_reclaim_fraction		ip_param_arr[39].ip_param_value
27537c478bd9Sstevel@tonic-gate #define	ipsec_policy_log_interval	ip_param_arr[40].ip_param_value
27547c478bd9Sstevel@tonic-gate #define	ip_ndp_unsolicit_interval	ip_param_arr[42].ip_param_value
27557c478bd9Sstevel@tonic-gate #define	ip_ndp_unsolicit_count		ip_param_arr[43].ip_param_value
27567c478bd9Sstevel@tonic-gate #define	ipv6_ignore_home_address_opt	ip_param_arr[44].ip_param_value
27577c478bd9Sstevel@tonic-gate #define	ip_policy_mask			ip_param_arr[45].ip_param_value
27587c478bd9Sstevel@tonic-gate #define	ip_multirt_resolution_interval	ip_param_arr[46].ip_param_value
27597c478bd9Sstevel@tonic-gate #define	ip_multirt_ttl			ip_param_arr[47].ip_param_value
27607c478bd9Sstevel@tonic-gate #define	ip_multidata_outbound		ip_param_arr[48].ip_param_value
27617c478bd9Sstevel@tonic-gate #ifdef DEBUG
27627c478bd9Sstevel@tonic-gate #define	ipv6_drop_inbound_icmpv6	ip_param_arr[49].ip_param_value
27637c478bd9Sstevel@tonic-gate #else
27647c478bd9Sstevel@tonic-gate #define	ipv6_drop_inbound_icmpv6	0
27657c478bd9Sstevel@tonic-gate #endif
27667c478bd9Sstevel@tonic-gate 
27677c478bd9Sstevel@tonic-gate extern hrtime_t	ipsec_policy_failure_last;
27687c478bd9Sstevel@tonic-gate 
27697c478bd9Sstevel@tonic-gate extern int	dohwcksum;	/* use h/w cksum if supported by the h/w */
27707c478bd9Sstevel@tonic-gate #ifdef ZC_TEST
27717c478bd9Sstevel@tonic-gate extern int	noswcksum;
27727c478bd9Sstevel@tonic-gate #endif
27737c478bd9Sstevel@tonic-gate 
27747c478bd9Sstevel@tonic-gate extern char	ipif_loopback_name[];
27757c478bd9Sstevel@tonic-gate 
27767c478bd9Sstevel@tonic-gate extern nv_t	*ire_nv_tbl;
27777c478bd9Sstevel@tonic-gate 
27787c478bd9Sstevel@tonic-gate extern time_t	ip_g_frag_timeout;
27797c478bd9Sstevel@tonic-gate extern clock_t	ip_g_frag_timo_ms;
27807c478bd9Sstevel@tonic-gate 
27817c478bd9Sstevel@tonic-gate extern mib2_ip_t	ip_mib;	/* For tcpInErrs and udpNoPorts */
27827c478bd9Sstevel@tonic-gate 
27837c478bd9Sstevel@tonic-gate extern struct module_info ip_mod_info;
27847c478bd9Sstevel@tonic-gate 
27857c478bd9Sstevel@tonic-gate extern timeout_id_t	igmp_slowtimeout_id;
27867c478bd9Sstevel@tonic-gate extern timeout_id_t	mld_slowtimeout_id;
27877c478bd9Sstevel@tonic-gate 
27887c478bd9Sstevel@tonic-gate extern uint_t	loopback_packets;
27897c478bd9Sstevel@tonic-gate 
27907c478bd9Sstevel@tonic-gate /*
27917c478bd9Sstevel@tonic-gate  * Network byte order macros
27927c478bd9Sstevel@tonic-gate  */
27937c478bd9Sstevel@tonic-gate #ifdef	_BIG_ENDIAN
27947c478bd9Sstevel@tonic-gate #define	N_IN_CLASSD_NET		IN_CLASSD_NET
27957c478bd9Sstevel@tonic-gate #define	N_INADDR_UNSPEC_GROUP	INADDR_UNSPEC_GROUP
27967c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */
27977c478bd9Sstevel@tonic-gate #define	N_IN_CLASSD_NET		(ipaddr_t)0x000000f0U
27987c478bd9Sstevel@tonic-gate #define	N_INADDR_UNSPEC_GROUP	(ipaddr_t)0x000000e0U
27997c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */
28007c478bd9Sstevel@tonic-gate #define	CLASSD(addr)	(((addr) & N_IN_CLASSD_NET) == N_INADDR_UNSPEC_GROUP)
28017c478bd9Sstevel@tonic-gate 
28027c478bd9Sstevel@tonic-gate #ifdef DEBUG
28037c478bd9Sstevel@tonic-gate /* IPsec HW acceleration debugging support */
28047c478bd9Sstevel@tonic-gate 
28057c478bd9Sstevel@tonic-gate #define	IPSECHW_CAPAB		0x0001	/* capability negotiation */
28067c478bd9Sstevel@tonic-gate #define	IPSECHW_SADB		0x0002	/* SADB exchange */
28077c478bd9Sstevel@tonic-gate #define	IPSECHW_PKT		0x0004	/* general packet flow */
28087c478bd9Sstevel@tonic-gate #define	IPSECHW_PKTIN		0x0008	/* driver in pkt processing details */
28097c478bd9Sstevel@tonic-gate #define	IPSECHW_PKTOUT		0x0010	/* driver out pkt processing details */
28107c478bd9Sstevel@tonic-gate 
28117c478bd9Sstevel@tonic-gate #define	IPSECHW_DEBUG(f, x)	if (ipsechw_debug & (f)) { (void) printf x; }
28127c478bd9Sstevel@tonic-gate #define	IPSECHW_CALL(f, r, x)	if (ipsechw_debug & (f)) { (void) r x; }
28137c478bd9Sstevel@tonic-gate 
28147c478bd9Sstevel@tonic-gate extern uint32_t ipsechw_debug;
28157c478bd9Sstevel@tonic-gate #else
28167c478bd9Sstevel@tonic-gate #define	IPSECHW_DEBUG(f, x)	{}
28177c478bd9Sstevel@tonic-gate #define	IPSECHW_CALL(f, r, x)	{}
28187c478bd9Sstevel@tonic-gate #endif
28197c478bd9Sstevel@tonic-gate 
28207c478bd9Sstevel@tonic-gate #ifdef IP_DEBUG
28217c478bd9Sstevel@tonic-gate #include <sys/debug.h>
28227c478bd9Sstevel@tonic-gate #include <sys/promif.h>
28237c478bd9Sstevel@tonic-gate 
28247c478bd9Sstevel@tonic-gate #define	ip0dbg(a)	printf a
28257c478bd9Sstevel@tonic-gate #define	ip1dbg(a)	if (ip_debug > 2) printf a
28267c478bd9Sstevel@tonic-gate #define	ip2dbg(a)	if (ip_debug > 3) printf a
28277c478bd9Sstevel@tonic-gate #define	ip3dbg(a)	if (ip_debug > 4) printf a
28287c478bd9Sstevel@tonic-gate #else
28297c478bd9Sstevel@tonic-gate #define	ip0dbg(a)	/* */
28307c478bd9Sstevel@tonic-gate #define	ip1dbg(a)	/* */
28317c478bd9Sstevel@tonic-gate #define	ip2dbg(a)	/* */
28327c478bd9Sstevel@tonic-gate #define	ip3dbg(a)	/* */
28337c478bd9Sstevel@tonic-gate #endif	/* IP_DEBUG */
28347c478bd9Sstevel@tonic-gate 
28357c478bd9Sstevel@tonic-gate extern const char *dlpi_prim_str(int);
28367c478bd9Sstevel@tonic-gate extern const char *dlpi_err_str(int);
28377c478bd9Sstevel@tonic-gate extern void	ill_frag_timer(void *);
28387c478bd9Sstevel@tonic-gate extern ill_t	*ill_first(int, int, ill_walk_context_t *);
28397c478bd9Sstevel@tonic-gate extern ill_t	*ill_next(ill_walk_context_t *, ill_t *);
28407c478bd9Sstevel@tonic-gate extern void	ill_frag_timer_start(ill_t *);
28417c478bd9Sstevel@tonic-gate extern mblk_t	*ip_carve_mp(mblk_t **, ssize_t);
28427c478bd9Sstevel@tonic-gate extern mblk_t	*ip_dlpi_alloc(size_t, t_uscalar_t);
28437c478bd9Sstevel@tonic-gate extern char	*ip_dot_addr(ipaddr_t, char *);
28447c478bd9Sstevel@tonic-gate extern void	ip_lwput(queue_t *, mblk_t *);
28457c478bd9Sstevel@tonic-gate extern boolean_t icmp_err_rate_limit(void);
28467c478bd9Sstevel@tonic-gate extern void	icmp_time_exceeded(queue_t *, mblk_t *, uint8_t);
28477c478bd9Sstevel@tonic-gate extern void	icmp_unreachable(queue_t *, mblk_t *, uint8_t);
28487c478bd9Sstevel@tonic-gate extern mblk_t	*ip_add_info(mblk_t *, ill_t *, uint_t);
28497c478bd9Sstevel@tonic-gate extern mblk_t	*ip_bind_v4(queue_t *, mblk_t *, conn_t *);
28507c478bd9Sstevel@tonic-gate extern int	ip_bind_connected(conn_t *, mblk_t *, ipaddr_t *, uint16_t,
28517c478bd9Sstevel@tonic-gate     ipaddr_t, uint16_t, boolean_t, boolean_t, boolean_t,
28527c478bd9Sstevel@tonic-gate     boolean_t);
28537c478bd9Sstevel@tonic-gate extern boolean_t ip_bind_ipsec_policy_set(conn_t *, mblk_t *);
28547c478bd9Sstevel@tonic-gate extern int	ip_bind_laddr(conn_t *, mblk_t *, ipaddr_t, uint16_t,
28557c478bd9Sstevel@tonic-gate     boolean_t, boolean_t, boolean_t);
28567c478bd9Sstevel@tonic-gate extern uint_t	ip_cksum(mblk_t *, int, uint32_t);
28577c478bd9Sstevel@tonic-gate extern int	ip_close(queue_t *, int);
28587c478bd9Sstevel@tonic-gate extern uint16_t	ip_csum_hdr(ipha_t *);
28597c478bd9Sstevel@tonic-gate extern void	ip_proto_not_sup(queue_t *, mblk_t *, uint_t, zoneid_t);
28607c478bd9Sstevel@tonic-gate extern void	ip_ire_fini(void);
28617c478bd9Sstevel@tonic-gate extern void	ip_ire_init(void);
28627c478bd9Sstevel@tonic-gate extern int	ip_open(queue_t *, dev_t *, int, int, cred_t *);
28637c478bd9Sstevel@tonic-gate extern int	ip_reassemble(mblk_t *, ipf_t *, uint_t, boolean_t, ill_t *,
28647c478bd9Sstevel@tonic-gate     size_t);
28657c478bd9Sstevel@tonic-gate extern int	ip_opt_set_ill(conn_t *, int, boolean_t, boolean_t,
28667c478bd9Sstevel@tonic-gate     int, int, mblk_t *);
28677c478bd9Sstevel@tonic-gate extern void	ip_rput(queue_t *, mblk_t *);
28687c478bd9Sstevel@tonic-gate extern void	ip_input(ill_t *, ill_rx_ring_t *, mblk_t *, size_t);
28697c478bd9Sstevel@tonic-gate extern void	ip_rput_dlpi(queue_t *, mblk_t *);
28707c478bd9Sstevel@tonic-gate extern void	ip_rput_forward(ire_t *, ipha_t *, mblk_t *, ill_t *);
28717c478bd9Sstevel@tonic-gate extern void	ip_rput_forward_multicast(ipaddr_t, mblk_t *, ipif_t *);
2872ff550d0eSmasputra 
2873ff550d0eSmasputra extern int	ip_snmpmod_close(queue_t *);
2874ff550d0eSmasputra extern void	ip_snmpmod_wput(queue_t *, mblk_t *);
28757c478bd9Sstevel@tonic-gate extern void	ip_udp_input(queue_t *, mblk_t *, ipha_t *, ire_t *, ill_t *);
28767c478bd9Sstevel@tonic-gate extern void	ip_proto_input(queue_t *, mblk_t *, ipha_t *, ire_t *, ill_t *);
28777c478bd9Sstevel@tonic-gate extern void	ip_rput_other(ipsq_t *, queue_t *, mblk_t *, void *);
28787c478bd9Sstevel@tonic-gate extern void	ip_setqinfo(queue_t *, minor_t, boolean_t);
28797c478bd9Sstevel@tonic-gate extern void	ip_trash_ire_reclaim(void *);
28807c478bd9Sstevel@tonic-gate extern void	ip_trash_timer_expire(void *);
28817c478bd9Sstevel@tonic-gate extern void	ip_wput(queue_t *, mblk_t *);
28827c478bd9Sstevel@tonic-gate extern void	ip_output(void *, mblk_t *, void *, int);
28837c478bd9Sstevel@tonic-gate extern void	ip_wput_md(queue_t *, mblk_t *, conn_t *);
28847c478bd9Sstevel@tonic-gate 
28857c478bd9Sstevel@tonic-gate extern void	ip_wput_ire(queue_t *, mblk_t *, ire_t *, conn_t *, int);
28867c478bd9Sstevel@tonic-gate extern void	ip_wput_local(queue_t *, ill_t *, ipha_t *, mblk_t *, ire_t *,
28877c478bd9Sstevel@tonic-gate     int, zoneid_t);
28887c478bd9Sstevel@tonic-gate extern void	ip_wput_multicast(queue_t *, mblk_t *, ipif_t *);
28897c478bd9Sstevel@tonic-gate extern void	ip_wput_nondata(ipsq_t *, queue_t *, mblk_t *, void *);
28907c478bd9Sstevel@tonic-gate extern void	ip_wsrv(queue_t *);
28917c478bd9Sstevel@tonic-gate extern char	*ip_nv_lookup(nv_t *, int);
28927c478bd9Sstevel@tonic-gate extern boolean_t ip_local_addr_ok_v6(const in6_addr_t *, const in6_addr_t *);
28937c478bd9Sstevel@tonic-gate extern boolean_t ip_remote_addr_ok_v6(const in6_addr_t *, const in6_addr_t *);
28947c478bd9Sstevel@tonic-gate extern ipaddr_t ip_massage_options(ipha_t *);
28957c478bd9Sstevel@tonic-gate extern ipaddr_t ip_net_mask(ipaddr_t);
28967c478bd9Sstevel@tonic-gate extern void	ip_newroute(queue_t *, mblk_t *, ipaddr_t, ill_t *, conn_t *);
28977c478bd9Sstevel@tonic-gate 
28987c478bd9Sstevel@tonic-gate extern struct qinit rinit_ipv6;
28997c478bd9Sstevel@tonic-gate extern struct qinit winit_ipv6;
29007c478bd9Sstevel@tonic-gate extern struct qinit rinit_tcp;
29017c478bd9Sstevel@tonic-gate extern struct qinit rinit_tcp6;
29027c478bd9Sstevel@tonic-gate extern struct qinit winit_tcp;
29037c478bd9Sstevel@tonic-gate extern struct qinit rinit_acceptor_tcp;
29047c478bd9Sstevel@tonic-gate extern struct qinit winit_acceptor_tcp;
29057c478bd9Sstevel@tonic-gate 
29067c478bd9Sstevel@tonic-gate extern void	conn_drain_insert(conn_t *connp);
29077c478bd9Sstevel@tonic-gate extern	int	conn_ipsec_length(conn_t *connp);
29087c478bd9Sstevel@tonic-gate extern void	ip_wput_ipsec_out(queue_t *, mblk_t *, ipha_t *, ill_t *,
29097c478bd9Sstevel@tonic-gate     ire_t *);
29107c478bd9Sstevel@tonic-gate extern ipaddr_t	ip_get_dst(ipha_t *);
29117c478bd9Sstevel@tonic-gate extern int	ipsec_out_extra_length(mblk_t *);
29127c478bd9Sstevel@tonic-gate extern int	ipsec_in_extra_length(mblk_t *);
29137c478bd9Sstevel@tonic-gate extern mblk_t	*ipsec_in_alloc();
29147c478bd9Sstevel@tonic-gate extern boolean_t ipsec_in_is_secure(mblk_t *);
29157c478bd9Sstevel@tonic-gate extern void	ipsec_out_process(queue_t *, mblk_t *, ire_t *, uint_t);
29167c478bd9Sstevel@tonic-gate extern void	ipsec_out_to_in(mblk_t *);
29177c478bd9Sstevel@tonic-gate extern int	ill_forward_set(queue_t *, mblk_t *, boolean_t, caddr_t);
29187c478bd9Sstevel@tonic-gate extern void	ip_fanout_proto_again(mblk_t *, ill_t *, ill_t *, ire_t *);
29197c478bd9Sstevel@tonic-gate 
29207c478bd9Sstevel@tonic-gate extern void	ire_cleanup(ire_t *);
29217c478bd9Sstevel@tonic-gate extern void	ire_inactive(ire_t *);
29227c478bd9Sstevel@tonic-gate extern ire_t	*ire_unlink(irb_t *);
29237c478bd9Sstevel@tonic-gate #ifdef IRE_DEBUG
29247c478bd9Sstevel@tonic-gate extern	void	ire_trace_ref(ire_t *ire);
29257c478bd9Sstevel@tonic-gate extern	void	ire_untrace_ref(ire_t *ire);
29267c478bd9Sstevel@tonic-gate extern	void	ire_thread_exit(ire_t *ire, caddr_t);
29277c478bd9Sstevel@tonic-gate #endif
29287c478bd9Sstevel@tonic-gate #ifdef ILL_DEBUG
29297c478bd9Sstevel@tonic-gate extern	void	ill_trace_cleanup(ill_t *);
29307c478bd9Sstevel@tonic-gate extern	void	ipif_trace_cleanup(ipif_t *);
29317c478bd9Sstevel@tonic-gate #endif
29327c478bd9Sstevel@tonic-gate 
29337c478bd9Sstevel@tonic-gate extern int	ip_srcid_insert(const in6_addr_t *, zoneid_t);
29347c478bd9Sstevel@tonic-gate extern int	ip_srcid_remove(const in6_addr_t *, zoneid_t);
29357c478bd9Sstevel@tonic-gate extern void	ip_srcid_find_id(uint_t, in6_addr_t *, zoneid_t);
29367c478bd9Sstevel@tonic-gate extern uint_t	ip_srcid_find_addr(const in6_addr_t *, zoneid_t);
29377c478bd9Sstevel@tonic-gate extern int	ip_srcid_report(queue_t *, mblk_t *, caddr_t, cred_t *);
29387c478bd9Sstevel@tonic-gate 
29397c478bd9Sstevel@tonic-gate extern uint8_t	ipoptp_next(ipoptp_t *);
29407c478bd9Sstevel@tonic-gate extern uint8_t	ipoptp_first(ipoptp_t *, ipha_t *);
2941*45916cd2Sjpk extern int	ip_opt_get_user(const ipha_t *, uchar_t *);
29427c478bd9Sstevel@tonic-gate extern ill_t	*ip_grab_attach_ill(ill_t *, mblk_t *, int, boolean_t);
29437c478bd9Sstevel@tonic-gate extern ire_t	*conn_set_outgoing_ill(conn_t *, ire_t *, ill_t **);
29447c478bd9Sstevel@tonic-gate extern int	ipsec_req_from_conn(conn_t *, ipsec_req_t *, int);
29457c478bd9Sstevel@tonic-gate extern int	ip_snmp_get(queue_t *q, mblk_t *mctl);
29467c478bd9Sstevel@tonic-gate extern int	ip_snmp_set(queue_t *q, int, int, uchar_t *, int);
29477c478bd9Sstevel@tonic-gate extern void	ip_process_ioctl(ipsq_t *, queue_t *, mblk_t *, void *);
2948ff550d0eSmasputra extern void	ip_quiesce_conn(conn_t *);
29497c478bd9Sstevel@tonic-gate extern  void    ip_reprocess_ioctl(ipsq_t *, queue_t *, mblk_t *, void *);
29507c478bd9Sstevel@tonic-gate extern void	ip_restart_optmgmt(ipsq_t *, queue_t *, mblk_t *, void *);
29517c478bd9Sstevel@tonic-gate extern void	ip_ioctl_finish(queue_t *, mblk_t *, int, int, ipif_t *,
29527c478bd9Sstevel@tonic-gate     ipsq_t *);
29537c478bd9Sstevel@tonic-gate 
2954*45916cd2Sjpk extern boolean_t ip_cmpbuf(const void *, uint_t, boolean_t, const void *,
2955*45916cd2Sjpk     uint_t);
2956*45916cd2Sjpk extern boolean_t ip_allocbuf(void **, uint_t *, boolean_t, const void *,
2957*45916cd2Sjpk     uint_t);
2958*45916cd2Sjpk extern void	ip_savebuf(void **, uint_t *, boolean_t, const void *, uint_t);
2959*45916cd2Sjpk 
29607c478bd9Sstevel@tonic-gate extern boolean_t	ipsq_pending_mp_cleanup(ill_t *, conn_t *);
29617c478bd9Sstevel@tonic-gate extern void	conn_ioctl_cleanup(conn_t *);
29627c478bd9Sstevel@tonic-gate extern ill_t	*conn_get_held_ill(conn_t *, ill_t **, int *);
29637c478bd9Sstevel@tonic-gate 
29647c478bd9Sstevel@tonic-gate struct multidata_s;
29657c478bd9Sstevel@tonic-gate struct pdesc_s;
29667c478bd9Sstevel@tonic-gate 
29677c478bd9Sstevel@tonic-gate extern mblk_t	*ip_mdinfo_alloc(ill_mdt_capab_t *);
29687c478bd9Sstevel@tonic-gate extern mblk_t	*ip_mdinfo_return(ire_t *, conn_t *, char *, ill_mdt_capab_t *);
29697c478bd9Sstevel@tonic-gate extern uint_t	ip_md_cksum(struct pdesc_s *, int, uint_t);
29707c478bd9Sstevel@tonic-gate extern boolean_t ip_md_addr_attr(struct multidata_s *, struct pdesc_s *,
29717c478bd9Sstevel@tonic-gate 			const mblk_t *);
29727c478bd9Sstevel@tonic-gate extern boolean_t ip_md_hcksum_attr(struct multidata_s *, struct pdesc_s *,
29737c478bd9Sstevel@tonic-gate 			uint32_t, uint32_t, uint32_t, uint32_t);
29747c478bd9Sstevel@tonic-gate extern boolean_t ip_md_zcopy_attr(struct multidata_s *, struct pdesc_s *,
29757c478bd9Sstevel@tonic-gate 			uint_t);
2976ff550d0eSmasputra extern mblk_t	*ip_unbind(queue_t *, mblk_t *);
29777c478bd9Sstevel@tonic-gate 
2978*45916cd2Sjpk extern void tnet_init(void);
2979*45916cd2Sjpk extern void tnet_fini(void);
2980*45916cd2Sjpk 
29817c478bd9Sstevel@tonic-gate /* Hooks for CGTP (multirt routes) filtering module */
29827c478bd9Sstevel@tonic-gate #define	CGTP_FILTER_REV_1	1
29837c478bd9Sstevel@tonic-gate #define	CGTP_FILTER_REV_2	2
29847c478bd9Sstevel@tonic-gate #define	CGTP_FILTER_REV		CGTP_FILTER_REV_2
29857c478bd9Sstevel@tonic-gate 
29867c478bd9Sstevel@tonic-gate /* cfo_filter, cfo_filter_fp, cfo_filter_v6 hooks return values */
29877c478bd9Sstevel@tonic-gate #define	CGTP_IP_PKT_NOT_CGTP	0
29887c478bd9Sstevel@tonic-gate #define	CGTP_IP_PKT_PREMIUM	1
29897c478bd9Sstevel@tonic-gate #define	CGTP_IP_PKT_DUPLICATE	2
29907c478bd9Sstevel@tonic-gate 
29917c478bd9Sstevel@tonic-gate typedef struct cgtp_filter_ops {
29927c478bd9Sstevel@tonic-gate 	int	cfo_filter_rev;
29937c478bd9Sstevel@tonic-gate 	int	(*cfo_change_state)(int);
29947c478bd9Sstevel@tonic-gate 	int	(*cfo_add_dest_v4)(ipaddr_t, ipaddr_t, ipaddr_t, ipaddr_t);
29957c478bd9Sstevel@tonic-gate 	int	(*cfo_del_dest_v4)(ipaddr_t, ipaddr_t);
29967c478bd9Sstevel@tonic-gate 	int	(*cfo_add_dest_v6)(in6_addr_t *, in6_addr_t *, in6_addr_t *,
29977c478bd9Sstevel@tonic-gate 		    in6_addr_t *);
29987c478bd9Sstevel@tonic-gate 	int	(*cfo_del_dest_v6)(in6_addr_t *, in6_addr_t *);
29997c478bd9Sstevel@tonic-gate 	int	(*cfo_filter)(queue_t *, mblk_t *);
30007c478bd9Sstevel@tonic-gate 	int	(*cfo_filter_fp)(queue_t *, mblk_t *);
30017c478bd9Sstevel@tonic-gate 	int	(*cfo_filter_v6)(queue_t *, ip6_t *, ip6_frag_t *);
30027c478bd9Sstevel@tonic-gate } cgtp_filter_ops_t;
30037c478bd9Sstevel@tonic-gate 
30047c478bd9Sstevel@tonic-gate #define	CGTP_MCAST_SUCCESS	1
30057c478bd9Sstevel@tonic-gate 
30067c478bd9Sstevel@tonic-gate extern cgtp_filter_ops_t *ip_cgtp_filter_ops;
30077c478bd9Sstevel@tonic-gate extern boolean_t ip_cgtp_filter;
30087c478bd9Sstevel@tonic-gate 
30097c478bd9Sstevel@tonic-gate extern int	ip_cgtp_filter_supported(void);
30107c478bd9Sstevel@tonic-gate extern int	ip_cgtp_filter_register(cgtp_filter_ops_t *);
30117c478bd9Sstevel@tonic-gate 
30127c478bd9Sstevel@tonic-gate /* Flags for ire_multirt_lookup() */
30137c478bd9Sstevel@tonic-gate 
30147c478bd9Sstevel@tonic-gate #define	MULTIRT_USESTAMP	0x0001
30157c478bd9Sstevel@tonic-gate #define	MULTIRT_SETSTAMP	0x0002
30167c478bd9Sstevel@tonic-gate #define	MULTIRT_CACHEGW		0x0004
30177c478bd9Sstevel@tonic-gate 
30187c478bd9Sstevel@tonic-gate /* Debug stuff for multirt route resolution. */
30197c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(__lint)
30207c478bd9Sstevel@tonic-gate /* Our "don't send, rather drop" flag. */
30217c478bd9Sstevel@tonic-gate #define	MULTIRT_DEBUG_FLAG	0x8000
30227c478bd9Sstevel@tonic-gate 
30237c478bd9Sstevel@tonic-gate #define	MULTIRT_TRACE(x)	ip2dbg(x)
30247c478bd9Sstevel@tonic-gate 
30257c478bd9Sstevel@tonic-gate #define	MULTIRT_DEBUG_TAG(mblk)	\
30267c478bd9Sstevel@tonic-gate 	do { \
30277c478bd9Sstevel@tonic-gate 		ASSERT(mblk != NULL); \
30287c478bd9Sstevel@tonic-gate 		MULTIRT_TRACE(("%s[%d]: tagging mblk %p, tag was %d\n", \
30297c478bd9Sstevel@tonic-gate 		__FILE__, __LINE__, \
30307c478bd9Sstevel@tonic-gate 		(void *)(mblk), (mblk)->b_flag & MULTIRT_DEBUG_FLAG)); \
30317c478bd9Sstevel@tonic-gate 		(mblk)->b_flag |= MULTIRT_DEBUG_FLAG; \
30327c478bd9Sstevel@tonic-gate 	} while (0)
30337c478bd9Sstevel@tonic-gate 
30347c478bd9Sstevel@tonic-gate #define	MULTIRT_DEBUG_UNTAG(mblk) \
30357c478bd9Sstevel@tonic-gate 	do { \
30367c478bd9Sstevel@tonic-gate 		ASSERT(mblk != NULL); \
30377c478bd9Sstevel@tonic-gate 		MULTIRT_TRACE(("%s[%d]: untagging mblk %p, tag was %d\n", \
30387c478bd9Sstevel@tonic-gate 		__FILE__, __LINE__, \
30397c478bd9Sstevel@tonic-gate 		(void *)(mblk), (mblk)->b_flag & MULTIRT_DEBUG_FLAG)); \
30407c478bd9Sstevel@tonic-gate 		(mblk)->b_flag &= ~MULTIRT_DEBUG_FLAG; \
30417c478bd9Sstevel@tonic-gate 	} while (0)
30427c478bd9Sstevel@tonic-gate 
30437c478bd9Sstevel@tonic-gate #define	MULTIRT_DEBUG_TAGGED(mblk) \
30447c478bd9Sstevel@tonic-gate 	(((mblk)->b_flag & MULTIRT_DEBUG_FLAG) ? B_TRUE : B_FALSE)
30457c478bd9Sstevel@tonic-gate #else
30467c478bd9Sstevel@tonic-gate #define	MULTIRT_DEBUG_TAG(mblk)		ASSERT(mblk != NULL)
30477c478bd9Sstevel@tonic-gate #define	MULTIRT_DEBUG_UNTAG(mblk)	ASSERT(mblk != NULL)
30487c478bd9Sstevel@tonic-gate #define	MULTIRT_DEBUG_TAGGED(mblk)	B_FALSE
30497c478bd9Sstevel@tonic-gate #endif
30507c478bd9Sstevel@tonic-gate 
30517c478bd9Sstevel@tonic-gate /*
30527c478bd9Sstevel@tonic-gate  * Per-ILL Multidata Transmit capabilities.
30537c478bd9Sstevel@tonic-gate  */
30547c478bd9Sstevel@tonic-gate struct ill_mdt_capab_s {
30557c478bd9Sstevel@tonic-gate 	uint_t ill_mdt_version;  /* interface version */
30567c478bd9Sstevel@tonic-gate 	uint_t ill_mdt_on;	 /* on/off switch for MDT on this ILL */
30577c478bd9Sstevel@tonic-gate 	uint_t ill_mdt_hdr_head; /* leading header fragment extra space */
30587c478bd9Sstevel@tonic-gate 	uint_t ill_mdt_hdr_tail; /* trailing header fragment extra space */
30597c478bd9Sstevel@tonic-gate 	uint_t ill_mdt_max_pld;	 /* maximum payload buffers per Multidata */
30607c478bd9Sstevel@tonic-gate 	uint_t ill_mdt_span_limit; /* maximum payload span per packet */
30617c478bd9Sstevel@tonic-gate };
30627c478bd9Sstevel@tonic-gate 
30637c478bd9Sstevel@tonic-gate struct ill_hcksum_capab_s {
30647c478bd9Sstevel@tonic-gate 	uint_t	ill_hcksum_version;	/* interface version */
30657c478bd9Sstevel@tonic-gate 	uint_t	ill_hcksum_txflags;	/* capabilities on transmit */
30667c478bd9Sstevel@tonic-gate };
30677c478bd9Sstevel@tonic-gate 
30687c478bd9Sstevel@tonic-gate struct ill_zerocopy_capab_s {
30697c478bd9Sstevel@tonic-gate 	uint_t	ill_zerocopy_version;	/* interface version */
30707c478bd9Sstevel@tonic-gate 	uint_t	ill_zerocopy_flags;	/* capabilities */
30717c478bd9Sstevel@tonic-gate };
30727c478bd9Sstevel@tonic-gate 
30737c478bd9Sstevel@tonic-gate /* Possible ill_states */
30747c478bd9Sstevel@tonic-gate #define	ILL_RING_INPROC		3	/* Being assigned to squeue */
30757c478bd9Sstevel@tonic-gate #define	ILL_RING_INUSE		2	/* Already Assigned to Rx Ring */
30767c478bd9Sstevel@tonic-gate #define	ILL_RING_BEING_FREED	1	/* Being Unassigned */
30777c478bd9Sstevel@tonic-gate #define	ILL_RING_FREE		0	/* Available to be assigned to Ring */
30787c478bd9Sstevel@tonic-gate 
30797c478bd9Sstevel@tonic-gate #define	ILL_MAX_RINGS		256	/* Max num of rx rings we can manage */
30807c478bd9Sstevel@tonic-gate #define	ILL_POLLING		0x01	/* Polling in use */
30817c478bd9Sstevel@tonic-gate 
30827c478bd9Sstevel@tonic-gate /*
30834b46d1efSkrgopi  * These functions pointer types are exported by the mac/dls layer.
30844b46d1efSkrgopi  * we need to duplicate the definitions here because we cannot
30854b46d1efSkrgopi  * include mac/dls header files here.
30867c478bd9Sstevel@tonic-gate  */
30877c478bd9Sstevel@tonic-gate typedef void	(*ip_mac_blank_t)(void *, time_t, uint_t);
30884b46d1efSkrgopi typedef void	(*ip_dld_tx_t)(void *, mblk_t *);
30894b46d1efSkrgopi 
30904b46d1efSkrgopi typedef void	(*ip_dls_chg_soft_ring_t)(void *, int);
30914b46d1efSkrgopi typedef void	(*ip_dls_bind_t)(void *, processorid_t);
30924b46d1efSkrgopi typedef void	(*ip_dls_unbind_t)(void *);
30937c478bd9Sstevel@tonic-gate 
30947c478bd9Sstevel@tonic-gate struct ill_rx_ring {
30957c478bd9Sstevel@tonic-gate 	ip_mac_blank_t		rr_blank; /* Driver interrupt blanking func */
30967c478bd9Sstevel@tonic-gate 	void			*rr_handle; /* Handle for Rx ring */
30977c478bd9Sstevel@tonic-gate 	squeue_t		*rr_sqp; /* Squeue the ring is bound to */
30987c478bd9Sstevel@tonic-gate 	ill_t			*rr_ill; /* back pointer to ill */
30997c478bd9Sstevel@tonic-gate 	clock_t			rr_poll_time; /* Last lbolt polling was used */
31007c478bd9Sstevel@tonic-gate 	uint32_t		rr_poll_state; /* polling state flags */
31017c478bd9Sstevel@tonic-gate 	uint32_t		rr_max_blank_time; /* Max interrupt blank */
31027c478bd9Sstevel@tonic-gate 	uint32_t		rr_min_blank_time; /* Min interrupt blank */
31037c478bd9Sstevel@tonic-gate 	uint32_t		rr_max_pkt_cnt; /* Max pkts before interrupt */
31047c478bd9Sstevel@tonic-gate 	uint32_t		rr_min_pkt_cnt; /* Mix pkts before interrupt */
31057c478bd9Sstevel@tonic-gate 	uint32_t		rr_normal_blank_time; /* Normal intr freq */
31067c478bd9Sstevel@tonic-gate 	uint32_t		rr_normal_pkt_cnt; /* Normal intr pkt cnt */
31077c478bd9Sstevel@tonic-gate 	uint32_t		rr_ring_state; /* State of this ring */
31087c478bd9Sstevel@tonic-gate };
31097c478bd9Sstevel@tonic-gate 
31104b46d1efSkrgopi struct ill_dls_capab_s {
31114b46d1efSkrgopi 	ip_dld_tx_t		ill_tx;		/* Driver Tx routine */
31124b46d1efSkrgopi 	void			*ill_tx_handle;	/* Driver Tx handle */
31134b46d1efSkrgopi 	ip_dls_chg_soft_ring_t	ill_dls_change_status;
31144b46d1efSkrgopi 						/* change soft ring fanout */
31154b46d1efSkrgopi 	ip_dls_bind_t		ill_dls_bind;	/* to add CPU affinity */
31164b46d1efSkrgopi 	ip_dls_unbind_t		ill_dls_unbind;	/* remove CPU affinity */
31177c478bd9Sstevel@tonic-gate 	ill_rx_ring_t		*ill_ring_tbl; /* Ring to Sqp mapping table */
31184b46d1efSkrgopi 	uint_t			ill_dls_soft_ring_cnt; /* Number of soft ring */
31197c478bd9Sstevel@tonic-gate 	conn_t			*ill_unbind_conn; /* Conn used during unplumb */
31207c478bd9Sstevel@tonic-gate };
31217c478bd9Sstevel@tonic-gate 
31227c478bd9Sstevel@tonic-gate /*
3123*45916cd2Sjpk  * This message is sent by an upper-layer protocol to tell IP that it knows all
3124*45916cd2Sjpk  * about labels and will construct them itself.  IP takes the slow path and
3125*45916cd2Sjpk  * recomputes the label on every packet when this isn't true.
3126*45916cd2Sjpk  */
3127*45916cd2Sjpk #define	IP_ULP_OUT_LABELED		(('O' << 8) + 'L')
3128*45916cd2Sjpk typedef struct out_labeled_s {
3129*45916cd2Sjpk 	uint32_t	out_labeled_type;	/* OUT_LABELED */
3130*45916cd2Sjpk 	queue_t		*out_qnext;		/* intermediate detection */
3131*45916cd2Sjpk } out_labeled_t;
3132*45916cd2Sjpk 
3133*45916cd2Sjpk /*
31347c478bd9Sstevel@tonic-gate  * IP squeues exports
31357c478bd9Sstevel@tonic-gate  */
31367c478bd9Sstevel@tonic-gate extern int 		ip_squeue_profile;
31377c478bd9Sstevel@tonic-gate extern int 		ip_squeue_bind;
31387c478bd9Sstevel@tonic-gate extern boolean_t 	ip_squeue_fanout;
31394b46d1efSkrgopi extern boolean_t	ip_squeue_soft_ring;
31404b46d1efSkrgopi extern uint_t		ip_threads_per_cpu;
31414b46d1efSkrgopi extern uint_t		ip_squeues_per_cpu;
31424b46d1efSkrgopi extern uint_t		ip_soft_rings_cnt;
31437c478bd9Sstevel@tonic-gate 
31447c478bd9Sstevel@tonic-gate typedef struct squeue_set_s {
31457c478bd9Sstevel@tonic-gate 	kmutex_t	sqs_lock;
31467c478bd9Sstevel@tonic-gate 	struct squeue_s	**sqs_list;
31477c478bd9Sstevel@tonic-gate 	int		sqs_size;
31487c478bd9Sstevel@tonic-gate 	int		sqs_max_size;
31497c478bd9Sstevel@tonic-gate 	processorid_t	sqs_bind;
31507c478bd9Sstevel@tonic-gate } squeue_set_t;
31517c478bd9Sstevel@tonic-gate 
31527c478bd9Sstevel@tonic-gate #define	IP_SQUEUE_GET(hint) 						\
31534b46d1efSkrgopi 	((!ip_squeue_fanout) ?	(CPU->cpu_squeue_set->sqs_list[0]) :	\
31547c478bd9Sstevel@tonic-gate 		ip_squeue_random(hint))
31557c478bd9Sstevel@tonic-gate 
31567c478bd9Sstevel@tonic-gate typedef void (*squeue_func_t)(squeue_t *, mblk_t *, sqproc_t, void *, uint8_t);
31577c478bd9Sstevel@tonic-gate 
31587c478bd9Sstevel@tonic-gate extern void ip_squeue_init(void (*)(squeue_t *));
31597c478bd9Sstevel@tonic-gate extern squeue_t	*ip_squeue_random(uint_t);
31607c478bd9Sstevel@tonic-gate extern squeue_t *ip_squeue_get(ill_rx_ring_t *);
31617c478bd9Sstevel@tonic-gate extern void ip_squeue_get_pkts(squeue_t *);
31627c478bd9Sstevel@tonic-gate extern int ip_squeue_bind_set(queue_t *, mblk_t *, char *, caddr_t, cred_t *);
31637c478bd9Sstevel@tonic-gate extern int ip_squeue_bind_get(queue_t *, mblk_t *, caddr_t, cred_t *);
31647c478bd9Sstevel@tonic-gate extern void ip_squeue_clean(void *, mblk_t *, void *);
3165ff550d0eSmasputra extern void ip_resume_tcp_bind(void *, mblk_t *, void *);
31664b46d1efSkrgopi extern void	ip_soft_ring_assignment(ill_t *, ill_rx_ring_t *,
31674b46d1efSkrgopi     mblk_t *, size_t);
31687c478bd9Sstevel@tonic-gate 
3169ff550d0eSmasputra extern void tcp_wput(queue_t *, mblk_t *);
3170ff550d0eSmasputra 
31717c478bd9Sstevel@tonic-gate extern int	ip_fill_mtuinfo(struct in6_addr *, in_port_t,
31727c478bd9Sstevel@tonic-gate 	struct ip6_mtuinfo *);
3173ff550d0eSmasputra extern	ipif_t *conn_get_held_ipif(conn_t *, ipif_t **, int *);
31747c478bd9Sstevel@tonic-gate 
31757c478bd9Sstevel@tonic-gate typedef void    (*ipsq_func_t)(ipsq_t *, queue_t *, mblk_t *, void *);
31767c478bd9Sstevel@tonic-gate 
31777c478bd9Sstevel@tonic-gate /*
31787c478bd9Sstevel@tonic-gate  * Squeue tags. Tags only need to be unique when the callback function is the
31797c478bd9Sstevel@tonic-gate  * same to distinguish between different calls, but we use unique tags for
31807c478bd9Sstevel@tonic-gate  * convenience anyway.
31817c478bd9Sstevel@tonic-gate  */
31827c478bd9Sstevel@tonic-gate #define	SQTAG_IP_INPUT			1
31837c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_INPUT_ICMP_ERR	2
31847c478bd9Sstevel@tonic-gate #define	SQTAG_TCP6_INPUT_ICMP_ERR	3
31857c478bd9Sstevel@tonic-gate #define	SQTAG_IP_TCP_INPUT		4
31867c478bd9Sstevel@tonic-gate #define	SQTAG_IP6_TCP_INPUT		5
31877c478bd9Sstevel@tonic-gate #define	SQTAG_IP_TCP_CLOSE		6
31887c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_OUTPUT		7
31897c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_TIMER			8
31907c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_TIMEWAIT		9
31917c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_ACCEPT_FINISH		10
31927c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_ACCEPT_FINISH_Q0	11
31937c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_ACCEPT_PENDING	12
31947c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_LISTEN_DISCON		13
31957c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_CONN_REQ		14
31967c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_EAGER_BLOWOFF		15
31977c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_EAGER_CLEANUP		16
31987c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_EAGER_CLEANUP_Q0	17
31997c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_CONN_IND		18
32007c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_RSRV			19
32017c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_ABORT_BUCKET		20
32027c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_REINPUT		21
32037c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_REINPUT_EAGER		22
32047c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_INPUT_MCTL		23
32057c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_RPUTOTHER		24
32067c478bd9Sstevel@tonic-gate #define	SQTAG_IP_PROTO_AGAIN		25
32077c478bd9Sstevel@tonic-gate #define	SQTAG_IP_FANOUT_TCP		26
32087c478bd9Sstevel@tonic-gate #define	SQTAG_IPSQ_CLEAN_RING		27
32097c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_WPUT_OTHER		28
32107c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_CONN_REQ_UNBOUND	29
32117c478bd9Sstevel@tonic-gate #define	SQTAG_TCP_SEND_PENDING		30
3212ff550d0eSmasputra #define	SQTAG_BIND_RETRY		31
3213ff550d0eSmasputra #define	SQTAG_UDP_FANOUT		32
3214ff550d0eSmasputra #define	SQTAG_UDP_INPUT			33
3215ff550d0eSmasputra #define	SQTAG_UDP_WPUT			34
3216ff550d0eSmasputra #define	SQTAG_UDP_OUTPUT		35
3217c28749e9Skais #define	SQTAG_TCP_KSSL_INPUT		36
32187c478bd9Sstevel@tonic-gate 
32197c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
32207c478bd9Sstevel@tonic-gate 
32217c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
32227c478bd9Sstevel@tonic-gate }
32237c478bd9Sstevel@tonic-gate #endif
32247c478bd9Sstevel@tonic-gate 
32257c478bd9Sstevel@tonic-gate #endif	/* _INET_IP_H */
3226