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 /* 23e11c3f44Smeem * Copyright 2009 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 #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <sys/isa_defs.h> 367c478bd9Sstevel@tonic-gate #include <sys/types.h> 377c478bd9Sstevel@tonic-gate #include <inet/mib2.h> 387c478bd9Sstevel@tonic-gate #include <inet/nd.h> 397c478bd9Sstevel@tonic-gate #include <sys/atomic.h> 407c478bd9Sstevel@tonic-gate #include <net/if_dl.h> 417c478bd9Sstevel@tonic-gate #include <net/if.h> 427c478bd9Sstevel@tonic-gate #include <netinet/ip.h> 437c478bd9Sstevel@tonic-gate #include <netinet/igmp.h> 44381a2a9aSdr146992 #include <sys/neti.h> 45381a2a9aSdr146992 #include <sys/hook.h> 46381a2a9aSdr146992 #include <sys/hook_event.h> 47381a2a9aSdr146992 #include <sys/hook_impl.h> 48f4b3ec61Sdh155122 #include <inet/ip_stack.h> 497c478bd9Sstevel@tonic-gate 507c478bd9Sstevel@tonic-gate #ifdef _KERNEL 517c478bd9Sstevel@tonic-gate #include <netinet/ip6.h> 527c478bd9Sstevel@tonic-gate #include <sys/avl.h> 53da14cebeSEric Cheng #include <sys/list.h> 547c478bd9Sstevel@tonic-gate #include <sys/vmem.h> 557c478bd9Sstevel@tonic-gate #include <sys/squeue.h> 5645916cd2Sjpk #include <net/route.h> 577c478bd9Sstevel@tonic-gate #include <sys/systm.h> 58ff550d0eSmasputra #include <sys/multidata.h> 59e11c3f44Smeem #include <sys/list.h> 60c793af95Ssangeeta #include <net/radix.h> 616a8288c7Scarlsonj #include <sys/modhash.h> 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate #ifdef DEBUG 647c478bd9Sstevel@tonic-gate #define CONN_DEBUG 657c478bd9Sstevel@tonic-gate #endif 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate #define IP_DEBUG 687c478bd9Sstevel@tonic-gate /* 697c478bd9Sstevel@tonic-gate * The mt-streams(9F) flags for the IP module; put here so that other 707c478bd9Sstevel@tonic-gate * "drivers" that are actually IP (e.g., ICMP, UDP) can use the same set 717c478bd9Sstevel@tonic-gate * of flags. 727c478bd9Sstevel@tonic-gate */ 737c478bd9Sstevel@tonic-gate #define IP_DEVMTFLAGS D_MP 74ff550d0eSmasputra #endif /* _KERNEL */ 75ff550d0eSmasputra 76ff550d0eSmasputra #define IP_MOD_NAME "ip" 77ff550d0eSmasputra #define IP_DEV_NAME "/dev/ip" 78ff550d0eSmasputra #define IP6_DEV_NAME "/dev/ip6" 79ff550d0eSmasputra 80ff550d0eSmasputra #define UDP_MOD_NAME "udp" 81ff550d0eSmasputra #define UDP_DEV_NAME "/dev/udp" 82ff550d0eSmasputra #define UDP6_DEV_NAME "/dev/udp6" 83ff550d0eSmasputra 84ff550d0eSmasputra #define TCP_MOD_NAME "tcp" 85ff550d0eSmasputra #define TCP_DEV_NAME "/dev/tcp" 86ff550d0eSmasputra #define TCP6_DEV_NAME "/dev/tcp6" 877c478bd9Sstevel@tonic-gate 8877c67f2fSkcpoon #define SCTP_MOD_NAME "sctp" 8977c67f2fSkcpoon 907c478bd9Sstevel@tonic-gate #ifndef _IPADDR_T 917c478bd9Sstevel@tonic-gate #define _IPADDR_T 927c478bd9Sstevel@tonic-gate typedef uint32_t ipaddr_t; 937c478bd9Sstevel@tonic-gate #endif 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* Number of bits in an address */ 967c478bd9Sstevel@tonic-gate #define IP_ABITS 32 977c478bd9Sstevel@tonic-gate #define IPV6_ABITS 128 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate #define IP_HOST_MASK (ipaddr_t)0xffffffffU 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate #define IP_CSUM(mp, off, sum) (~ip_cksum(mp, off, sum) & 0xFFFF) 1027c478bd9Sstevel@tonic-gate #define IP_CSUM_PARTIAL(mp, off, sum) ip_cksum(mp, off, sum) 1037c478bd9Sstevel@tonic-gate #define IP_BCSUM_PARTIAL(bp, len, sum) bcksum(bp, len, sum) 1047c478bd9Sstevel@tonic-gate #define IP_MD_CSUM(pd, off, sum) (~ip_md_cksum(pd, off, sum) & 0xffff) 1057c478bd9Sstevel@tonic-gate #define IP_MD_CSUM_PARTIAL(pd, off, sum) ip_md_cksum(pd, off, sum) 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* 1087c478bd9Sstevel@tonic-gate * Flag to IP write side to indicate that the appln has sent in a pre-built 1097c478bd9Sstevel@tonic-gate * IP header. Stored in ipha_ident (which is otherwise zero). 1107c478bd9Sstevel@tonic-gate */ 1117c478bd9Sstevel@tonic-gate #define IP_HDR_INCLUDED 0xFFFF 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate #define ILL_FRAG_HASH_TBL_COUNT ((unsigned int)64) 1147c478bd9Sstevel@tonic-gate #define ILL_FRAG_HASH_TBL_SIZE (ILL_FRAG_HASH_TBL_COUNT * sizeof (ipfb_t)) 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate #define IPV4_ADDR_LEN 4 1177c478bd9Sstevel@tonic-gate #define IP_ADDR_LEN IPV4_ADDR_LEN 1187c478bd9Sstevel@tonic-gate #define IP_ARP_PROTO_TYPE 0x0800 1197c478bd9Sstevel@tonic-gate 1207c478bd9Sstevel@tonic-gate #define IPV4_VERSION 4 1217c478bd9Sstevel@tonic-gate #define IP_VERSION IPV4_VERSION 1227c478bd9Sstevel@tonic-gate #define IP_SIMPLE_HDR_LENGTH_IN_WORDS 5 1237c478bd9Sstevel@tonic-gate #define IP_SIMPLE_HDR_LENGTH 20 1247c478bd9Sstevel@tonic-gate #define IP_MAX_HDR_LENGTH 60 1257c478bd9Sstevel@tonic-gate 12645916cd2Sjpk #define IP_MAX_OPT_LENGTH (IP_MAX_HDR_LENGTH-IP_SIMPLE_HDR_LENGTH) 12745916cd2Sjpk 1287c478bd9Sstevel@tonic-gate #define IP_MIN_MTU (IP_MAX_HDR_LENGTH + 8) /* 68 bytes */ 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate /* 1317c478bd9Sstevel@tonic-gate * XXX IP_MAXPACKET is defined in <netinet/ip.h> as well. At some point the 1327c478bd9Sstevel@tonic-gate * 2 files should be cleaned up to remove all redundant definitions. 1337c478bd9Sstevel@tonic-gate */ 1347c478bd9Sstevel@tonic-gate #define IP_MAXPACKET 65535 1357c478bd9Sstevel@tonic-gate #define IP_SIMPLE_HDR_VERSION \ 1367c478bd9Sstevel@tonic-gate ((IP_VERSION << 4) | IP_SIMPLE_HDR_LENGTH_IN_WORDS) 1377c478bd9Sstevel@tonic-gate 13845916cd2Sjpk #define UDPH_SIZE 8 13945916cd2Sjpk 140c793af95Ssangeeta /* Leave room for ip_newroute to tack on the src and target addresses */ 141c793af95Ssangeeta #define OK_RESOLVER_MP(mp) \ 142c793af95Ssangeeta ((mp) && ((mp)->b_wptr - (mp)->b_rptr) >= (2 * IP_ADDR_LEN)) 143c793af95Ssangeeta 1447c478bd9Sstevel@tonic-gate /* 1457c478bd9Sstevel@tonic-gate * Constants and type definitions to support IP IOCTL commands 1467c478bd9Sstevel@tonic-gate */ 1477c478bd9Sstevel@tonic-gate #define IP_IOCTL (('i'<<8)|'p') 1487c478bd9Sstevel@tonic-gate #define IP_IOC_IRE_DELETE 4 1497c478bd9Sstevel@tonic-gate #define IP_IOC_IRE_DELETE_NO_REPLY 5 1507c478bd9Sstevel@tonic-gate #define IP_IOC_IRE_ADVISE_NO_REPLY 6 1517c478bd9Sstevel@tonic-gate #define IP_IOC_RTS_REQUEST 7 1527c478bd9Sstevel@tonic-gate 1537c478bd9Sstevel@tonic-gate /* Common definitions used by IP IOCTL data structures */ 1547c478bd9Sstevel@tonic-gate typedef struct ipllcmd_s { 1557c478bd9Sstevel@tonic-gate uint_t ipllc_cmd; 1567c478bd9Sstevel@tonic-gate uint_t ipllc_name_offset; 1577c478bd9Sstevel@tonic-gate uint_t ipllc_name_length; 1587c478bd9Sstevel@tonic-gate } ipllc_t; 1597c478bd9Sstevel@tonic-gate 1607c478bd9Sstevel@tonic-gate /* IP IRE Change Command Structure. */ 1617c478bd9Sstevel@tonic-gate typedef struct ipic_s { 1627c478bd9Sstevel@tonic-gate ipllc_t ipic_ipllc; 1637c478bd9Sstevel@tonic-gate uint_t ipic_ire_type; 1647c478bd9Sstevel@tonic-gate uint_t ipic_max_frag; 1657c478bd9Sstevel@tonic-gate uint_t ipic_addr_offset; 1667c478bd9Sstevel@tonic-gate uint_t ipic_addr_length; 1677c478bd9Sstevel@tonic-gate uint_t ipic_mask_offset; 1687c478bd9Sstevel@tonic-gate uint_t ipic_mask_length; 1697c478bd9Sstevel@tonic-gate uint_t ipic_src_addr_offset; 1707c478bd9Sstevel@tonic-gate uint_t ipic_src_addr_length; 1717c478bd9Sstevel@tonic-gate uint_t ipic_ll_hdr_offset; 1727c478bd9Sstevel@tonic-gate uint_t ipic_ll_hdr_length; 1737c478bd9Sstevel@tonic-gate uint_t ipic_gateway_addr_offset; 1747c478bd9Sstevel@tonic-gate uint_t ipic_gateway_addr_length; 1757c478bd9Sstevel@tonic-gate clock_t ipic_rtt; 1767c478bd9Sstevel@tonic-gate uint32_t ipic_ssthresh; 1777c478bd9Sstevel@tonic-gate clock_t ipic_rtt_sd; 1787c478bd9Sstevel@tonic-gate uchar_t ipic_ire_marks; 1797c478bd9Sstevel@tonic-gate } ipic_t; 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate #define ipic_cmd ipic_ipllc.ipllc_cmd 1827c478bd9Sstevel@tonic-gate #define ipic_ll_name_length ipic_ipllc.ipllc_name_length 1837c478bd9Sstevel@tonic-gate #define ipic_ll_name_offset ipic_ipllc.ipllc_name_offset 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate /* IP IRE Delete Command Structure. */ 1867c478bd9Sstevel@tonic-gate typedef struct ipid_s { 1877c478bd9Sstevel@tonic-gate ipllc_t ipid_ipllc; 1887c478bd9Sstevel@tonic-gate uint_t ipid_ire_type; 1897c478bd9Sstevel@tonic-gate uint_t ipid_addr_offset; 1907c478bd9Sstevel@tonic-gate uint_t ipid_addr_length; 1917c478bd9Sstevel@tonic-gate uint_t ipid_mask_offset; 1927c478bd9Sstevel@tonic-gate uint_t ipid_mask_length; 1937c478bd9Sstevel@tonic-gate } ipid_t; 1947c478bd9Sstevel@tonic-gate 1957c478bd9Sstevel@tonic-gate #define ipid_cmd ipid_ipllc.ipllc_cmd 1967c478bd9Sstevel@tonic-gate 1977c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1987c478bd9Sstevel@tonic-gate /* 1997c478bd9Sstevel@tonic-gate * Temporary state for ip options parser. 2007c478bd9Sstevel@tonic-gate */ 2017c478bd9Sstevel@tonic-gate typedef struct ipoptp_s 2027c478bd9Sstevel@tonic-gate { 2037c478bd9Sstevel@tonic-gate uint8_t *ipoptp_next; /* next option to look at */ 2047c478bd9Sstevel@tonic-gate uint8_t *ipoptp_end; /* end of options */ 2057c478bd9Sstevel@tonic-gate uint8_t *ipoptp_cur; /* start of current option */ 2067c478bd9Sstevel@tonic-gate uint8_t ipoptp_len; /* length of current option */ 2077c478bd9Sstevel@tonic-gate uint32_t ipoptp_flags; 2087c478bd9Sstevel@tonic-gate } ipoptp_t; 2097c478bd9Sstevel@tonic-gate 2107c478bd9Sstevel@tonic-gate /* 2117c478bd9Sstevel@tonic-gate * Flag(s) for ipoptp_flags 2127c478bd9Sstevel@tonic-gate */ 2137c478bd9Sstevel@tonic-gate #define IPOPTP_ERROR 0x00000001 2147c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2157c478bd9Sstevel@tonic-gate 2167c478bd9Sstevel@tonic-gate /* Controls forwarding of IP packets, set via ndd */ 2177c478bd9Sstevel@tonic-gate #define IP_FORWARD_NEVER 0 2187c478bd9Sstevel@tonic-gate #define IP_FORWARD_ALWAYS 1 2197c478bd9Sstevel@tonic-gate 220f4b3ec61Sdh155122 #define WE_ARE_FORWARDING(ipst) ((ipst)->ips_ip_g_forward == IP_FORWARD_ALWAYS) 2217c478bd9Sstevel@tonic-gate 2227c478bd9Sstevel@tonic-gate #define IPH_HDR_LENGTH(ipha) \ 2237c478bd9Sstevel@tonic-gate ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length & 0xF) << 2) 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate #define IPH_HDR_VERSION(ipha) \ 2267c478bd9Sstevel@tonic-gate ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length) >> 4) 2277c478bd9Sstevel@tonic-gate 2287c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2297c478bd9Sstevel@tonic-gate /* 2307c478bd9Sstevel@tonic-gate * IP reassembly macros. We hide starting and ending offsets in b_next and 2317c478bd9Sstevel@tonic-gate * b_prev of messages on the reassembly queue. The messages are chained using 2327c478bd9Sstevel@tonic-gate * b_cont. These macros are used in ip_reassemble() so we don't have to see 2337c478bd9Sstevel@tonic-gate * the ugly casts and assignments. 2347c478bd9Sstevel@tonic-gate * Note that the offsets are <= 64k i.e. a uint_t is sufficient to represent 2357c478bd9Sstevel@tonic-gate * them. 2367c478bd9Sstevel@tonic-gate */ 2377c478bd9Sstevel@tonic-gate #define IP_REASS_START(mp) ((uint_t)(uintptr_t)((mp)->b_next)) 2387c478bd9Sstevel@tonic-gate #define IP_REASS_SET_START(mp, u) \ 2397c478bd9Sstevel@tonic-gate ((mp)->b_next = (mblk_t *)(uintptr_t)(u)) 2407c478bd9Sstevel@tonic-gate #define IP_REASS_END(mp) ((uint_t)(uintptr_t)((mp)->b_prev)) 2417c478bd9Sstevel@tonic-gate #define IP_REASS_SET_END(mp, u) \ 2427c478bd9Sstevel@tonic-gate ((mp)->b_prev = (mblk_t *)(uintptr_t)(u)) 2437c478bd9Sstevel@tonic-gate 2447c478bd9Sstevel@tonic-gate #define IP_REASS_COMPLETE 0x1 2457c478bd9Sstevel@tonic-gate #define IP_REASS_PARTIAL 0x2 2467c478bd9Sstevel@tonic-gate #define IP_REASS_FAILED 0x4 2477c478bd9Sstevel@tonic-gate 2487c478bd9Sstevel@tonic-gate /* 2497c478bd9Sstevel@tonic-gate * Test to determine whether this is a module instance of IP or a 2507c478bd9Sstevel@tonic-gate * driver instance of IP. 2517c478bd9Sstevel@tonic-gate */ 2527c478bd9Sstevel@tonic-gate #define CONN_Q(q) (WR(q)->q_next == NULL) 2537c478bd9Sstevel@tonic-gate 2547c478bd9Sstevel@tonic-gate #define Q_TO_CONN(q) ((conn_t *)(q)->q_ptr) 2557c478bd9Sstevel@tonic-gate #define Q_TO_TCP(q) (Q_TO_CONN((q))->conn_tcp) 256ff550d0eSmasputra #define Q_TO_UDP(q) (Q_TO_CONN((q))->conn_udp) 257fc80c0dfSnordmark #define Q_TO_ICMP(q) (Q_TO_CONN((q))->conn_icmp) 258fc80c0dfSnordmark #define Q_TO_RTS(q) (Q_TO_CONN((q))->conn_rts) 2597c478bd9Sstevel@tonic-gate 2607c478bd9Sstevel@tonic-gate /* 2617c478bd9Sstevel@tonic-gate * The following two macros are used by IP to get the appropriate 2627c478bd9Sstevel@tonic-gate * wq and rq for a conn. If it is a TCP conn, then we need 2637c478bd9Sstevel@tonic-gate * tcp_wq/tcp_rq else, conn_wq/conn_rq. IP can use conn_wq and conn_rq 2647c478bd9Sstevel@tonic-gate * from a conn directly if it knows that the conn is not TCP. 2657c478bd9Sstevel@tonic-gate */ 2667c478bd9Sstevel@tonic-gate #define CONNP_TO_WQ(connp) \ 267ff550d0eSmasputra (IPCL_IS_TCP(connp) ? (connp)->conn_tcp->tcp_wq : (connp)->conn_wq) 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate #define CONNP_TO_RQ(connp) RD(CONNP_TO_WQ(connp)) 2707c478bd9Sstevel@tonic-gate 2717c478bd9Sstevel@tonic-gate #define GRAB_CONN_LOCK(q) { \ 2727c478bd9Sstevel@tonic-gate if (q != NULL && CONN_Q(q)) \ 2737c478bd9Sstevel@tonic-gate mutex_enter(&(Q_TO_CONN(q))->conn_lock); \ 2747c478bd9Sstevel@tonic-gate } 2757c478bd9Sstevel@tonic-gate 2767c478bd9Sstevel@tonic-gate #define RELEASE_CONN_LOCK(q) { \ 2777c478bd9Sstevel@tonic-gate if (q != NULL && CONN_Q(q)) \ 2787c478bd9Sstevel@tonic-gate mutex_exit(&(Q_TO_CONN(q))->conn_lock); \ 2797c478bd9Sstevel@tonic-gate } 2807c478bd9Sstevel@tonic-gate 2817c478bd9Sstevel@tonic-gate /* "Congestion controlled" protocol */ 2827c478bd9Sstevel@tonic-gate #define IP_FLOW_CONTROLLED_ULP(p) ((p) == IPPROTO_TCP || (p) == IPPROTO_SCTP) 2837c478bd9Sstevel@tonic-gate 2847c478bd9Sstevel@tonic-gate /* 2857c478bd9Sstevel@tonic-gate * Complete the pending operation. Usually an ioctl. Can also 2867c478bd9Sstevel@tonic-gate * be a bind or option management request that got enqueued 2877c478bd9Sstevel@tonic-gate * in an ipsq_t. Called on completion of the operation. 2887c478bd9Sstevel@tonic-gate */ 2897c478bd9Sstevel@tonic-gate #define CONN_OPER_PENDING_DONE(connp) { \ 2907c478bd9Sstevel@tonic-gate mutex_enter(&(connp)->conn_lock); \ 2917c478bd9Sstevel@tonic-gate (connp)->conn_oper_pending_ill = NULL; \ 2927c478bd9Sstevel@tonic-gate cv_broadcast(&(connp)->conn_refcv); \ 2937c478bd9Sstevel@tonic-gate mutex_exit(&(connp)->conn_lock); \ 2947c478bd9Sstevel@tonic-gate CONN_DEC_REF(connp); \ 2957c478bd9Sstevel@tonic-gate } 2967c478bd9Sstevel@tonic-gate 2977c478bd9Sstevel@tonic-gate /* 2987c478bd9Sstevel@tonic-gate * Flags for the various ip_fanout_* routines. 2997c478bd9Sstevel@tonic-gate */ 3007c478bd9Sstevel@tonic-gate #define IP_FF_SEND_ICMP 0x01 /* Send an ICMP error */ 3017c478bd9Sstevel@tonic-gate #define IP_FF_HDR_COMPLETE 0x02 /* Call ip_hdr_complete if error */ 3027c478bd9Sstevel@tonic-gate #define IP_FF_CKSUM 0x04 /* Recompute ipha_cksum if error */ 3037c478bd9Sstevel@tonic-gate #define IP_FF_RAWIP 0x08 /* Use rawip mib variable */ 3047c478bd9Sstevel@tonic-gate #define IP_FF_SRC_QUENCH 0x10 /* OK to send ICMP_SOURCE_QUENCH */ 3057c478bd9Sstevel@tonic-gate #define IP_FF_SYN_ADDIRE 0x20 /* Add IRE if TCP syn packet */ 30619a30e1aSrshoaib #define IP_FF_IPINFO 0x80 /* Used for both V4 and V6 */ 3077c478bd9Sstevel@tonic-gate #define IP_FF_SEND_SLLA 0x100 /* Send source link layer info ? */ 3087c478bd9Sstevel@tonic-gate #define IPV6_REACHABILITY_CONFIRMATION 0x200 /* Flags for ip_xmit_v6 */ 3097c478bd9Sstevel@tonic-gate #define IP_FF_NO_MCAST_LOOP 0x400 /* No multicasts for sending zone */ 3107c478bd9Sstevel@tonic-gate 3117c478bd9Sstevel@tonic-gate /* 3127c478bd9Sstevel@tonic-gate * Following flags are used by IPQoS to determine if policy processing is 3137c478bd9Sstevel@tonic-gate * required. 3147c478bd9Sstevel@tonic-gate */ 3157c478bd9Sstevel@tonic-gate #define IP6_NO_IPPOLICY 0x800 /* Don't do IPQoS processing */ 3167c478bd9Sstevel@tonic-gate #define IP6_IN_LLMCAST 0x1000 /* Multicast */ 3177c478bd9Sstevel@tonic-gate 318ff550d0eSmasputra #define IP_FF_LOOPBACK 0x2000 /* Loopback fanout */ 319b043aa6fSgeorges #define IP_FF_SCTP_CSUM_ERR 0x4000 /* sctp pkt has failed chksum */ 3207c478bd9Sstevel@tonic-gate 3217c478bd9Sstevel@tonic-gate #ifndef IRE_DB_TYPE 3227c478bd9Sstevel@tonic-gate #define IRE_DB_TYPE M_SIG 3237c478bd9Sstevel@tonic-gate #endif 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate #ifndef IRE_DB_REQ_TYPE 3267c478bd9Sstevel@tonic-gate #define IRE_DB_REQ_TYPE M_PCSIG 3277c478bd9Sstevel@tonic-gate #endif 3287c478bd9Sstevel@tonic-gate 329c793af95Ssangeeta #ifndef IRE_ARPRESOLVE_TYPE 330c793af95Ssangeeta #define IRE_ARPRESOLVE_TYPE M_EVENT 331c793af95Ssangeeta #endif 332c793af95Ssangeeta 3337c478bd9Sstevel@tonic-gate /* 3347c478bd9Sstevel@tonic-gate * Values for squeue switch: 3357c478bd9Sstevel@tonic-gate */ 3367c478bd9Sstevel@tonic-gate 3377c478bd9Sstevel@tonic-gate #define IP_SQUEUE_ENTER_NODRAIN 1 3387c478bd9Sstevel@tonic-gate #define IP_SQUEUE_ENTER 2 3397c478bd9Sstevel@tonic-gate /* 3407c478bd9Sstevel@tonic-gate * This is part of the interface between Transport provider and 3417c478bd9Sstevel@tonic-gate * IP which can be used to set policy information. This is usually 3427c478bd9Sstevel@tonic-gate * accompanied with O_T_BIND_REQ/T_BIND_REQ.ip_bind assumes that 3437c478bd9Sstevel@tonic-gate * only IPSEC_POLICY_SET is there when it is found in the chain. 3447c478bd9Sstevel@tonic-gate * The information contained is an struct ipsec_req_t. On success 3457c478bd9Sstevel@tonic-gate * or failure, either the T_BIND_ACK or the T_ERROR_ACK is returned. 3467c478bd9Sstevel@tonic-gate * IPSEC_POLICY_SET is never returned. 3477c478bd9Sstevel@tonic-gate */ 3487c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_SET M_SETOPTS 3497c478bd9Sstevel@tonic-gate 3507c478bd9Sstevel@tonic-gate #define IRE_IS_LOCAL(ire) ((ire != NULL) && \ 3517c478bd9Sstevel@tonic-gate ((ire)->ire_type & (IRE_LOCAL | IRE_LOOPBACK))) 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate #define IRE_IS_TARGET(ire) ((ire != NULL) && \ 3547c478bd9Sstevel@tonic-gate ((ire)->ire_type != IRE_BROADCAST)) 3557c478bd9Sstevel@tonic-gate 3567c478bd9Sstevel@tonic-gate /* IP Fragmentation Reassembly Header */ 3577c478bd9Sstevel@tonic-gate typedef struct ipf_s { 3587c478bd9Sstevel@tonic-gate struct ipf_s *ipf_hash_next; 3597c478bd9Sstevel@tonic-gate struct ipf_s **ipf_ptphn; /* Pointer to previous hash next. */ 3607c478bd9Sstevel@tonic-gate uint32_t ipf_ident; /* Ident to match. */ 3617c478bd9Sstevel@tonic-gate uint8_t ipf_protocol; /* Protocol to match. */ 3627c478bd9Sstevel@tonic-gate uchar_t ipf_last_frag_seen : 1; /* Last fragment seen ? */ 3637c478bd9Sstevel@tonic-gate time_t ipf_timestamp; /* Reassembly start time. */ 3647c478bd9Sstevel@tonic-gate mblk_t *ipf_mp; /* mblk we live in. */ 3657c478bd9Sstevel@tonic-gate mblk_t *ipf_tail_mp; /* Frag queue tail pointer. */ 3667c478bd9Sstevel@tonic-gate int ipf_hole_cnt; /* Number of holes (hard-case). */ 3677c478bd9Sstevel@tonic-gate int ipf_end; /* Tail end offset (0 -> hard-case). */ 3687c478bd9Sstevel@tonic-gate uint_t ipf_gen; /* Frag queue generation */ 3697c478bd9Sstevel@tonic-gate size_t ipf_count; /* Count of bytes used by frag */ 3707c478bd9Sstevel@tonic-gate uint_t ipf_nf_hdr_len; /* Length of nonfragmented header */ 3717c478bd9Sstevel@tonic-gate in6_addr_t ipf_v6src; /* IPv6 source address */ 3727c478bd9Sstevel@tonic-gate in6_addr_t ipf_v6dst; /* IPv6 dest address */ 3737c478bd9Sstevel@tonic-gate uint_t ipf_prev_nexthdr_offset; /* Offset for nexthdr value */ 3747c478bd9Sstevel@tonic-gate uint8_t ipf_ecn; /* ECN info for the fragments */ 3757c478bd9Sstevel@tonic-gate uint8_t ipf_num_dups; /* Number of times dup frags recvd */ 376ff550d0eSmasputra uint16_t ipf_checksum_flags; /* Hardware checksum flags */ 377ff550d0eSmasputra uint32_t ipf_checksum; /* Partial checksum of fragment data */ 3787c478bd9Sstevel@tonic-gate } ipf_t; 3797c478bd9Sstevel@tonic-gate 380da14cebeSEric Cheng /* 381da14cebeSEric Cheng * IPv4 Fragments 382da14cebeSEric Cheng */ 383da14cebeSEric Cheng #define IS_V4_FRAGMENT(ipha_fragment_offset_and_flags) \ 384da14cebeSEric Cheng (((ntohs(ipha_fragment_offset_and_flags) & IPH_OFFSET) != 0) || \ 385da14cebeSEric Cheng ((ntohs(ipha_fragment_offset_and_flags) & IPH_MF) != 0)) 386da14cebeSEric Cheng 3877c478bd9Sstevel@tonic-gate #define ipf_src V4_PART_OF_V6(ipf_v6src) 3887c478bd9Sstevel@tonic-gate #define ipf_dst V4_PART_OF_V6(ipf_v6dst) 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate typedef enum { 3917c478bd9Sstevel@tonic-gate IB_PKT = 0x01, 3927c478bd9Sstevel@tonic-gate OB_PKT = 0x02 3937c478bd9Sstevel@tonic-gate } ip_pkt_t; 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate #define UPDATE_IB_PKT_COUNT(ire)\ 3967c478bd9Sstevel@tonic-gate { \ 3977c478bd9Sstevel@tonic-gate (ire)->ire_ib_pkt_count++; \ 3987c478bd9Sstevel@tonic-gate if ((ire)->ire_ipif != NULL) { \ 3997c478bd9Sstevel@tonic-gate /* \ 4007c478bd9Sstevel@tonic-gate * forwarding packet \ 4017c478bd9Sstevel@tonic-gate */ \ 4027c478bd9Sstevel@tonic-gate if ((ire)->ire_type & (IRE_LOCAL|IRE_BROADCAST)) \ 4037c478bd9Sstevel@tonic-gate atomic_add_32(&(ire)->ire_ipif->ipif_ib_pkt_count, 1);\ 4047c478bd9Sstevel@tonic-gate else \ 4057c478bd9Sstevel@tonic-gate atomic_add_32(&(ire)->ire_ipif->ipif_fo_pkt_count, 1);\ 4067c478bd9Sstevel@tonic-gate } \ 4077c478bd9Sstevel@tonic-gate } 4087924222fSmeem 4097c478bd9Sstevel@tonic-gate #define UPDATE_OB_PKT_COUNT(ire)\ 4107c478bd9Sstevel@tonic-gate { \ 4117c478bd9Sstevel@tonic-gate (ire)->ire_ob_pkt_count++;\ 4127c478bd9Sstevel@tonic-gate if ((ire)->ire_ipif != NULL) { \ 4137c478bd9Sstevel@tonic-gate atomic_add_32(&(ire)->ire_ipif->ipif_ob_pkt_count, 1); \ 4147c478bd9Sstevel@tonic-gate } \ 4157c478bd9Sstevel@tonic-gate } 4167c478bd9Sstevel@tonic-gate 4177c478bd9Sstevel@tonic-gate #define IP_RPUT_LOCAL(q, mp, ipha, ire, recv_ill) \ 4187c478bd9Sstevel@tonic-gate { \ 4197c478bd9Sstevel@tonic-gate switch (ipha->ipha_protocol) { \ 4207c478bd9Sstevel@tonic-gate case IPPROTO_UDP: \ 4217c478bd9Sstevel@tonic-gate ip_udp_input(q, mp, ipha, ire, recv_ill); \ 4227c478bd9Sstevel@tonic-gate break; \ 4237c478bd9Sstevel@tonic-gate default: \ 4244a179720Sdanmcd ip_proto_input(q, mp, ipha, ire, recv_ill, 0); \ 4257c478bd9Sstevel@tonic-gate break; \ 4267c478bd9Sstevel@tonic-gate } \ 4277c478bd9Sstevel@tonic-gate } 4287c478bd9Sstevel@tonic-gate 429c793af95Ssangeeta /* 430c793af95Ssangeeta * NCE_EXPIRED is TRUE when we have a non-permanent nce that was 431c793af95Ssangeeta * found to be REACHABLE more than ip_ire_arp_interval ms ago. 432b9c344b3Ssowmini * This macro is used to age existing nce_t entries. The 433b9c344b3Ssowmini * nce's will get cleaned up in the following circumstances: 434c793af95Ssangeeta * - ip_ire_trash_reclaim will free nce's using ndp_cache_reclaim 435c793af95Ssangeeta * when memory is low, 436c793af95Ssangeeta * - ip_arp_news, when updates are received. 437b9c344b3Ssowmini * - if the nce is NCE_EXPIRED(), it will deleted, so that a new 438b9c344b3Ssowmini * arp request will need to be triggered from an ND_INITIAL nce. 439b9c344b3Ssowmini * 440b9c344b3Ssowmini * Note that the nce state transition follows the pattern: 441b9c344b3Ssowmini * ND_INITIAL -> ND_INCOMPLETE -> ND_REACHABLE 442b9c344b3Ssowmini * after which the nce is deleted when it has expired. 443b9c344b3Ssowmini * 444c793af95Ssangeeta * nce_last is the timestamp that indicates when the nce_res_mp in the 445c793af95Ssangeeta * nce_t was last updated to a valid link-layer address. nce_last gets 446c793af95Ssangeeta * modified/updated : 447b9c344b3Ssowmini * - when the nce is created 448c793af95Ssangeeta * - every time we get a sane arp response for the nce. 449c793af95Ssangeeta */ 450f4b3ec61Sdh155122 #define NCE_EXPIRED(nce, ipst) (nce->nce_last > 0 && \ 451c793af95Ssangeeta ((nce->nce_flags & NCE_F_PERMANENT) == 0) && \ 452f4b3ec61Sdh155122 ((TICK_TO_MSEC(lbolt64) - nce->nce_last) > \ 453f4b3ec61Sdh155122 (ipst)->ips_ip_ire_arp_interval)) 4547c478bd9Sstevel@tonic-gate 4557c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 4567c478bd9Sstevel@tonic-gate 4577c478bd9Sstevel@tonic-gate /* ICMP types */ 4587c478bd9Sstevel@tonic-gate #define ICMP_ECHO_REPLY 0 4597c478bd9Sstevel@tonic-gate #define ICMP_DEST_UNREACHABLE 3 4607c478bd9Sstevel@tonic-gate #define ICMP_SOURCE_QUENCH 4 4617c478bd9Sstevel@tonic-gate #define ICMP_REDIRECT 5 4627c478bd9Sstevel@tonic-gate #define ICMP_ECHO_REQUEST 8 4637c478bd9Sstevel@tonic-gate #define ICMP_ROUTER_ADVERTISEMENT 9 4647c478bd9Sstevel@tonic-gate #define ICMP_ROUTER_SOLICITATION 10 4657c478bd9Sstevel@tonic-gate #define ICMP_TIME_EXCEEDED 11 4667c478bd9Sstevel@tonic-gate #define ICMP_PARAM_PROBLEM 12 4677c478bd9Sstevel@tonic-gate #define ICMP_TIME_STAMP_REQUEST 13 4687c478bd9Sstevel@tonic-gate #define ICMP_TIME_STAMP_REPLY 14 4697c478bd9Sstevel@tonic-gate #define ICMP_INFO_REQUEST 15 4707c478bd9Sstevel@tonic-gate #define ICMP_INFO_REPLY 16 4717c478bd9Sstevel@tonic-gate #define ICMP_ADDRESS_MASK_REQUEST 17 4727c478bd9Sstevel@tonic-gate #define ICMP_ADDRESS_MASK_REPLY 18 4737c478bd9Sstevel@tonic-gate 4747c478bd9Sstevel@tonic-gate /* ICMP_TIME_EXCEEDED codes */ 4757c478bd9Sstevel@tonic-gate #define ICMP_TTL_EXCEEDED 0 4767c478bd9Sstevel@tonic-gate #define ICMP_REASSEMBLY_TIME_EXCEEDED 1 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate /* ICMP_DEST_UNREACHABLE codes */ 4797c478bd9Sstevel@tonic-gate #define ICMP_NET_UNREACHABLE 0 4807c478bd9Sstevel@tonic-gate #define ICMP_HOST_UNREACHABLE 1 4817c478bd9Sstevel@tonic-gate #define ICMP_PROTOCOL_UNREACHABLE 2 4827c478bd9Sstevel@tonic-gate #define ICMP_PORT_UNREACHABLE 3 4837c478bd9Sstevel@tonic-gate #define ICMP_FRAGMENTATION_NEEDED 4 4847c478bd9Sstevel@tonic-gate #define ICMP_SOURCE_ROUTE_FAILED 5 4857c478bd9Sstevel@tonic-gate #define ICMP_DEST_NET_UNKNOWN 6 4867c478bd9Sstevel@tonic-gate #define ICMP_DEST_HOST_UNKNOWN 7 4877c478bd9Sstevel@tonic-gate #define ICMP_SRC_HOST_ISOLATED 8 4887c478bd9Sstevel@tonic-gate #define ICMP_DEST_NET_UNREACH_ADMIN 9 4897c478bd9Sstevel@tonic-gate #define ICMP_DEST_HOST_UNREACH_ADMIN 10 4907c478bd9Sstevel@tonic-gate #define ICMP_DEST_NET_UNREACH_TOS 11 4917c478bd9Sstevel@tonic-gate #define ICMP_DEST_HOST_UNREACH_TOS 12 4927c478bd9Sstevel@tonic-gate 4937c478bd9Sstevel@tonic-gate /* ICMP Header Structure */ 4947c478bd9Sstevel@tonic-gate typedef struct icmph_s { 4957c478bd9Sstevel@tonic-gate uint8_t icmph_type; 4967c478bd9Sstevel@tonic-gate uint8_t icmph_code; 4977c478bd9Sstevel@tonic-gate uint16_t icmph_checksum; 4987c478bd9Sstevel@tonic-gate union { 4997c478bd9Sstevel@tonic-gate struct { /* ECHO request/response structure */ 5007c478bd9Sstevel@tonic-gate uint16_t u_echo_ident; 5017c478bd9Sstevel@tonic-gate uint16_t u_echo_seqnum; 5027c478bd9Sstevel@tonic-gate } u_echo; 5037c478bd9Sstevel@tonic-gate struct { /* Destination unreachable structure */ 5047c478bd9Sstevel@tonic-gate uint16_t u_du_zero; 5057c478bd9Sstevel@tonic-gate uint16_t u_du_mtu; 5067c478bd9Sstevel@tonic-gate } u_du; 5077c478bd9Sstevel@tonic-gate struct { /* Parameter problem structure */ 5087c478bd9Sstevel@tonic-gate uint8_t u_pp_ptr; 5097c478bd9Sstevel@tonic-gate uint8_t u_pp_rsvd[3]; 5107c478bd9Sstevel@tonic-gate } u_pp; 5117c478bd9Sstevel@tonic-gate struct { /* Redirect structure */ 5127c478bd9Sstevel@tonic-gate ipaddr_t u_rd_gateway; 5137c478bd9Sstevel@tonic-gate } u_rd; 5147c478bd9Sstevel@tonic-gate } icmph_u; 5157c478bd9Sstevel@tonic-gate } icmph_t; 5167c478bd9Sstevel@tonic-gate 5177c478bd9Sstevel@tonic-gate #define icmph_echo_ident icmph_u.u_echo.u_echo_ident 5187c478bd9Sstevel@tonic-gate #define icmph_echo_seqnum icmph_u.u_echo.u_echo_seqnum 5197c478bd9Sstevel@tonic-gate #define icmph_du_zero icmph_u.u_du.u_du_zero 5207c478bd9Sstevel@tonic-gate #define icmph_du_mtu icmph_u.u_du.u_du_mtu 5217c478bd9Sstevel@tonic-gate #define icmph_pp_ptr icmph_u.u_pp.u_pp_ptr 5227c478bd9Sstevel@tonic-gate #define icmph_rd_gateway icmph_u.u_rd.u_rd_gateway 5237c478bd9Sstevel@tonic-gate 5247c478bd9Sstevel@tonic-gate #define ICMPH_SIZE 8 5257c478bd9Sstevel@tonic-gate 5267c478bd9Sstevel@tonic-gate /* 5277c478bd9Sstevel@tonic-gate * Minimum length of transport layer header included in an ICMP error 5287c478bd9Sstevel@tonic-gate * message for it to be considered valid. 5297c478bd9Sstevel@tonic-gate */ 5307c478bd9Sstevel@tonic-gate #define ICMP_MIN_TP_HDR_LEN 8 5317c478bd9Sstevel@tonic-gate 5327c478bd9Sstevel@tonic-gate /* Aligned IP header */ 5337c478bd9Sstevel@tonic-gate typedef struct ipha_s { 5347c478bd9Sstevel@tonic-gate uint8_t ipha_version_and_hdr_length; 5357c478bd9Sstevel@tonic-gate uint8_t ipha_type_of_service; 5367c478bd9Sstevel@tonic-gate uint16_t ipha_length; 5377c478bd9Sstevel@tonic-gate uint16_t ipha_ident; 5387c478bd9Sstevel@tonic-gate uint16_t ipha_fragment_offset_and_flags; 5397c478bd9Sstevel@tonic-gate uint8_t ipha_ttl; 5407c478bd9Sstevel@tonic-gate uint8_t ipha_protocol; 5417c478bd9Sstevel@tonic-gate uint16_t ipha_hdr_checksum; 5427c478bd9Sstevel@tonic-gate ipaddr_t ipha_src; 5437c478bd9Sstevel@tonic-gate ipaddr_t ipha_dst; 5447c478bd9Sstevel@tonic-gate } ipha_t; 5457c478bd9Sstevel@tonic-gate 54610e6dadfSbrendan /* 54710e6dadfSbrendan * IP Flags 54810e6dadfSbrendan * 54910e6dadfSbrendan * Some of these constant names are copied for the DTrace IP provider in 55010e6dadfSbrendan * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept 55110e6dadfSbrendan * in sync. 55210e6dadfSbrendan */ 5537c478bd9Sstevel@tonic-gate #define IPH_DF 0x4000 /* Don't fragment */ 5547c478bd9Sstevel@tonic-gate #define IPH_MF 0x2000 /* More fragments to come */ 5557c478bd9Sstevel@tonic-gate #define IPH_OFFSET 0x1FFF /* Where the offset lives */ 5567c478bd9Sstevel@tonic-gate #define IPH_FRAG_HDR 0x8000 /* IPv6 don't fragment bit */ 5577c478bd9Sstevel@tonic-gate 5587c478bd9Sstevel@tonic-gate /* ECN code points for IPv4 TOS byte and IPv6 traffic class octet. */ 5597924222fSmeem #define IPH_ECN_NECT 0x0 /* Not ECN-Capable Transport */ 5607c478bd9Sstevel@tonic-gate #define IPH_ECN_ECT1 0x1 /* ECN-Capable Transport, ECT(1) */ 5617c478bd9Sstevel@tonic-gate #define IPH_ECN_ECT0 0x2 /* ECN-Capable Transport, ECT(0) */ 5627c478bd9Sstevel@tonic-gate #define IPH_ECN_CE 0x3 /* ECN-Congestion Experienced (CE) */ 5637c478bd9Sstevel@tonic-gate 564e11c3f44Smeem struct ill_s; 565e11c3f44Smeem 566e11c3f44Smeem typedef boolean_t ip_v6intfid_func_t(struct ill_s *, in6_addr_t *); 567e11c3f44Smeem typedef boolean_t ip_v6mapinfo_func_t(uint_t, uint8_t *, uint8_t *, uint32_t *, 568e11c3f44Smeem in6_addr_t *); 569e11c3f44Smeem typedef boolean_t ip_v4mapinfo_func_t(uint_t, uint8_t *, uint8_t *, uint32_t *, 570e11c3f44Smeem ipaddr_t *); 571e11c3f44Smeem 5727c478bd9Sstevel@tonic-gate /* IP Mac info structure */ 5737c478bd9Sstevel@tonic-gate typedef struct ip_m_s { 5747c478bd9Sstevel@tonic-gate t_uscalar_t ip_m_mac_type; /* From <sys/dlpi.h> */ 5757c478bd9Sstevel@tonic-gate int ip_m_type; /* From <net/if_types.h> */ 576e11c3f44Smeem ip_v4mapinfo_func_t *ip_m_v4mapinfo; 577e11c3f44Smeem ip_v6mapinfo_func_t *ip_m_v6mapinfo; 578e11c3f44Smeem ip_v6intfid_func_t *ip_m_v6intfid; 5797c478bd9Sstevel@tonic-gate } ip_m_t; 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate /* 5827c478bd9Sstevel@tonic-gate * The following functions attempt to reduce the link layer dependency 5837c478bd9Sstevel@tonic-gate * of the IP stack. The current set of link specific operations are: 5847c478bd9Sstevel@tonic-gate * a. map from IPv4 class D (224.0/4) multicast address range to the link 5857c478bd9Sstevel@tonic-gate * layer multicast address range. 5867c478bd9Sstevel@tonic-gate * b. map from IPv6 multicast address range (ff00::/8) to the link 5877c478bd9Sstevel@tonic-gate * layer multicast address range. 588e11c3f44Smeem * c. derive the default IPv6 interface identifier from the interface. 589e11c3f44Smeem * d. derive the default IPv6 destination interface identifier from 590e11c3f44Smeem * the interface (point-to-point only). 5917c478bd9Sstevel@tonic-gate */ 5927c478bd9Sstevel@tonic-gate #define MEDIA_V4MINFO(ip_m, plen, bphys, maddr, hwxp, v4ptr) \ 5937c478bd9Sstevel@tonic-gate (((ip_m)->ip_m_v4mapinfo != NULL) && \ 5947c478bd9Sstevel@tonic-gate (*(ip_m)->ip_m_v4mapinfo)(plen, bphys, maddr, hwxp, v4ptr)) 5957c478bd9Sstevel@tonic-gate #define MEDIA_V6MINFO(ip_m, plen, bphys, maddr, hwxp, v6ptr) \ 5967c478bd9Sstevel@tonic-gate (((ip_m)->ip_m_v6mapinfo != NULL) && \ 5977c478bd9Sstevel@tonic-gate (*(ip_m)->ip_m_v6mapinfo)(plen, bphys, maddr, hwxp, v6ptr)) 598e11c3f44Smeem #define MEDIA_V6INTFID(ip_m, ill, v6ptr) \ 599e11c3f44Smeem (((ip_m)->ip_m_v6intfid != NULL) && \ 600e11c3f44Smeem (*(ip_m)->ip_m_v6intfid)(ill, v6ptr)) 601e11c3f44Smeem #define MEDIA_V6DESTINTFID(ip_m, ill, v6ptr) \ 602e11c3f44Smeem (((ip_m)->ip_m_v6destintfid != NULL) && \ 603e11c3f44Smeem (*(ip_m)->ip_m_v6destintfid)(ill, v6ptr)) 6047c478bd9Sstevel@tonic-gate 6057c478bd9Sstevel@tonic-gate /* Router entry types */ 6067c478bd9Sstevel@tonic-gate #define IRE_BROADCAST 0x0001 /* Route entry for broadcast address */ 6077c478bd9Sstevel@tonic-gate #define IRE_DEFAULT 0x0002 /* Route entry for default gateway */ 6087c478bd9Sstevel@tonic-gate #define IRE_LOCAL 0x0004 /* Route entry for local address */ 6097c478bd9Sstevel@tonic-gate #define IRE_LOOPBACK 0x0008 /* Route entry for loopback address */ 6107c478bd9Sstevel@tonic-gate #define IRE_PREFIX 0x0010 /* Route entry for prefix routes */ 6117c478bd9Sstevel@tonic-gate #define IRE_CACHE 0x0020 /* Cached Route entry */ 6127c478bd9Sstevel@tonic-gate #define IRE_IF_NORESOLVER 0x0040 /* Route entry for local interface */ 6137c478bd9Sstevel@tonic-gate /* net without any address mapping. */ 6147c478bd9Sstevel@tonic-gate #define IRE_IF_RESOLVER 0x0080 /* Route entry for local interface */ 6157c478bd9Sstevel@tonic-gate /* net with resolver. */ 6167c478bd9Sstevel@tonic-gate #define IRE_HOST 0x0100 /* Host route entry */ 6176bdb8e66Sdd193516 #define IRE_HOST_REDIRECT 0x0200 /* only used for T_SVR4_OPTMGMT_REQ */ 6187c478bd9Sstevel@tonic-gate 6197c478bd9Sstevel@tonic-gate #define IRE_INTERFACE (IRE_IF_NORESOLVER | IRE_IF_RESOLVER) 6206bdb8e66Sdd193516 #define IRE_OFFSUBNET (IRE_DEFAULT | IRE_PREFIX | IRE_HOST) 6217c478bd9Sstevel@tonic-gate #define IRE_CACHETABLE (IRE_CACHE | IRE_BROADCAST | IRE_LOCAL | \ 6227c478bd9Sstevel@tonic-gate IRE_LOOPBACK) 6237c478bd9Sstevel@tonic-gate #define IRE_FORWARDTABLE (IRE_INTERFACE | IRE_OFFSUBNET) 6247c478bd9Sstevel@tonic-gate 6257c478bd9Sstevel@tonic-gate /* 6267c478bd9Sstevel@tonic-gate * If an IRE is marked with IRE_MARK_CONDEMNED, the last walker of 6277c478bd9Sstevel@tonic-gate * the bucket should delete this IRE from this bucket. 6287c478bd9Sstevel@tonic-gate */ 6297c478bd9Sstevel@tonic-gate #define IRE_MARK_CONDEMNED 0x0001 630e11c3f44Smeem 6317c478bd9Sstevel@tonic-gate /* 632a988fde5SErik Nordmark * An IRE with IRE_MARK_PMTU has ire_max_frag set from an ICMP error. 633a988fde5SErik Nordmark */ 634a988fde5SErik Nordmark #define IRE_MARK_PMTU 0x0002 635a988fde5SErik Nordmark 636a988fde5SErik Nordmark /* 637e11c3f44Smeem * An IRE with IRE_MARK_TESTHIDDEN is used by in.mpathd for test traffic. It 638e11c3f44Smeem * can only be looked up by requesting MATCH_IRE_MARK_TESTHIDDEN. 6397c478bd9Sstevel@tonic-gate */ 640e11c3f44Smeem #define IRE_MARK_TESTHIDDEN 0x0004 6417c478bd9Sstevel@tonic-gate 6427c478bd9Sstevel@tonic-gate /* 643e704a8f2Smeem * An IRE with IRE_MARK_NOADD is created in ip_newroute_ipif when the outgoing 644e704a8f2Smeem * interface is specified by e.g. IP_PKTINFO. The IRE is not added to the IRE 645e704a8f2Smeem * cache table. 6467c478bd9Sstevel@tonic-gate */ 6477c478bd9Sstevel@tonic-gate #define IRE_MARK_NOADD 0x0008 /* Mark not to add ire in cache */ 6487c478bd9Sstevel@tonic-gate 6497c478bd9Sstevel@tonic-gate /* 6507c478bd9Sstevel@tonic-gate * IRE marked with IRE_MARK_TEMPORARY means that this IRE has been used 6517c478bd9Sstevel@tonic-gate * either for forwarding a packet or has not been used for sending 6527c478bd9Sstevel@tonic-gate * traffic on TCP connections terminated on this system. In both 6537c478bd9Sstevel@tonic-gate * cases, this IRE is the first to go when IRE is being cleaned up. 6547c478bd9Sstevel@tonic-gate */ 6557c478bd9Sstevel@tonic-gate #define IRE_MARK_TEMPORARY 0x0010 6567c478bd9Sstevel@tonic-gate 6577c478bd9Sstevel@tonic-gate /* 6587c478bd9Sstevel@tonic-gate * IRE marked with IRE_MARK_USESRC_CHECK means that while adding an IRE with 6597c478bd9Sstevel@tonic-gate * this mark, additional atomic checks need to be performed. For eg: by the 6607c478bd9Sstevel@tonic-gate * time an IRE_CACHE is created, sent up to ARP and then comes back to IP; the 6617c478bd9Sstevel@tonic-gate * usesrc grouping could have changed in which case we want to fail adding 6627c478bd9Sstevel@tonic-gate * the IRE_CACHE entry 6637c478bd9Sstevel@tonic-gate */ 6647c478bd9Sstevel@tonic-gate #define IRE_MARK_USESRC_CHECK 0x0020 6657c478bd9Sstevel@tonic-gate 66643d18f1cSpriyanka /* 66743d18f1cSpriyanka * IRE_MARK_PRIVATE_ADDR is used for IP_NEXTHOP. When IP_NEXTHOP is set, the 66843d18f1cSpriyanka * routing table lookup for the destination is bypassed and the packet is 66943d18f1cSpriyanka * sent directly to the specified nexthop. The associated IRE_CACHE entries 67043d18f1cSpriyanka * should be marked with IRE_MARK_PRIVATE_ADDR flag so that they don't show up 67143d18f1cSpriyanka * in regular ire cache lookups. 67243d18f1cSpriyanka */ 67343d18f1cSpriyanka #define IRE_MARK_PRIVATE_ADDR 0x0040 67443d18f1cSpriyanka 675c793af95Ssangeeta /* 676c793af95Ssangeeta * When we send an ARP resolution query for the nexthop gateway's ire, 677c793af95Ssangeeta * we use esballoc to create the ire_t in the AR_ENTRY_QUERY mblk 678c793af95Ssangeeta * chain, and mark its ire_marks with IRE_MARK_UNCACHED. This flag 679c793af95Ssangeeta * indicates that information from ARP has not been transferred to a 680c793af95Ssangeeta * permanent IRE_CACHE entry. The flag is reset only when the 681c793af95Ssangeeta * information is successfully transferred to an ire_cache entry (in 682c793af95Ssangeeta * ire_add()). Attempting to free the AR_ENTRY_QUERY mblk chain prior 683c793af95Ssangeeta * to ire_add (e.g., from arp, or from ip`ip_wput_nondata) will 684c793af95Ssangeeta * require that the resources (incomplete ire_cache and/or nce) must 685c793af95Ssangeeta * be cleaned up. The free callback routine (ire_freemblk()) checks 686c793af95Ssangeeta * for IRE_MARK_UNCACHED to see if any resources that are pinned down 687c793af95Ssangeeta * will need to be cleaned up or not. 688c793af95Ssangeeta */ 689c793af95Ssangeeta 690c793af95Ssangeeta #define IRE_MARK_UNCACHED 0x0080 691c793af95Ssangeeta 692f4b3ec61Sdh155122 /* 693f4b3ec61Sdh155122 * The comment below (and for other netstack_t references) refers 694f4b3ec61Sdh155122 * to the fact that we only do netstack_hold in particular cases, 695f4b3ec61Sdh155122 * such as the references from open streams (ill_t and conn_t's 696f4b3ec61Sdh155122 * pointers). Internally within IP we rely on IP's ability to cleanup e.g. 697f4b3ec61Sdh155122 * ire_t's when an ill goes away. 698f4b3ec61Sdh155122 */ 699f4b3ec61Sdh155122 typedef struct ire_expire_arg_s { 700f4b3ec61Sdh155122 int iea_flush_flag; 701f4b3ec61Sdh155122 ip_stack_t *iea_ipst; /* Does not have a netstack_hold */ 702f4b3ec61Sdh155122 } ire_expire_arg_t; 703f4b3ec61Sdh155122 7047c478bd9Sstevel@tonic-gate /* Flags with ire_expire routine */ 7057c478bd9Sstevel@tonic-gate #define FLUSH_ARP_TIME 0x0001 /* ARP info potentially stale timer */ 7067c478bd9Sstevel@tonic-gate #define FLUSH_REDIRECT_TIME 0x0002 /* Redirects potentially stale */ 7077c478bd9Sstevel@tonic-gate #define FLUSH_MTU_TIME 0x0004 /* Include path MTU per RFC 1191 */ 7087c478bd9Sstevel@tonic-gate 7097c478bd9Sstevel@tonic-gate /* Arguments to ire_flush_cache() */ 7107c478bd9Sstevel@tonic-gate #define IRE_FLUSH_DELETE 0 7117c478bd9Sstevel@tonic-gate #define IRE_FLUSH_ADD 1 7127c478bd9Sstevel@tonic-gate 7137c478bd9Sstevel@tonic-gate /* 7147c478bd9Sstevel@tonic-gate * Open/close synchronization flags. 7157c478bd9Sstevel@tonic-gate * These are kept in a separate field in the conn and the synchronization 7167c478bd9Sstevel@tonic-gate * depends on the atomic 32 bit access to that field. 7177c478bd9Sstevel@tonic-gate */ 7187c478bd9Sstevel@tonic-gate #define CONN_CLOSING 0x01 /* ip_close waiting for ip_wsrv */ 719ff550d0eSmasputra #define CONN_IPSEC_LOAD_WAIT 0x02 /* waiting for load */ 720ff550d0eSmasputra #define CONN_CONDEMNED 0x04 /* conn is closing, no more refs */ 721ff550d0eSmasputra #define CONN_INCIPIENT 0x08 /* conn not yet visible, no refs */ 722ff550d0eSmasputra #define CONN_QUIESCED 0x10 /* conn is now quiescent */ 7237c478bd9Sstevel@tonic-gate 724325b8068Sgeorges /* Used to check connection state flags before caching the IRE */ 725325b8068Sgeorges #define CONN_CACHE_IRE(connp) \ 726325b8068Sgeorges (!((connp)->conn_state_flags & (CONN_CLOSING|CONN_CONDEMNED))) 727325b8068Sgeorges 7287c478bd9Sstevel@tonic-gate /* 7297c478bd9Sstevel@tonic-gate * Parameter to ip_output giving the identity of the caller. 7307c478bd9Sstevel@tonic-gate * IP_WSRV means the packet was enqueued in the STREAMS queue 7317c478bd9Sstevel@tonic-gate * due to flow control and is now being reprocessed in the context of 7327c478bd9Sstevel@tonic-gate * the STREAMS service procedure, consequent to flow control relief. 7337c478bd9Sstevel@tonic-gate * IRE_SEND means the packet is being reprocessed consequent to an 7347c478bd9Sstevel@tonic-gate * ire cache creation and addition and this may or may not be happening 7357c478bd9Sstevel@tonic-gate * in the service procedure context. Anything other than the above 2 7367c478bd9Sstevel@tonic-gate * cases is identified as IP_WPUT. Most commonly this is the case of 7377c478bd9Sstevel@tonic-gate * packets coming down from the application. 7387c478bd9Sstevel@tonic-gate */ 7397c478bd9Sstevel@tonic-gate #ifdef _KERNEL 7407c478bd9Sstevel@tonic-gate #define IP_WSRV 1 /* Called from ip_wsrv */ 7417c478bd9Sstevel@tonic-gate #define IP_WPUT 2 /* Called from ip_wput */ 7427c478bd9Sstevel@tonic-gate #define IRE_SEND 3 /* Called from ire_send */ 7437c478bd9Sstevel@tonic-gate 7447c478bd9Sstevel@tonic-gate /* 7457c478bd9Sstevel@tonic-gate * Extra structures need for per-src-addr filtering (IGMPv3/MLDv2) 7467c478bd9Sstevel@tonic-gate */ 7477c478bd9Sstevel@tonic-gate #define MAX_FILTER_SIZE 64 7487c478bd9Sstevel@tonic-gate 7497c478bd9Sstevel@tonic-gate typedef struct slist_s { 7507c478bd9Sstevel@tonic-gate int sl_numsrc; 7517c478bd9Sstevel@tonic-gate in6_addr_t sl_addr[MAX_FILTER_SIZE]; 7527c478bd9Sstevel@tonic-gate } slist_t; 7537c478bd9Sstevel@tonic-gate 7547c478bd9Sstevel@tonic-gate /* 7557c478bd9Sstevel@tonic-gate * Following struct is used to maintain retransmission state for 7567c478bd9Sstevel@tonic-gate * a multicast group. One rtx_state_t struct is an in-line field 7577c478bd9Sstevel@tonic-gate * of the ilm_t struct; the slist_ts in the rtx_state_t struct are 7587c478bd9Sstevel@tonic-gate * alloc'd as needed. 7597c478bd9Sstevel@tonic-gate */ 7607c478bd9Sstevel@tonic-gate typedef struct rtx_state_s { 7617c478bd9Sstevel@tonic-gate uint_t rtx_timer; /* retrans timer */ 7627c478bd9Sstevel@tonic-gate int rtx_cnt; /* retrans count */ 7637c478bd9Sstevel@tonic-gate int rtx_fmode_cnt; /* retrans count for fmode change */ 7647c478bd9Sstevel@tonic-gate slist_t *rtx_allow; 7657c478bd9Sstevel@tonic-gate slist_t *rtx_block; 7667c478bd9Sstevel@tonic-gate } rtx_state_t; 7677c478bd9Sstevel@tonic-gate 7687c478bd9Sstevel@tonic-gate /* 7697c478bd9Sstevel@tonic-gate * Used to construct list of multicast address records that will be 7707c478bd9Sstevel@tonic-gate * sent in a single listener report. 7717c478bd9Sstevel@tonic-gate */ 7727c478bd9Sstevel@tonic-gate typedef struct mrec_s { 7737c478bd9Sstevel@tonic-gate struct mrec_s *mrec_next; 7747c478bd9Sstevel@tonic-gate uint8_t mrec_type; 7757c478bd9Sstevel@tonic-gate uint8_t mrec_auxlen; /* currently unused */ 7767c478bd9Sstevel@tonic-gate in6_addr_t mrec_group; 7777c478bd9Sstevel@tonic-gate slist_t mrec_srcs; 7787c478bd9Sstevel@tonic-gate } mrec_t; 7797c478bd9Sstevel@tonic-gate 7807c478bd9Sstevel@tonic-gate /* Group membership list per upper conn */ 7817c478bd9Sstevel@tonic-gate /* 7827c478bd9Sstevel@tonic-gate * XXX add ilg info for ifaddr/ifindex. 7837c478bd9Sstevel@tonic-gate * XXX can we make ilg survive an ifconfig unplumb + plumb 7847c478bd9Sstevel@tonic-gate * by setting the ipif/ill to NULL and recover that later? 7857c478bd9Sstevel@tonic-gate * 7867c478bd9Sstevel@tonic-gate * ilg_ipif is used by IPv4 as multicast groups are joined using an interface 7877c478bd9Sstevel@tonic-gate * address (ipif). 7887c478bd9Sstevel@tonic-gate * ilg_ill is used by IPv6 as multicast groups are joined using an interface 7897c478bd9Sstevel@tonic-gate * index (phyint->phyint_ifindex). 7907c478bd9Sstevel@tonic-gate * ilg_ill is NULL for IPv4 and ilg_ipif is NULL for IPv6. 7917c478bd9Sstevel@tonic-gate * 7927c478bd9Sstevel@tonic-gate * ilg records the state of multicast memberships of a socket end point. 7937c478bd9Sstevel@tonic-gate * ilm records the state of multicast memberships with the driver and is 7947c478bd9Sstevel@tonic-gate * maintained per interface. 7957c478bd9Sstevel@tonic-gate * 796e11c3f44Smeem * There is no direct link between a given ilg and ilm. If the 7977c478bd9Sstevel@tonic-gate * application has joined a group G with ifindex I, we will have 7987c478bd9Sstevel@tonic-gate * an ilg with ilg_v6group and ilg_ill. There will be a corresponding 7997c478bd9Sstevel@tonic-gate * ilm with ilm_ill/ilm_v6addr recording the multicast membership. 800e11c3f44Smeem * To delete the membership: 8017c478bd9Sstevel@tonic-gate * 8027c478bd9Sstevel@tonic-gate * a) Search for ilg matching on G and I with ilg_v6group 8037c478bd9Sstevel@tonic-gate * and ilg_ill. Delete ilg_ill. 8047c478bd9Sstevel@tonic-gate * b) Search the corresponding ilm matching on G and I with 8057c478bd9Sstevel@tonic-gate * ilm_v6addr and ilm_ill. Delete ilm. 8067c478bd9Sstevel@tonic-gate * 807e11c3f44Smeem * For IPv4 the only difference is that we look using ipifs, not ills. 8087c478bd9Sstevel@tonic-gate */ 8097c478bd9Sstevel@tonic-gate 8107c478bd9Sstevel@tonic-gate /* 8117c478bd9Sstevel@tonic-gate * The ilg_t and ilm_t members are protected by ipsq. They can be changed only 8127c478bd9Sstevel@tonic-gate * by a thread executing in the ipsq. In other words add/delete of a 8137c478bd9Sstevel@tonic-gate * multicast group has to execute in the ipsq. 8147c478bd9Sstevel@tonic-gate */ 8157c478bd9Sstevel@tonic-gate #define ILG_DELETED 0x1 /* ilg_flags */ 8167c478bd9Sstevel@tonic-gate typedef struct ilg_s { 8177c478bd9Sstevel@tonic-gate in6_addr_t ilg_v6group; 8187c478bd9Sstevel@tonic-gate struct ipif_s *ilg_ipif; /* Logical interface we are member on */ 8197c478bd9Sstevel@tonic-gate struct ill_s *ilg_ill; /* Used by IPv6 */ 8207c478bd9Sstevel@tonic-gate uint_t ilg_flags; 8217c478bd9Sstevel@tonic-gate mcast_record_t ilg_fmode; /* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */ 8227c478bd9Sstevel@tonic-gate slist_t *ilg_filter; 8237c478bd9Sstevel@tonic-gate } ilg_t; 8247c478bd9Sstevel@tonic-gate 8257c478bd9Sstevel@tonic-gate /* 8267924222fSmeem * Multicast address list entry for ill. 8277c478bd9Sstevel@tonic-gate * ilm_ipif is used by IPv4 as multicast groups are joined using ipif. 8287c478bd9Sstevel@tonic-gate * ilm_ill is used by IPv6 as multicast groups are joined using ill. 8297c478bd9Sstevel@tonic-gate * ilm_ill is NULL for IPv4 and ilm_ipif is NULL for IPv6. 830f4b3ec61Sdh155122 * 831f4b3ec61Sdh155122 * The comment below (and for other netstack_t references) refers 832f4b3ec61Sdh155122 * to the fact that we only do netstack_hold in particular cases, 833f4b3ec61Sdh155122 * such as the references from open streams (ill_t and conn_t's 834f4b3ec61Sdh155122 * pointers). Internally within IP we rely on IP's ability to cleanup e.g. 835f4b3ec61Sdh155122 * ire_t's when an ill goes away. 8367c478bd9Sstevel@tonic-gate */ 8377c478bd9Sstevel@tonic-gate #define ILM_DELETED 0x1 /* ilm_flags */ 8387c478bd9Sstevel@tonic-gate typedef struct ilm_s { 8397c478bd9Sstevel@tonic-gate in6_addr_t ilm_v6addr; 8407c478bd9Sstevel@tonic-gate int ilm_refcnt; 8417c478bd9Sstevel@tonic-gate uint_t ilm_timer; /* IGMP/MLD query resp timer, in msec */ 8427c478bd9Sstevel@tonic-gate struct ipif_s *ilm_ipif; /* Back pointer to ipif for IPv4 */ 8437c478bd9Sstevel@tonic-gate struct ilm_s *ilm_next; /* Linked list for each ill */ 8447c478bd9Sstevel@tonic-gate uint_t ilm_state; /* state of the membership */ 8457c478bd9Sstevel@tonic-gate struct ill_s *ilm_ill; /* Back pointer to ill for IPv6 */ 8467c478bd9Sstevel@tonic-gate uint_t ilm_flags; 8477c478bd9Sstevel@tonic-gate boolean_t ilm_notify_driver; /* Need to notify the driver */ 8487c478bd9Sstevel@tonic-gate zoneid_t ilm_zoneid; 8497c478bd9Sstevel@tonic-gate int ilm_no_ilg_cnt; /* number of joins w/ no ilg */ 8507c478bd9Sstevel@tonic-gate mcast_record_t ilm_fmode; /* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */ 8517c478bd9Sstevel@tonic-gate slist_t *ilm_filter; /* source filter list */ 8527c478bd9Sstevel@tonic-gate slist_t *ilm_pendsrcs; /* relevant src addrs for pending req */ 8537c478bd9Sstevel@tonic-gate rtx_state_t ilm_rtx; /* SCR retransmission state */ 854f4b3ec61Sdh155122 ip_stack_t *ilm_ipst; /* Does not have a netstack_hold */ 8557c478bd9Sstevel@tonic-gate } ilm_t; 8567c478bd9Sstevel@tonic-gate 8577c478bd9Sstevel@tonic-gate #define ilm_addr V4_PART_OF_V6(ilm_v6addr) 8587c478bd9Sstevel@tonic-gate 859e11c3f44Smeem typedef struct ilm_walker { 860e11c3f44Smeem struct ill_s *ilw_ill; /* associated ill */ 861e11c3f44Smeem struct ill_s *ilw_ipmp_ill; /* associated ipmp ill (if any) */ 862e11c3f44Smeem struct ill_s *ilw_walk_ill; /* current ill being walked */ 863e11c3f44Smeem } ilm_walker_t; 8647c478bd9Sstevel@tonic-gate 8657c478bd9Sstevel@tonic-gate /* 8667c478bd9Sstevel@tonic-gate * Soft reference to an IPsec SA. 8677c478bd9Sstevel@tonic-gate * 8687924222fSmeem * On relative terms, conn's can be persistent (living as long as the 8697c478bd9Sstevel@tonic-gate * processes which create them), while SA's are ephemeral (dying when 8707c478bd9Sstevel@tonic-gate * they hit their time-based or byte-based lifetimes). 8717c478bd9Sstevel@tonic-gate * 8727c478bd9Sstevel@tonic-gate * We could hold a hard reference to an SA from an ipsec_latch_t, 8737c478bd9Sstevel@tonic-gate * but this would cause expired SA's to linger for a potentially 8747c478bd9Sstevel@tonic-gate * unbounded time. 8757c478bd9Sstevel@tonic-gate * 8767c478bd9Sstevel@tonic-gate * Instead, we remember the hash bucket number and bucket generation 8777c478bd9Sstevel@tonic-gate * in addition to the pointer. The bucket generation is incremented on 8787c478bd9Sstevel@tonic-gate * each deletion. 8797c478bd9Sstevel@tonic-gate */ 8807c478bd9Sstevel@tonic-gate typedef struct ipsa_ref_s 8817c478bd9Sstevel@tonic-gate { 8827c478bd9Sstevel@tonic-gate struct ipsa_s *ipsr_sa; 8837c478bd9Sstevel@tonic-gate struct isaf_s *ipsr_bucket; 8847c478bd9Sstevel@tonic-gate uint64_t ipsr_gen; 8857c478bd9Sstevel@tonic-gate } ipsa_ref_t; 8867c478bd9Sstevel@tonic-gate 8877c478bd9Sstevel@tonic-gate /* 8887c478bd9Sstevel@tonic-gate * IPsec "latching" state. 8897c478bd9Sstevel@tonic-gate * 8907c478bd9Sstevel@tonic-gate * In the presence of IPsec policy, fully-bound conn's bind a connection 8917c478bd9Sstevel@tonic-gate * to more than just the 5-tuple, but also a specific IPsec action and 8927c478bd9Sstevel@tonic-gate * identity-pair. 8937c478bd9Sstevel@tonic-gate * 8947c478bd9Sstevel@tonic-gate * As an optimization, we also cache soft references to IPsec SA's 8957c478bd9Sstevel@tonic-gate * here so that we can fast-path around most of the work needed for 8967c478bd9Sstevel@tonic-gate * outbound IPsec SA selection. 8977c478bd9Sstevel@tonic-gate * 8987c478bd9Sstevel@tonic-gate * Were it not for TCP's detached connections, this state would be 8997c478bd9Sstevel@tonic-gate * in-line in conn_t; instead, this is in a separate structure so it 9007c478bd9Sstevel@tonic-gate * can be handed off to TCP when a connection is detached. 9017c478bd9Sstevel@tonic-gate */ 9027c478bd9Sstevel@tonic-gate typedef struct ipsec_latch_s 9037c478bd9Sstevel@tonic-gate { 9047c478bd9Sstevel@tonic-gate kmutex_t ipl_lock; 9057c478bd9Sstevel@tonic-gate uint32_t ipl_refcnt; 9067c478bd9Sstevel@tonic-gate 9077c478bd9Sstevel@tonic-gate uint64_t ipl_unique; 9087c478bd9Sstevel@tonic-gate struct ipsec_policy_s *ipl_in_policy; /* latched policy (in) */ 9097c478bd9Sstevel@tonic-gate struct ipsec_policy_s *ipl_out_policy; /* latched policy (out) */ 9107c478bd9Sstevel@tonic-gate struct ipsec_action_s *ipl_in_action; /* latched action (in) */ 9117c478bd9Sstevel@tonic-gate struct ipsec_action_s *ipl_out_action; /* latched action (out) */ 9127c478bd9Sstevel@tonic-gate cred_t *ipl_local_id; 9137c478bd9Sstevel@tonic-gate struct ipsid_s *ipl_local_cid; 9147c478bd9Sstevel@tonic-gate struct ipsid_s *ipl_remote_cid; 9157c478bd9Sstevel@tonic-gate unsigned int 9167c478bd9Sstevel@tonic-gate ipl_out_action_latched : 1, 9177c478bd9Sstevel@tonic-gate ipl_in_action_latched : 1, 9187c478bd9Sstevel@tonic-gate ipl_out_policy_latched : 1, 9197c478bd9Sstevel@tonic-gate ipl_in_policy_latched : 1, 9207c478bd9Sstevel@tonic-gate 9217c478bd9Sstevel@tonic-gate ipl_ids_latched : 1, 9227c478bd9Sstevel@tonic-gate 9237c478bd9Sstevel@tonic-gate ipl_pad_to_bit_31 : 27; 9247c478bd9Sstevel@tonic-gate 9257c478bd9Sstevel@tonic-gate ipsa_ref_t ipl_ref[2]; /* 0: ESP, 1: AH */ 9267c478bd9Sstevel@tonic-gate 9277c478bd9Sstevel@tonic-gate } ipsec_latch_t; 9287c478bd9Sstevel@tonic-gate 9297c478bd9Sstevel@tonic-gate #define IPLATCH_REFHOLD(ipl) { \ 9307c478bd9Sstevel@tonic-gate atomic_add_32(&(ipl)->ipl_refcnt, 1); \ 9317c478bd9Sstevel@tonic-gate ASSERT((ipl)->ipl_refcnt != 0); \ 9327c478bd9Sstevel@tonic-gate } 9337c478bd9Sstevel@tonic-gate 934f4b3ec61Sdh155122 #define IPLATCH_REFRELE(ipl, ns) { \ 9357c478bd9Sstevel@tonic-gate ASSERT((ipl)->ipl_refcnt != 0); \ 9367c478bd9Sstevel@tonic-gate membar_exit(); \ 9377c478bd9Sstevel@tonic-gate if (atomic_add_32_nv(&(ipl)->ipl_refcnt, -1) == 0) \ 938f4b3ec61Sdh155122 iplatch_free(ipl, ns); \ 9397c478bd9Sstevel@tonic-gate } 9407c478bd9Sstevel@tonic-gate 9417c478bd9Sstevel@tonic-gate /* 9427c478bd9Sstevel@tonic-gate * peer identity structure. 9437c478bd9Sstevel@tonic-gate */ 9447c478bd9Sstevel@tonic-gate 9457c478bd9Sstevel@tonic-gate typedef struct conn_s conn_t; 9467c478bd9Sstevel@tonic-gate 9477c478bd9Sstevel@tonic-gate /* 9487c478bd9Sstevel@tonic-gate * The old IP client structure "ipc_t" is gone. All the data is stored in the 9497c478bd9Sstevel@tonic-gate * connection structure "conn_t" now. The mapping of old and new fields looks 9507c478bd9Sstevel@tonic-gate * like this: 9517c478bd9Sstevel@tonic-gate * 9527c478bd9Sstevel@tonic-gate * ipc_ulp conn_ulp 9537c478bd9Sstevel@tonic-gate * ipc_rq conn_rq 9547c478bd9Sstevel@tonic-gate * ipc_wq conn_wq 9557c478bd9Sstevel@tonic-gate * 9567c478bd9Sstevel@tonic-gate * ipc_laddr conn_src 9577c478bd9Sstevel@tonic-gate * ipc_faddr conn_rem 9587c478bd9Sstevel@tonic-gate * ipc_v6laddr conn_srcv6 9597c478bd9Sstevel@tonic-gate * ipc_v6faddr conn_remv6 9607c478bd9Sstevel@tonic-gate * 9617c478bd9Sstevel@tonic-gate * ipc_lport conn_lport 9627c478bd9Sstevel@tonic-gate * ipc_fport conn_fport 9637c478bd9Sstevel@tonic-gate * ipc_ports conn_ports 9647c478bd9Sstevel@tonic-gate * 9657c478bd9Sstevel@tonic-gate * ipc_policy conn_policy 9667c478bd9Sstevel@tonic-gate * ipc_latch conn_latch 9677c478bd9Sstevel@tonic-gate * 9687c478bd9Sstevel@tonic-gate * ipc_irc_lock conn_lock 9697c478bd9Sstevel@tonic-gate * ipc_ire_cache conn_ire_cache 9707c478bd9Sstevel@tonic-gate * 9717c478bd9Sstevel@tonic-gate * ipc_state_flags conn_state_flags 9727c478bd9Sstevel@tonic-gate * ipc_outgoing_ill conn_outgoing_ill 9737c478bd9Sstevel@tonic-gate * 9747c478bd9Sstevel@tonic-gate * ipc_dontroute conn_dontroute 9757c478bd9Sstevel@tonic-gate * ipc_loopback conn_loopback 9767c478bd9Sstevel@tonic-gate * ipc_broadcast conn_broadcast 9777c478bd9Sstevel@tonic-gate * ipc_reuseaddr conn_reuseaddr 9787c478bd9Sstevel@tonic-gate * 9797c478bd9Sstevel@tonic-gate * ipc_multicast_loop conn_multicast_loop 9807c478bd9Sstevel@tonic-gate * ipc_multi_router conn_multi_router 9817c478bd9Sstevel@tonic-gate * ipc_draining conn_draining 9827c478bd9Sstevel@tonic-gate * 9837c478bd9Sstevel@tonic-gate * ipc_did_putbq conn_did_putbq 9847c478bd9Sstevel@tonic-gate * ipc_unspec_src conn_unspec_src 9857c478bd9Sstevel@tonic-gate * ipc_policy_cached conn_policy_cached 9867c478bd9Sstevel@tonic-gate * 9877c478bd9Sstevel@tonic-gate * ipc_in_enforce_policy conn_in_enforce_policy 9887c478bd9Sstevel@tonic-gate * ipc_out_enforce_policy conn_out_enforce_policy 9897c478bd9Sstevel@tonic-gate * ipc_af_isv6 conn_af_isv6 9907c478bd9Sstevel@tonic-gate * ipc_pkt_isv6 conn_pkt_isv6 9917c478bd9Sstevel@tonic-gate * 9927c478bd9Sstevel@tonic-gate * ipc_ipv6_recvpktinfo conn_ipv6_recvpktinfo 9937c478bd9Sstevel@tonic-gate * 9947c478bd9Sstevel@tonic-gate * ipc_ipv6_recvhoplimit conn_ipv6_recvhoplimit 9957c478bd9Sstevel@tonic-gate * ipc_ipv6_recvhopopts conn_ipv6_recvhopopts 9967c478bd9Sstevel@tonic-gate * ipc_ipv6_recvdstopts conn_ipv6_recvdstopts 9977c478bd9Sstevel@tonic-gate * 9987c478bd9Sstevel@tonic-gate * ipc_ipv6_recvrthdr conn_ipv6_recvrthdr 9997c478bd9Sstevel@tonic-gate * ipc_ipv6_recvrtdstopts conn_ipv6_recvrtdstopts 10007c478bd9Sstevel@tonic-gate * ipc_fully_bound conn_fully_bound 10017c478bd9Sstevel@tonic-gate * 10027c478bd9Sstevel@tonic-gate * ipc_recvif conn_recvif 10037c478bd9Sstevel@tonic-gate * 10047c478bd9Sstevel@tonic-gate * ipc_recvslla conn_recvslla 10057c478bd9Sstevel@tonic-gate * ipc_acking_unbind conn_acking_unbind 10067c478bd9Sstevel@tonic-gate * ipc_pad_to_bit_31 conn_pad_to_bit_31 10077c478bd9Sstevel@tonic-gate * 10087c478bd9Sstevel@tonic-gate * ipc_proto conn_proto 10097c478bd9Sstevel@tonic-gate * ipc_incoming_ill conn_incoming_ill 10107c478bd9Sstevel@tonic-gate * ipc_pending_ill conn_pending_ill 10117c478bd9Sstevel@tonic-gate * ipc_unbind_mp conn_unbind_mp 10127c478bd9Sstevel@tonic-gate * ipc_ilg conn_ilg 10137c478bd9Sstevel@tonic-gate * ipc_ilg_allocated conn_ilg_allocated 10147c478bd9Sstevel@tonic-gate * ipc_ilg_inuse conn_ilg_inuse 10157c478bd9Sstevel@tonic-gate * ipc_ilg_walker_cnt conn_ilg_walker_cnt 10167c478bd9Sstevel@tonic-gate * ipc_refcv conn_refcv 10177c478bd9Sstevel@tonic-gate * ipc_multicast_ipif conn_multicast_ipif 10187c478bd9Sstevel@tonic-gate * ipc_multicast_ill conn_multicast_ill 10197c478bd9Sstevel@tonic-gate * ipc_drain_next conn_drain_next 10207c478bd9Sstevel@tonic-gate * ipc_drain_prev conn_drain_prev 10217c478bd9Sstevel@tonic-gate * ipc_idl conn_idl 10227c478bd9Sstevel@tonic-gate */ 10237c478bd9Sstevel@tonic-gate 10247c478bd9Sstevel@tonic-gate /* 10257924222fSmeem * This is used to match an inbound/outbound datagram with policy. 10267c478bd9Sstevel@tonic-gate */ 10277c478bd9Sstevel@tonic-gate typedef struct ipsec_selector { 10287c478bd9Sstevel@tonic-gate in6_addr_t ips_local_addr_v6; 10297c478bd9Sstevel@tonic-gate in6_addr_t ips_remote_addr_v6; 10307c478bd9Sstevel@tonic-gate uint16_t ips_local_port; 10317c478bd9Sstevel@tonic-gate uint16_t ips_remote_port; 10327c478bd9Sstevel@tonic-gate uint8_t ips_icmp_type; 10337c478bd9Sstevel@tonic-gate uint8_t ips_icmp_code; 10347c478bd9Sstevel@tonic-gate uint8_t ips_protocol; 10357c478bd9Sstevel@tonic-gate uint8_t ips_isv4 : 1, 10367c478bd9Sstevel@tonic-gate ips_is_icmp_inv_acq: 1; 10377c478bd9Sstevel@tonic-gate } ipsec_selector_t; 10387c478bd9Sstevel@tonic-gate 10397c478bd9Sstevel@tonic-gate /* 10407c478bd9Sstevel@tonic-gate * Note that we put v4 addresses in the *first* 32-bit word of the 10417c478bd9Sstevel@tonic-gate * selector rather than the last to simplify the prefix match/mask code 10427c478bd9Sstevel@tonic-gate * in spd.c 10437c478bd9Sstevel@tonic-gate */ 10447c478bd9Sstevel@tonic-gate #define ips_local_addr_v4 ips_local_addr_v6.s6_addr32[0] 10457c478bd9Sstevel@tonic-gate #define ips_remote_addr_v4 ips_remote_addr_v6.s6_addr32[0] 10467c478bd9Sstevel@tonic-gate 10477c478bd9Sstevel@tonic-gate /* Values used in IP by IPSEC Code */ 10487c478bd9Sstevel@tonic-gate #define IPSEC_OUTBOUND B_TRUE 10497c478bd9Sstevel@tonic-gate #define IPSEC_INBOUND B_FALSE 10507c478bd9Sstevel@tonic-gate 10517c478bd9Sstevel@tonic-gate /* 10527c478bd9Sstevel@tonic-gate * There are two variants in policy failures. The packet may come in 10537c478bd9Sstevel@tonic-gate * secure when not needed (IPSEC_POLICY_???_NOT_NEEDED) or it may not 10547c478bd9Sstevel@tonic-gate * have the desired level of protection (IPSEC_POLICY_MISMATCH). 10557c478bd9Sstevel@tonic-gate */ 10567c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_NOT_NEEDED 0 10577c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_MISMATCH 1 10587c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_AUTH_NOT_NEEDED 2 10597c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_ENCR_NOT_NEEDED 3 10607c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_SE_NOT_NEEDED 4 10617c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_MAX 5 /* Always max + 1. */ 10627c478bd9Sstevel@tonic-gate 10637c478bd9Sstevel@tonic-gate /* 10647c478bd9Sstevel@tonic-gate * Folowing macro is used whenever the code does not know whether there 10657c478bd9Sstevel@tonic-gate * is a M_CTL present in the front and it needs to examine the actual mp 10667c478bd9Sstevel@tonic-gate * i.e the IP header. As a M_CTL message could be in the front, this 10677c478bd9Sstevel@tonic-gate * extracts the packet into mp and the M_CTL mp into first_mp. If M_CTL 10687c478bd9Sstevel@tonic-gate * mp is not present, both first_mp and mp point to the same message. 10697c478bd9Sstevel@tonic-gate */ 10707c478bd9Sstevel@tonic-gate #define EXTRACT_PKT_MP(mp, first_mp, mctl_present) \ 10717c478bd9Sstevel@tonic-gate (first_mp) = (mp); \ 10727c478bd9Sstevel@tonic-gate if ((mp)->b_datap->db_type == M_CTL) { \ 10737c478bd9Sstevel@tonic-gate (mp) = (mp)->b_cont; \ 10747c478bd9Sstevel@tonic-gate (mctl_present) = B_TRUE; \ 10757c478bd9Sstevel@tonic-gate } else { \ 10767c478bd9Sstevel@tonic-gate (mctl_present) = B_FALSE; \ 10777c478bd9Sstevel@tonic-gate } 10787c478bd9Sstevel@tonic-gate 10797c478bd9Sstevel@tonic-gate /* 10807c478bd9Sstevel@tonic-gate * Check with IPSEC inbound policy if 10817c478bd9Sstevel@tonic-gate * 10827c478bd9Sstevel@tonic-gate * 1) per-socket policy is present - indicated by conn_in_enforce_policy. 10837c478bd9Sstevel@tonic-gate * 2) Or if we have not cached policy on the conn and the global policy is 10847c478bd9Sstevel@tonic-gate * non-empty. 10857c478bd9Sstevel@tonic-gate */ 1086f4b3ec61Sdh155122 #define CONN_INBOUND_POLICY_PRESENT(connp, ipss) \ 10877c478bd9Sstevel@tonic-gate ((connp)->conn_in_enforce_policy || \ 10887c478bd9Sstevel@tonic-gate (!((connp)->conn_policy_cached) && \ 1089f4b3ec61Sdh155122 (ipss)->ipsec_inbound_v4_policy_present)) 10907c478bd9Sstevel@tonic-gate 1091f4b3ec61Sdh155122 #define CONN_INBOUND_POLICY_PRESENT_V6(connp, ipss) \ 10927c478bd9Sstevel@tonic-gate ((connp)->conn_in_enforce_policy || \ 10937c478bd9Sstevel@tonic-gate (!(connp)->conn_policy_cached && \ 1094f4b3ec61Sdh155122 (ipss)->ipsec_inbound_v6_policy_present)) 10957c478bd9Sstevel@tonic-gate 1096f4b3ec61Sdh155122 #define CONN_OUTBOUND_POLICY_PRESENT(connp, ipss) \ 10977c478bd9Sstevel@tonic-gate ((connp)->conn_out_enforce_policy || \ 10987c478bd9Sstevel@tonic-gate (!((connp)->conn_policy_cached) && \ 1099f4b3ec61Sdh155122 (ipss)->ipsec_outbound_v4_policy_present)) 11007c478bd9Sstevel@tonic-gate 1101f4b3ec61Sdh155122 #define CONN_OUTBOUND_POLICY_PRESENT_V6(connp, ipss) \ 11027c478bd9Sstevel@tonic-gate ((connp)->conn_out_enforce_policy || \ 11037c478bd9Sstevel@tonic-gate (!(connp)->conn_policy_cached && \ 1104f4b3ec61Sdh155122 (ipss)->ipsec_outbound_v6_policy_present)) 11057c478bd9Sstevel@tonic-gate 11067c478bd9Sstevel@tonic-gate /* 11077c478bd9Sstevel@tonic-gate * Information cached in IRE for upper layer protocol (ULP). 11087c478bd9Sstevel@tonic-gate * 11097c478bd9Sstevel@tonic-gate * Notice that ire_max_frag is not included in the iulp_t structure, which 11107c478bd9Sstevel@tonic-gate * it may seem that it should. But ire_max_frag cannot really be cached. It 11117c478bd9Sstevel@tonic-gate * is fixed for each interface. For MTU found by PMTUd, we may want to cache 11127c478bd9Sstevel@tonic-gate * it. But currently, we do not do that. 11137c478bd9Sstevel@tonic-gate */ 11147c478bd9Sstevel@tonic-gate typedef struct iulp_s { 11157c478bd9Sstevel@tonic-gate boolean_t iulp_set; /* Is any metric set? */ 11167c478bd9Sstevel@tonic-gate uint32_t iulp_ssthresh; /* Slow start threshold (TCP). */ 11177c478bd9Sstevel@tonic-gate clock_t iulp_rtt; /* Guestimate in millisecs. */ 11187c478bd9Sstevel@tonic-gate clock_t iulp_rtt_sd; /* Cached value of RTT variance. */ 11197c478bd9Sstevel@tonic-gate uint32_t iulp_spipe; /* Send pipe size. */ 11207c478bd9Sstevel@tonic-gate uint32_t iulp_rpipe; /* Receive pipe size. */ 11217c478bd9Sstevel@tonic-gate uint32_t iulp_rtomax; /* Max round trip timeout. */ 11227c478bd9Sstevel@tonic-gate uint32_t iulp_sack; /* Use SACK option (TCP)? */ 11237c478bd9Sstevel@tonic-gate uint32_t 11247c478bd9Sstevel@tonic-gate iulp_tstamp_ok : 1, /* Use timestamp option (TCP)? */ 11257c478bd9Sstevel@tonic-gate iulp_wscale_ok : 1, /* Use window scale option (TCP)? */ 11267c478bd9Sstevel@tonic-gate iulp_ecn_ok : 1, /* Enable ECN (for TCP)? */ 11277c478bd9Sstevel@tonic-gate iulp_pmtud_ok : 1, /* Enable PMTUd? */ 11287c478bd9Sstevel@tonic-gate 11297c478bd9Sstevel@tonic-gate iulp_not_used : 28; 11307c478bd9Sstevel@tonic-gate } iulp_t; 11317c478bd9Sstevel@tonic-gate 11327c478bd9Sstevel@tonic-gate /* Zero iulp_t. */ 11337c478bd9Sstevel@tonic-gate extern const iulp_t ire_uinfo_null; 11347c478bd9Sstevel@tonic-gate 11357c478bd9Sstevel@tonic-gate /* 1136ae6aa22aSVenugopal Iyer * The conn drain list structure (idl_t). 11377c478bd9Sstevel@tonic-gate * The list is protected by idl_lock. Each conn_t inserted in the list 11387c478bd9Sstevel@tonic-gate * points back at this idl_t using conn_idl. IP primes the draining of the 11397c478bd9Sstevel@tonic-gate * conns queued in these lists, by qenabling the 1st conn of each list. This 11407c478bd9Sstevel@tonic-gate * occurs when STREAMS backenables ip_wsrv on the IP module. Each conn instance 11417c478bd9Sstevel@tonic-gate * of ip_wsrv successively qenables the next conn in the list. 11427c478bd9Sstevel@tonic-gate * idl_lock protects all other members of idl_t and conn_drain_next 11437c478bd9Sstevel@tonic-gate * and conn_drain_prev of conn_t. The conn_lock protects IPCF_DRAIN_DISABLED 11447c478bd9Sstevel@tonic-gate * flag of the conn_t and conn_idl. 1145ae6aa22aSVenugopal Iyer * 1146ae6aa22aSVenugopal Iyer * The conn drain list, idl_t, itself is part of tx cookie list structure. 1147ae6aa22aSVenugopal Iyer * A tx cookie list points to a blocked Tx ring and contains the list of 1148ae6aa22aSVenugopal Iyer * all conn's that are blocked due to the flow-controlled Tx ring (via 1149ae6aa22aSVenugopal Iyer * the idl drain list). Note that a link can have multiple Tx rings. The 1150ae6aa22aSVenugopal Iyer * drain list will store the conn's blocked due to Tx ring being flow 1151ae6aa22aSVenugopal Iyer * controlled. 11527c478bd9Sstevel@tonic-gate */ 1153ae6aa22aSVenugopal Iyer 1154ae6aa22aSVenugopal Iyer typedef uintptr_t ip_mac_tx_cookie_t; 1155ae6aa22aSVenugopal Iyer typedef struct idl_s idl_t; 1156ae6aa22aSVenugopal Iyer typedef struct idl_tx_list_s idl_tx_list_t; 1157ae6aa22aSVenugopal Iyer 1158ae6aa22aSVenugopal Iyer struct idl_tx_list_s { 1159ae6aa22aSVenugopal Iyer ip_mac_tx_cookie_t txl_cookie; 1160ae6aa22aSVenugopal Iyer kmutex_t txl_lock; /* Lock for this list */ 1161ae6aa22aSVenugopal Iyer idl_t *txl_drain_list; 1162ae6aa22aSVenugopal Iyer int txl_drain_index; 1163ae6aa22aSVenugopal Iyer }; 1164ae6aa22aSVenugopal Iyer 1165ae6aa22aSVenugopal Iyer struct idl_s { 11667c478bd9Sstevel@tonic-gate conn_t *idl_conn; /* Head of drain list */ 11677c478bd9Sstevel@tonic-gate kmutex_t idl_lock; /* Lock for this list */ 11687c478bd9Sstevel@tonic-gate conn_t *idl_conn_draining; /* conn that is draining */ 11697c478bd9Sstevel@tonic-gate uint32_t 11707c478bd9Sstevel@tonic-gate idl_repeat : 1, /* Last conn must re-enable */ 11717c478bd9Sstevel@tonic-gate /* drain list again */ 11727c478bd9Sstevel@tonic-gate idl_unused : 31; 1173ae6aa22aSVenugopal Iyer idl_tx_list_t *idl_itl; 1174ae6aa22aSVenugopal Iyer }; 11757c478bd9Sstevel@tonic-gate 11767c478bd9Sstevel@tonic-gate #define CONN_DRAIN_LIST_LOCK(connp) (&((connp)->conn_idl->idl_lock)) 11777c478bd9Sstevel@tonic-gate /* 11787c478bd9Sstevel@tonic-gate * Interface route structure which holds the necessary information to recreate 11797c478bd9Sstevel@tonic-gate * routes that are tied to an interface (namely where ire_ipif != NULL). 11807c478bd9Sstevel@tonic-gate * These routes which were initially created via a routing socket or via the 11817c478bd9Sstevel@tonic-gate * SIOCADDRT ioctl may be gateway routes (RTF_GATEWAY being set) or may be 11827c478bd9Sstevel@tonic-gate * traditional interface routes. When an interface comes back up after being 11837c478bd9Sstevel@tonic-gate * marked down, this information will be used to recreate the routes. These 11847c478bd9Sstevel@tonic-gate * are part of an mblk_t chain that hangs off of the IPIF (ipif_saved_ire_mp). 11857c478bd9Sstevel@tonic-gate */ 11867c478bd9Sstevel@tonic-gate typedef struct ifrt_s { 11877c478bd9Sstevel@tonic-gate ushort_t ifrt_type; /* Type of IRE */ 11887c478bd9Sstevel@tonic-gate in6_addr_t ifrt_v6addr; /* Address IRE represents. */ 11897c478bd9Sstevel@tonic-gate in6_addr_t ifrt_v6gateway_addr; /* Gateway if IRE_OFFSUBNET */ 11907c478bd9Sstevel@tonic-gate in6_addr_t ifrt_v6src_addr; /* Src addr if RTF_SETSRC */ 11917c478bd9Sstevel@tonic-gate in6_addr_t ifrt_v6mask; /* Mask for matching IRE. */ 11927c478bd9Sstevel@tonic-gate uint32_t ifrt_flags; /* flags related to route */ 11937c478bd9Sstevel@tonic-gate uint_t ifrt_max_frag; /* MTU (next hop or path). */ 11947c478bd9Sstevel@tonic-gate iulp_t ifrt_iulp_info; /* Cached IRE ULP info. */ 11957c478bd9Sstevel@tonic-gate } ifrt_t; 11967c478bd9Sstevel@tonic-gate 11977c478bd9Sstevel@tonic-gate #define ifrt_addr V4_PART_OF_V6(ifrt_v6addr) 11987c478bd9Sstevel@tonic-gate #define ifrt_gateway_addr V4_PART_OF_V6(ifrt_v6gateway_addr) 11997c478bd9Sstevel@tonic-gate #define ifrt_src_addr V4_PART_OF_V6(ifrt_v6src_addr) 12007c478bd9Sstevel@tonic-gate #define ifrt_mask V4_PART_OF_V6(ifrt_v6mask) 12017c478bd9Sstevel@tonic-gate 12027c478bd9Sstevel@tonic-gate /* Number of IP addresses that can be hosted on a physical interface */ 12037c478bd9Sstevel@tonic-gate #define MAX_ADDRS_PER_IF 8192 12047c478bd9Sstevel@tonic-gate /* 12057c478bd9Sstevel@tonic-gate * Number of Source addresses to be considered for source address 12067c478bd9Sstevel@tonic-gate * selection. Used by ipif_select_source[_v6]. 12077c478bd9Sstevel@tonic-gate */ 12087c478bd9Sstevel@tonic-gate #define MAX_IPIF_SELECT_SOURCE 50 12097c478bd9Sstevel@tonic-gate 12107c478bd9Sstevel@tonic-gate #ifdef IP_DEBUG 12117c478bd9Sstevel@tonic-gate /* 12127924222fSmeem * Trace refholds and refreles for debugging. 12137c478bd9Sstevel@tonic-gate */ 12146a8288c7Scarlsonj #define TR_STACK_DEPTH 14 12157c478bd9Sstevel@tonic-gate typedef struct tr_buf_s { 12167c478bd9Sstevel@tonic-gate int tr_depth; 12176a8288c7Scarlsonj clock_t tr_time; 12186a8288c7Scarlsonj pc_t tr_stack[TR_STACK_DEPTH]; 12197c478bd9Sstevel@tonic-gate } tr_buf_t; 12207c478bd9Sstevel@tonic-gate 12217c478bd9Sstevel@tonic-gate typedef struct th_trace_s { 12227c478bd9Sstevel@tonic-gate int th_refcnt; 12237c478bd9Sstevel@tonic-gate uint_t th_trace_lastref; 12246a8288c7Scarlsonj kthread_t *th_id; 12257c478bd9Sstevel@tonic-gate #define TR_BUF_MAX 38 12267c478bd9Sstevel@tonic-gate tr_buf_t th_trbuf[TR_BUF_MAX]; 12277c478bd9Sstevel@tonic-gate } th_trace_t; 12286a8288c7Scarlsonj 12296a8288c7Scarlsonj typedef struct th_hash_s { 12306a8288c7Scarlsonj list_node_t thh_link; 12316a8288c7Scarlsonj mod_hash_t *thh_hash; 12326a8288c7Scarlsonj ip_stack_t *thh_ipst; 12336a8288c7Scarlsonj } th_hash_t; 12347c478bd9Sstevel@tonic-gate #endif 12357c478bd9Sstevel@tonic-gate 12367c478bd9Sstevel@tonic-gate /* The following are ipif_state_flags */ 12377c478bd9Sstevel@tonic-gate #define IPIF_CONDEMNED 0x1 /* The ipif is being removed */ 12387c478bd9Sstevel@tonic-gate #define IPIF_CHANGING 0x2 /* A critcal ipif field is changing */ 12397c478bd9Sstevel@tonic-gate #define IPIF_SET_LINKLOCAL 0x10 /* transient flag during bringup */ 12407c478bd9Sstevel@tonic-gate #define IPIF_ZERO_SOURCE 0x20 /* transient flag during bringup */ 12417c478bd9Sstevel@tonic-gate 12427c478bd9Sstevel@tonic-gate /* IP interface structure, one per local address */ 12437c478bd9Sstevel@tonic-gate typedef struct ipif_s { 12447c478bd9Sstevel@tonic-gate struct ipif_s *ipif_next; 12457c478bd9Sstevel@tonic-gate struct ill_s *ipif_ill; /* Back pointer to our ill */ 12467c478bd9Sstevel@tonic-gate int ipif_id; /* Logical unit number */ 12477c478bd9Sstevel@tonic-gate uint_t ipif_mtu; /* Starts at ipif_ill->ill_max_frag */ 12487c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6lcl_addr; /* Local IP address for this if. */ 12497c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6src_addr; /* Source IP address for this if. */ 12507c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6subnet; /* Subnet prefix for this if. */ 12517c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6net_mask; /* Net mask for this interface. */ 12527c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6brd_addr; /* Broadcast addr for this interface. */ 12537c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6pp_dst_addr; /* Point-to-point dest address. */ 12547c478bd9Sstevel@tonic-gate uint64_t ipif_flags; /* Interface flags. */ 12557c478bd9Sstevel@tonic-gate uint_t ipif_metric; /* BSD if metric, for compatibility. */ 12567c478bd9Sstevel@tonic-gate uint_t ipif_ire_type; /* IRE_LOCAL or IRE_LOOPBACK */ 12577c478bd9Sstevel@tonic-gate mblk_t *ipif_arp_del_mp; /* Allocated at time arp comes up, to */ 12587c478bd9Sstevel@tonic-gate /* prevent awkward out of mem */ 12597c478bd9Sstevel@tonic-gate /* condition later */ 12607c478bd9Sstevel@tonic-gate mblk_t *ipif_saved_ire_mp; /* Allocated for each extra */ 12617c478bd9Sstevel@tonic-gate /* IRE_IF_NORESOLVER/IRE_IF_RESOLVER */ 12627c478bd9Sstevel@tonic-gate /* on this interface so that they */ 12637c478bd9Sstevel@tonic-gate /* can survive ifconfig down. */ 12647c478bd9Sstevel@tonic-gate kmutex_t ipif_saved_ire_lock; /* Protects ipif_saved_ire_mp */ 12657c478bd9Sstevel@tonic-gate 12667c478bd9Sstevel@tonic-gate mrec_t *ipif_igmp_rpt; /* List of group memberships which */ 12677c478bd9Sstevel@tonic-gate /* will be reported on. Used when */ 12687c478bd9Sstevel@tonic-gate /* handling an igmp timeout. */ 12697c478bd9Sstevel@tonic-gate 12707c478bd9Sstevel@tonic-gate /* 12717c478bd9Sstevel@tonic-gate * The packet counts in the ipif contain the sum of the 12727c478bd9Sstevel@tonic-gate * packet counts in dead IREs that were affiliated with 12737c478bd9Sstevel@tonic-gate * this ipif. 12747c478bd9Sstevel@tonic-gate */ 12757c478bd9Sstevel@tonic-gate uint_t ipif_fo_pkt_count; /* Forwarded thru our dead IREs */ 12767c478bd9Sstevel@tonic-gate uint_t ipif_ib_pkt_count; /* Inbound packets for our dead IREs */ 12777c478bd9Sstevel@tonic-gate uint_t ipif_ob_pkt_count; /* Outbound packets to our dead IREs */ 12787c478bd9Sstevel@tonic-gate /* Exclusive bit fields, protected by ipsq_t */ 12797c478bd9Sstevel@tonic-gate unsigned int 1280e11c3f44Smeem ipif_multicast_up : 1, /* ipif_multicast_up() successful */ 12817c478bd9Sstevel@tonic-gate ipif_was_up : 1, /* ipif was up before */ 128269bb4bb4Scarlsonj ipif_addr_ready : 1, /* DAD is done */ 128369bb4bb4Scarlsonj ipif_was_dup : 1, /* DAD had failed */ 1284e11c3f44Smeem 1285e11c3f44Smeem ipif_joined_allhosts : 1, /* allhosts joined */ 12869294ad19SSowmini Varadhan ipif_added_nce : 1, /* nce added for local address */ 12879294ad19SSowmini Varadhan ipif_pad_to_31 : 26; 12887c478bd9Sstevel@tonic-gate 12897c478bd9Sstevel@tonic-gate uint_t ipif_seqid; /* unique index across all ills */ 12907c478bd9Sstevel@tonic-gate uint_t ipif_state_flags; /* See IPIF_* flag defs above */ 12917c478bd9Sstevel@tonic-gate uint_t ipif_refcnt; /* active consistent reader cnt */ 1292968d2fd1Ssowmini 1293384ad179Ssowmini /* Number of ire's and ilm's referencing this ipif */ 1294384ad179Ssowmini uint_t ipif_ire_cnt; 1295384ad179Ssowmini uint_t ipif_ilm_cnt; 1296968d2fd1Ssowmini 12977c478bd9Sstevel@tonic-gate uint_t ipif_saved_ire_cnt; 1298968d2fd1Ssowmini zoneid_t ipif_zoneid; /* zone ID number */ 129969bb4bb4Scarlsonj timeout_id_t ipif_recovery_id; /* Timer for DAD recovery */ 13007c478bd9Sstevel@tonic-gate boolean_t ipif_trace_disable; /* True when alloc fails */ 1301e11c3f44Smeem /* 1302e11c3f44Smeem * For an IPMP interface, ipif_bound_ill tracks the ill whose hardware 1303e11c3f44Smeem * information this ipif is associated with via ARP/NDP. We can use 1304e11c3f44Smeem * an ill pointer (rather than an index) because only ills that are 1305e11c3f44Smeem * part of a group will be pointed to, and an ill cannot disappear 1306e11c3f44Smeem * while it's in a group. 1307e11c3f44Smeem */ 1308e11c3f44Smeem struct ill_s *ipif_bound_ill; 1309e11c3f44Smeem struct ipif_s *ipif_bound_next; /* bound ipif chain */ 1310e11c3f44Smeem boolean_t ipif_bound; /* B_TRUE if we successfully bound */ 13117c478bd9Sstevel@tonic-gate } ipif_t; 13127c478bd9Sstevel@tonic-gate 13137c478bd9Sstevel@tonic-gate /* 1314968d2fd1Ssowmini * IPIF_FREE_OK() means that there are no incoming references 1315968d2fd1Ssowmini * to the ipif. Incoming refs would prevent the ipif from being freed. 1316968d2fd1Ssowmini */ 1317968d2fd1Ssowmini #define IPIF_FREE_OK(ipif) \ 1318384ad179Ssowmini ((ipif)->ipif_ire_cnt == 0 && (ipif)->ipif_ilm_cnt == 0) 1319968d2fd1Ssowmini /* 1320968d2fd1Ssowmini * IPIF_DOWN_OK() determines whether the incoming pointer reference counts 1321968d2fd1Ssowmini * would permit the ipif to be considered quiescent. In order for 1322968d2fd1Ssowmini * an ipif or ill to be considered quiescent, the ire and nce references 1323968d2fd1Ssowmini * to that ipif/ill must be zero. 1324968d2fd1Ssowmini * 1325968d2fd1Ssowmini * We do not require the ilm references to go to zero for quiescence 1326968d2fd1Ssowmini * because the quiescence checks are done to ensure that 1327968d2fd1Ssowmini * outgoing packets do not use addresses from the ipif/ill after it 1328968d2fd1Ssowmini * has been marked down, and incoming packets to addresses on a 1329968d2fd1Ssowmini * queiscent interface are rejected. This implies that all the 1330968d2fd1Ssowmini * ire/nce's using that source address need to be deleted and future 1331968d2fd1Ssowmini * creation of any ires using that source address must be prevented. 1332968d2fd1Ssowmini * Similarly incoming unicast packets destined to the 'down' address 1333968d2fd1Ssowmini * will not be accepted once that ire is gone. However incoming 1334968d2fd1Ssowmini * multicast packets are not destined to the downed address. 1335968d2fd1Ssowmini * They are only related to the ill in question. Furthermore 1336968d2fd1Ssowmini * the current API behavior allows applications to join or leave 1337968d2fd1Ssowmini * multicast groups, i.e., IP_ADD_MEMBERSHIP / LEAVE_MEMBERSHIP, using a 1338968d2fd1Ssowmini * down address. Therefore the ilm references are not included in 1339968d2fd1Ssowmini * the _DOWN_OK macros. 1340968d2fd1Ssowmini */ 1341384ad179Ssowmini #define IPIF_DOWN_OK(ipif) ((ipif)->ipif_ire_cnt == 0) 1342968d2fd1Ssowmini 1343968d2fd1Ssowmini /* 13447c478bd9Sstevel@tonic-gate * The following table lists the protection levels of the various members 13457c478bd9Sstevel@tonic-gate * of the ipif_t. The following notation is used. 13467c478bd9Sstevel@tonic-gate * 13477c478bd9Sstevel@tonic-gate * Write once - Written to only once at the time of bringing up 13487c478bd9Sstevel@tonic-gate * the interface and can be safely read after the bringup without any lock. 13497c478bd9Sstevel@tonic-gate * 13507c478bd9Sstevel@tonic-gate * ipsq - Need to execute in the ipsq to perform the indicated access. 13517c478bd9Sstevel@tonic-gate * 13527c478bd9Sstevel@tonic-gate * ill_lock - Need to hold this mutex to perform the indicated access. 13537c478bd9Sstevel@tonic-gate * 13547c478bd9Sstevel@tonic-gate * ill_g_lock - Need to hold this rw lock as reader/writer for read access or 13557c478bd9Sstevel@tonic-gate * write access respectively. 13567c478bd9Sstevel@tonic-gate * 13577c478bd9Sstevel@tonic-gate * down ill - Written to only when the ill is down (i.e all ipifs are down) 13587c478bd9Sstevel@tonic-gate * up ill - Read only when the ill is up (i.e. at least 1 ipif is up) 13597c478bd9Sstevel@tonic-gate * 13607c478bd9Sstevel@tonic-gate * Table of ipif_t members and their protection 13617c478bd9Sstevel@tonic-gate * 13628df01f76Smeem * ipif_next ipsq + ill_lock + ipsq OR ill_lock OR 13638df01f76Smeem * ill_g_lock ill_g_lock 13647c478bd9Sstevel@tonic-gate * ipif_ill ipsq + down ipif write once 13657c478bd9Sstevel@tonic-gate * ipif_id ipsq + down ipif write once 13667c478bd9Sstevel@tonic-gate * ipif_mtu ipsq 13677c478bd9Sstevel@tonic-gate * ipif_v6lcl_addr ipsq + down ipif up ipif 13687c478bd9Sstevel@tonic-gate * ipif_v6src_addr ipsq + down ipif up ipif 13697c478bd9Sstevel@tonic-gate * ipif_v6subnet ipsq + down ipif up ipif 13707c478bd9Sstevel@tonic-gate * ipif_v6net_mask ipsq + down ipif up ipif 13717c478bd9Sstevel@tonic-gate * 13727c478bd9Sstevel@tonic-gate * ipif_v6brd_addr 13737c478bd9Sstevel@tonic-gate * ipif_v6pp_dst_addr 13747c478bd9Sstevel@tonic-gate * ipif_flags ill_lock ill_lock 13757c478bd9Sstevel@tonic-gate * ipif_metric 13767c478bd9Sstevel@tonic-gate * ipif_ire_type ipsq + down ill up ill 13777c478bd9Sstevel@tonic-gate * 13787c478bd9Sstevel@tonic-gate * ipif_arp_del_mp ipsq ipsq 13797c478bd9Sstevel@tonic-gate * ipif_saved_ire_mp ipif_saved_ire_lock ipif_saved_ire_lock 13807c478bd9Sstevel@tonic-gate * ipif_igmp_rpt ipsq ipsq 13817c478bd9Sstevel@tonic-gate * 13827c478bd9Sstevel@tonic-gate * ipif_fo_pkt_count Approx 13837c478bd9Sstevel@tonic-gate * ipif_ib_pkt_count Approx 13847c478bd9Sstevel@tonic-gate * ipif_ob_pkt_count Approx 13857c478bd9Sstevel@tonic-gate * 13867c478bd9Sstevel@tonic-gate * bit fields ill_lock ill_lock 13877c478bd9Sstevel@tonic-gate * 13887c478bd9Sstevel@tonic-gate * ipif_seqid ipsq Write once 13897c478bd9Sstevel@tonic-gate * 13907c478bd9Sstevel@tonic-gate * ipif_state_flags ill_lock ill_lock 13917c478bd9Sstevel@tonic-gate * ipif_refcnt ill_lock ill_lock 1392384ad179Ssowmini * ipif_ire_cnt ill_lock ill_lock 1393384ad179Ssowmini * ipif_ilm_cnt ill_lock ill_lock 13947c478bd9Sstevel@tonic-gate * ipif_saved_ire_cnt 1395e11c3f44Smeem * 1396e11c3f44Smeem * ipif_bound_ill ipsq + ipmp_lock ipsq OR ipmp_lock 1397e11c3f44Smeem * ipif_bound_next ipsq ipsq 1398e11c3f44Smeem * ipif_bound ipsq ipsq 13997c478bd9Sstevel@tonic-gate */ 14007c478bd9Sstevel@tonic-gate 14017c478bd9Sstevel@tonic-gate #define IP_TR_HASH(tid) ((((uintptr_t)tid) >> 6) & (IP_TR_HASH_MAX - 1)) 14027c478bd9Sstevel@tonic-gate 14036a8288c7Scarlsonj #ifdef DEBUG 14047c478bd9Sstevel@tonic-gate #define IPIF_TRACE_REF(ipif) ipif_trace_ref(ipif) 14057c478bd9Sstevel@tonic-gate #define ILL_TRACE_REF(ill) ill_trace_ref(ill) 14067c478bd9Sstevel@tonic-gate #define IPIF_UNTRACE_REF(ipif) ipif_untrace_ref(ipif) 14077c478bd9Sstevel@tonic-gate #define ILL_UNTRACE_REF(ill) ill_untrace_ref(ill) 14087c478bd9Sstevel@tonic-gate #else 14097c478bd9Sstevel@tonic-gate #define IPIF_TRACE_REF(ipif) 14107c478bd9Sstevel@tonic-gate #define ILL_TRACE_REF(ill) 14117c478bd9Sstevel@tonic-gate #define IPIF_UNTRACE_REF(ipif) 14127c478bd9Sstevel@tonic-gate #define ILL_UNTRACE_REF(ill) 14137c478bd9Sstevel@tonic-gate #endif 14147c478bd9Sstevel@tonic-gate 14157924222fSmeem /* IPv4 compatibility macros */ 14167c478bd9Sstevel@tonic-gate #define ipif_lcl_addr V4_PART_OF_V6(ipif_v6lcl_addr) 14177c478bd9Sstevel@tonic-gate #define ipif_src_addr V4_PART_OF_V6(ipif_v6src_addr) 14187c478bd9Sstevel@tonic-gate #define ipif_subnet V4_PART_OF_V6(ipif_v6subnet) 14197c478bd9Sstevel@tonic-gate #define ipif_net_mask V4_PART_OF_V6(ipif_v6net_mask) 14207c478bd9Sstevel@tonic-gate #define ipif_brd_addr V4_PART_OF_V6(ipif_v6brd_addr) 14217c478bd9Sstevel@tonic-gate #define ipif_pp_dst_addr V4_PART_OF_V6(ipif_v6pp_dst_addr) 14227c478bd9Sstevel@tonic-gate 14237c478bd9Sstevel@tonic-gate /* Macros for easy backreferences to the ill. */ 14247c478bd9Sstevel@tonic-gate #define ipif_wq ipif_ill->ill_wq 14257c478bd9Sstevel@tonic-gate #define ipif_rq ipif_ill->ill_rq 14267c478bd9Sstevel@tonic-gate #define ipif_net_type ipif_ill->ill_net_type 14277c478bd9Sstevel@tonic-gate #define ipif_ipif_up_count ipif_ill->ill_ipif_up_count 14287c478bd9Sstevel@tonic-gate #define ipif_type ipif_ill->ill_type 14297c478bd9Sstevel@tonic-gate #define ipif_isv6 ipif_ill->ill_isv6 14307c478bd9Sstevel@tonic-gate 14317c478bd9Sstevel@tonic-gate #define SIOCLIFADDR_NDX 112 /* ndx of SIOCLIFADDR in the ndx ioctl table */ 14327c478bd9Sstevel@tonic-gate 14337c478bd9Sstevel@tonic-gate /* 14347c478bd9Sstevel@tonic-gate * mode value for ip_ioctl_finish for finishing an ioctl 14357c478bd9Sstevel@tonic-gate */ 14367c478bd9Sstevel@tonic-gate #define CONN_CLOSE 1 /* No mi_copy */ 14377c478bd9Sstevel@tonic-gate #define COPYOUT 2 /* do an mi_copyout if needed */ 14387c478bd9Sstevel@tonic-gate #define NO_COPYOUT 3 /* do an mi_copy_done */ 1439b051ecf6Smeem #define IPI2MODE(ipi) ((ipi)->ipi_flags & IPI_GET_CMD ? COPYOUT : NO_COPYOUT) 14407c478bd9Sstevel@tonic-gate 14417c478bd9Sstevel@tonic-gate /* 1442e11c3f44Smeem * The IP-MT design revolves around the serialization objects ipsq_t (IPSQ) 1443e11c3f44Smeem * and ipxop_t (exclusive operation or "xop"). Becoming "writer" on an IPSQ 1444e11c3f44Smeem * ensures that no other threads can become "writer" on any IPSQs sharing that 1445e11c3f44Smeem * IPSQ's xop until the writer thread is done. 14467c478bd9Sstevel@tonic-gate * 1447e11c3f44Smeem * Each phyint points to one IPSQ that remains fixed over the phyint's life. 1448e11c3f44Smeem * Each IPSQ points to one xop that can change over the IPSQ's life. If a 1449e11c3f44Smeem * phyint is *not* in an IPMP group, then its IPSQ will refer to the IPSQ's 1450e11c3f44Smeem * "own" xop (ipsq_ownxop). If a phyint *is* part of an IPMP group, then its 1451e11c3f44Smeem * IPSQ will refer to the "group" xop, which is shorthand for the xop of the 1452e11c3f44Smeem * IPSQ of the IPMP meta-interface's phyint. Thus, all phyints that are part 1453e11c3f44Smeem * of the same IPMP group will have their IPSQ's point to the group xop, and 1454e11c3f44Smeem * thus becoming "writer" on any phyint in the group will prevent any other 1455e11c3f44Smeem * writer on any other phyint in the group. All IPSQs sharing the same xop 1456e11c3f44Smeem * are chained together through ipsq_next (in the degenerate common case, 1457e11c3f44Smeem * ipsq_next simply refers to itself). Note that the group xop is guaranteed 1458e11c3f44Smeem * to exist at least as long as there are members in the group, since the IPMP 1459e11c3f44Smeem * meta-interface can only be destroyed if the group is empty. 14607c478bd9Sstevel@tonic-gate * 1461e11c3f44Smeem * Incoming exclusive operation requests are enqueued on the IPSQ they arrived 1462e11c3f44Smeem * on rather than the xop. This makes switching xop's (as would happen when a 1463e11c3f44Smeem * phyint leaves an IPMP group) simple, because after the phyint leaves the 1464e11c3f44Smeem * group, any operations enqueued on its IPSQ can be safely processed with 1465e11c3f44Smeem * respect to its new xop, and any operations enqueued on the IPSQs of its 1466e11c3f44Smeem * former group can be processed with respect to their existing group xop. 1467e11c3f44Smeem * Even so, switching xops is a subtle dance; see ipsq_dq() for details. 14687c478bd9Sstevel@tonic-gate * 1469e11c3f44Smeem * An IPSQ's "own" xop is embedded within the IPSQ itself since they have have 1470e11c3f44Smeem * identical lifetimes, and because doing so simplifies pointer management. 1471e11c3f44Smeem * While each phyint and IPSQ point to each other, it is not possible to free 1472e11c3f44Smeem * the IPSQ when the phyint is freed, since we may still *inside* the IPSQ 1473e11c3f44Smeem * when the phyint is being freed. Thus, ipsq_phyint is set to NULL when the 1474e11c3f44Smeem * phyint is freed, and the IPSQ free is later done in ipsq_exit(). 1475e11c3f44Smeem * 1476e11c3f44Smeem * ipsq_t synchronization: read write 1477e11c3f44Smeem * 1478e11c3f44Smeem * ipsq_xopq_mphead ipx_lock ipx_lock 1479e11c3f44Smeem * ipsq_xopq_mptail ipx_lock ipx_lock 1480e11c3f44Smeem * ipsq_xop_switch_mp ipsq_lock ipsq_lock 1481e11c3f44Smeem * ipsq_phyint write once write once 1482e11c3f44Smeem * ipsq_next RW_READER ill_g_lock RW_WRITER ill_g_lock 1483e11c3f44Smeem * ipsq_xop ipsq_lock or ipsq ipsq_lock + ipsq 1484e11c3f44Smeem * ipsq_swxop ipsq ipsq 1485e11c3f44Smeem * ipsq_ownxop see ipxop_t see ipxop_t 1486e11c3f44Smeem * ipsq_ipst write once write once 1487e11c3f44Smeem * 1488e11c3f44Smeem * ipxop_t synchronization: read write 1489e11c3f44Smeem * 1490e11c3f44Smeem * ipx_writer ipx_lock ipx_lock 1491e11c3f44Smeem * ipx_xop_queued ipx_lock ipx_lock 1492e11c3f44Smeem * ipx_mphead ipx_lock ipx_lock 1493e11c3f44Smeem * ipx_mptail ipx_lock ipx_lock 1494e11c3f44Smeem * ipx_ipsq write once write once 1495e11c3f44Smeem * ips_ipsq_queued ipx_lock ipx_lock 1496e11c3f44Smeem * ipx_waitfor ipsq or ipx_lock ipsq + ipx_lock 1497e11c3f44Smeem * ipx_reentry_cnt ipsq or ipx_lock ipsq + ipx_lock 1498e11c3f44Smeem * ipx_current_done ipsq ipsq 1499e11c3f44Smeem * ipx_current_ioctl ipsq ipsq 1500e11c3f44Smeem * ipx_current_ipif ipsq or ipx_lock ipsq + ipx_lock 1501e11c3f44Smeem * ipx_pending_ipif ipsq or ipx_lock ipsq + ipx_lock 1502e11c3f44Smeem * ipx_pending_mp ipsq or ipx_lock ipsq + ipx_lock 1503e11c3f44Smeem * ipx_forced ipsq ipsq 1504e11c3f44Smeem * ipx_depth ipsq ipsq 1505e11c3f44Smeem * ipx_stack ipsq ipsq 15067c478bd9Sstevel@tonic-gate */ 1507e11c3f44Smeem typedef struct ipxop_s { 1508e11c3f44Smeem kmutex_t ipx_lock; /* see above */ 1509e11c3f44Smeem kthread_t *ipx_writer; /* current owner */ 1510e11c3f44Smeem mblk_t *ipx_mphead; /* messages tied to this op */ 1511e11c3f44Smeem mblk_t *ipx_mptail; 1512e11c3f44Smeem struct ipsq_s *ipx_ipsq; /* associated ipsq */ 1513e11c3f44Smeem boolean_t ipx_ipsq_queued; /* ipsq using xop has queued op */ 1514e11c3f44Smeem int ipx_waitfor; /* waiting; values encoded below */ 1515e11c3f44Smeem int ipx_reentry_cnt; 1516e11c3f44Smeem boolean_t ipx_current_done; /* is the current operation done? */ 1517e11c3f44Smeem int ipx_current_ioctl; /* current ioctl, or 0 if no ioctl */ 1518e11c3f44Smeem ipif_t *ipx_current_ipif; /* ipif for current op */ 1519e11c3f44Smeem ipif_t *ipx_pending_ipif; /* ipif for ipsq_pending_mp */ 1520e11c3f44Smeem mblk_t *ipx_pending_mp; /* current ioctl mp while waiting */ 1521e11c3f44Smeem boolean_t ipx_forced; /* debugging aid */ 15226a8288c7Scarlsonj #ifdef DEBUG 1523e11c3f44Smeem int ipx_depth; /* debugging aid */ 1524e11c3f44Smeem #define IPX_STACK_DEPTH 15 1525e11c3f44Smeem pc_t ipx_stack[IPX_STACK_DEPTH]; /* debugging aid */ 15266a8288c7Scarlsonj #endif 1527e11c3f44Smeem } ipxop_t; 1528e11c3f44Smeem 1529e11c3f44Smeem typedef struct ipsq_s { 1530e11c3f44Smeem kmutex_t ipsq_lock; /* see above */ 1531e11c3f44Smeem mblk_t *ipsq_switch_mp; /* op to handle right after switch */ 1532e11c3f44Smeem mblk_t *ipsq_xopq_mphead; /* list of excl ops (mostly ioctls) */ 1533e11c3f44Smeem mblk_t *ipsq_xopq_mptail; 1534e11c3f44Smeem struct phyint *ipsq_phyint; /* associated phyint */ 1535e11c3f44Smeem struct ipsq_s *ipsq_next; /* next ipsq sharing ipsq_xop */ 1536e11c3f44Smeem struct ipxop_s *ipsq_xop; /* current xop synchronization info */ 1537e11c3f44Smeem struct ipxop_s *ipsq_swxop; /* switch xop to on ipsq_exit() */ 1538e11c3f44Smeem struct ipxop_s ipsq_ownxop; /* our own xop (may not be in-use) */ 1539e11c3f44Smeem ip_stack_t *ipsq_ipst; /* does not have a netstack_hold */ 15407c478bd9Sstevel@tonic-gate } ipsq_t; 15417c478bd9Sstevel@tonic-gate 1542e11c3f44Smeem /* 1543e11c3f44Smeem * ipx_waitfor values: 1544e11c3f44Smeem */ 1545e11c3f44Smeem enum { 1546e11c3f44Smeem IPIF_DOWN = 1, /* ipif_down() waiting for refcnts to drop */ 1547e11c3f44Smeem ILL_DOWN, /* ill_down() waiting for refcnts to drop */ 1548e11c3f44Smeem IPIF_FREE, /* ipif_free() waiting for refcnts to drop */ 1549e11c3f44Smeem ILL_FREE /* ill unplumb waiting for refcnts to drop */ 1550e11c3f44Smeem }; 1551e11c3f44Smeem 1552e11c3f44Smeem /* Operation types for ipsq_try_enter() */ 1553e11c3f44Smeem #define CUR_OP 0 /* request writer within current operation */ 1554e11c3f44Smeem #define NEW_OP 1 /* request writer for a new operation */ 1555e11c3f44Smeem #define SWITCH_OP 2 /* request writer once IPSQ XOP switches */ 15567c478bd9Sstevel@tonic-gate 15577c478bd9Sstevel@tonic-gate /* 1558e11c3f44Smeem * Kstats tracked on each IPMP meta-interface. Order here must match 1559e11c3f44Smeem * ipmp_kstats[] in ip/ipmp.c. 15607c478bd9Sstevel@tonic-gate */ 1561e11c3f44Smeem enum { 1562e11c3f44Smeem IPMP_KSTAT_OBYTES, IPMP_KSTAT_OBYTES64, IPMP_KSTAT_RBYTES, 1563e11c3f44Smeem IPMP_KSTAT_RBYTES64, IPMP_KSTAT_OPACKETS, IPMP_KSTAT_OPACKETS64, 1564e11c3f44Smeem IPMP_KSTAT_OERRORS, IPMP_KSTAT_IPACKETS, IPMP_KSTAT_IPACKETS64, 1565e11c3f44Smeem IPMP_KSTAT_IERRORS, IPMP_KSTAT_MULTIRCV, IPMP_KSTAT_MULTIXMT, 1566e11c3f44Smeem IPMP_KSTAT_BRDCSTRCV, IPMP_KSTAT_BRDCSTXMT, IPMP_KSTAT_LINK_UP, 1567e11c3f44Smeem IPMP_KSTAT_MAX /* keep last */ 1568e11c3f44Smeem }; 15697c478bd9Sstevel@tonic-gate 15707c478bd9Sstevel@tonic-gate /* 15717c478bd9Sstevel@tonic-gate * phyint represents state that is common to both IPv4 and IPv6 interfaces. 15727c478bd9Sstevel@tonic-gate * There is a separate ill_t representing IPv4 and IPv6 which has a 15737924222fSmeem * backpointer to the phyint structure for accessing common state. 15747c478bd9Sstevel@tonic-gate */ 15757c478bd9Sstevel@tonic-gate typedef struct phyint { 15767c478bd9Sstevel@tonic-gate struct ill_s *phyint_illv4; 15777c478bd9Sstevel@tonic-gate struct ill_s *phyint_illv6; 1578e11c3f44Smeem uint_t phyint_ifindex; /* SIOCSLIFINDEX */ 15797c478bd9Sstevel@tonic-gate uint64_t phyint_flags; 15807c478bd9Sstevel@tonic-gate avl_node_t phyint_avl_by_index; /* avl tree by index */ 15817c478bd9Sstevel@tonic-gate avl_node_t phyint_avl_by_name; /* avl tree by name */ 15827c478bd9Sstevel@tonic-gate kmutex_t phyint_lock; 15837c478bd9Sstevel@tonic-gate struct ipsq_s *phyint_ipsq; /* back pointer to ipsq */ 1584e11c3f44Smeem struct ipmp_grp_s *phyint_grp; /* associated IPMP group */ 1585e11c3f44Smeem char phyint_name[LIFNAMSIZ]; /* physical interface name */ 1586e11c3f44Smeem uint64_t phyint_kstats0[IPMP_KSTAT_MAX]; /* baseline kstats */ 15877c478bd9Sstevel@tonic-gate } phyint_t; 15887c478bd9Sstevel@tonic-gate 15897c478bd9Sstevel@tonic-gate #define CACHE_ALIGN_SIZE 64 15907c478bd9Sstevel@tonic-gate #define CACHE_ALIGN(align_struct) P2ROUNDUP(sizeof (struct align_struct),\ 15917c478bd9Sstevel@tonic-gate CACHE_ALIGN_SIZE) 15927c478bd9Sstevel@tonic-gate struct _phyint_list_s_ { 15937c478bd9Sstevel@tonic-gate avl_tree_t phyint_list_avl_by_index; /* avl tree by index */ 15947c478bd9Sstevel@tonic-gate avl_tree_t phyint_list_avl_by_name; /* avl tree by name */ 15957c478bd9Sstevel@tonic-gate }; 15967c478bd9Sstevel@tonic-gate 15977c478bd9Sstevel@tonic-gate typedef union phyint_list_u { 15987c478bd9Sstevel@tonic-gate struct _phyint_list_s_ phyint_list_s; 15997c478bd9Sstevel@tonic-gate char phyint_list_filler[CACHE_ALIGN(_phyint_list_s_)]; 16007c478bd9Sstevel@tonic-gate } phyint_list_t; 16017c478bd9Sstevel@tonic-gate 16027c478bd9Sstevel@tonic-gate #define phyint_list_avl_by_index phyint_list_s.phyint_list_avl_by_index 16037c478bd9Sstevel@tonic-gate #define phyint_list_avl_by_name phyint_list_s.phyint_list_avl_by_name 16047c478bd9Sstevel@tonic-gate 16057c478bd9Sstevel@tonic-gate /* 16067c478bd9Sstevel@tonic-gate * Fragmentation hash bucket 16077c478bd9Sstevel@tonic-gate */ 16087c478bd9Sstevel@tonic-gate typedef struct ipfb_s { 16097c478bd9Sstevel@tonic-gate struct ipf_s *ipfb_ipf; /* List of ... */ 16107c478bd9Sstevel@tonic-gate size_t ipfb_count; /* Count of bytes used by frag(s) */ 16117c478bd9Sstevel@tonic-gate kmutex_t ipfb_lock; /* Protect all ipf in list */ 16127c478bd9Sstevel@tonic-gate uint_t ipfb_frag_pkts; /* num of distinct fragmented pkts */ 16137c478bd9Sstevel@tonic-gate } ipfb_t; 16147c478bd9Sstevel@tonic-gate 16157c478bd9Sstevel@tonic-gate /* 16167c478bd9Sstevel@tonic-gate * IRE bucket structure. Usually there is an array of such structures, 16177c478bd9Sstevel@tonic-gate * each pointing to a linked list of ires. irb_refcnt counts the number 16187c478bd9Sstevel@tonic-gate * of walkers of a given hash bucket. Usually the reference count is 16197c478bd9Sstevel@tonic-gate * bumped up if the walker wants no IRES to be DELETED while walking the 16207c478bd9Sstevel@tonic-gate * list. Bumping up does not PREVENT ADDITION. This allows walking a given 16217c478bd9Sstevel@tonic-gate * hash bucket without stumbling up on a free pointer. 1622c793af95Ssangeeta * 1623c793af95Ssangeeta * irb_t structures in ip_ftable are dynamically allocated and freed. 16243173664eSapersson * In order to identify the irb_t structures that can be safely kmem_free'd 1625c793af95Ssangeeta * we need to ensure that 1626c793af95Ssangeeta * - the irb_refcnt is quiescent, indicating no other walkers, 1627c793af95Ssangeeta * - no other threads or ire's are holding references to the irb, 1628c793af95Ssangeeta * i.e., irb_nire == 0, 1629c793af95Ssangeeta * - there are no active ire's in the bucket, i.e., irb_ire_cnt == 0 16307c478bd9Sstevel@tonic-gate */ 16317c478bd9Sstevel@tonic-gate typedef struct irb { 16327c478bd9Sstevel@tonic-gate struct ire_s *irb_ire; /* First ire in this bucket */ 16337c478bd9Sstevel@tonic-gate /* Should be first in this struct */ 16347c478bd9Sstevel@tonic-gate krwlock_t irb_lock; /* Protect this bucket */ 16357c478bd9Sstevel@tonic-gate uint_t irb_refcnt; /* Protected by irb_lock */ 16367c478bd9Sstevel@tonic-gate uchar_t irb_marks; /* CONDEMNED ires in this bucket ? */ 1637c793af95Ssangeeta #define IRB_MARK_CONDEMNED 0x0001 1638c793af95Ssangeeta #define IRB_MARK_FTABLE 0x0002 1639c793af95Ssangeeta uint_t irb_ire_cnt; /* Num of active IRE in this bucket */ 16407c478bd9Sstevel@tonic-gate uint_t irb_tmp_ire_cnt; /* Num of temporary IRE */ 1641c793af95Ssangeeta struct ire_s *irb_rr_origin; /* origin for round-robin */ 1642c793af95Ssangeeta int irb_nire; /* Num of ftable ire's that ref irb */ 1643f4b3ec61Sdh155122 ip_stack_t *irb_ipst; /* Does not have a netstack_hold */ 16447c478bd9Sstevel@tonic-gate } irb_t; 16457c478bd9Sstevel@tonic-gate 1646c793af95Ssangeeta #define IRB2RT(irb) (rt_t *)((caddr_t)(irb) - offsetof(rt_t, rt_irb)) 1647c793af95Ssangeeta 1648c793af95Ssangeeta /* The following are return values of ip_xmit_v4() */ 1649c793af95Ssangeeta typedef enum { 1650c793af95Ssangeeta SEND_PASSED = 0, /* sent packet out on wire */ 1651c793af95Ssangeeta SEND_FAILED, /* sending of packet failed */ 1652c793af95Ssangeeta LOOKUP_IN_PROGRESS, /* ire cache found, ARP resolution in progress */ 1653c793af95Ssangeeta LLHDR_RESLV_FAILED /* macaddr resl of onlink dst or nexthop failed */ 1654c793af95Ssangeeta } ipxmit_state_t; 1655c793af95Ssangeeta 16567c478bd9Sstevel@tonic-gate #define IP_V4_G_HEAD 0 16577c478bd9Sstevel@tonic-gate #define IP_V6_G_HEAD 1 16587c478bd9Sstevel@tonic-gate 16597c478bd9Sstevel@tonic-gate #define MAX_G_HEADS 2 16607c478bd9Sstevel@tonic-gate 16617c478bd9Sstevel@tonic-gate /* 16627c478bd9Sstevel@tonic-gate * unpadded ill_if structure 16637c478bd9Sstevel@tonic-gate */ 16647c478bd9Sstevel@tonic-gate struct _ill_if_s_ { 16657c478bd9Sstevel@tonic-gate union ill_if_u *illif_next; 16667c478bd9Sstevel@tonic-gate union ill_if_u *illif_prev; 16677c478bd9Sstevel@tonic-gate avl_tree_t illif_avl_by_ppa; /* AVL tree sorted on ppa */ 16687c478bd9Sstevel@tonic-gate vmem_t *illif_ppa_arena; /* ppa index space */ 16697c478bd9Sstevel@tonic-gate uint16_t illif_mcast_v1; /* hints for */ 16707c478bd9Sstevel@tonic-gate uint16_t illif_mcast_v2; /* [igmp|mld]_slowtimo */ 16717c478bd9Sstevel@tonic-gate int illif_name_len; /* name length */ 16727c478bd9Sstevel@tonic-gate char illif_name[LIFNAMSIZ]; /* name of interface type */ 16737c478bd9Sstevel@tonic-gate }; 16747c478bd9Sstevel@tonic-gate 16757c478bd9Sstevel@tonic-gate /* cache aligned ill_if structure */ 16767c478bd9Sstevel@tonic-gate typedef union ill_if_u { 16777c478bd9Sstevel@tonic-gate struct _ill_if_s_ ill_if_s; 16787c478bd9Sstevel@tonic-gate char illif_filler[CACHE_ALIGN(_ill_if_s_)]; 16797c478bd9Sstevel@tonic-gate } ill_if_t; 16807c478bd9Sstevel@tonic-gate 16817c478bd9Sstevel@tonic-gate #define illif_next ill_if_s.illif_next 16827c478bd9Sstevel@tonic-gate #define illif_prev ill_if_s.illif_prev 16837c478bd9Sstevel@tonic-gate #define illif_avl_by_ppa ill_if_s.illif_avl_by_ppa 16847c478bd9Sstevel@tonic-gate #define illif_ppa_arena ill_if_s.illif_ppa_arena 16857c478bd9Sstevel@tonic-gate #define illif_mcast_v1 ill_if_s.illif_mcast_v1 16867c478bd9Sstevel@tonic-gate #define illif_mcast_v2 ill_if_s.illif_mcast_v2 16877c478bd9Sstevel@tonic-gate #define illif_name ill_if_s.illif_name 16887c478bd9Sstevel@tonic-gate #define illif_name_len ill_if_s.illif_name_len 16897c478bd9Sstevel@tonic-gate 16907c478bd9Sstevel@tonic-gate typedef struct ill_walk_context_s { 16917c478bd9Sstevel@tonic-gate int ctx_current_list; /* current list being searched */ 16927c478bd9Sstevel@tonic-gate int ctx_last_list; /* last list to search */ 16937c478bd9Sstevel@tonic-gate } ill_walk_context_t; 16947c478bd9Sstevel@tonic-gate 16957c478bd9Sstevel@tonic-gate /* 1696f4b3ec61Sdh155122 * ill_g_heads structure, one for IPV4 and one for IPV6 16977c478bd9Sstevel@tonic-gate */ 16987c478bd9Sstevel@tonic-gate struct _ill_g_head_s_ { 16997c478bd9Sstevel@tonic-gate ill_if_t *ill_g_list_head; 17007c478bd9Sstevel@tonic-gate ill_if_t *ill_g_list_tail; 17017c478bd9Sstevel@tonic-gate }; 17027c478bd9Sstevel@tonic-gate 17037c478bd9Sstevel@tonic-gate typedef union ill_g_head_u { 17047c478bd9Sstevel@tonic-gate struct _ill_g_head_s_ ill_g_head_s; 17057c478bd9Sstevel@tonic-gate char ill_g_head_filler[CACHE_ALIGN(_ill_g_head_s_)]; 17067c478bd9Sstevel@tonic-gate } ill_g_head_t; 17077c478bd9Sstevel@tonic-gate 17087c478bd9Sstevel@tonic-gate #define ill_g_list_head ill_g_head_s.ill_g_list_head 17097c478bd9Sstevel@tonic-gate #define ill_g_list_tail ill_g_head_s.ill_g_list_tail 17107c478bd9Sstevel@tonic-gate 1711f4b3ec61Sdh155122 #define IP_V4_ILL_G_LIST(ipst) \ 1712f4b3ec61Sdh155122 (ipst)->ips_ill_g_heads[IP_V4_G_HEAD].ill_g_list_head 1713f4b3ec61Sdh155122 #define IP_V6_ILL_G_LIST(ipst) \ 1714f4b3ec61Sdh155122 (ipst)->ips_ill_g_heads[IP_V6_G_HEAD].ill_g_list_head 1715f4b3ec61Sdh155122 #define IP_VX_ILL_G_LIST(i, ipst) \ 1716f4b3ec61Sdh155122 (ipst)->ips_ill_g_heads[i].ill_g_list_head 17177c478bd9Sstevel@tonic-gate 1718f4b3ec61Sdh155122 #define ILL_START_WALK_V4(ctx_ptr, ipst) \ 1719f4b3ec61Sdh155122 ill_first(IP_V4_G_HEAD, IP_V4_G_HEAD, ctx_ptr, ipst) 1720f4b3ec61Sdh155122 #define ILL_START_WALK_V6(ctx_ptr, ipst) \ 1721f4b3ec61Sdh155122 ill_first(IP_V6_G_HEAD, IP_V6_G_HEAD, ctx_ptr, ipst) 1722f4b3ec61Sdh155122 #define ILL_START_WALK_ALL(ctx_ptr, ipst) \ 1723f4b3ec61Sdh155122 ill_first(MAX_G_HEADS, MAX_G_HEADS, ctx_ptr, ipst) 17247c478bd9Sstevel@tonic-gate 17257c478bd9Sstevel@tonic-gate /* 17267c478bd9Sstevel@tonic-gate * Capabilities, possible flags for ill_capabilities. 17277c478bd9Sstevel@tonic-gate */ 17287c478bd9Sstevel@tonic-gate 17297c478bd9Sstevel@tonic-gate #define ILL_CAPAB_AH 0x01 /* IPsec AH acceleration */ 17307c478bd9Sstevel@tonic-gate #define ILL_CAPAB_ESP 0x02 /* IPsec ESP acceleration */ 17317c478bd9Sstevel@tonic-gate #define ILL_CAPAB_MDT 0x04 /* Multidata Transmit */ 17327c478bd9Sstevel@tonic-gate #define ILL_CAPAB_HCKSUM 0x08 /* Hardware checksumming */ 17337c478bd9Sstevel@tonic-gate #define ILL_CAPAB_ZEROCOPY 0x10 /* Zero-copy */ 1734da14cebeSEric Cheng #define ILL_CAPAB_DLD 0x20 /* DLD capabilities */ 1735da14cebeSEric Cheng #define ILL_CAPAB_DLD_POLL 0x40 /* Polling */ 1736da14cebeSEric Cheng #define ILL_CAPAB_DLD_DIRECT 0x80 /* Direct function call */ 1737da14cebeSEric Cheng #define ILL_CAPAB_DLD_LSO 0x100 /* Large Segment Offload */ 17387c478bd9Sstevel@tonic-gate 17397c478bd9Sstevel@tonic-gate /* 17407c478bd9Sstevel@tonic-gate * Per-ill Multidata Transmit capabilities. 17417c478bd9Sstevel@tonic-gate */ 17427c478bd9Sstevel@tonic-gate typedef struct ill_mdt_capab_s ill_mdt_capab_t; 17437c478bd9Sstevel@tonic-gate 17447c478bd9Sstevel@tonic-gate /* 17457c478bd9Sstevel@tonic-gate * Per-ill IPsec capabilities. 17467c478bd9Sstevel@tonic-gate */ 17477c478bd9Sstevel@tonic-gate typedef struct ill_ipsec_capab_s ill_ipsec_capab_t; 17487c478bd9Sstevel@tonic-gate 17497c478bd9Sstevel@tonic-gate /* 17507c478bd9Sstevel@tonic-gate * Per-ill Hardware Checksumming capbilities. 17517c478bd9Sstevel@tonic-gate */ 17527c478bd9Sstevel@tonic-gate typedef struct ill_hcksum_capab_s ill_hcksum_capab_t; 17537c478bd9Sstevel@tonic-gate 17547c478bd9Sstevel@tonic-gate /* 17557c478bd9Sstevel@tonic-gate * Per-ill Zero-copy capabilities. 17567c478bd9Sstevel@tonic-gate */ 17577c478bd9Sstevel@tonic-gate typedef struct ill_zerocopy_capab_s ill_zerocopy_capab_t; 17587c478bd9Sstevel@tonic-gate 17597c478bd9Sstevel@tonic-gate /* 1760da14cebeSEric Cheng * DLD capbilities. 17617c478bd9Sstevel@tonic-gate */ 1762da14cebeSEric Cheng typedef struct ill_dld_capab_s ill_dld_capab_t; 17637c478bd9Sstevel@tonic-gate 17647c478bd9Sstevel@tonic-gate /* 17657c478bd9Sstevel@tonic-gate * Per-ill polling resource map. 17667c478bd9Sstevel@tonic-gate */ 17677c478bd9Sstevel@tonic-gate typedef struct ill_rx_ring ill_rx_ring_t; 17687c478bd9Sstevel@tonic-gate 17698347601bSyl150051 /* 17708347601bSyl150051 * Per-ill Large Segment Offload capabilities. 17718347601bSyl150051 */ 17728347601bSyl150051 typedef struct ill_lso_capab_s ill_lso_capab_t; 17738347601bSyl150051 17747c478bd9Sstevel@tonic-gate /* The following are ill_state_flags */ 17757c478bd9Sstevel@tonic-gate #define ILL_LL_SUBNET_PENDING 0x01 /* Waiting for DL_INFO_ACK from drv */ 17767c478bd9Sstevel@tonic-gate #define ILL_CONDEMNED 0x02 /* No more new ref's to the ILL */ 17777c478bd9Sstevel@tonic-gate #define ILL_CHANGING 0x04 /* ILL not globally visible */ 1778a5e428f7Skrgopi #define ILL_DL_UNBIND_IN_PROGRESS 0x08 /* UNBIND_REQ is sent */ 17797c478bd9Sstevel@tonic-gate 17807c478bd9Sstevel@tonic-gate /* Is this an ILL whose source address is used by other ILL's ? */ 17817c478bd9Sstevel@tonic-gate #define IS_USESRC_ILL(ill) \ 17827c478bd9Sstevel@tonic-gate (((ill)->ill_usesrc_ifindex == 0) && \ 17835dddb8baSkcpoon ((ill)->ill_usesrc_grp_next != NULL)) 17847c478bd9Sstevel@tonic-gate 17857c478bd9Sstevel@tonic-gate /* Is this a client/consumer of the usesrc ILL ? */ 17867c478bd9Sstevel@tonic-gate #define IS_USESRC_CLI_ILL(ill) \ 17877c478bd9Sstevel@tonic-gate (((ill)->ill_usesrc_ifindex != 0) && \ 17885dddb8baSkcpoon ((ill)->ill_usesrc_grp_next != NULL)) 17897c478bd9Sstevel@tonic-gate 17907c478bd9Sstevel@tonic-gate /* Is this an virtual network interface (vni) ILL ? */ 17917c478bd9Sstevel@tonic-gate #define IS_VNI(ill) \ 1792c793af95Ssangeeta (((ill) != NULL) && \ 1793c793af95Ssangeeta (((ill)->ill_phyint->phyint_flags & (PHYI_LOOPBACK|PHYI_VIRTUAL)) == \ 17945dddb8baSkcpoon PHYI_VIRTUAL)) 17957c478bd9Sstevel@tonic-gate 179648de1bd2Skcpoon /* Is this a loopback ILL? */ 179748de1bd2Skcpoon #define IS_LOOPBACK(ill) \ 179848de1bd2Skcpoon ((ill)->ill_phyint->phyint_flags & PHYI_LOOPBACK) 179948de1bd2Skcpoon 1800e11c3f44Smeem /* Is this an IPMP meta-interface ILL? */ 1801e11c3f44Smeem #define IS_IPMP(ill) \ 1802e11c3f44Smeem ((ill)->ill_phyint->phyint_flags & PHYI_IPMP) 1803e11c3f44Smeem 1804e11c3f44Smeem /* Is this ILL under an IPMP meta-interface? (aka "in a group?") */ 1805e11c3f44Smeem #define IS_UNDER_IPMP(ill) \ 1806e11c3f44Smeem ((ill)->ill_grp != NULL && !IS_IPMP(ill)) 1807e11c3f44Smeem 1808e11c3f44Smeem /* Is ill1 in the same illgrp as ill2? */ 1809e11c3f44Smeem #define IS_IN_SAME_ILLGRP(ill1, ill2) \ 1810e11c3f44Smeem ((ill1)->ill_grp != NULL && ((ill1)->ill_grp == (ill2)->ill_grp)) 1811e11c3f44Smeem 1812e11c3f44Smeem /* Is ill1 on the same LAN as ill2? */ 1813e11c3f44Smeem #define IS_ON_SAME_LAN(ill1, ill2) \ 1814e11c3f44Smeem ((ill1) == (ill2) || IS_IN_SAME_ILLGRP(ill1, ill2)) 1815e11c3f44Smeem 1816e11c3f44Smeem #define ILL_OTHER(ill) \ 1817e11c3f44Smeem ((ill)->ill_isv6 ? (ill)->ill_phyint->phyint_illv4 : \ 1818e11c3f44Smeem (ill)->ill_phyint->phyint_illv6) 1819e11c3f44Smeem 1820e11c3f44Smeem /* 1821e11c3f44Smeem * IPMP group ILL state structure -- up to two per IPMP group (V4 and V6). 1822e11c3f44Smeem * Created when the V4 and/or V6 IPMP meta-interface is I_PLINK'd. It is 1823e11c3f44Smeem * guaranteed to persist while there are interfaces of that type in the group. 1824e11c3f44Smeem * In general, most fields are accessed outside of the IPSQ (e.g., in the 1825e11c3f44Smeem * datapath), and thus use locks in addition to the IPSQ for protection. 1826e11c3f44Smeem * 1827e11c3f44Smeem * synchronization: read write 1828e11c3f44Smeem * 1829e11c3f44Smeem * ig_if ipsq or ill_g_lock ipsq and ill_g_lock 1830e11c3f44Smeem * ig_actif ipsq or ipmp_lock ipsq and ipmp_lock 1831e11c3f44Smeem * ig_nactif ipsq or ipmp_lock ipsq and ipmp_lock 1832e11c3f44Smeem * ig_next_ill ipsq or ipmp_lock ipsq and ipmp_lock 1833e11c3f44Smeem * ig_ipmp_ill write once write once 1834e11c3f44Smeem * ig_cast_ill ipsq or ipmp_lock ipsq and ipmp_lock 1835e11c3f44Smeem * ig_arpent ipsq ipsq 1836e11c3f44Smeem * ig_mtu ipsq ipsq 1837e11c3f44Smeem */ 1838e11c3f44Smeem typedef struct ipmp_illgrp_s { 1839e11c3f44Smeem list_t ig_if; /* list of all interfaces */ 1840e11c3f44Smeem list_t ig_actif; /* list of active interfaces */ 1841e11c3f44Smeem uint_t ig_nactif; /* number of active interfaces */ 1842e11c3f44Smeem struct ill_s *ig_next_ill; /* next active interface to use */ 1843e11c3f44Smeem struct ill_s *ig_ipmp_ill; /* backpointer to IPMP meta-interface */ 1844e11c3f44Smeem struct ill_s *ig_cast_ill; /* nominated ill for multi/broadcast */ 1845e11c3f44Smeem list_t ig_arpent; /* list of ARP entries */ 1846e11c3f44Smeem uint_t ig_mtu; /* ig_ipmp_ill->ill_max_mtu */ 1847e11c3f44Smeem } ipmp_illgrp_t; 1848e11c3f44Smeem 1849e11c3f44Smeem /* 1850e11c3f44Smeem * IPMP group state structure -- one per IPMP group. Created when the 1851e11c3f44Smeem * IPMP meta-interface is plumbed; it is guaranteed to persist while there 1852e11c3f44Smeem * are interfaces in it. 1853e11c3f44Smeem * 1854e11c3f44Smeem * ipmp_grp_t synchronization: read write 1855e11c3f44Smeem * 1856e11c3f44Smeem * gr_name ipmp_lock ipmp_lock 1857e11c3f44Smeem * gr_ifname write once write once 1858e11c3f44Smeem * gr_mactype ipmp_lock ipmp_lock 1859e11c3f44Smeem * gr_phyint write once write once 1860e11c3f44Smeem * gr_nif ipmp_lock ipmp_lock 1861e11c3f44Smeem * gr_nactif ipsq ipsq 1862e11c3f44Smeem * gr_v4 ipmp_lock ipmp_lock 1863e11c3f44Smeem * gr_v6 ipmp_lock ipmp_lock 1864e11c3f44Smeem * gr_nv4 ipmp_lock ipmp_lock 1865e11c3f44Smeem * gr_nv6 ipmp_lock ipmp_lock 1866e11c3f44Smeem * gr_pendv4 ipmp_lock ipmp_lock 1867e11c3f44Smeem * gr_pendv6 ipmp_lock ipmp_lock 1868e11c3f44Smeem * gr_linkdownmp ipsq ipsq 1869e11c3f44Smeem * gr_ksp ipmp_lock ipmp_lock 1870e11c3f44Smeem * gr_kstats0 atomic atomic 1871e11c3f44Smeem */ 1872e11c3f44Smeem typedef struct ipmp_grp_s { 1873e11c3f44Smeem char gr_name[LIFGRNAMSIZ]; /* group name */ 1874e11c3f44Smeem char gr_ifname[LIFNAMSIZ]; /* interface name */ 1875e11c3f44Smeem t_uscalar_t gr_mactype; /* DLPI mactype of group */ 1876e11c3f44Smeem phyint_t *gr_phyint; /* IPMP group phyint */ 1877e11c3f44Smeem uint_t gr_nif; /* number of interfaces in group */ 1878e11c3f44Smeem uint_t gr_nactif; /* number of active interfaces */ 1879e11c3f44Smeem ipmp_illgrp_t *gr_v4; /* V4 group information */ 1880e11c3f44Smeem ipmp_illgrp_t *gr_v6; /* V6 group information */ 1881e11c3f44Smeem uint_t gr_nv4; /* number of ills in V4 group */ 1882e11c3f44Smeem uint_t gr_nv6; /* number of ills in V6 group */ 1883e11c3f44Smeem uint_t gr_pendv4; /* number of pending ills in V4 group */ 1884e11c3f44Smeem uint_t gr_pendv6; /* number of pending ills in V6 group */ 1885e11c3f44Smeem mblk_t *gr_linkdownmp; /* message used to bring link down */ 1886e11c3f44Smeem kstat_t *gr_ksp; /* group kstat pointer */ 1887e11c3f44Smeem uint64_t gr_kstats0[IPMP_KSTAT_MAX]; /* baseline group kstats */ 1888e11c3f44Smeem } ipmp_grp_t; 1889e11c3f44Smeem 1890e11c3f44Smeem /* 1891e11c3f44Smeem * IPMP ARP entry -- one per SIOCS*ARP entry tied to the group. Used to keep 1892e11c3f44Smeem * ARP up-to-date as the active set of interfaces in the group changes. 1893e11c3f44Smeem */ 1894e11c3f44Smeem typedef struct ipmp_arpent_s { 1895e11c3f44Smeem mblk_t *ia_area_mp; /* AR_ENTRY_ADD pointer */ 1896e11c3f44Smeem ipaddr_t ia_ipaddr; /* IP address for this entry */ 1897e11c3f44Smeem boolean_t ia_proxyarp; /* proxy ARP entry? */ 1898e11c3f44Smeem boolean_t ia_notified; /* ARP notified about this entry? */ 1899e11c3f44Smeem list_node_t ia_node; /* next ARP entry in list */ 1900e11c3f44Smeem } ipmp_arpent_t; 1901e11c3f44Smeem 19027c478bd9Sstevel@tonic-gate /* 19037c478bd9Sstevel@tonic-gate * IP Lower level Structure. 19047c478bd9Sstevel@tonic-gate * Instance data structure in ip_open when there is a device below us. 19057c478bd9Sstevel@tonic-gate */ 19067c478bd9Sstevel@tonic-gate typedef struct ill_s { 19077c478bd9Sstevel@tonic-gate ill_if_t *ill_ifptr; /* pointer to interface type */ 19087c478bd9Sstevel@tonic-gate queue_t *ill_rq; /* Read queue. */ 19097c478bd9Sstevel@tonic-gate queue_t *ill_wq; /* Write queue. */ 19107c478bd9Sstevel@tonic-gate 19117c478bd9Sstevel@tonic-gate int ill_error; /* Error value sent up by device. */ 19127c478bd9Sstevel@tonic-gate 19137c478bd9Sstevel@tonic-gate ipif_t *ill_ipif; /* Interface chain for this ILL. */ 19147c478bd9Sstevel@tonic-gate 19157c478bd9Sstevel@tonic-gate uint_t ill_ipif_up_count; /* Number of IPIFs currently up. */ 19167c478bd9Sstevel@tonic-gate uint_t ill_max_frag; /* Max IDU from DLPI. */ 19177c478bd9Sstevel@tonic-gate char *ill_name; /* Our name. */ 191869bb4bb4Scarlsonj uint_t ill_ipif_dup_count; /* Number of duplicate addresses. */ 19197c478bd9Sstevel@tonic-gate uint_t ill_name_length; /* Name length, incl. terminator. */ 19207c478bd9Sstevel@tonic-gate char *ill_ndd_name; /* Name + ":ip?_forwarding" for NDD. */ 19217c478bd9Sstevel@tonic-gate uint_t ill_net_type; /* IRE_IF_RESOLVER/IRE_IF_NORESOLVER. */ 19227c478bd9Sstevel@tonic-gate /* 19237c478bd9Sstevel@tonic-gate * Physical Point of Attachment num. If DLPI style 1 provider 19247c478bd9Sstevel@tonic-gate * then this is derived from the devname. 19257c478bd9Sstevel@tonic-gate */ 19267c478bd9Sstevel@tonic-gate uint_t ill_ppa; 19277c478bd9Sstevel@tonic-gate t_uscalar_t ill_sap; 19287c478bd9Sstevel@tonic-gate t_scalar_t ill_sap_length; /* Including sign (for position) */ 19297c478bd9Sstevel@tonic-gate uint_t ill_phys_addr_length; /* Excluding the sap. */ 19307c478bd9Sstevel@tonic-gate uint_t ill_bcast_addr_length; /* Only set when the DL provider */ 19317c478bd9Sstevel@tonic-gate /* supports broadcast. */ 19327c478bd9Sstevel@tonic-gate t_uscalar_t ill_mactype; 19337c478bd9Sstevel@tonic-gate uint8_t *ill_frag_ptr; /* Reassembly state. */ 19347c478bd9Sstevel@tonic-gate timeout_id_t ill_frag_timer_id; /* timeout id for the frag timer */ 19357c478bd9Sstevel@tonic-gate ipfb_t *ill_frag_hash_tbl; /* Fragment hash list head. */ 19367c478bd9Sstevel@tonic-gate ipif_t *ill_pending_ipif; /* IPIF waiting for DL operation. */ 19377c478bd9Sstevel@tonic-gate 19387924222fSmeem ilm_t *ill_ilm; /* Multicast membership for ill */ 19397c478bd9Sstevel@tonic-gate uint_t ill_global_timer; /* for IGMPv3/MLDv2 general queries */ 19407c478bd9Sstevel@tonic-gate int ill_mcast_type; /* type of router which is querier */ 19417c478bd9Sstevel@tonic-gate /* on this interface */ 19427c478bd9Sstevel@tonic-gate uint16_t ill_mcast_v1_time; /* # slow timeouts since last v1 qry */ 19437c478bd9Sstevel@tonic-gate uint16_t ill_mcast_v2_time; /* # slow timeouts since last v2 qry */ 19447c478bd9Sstevel@tonic-gate uint8_t ill_mcast_v1_tset; /* 1 => timer is set; 0 => not set */ 19457c478bd9Sstevel@tonic-gate uint8_t ill_mcast_v2_tset; /* 1 => timer is set; 0 => not set */ 19467c478bd9Sstevel@tonic-gate 19477c478bd9Sstevel@tonic-gate uint8_t ill_mcast_rv; /* IGMPv3/MLDv2 robustness variable */ 19487c478bd9Sstevel@tonic-gate int ill_mcast_qi; /* IGMPv3/MLDv2 query interval var */ 19497c478bd9Sstevel@tonic-gate 19507c478bd9Sstevel@tonic-gate mblk_t *ill_pending_mp; /* IOCTL/DLPI awaiting completion. */ 19517c478bd9Sstevel@tonic-gate /* 19527c478bd9Sstevel@tonic-gate * All non-NULL cells between 'ill_first_mp_to_free' and 19537c478bd9Sstevel@tonic-gate * 'ill_last_mp_to_free' are freed in ill_delete. 19547c478bd9Sstevel@tonic-gate */ 19557c478bd9Sstevel@tonic-gate #define ill_first_mp_to_free ill_bcast_mp 19567c478bd9Sstevel@tonic-gate mblk_t *ill_bcast_mp; /* DLPI header for broadcasts. */ 19577c478bd9Sstevel@tonic-gate mblk_t *ill_resolver_mp; /* Resolver template. */ 19587c478bd9Sstevel@tonic-gate mblk_t *ill_unbind_mp; /* unbind mp from ill_dl_up() */ 1959b127ac41SPhilip Kirk mblk_t *ill_promiscoff_mp; /* for ill_leave_allmulti() */ 19607c478bd9Sstevel@tonic-gate mblk_t *ill_dlpi_deferred; /* b_next chain of control messages */ 1961e11c3f44Smeem mblk_t *ill_ardeact_mp; /* deact mp from ipmp_ill_activate() */ 19625d460eafSCathy Zhou mblk_t *ill_replumb_mp; /* replumb mp from ill_replumb() */ 19637c478bd9Sstevel@tonic-gate mblk_t *ill_phys_addr_mp; /* mblk which holds ill_phys_addr */ 19647c478bd9Sstevel@tonic-gate #define ill_last_mp_to_free ill_phys_addr_mp 19657c478bd9Sstevel@tonic-gate 19667c478bd9Sstevel@tonic-gate cred_t *ill_credp; /* opener's credentials */ 19677c478bd9Sstevel@tonic-gate uint8_t *ill_phys_addr; /* ill_phys_addr_mp->b_rptr + off */ 19687c478bd9Sstevel@tonic-gate 19697c478bd9Sstevel@tonic-gate uint_t ill_state_flags; /* see ILL_* flags above */ 19707c478bd9Sstevel@tonic-gate 19717c478bd9Sstevel@tonic-gate /* Following bit fields protected by ipsq_t */ 19727c478bd9Sstevel@tonic-gate uint_t 19737c478bd9Sstevel@tonic-gate ill_needs_attach : 1, 19747c478bd9Sstevel@tonic-gate ill_reserved : 1, 19757c478bd9Sstevel@tonic-gate ill_isv6 : 1, 19767c478bd9Sstevel@tonic-gate ill_dlpi_style_set : 1, 19777c478bd9Sstevel@tonic-gate 19787c478bd9Sstevel@tonic-gate ill_ifname_pending : 1, 19797c478bd9Sstevel@tonic-gate ill_join_allmulti : 1, 19807c478bd9Sstevel@tonic-gate ill_logical_down : 1, 19817c478bd9Sstevel@tonic-gate ill_is_6to4tun : 1, /* Interface is a 6to4 tunnel */ 1982e11c3f44Smeem 19837c478bd9Sstevel@tonic-gate ill_dl_up : 1, 19847c478bd9Sstevel@tonic-gate ill_up_ipifs : 1, 198569bb4bb4Scarlsonj ill_note_link : 1, /* supports link-up notification */ 19868fb46f24Syz147064 ill_capab_reneg : 1, /* capability renegotiation to be done */ 1987da14cebeSEric Cheng ill_dld_capab_inprog : 1, /* direct dld capab call in prog */ 1988b127ac41SPhilip Kirk ill_need_recover_multicast : 1, 1989806139abSGirish Moodalbail ill_pad_to_bit_31 : 18; 19907c478bd9Sstevel@tonic-gate 19917c478bd9Sstevel@tonic-gate /* Following bit fields protected by ill_lock */ 19927c478bd9Sstevel@tonic-gate uint_t 19937c478bd9Sstevel@tonic-gate ill_fragtimer_executing : 1, 19947c478bd9Sstevel@tonic-gate ill_fragtimer_needrestart : 1, 19957c478bd9Sstevel@tonic-gate ill_ilm_cleanup_reqd : 1, 19967c478bd9Sstevel@tonic-gate ill_arp_closing : 1, 19977c478bd9Sstevel@tonic-gate 19987c478bd9Sstevel@tonic-gate ill_arp_bringup_pending : 1, 199969bb4bb4Scarlsonj ill_arp_extend : 1, /* ARP has DAD extensions */ 2000e11c3f44Smeem ill_pad_bit_31 : 26; 20017c478bd9Sstevel@tonic-gate 20027c478bd9Sstevel@tonic-gate /* 20037c478bd9Sstevel@tonic-gate * Used in SIOCSIFMUXID and SIOCGIFMUXID for 'ifconfig unplumb'. 20047c478bd9Sstevel@tonic-gate */ 20057c478bd9Sstevel@tonic-gate int ill_arp_muxid; /* muxid returned from plink for arp */ 20067c478bd9Sstevel@tonic-gate int ill_ip_muxid; /* muxid returned from plink for ip */ 20077c478bd9Sstevel@tonic-gate 20080a5d959fSgeorges /* Used for IP frag reassembly throttling on a per ILL basis. */ 20097c478bd9Sstevel@tonic-gate uint_t ill_ipf_gen; /* Generation of next fragment queue */ 20100a5d959fSgeorges uint_t ill_frag_count; /* Count of all reassembly mblk bytes */ 20117c478bd9Sstevel@tonic-gate uint_t ill_frag_free_num_pkts; /* num of fragmented packets to free */ 20127c478bd9Sstevel@tonic-gate clock_t ill_last_frag_clean_time; /* time when frag's were pruned */ 20137c478bd9Sstevel@tonic-gate int ill_type; /* From <net/if_types.h> */ 20144d876314Sja97890 uint_t ill_dlpi_multicast_state; /* See below IDS_* */ 20154d876314Sja97890 uint_t ill_dlpi_fastpath_state; /* See below IDS_* */ 20167c478bd9Sstevel@tonic-gate 20177c478bd9Sstevel@tonic-gate /* 20187c478bd9Sstevel@tonic-gate * Capabilities related fields. 20197c478bd9Sstevel@tonic-gate */ 2020da14cebeSEric Cheng uint_t ill_dlpi_capab_state; /* State of capability query, IDCS_* */ 2021da14cebeSEric Cheng uint_t ill_capab_pending_cnt; 20227c478bd9Sstevel@tonic-gate uint64_t ill_capabilities; /* Enabled capabilities, ILL_CAPAB_* */ 20237c478bd9Sstevel@tonic-gate ill_mdt_capab_t *ill_mdt_capab; /* Multidata Transmit capabilities */ 20247c478bd9Sstevel@tonic-gate ill_ipsec_capab_t *ill_ipsec_capab_ah; /* IPsec AH capabilities */ 20257c478bd9Sstevel@tonic-gate ill_ipsec_capab_t *ill_ipsec_capab_esp; /* IPsec ESP capabilities */ 20267c478bd9Sstevel@tonic-gate ill_hcksum_capab_t *ill_hcksum_capab; /* H/W cksumming capabilities */ 20277c478bd9Sstevel@tonic-gate ill_zerocopy_capab_t *ill_zerocopy_capab; /* Zero-copy capabilities */ 2028da14cebeSEric Cheng ill_dld_capab_t *ill_dld_capab; /* DLD capabilities */ 20298347601bSyl150051 ill_lso_capab_t *ill_lso_capab; /* Large Segment Offload capabilities */ 2030da14cebeSEric Cheng mblk_t *ill_capab_reset_mp; /* Preallocated mblk for capab reset */ 20317c478bd9Sstevel@tonic-gate 20327c478bd9Sstevel@tonic-gate /* 20337c478bd9Sstevel@tonic-gate * New fields for IPv6 20347c478bd9Sstevel@tonic-gate */ 20357c478bd9Sstevel@tonic-gate uint8_t ill_max_hops; /* Maximum hops for any logical interface */ 20367c478bd9Sstevel@tonic-gate uint_t ill_max_mtu; /* Maximum MTU for any logical interface */ 2037e11c3f44Smeem uint_t ill_user_mtu; /* User-specified MTU via SIOCSLIFLNKINFO */ 20387c478bd9Sstevel@tonic-gate uint32_t ill_reachable_time; /* Value for ND algorithm in msec */ 20397c478bd9Sstevel@tonic-gate uint32_t ill_reachable_retrans_time; /* Value for ND algorithm msec */ 20407c478bd9Sstevel@tonic-gate uint_t ill_max_buf; /* Max # of req to buffer for ND */ 20417c478bd9Sstevel@tonic-gate in6_addr_t ill_token; 20427c478bd9Sstevel@tonic-gate uint_t ill_token_length; 20437c478bd9Sstevel@tonic-gate uint32_t ill_xmit_count; /* ndp max multicast xmits */ 20443173664eSapersson mib2_ipIfStatsEntry_t *ill_ip_mib; /* ver indep. interface mib */ 20457c478bd9Sstevel@tonic-gate mib2_ipv6IfIcmpEntry_t *ill_icmp6_mib; /* Per interface mib */ 20467c478bd9Sstevel@tonic-gate /* 20477c478bd9Sstevel@tonic-gate * Following two mblks are allocated common to all 20487c478bd9Sstevel@tonic-gate * the ipifs when the first interface is coming up. 20497c478bd9Sstevel@tonic-gate * It is sent up to arp when the last ipif is coming 20507c478bd9Sstevel@tonic-gate * down. 20517c478bd9Sstevel@tonic-gate */ 20527c478bd9Sstevel@tonic-gate mblk_t *ill_arp_down_mp; 20537c478bd9Sstevel@tonic-gate mblk_t *ill_arp_del_mapping_mp; 20547c478bd9Sstevel@tonic-gate /* 20557c478bd9Sstevel@tonic-gate * Used for implementing IFF_NOARP. As IFF_NOARP is used 20567c478bd9Sstevel@tonic-gate * to turn off for all the logicals, it is here instead 20577c478bd9Sstevel@tonic-gate * of the ipif. 20587c478bd9Sstevel@tonic-gate */ 20597c478bd9Sstevel@tonic-gate mblk_t *ill_arp_on_mp; 20607c478bd9Sstevel@tonic-gate 20617c478bd9Sstevel@tonic-gate phyint_t *ill_phyint; 20627c478bd9Sstevel@tonic-gate uint64_t ill_flags; 20637c478bd9Sstevel@tonic-gate 20647c478bd9Sstevel@tonic-gate kmutex_t ill_lock; /* Please see table below */ 20657c478bd9Sstevel@tonic-gate /* 20667c478bd9Sstevel@tonic-gate * The ill_nd_lla* fields handle the link layer address option 20677c478bd9Sstevel@tonic-gate * from neighbor discovery. This is used for external IPv6 20687c478bd9Sstevel@tonic-gate * address resolution. 20697c478bd9Sstevel@tonic-gate */ 20707c478bd9Sstevel@tonic-gate mblk_t *ill_nd_lla_mp; /* mblk which holds ill_nd_lla */ 20717c478bd9Sstevel@tonic-gate uint8_t *ill_nd_lla; /* Link Layer Address */ 20727c478bd9Sstevel@tonic-gate uint_t ill_nd_lla_len; /* Link Layer Address length */ 20737c478bd9Sstevel@tonic-gate /* 20747c478bd9Sstevel@tonic-gate * We now have 3 phys_addr_req's sent down. This field keeps track 20757c478bd9Sstevel@tonic-gate * of which one is pending. 20767c478bd9Sstevel@tonic-gate */ 20777c478bd9Sstevel@tonic-gate t_uscalar_t ill_phys_addr_pend; /* which dl_phys_addr_req pending */ 20787c478bd9Sstevel@tonic-gate /* 20797c478bd9Sstevel@tonic-gate * Used to save errors that occur during plumbing 20807c478bd9Sstevel@tonic-gate */ 20817c478bd9Sstevel@tonic-gate uint_t ill_ifname_pending_err; 20827c478bd9Sstevel@tonic-gate avl_node_t ill_avl_byppa; /* avl node based on ppa */ 20837c478bd9Sstevel@tonic-gate void *ill_fastpath_list; /* both ire and nce hang off this */ 20847c478bd9Sstevel@tonic-gate uint_t ill_refcnt; /* active refcnt by threads */ 2085384ad179Ssowmini uint_t ill_ire_cnt; /* ires associated with this ill */ 20867c478bd9Sstevel@tonic-gate kcondvar_t ill_cv; 20877c478bd9Sstevel@tonic-gate uint_t ill_ilm_walker_cnt; /* snmp ilm walkers */ 2088384ad179Ssowmini uint_t ill_nce_cnt; /* nces associated with this ill */ 20897c478bd9Sstevel@tonic-gate uint_t ill_waiters; /* threads waiting in ipsq_enter */ 20907c478bd9Sstevel@tonic-gate /* 20917c478bd9Sstevel@tonic-gate * Contains the upper read queue pointer of the module immediately 20927c478bd9Sstevel@tonic-gate * beneath IP. This field allows IP to validate sub-capability 20937c478bd9Sstevel@tonic-gate * acknowledgments coming up from downstream. 20947c478bd9Sstevel@tonic-gate */ 20957c478bd9Sstevel@tonic-gate queue_t *ill_lmod_rq; /* read queue pointer of module below */ 20967c478bd9Sstevel@tonic-gate uint_t ill_lmod_cnt; /* number of modules beneath IP */ 20977c478bd9Sstevel@tonic-gate ip_m_t *ill_media; /* media specific params/functions */ 20987c478bd9Sstevel@tonic-gate t_uscalar_t ill_dlpi_pending; /* Last DLPI primitive issued */ 20997c478bd9Sstevel@tonic-gate uint_t ill_usesrc_ifindex; /* use src addr from this ILL */ 21007c478bd9Sstevel@tonic-gate struct ill_s *ill_usesrc_grp_next; /* Next ILL in the usesrc group */ 21017c478bd9Sstevel@tonic-gate boolean_t ill_trace_disable; /* True when alloc fails */ 2102f4b3ec61Sdh155122 zoneid_t ill_zoneid; 2103f4b3ec61Sdh155122 ip_stack_t *ill_ipst; /* Corresponds to a netstack_hold */ 2104e704a8f2Smeem uint32_t ill_dhcpinit; /* IP_DHCPINIT_IFs for ill */ 2105da14cebeSEric Cheng void *ill_flownotify_mh; /* Tx flow ctl, mac cb handle */ 2106384ad179Ssowmini uint_t ill_ilm_cnt; /* ilms referencing this ill */ 2107b127ac41SPhilip Kirk uint_t ill_ipallmulti_cnt; /* ip_join_allmulti() calls */ 2108e11c3f44Smeem /* 2109e11c3f44Smeem * IPMP fields. 2110e11c3f44Smeem */ 2111e11c3f44Smeem ipmp_illgrp_t *ill_grp; /* IPMP group information */ 2112e11c3f44Smeem list_node_t ill_actnode; /* next active ill in group */ 2113e11c3f44Smeem list_node_t ill_grpnode; /* next ill in group */ 2114e11c3f44Smeem ipif_t *ill_src_ipif; /* source address selection rotor */ 2115e11c3f44Smeem ipif_t *ill_move_ipif; /* ipif awaiting move to new ill */ 2116e11c3f44Smeem boolean_t ill_nom_cast; /* nominated for mcast/bcast */ 2117e11c3f44Smeem uint_t ill_bound_cnt; /* # of data addresses bound to ill */ 2118e11c3f44Smeem ipif_t *ill_bound_ipif; /* ipif chain bound to ill */ 2119e11c3f44Smeem timeout_id_t ill_refresh_tid; /* ill refresh retry timeout id */ 21207c478bd9Sstevel@tonic-gate } ill_t; 21217c478bd9Sstevel@tonic-gate 21227c478bd9Sstevel@tonic-gate /* 2123384ad179Ssowmini * ILL_FREE_OK() means that there are no incoming pointer references 2124968d2fd1Ssowmini * to the ill. 2125968d2fd1Ssowmini */ 2126968d2fd1Ssowmini #define ILL_FREE_OK(ill) \ 2127384ad179Ssowmini ((ill)->ill_ire_cnt == 0 && (ill)->ill_ilm_cnt == 0 && \ 2128384ad179Ssowmini (ill)->ill_nce_cnt == 0) 2129968d2fd1Ssowmini 2130968d2fd1Ssowmini /* 2131968d2fd1Ssowmini * An ipif/ill can be marked down only when the ire and nce references 2132968d2fd1Ssowmini * to that ipif/ill goes to zero. ILL_DOWN_OK() is a necessary condition 2133968d2fd1Ssowmini * quiescence checks. See comments above IPIF_DOWN_OK for details 2134968d2fd1Ssowmini * on why ires and nces are selectively considered for this macro. 2135968d2fd1Ssowmini */ 2136384ad179Ssowmini #define ILL_DOWN_OK(ill) (ill->ill_ire_cnt == 0 && ill->ill_nce_cnt == 0) 2137968d2fd1Ssowmini 2138968d2fd1Ssowmini /* 21397c478bd9Sstevel@tonic-gate * The following table lists the protection levels of the various members 21407c478bd9Sstevel@tonic-gate * of the ill_t. Same notation as that used for ipif_t above is used. 21417c478bd9Sstevel@tonic-gate * 21427c478bd9Sstevel@tonic-gate * Write Read 21437c478bd9Sstevel@tonic-gate * 21447c478bd9Sstevel@tonic-gate * ill_ifptr ill_g_lock + s Write once 21457c478bd9Sstevel@tonic-gate * ill_rq ipsq Write once 21467c478bd9Sstevel@tonic-gate * ill_wq ipsq Write once 21477c478bd9Sstevel@tonic-gate * 21487c478bd9Sstevel@tonic-gate * ill_error ipsq None 21497c478bd9Sstevel@tonic-gate * ill_ipif ill_g_lock + ipsq ill_g_lock OR ipsq 21508df01f76Smeem * ill_ipif_up_count ill_lock + ipsq ill_lock OR ipsq 21517c478bd9Sstevel@tonic-gate * ill_max_frag ipsq Write once 21527c478bd9Sstevel@tonic-gate * 21537c478bd9Sstevel@tonic-gate * ill_name ill_g_lock + ipsq Write once 21547c478bd9Sstevel@tonic-gate * ill_name_length ill_g_lock + ipsq Write once 21557c478bd9Sstevel@tonic-gate * ill_ndd_name ipsq Write once 21567c478bd9Sstevel@tonic-gate * ill_net_type ipsq Write once 21577c478bd9Sstevel@tonic-gate * ill_ppa ill_g_lock + ipsq Write once 21587c478bd9Sstevel@tonic-gate * ill_sap ipsq + down ill Write once 21597c478bd9Sstevel@tonic-gate * ill_sap_length ipsq + down ill Write once 21607c478bd9Sstevel@tonic-gate * ill_phys_addr_length ipsq + down ill Write once 21617c478bd9Sstevel@tonic-gate * 21627c478bd9Sstevel@tonic-gate * ill_bcast_addr_length ipsq ipsq 21637c478bd9Sstevel@tonic-gate * ill_mactype ipsq ipsq 21647c478bd9Sstevel@tonic-gate * ill_frag_ptr ipsq ipsq 21657c478bd9Sstevel@tonic-gate * 21667c478bd9Sstevel@tonic-gate * ill_frag_timer_id ill_lock ill_lock 21677c478bd9Sstevel@tonic-gate * ill_frag_hash_tbl ipsq up ill 21687c478bd9Sstevel@tonic-gate * ill_ilm ipsq + ill_lock ill_lock 21697c478bd9Sstevel@tonic-gate * ill_mcast_type ill_lock ill_lock 21707c478bd9Sstevel@tonic-gate * ill_mcast_v1_time ill_lock ill_lock 21717c478bd9Sstevel@tonic-gate * ill_mcast_v2_time ill_lock ill_lock 21727c478bd9Sstevel@tonic-gate * ill_mcast_v1_tset ill_lock ill_lock 21737c478bd9Sstevel@tonic-gate * ill_mcast_v2_tset ill_lock ill_lock 21747c478bd9Sstevel@tonic-gate * ill_mcast_rv ill_lock ill_lock 21757c478bd9Sstevel@tonic-gate * ill_mcast_qi ill_lock ill_lock 21767c478bd9Sstevel@tonic-gate * ill_pending_mp ill_lock ill_lock 21777c478bd9Sstevel@tonic-gate * 21787c478bd9Sstevel@tonic-gate * ill_bcast_mp ipsq ipsq 21797c478bd9Sstevel@tonic-gate * ill_resolver_mp ipsq only when ill is up 21807c478bd9Sstevel@tonic-gate * ill_down_mp ipsq ipsq 21818df01f76Smeem * ill_dlpi_deferred ill_lock ill_lock 2182*7571834aSThirumalai Srinivasan * ill_dlpi_pending ipsq + ill_lock ipsq or ill_lock or 2183*7571834aSThirumalai Srinivasan * absence of ipsq writer. 2184b051ecf6Smeem * ill_phys_addr_mp ipsq + down ill only when ill is up 2185b051ecf6Smeem * ill_phys_addr ipsq + down ill only when ill is up 21867c478bd9Sstevel@tonic-gate * 21877c478bd9Sstevel@tonic-gate * ill_state_flags ill_lock ill_lock 21887c478bd9Sstevel@tonic-gate * exclusive bit flags ipsq_t ipsq_t 21897c478bd9Sstevel@tonic-gate * shared bit flags ill_lock ill_lock 21907c478bd9Sstevel@tonic-gate * 21917c478bd9Sstevel@tonic-gate * ill_arp_muxid ipsq Not atomic 21927c478bd9Sstevel@tonic-gate * ill_ip_muxid ipsq Not atomic 21937c478bd9Sstevel@tonic-gate * 21947c478bd9Sstevel@tonic-gate * ill_ipf_gen Not atomic 21950a5d959fSgeorges * ill_frag_count atomics atomics 21967c478bd9Sstevel@tonic-gate * ill_type ipsq + down ill only when ill is up 21977c478bd9Sstevel@tonic-gate * ill_dlpi_multicast_state ill_lock ill_lock 21987c478bd9Sstevel@tonic-gate * ill_dlpi_fastpath_state ill_lock ill_lock 2199da14cebeSEric Cheng * ill_dlpi_capab_state ipsq ipsq 22007c478bd9Sstevel@tonic-gate * ill_max_hops ipsq Not atomic 22017c478bd9Sstevel@tonic-gate * 22027c478bd9Sstevel@tonic-gate * ill_max_mtu 22037c478bd9Sstevel@tonic-gate * 2204e11c3f44Smeem * ill_user_mtu ipsq + ill_lock ill_lock 22057c478bd9Sstevel@tonic-gate * ill_reachable_time ipsq + ill_lock ill_lock 22067c478bd9Sstevel@tonic-gate * ill_reachable_retrans_time ipsq + ill_lock ill_lock 22077c478bd9Sstevel@tonic-gate * ill_max_buf ipsq + ill_lock ill_lock 22087c478bd9Sstevel@tonic-gate * 22097c478bd9Sstevel@tonic-gate * Next 2 fields need ill_lock because of the get ioctls. They should not 22107c478bd9Sstevel@tonic-gate * report partially updated results without executing in the ipsq. 22117c478bd9Sstevel@tonic-gate * ill_token ipsq + ill_lock ill_lock 22127c478bd9Sstevel@tonic-gate * ill_token_length ipsq + ill_lock ill_lock 22137c478bd9Sstevel@tonic-gate * ill_xmit_count ipsq + down ill write once 22147c478bd9Sstevel@tonic-gate * ill_ip6_mib ipsq + down ill only when ill is up 22157c478bd9Sstevel@tonic-gate * ill_icmp6_mib ipsq + down ill only when ill is up 22167c478bd9Sstevel@tonic-gate * ill_arp_down_mp ipsq ipsq 22177c478bd9Sstevel@tonic-gate * ill_arp_del_mapping_mp ipsq ipsq 22187c478bd9Sstevel@tonic-gate * ill_arp_on_mp ipsq ipsq 22197c478bd9Sstevel@tonic-gate * 22207c478bd9Sstevel@tonic-gate * ill_phyint ipsq, ill_g_lock, ill_lock Any of them 22217c478bd9Sstevel@tonic-gate * ill_flags ill_lock ill_lock 2222b051ecf6Smeem * ill_nd_lla_mp ipsq + down ill only when ill is up 2223b051ecf6Smeem * ill_nd_lla ipsq + down ill only when ill is up 2224b051ecf6Smeem * ill_nd_lla_len ipsq + down ill only when ill is up 22257c478bd9Sstevel@tonic-gate * ill_phys_addr_pend ipsq + down ill only when ill is up 22267c478bd9Sstevel@tonic-gate * ill_ifname_pending_err ipsq ipsq 2227b051ecf6Smeem * ill_avl_byppa ipsq, ill_g_lock write once 22287c478bd9Sstevel@tonic-gate * 22297c478bd9Sstevel@tonic-gate * ill_fastpath_list ill_lock ill_lock 22307c478bd9Sstevel@tonic-gate * ill_refcnt ill_lock ill_lock 2231384ad179Ssowmini * ill_ire_cnt ill_lock ill_lock 22327c478bd9Sstevel@tonic-gate * ill_cv ill_lock ill_lock 22337c478bd9Sstevel@tonic-gate * ill_ilm_walker_cnt ill_lock ill_lock 2234384ad179Ssowmini * ill_nce_cnt ill_lock ill_lock 2235384ad179Ssowmini * ill_ilm_cnt ill_lock ill_lock 2236e11c3f44Smeem * ill_src_ipif ill_g_lock ill_g_lock 22377c478bd9Sstevel@tonic-gate * ill_trace ill_lock ill_lock 22387c478bd9Sstevel@tonic-gate * ill_usesrc_grp_next ill_g_usesrc_lock ill_g_usesrc_lock 2239e704a8f2Smeem * ill_dhcpinit atomics atomics 2240da14cebeSEric Cheng * ill_flownotify_mh write once write once 2241da14cebeSEric Cheng * ill_capab_pending_cnt ipsq ipsq 2242e11c3f44Smeem * 2243e11c3f44Smeem * ill_bound_cnt ipsq ipsq 2244e11c3f44Smeem * ill_bound_ipif ipsq ipsq 2245e11c3f44Smeem * ill_actnode ipsq + ipmp_lock ipsq OR ipmp_lock 2246e11c3f44Smeem * ill_grpnode ipsq + ill_g_lock ipsq OR ill_g_lock 2247e11c3f44Smeem * ill_src_ipif ill_g_lock ill_g_lock 2248e11c3f44Smeem * ill_move_ipif ipsq ipsq 2249e11c3f44Smeem * ill_nom_cast ipsq ipsq OR advisory 2250e11c3f44Smeem * ill_refresh_tid ill_lock ill_lock 2251e11c3f44Smeem * ill_grp (for IPMP ill) write once write once 2252e11c3f44Smeem * ill_grp (for underlying ill) ipsq + ill_g_lock ipsq OR ill_g_lock 2253e11c3f44Smeem * 2254e11c3f44Smeem * NOTE: It's OK to make heuristic decisions on an underlying interface 2255e11c3f44Smeem * by using IS_UNDER_IPMP() or comparing ill_grp's raw pointer value. 22567c478bd9Sstevel@tonic-gate */ 22577c478bd9Sstevel@tonic-gate 22587c478bd9Sstevel@tonic-gate /* 22597c478bd9Sstevel@tonic-gate * For ioctl restart mechanism see ip_reprocess_ioctl() 22607c478bd9Sstevel@tonic-gate */ 22617c478bd9Sstevel@tonic-gate struct ip_ioctl_cmd_s; 22627c478bd9Sstevel@tonic-gate 22637c478bd9Sstevel@tonic-gate typedef int (*ifunc_t)(ipif_t *, struct sockaddr_in *, queue_t *, mblk_t *, 22647c478bd9Sstevel@tonic-gate struct ip_ioctl_cmd_s *, void *); 22657c478bd9Sstevel@tonic-gate 22667c478bd9Sstevel@tonic-gate typedef struct ip_ioctl_cmd_s { 22677c478bd9Sstevel@tonic-gate int ipi_cmd; 22687c478bd9Sstevel@tonic-gate size_t ipi_copyin_size; 22697c478bd9Sstevel@tonic-gate uint_t ipi_flags; 22707c478bd9Sstevel@tonic-gate uint_t ipi_cmd_type; 22717c478bd9Sstevel@tonic-gate ifunc_t ipi_func; 22727c478bd9Sstevel@tonic-gate ifunc_t ipi_func_restart; 22737c478bd9Sstevel@tonic-gate } ip_ioctl_cmd_t; 22747c478bd9Sstevel@tonic-gate 22757c478bd9Sstevel@tonic-gate /* 22767c478bd9Sstevel@tonic-gate * ipi_cmd_type: 22777c478bd9Sstevel@tonic-gate * 22787c478bd9Sstevel@tonic-gate * IF_CMD 1 old style ifreq cmd 22797c478bd9Sstevel@tonic-gate * LIF_CMD 2 new style lifreq cmd 228098e93c29Smeem * TUN_CMD 3 tunnel related 228198e93c29Smeem * ARP_CMD 4 arpreq cmd 228298e93c29Smeem * XARP_CMD 5 xarpreq cmd 228398e93c29Smeem * MSFILT_CMD 6 multicast source filter cmd 228498e93c29Smeem * MISC_CMD 7 misc cmd (not a more specific one above) 22857c478bd9Sstevel@tonic-gate */ 22867c478bd9Sstevel@tonic-gate 228798e93c29Smeem enum { IF_CMD = 1, LIF_CMD, TUN_CMD, ARP_CMD, XARP_CMD, MSFILT_CMD, MISC_CMD }; 22887c478bd9Sstevel@tonic-gate 22897c478bd9Sstevel@tonic-gate #define IPI_DONTCARE 0 /* For ioctl encoded values that don't matter */ 22907c478bd9Sstevel@tonic-gate 22917c478bd9Sstevel@tonic-gate /* Flag values in ipi_flags */ 22927c478bd9Sstevel@tonic-gate #define IPI_PRIV 0x1 /* Root only command */ 22937c478bd9Sstevel@tonic-gate #define IPI_MODOK 0x2 /* Permitted on mod instance of IP */ 22947c478bd9Sstevel@tonic-gate #define IPI_WR 0x4 /* Need to grab writer access */ 22957c478bd9Sstevel@tonic-gate #define IPI_GET_CMD 0x8 /* branch to mi_copyout on success */ 2296e11c3f44Smeem /* unused 0x10 */ 22977c478bd9Sstevel@tonic-gate #define IPI_NULL_BCONT 0x20 /* ioctl has not data and hence no b_cont */ 22987c478bd9Sstevel@tonic-gate #define IPI_PASS_DOWN 0x40 /* pass this ioctl down when a module only */ 22997c478bd9Sstevel@tonic-gate 23007c478bd9Sstevel@tonic-gate extern ip_ioctl_cmd_t ip_ndx_ioctl_table[]; 23017c478bd9Sstevel@tonic-gate extern ip_ioctl_cmd_t ip_misc_ioctl_table[]; 23027c478bd9Sstevel@tonic-gate extern int ip_ndx_ioctl_count; 23037c478bd9Sstevel@tonic-gate extern int ip_misc_ioctl_count; 23047c478bd9Sstevel@tonic-gate 23057c478bd9Sstevel@tonic-gate /* Passed down by ARP to IP during I_PLINK/I_PUNLINK */ 23067c478bd9Sstevel@tonic-gate typedef struct ipmx_s { 23077c478bd9Sstevel@tonic-gate char ipmx_name[LIFNAMSIZ]; /* if name */ 23087c478bd9Sstevel@tonic-gate uint_t 23097c478bd9Sstevel@tonic-gate ipmx_arpdev_stream : 1, /* This is the arp stream */ 23107c478bd9Sstevel@tonic-gate ipmx_notused : 31; 23117c478bd9Sstevel@tonic-gate } ipmx_t; 23127c478bd9Sstevel@tonic-gate 23137c478bd9Sstevel@tonic-gate /* 23147c478bd9Sstevel@tonic-gate * State for detecting if a driver supports certain features. 23157c478bd9Sstevel@tonic-gate * Support for DL_ENABMULTI_REQ uses ill_dlpi_multicast_state. 23167c478bd9Sstevel@tonic-gate * Support for DLPI M_DATA fastpath uses ill_dlpi_fastpath_state. 23177c478bd9Sstevel@tonic-gate */ 23184d876314Sja97890 #define IDS_UNKNOWN 0 /* No DLPI request sent */ 23194d876314Sja97890 #define IDS_INPROGRESS 1 /* DLPI request sent */ 23204d876314Sja97890 #define IDS_OK 2 /* DLPI request completed successfully */ 23214d876314Sja97890 #define IDS_FAILED 3 /* DLPI request failed */ 23227c478bd9Sstevel@tonic-gate 2323da14cebeSEric Cheng /* Support for DL_CAPABILITY_REQ uses ill_dlpi_capab_state. */ 2324da14cebeSEric Cheng enum { 2325da14cebeSEric Cheng IDCS_UNKNOWN, 2326da14cebeSEric Cheng IDCS_PROBE_SENT, 2327da14cebeSEric Cheng IDCS_OK, 2328da14cebeSEric Cheng IDCS_RESET_SENT, 2329da14cebeSEric Cheng IDCS_RENEG, 2330da14cebeSEric Cheng IDCS_FAILED 2331da14cebeSEric Cheng }; 2332da14cebeSEric Cheng 23337c478bd9Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */ 23347c478bd9Sstevel@tonic-gate typedef struct ipparam_s { 23357c478bd9Sstevel@tonic-gate uint_t ip_param_min; 23367c478bd9Sstevel@tonic-gate uint_t ip_param_max; 23377c478bd9Sstevel@tonic-gate uint_t ip_param_value; 23387c478bd9Sstevel@tonic-gate char *ip_param_name; 23397c478bd9Sstevel@tonic-gate } ipparam_t; 23407c478bd9Sstevel@tonic-gate 23417c478bd9Sstevel@tonic-gate /* Extended NDP Management Structure */ 23427c478bd9Sstevel@tonic-gate typedef struct ipndp_s { 23437c478bd9Sstevel@tonic-gate ndgetf_t ip_ndp_getf; 23447c478bd9Sstevel@tonic-gate ndsetf_t ip_ndp_setf; 23457c478bd9Sstevel@tonic-gate caddr_t ip_ndp_data; 23467c478bd9Sstevel@tonic-gate char *ip_ndp_name; 23477c478bd9Sstevel@tonic-gate } ipndp_t; 23487c478bd9Sstevel@tonic-gate 23497c478bd9Sstevel@tonic-gate /* 235045916cd2Sjpk * The kernel stores security attributes of all gateways in a database made 235145916cd2Sjpk * up of one or more tsol_gcdb_t elements. Each tsol_gcdb_t contains the 235245916cd2Sjpk * security-related credentials of the gateway. More than one gateways may 235345916cd2Sjpk * share entries in the database. 235445916cd2Sjpk * 235545916cd2Sjpk * The tsol_gc_t structure represents the gateway to credential association, 235645916cd2Sjpk * and refers to an entry in the database. One or more tsol_gc_t entities are 235745916cd2Sjpk * grouped together to form one or more tsol_gcgrp_t, each representing the 235845916cd2Sjpk * list of security attributes specific to the gateway. A gateway may be 235945916cd2Sjpk * associated with at most one credentials group. 236045916cd2Sjpk */ 236145916cd2Sjpk struct tsol_gcgrp_s; 236245916cd2Sjpk 236345916cd2Sjpk extern uchar_t ip6opt_ls; /* TX IPv6 enabler */ 236445916cd2Sjpk 236545916cd2Sjpk /* 236645916cd2Sjpk * Gateway security credential record. 236745916cd2Sjpk */ 236845916cd2Sjpk typedef struct tsol_gcdb_s { 236945916cd2Sjpk uint_t gcdb_refcnt; /* reference count */ 237045916cd2Sjpk struct rtsa_s gcdb_attr; /* security attributes */ 237145916cd2Sjpk #define gcdb_mask gcdb_attr.rtsa_mask 237245916cd2Sjpk #define gcdb_doi gcdb_attr.rtsa_doi 237345916cd2Sjpk #define gcdb_slrange gcdb_attr.rtsa_slrange 237445916cd2Sjpk } tsol_gcdb_t; 237545916cd2Sjpk 237645916cd2Sjpk /* 237745916cd2Sjpk * Gateway to credential association. 237845916cd2Sjpk */ 237945916cd2Sjpk typedef struct tsol_gc_s { 238045916cd2Sjpk uint_t gc_refcnt; /* reference count */ 238145916cd2Sjpk struct tsol_gcgrp_s *gc_grp; /* pointer to group */ 238245916cd2Sjpk struct tsol_gc_s *gc_prev; /* previous in list */ 238345916cd2Sjpk struct tsol_gc_s *gc_next; /* next in list */ 238445916cd2Sjpk tsol_gcdb_t *gc_db; /* pointer to actual credentials */ 238545916cd2Sjpk } tsol_gc_t; 238645916cd2Sjpk 238745916cd2Sjpk /* 238845916cd2Sjpk * Gateway credentials group address. 238945916cd2Sjpk */ 239045916cd2Sjpk typedef struct tsol_gcgrp_addr_s { 239145916cd2Sjpk int ga_af; /* address family */ 239245916cd2Sjpk in6_addr_t ga_addr; /* IPv4 mapped or IPv6 address */ 239345916cd2Sjpk } tsol_gcgrp_addr_t; 239445916cd2Sjpk 239545916cd2Sjpk /* 239645916cd2Sjpk * Gateway credentials group. 239745916cd2Sjpk */ 239845916cd2Sjpk typedef struct tsol_gcgrp_s { 239945916cd2Sjpk uint_t gcgrp_refcnt; /* reference count */ 240045916cd2Sjpk krwlock_t gcgrp_rwlock; /* lock to protect following */ 240145916cd2Sjpk uint_t gcgrp_count; /* number of credentials */ 240245916cd2Sjpk tsol_gc_t *gcgrp_head; /* first credential in list */ 240345916cd2Sjpk tsol_gc_t *gcgrp_tail; /* last credential in list */ 240445916cd2Sjpk tsol_gcgrp_addr_t gcgrp_addr; /* next-hop gateway address */ 240545916cd2Sjpk } tsol_gcgrp_t; 240645916cd2Sjpk 240745916cd2Sjpk extern kmutex_t gcgrp_lock; 240845916cd2Sjpk 240945916cd2Sjpk #define GC_REFRELE(p) { \ 241045916cd2Sjpk ASSERT((p)->gc_grp != NULL); \ 241145916cd2Sjpk rw_enter(&(p)->gc_grp->gcgrp_rwlock, RW_WRITER); \ 241245916cd2Sjpk ASSERT((p)->gc_refcnt > 0); \ 241345916cd2Sjpk if (--((p)->gc_refcnt) == 0) \ 241445916cd2Sjpk gc_inactive(p); \ 241545916cd2Sjpk else \ 241645916cd2Sjpk rw_exit(&(p)->gc_grp->gcgrp_rwlock); \ 241745916cd2Sjpk } 241845916cd2Sjpk 241945916cd2Sjpk #define GCGRP_REFHOLD(p) { \ 242045916cd2Sjpk mutex_enter(&gcgrp_lock); \ 242145916cd2Sjpk ++((p)->gcgrp_refcnt); \ 242245916cd2Sjpk ASSERT((p)->gcgrp_refcnt != 0); \ 242345916cd2Sjpk mutex_exit(&gcgrp_lock); \ 242445916cd2Sjpk } 242545916cd2Sjpk 242645916cd2Sjpk #define GCGRP_REFRELE(p) { \ 242745916cd2Sjpk mutex_enter(&gcgrp_lock); \ 242845916cd2Sjpk ASSERT((p)->gcgrp_refcnt > 0); \ 242945916cd2Sjpk if (--((p)->gcgrp_refcnt) == 0) \ 243045916cd2Sjpk gcgrp_inactive(p); \ 243145916cd2Sjpk ASSERT(MUTEX_HELD(&gcgrp_lock)); \ 243245916cd2Sjpk mutex_exit(&gcgrp_lock); \ 243345916cd2Sjpk } 243445916cd2Sjpk 243545916cd2Sjpk /* 243645916cd2Sjpk * IRE gateway security attributes structure, pointed to by tsol_ire_gw_secattr 243745916cd2Sjpk */ 243845916cd2Sjpk struct tsol_tnrhc; 243945916cd2Sjpk 244045916cd2Sjpk typedef struct tsol_ire_gw_secattr_s { 244145916cd2Sjpk kmutex_t igsa_lock; /* lock to protect following */ 244245916cd2Sjpk struct tsol_tnrhc *igsa_rhc; /* host entry for gateway */ 244345916cd2Sjpk tsol_gc_t *igsa_gc; /* for prefix IREs */ 244445916cd2Sjpk tsol_gcgrp_t *igsa_gcgrp; /* for cache IREs */ 244545916cd2Sjpk } tsol_ire_gw_secattr_t; 244645916cd2Sjpk 244745916cd2Sjpk /* 24487c478bd9Sstevel@tonic-gate * Following are the macros to increment/decrement the reference 24497c478bd9Sstevel@tonic-gate * count of the IREs and IRBs (ire bucket). 24507c478bd9Sstevel@tonic-gate * 24517c478bd9Sstevel@tonic-gate * 1) We bump up the reference count of an IRE to make sure that 24527c478bd9Sstevel@tonic-gate * it does not get deleted and freed while we are using it. 24537c478bd9Sstevel@tonic-gate * Typically all the lookup functions hold the bucket lock, 24547c478bd9Sstevel@tonic-gate * and look for the IRE. If it finds an IRE, it bumps up the 24557c478bd9Sstevel@tonic-gate * reference count before dropping the lock. Sometimes we *may* want 24567c478bd9Sstevel@tonic-gate * to bump up the reference count after we *looked* up i.e without 24577c478bd9Sstevel@tonic-gate * holding the bucket lock. So, the IRE_REFHOLD macro does not assert 24587c478bd9Sstevel@tonic-gate * on the bucket lock being held. Any thread trying to delete from 24597c478bd9Sstevel@tonic-gate * the hash bucket can still do so but cannot free the IRE if 24607c478bd9Sstevel@tonic-gate * ire_refcnt is not 0. 24617c478bd9Sstevel@tonic-gate * 24627c478bd9Sstevel@tonic-gate * 2) We bump up the reference count on the bucket where the IRE resides 24637c478bd9Sstevel@tonic-gate * (IRB), when we want to prevent the IREs getting deleted from a given 24647c478bd9Sstevel@tonic-gate * hash bucket. This makes life easier for ire_walk type functions which 24657c478bd9Sstevel@tonic-gate * wants to walk the IRE list, call a function, but needs to drop 24667c478bd9Sstevel@tonic-gate * the bucket lock to prevent recursive rw_enters. While the 24677c478bd9Sstevel@tonic-gate * lock is dropped, the list could be changed by other threads or 24687c478bd9Sstevel@tonic-gate * the same thread could end up deleting the ire or the ire pointed by 24697c478bd9Sstevel@tonic-gate * ire_next. IRE_REFHOLDing the ire or ire_next is not sufficient as 24707c478bd9Sstevel@tonic-gate * a delete will still remove the ire from the bucket while we have 24717c478bd9Sstevel@tonic-gate * dropped the lock and hence the ire_next would be NULL. Thus, we 24727c478bd9Sstevel@tonic-gate * need a mechanism to prevent deletions from a given bucket. 24737c478bd9Sstevel@tonic-gate * 24747c478bd9Sstevel@tonic-gate * To prevent deletions, we bump up the reference count on the 24757c478bd9Sstevel@tonic-gate * bucket. If the bucket is held, ire_delete just marks IRE_MARK_CONDEMNED 24767c478bd9Sstevel@tonic-gate * both on the ire's ire_marks and the bucket's irb_marks. When the 24777c478bd9Sstevel@tonic-gate * reference count on the bucket drops to zero, all the CONDEMNED ires 24787c478bd9Sstevel@tonic-gate * are deleted. We don't have to bump up the reference count on the 24797c478bd9Sstevel@tonic-gate * bucket if we are walking the bucket and never have to drop the bucket 24807c478bd9Sstevel@tonic-gate * lock. Note that IRB_REFHOLD does not prevent addition of new ires 24817c478bd9Sstevel@tonic-gate * in the list. It is okay because addition of new ires will not cause 24827c478bd9Sstevel@tonic-gate * ire_next to point to freed memory. We do IRB_REFHOLD only when 24837c478bd9Sstevel@tonic-gate * all of the 3 conditions are true : 24847c478bd9Sstevel@tonic-gate * 24857c478bd9Sstevel@tonic-gate * 1) The code needs to walk the IRE bucket from start to end. 24867c478bd9Sstevel@tonic-gate * 2) It may have to drop the bucket lock sometimes while doing (1) 24877c478bd9Sstevel@tonic-gate * 3) It does not want any ires to be deleted meanwhile. 24887c478bd9Sstevel@tonic-gate */ 24897c478bd9Sstevel@tonic-gate 24907c478bd9Sstevel@tonic-gate /* 24917c478bd9Sstevel@tonic-gate * Bump up the reference count on the IRE. We cannot assert that the 24927c478bd9Sstevel@tonic-gate * bucket lock is being held as it is legal to bump up the reference 24937c478bd9Sstevel@tonic-gate * count after the first lookup has returned the IRE without 24947c478bd9Sstevel@tonic-gate * holding the lock. Currently ip_wput does this for caching IRE_CACHEs. 24957c478bd9Sstevel@tonic-gate */ 24967c478bd9Sstevel@tonic-gate 24976a8288c7Scarlsonj #ifdef DEBUG 24986a8288c7Scarlsonj #define IRE_UNTRACE_REF(ire) ire_untrace_ref(ire); 24996a8288c7Scarlsonj #define IRE_TRACE_REF(ire) ire_trace_ref(ire); 25006a8288c7Scarlsonj #else 25017c478bd9Sstevel@tonic-gate #define IRE_UNTRACE_REF(ire) 25027c478bd9Sstevel@tonic-gate #define IRE_TRACE_REF(ire) 25036a8288c7Scarlsonj #endif 25047c478bd9Sstevel@tonic-gate 25057c478bd9Sstevel@tonic-gate #define IRE_REFHOLD_NOTR(ire) { \ 25067c478bd9Sstevel@tonic-gate atomic_add_32(&(ire)->ire_refcnt, 1); \ 25077c478bd9Sstevel@tonic-gate ASSERT((ire)->ire_refcnt != 0); \ 25087c478bd9Sstevel@tonic-gate } 25097c478bd9Sstevel@tonic-gate 25107c478bd9Sstevel@tonic-gate #define IRE_REFHOLD(ire) { \ 25116a8288c7Scarlsonj IRE_REFHOLD_NOTR(ire); \ 25127c478bd9Sstevel@tonic-gate IRE_TRACE_REF(ire); \ 25137c478bd9Sstevel@tonic-gate } 25147c478bd9Sstevel@tonic-gate 25157c478bd9Sstevel@tonic-gate #define IRE_REFHOLD_LOCKED(ire) { \ 25167c478bd9Sstevel@tonic-gate IRE_TRACE_REF(ire); \ 25177c478bd9Sstevel@tonic-gate (ire)->ire_refcnt++; \ 25187c478bd9Sstevel@tonic-gate } 25197c478bd9Sstevel@tonic-gate 25207c478bd9Sstevel@tonic-gate /* 25217c478bd9Sstevel@tonic-gate * Decrement the reference count on the IRE. 25227c478bd9Sstevel@tonic-gate * In architectures e.g sun4u, where atomic_add_32_nv is just 25237c478bd9Sstevel@tonic-gate * a cas, we need to maintain the right memory barrier semantics 25247c478bd9Sstevel@tonic-gate * as that of mutex_exit i.e all the loads and stores should complete 25257c478bd9Sstevel@tonic-gate * before the cas is executed. membar_exit() does that here. 25267c478bd9Sstevel@tonic-gate * 25277c478bd9Sstevel@tonic-gate * NOTE : This macro is used only in places where we want performance. 25287c478bd9Sstevel@tonic-gate * To avoid bloating the code, we use the function "ire_refrele" 25297c478bd9Sstevel@tonic-gate * which essentially calls the macro. 25307c478bd9Sstevel@tonic-gate */ 25317c478bd9Sstevel@tonic-gate #define IRE_REFRELE_NOTR(ire) { \ 25327c478bd9Sstevel@tonic-gate ASSERT((ire)->ire_refcnt != 0); \ 25337c478bd9Sstevel@tonic-gate membar_exit(); \ 25347c478bd9Sstevel@tonic-gate if (atomic_add_32_nv(&(ire)->ire_refcnt, -1) == 0) \ 25357c478bd9Sstevel@tonic-gate ire_inactive(ire); \ 25367c478bd9Sstevel@tonic-gate } 25376a8288c7Scarlsonj 25386a8288c7Scarlsonj #define IRE_REFRELE(ire) { \ 25396a8288c7Scarlsonj if (ire->ire_bucket != NULL) { \ 25406a8288c7Scarlsonj IRE_UNTRACE_REF(ire); \ 25416a8288c7Scarlsonj } \ 25426a8288c7Scarlsonj IRE_REFRELE_NOTR(ire); \ 25436a8288c7Scarlsonj } 25447c478bd9Sstevel@tonic-gate 25457c478bd9Sstevel@tonic-gate /* 25467c478bd9Sstevel@tonic-gate * Bump up the reference count on the hash bucket - IRB to 25477c478bd9Sstevel@tonic-gate * prevent ires from being deleted in this bucket. 25487c478bd9Sstevel@tonic-gate */ 25497c478bd9Sstevel@tonic-gate #define IRB_REFHOLD(irb) { \ 25507c478bd9Sstevel@tonic-gate rw_enter(&(irb)->irb_lock, RW_WRITER); \ 25517c478bd9Sstevel@tonic-gate (irb)->irb_refcnt++; \ 25527c478bd9Sstevel@tonic-gate ASSERT((irb)->irb_refcnt != 0); \ 25537c478bd9Sstevel@tonic-gate rw_exit(&(irb)->irb_lock); \ 25547c478bd9Sstevel@tonic-gate } 2555c793af95Ssangeeta #define IRB_REFHOLD_LOCKED(irb) { \ 2556c793af95Ssangeeta ASSERT(RW_WRITE_HELD(&(irb)->irb_lock)); \ 2557c793af95Ssangeeta (irb)->irb_refcnt++; \ 2558c793af95Ssangeeta ASSERT((irb)->irb_refcnt != 0); \ 2559c793af95Ssangeeta } 25607c478bd9Sstevel@tonic-gate 2561c793af95Ssangeeta void irb_refrele_ftable(irb_t *); 2562c793af95Ssangeeta /* 2563c793af95Ssangeeta * Note: when IRB_MARK_FTABLE (i.e., IRE_CACHETABLE entry), the irb_t 2564c793af95Ssangeeta * is statically allocated, so that when the irb_refcnt goes to 0, 2565c793af95Ssangeeta * we simply clean up the ire list and continue. 2566c793af95Ssangeeta */ 25677c478bd9Sstevel@tonic-gate #define IRB_REFRELE(irb) { \ 2568c793af95Ssangeeta if ((irb)->irb_marks & IRB_MARK_FTABLE) { \ 2569c793af95Ssangeeta irb_refrele_ftable((irb)); \ 2570c793af95Ssangeeta } else { \ 25717c478bd9Sstevel@tonic-gate rw_enter(&(irb)->irb_lock, RW_WRITER); \ 25727c478bd9Sstevel@tonic-gate ASSERT((irb)->irb_refcnt != 0); \ 25737c478bd9Sstevel@tonic-gate if (--(irb)->irb_refcnt == 0 && \ 25747c478bd9Sstevel@tonic-gate ((irb)->irb_marks & IRE_MARK_CONDEMNED)) { \ 25757c478bd9Sstevel@tonic-gate ire_t *ire_list; \ 25767c478bd9Sstevel@tonic-gate \ 25777c478bd9Sstevel@tonic-gate ire_list = ire_unlink(irb); \ 25787c478bd9Sstevel@tonic-gate rw_exit(&(irb)->irb_lock); \ 25797c478bd9Sstevel@tonic-gate ASSERT(ire_list != NULL); \ 25807c478bd9Sstevel@tonic-gate ire_cleanup(ire_list); \ 25817c478bd9Sstevel@tonic-gate } else { \ 25827c478bd9Sstevel@tonic-gate rw_exit(&(irb)->irb_lock); \ 25837c478bd9Sstevel@tonic-gate } \ 2584c793af95Ssangeeta } \ 25857c478bd9Sstevel@tonic-gate } 25867c478bd9Sstevel@tonic-gate 2587c793af95Ssangeeta extern struct kmem_cache *rt_entry_cache; 2588c793af95Ssangeeta 25897c478bd9Sstevel@tonic-gate /* 2590c793af95Ssangeeta * Lock the fast path mp for access, since the fp_mp can be deleted 25915c0b7edeSseb * due a DL_NOTE_FASTPATH_FLUSH in the case of IRE_BROADCAST 25927c478bd9Sstevel@tonic-gate */ 25937c478bd9Sstevel@tonic-gate 25947c478bd9Sstevel@tonic-gate #define LOCK_IRE_FP_MP(ire) { \ 25955c0b7edeSseb if ((ire)->ire_type == IRE_BROADCAST) \ 2596c793af95Ssangeeta mutex_enter(&ire->ire_nce->nce_lock); \ 25977c478bd9Sstevel@tonic-gate } 25987c478bd9Sstevel@tonic-gate #define UNLOCK_IRE_FP_MP(ire) { \ 25995c0b7edeSseb if ((ire)->ire_type == IRE_BROADCAST) \ 2600c793af95Ssangeeta mutex_exit(&ire->ire_nce->nce_lock); \ 26017c478bd9Sstevel@tonic-gate } 26027c478bd9Sstevel@tonic-gate 26037c478bd9Sstevel@tonic-gate typedef struct ire4 { 26047c478bd9Sstevel@tonic-gate ipaddr_t ire4_src_addr; /* Source address to use. */ 26057c478bd9Sstevel@tonic-gate ipaddr_t ire4_mask; /* Mask for matching this IRE. */ 26067c478bd9Sstevel@tonic-gate ipaddr_t ire4_addr; /* Address this IRE represents. */ 26077c478bd9Sstevel@tonic-gate ipaddr_t ire4_gateway_addr; /* Gateway if IRE_CACHE/IRE_OFFSUBNET */ 26087c478bd9Sstevel@tonic-gate ipaddr_t ire4_cmask; /* Mask from parent prefix route */ 26097c478bd9Sstevel@tonic-gate } ire4_t; 26107c478bd9Sstevel@tonic-gate 26117c478bd9Sstevel@tonic-gate typedef struct ire6 { 26127c478bd9Sstevel@tonic-gate in6_addr_t ire6_src_addr; /* Source address to use. */ 26137c478bd9Sstevel@tonic-gate in6_addr_t ire6_mask; /* Mask for matching this IRE. */ 26147c478bd9Sstevel@tonic-gate in6_addr_t ire6_addr; /* Address this IRE represents. */ 26157c478bd9Sstevel@tonic-gate in6_addr_t ire6_gateway_addr; /* Gateway if IRE_CACHE/IRE_OFFSUBNET */ 26167c478bd9Sstevel@tonic-gate in6_addr_t ire6_cmask; /* Mask from parent prefix route */ 26177c478bd9Sstevel@tonic-gate } ire6_t; 26187c478bd9Sstevel@tonic-gate 26197c478bd9Sstevel@tonic-gate typedef union ire_addr { 26207c478bd9Sstevel@tonic-gate ire6_t ire6_u; 26217c478bd9Sstevel@tonic-gate ire4_t ire4_u; 26227c478bd9Sstevel@tonic-gate } ire_addr_u_t; 26237c478bd9Sstevel@tonic-gate 26247c478bd9Sstevel@tonic-gate /* Internet Routing Entry */ 26257c478bd9Sstevel@tonic-gate typedef struct ire_s { 26267c478bd9Sstevel@tonic-gate struct ire_s *ire_next; /* The hash chain must be first. */ 26277c478bd9Sstevel@tonic-gate struct ire_s **ire_ptpn; /* Pointer to previous next. */ 26287c478bd9Sstevel@tonic-gate uint32_t ire_refcnt; /* Number of references */ 26297c478bd9Sstevel@tonic-gate mblk_t *ire_mp; /* Non-null if allocated as mblk */ 26307c478bd9Sstevel@tonic-gate queue_t *ire_rfq; /* recv from this queue */ 26317c478bd9Sstevel@tonic-gate queue_t *ire_stq; /* send to this queue */ 26327c478bd9Sstevel@tonic-gate union { 26337c478bd9Sstevel@tonic-gate uint_t *max_fragp; /* Used only during ire creation */ 26347c478bd9Sstevel@tonic-gate uint_t max_frag; /* MTU (next hop or path). */ 26357c478bd9Sstevel@tonic-gate } imf_u; 26367c478bd9Sstevel@tonic-gate #define ire_max_frag imf_u.max_frag 26377c478bd9Sstevel@tonic-gate #define ire_max_fragp imf_u.max_fragp 26387c478bd9Sstevel@tonic-gate uint32_t ire_frag_flag; /* IPH_DF or zero. */ 26397c478bd9Sstevel@tonic-gate uint32_t ire_ident; /* Per IRE IP ident. */ 26407c478bd9Sstevel@tonic-gate uint32_t ire_tire_mark; /* Used for reclaim of unused. */ 26417c478bd9Sstevel@tonic-gate uchar_t ire_ipversion; /* IPv4/IPv6 version */ 26427c478bd9Sstevel@tonic-gate uchar_t ire_marks; /* IRE_MARK_CONDEMNED etc. */ 26437c478bd9Sstevel@tonic-gate ushort_t ire_type; /* Type of IRE */ 26447c478bd9Sstevel@tonic-gate uint_t ire_ib_pkt_count; /* Inbound packets for ire_addr */ 26457c478bd9Sstevel@tonic-gate uint_t ire_ob_pkt_count; /* Outbound packets to ire_addr */ 26467c478bd9Sstevel@tonic-gate uint_t ire_ll_hdr_length; /* Non-zero if we do M_DATA prepends */ 26477c478bd9Sstevel@tonic-gate time_t ire_create_time; /* Time (in secs) IRE was created. */ 26487c478bd9Sstevel@tonic-gate uint32_t ire_phandle; /* Associate prefix IREs to cache */ 26497c478bd9Sstevel@tonic-gate uint32_t ire_ihandle; /* Associate interface IREs to cache */ 26507c478bd9Sstevel@tonic-gate ipif_t *ire_ipif; /* the interface that this ire uses */ 26517c478bd9Sstevel@tonic-gate uint32_t ire_flags; /* flags related to route (RTF_*) */ 26527c478bd9Sstevel@tonic-gate uint_t ire_ipsec_overhead; /* IPSEC overhead */ 2653c793af95Ssangeeta /* 2654c793af95Ssangeeta * Neighbor Cache Entry for IPv6; arp info for IPv4 2655c793af95Ssangeeta */ 2656c793af95Ssangeeta struct nce_s *ire_nce; 26577c478bd9Sstevel@tonic-gate uint_t ire_masklen; /* # bits in ire_mask{,_v6} */ 26587c478bd9Sstevel@tonic-gate ire_addr_u_t ire_u; /* IPv4/IPv6 address info. */ 26597c478bd9Sstevel@tonic-gate 26607c478bd9Sstevel@tonic-gate irb_t *ire_bucket; /* Hash bucket when ire_ptphn is set */ 26617c478bd9Sstevel@tonic-gate iulp_t ire_uinfo; /* Upper layer protocol info. */ 26627c478bd9Sstevel@tonic-gate /* 26637c478bd9Sstevel@tonic-gate * Protects ire_uinfo, ire_max_frag, and ire_frag_flag. 26647c478bd9Sstevel@tonic-gate */ 26657c478bd9Sstevel@tonic-gate kmutex_t ire_lock; 26667c478bd9Sstevel@tonic-gate uint_t ire_ipif_seqid; /* ipif_seqid of ire_ipif */ 26675b17e9bdSJon Anderson uint_t ire_ipif_ifindex; /* ifindex associated with ipif */ 26687c478bd9Sstevel@tonic-gate clock_t ire_last_used_time; /* Last used time */ 266945916cd2Sjpk tsol_ire_gw_secattr_t *ire_gw_secattr; /* gateway security attributes */ 267069bb4bb4Scarlsonj zoneid_t ire_zoneid; /* for local address discrimination */ 2671c793af95Ssangeeta /* 2672c793af95Ssangeeta * ire's that are embedded inside mblk_t and sent to the external 2673c793af95Ssangeeta * resolver use the ire_stq_ifindex to track the ifindex of the 2674c793af95Ssangeeta * ire_stq, so that the ill (if it exists) can be correctly recovered 26751bf5e2aeSSowmini Varadhan * for cleanup in the esbfree routine when arp failure occurs. 26761bf5e2aeSSowmini Varadhan * Similarly, the ire_stackid is used to recover the ip_stack_t. 2677c793af95Ssangeeta */ 2678c793af95Ssangeeta uint_t ire_stq_ifindex; 26791bf5e2aeSSowmini Varadhan netstackid_t ire_stackid; 268069bb4bb4Scarlsonj uint_t ire_defense_count; /* number of ARP conflicts */ 268169bb4bb4Scarlsonj uint_t ire_defense_time; /* last time defended (secs) */ 268269bb4bb4Scarlsonj boolean_t ire_trace_disable; /* True when alloc fails */ 26836a8288c7Scarlsonj ip_stack_t *ire_ipst; /* Does not have a netstack_hold */ 26847c478bd9Sstevel@tonic-gate } ire_t; 26857c478bd9Sstevel@tonic-gate 26867924222fSmeem /* IPv4 compatibility macros */ 26877c478bd9Sstevel@tonic-gate #define ire_src_addr ire_u.ire4_u.ire4_src_addr 26887c478bd9Sstevel@tonic-gate #define ire_mask ire_u.ire4_u.ire4_mask 26897c478bd9Sstevel@tonic-gate #define ire_addr ire_u.ire4_u.ire4_addr 26907c478bd9Sstevel@tonic-gate #define ire_gateway_addr ire_u.ire4_u.ire4_gateway_addr 26917c478bd9Sstevel@tonic-gate #define ire_cmask ire_u.ire4_u.ire4_cmask 26927c478bd9Sstevel@tonic-gate 26937c478bd9Sstevel@tonic-gate #define ire_src_addr_v6 ire_u.ire6_u.ire6_src_addr 26947c478bd9Sstevel@tonic-gate #define ire_mask_v6 ire_u.ire6_u.ire6_mask 26957c478bd9Sstevel@tonic-gate #define ire_addr_v6 ire_u.ire6_u.ire6_addr 26967c478bd9Sstevel@tonic-gate #define ire_gateway_addr_v6 ire_u.ire6_u.ire6_gateway_addr 26977c478bd9Sstevel@tonic-gate #define ire_cmask_v6 ire_u.ire6_u.ire6_cmask 26987c478bd9Sstevel@tonic-gate 26997c478bd9Sstevel@tonic-gate /* Convenient typedefs for sockaddrs */ 27007c478bd9Sstevel@tonic-gate typedef struct sockaddr_in sin_t; 27017c478bd9Sstevel@tonic-gate typedef struct sockaddr_in6 sin6_t; 27027c478bd9Sstevel@tonic-gate 27037c478bd9Sstevel@tonic-gate /* Address structure used for internal bind with IP */ 27047c478bd9Sstevel@tonic-gate typedef struct ipa_conn_s { 27057c478bd9Sstevel@tonic-gate ipaddr_t ac_laddr; 27067c478bd9Sstevel@tonic-gate ipaddr_t ac_faddr; 27077c478bd9Sstevel@tonic-gate uint16_t ac_fport; 27087c478bd9Sstevel@tonic-gate uint16_t ac_lport; 27097c478bd9Sstevel@tonic-gate } ipa_conn_t; 27107c478bd9Sstevel@tonic-gate 27117c478bd9Sstevel@tonic-gate typedef struct ipa6_conn_s { 27127c478bd9Sstevel@tonic-gate in6_addr_t ac6_laddr; 27137c478bd9Sstevel@tonic-gate in6_addr_t ac6_faddr; 27147c478bd9Sstevel@tonic-gate uint16_t ac6_fport; 27157c478bd9Sstevel@tonic-gate uint16_t ac6_lport; 27167c478bd9Sstevel@tonic-gate } ipa6_conn_t; 27177c478bd9Sstevel@tonic-gate 27187c478bd9Sstevel@tonic-gate /* 27197c478bd9Sstevel@tonic-gate * Using ipa_conn_x_t or ipa6_conn_x_t allows us to modify the behavior of IP's 27207c478bd9Sstevel@tonic-gate * bind handler. 27217c478bd9Sstevel@tonic-gate */ 27227c478bd9Sstevel@tonic-gate typedef struct ipa_conn_extended_s { 27237c478bd9Sstevel@tonic-gate uint64_t acx_flags; 27247c478bd9Sstevel@tonic-gate ipa_conn_t acx_conn; 27257c478bd9Sstevel@tonic-gate } ipa_conn_x_t; 27267c478bd9Sstevel@tonic-gate 27277c478bd9Sstevel@tonic-gate typedef struct ipa6_conn_extended_s { 27287c478bd9Sstevel@tonic-gate uint64_t ac6x_flags; 27297c478bd9Sstevel@tonic-gate ipa6_conn_t ac6x_conn; 27307c478bd9Sstevel@tonic-gate } ipa6_conn_x_t; 27317c478bd9Sstevel@tonic-gate 27327c478bd9Sstevel@tonic-gate /* flag values for ipa_conn_x_t and ipa6_conn_x_t. */ 27337c478bd9Sstevel@tonic-gate #define ACX_VERIFY_DST 0x1ULL /* verify destination address is reachable */ 27347c478bd9Sstevel@tonic-gate 27357c478bd9Sstevel@tonic-gate /* Name/Value Descriptor. */ 27367c478bd9Sstevel@tonic-gate typedef struct nv_s { 27377c478bd9Sstevel@tonic-gate uint64_t nv_value; 27387c478bd9Sstevel@tonic-gate char *nv_name; 27397c478bd9Sstevel@tonic-gate } nv_t; 27407c478bd9Sstevel@tonic-gate 27417c478bd9Sstevel@tonic-gate #define ILL_FRAG_HASH(s, i) \ 27427c478bd9Sstevel@tonic-gate ((ntohl(s) ^ ((i) ^ ((i) >> 8))) % ILL_FRAG_HASH_TBL_COUNT) 27437c478bd9Sstevel@tonic-gate 27447c478bd9Sstevel@tonic-gate /* 27457c478bd9Sstevel@tonic-gate * The MAX number of allowed fragmented packets per hash bucket 27467c478bd9Sstevel@tonic-gate * calculation is based on the most common mtu size of 1500. This limit 27477c478bd9Sstevel@tonic-gate * will work well for other mtu sizes as well. 27487c478bd9Sstevel@tonic-gate */ 27497c478bd9Sstevel@tonic-gate #define COMMON_IP_MTU 1500 27507c478bd9Sstevel@tonic-gate #define MAX_FRAG_MIN 10 2751f4b3ec61Sdh155122 #define MAX_FRAG_PKTS(ipst) \ 2752f4b3ec61Sdh155122 MAX(MAX_FRAG_MIN, (2 * (ipst->ips_ip_reass_queue_bytes / \ 27537c478bd9Sstevel@tonic-gate (COMMON_IP_MTU * ILL_FRAG_HASH_TBL_COUNT)))) 27547c478bd9Sstevel@tonic-gate 27557c478bd9Sstevel@tonic-gate /* 27567c478bd9Sstevel@tonic-gate * Maximum dups allowed per packet. 27577c478bd9Sstevel@tonic-gate */ 27587c478bd9Sstevel@tonic-gate extern uint_t ip_max_frag_dups; 27597c478bd9Sstevel@tonic-gate 27607c478bd9Sstevel@tonic-gate /* 27617c478bd9Sstevel@tonic-gate * Per-packet information for received packets and transmitted. 27627c478bd9Sstevel@tonic-gate * Used by the transport protocols when converting between the packet 27637c478bd9Sstevel@tonic-gate * and ancillary data and socket options. 27647c478bd9Sstevel@tonic-gate * 27657c478bd9Sstevel@tonic-gate * Note: This private data structure and related IPPF_* constant 27667c478bd9Sstevel@tonic-gate * definitions are exposed to enable compilation of some debugging tools 27677c478bd9Sstevel@tonic-gate * like lsof which use struct tcp_t in <inet/tcp.h>. This is intended to be 27687c478bd9Sstevel@tonic-gate * a temporary hack and long term alternate interfaces should be defined 27697c478bd9Sstevel@tonic-gate * to support the needs of such tools and private definitions moved to 27707c478bd9Sstevel@tonic-gate * private headers. 27717c478bd9Sstevel@tonic-gate */ 27727c478bd9Sstevel@tonic-gate struct ip6_pkt_s { 27737c478bd9Sstevel@tonic-gate uint_t ipp_fields; /* Which fields are valid */ 27747c478bd9Sstevel@tonic-gate uint_t ipp_sticky_ignored; /* sticky fields to ignore */ 27757c478bd9Sstevel@tonic-gate uint_t ipp_ifindex; /* pktinfo ifindex */ 27767c478bd9Sstevel@tonic-gate in6_addr_t ipp_addr; /* pktinfo src/dst addr */ 2777b3d0fa4fSseb uint_t ipp_unicast_hops; /* IPV6_UNICAST_HOPS */ 2778b3d0fa4fSseb uint_t ipp_multicast_hops; /* IPV6_MULTICAST_HOPS */ 2779b3d0fa4fSseb uint_t ipp_hoplimit; /* IPV6_HOPLIMIT */ 27807c478bd9Sstevel@tonic-gate uint_t ipp_hopoptslen; 27817c478bd9Sstevel@tonic-gate uint_t ipp_rtdstoptslen; 27827c478bd9Sstevel@tonic-gate uint_t ipp_rthdrlen; 27837c478bd9Sstevel@tonic-gate uint_t ipp_dstoptslen; 27847c478bd9Sstevel@tonic-gate uint_t ipp_pathmtulen; 27858810c16bSdanmcd uint_t ipp_fraghdrlen; 27867c478bd9Sstevel@tonic-gate ip6_hbh_t *ipp_hopopts; 27877c478bd9Sstevel@tonic-gate ip6_dest_t *ipp_rtdstopts; 27887c478bd9Sstevel@tonic-gate ip6_rthdr_t *ipp_rthdr; 27897c478bd9Sstevel@tonic-gate ip6_dest_t *ipp_dstopts; 27908810c16bSdanmcd ip6_frag_t *ipp_fraghdr; 27917c478bd9Sstevel@tonic-gate struct ip6_mtuinfo *ipp_pathmtu; 27927c478bd9Sstevel@tonic-gate in6_addr_t ipp_nexthop; /* Transmit only */ 27937c478bd9Sstevel@tonic-gate uint8_t ipp_tclass; 27947c478bd9Sstevel@tonic-gate int8_t ipp_use_min_mtu; 27957c478bd9Sstevel@tonic-gate }; 27967c478bd9Sstevel@tonic-gate typedef struct ip6_pkt_s ip6_pkt_t; 27977c478bd9Sstevel@tonic-gate 279845916cd2Sjpk extern void ip6_pkt_free(ip6_pkt_t *); /* free storage inside ip6_pkt_t */ 279945916cd2Sjpk 28007c478bd9Sstevel@tonic-gate /* 280119a30e1aSrshoaib * This struct is used by ULP_opt_set() functions to return value of IPv4 280219a30e1aSrshoaib * ancillary options. Currently this is only used by udp and icmp and only 280319a30e1aSrshoaib * IP_PKTINFO option is supported. 28047c478bd9Sstevel@tonic-gate */ 280519a30e1aSrshoaib typedef struct ip4_pkt_s { 280619a30e1aSrshoaib uint_t ip4_ill_index; /* interface index */ 280719a30e1aSrshoaib ipaddr_t ip4_addr; /* source address */ 280819a30e1aSrshoaib } ip4_pkt_t; 280919a30e1aSrshoaib 281019a30e1aSrshoaib /* 281119a30e1aSrshoaib * Used by ULP's to pass options info to ip_output 281219a30e1aSrshoaib * currently only IP_PKTINFO is supported. 281319a30e1aSrshoaib */ 281419a30e1aSrshoaib typedef struct ip_opt_info_s { 281519a30e1aSrshoaib uint_t ip_opt_ill_index; 281619a30e1aSrshoaib uint_t ip_opt_flags; 281719a30e1aSrshoaib } ip_opt_info_t; 281819a30e1aSrshoaib 281919a30e1aSrshoaib /* 282019a30e1aSrshoaib * value for ip_opt_flags 282119a30e1aSrshoaib */ 282219a30e1aSrshoaib #define IP_VERIFY_SRC 0x1 282319a30e1aSrshoaib 282419a30e1aSrshoaib /* 282519a30e1aSrshoaib * This structure is used to convey information from IP and the ULP. 282619a30e1aSrshoaib * Currently used for the IP_RECVSLLA, IP_RECVIF and IP_RECVPKTINFO options. 282719a30e1aSrshoaib * The type of information field is set to IN_PKTINFO (i.e inbound pkt info) 282819a30e1aSrshoaib */ 282919a30e1aSrshoaib typedef struct ip_pktinfo { 283019a30e1aSrshoaib uint32_t ip_pkt_ulp_type; /* type of info sent */ 283119a30e1aSrshoaib uint32_t ip_pkt_flags; /* what is sent up by IP */ 283219a30e1aSrshoaib uint32_t ip_pkt_ifindex; /* inbound interface index */ 283319a30e1aSrshoaib struct sockaddr_dl ip_pkt_slla; /* has source link layer addr */ 283419a30e1aSrshoaib struct in_addr ip_pkt_match_addr; /* matched address */ 283519a30e1aSrshoaib } ip_pktinfo_t; 28367c478bd9Sstevel@tonic-gate 28377c478bd9Sstevel@tonic-gate /* 283845916cd2Sjpk * flags to tell UDP what IP is sending; in_pkt_flags 28397c478bd9Sstevel@tonic-gate */ 28407c478bd9Sstevel@tonic-gate #define IPF_RECVIF 0x01 /* inbound interface index */ 28417c478bd9Sstevel@tonic-gate #define IPF_RECVSLLA 0x02 /* source link layer address */ 284219a30e1aSrshoaib /* 284319a30e1aSrshoaib * Inbound interface index + matched address. 284419a30e1aSrshoaib * Used only by IPV4. 284519a30e1aSrshoaib */ 284619a30e1aSrshoaib #define IPF_RECVADDR 0x04 28477c478bd9Sstevel@tonic-gate 28487c478bd9Sstevel@tonic-gate /* ipp_fields values */ 28497c478bd9Sstevel@tonic-gate #define IPPF_IFINDEX 0x0001 /* Part of in6_pktinfo: ifindex */ 28507c478bd9Sstevel@tonic-gate #define IPPF_ADDR 0x0002 /* Part of in6_pktinfo: src/dst addr */ 28517c478bd9Sstevel@tonic-gate #define IPPF_SCOPE_ID 0x0004 /* Add xmit ip6i_t for sin6_scope_id */ 28527c478bd9Sstevel@tonic-gate #define IPPF_NO_CKSUM 0x0008 /* Add xmit ip6i_t for IP6I_NO_*_CKSUM */ 28537c478bd9Sstevel@tonic-gate 28547c478bd9Sstevel@tonic-gate #define IPPF_RAW_CKSUM 0x0010 /* Add xmit ip6i_t for IP6I_RAW_CHECKSUM */ 28557c478bd9Sstevel@tonic-gate #define IPPF_HOPLIMIT 0x0020 28567c478bd9Sstevel@tonic-gate #define IPPF_HOPOPTS 0x0040 28577c478bd9Sstevel@tonic-gate #define IPPF_RTHDR 0x0080 28587c478bd9Sstevel@tonic-gate 28597c478bd9Sstevel@tonic-gate #define IPPF_RTDSTOPTS 0x0100 28607c478bd9Sstevel@tonic-gate #define IPPF_DSTOPTS 0x0200 28617c478bd9Sstevel@tonic-gate #define IPPF_NEXTHOP 0x0400 28627c478bd9Sstevel@tonic-gate #define IPPF_PATHMTU 0x0800 28637c478bd9Sstevel@tonic-gate 28647c478bd9Sstevel@tonic-gate #define IPPF_TCLASS 0x1000 28657c478bd9Sstevel@tonic-gate #define IPPF_DONTFRAG 0x2000 2866b3d0fa4fSseb #define IPPF_USE_MIN_MTU 0x04000 2867b3d0fa4fSseb #define IPPF_MULTICAST_HOPS 0x08000 28688810c16bSdanmcd 2869b3d0fa4fSseb #define IPPF_UNICAST_HOPS 0x10000 28708810c16bSdanmcd #define IPPF_FRAGHDR 0x20000 28717c478bd9Sstevel@tonic-gate 28727c478bd9Sstevel@tonic-gate #define IPPF_HAS_IP6I \ 28737c478bd9Sstevel@tonic-gate (IPPF_IFINDEX|IPPF_ADDR|IPPF_NEXTHOP|IPPF_SCOPE_ID| \ 28747c478bd9Sstevel@tonic-gate IPPF_NO_CKSUM|IPPF_RAW_CKSUM|IPPF_HOPLIMIT|IPPF_DONTFRAG| \ 2875b3d0fa4fSseb IPPF_USE_MIN_MTU|IPPF_MULTICAST_HOPS|IPPF_UNICAST_HOPS) 28767c478bd9Sstevel@tonic-gate 28777c478bd9Sstevel@tonic-gate #define TCP_PORTS_OFFSET 0 28787c478bd9Sstevel@tonic-gate #define UDP_PORTS_OFFSET 0 28797c478bd9Sstevel@tonic-gate 28807c478bd9Sstevel@tonic-gate /* 28817c478bd9Sstevel@tonic-gate * lookups return the ill/ipif only if the flags are clear OR Iam writer. 28827c478bd9Sstevel@tonic-gate * ill / ipif lookup functions increment the refcnt on the ill / ipif only 28837c478bd9Sstevel@tonic-gate * after calling these macros. This ensures that the refcnt on the ipif or 28847c478bd9Sstevel@tonic-gate * ill will eventually drop down to zero. 28857c478bd9Sstevel@tonic-gate */ 28867c478bd9Sstevel@tonic-gate #define ILL_LOOKUP_FAILED 1 /* Used as error code */ 28877c478bd9Sstevel@tonic-gate #define IPIF_LOOKUP_FAILED 2 /* Used as error code */ 28887c478bd9Sstevel@tonic-gate 28897c478bd9Sstevel@tonic-gate #define ILL_CAN_LOOKUP(ill) \ 28907c478bd9Sstevel@tonic-gate (!((ill)->ill_state_flags & (ILL_CONDEMNED | ILL_CHANGING)) || \ 28917c478bd9Sstevel@tonic-gate IAM_WRITER_ILL(ill)) 28927c478bd9Sstevel@tonic-gate 28937c478bd9Sstevel@tonic-gate #define ILL_CAN_WAIT(ill, q) \ 28947c478bd9Sstevel@tonic-gate (((q) != NULL) && !((ill)->ill_state_flags & (ILL_CONDEMNED))) 28957c478bd9Sstevel@tonic-gate 28967c478bd9Sstevel@tonic-gate #define IPIF_CAN_LOOKUP(ipif) \ 28977c478bd9Sstevel@tonic-gate (!((ipif)->ipif_state_flags & (IPIF_CONDEMNED | IPIF_CHANGING)) || \ 28987c478bd9Sstevel@tonic-gate IAM_WRITER_IPIF(ipif)) 28997c478bd9Sstevel@tonic-gate 29007c478bd9Sstevel@tonic-gate /* 29017c478bd9Sstevel@tonic-gate * If the parameter 'q' is NULL, the caller is not interested in wait and 29027c478bd9Sstevel@tonic-gate * restart of the operation if the ILL or IPIF cannot be looked up when it is 29037c478bd9Sstevel@tonic-gate * marked as 'CHANGING'. Typically a thread that tries to send out data will 29047c478bd9Sstevel@tonic-gate * end up passing NULLs as the last 4 parameters to ill_lookup_on_ifindex and 29057c478bd9Sstevel@tonic-gate * in this case 'q' is NULL 29067c478bd9Sstevel@tonic-gate */ 29077c478bd9Sstevel@tonic-gate #define IPIF_CAN_WAIT(ipif, q) \ 29087c478bd9Sstevel@tonic-gate (((q) != NULL) && !((ipif)->ipif_state_flags & (IPIF_CONDEMNED))) 29097c478bd9Sstevel@tonic-gate 29107c478bd9Sstevel@tonic-gate #define IPIF_CAN_LOOKUP_WALKER(ipif) \ 29117c478bd9Sstevel@tonic-gate (!((ipif)->ipif_state_flags & (IPIF_CONDEMNED)) || \ 29127c478bd9Sstevel@tonic-gate IAM_WRITER_IPIF(ipif)) 29137c478bd9Sstevel@tonic-gate 29147c478bd9Sstevel@tonic-gate #define ILL_UNMARK_CHANGING(ill) \ 29157c478bd9Sstevel@tonic-gate (ill)->ill_state_flags &= ~ILL_CHANGING; 29167c478bd9Sstevel@tonic-gate 29177c478bd9Sstevel@tonic-gate /* Macros used to assert that this thread is a writer */ 2918e11c3f44Smeem #define IAM_WRITER_IPSQ(ipsq) ((ipsq)->ipsq_xop->ipx_writer == curthread) 29197924222fSmeem #define IAM_WRITER_ILL(ill) IAM_WRITER_IPSQ((ill)->ill_phyint->phyint_ipsq) 29207924222fSmeem #define IAM_WRITER_IPIF(ipif) IAM_WRITER_ILL((ipif)->ipif_ill) 29217c478bd9Sstevel@tonic-gate 29227c478bd9Sstevel@tonic-gate /* 29237c478bd9Sstevel@tonic-gate * Grab ill locks in the proper order. The order is highest addressed 29247c478bd9Sstevel@tonic-gate * ill is locked first. 29257c478bd9Sstevel@tonic-gate */ 29267c478bd9Sstevel@tonic-gate #define GRAB_ILL_LOCKS(ill_1, ill_2) \ 29277c478bd9Sstevel@tonic-gate { \ 29287c478bd9Sstevel@tonic-gate if ((ill_1) > (ill_2)) { \ 29297c478bd9Sstevel@tonic-gate if (ill_1 != NULL) \ 29307c478bd9Sstevel@tonic-gate mutex_enter(&(ill_1)->ill_lock); \ 29317c478bd9Sstevel@tonic-gate if (ill_2 != NULL) \ 29327c478bd9Sstevel@tonic-gate mutex_enter(&(ill_2)->ill_lock); \ 29337c478bd9Sstevel@tonic-gate } else { \ 29347c478bd9Sstevel@tonic-gate if (ill_2 != NULL) \ 29357c478bd9Sstevel@tonic-gate mutex_enter(&(ill_2)->ill_lock); \ 29367c478bd9Sstevel@tonic-gate if (ill_1 != NULL && ill_1 != ill_2) \ 29377c478bd9Sstevel@tonic-gate mutex_enter(&(ill_1)->ill_lock); \ 29387c478bd9Sstevel@tonic-gate } \ 29397c478bd9Sstevel@tonic-gate } 29407c478bd9Sstevel@tonic-gate 29417c478bd9Sstevel@tonic-gate #define RELEASE_ILL_LOCKS(ill_1, ill_2) \ 29427c478bd9Sstevel@tonic-gate { \ 29437c478bd9Sstevel@tonic-gate if (ill_1 != NULL) \ 29447c478bd9Sstevel@tonic-gate mutex_exit(&(ill_1)->ill_lock); \ 29457c478bd9Sstevel@tonic-gate if (ill_2 != NULL && ill_2 != ill_1) \ 29467c478bd9Sstevel@tonic-gate mutex_exit(&(ill_2)->ill_lock); \ 29477c478bd9Sstevel@tonic-gate } 29487c478bd9Sstevel@tonic-gate 29497c478bd9Sstevel@tonic-gate /* Get the other protocol instance ill */ 29507c478bd9Sstevel@tonic-gate #define ILL_OTHER(ill) \ 29517c478bd9Sstevel@tonic-gate ((ill)->ill_isv6 ? (ill)->ill_phyint->phyint_illv4 : \ 29527c478bd9Sstevel@tonic-gate (ill)->ill_phyint->phyint_illv6) 29537c478bd9Sstevel@tonic-gate 29547c478bd9Sstevel@tonic-gate /* ioctl command info: Ioctl properties extracted and stored in here */ 29557c478bd9Sstevel@tonic-gate typedef struct cmd_info_s 29567c478bd9Sstevel@tonic-gate { 29577c478bd9Sstevel@tonic-gate ipif_t *ci_ipif; /* ipif associated with [l]ifreq ioctl's */ 29587c478bd9Sstevel@tonic-gate sin_t *ci_sin; /* the sin struct passed down */ 29597c478bd9Sstevel@tonic-gate sin6_t *ci_sin6; /* the sin6_t struct passed down */ 29607c478bd9Sstevel@tonic-gate struct lifreq *ci_lifr; /* the lifreq struct passed down */ 29617c478bd9Sstevel@tonic-gate } cmd_info_t; 29627c478bd9Sstevel@tonic-gate 2963f4b3ec61Sdh155122 /* 2964f4b3ec61Sdh155122 * List of AH and ESP IPsec acceleration capable ills 2965f4b3ec61Sdh155122 */ 2966f4b3ec61Sdh155122 typedef struct ipsec_capab_ill_s { 2967f4b3ec61Sdh155122 uint_t ill_index; 2968f4b3ec61Sdh155122 boolean_t ill_isv6; 2969f4b3ec61Sdh155122 struct ipsec_capab_ill_s *next; 2970f4b3ec61Sdh155122 } ipsec_capab_ill_t; 29717c478bd9Sstevel@tonic-gate 29727c478bd9Sstevel@tonic-gate extern struct kmem_cache *ire_cache; 29737c478bd9Sstevel@tonic-gate 29747c478bd9Sstevel@tonic-gate extern ipaddr_t ip_g_all_ones; 29757c478bd9Sstevel@tonic-gate 2976f4b3ec61Sdh155122 extern uint_t ip_loopback_mtu; /* /etc/system */ 29777c478bd9Sstevel@tonic-gate 2978aa92d85bSgt145670 extern vmem_t *ip_minor_arena_sa; 2979aa92d85bSgt145670 extern vmem_t *ip_minor_arena_la; 29807c478bd9Sstevel@tonic-gate 2981f4b3ec61Sdh155122 /* 2982f4b3ec61Sdh155122 * ip_g_forward controls IP forwarding. It takes two values: 2983f4b3ec61Sdh155122 * 0: IP_FORWARD_NEVER Don't forward packets ever. 2984f4b3ec61Sdh155122 * 1: IP_FORWARD_ALWAYS Forward packets for elsewhere. 2985f4b3ec61Sdh155122 * 2986f4b3ec61Sdh155122 * RFC1122 says there must be a configuration switch to control forwarding, 2987f4b3ec61Sdh155122 * but that the default MUST be to not forward packets ever. Implicit 2988f4b3ec61Sdh155122 * control based on configuration of multiple interfaces MUST NOT be 2989f4b3ec61Sdh155122 * implemented (Section 3.1). SunOS 4.1 did provide the "automatic" capability 2990f4b3ec61Sdh155122 * and, in fact, it was the default. That capability is now provided in the 2991f4b3ec61Sdh155122 * /etc/rc2.d/S69inet script. 2992f4b3ec61Sdh155122 */ 2993f4b3ec61Sdh155122 2994f4b3ec61Sdh155122 #define ips_ip_respond_to_address_mask_broadcast ips_param_arr[0].ip_param_value 2995f4b3ec61Sdh155122 #define ips_ip_g_resp_to_echo_bcast ips_param_arr[1].ip_param_value 2996f4b3ec61Sdh155122 #define ips_ip_g_resp_to_echo_mcast ips_param_arr[2].ip_param_value 2997f4b3ec61Sdh155122 #define ips_ip_g_resp_to_timestamp ips_param_arr[3].ip_param_value 2998f4b3ec61Sdh155122 #define ips_ip_g_resp_to_timestamp_bcast ips_param_arr[4].ip_param_value 2999f4b3ec61Sdh155122 #define ips_ip_g_send_redirects ips_param_arr[5].ip_param_value 3000f4b3ec61Sdh155122 #define ips_ip_g_forward_directed_bcast ips_param_arr[6].ip_param_value 3001ae43f94fSnordmark #define ips_ip_mrtdebug ips_param_arr[7].ip_param_value 3002ae43f94fSnordmark #define ips_ip_timer_interval ips_param_arr[8].ip_param_value 3003ae43f94fSnordmark #define ips_ip_ire_arp_interval ips_param_arr[9].ip_param_value 3004ae43f94fSnordmark #define ips_ip_ire_redir_interval ips_param_arr[10].ip_param_value 3005ae43f94fSnordmark #define ips_ip_def_ttl ips_param_arr[11].ip_param_value 3006ae43f94fSnordmark #define ips_ip_forward_src_routed ips_param_arr[12].ip_param_value 3007ae43f94fSnordmark #define ips_ip_wroff_extra ips_param_arr[13].ip_param_value 3008ae43f94fSnordmark #define ips_ip_ire_pathmtu_interval ips_param_arr[14].ip_param_value 3009ae43f94fSnordmark #define ips_ip_icmp_return ips_param_arr[15].ip_param_value 3010ae43f94fSnordmark #define ips_ip_path_mtu_discovery ips_param_arr[16].ip_param_value 3011ae43f94fSnordmark #define ips_ip_ignore_delete_time ips_param_arr[17].ip_param_value 3012ae43f94fSnordmark #define ips_ip_ignore_redirect ips_param_arr[18].ip_param_value 3013ae43f94fSnordmark #define ips_ip_output_queue ips_param_arr[19].ip_param_value 3014ae43f94fSnordmark #define ips_ip_broadcast_ttl ips_param_arr[20].ip_param_value 3015ae43f94fSnordmark #define ips_ip_icmp_err_interval ips_param_arr[21].ip_param_value 3016ae43f94fSnordmark #define ips_ip_icmp_err_burst ips_param_arr[22].ip_param_value 3017ae43f94fSnordmark #define ips_ip_reass_queue_bytes ips_param_arr[23].ip_param_value 3018ae43f94fSnordmark #define ips_ip_strict_dst_multihoming ips_param_arr[24].ip_param_value 3019ae43f94fSnordmark #define ips_ip_addrs_per_if ips_param_arr[25].ip_param_value 3020ae43f94fSnordmark #define ips_ipsec_override_persocket_policy ips_param_arr[26].ip_param_value 3021ae43f94fSnordmark #define ips_icmp_accept_clear_messages ips_param_arr[27].ip_param_value 3022ae43f94fSnordmark #define ips_igmp_accept_clear_messages ips_param_arr[28].ip_param_value 302369bb4bb4Scarlsonj 302469bb4bb4Scarlsonj /* IPv6 configuration knobs */ 3025ae43f94fSnordmark #define ips_delay_first_probe_time ips_param_arr[29].ip_param_value 3026ae43f94fSnordmark #define ips_max_unicast_solicit ips_param_arr[30].ip_param_value 3027ae43f94fSnordmark #define ips_ipv6_def_hops ips_param_arr[31].ip_param_value 3028ae43f94fSnordmark #define ips_ipv6_icmp_return ips_param_arr[32].ip_param_value 3029ae43f94fSnordmark #define ips_ipv6_forward_src_routed ips_param_arr[33].ip_param_value 3030ae43f94fSnordmark #define ips_ipv6_resp_echo_mcast ips_param_arr[34].ip_param_value 3031ae43f94fSnordmark #define ips_ipv6_send_redirects ips_param_arr[35].ip_param_value 3032ae43f94fSnordmark #define ips_ipv6_ignore_redirect ips_param_arr[36].ip_param_value 3033ae43f94fSnordmark #define ips_ipv6_strict_dst_multihoming ips_param_arr[37].ip_param_value 3034ae43f94fSnordmark #define ips_ip_ire_reclaim_fraction ips_param_arr[38].ip_param_value 3035ae43f94fSnordmark #define ips_ipsec_policy_log_interval ips_param_arr[39].ip_param_value 3036ae43f94fSnordmark #define ips_pim_accept_clear_messages ips_param_arr[40].ip_param_value 3037ae43f94fSnordmark #define ips_ip_ndp_unsolicit_interval ips_param_arr[41].ip_param_value 3038ae43f94fSnordmark #define ips_ip_ndp_unsolicit_count ips_param_arr[42].ip_param_value 3039ae43f94fSnordmark #define ips_ipv6_ignore_home_address_opt ips_param_arr[43].ip_param_value 304016c9d76cSKacheong Poon 304116c9d76cSKacheong Poon /* Misc IP configuration knobs */ 3042ae43f94fSnordmark #define ips_ip_policy_mask ips_param_arr[44].ip_param_value 3043ae43f94fSnordmark #define ips_ip_multirt_resolution_interval ips_param_arr[45].ip_param_value 3044ae43f94fSnordmark #define ips_ip_multirt_ttl ips_param_arr[46].ip_param_value 3045ae43f94fSnordmark #define ips_ip_multidata_outbound ips_param_arr[47].ip_param_value 3046ae43f94fSnordmark #define ips_ip_ndp_defense_interval ips_param_arr[48].ip_param_value 3047ae43f94fSnordmark #define ips_ip_max_temp_idle ips_param_arr[49].ip_param_value 3048ae43f94fSnordmark #define ips_ip_max_temp_defend ips_param_arr[50].ip_param_value 3049ae43f94fSnordmark #define ips_ip_max_defend ips_param_arr[51].ip_param_value 3050ae43f94fSnordmark #define ips_ip_defend_interval ips_param_arr[52].ip_param_value 3051ae43f94fSnordmark #define ips_ip_dup_recovery ips_param_arr[53].ip_param_value 3052ae43f94fSnordmark #define ips_ip_restrict_interzone_loopback ips_param_arr[54].ip_param_value 3053ae43f94fSnordmark #define ips_ip_lso_outbound ips_param_arr[55].ip_param_value 3054ae43f94fSnordmark #define ips_igmp_max_version ips_param_arr[56].ip_param_value 3055ae43f94fSnordmark #define ips_mld_max_version ips_param_arr[57].ip_param_value 305616c9d76cSKacheong Poon #define ips_ip_pmtu_min ips_param_arr[58].ip_param_value 305716c9d76cSKacheong Poon #define ips_ipv6_drop_inbound_icmpv6 ips_param_arr[59].ip_param_value 30587c478bd9Sstevel@tonic-gate 30597c478bd9Sstevel@tonic-gate extern int dohwcksum; /* use h/w cksum if supported by the h/w */ 30607c478bd9Sstevel@tonic-gate #ifdef ZC_TEST 30617c478bd9Sstevel@tonic-gate extern int noswcksum; 30627c478bd9Sstevel@tonic-gate #endif 30637c478bd9Sstevel@tonic-gate 30647c478bd9Sstevel@tonic-gate extern char ipif_loopback_name[]; 30657c478bd9Sstevel@tonic-gate 30667c478bd9Sstevel@tonic-gate extern nv_t *ire_nv_tbl; 30677c478bd9Sstevel@tonic-gate 30687c478bd9Sstevel@tonic-gate extern struct module_info ip_mod_info; 30697c478bd9Sstevel@tonic-gate 3070f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_PHYSICAL_IN(ipst) \ 3071f4b3ec61Sdh155122 ((ipst)->ips_ip4_physical_in_event.he_interested) 3072f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_PHYSICAL_IN(ipst) \ 3073f4b3ec61Sdh155122 ((ipst)->ips_ip6_physical_in_event.he_interested) 3074f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_PHYSICAL_OUT(ipst) \ 3075f4b3ec61Sdh155122 ((ipst)->ips_ip4_physical_out_event.he_interested) 3076f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_PHYSICAL_OUT(ipst) \ 3077f4b3ec61Sdh155122 ((ipst)->ips_ip6_physical_out_event.he_interested) 3078f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_FORWARDING(ipst) \ 3079f4b3ec61Sdh155122 ((ipst)->ips_ip4_forwarding_event.he_interested) 3080f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_FORWARDING(ipst) \ 3081f4b3ec61Sdh155122 ((ipst)->ips_ip6_forwarding_event.he_interested) 3082f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_LOOPBACK_IN(ipst) \ 3083f4b3ec61Sdh155122 ((ipst)->ips_ip4_loopback_in_event.he_interested) 3084f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_LOOPBACK_IN(ipst) \ 3085f4b3ec61Sdh155122 ((ipst)->ips_ip6_loopback_in_event.he_interested) 3086f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_LOOPBACK_OUT(ipst) \ 3087f4b3ec61Sdh155122 ((ipst)->ips_ip4_loopback_out_event.he_interested) 3088f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_LOOPBACK_OUT(ipst) \ 3089f4b3ec61Sdh155122 ((ipst)->ips_ip6_loopback_out_event.he_interested) 3090381a2a9aSdr146992 3091381a2a9aSdr146992 /* 3092e11c3f44Smeem * Hooks macros used inside of ip 3093381a2a9aSdr146992 */ 30941b47e080Sdr146992 #define FW_HOOKS(_hook, _event, _ilp, _olp, _iph, _fm, _m, _llm, ipst) \ 3095381a2a9aSdr146992 \ 3096381a2a9aSdr146992 if ((_hook).he_interested) { \ 3097381a2a9aSdr146992 hook_pkt_event_t info; \ 3098381a2a9aSdr146992 \ 3099381a2a9aSdr146992 _NOTE(CONSTCOND) \ 3100381a2a9aSdr146992 ASSERT((_ilp != NULL) || (_olp != NULL)); \ 3101381a2a9aSdr146992 \ 3102e11c3f44Smeem FW_SET_ILL_INDEX(info.hpe_ifp, (ill_t *)_ilp); \ 3103e11c3f44Smeem FW_SET_ILL_INDEX(info.hpe_ofp, (ill_t *)_olp); \ 31047ddc9b1aSDarren Reed info.hpe_protocol = ipst->ips_ipv4_net_data; \ 3105381a2a9aSdr146992 info.hpe_hdr = _iph; \ 3106381a2a9aSdr146992 info.hpe_mp = &(_fm); \ 3107381a2a9aSdr146992 info.hpe_mb = _m; \ 31081b47e080Sdr146992 info.hpe_flags = _llm; \ 31097ddc9b1aSDarren Reed if (hook_run(ipst->ips_ipv4_net_data->netd_hooks, \ 31107ddc9b1aSDarren Reed _event, (hook_data_t)&info) != 0) { \ 3111381a2a9aSdr146992 ip2dbg(("%s hook dropped mblk chain %p hdr %p\n",\ 3112381a2a9aSdr146992 (_hook).he_name, (void *)_fm, (void *)_m)); \ 3113381a2a9aSdr146992 freemsg(_fm); \ 3114381a2a9aSdr146992 _fm = NULL; \ 3115381a2a9aSdr146992 _iph = NULL; \ 3116381a2a9aSdr146992 _m = NULL; \ 3117381a2a9aSdr146992 } else { \ 3118381a2a9aSdr146992 _iph = info.hpe_hdr; \ 3119381a2a9aSdr146992 _m = info.hpe_mb; \ 3120381a2a9aSdr146992 } \ 3121381a2a9aSdr146992 } 3122381a2a9aSdr146992 31231b47e080Sdr146992 #define FW_HOOKS6(_hook, _event, _ilp, _olp, _iph, _fm, _m, _llm, ipst) \ 3124381a2a9aSdr146992 \ 3125381a2a9aSdr146992 if ((_hook).he_interested) { \ 3126381a2a9aSdr146992 hook_pkt_event_t info; \ 3127381a2a9aSdr146992 \ 3128381a2a9aSdr146992 _NOTE(CONSTCOND) \ 3129381a2a9aSdr146992 ASSERT((_ilp != NULL) || (_olp != NULL)); \ 3130381a2a9aSdr146992 \ 3131e11c3f44Smeem FW_SET_ILL_INDEX(info.hpe_ifp, (ill_t *)_ilp); \ 3132e11c3f44Smeem FW_SET_ILL_INDEX(info.hpe_ofp, (ill_t *)_olp); \ 31337ddc9b1aSDarren Reed info.hpe_protocol = ipst->ips_ipv6_net_data; \ 3134381a2a9aSdr146992 info.hpe_hdr = _iph; \ 3135381a2a9aSdr146992 info.hpe_mp = &(_fm); \ 3136381a2a9aSdr146992 info.hpe_mb = _m; \ 31371b47e080Sdr146992 info.hpe_flags = _llm; \ 31387ddc9b1aSDarren Reed if (hook_run(ipst->ips_ipv6_net_data->netd_hooks, \ 31397ddc9b1aSDarren Reed _event, (hook_data_t)&info) != 0) { \ 3140381a2a9aSdr146992 ip2dbg(("%s hook dropped mblk chain %p hdr %p\n",\ 3141381a2a9aSdr146992 (_hook).he_name, (void *)_fm, (void *)_m)); \ 3142381a2a9aSdr146992 freemsg(_fm); \ 3143381a2a9aSdr146992 _fm = NULL; \ 3144381a2a9aSdr146992 _iph = NULL; \ 3145381a2a9aSdr146992 _m = NULL; \ 3146381a2a9aSdr146992 } else { \ 3147381a2a9aSdr146992 _iph = info.hpe_hdr; \ 3148381a2a9aSdr146992 _m = info.hpe_mb; \ 3149381a2a9aSdr146992 } \ 3150381a2a9aSdr146992 } 3151381a2a9aSdr146992 3152e11c3f44Smeem #define FW_SET_ILL_INDEX(fp, ill) \ 3153e11c3f44Smeem _NOTE(CONSTCOND) \ 3154e11c3f44Smeem if ((ill) == NULL || (ill)->ill_phyint == NULL) { \ 3155e11c3f44Smeem (fp) = 0; \ 3156e11c3f44Smeem _NOTE(CONSTCOND) \ 3157e11c3f44Smeem } else if (IS_UNDER_IPMP(ill)) { \ 3158e11c3f44Smeem (fp) = ipmp_ill_get_ipmp_ifindex(ill); \ 3159e11c3f44Smeem } else { \ 3160e11c3f44Smeem (fp) = (ill)->ill_phyint->phyint_ifindex; \ 3161e11c3f44Smeem } 3162e11c3f44Smeem 3163381a2a9aSdr146992 /* 31647c478bd9Sstevel@tonic-gate * Network byte order macros 31657c478bd9Sstevel@tonic-gate */ 31667c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 31672a9459bdSsangeeta #define N_IN_CLASSA_NET IN_CLASSA_NET 31687c478bd9Sstevel@tonic-gate #define N_IN_CLASSD_NET IN_CLASSD_NET 31697c478bd9Sstevel@tonic-gate #define N_INADDR_UNSPEC_GROUP INADDR_UNSPEC_GROUP 31702a9459bdSsangeeta #define N_IN_LOOPBACK_NET (ipaddr_t)0x7f000000U 31717c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */ 31722a9459bdSsangeeta #define N_IN_CLASSA_NET (ipaddr_t)0x000000ffU 31737c478bd9Sstevel@tonic-gate #define N_IN_CLASSD_NET (ipaddr_t)0x000000f0U 31747c478bd9Sstevel@tonic-gate #define N_INADDR_UNSPEC_GROUP (ipaddr_t)0x000000e0U 31752a9459bdSsangeeta #define N_IN_LOOPBACK_NET (ipaddr_t)0x0000007fU 31767c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */ 31777c478bd9Sstevel@tonic-gate #define CLASSD(addr) (((addr) & N_IN_CLASSD_NET) == N_INADDR_UNSPEC_GROUP) 31782a9459bdSsangeeta #define CLASSE(addr) (((addr) & N_IN_CLASSD_NET) == N_IN_CLASSD_NET) 3179c793af95Ssangeeta #define IP_LOOPBACK_ADDR(addr) \ 31802a9459bdSsangeeta (((addr) & N_IN_CLASSA_NET == N_IN_LOOPBACK_NET)) 3181c793af95Ssangeeta 31827c478bd9Sstevel@tonic-gate #ifdef DEBUG 31837c478bd9Sstevel@tonic-gate /* IPsec HW acceleration debugging support */ 31847c478bd9Sstevel@tonic-gate 31857c478bd9Sstevel@tonic-gate #define IPSECHW_CAPAB 0x0001 /* capability negotiation */ 31867c478bd9Sstevel@tonic-gate #define IPSECHW_SADB 0x0002 /* SADB exchange */ 31877c478bd9Sstevel@tonic-gate #define IPSECHW_PKT 0x0004 /* general packet flow */ 31887c478bd9Sstevel@tonic-gate #define IPSECHW_PKTIN 0x0008 /* driver in pkt processing details */ 31897c478bd9Sstevel@tonic-gate #define IPSECHW_PKTOUT 0x0010 /* driver out pkt processing details */ 31907c478bd9Sstevel@tonic-gate 31917c478bd9Sstevel@tonic-gate #define IPSECHW_DEBUG(f, x) if (ipsechw_debug & (f)) { (void) printf x; } 31927c478bd9Sstevel@tonic-gate #define IPSECHW_CALL(f, r, x) if (ipsechw_debug & (f)) { (void) r x; } 31937c478bd9Sstevel@tonic-gate 31947c478bd9Sstevel@tonic-gate extern uint32_t ipsechw_debug; 31957c478bd9Sstevel@tonic-gate #else 31967c478bd9Sstevel@tonic-gate #define IPSECHW_DEBUG(f, x) {} 31977c478bd9Sstevel@tonic-gate #define IPSECHW_CALL(f, r, x) {} 31987c478bd9Sstevel@tonic-gate #endif 31997c478bd9Sstevel@tonic-gate 3200f4b3ec61Sdh155122 extern int ip_debug; 32016a8288c7Scarlsonj extern uint_t ip_thread_data; 32026a8288c7Scarlsonj extern krwlock_t ip_thread_rwlock; 32036a8288c7Scarlsonj extern list_t ip_thread_list; 3204f4b3ec61Sdh155122 32057c478bd9Sstevel@tonic-gate #ifdef IP_DEBUG 32067c478bd9Sstevel@tonic-gate #include <sys/debug.h> 32077c478bd9Sstevel@tonic-gate #include <sys/promif.h> 32087c478bd9Sstevel@tonic-gate 32097c478bd9Sstevel@tonic-gate #define ip0dbg(a) printf a 32107c478bd9Sstevel@tonic-gate #define ip1dbg(a) if (ip_debug > 2) printf a 32117c478bd9Sstevel@tonic-gate #define ip2dbg(a) if (ip_debug > 3) printf a 32127c478bd9Sstevel@tonic-gate #define ip3dbg(a) if (ip_debug > 4) printf a 32137c478bd9Sstevel@tonic-gate #else 32147c478bd9Sstevel@tonic-gate #define ip0dbg(a) /* */ 32157c478bd9Sstevel@tonic-gate #define ip1dbg(a) /* */ 32167c478bd9Sstevel@tonic-gate #define ip2dbg(a) /* */ 32177c478bd9Sstevel@tonic-gate #define ip3dbg(a) /* */ 32187c478bd9Sstevel@tonic-gate #endif /* IP_DEBUG */ 32197c478bd9Sstevel@tonic-gate 322069bb4bb4Scarlsonj /* Default MAC-layer address string length for mac_colon_addr */ 322169bb4bb4Scarlsonj #define MAC_STR_LEN 128 322269bb4bb4Scarlsonj 3223c793af95Ssangeeta struct ipsec_out_s; 3224c793af95Ssangeeta 3225605445d5Sdg199075 struct mac_header_info_s; 3226605445d5Sdg199075 32277c478bd9Sstevel@tonic-gate extern void ill_frag_timer(void *); 3228f4b3ec61Sdh155122 extern ill_t *ill_first(int, int, ill_walk_context_t *, ip_stack_t *); 32297c478bd9Sstevel@tonic-gate extern ill_t *ill_next(ill_walk_context_t *, ill_t *); 32307c478bd9Sstevel@tonic-gate extern void ill_frag_timer_start(ill_t *); 3231b127ac41SPhilip Kirk extern void ill_nic_event_dispatch(ill_t *, lif_if_t, nic_event_t, 3232b127ac41SPhilip Kirk nic_event_data_t, size_t); 32337c478bd9Sstevel@tonic-gate extern mblk_t *ip_carve_mp(mblk_t **, ssize_t); 32347c478bd9Sstevel@tonic-gate extern mblk_t *ip_dlpi_alloc(size_t, t_uscalar_t); 3235e11c3f44Smeem extern mblk_t *ip_dlnotify_alloc(uint_t, uint_t); 32367c478bd9Sstevel@tonic-gate extern char *ip_dot_addr(ipaddr_t, char *); 323769bb4bb4Scarlsonj extern const char *mac_colon_addr(const uint8_t *, size_t, char *, size_t); 32387c478bd9Sstevel@tonic-gate extern void ip_lwput(queue_t *, mblk_t *); 3239f4b3ec61Sdh155122 extern boolean_t icmp_err_rate_limit(ip_stack_t *); 3240f4b3ec61Sdh155122 extern void icmp_time_exceeded(queue_t *, mblk_t *, uint8_t, zoneid_t, 3241f4b3ec61Sdh155122 ip_stack_t *); 3242f4b3ec61Sdh155122 extern void icmp_unreachable(queue_t *, mblk_t *, uint8_t, zoneid_t, 3243f4b3ec61Sdh155122 ip_stack_t *); 3244f4b3ec61Sdh155122 extern mblk_t *ip_add_info(mblk_t *, ill_t *, uint_t, zoneid_t, ip_stack_t *); 32455f9878b0Sken Powell - Sun Microsystem cred_t *ip_best_cred(mblk_t *, conn_t *, pid_t *); 32467c478bd9Sstevel@tonic-gate extern mblk_t *ip_bind_v4(queue_t *, mblk_t *, conn_t *); 32477c478bd9Sstevel@tonic-gate extern boolean_t ip_bind_ipsec_policy_set(conn_t *, mblk_t *); 32480f1702c5SYu Xiangning extern int ip_bind_laddr_v4(conn_t *, mblk_t **, uint8_t, ipaddr_t, 32490f1702c5SYu Xiangning uint16_t, boolean_t); 32500f1702c5SYu Xiangning extern int ip_proto_bind_laddr_v4(conn_t *, mblk_t **, uint8_t, ipaddr_t, 32510f1702c5SYu Xiangning uint16_t, boolean_t); 32520f1702c5SYu Xiangning extern int ip_proto_bind_connected_v4(conn_t *, mblk_t **, 3253de8c4a14SErik Nordmark uint8_t, ipaddr_t *, uint16_t, ipaddr_t, uint16_t, boolean_t, boolean_t, 3254de8c4a14SErik Nordmark cred_t *); 32550f1702c5SYu Xiangning extern int ip_bind_connected_v4(conn_t *, mblk_t **, uint8_t, ipaddr_t *, 3256de8c4a14SErik Nordmark uint16_t, ipaddr_t, uint16_t, boolean_t, boolean_t, cred_t *); 32577c478bd9Sstevel@tonic-gate extern uint_t ip_cksum(mblk_t *, int, uint32_t); 32587c478bd9Sstevel@tonic-gate extern int ip_close(queue_t *, int); 32597c478bd9Sstevel@tonic-gate extern uint16_t ip_csum_hdr(ipha_t *); 3260f4b3ec61Sdh155122 extern void ip_proto_not_sup(queue_t *, mblk_t *, uint_t, zoneid_t, 3261f4b3ec61Sdh155122 ip_stack_t *); 3262f4b3ec61Sdh155122 extern void ip_ire_g_fini(void); 3263f4b3ec61Sdh155122 extern void ip_ire_g_init(void); 3264f4b3ec61Sdh155122 extern void ip_ire_fini(ip_stack_t *); 3265f4b3ec61Sdh155122 extern void ip_ire_init(ip_stack_t *); 3266fc80c0dfSnordmark extern int ip_openv4(queue_t *q, dev_t *devp, int flag, int sflag, 3267fc80c0dfSnordmark cred_t *credp); 3268fc80c0dfSnordmark extern int ip_openv6(queue_t *q, dev_t *devp, int flag, int sflag, 3269fc80c0dfSnordmark cred_t *credp); 32707c478bd9Sstevel@tonic-gate extern int ip_reassemble(mblk_t *, ipf_t *, uint_t, boolean_t, ill_t *, 32717c478bd9Sstevel@tonic-gate size_t); 32727c478bd9Sstevel@tonic-gate extern int ip_opt_set_ill(conn_t *, int, boolean_t, boolean_t, 32737c478bd9Sstevel@tonic-gate int, int, mblk_t *); 32747c478bd9Sstevel@tonic-gate extern void ip_rput(queue_t *, mblk_t *); 3275605445d5Sdg199075 extern void ip_input(ill_t *, ill_rx_ring_t *, mblk_t *, 3276605445d5Sdg199075 struct mac_header_info_s *); 3277da14cebeSEric Cheng extern mblk_t *ip_accept_tcp(ill_t *, ill_rx_ring_t *, squeue_t *, 3278da14cebeSEric Cheng mblk_t *, mblk_t **, uint_t *cnt); 32797c478bd9Sstevel@tonic-gate extern void ip_rput_dlpi(queue_t *, mblk_t *); 32807c478bd9Sstevel@tonic-gate extern void ip_rput_forward(ire_t *, ipha_t *, mblk_t *, ill_t *); 32817c478bd9Sstevel@tonic-gate extern void ip_rput_forward_multicast(ipaddr_t, mblk_t *, ipif_t *); 3282ff550d0eSmasputra 32833173664eSapersson extern void ip_mib2_add_ip_stats(mib2_ipIfStatsEntry_t *, 32843173664eSapersson mib2_ipIfStatsEntry_t *); 32853173664eSapersson extern void ip_mib2_add_icmp6_stats(mib2_ipv6IfIcmpEntry_t *, 32863173664eSapersson mib2_ipv6IfIcmpEntry_t *); 32877c478bd9Sstevel@tonic-gate extern void ip_udp_input(queue_t *, mblk_t *, ipha_t *, ire_t *, ill_t *); 3288437220cdSdanmcd extern void ip_proto_input(queue_t *, mblk_t *, ipha_t *, ire_t *, ill_t *, 32894a179720Sdanmcd uint32_t); 32907c478bd9Sstevel@tonic-gate extern void ip_rput_other(ipsq_t *, queue_t *, mblk_t *, void *); 329112dfe4f0Sja97890 extern ire_t *ip_check_multihome(void *, ire_t *, ill_t *); 3292fc80c0dfSnordmark extern void ip_setpktversion(conn_t *, boolean_t, boolean_t, ip_stack_t *); 32937c478bd9Sstevel@tonic-gate extern void ip_trash_ire_reclaim(void *); 32947c478bd9Sstevel@tonic-gate extern void ip_trash_timer_expire(void *); 32957c478bd9Sstevel@tonic-gate extern void ip_wput(queue_t *, mblk_t *); 32967c478bd9Sstevel@tonic-gate extern void ip_output(void *, mblk_t *, void *, int); 329719a30e1aSrshoaib extern void ip_output_options(void *, mblk_t *, void *, int, 329819a30e1aSrshoaib ip_opt_info_t *); 32997c478bd9Sstevel@tonic-gate 33005597b60aSnordmark extern void ip_wput_ire(queue_t *, mblk_t *, ire_t *, conn_t *, int, 33015597b60aSnordmark zoneid_t); 33027c478bd9Sstevel@tonic-gate extern void ip_wput_local(queue_t *, ill_t *, ipha_t *, mblk_t *, ire_t *, 33037c478bd9Sstevel@tonic-gate int, zoneid_t); 33045597b60aSnordmark extern void ip_wput_multicast(queue_t *, mblk_t *, ipif_t *, zoneid_t); 33057c478bd9Sstevel@tonic-gate extern void ip_wput_nondata(ipsq_t *, queue_t *, mblk_t *, void *); 33067c478bd9Sstevel@tonic-gate extern void ip_wsrv(queue_t *); 33077c478bd9Sstevel@tonic-gate extern char *ip_nv_lookup(nv_t *, int); 33087c478bd9Sstevel@tonic-gate extern boolean_t ip_local_addr_ok_v6(const in6_addr_t *, const in6_addr_t *); 33097c478bd9Sstevel@tonic-gate extern boolean_t ip_remote_addr_ok_v6(const in6_addr_t *, const in6_addr_t *); 3310f4b3ec61Sdh155122 extern ipaddr_t ip_massage_options(ipha_t *, netstack_t *); 33117c478bd9Sstevel@tonic-gate extern ipaddr_t ip_net_mask(ipaddr_t); 33125c0b7edeSseb extern void ip_newroute(queue_t *, mblk_t *, ipaddr_t, conn_t *, zoneid_t, 33135c0b7edeSseb ip_stack_t *); 3314c793af95Ssangeeta extern ipxmit_state_t ip_xmit_v4(mblk_t *, ire_t *, struct ipsec_out_s *, 3315da14cebeSEric Cheng boolean_t, conn_t *); 3316f4b3ec61Sdh155122 extern int ip_hdr_complete(ipha_t *, zoneid_t, ip_stack_t *); 33177c478bd9Sstevel@tonic-gate 3318fc80c0dfSnordmark extern struct qinit iprinitv6; 3319fc80c0dfSnordmark extern struct qinit ipwinitv6; 33207c478bd9Sstevel@tonic-gate 3321e11c3f44Smeem extern void ipmp_init(ip_stack_t *); 3322e11c3f44Smeem extern void ipmp_destroy(ip_stack_t *); 3323e11c3f44Smeem extern ipmp_grp_t *ipmp_grp_create(const char *, phyint_t *); 3324e11c3f44Smeem extern void ipmp_grp_destroy(ipmp_grp_t *); 3325e11c3f44Smeem extern void ipmp_grp_info(const ipmp_grp_t *, lifgroupinfo_t *); 3326e11c3f44Smeem extern int ipmp_grp_rename(ipmp_grp_t *, const char *); 3327e11c3f44Smeem extern ipmp_grp_t *ipmp_grp_lookup(const char *, ip_stack_t *); 3328e11c3f44Smeem extern int ipmp_grp_vet_phyint(ipmp_grp_t *, phyint_t *); 3329e11c3f44Smeem extern ipmp_illgrp_t *ipmp_illgrp_create(ill_t *); 3330e11c3f44Smeem extern void ipmp_illgrp_destroy(ipmp_illgrp_t *); 3331e11c3f44Smeem extern ill_t *ipmp_illgrp_add_ipif(ipmp_illgrp_t *, ipif_t *); 3332e11c3f44Smeem extern void ipmp_illgrp_del_ipif(ipmp_illgrp_t *, ipif_t *); 3333e11c3f44Smeem extern ill_t *ipmp_illgrp_next_ill(ipmp_illgrp_t *); 3334e11c3f44Smeem extern ill_t *ipmp_illgrp_hold_next_ill(ipmp_illgrp_t *); 3335e11c3f44Smeem extern ill_t *ipmp_illgrp_cast_ill(ipmp_illgrp_t *); 3336e11c3f44Smeem extern ill_t *ipmp_illgrp_hold_cast_ill(ipmp_illgrp_t *); 3337e11c3f44Smeem extern ill_t *ipmp_illgrp_ipmp_ill(ipmp_illgrp_t *); 3338e11c3f44Smeem extern void ipmp_illgrp_refresh_mtu(ipmp_illgrp_t *); 3339e11c3f44Smeem extern ipmp_arpent_t *ipmp_illgrp_create_arpent(ipmp_illgrp_t *, mblk_t *, 3340e11c3f44Smeem boolean_t); 3341e11c3f44Smeem extern void ipmp_illgrp_destroy_arpent(ipmp_illgrp_t *, ipmp_arpent_t *); 3342e11c3f44Smeem extern ipmp_arpent_t *ipmp_illgrp_lookup_arpent(ipmp_illgrp_t *, ipaddr_t *); 3343e11c3f44Smeem extern void ipmp_illgrp_refresh_arpent(ipmp_illgrp_t *); 3344e11c3f44Smeem extern void ipmp_illgrp_mark_arpent(ipmp_illgrp_t *, ipmp_arpent_t *); 3345e11c3f44Smeem extern ill_t *ipmp_illgrp_find_ill(ipmp_illgrp_t *, uchar_t *, uint_t); 3346e11c3f44Smeem extern void ipmp_illgrp_link_grp(ipmp_illgrp_t *, ipmp_grp_t *); 3347e11c3f44Smeem extern int ipmp_illgrp_unlink_grp(ipmp_illgrp_t *); 3348e11c3f44Smeem extern uint_t ipmp_ill_get_ipmp_ifindex(const ill_t *); 3349e11c3f44Smeem extern void ipmp_ill_join_illgrp(ill_t *, ipmp_illgrp_t *); 3350e11c3f44Smeem extern void ipmp_ill_leave_illgrp(ill_t *); 3351e11c3f44Smeem extern ill_t *ipmp_ill_hold_ipmp_ill(ill_t *); 3352e11c3f44Smeem extern boolean_t ipmp_ill_is_active(ill_t *); 3353e11c3f44Smeem extern void ipmp_ill_refresh_active(ill_t *); 3354e11c3f44Smeem extern void ipmp_phyint_join_grp(phyint_t *, ipmp_grp_t *); 3355e11c3f44Smeem extern void ipmp_phyint_leave_grp(phyint_t *); 3356e11c3f44Smeem extern void ipmp_phyint_refresh_active(phyint_t *); 3357e11c3f44Smeem extern ill_t *ipmp_ipif_bound_ill(const ipif_t *); 3358e11c3f44Smeem extern ill_t *ipmp_ipif_hold_bound_ill(const ipif_t *); 3359e11c3f44Smeem extern boolean_t ipmp_ipif_is_dataaddr(const ipif_t *); 3360e11c3f44Smeem extern boolean_t ipmp_ipif_is_stubaddr(const ipif_t *); 3361e11c3f44Smeem 3362ae6aa22aSVenugopal Iyer extern void conn_drain_insert(conn_t *, idl_tx_list_t *); 3363ae6aa22aSVenugopal Iyer extern int conn_ipsec_length(conn_t *); 33647c478bd9Sstevel@tonic-gate extern void ip_wput_ipsec_out(queue_t *, mblk_t *, ipha_t *, ill_t *, 33657c478bd9Sstevel@tonic-gate ire_t *); 33667c478bd9Sstevel@tonic-gate extern ipaddr_t ip_get_dst(ipha_t *); 33677c478bd9Sstevel@tonic-gate extern int ipsec_out_extra_length(mblk_t *); 33687c478bd9Sstevel@tonic-gate extern int ipsec_in_extra_length(mblk_t *); 3369f4b3ec61Sdh155122 extern mblk_t *ipsec_in_alloc(boolean_t, netstack_t *); 33707c478bd9Sstevel@tonic-gate extern boolean_t ipsec_in_is_secure(mblk_t *); 33717c478bd9Sstevel@tonic-gate extern void ipsec_out_process(queue_t *, mblk_t *, ire_t *, uint_t); 33727c478bd9Sstevel@tonic-gate extern void ipsec_out_to_in(mblk_t *); 33737c478bd9Sstevel@tonic-gate extern void ip_fanout_proto_again(mblk_t *, ill_t *, ill_t *, ire_t *); 33747c478bd9Sstevel@tonic-gate 33757c478bd9Sstevel@tonic-gate extern void ire_cleanup(ire_t *); 33767c478bd9Sstevel@tonic-gate extern void ire_inactive(ire_t *); 3377c793af95Ssangeeta extern boolean_t irb_inactive(irb_t *); 33787c478bd9Sstevel@tonic-gate extern ire_t *ire_unlink(irb_t *); 33796a8288c7Scarlsonj 33806a8288c7Scarlsonj #ifdef DEBUG 33816a8288c7Scarlsonj extern boolean_t th_trace_ref(const void *, ip_stack_t *); 33826a8288c7Scarlsonj extern void th_trace_unref(const void *); 33836a8288c7Scarlsonj extern void th_trace_cleanup(const void *, boolean_t); 33846a8288c7Scarlsonj extern void ire_trace_ref(ire_t *); 33856a8288c7Scarlsonj extern void ire_untrace_ref(ire_t *); 33867c478bd9Sstevel@tonic-gate #endif 33877c478bd9Sstevel@tonic-gate 3388f4b3ec61Sdh155122 extern int ip_srcid_insert(const in6_addr_t *, zoneid_t, ip_stack_t *); 3389f4b3ec61Sdh155122 extern int ip_srcid_remove(const in6_addr_t *, zoneid_t, ip_stack_t *); 3390f4b3ec61Sdh155122 extern void ip_srcid_find_id(uint_t, in6_addr_t *, zoneid_t, netstack_t *); 3391f4b3ec61Sdh155122 extern uint_t ip_srcid_find_addr(const in6_addr_t *, zoneid_t, netstack_t *); 33927c478bd9Sstevel@tonic-gate 33937c478bd9Sstevel@tonic-gate extern uint8_t ipoptp_next(ipoptp_t *); 33947c478bd9Sstevel@tonic-gate extern uint8_t ipoptp_first(ipoptp_t *, ipha_t *); 339545916cd2Sjpk extern int ip_opt_get_user(const ipha_t *, uchar_t *); 33967c478bd9Sstevel@tonic-gate extern int ipsec_req_from_conn(conn_t *, ipsec_req_t *, int); 3397fc80c0dfSnordmark extern int ip_snmp_get(queue_t *q, mblk_t *mctl, int level); 33987c478bd9Sstevel@tonic-gate extern int ip_snmp_set(queue_t *q, int, int, uchar_t *, int); 33997c478bd9Sstevel@tonic-gate extern void ip_process_ioctl(ipsq_t *, queue_t *, mblk_t *, void *); 3400ff550d0eSmasputra extern void ip_quiesce_conn(conn_t *); 34017c478bd9Sstevel@tonic-gate extern void ip_reprocess_ioctl(ipsq_t *, queue_t *, mblk_t *, void *); 34027c478bd9Sstevel@tonic-gate extern void ip_restart_optmgmt(ipsq_t *, queue_t *, mblk_t *, void *); 3403b051ecf6Smeem extern void ip_ioctl_finish(queue_t *, mblk_t *, int, int, ipsq_t *); 34047c478bd9Sstevel@tonic-gate 340545916cd2Sjpk extern boolean_t ip_cmpbuf(const void *, uint_t, boolean_t, const void *, 340645916cd2Sjpk uint_t); 340745916cd2Sjpk extern boolean_t ip_allocbuf(void **, uint_t *, boolean_t, const void *, 340845916cd2Sjpk uint_t); 340945916cd2Sjpk extern void ip_savebuf(void **, uint_t *, boolean_t, const void *, uint_t); 341045916cd2Sjpk 34117c478bd9Sstevel@tonic-gate extern boolean_t ipsq_pending_mp_cleanup(ill_t *, conn_t *); 34127c478bd9Sstevel@tonic-gate extern void conn_ioctl_cleanup(conn_t *); 34137c478bd9Sstevel@tonic-gate extern ill_t *conn_get_held_ill(conn_t *, ill_t **, int *); 34147c478bd9Sstevel@tonic-gate 34150854dd28SPhilip Kirk struct tcp_stack; 34160854dd28SPhilip Kirk extern void ip_xmit_reset_serialize(mblk_t *, int, zoneid_t, struct tcp_stack *, 34170854dd28SPhilip Kirk conn_t *); 34180854dd28SPhilip Kirk 34197c478bd9Sstevel@tonic-gate struct multidata_s; 34207c478bd9Sstevel@tonic-gate struct pdesc_s; 34217c478bd9Sstevel@tonic-gate 34227c478bd9Sstevel@tonic-gate extern mblk_t *ip_mdinfo_alloc(ill_mdt_capab_t *); 34237c478bd9Sstevel@tonic-gate extern mblk_t *ip_mdinfo_return(ire_t *, conn_t *, char *, ill_mdt_capab_t *); 34248347601bSyl150051 extern mblk_t *ip_lsoinfo_alloc(ill_lso_capab_t *); 34258347601bSyl150051 extern mblk_t *ip_lsoinfo_return(ire_t *, conn_t *, char *, 34268347601bSyl150051 ill_lso_capab_t *); 34277c478bd9Sstevel@tonic-gate extern uint_t ip_md_cksum(struct pdesc_s *, int, uint_t); 34287c478bd9Sstevel@tonic-gate extern boolean_t ip_md_addr_attr(struct multidata_s *, struct pdesc_s *, 34297c478bd9Sstevel@tonic-gate const mblk_t *); 34307c478bd9Sstevel@tonic-gate extern boolean_t ip_md_hcksum_attr(struct multidata_s *, struct pdesc_s *, 34317c478bd9Sstevel@tonic-gate uint32_t, uint32_t, uint32_t, uint32_t); 34327c478bd9Sstevel@tonic-gate extern boolean_t ip_md_zcopy_attr(struct multidata_s *, struct pdesc_s *, 34337c478bd9Sstevel@tonic-gate uint_t); 34340f1702c5SYu Xiangning extern void ip_unbind(conn_t *connp); 34357c478bd9Sstevel@tonic-gate 343645916cd2Sjpk extern void tnet_init(void); 343745916cd2Sjpk extern void tnet_fini(void); 343845916cd2Sjpk 34397c478bd9Sstevel@tonic-gate /* Hooks for CGTP (multirt routes) filtering module */ 34407c478bd9Sstevel@tonic-gate #define CGTP_FILTER_REV_1 1 34417c478bd9Sstevel@tonic-gate #define CGTP_FILTER_REV_2 2 3442655a42e2Snordmark #define CGTP_FILTER_REV_3 3 3443655a42e2Snordmark #define CGTP_FILTER_REV CGTP_FILTER_REV_3 34447c478bd9Sstevel@tonic-gate 3445655a42e2Snordmark /* cfo_filter and cfo_filter_v6 hooks return values */ 34467c478bd9Sstevel@tonic-gate #define CGTP_IP_PKT_NOT_CGTP 0 34477c478bd9Sstevel@tonic-gate #define CGTP_IP_PKT_PREMIUM 1 34487c478bd9Sstevel@tonic-gate #define CGTP_IP_PKT_DUPLICATE 2 34497c478bd9Sstevel@tonic-gate 3450655a42e2Snordmark /* Version 3 of the filter interface */ 34517c478bd9Sstevel@tonic-gate typedef struct cgtp_filter_ops { 3452655a42e2Snordmark int cfo_filter_rev; /* CGTP_FILTER_REV_3 */ 3453655a42e2Snordmark int (*cfo_change_state)(netstackid_t, int); 3454655a42e2Snordmark int (*cfo_add_dest_v4)(netstackid_t, ipaddr_t, ipaddr_t, 3455655a42e2Snordmark ipaddr_t, ipaddr_t); 3456655a42e2Snordmark int (*cfo_del_dest_v4)(netstackid_t, ipaddr_t, ipaddr_t); 3457655a42e2Snordmark int (*cfo_add_dest_v6)(netstackid_t, in6_addr_t *, in6_addr_t *, 3458655a42e2Snordmark in6_addr_t *, in6_addr_t *); 3459655a42e2Snordmark int (*cfo_del_dest_v6)(netstackid_t, in6_addr_t *, in6_addr_t *); 3460655a42e2Snordmark int (*cfo_filter)(netstackid_t, uint_t, mblk_t *); 3461655a42e2Snordmark int (*cfo_filter_v6)(netstackid_t, uint_t, ip6_t *, 3462655a42e2Snordmark ip6_frag_t *); 34637c478bd9Sstevel@tonic-gate } cgtp_filter_ops_t; 34647c478bd9Sstevel@tonic-gate 34657c478bd9Sstevel@tonic-gate #define CGTP_MCAST_SUCCESS 1 34667c478bd9Sstevel@tonic-gate 3467f4b3ec61Sdh155122 /* 3468655a42e2Snordmark * The separate CGTP module needs this global symbol so that it 3469655a42e2Snordmark * can check the version and determine whether to use the old or the new 3470655a42e2Snordmark * version of the filtering interface. 3471f4b3ec61Sdh155122 */ 3472655a42e2Snordmark extern int ip_cgtp_filter_rev; 34737c478bd9Sstevel@tonic-gate 34747c478bd9Sstevel@tonic-gate extern int ip_cgtp_filter_supported(void); 3475655a42e2Snordmark extern int ip_cgtp_filter_register(netstackid_t, cgtp_filter_ops_t *); 3476655a42e2Snordmark extern int ip_cgtp_filter_unregister(netstackid_t); 3477655a42e2Snordmark extern int ip_cgtp_filter_is_registered(netstackid_t); 34787c478bd9Sstevel@tonic-gate 34797c478bd9Sstevel@tonic-gate /* Flags for ire_multirt_lookup() */ 34807c478bd9Sstevel@tonic-gate 34817c478bd9Sstevel@tonic-gate #define MULTIRT_USESTAMP 0x0001 34827c478bd9Sstevel@tonic-gate #define MULTIRT_SETSTAMP 0x0002 34837c478bd9Sstevel@tonic-gate #define MULTIRT_CACHEGW 0x0004 34847c478bd9Sstevel@tonic-gate 34857c478bd9Sstevel@tonic-gate /* Debug stuff for multirt route resolution. */ 34867c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(__lint) 34877c478bd9Sstevel@tonic-gate /* Our "don't send, rather drop" flag. */ 34887c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_FLAG 0x8000 34897c478bd9Sstevel@tonic-gate 34907c478bd9Sstevel@tonic-gate #define MULTIRT_TRACE(x) ip2dbg(x) 34917c478bd9Sstevel@tonic-gate 34927c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_TAG(mblk) \ 34937c478bd9Sstevel@tonic-gate do { \ 34947c478bd9Sstevel@tonic-gate ASSERT(mblk != NULL); \ 34957c478bd9Sstevel@tonic-gate MULTIRT_TRACE(("%s[%d]: tagging mblk %p, tag was %d\n", \ 34967c478bd9Sstevel@tonic-gate __FILE__, __LINE__, \ 34977c478bd9Sstevel@tonic-gate (void *)(mblk), (mblk)->b_flag & MULTIRT_DEBUG_FLAG)); \ 34987c478bd9Sstevel@tonic-gate (mblk)->b_flag |= MULTIRT_DEBUG_FLAG; \ 34997c478bd9Sstevel@tonic-gate } while (0) 35007c478bd9Sstevel@tonic-gate 35017c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_UNTAG(mblk) \ 35027c478bd9Sstevel@tonic-gate do { \ 35037c478bd9Sstevel@tonic-gate ASSERT(mblk != NULL); \ 35047c478bd9Sstevel@tonic-gate MULTIRT_TRACE(("%s[%d]: untagging mblk %p, tag was %d\n", \ 35057c478bd9Sstevel@tonic-gate __FILE__, __LINE__, \ 35067c478bd9Sstevel@tonic-gate (void *)(mblk), (mblk)->b_flag & MULTIRT_DEBUG_FLAG)); \ 35077c478bd9Sstevel@tonic-gate (mblk)->b_flag &= ~MULTIRT_DEBUG_FLAG; \ 35087c478bd9Sstevel@tonic-gate } while (0) 35097c478bd9Sstevel@tonic-gate 35107c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_TAGGED(mblk) \ 35117c478bd9Sstevel@tonic-gate (((mblk)->b_flag & MULTIRT_DEBUG_FLAG) ? B_TRUE : B_FALSE) 35127c478bd9Sstevel@tonic-gate #else 35137c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_TAG(mblk) ASSERT(mblk != NULL) 35147c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_UNTAG(mblk) ASSERT(mblk != NULL) 35157c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_TAGGED(mblk) B_FALSE 35167c478bd9Sstevel@tonic-gate #endif 35177c478bd9Sstevel@tonic-gate 35187c478bd9Sstevel@tonic-gate /* 3519b127ac41SPhilip Kirk * IP observability hook support 3520b127ac41SPhilip Kirk */ 3521b127ac41SPhilip Kirk 3522b127ac41SPhilip Kirk /* 3523b127ac41SPhilip Kirk * ipobs_hooktype_t describes the hook types supported 3524b127ac41SPhilip Kirk * by the ip module. IPOBS_HOOK_LOCAL refers to packets 3525b127ac41SPhilip Kirk * which are looped back internally within the ip module. 3526b127ac41SPhilip Kirk */ 3527b127ac41SPhilip Kirk 3528b127ac41SPhilip Kirk typedef enum ipobs_hook_type { 3529b127ac41SPhilip Kirk IPOBS_HOOK_LOCAL, 3530b127ac41SPhilip Kirk IPOBS_HOOK_OUTBOUND, 3531b127ac41SPhilip Kirk IPOBS_HOOK_INBOUND 3532b127ac41SPhilip Kirk } ipobs_hook_type_t; 3533b127ac41SPhilip Kirk 3534b127ac41SPhilip Kirk typedef void ipobs_cbfunc_t(mblk_t *); 3535b127ac41SPhilip Kirk 3536b127ac41SPhilip Kirk typedef struct ipobs_cb { 3537b127ac41SPhilip Kirk ipobs_cbfunc_t *ipobs_cbfunc; 3538b127ac41SPhilip Kirk list_node_t ipobs_cbnext; 3539b127ac41SPhilip Kirk } ipobs_cb_t; 3540b127ac41SPhilip Kirk 3541b127ac41SPhilip Kirk /* 3542b127ac41SPhilip Kirk * This structure holds the data passed back from the ip module to 3543b127ac41SPhilip Kirk * observability consumers. 3544b127ac41SPhilip Kirk * 3545b127ac41SPhilip Kirk * ihd_mp Pointer to the IP packet. 3546b127ac41SPhilip Kirk * ihd_zsrc Source zoneid; set to ALL_ZONES when unknown. 3547b127ac41SPhilip Kirk * ihd_zdst Destination zoneid; set to ALL_ZONES when unknown. 3548b127ac41SPhilip Kirk * ihd_htype IPobs hook type, see above for the defined types. 3549b127ac41SPhilip Kirk * ihd_ipver IP version of the packet. 3550b127ac41SPhilip Kirk * ihd_ifindex Interface index that the packet was received/sent over. 3551b127ac41SPhilip Kirk * For local packets, this is the index of the interface 3552b127ac41SPhilip Kirk * associated with the local destination address. 3553e11c3f44Smeem * ihd_grifindex IPMP group interface index (zero unless ihd_ifindex 3554e11c3f44Smeem * is an IPMP underlying interface). 3555b127ac41SPhilip Kirk * ihd_stack Netstack the packet is from. 3556b127ac41SPhilip Kirk */ 3557b127ac41SPhilip Kirk typedef struct ipobs_hook_data { 3558b127ac41SPhilip Kirk mblk_t *ihd_mp; 3559b127ac41SPhilip Kirk zoneid_t ihd_zsrc; 3560b127ac41SPhilip Kirk zoneid_t ihd_zdst; 3561b127ac41SPhilip Kirk ipobs_hook_type_t ihd_htype; 3562b127ac41SPhilip Kirk uint16_t ihd_ipver; 3563b127ac41SPhilip Kirk uint64_t ihd_ifindex; 3564e11c3f44Smeem uint64_t ihd_grifindex; 3565b127ac41SPhilip Kirk netstack_t *ihd_stack; 3566b127ac41SPhilip Kirk } ipobs_hook_data_t; 3567b127ac41SPhilip Kirk 3568b127ac41SPhilip Kirk /* 35697c478bd9Sstevel@tonic-gate * Per-ILL Multidata Transmit capabilities. 35707c478bd9Sstevel@tonic-gate */ 35717c478bd9Sstevel@tonic-gate struct ill_mdt_capab_s { 35727c478bd9Sstevel@tonic-gate uint_t ill_mdt_version; /* interface version */ 35737c478bd9Sstevel@tonic-gate uint_t ill_mdt_on; /* on/off switch for MDT on this ILL */ 35747c478bd9Sstevel@tonic-gate uint_t ill_mdt_hdr_head; /* leading header fragment extra space */ 35757c478bd9Sstevel@tonic-gate uint_t ill_mdt_hdr_tail; /* trailing header fragment extra space */ 35767c478bd9Sstevel@tonic-gate uint_t ill_mdt_max_pld; /* maximum payload buffers per Multidata */ 35777c478bd9Sstevel@tonic-gate uint_t ill_mdt_span_limit; /* maximum payload span per packet */ 35787c478bd9Sstevel@tonic-gate }; 35797c478bd9Sstevel@tonic-gate 35807c478bd9Sstevel@tonic-gate struct ill_hcksum_capab_s { 35817c478bd9Sstevel@tonic-gate uint_t ill_hcksum_version; /* interface version */ 35827c478bd9Sstevel@tonic-gate uint_t ill_hcksum_txflags; /* capabilities on transmit */ 35837c478bd9Sstevel@tonic-gate }; 35847c478bd9Sstevel@tonic-gate 35857c478bd9Sstevel@tonic-gate struct ill_zerocopy_capab_s { 35867c478bd9Sstevel@tonic-gate uint_t ill_zerocopy_version; /* interface version */ 35877c478bd9Sstevel@tonic-gate uint_t ill_zerocopy_flags; /* capabilities */ 35887c478bd9Sstevel@tonic-gate }; 35897c478bd9Sstevel@tonic-gate 35908347601bSyl150051 struct ill_lso_capab_s { 35918347601bSyl150051 uint_t ill_lso_on; /* on/off switch for LSO on this ILL */ 35928347601bSyl150051 uint_t ill_lso_flags; /* capabilities */ 35938347601bSyl150051 uint_t ill_lso_max; /* maximum size of payload */ 35948347601bSyl150051 }; 35958347601bSyl150051 3596da14cebeSEric Cheng /* 3597da14cebeSEric Cheng * rr_ring_state cycles in the order shown below from RR_FREE through 3598da14cebeSEric Cheng * RR_FREE_IN_PROG and back to RR_FREE. 3599da14cebeSEric Cheng */ 3600da14cebeSEric Cheng typedef enum { 3601da14cebeSEric Cheng RR_FREE, /* Free slot */ 3602da14cebeSEric Cheng RR_SQUEUE_UNBOUND, /* Ring's squeue is unbound */ 3603da14cebeSEric Cheng RR_SQUEUE_BIND_INPROG, /* Ring's squeue bind in progress */ 3604da14cebeSEric Cheng RR_SQUEUE_BOUND, /* Ring's squeue bound to cpu */ 3605da14cebeSEric Cheng RR_FREE_INPROG /* Ring is being freed */ 3606da14cebeSEric Cheng } ip_ring_state_t; 36077c478bd9Sstevel@tonic-gate 36087c478bd9Sstevel@tonic-gate #define ILL_MAX_RINGS 256 /* Max num of rx rings we can manage */ 36097c478bd9Sstevel@tonic-gate #define ILL_POLLING 0x01 /* Polling in use */ 36107c478bd9Sstevel@tonic-gate 36117c478bd9Sstevel@tonic-gate /* 36124b46d1efSkrgopi * These functions pointer types are exported by the mac/dls layer. 36134b46d1efSkrgopi * we need to duplicate the definitions here because we cannot 36144b46d1efSkrgopi * include mac/dls header files here. 36157c478bd9Sstevel@tonic-gate */ 3616efe28d82SRajagopal Kunhappan typedef boolean_t (*ip_mac_intr_disable_t)(void *); 3617da14cebeSEric Cheng typedef void (*ip_mac_intr_enable_t)(void *); 3618ae6aa22aSVenugopal Iyer typedef ip_mac_tx_cookie_t (*ip_dld_tx_t)(void *, mblk_t *, 3619ae6aa22aSVenugopal Iyer uint64_t, uint16_t); 3620da14cebeSEric Cheng typedef void (*ip_flow_enable_t)(void *, ip_mac_tx_cookie_t); 3621ae6aa22aSVenugopal Iyer typedef void *(*ip_dld_callb_t)(void *, 3622ae6aa22aSVenugopal Iyer ip_flow_enable_t, void *); 3623ae6aa22aSVenugopal Iyer typedef boolean_t (*ip_dld_fctl_t)(void *, ip_mac_tx_cookie_t); 3624ae6aa22aSVenugopal Iyer typedef int (*ip_capab_func_t)(void *, uint_t, 3625ae6aa22aSVenugopal Iyer void *, uint_t); 36264b46d1efSkrgopi 3627da14cebeSEric Cheng /* 3628da14cebeSEric Cheng * POLLING README 3629da14cebeSEric Cheng * sq_get_pkts() is called to pick packets from softring in poll mode. It 3630da14cebeSEric Cheng * calls rr_rx to get the chain and process it with rr_ip_accept. 3631da14cebeSEric Cheng * rr_rx = mac_soft_ring_poll() to pick packets 3632da14cebeSEric Cheng * rr_ip_accept = ip_accept_tcp() to process packets 3633da14cebeSEric Cheng */ 36347c478bd9Sstevel@tonic-gate 3635da14cebeSEric Cheng /* 3636da14cebeSEric Cheng * XXX: With protocol, service specific squeues, they will have 3637da14cebeSEric Cheng * specific acceptor functions. 3638da14cebeSEric Cheng */ 3639da14cebeSEric Cheng typedef mblk_t *(*ip_mac_rx_t)(void *, size_t); 3640da14cebeSEric Cheng typedef mblk_t *(*ip_accept_t)(ill_t *, ill_rx_ring_t *, 3641da14cebeSEric Cheng squeue_t *, mblk_t *, mblk_t **, uint_t *); 3642da14cebeSEric Cheng 3643da14cebeSEric Cheng /* 3644da14cebeSEric Cheng * rr_intr_enable, rr_intr_disable, rr_rx_handle, rr_rx: 3645da14cebeSEric Cheng * May be accessed while in the squeue AND after checking that SQS_POLL_CAPAB 3646da14cebeSEric Cheng * is set. 3647da14cebeSEric Cheng * 3648da14cebeSEric Cheng * rr_ring_state: Protected by ill_lock. 3649da14cebeSEric Cheng */ 36507c478bd9Sstevel@tonic-gate struct ill_rx_ring { 3651da14cebeSEric Cheng ip_mac_intr_disable_t rr_intr_disable; /* Interrupt disabling func */ 3652da14cebeSEric Cheng ip_mac_intr_enable_t rr_intr_enable; /* Interrupt enabling func */ 3653da14cebeSEric Cheng void *rr_intr_handle; /* Handle interrupt funcs */ 3654da14cebeSEric Cheng ip_mac_rx_t rr_rx; /* Driver receive function */ 3655da14cebeSEric Cheng ip_accept_t rr_ip_accept; /* IP accept function */ 3656da14cebeSEric Cheng void *rr_rx_handle; /* Handle for Rx ring */ 36577c478bd9Sstevel@tonic-gate squeue_t *rr_sqp; /* Squeue the ring is bound to */ 36587c478bd9Sstevel@tonic-gate ill_t *rr_ill; /* back pointer to ill */ 3659da14cebeSEric Cheng ip_ring_state_t rr_ring_state; /* State of this ring */ 36607c478bd9Sstevel@tonic-gate }; 36617c478bd9Sstevel@tonic-gate 3662da14cebeSEric Cheng /* 3663da14cebeSEric Cheng * IP - DLD direct function call capability 3664da14cebeSEric Cheng * Suffixes, df - dld function, dh - dld handle, 3665da14cebeSEric Cheng * cf - client (IP) function, ch - client handle 3666da14cebeSEric Cheng */ 3667da14cebeSEric Cheng typedef struct ill_dld_direct_s { /* DLD provided driver Tx */ 3668da14cebeSEric Cheng ip_dld_tx_t idd_tx_df; /* str_mdata_fastpath_put */ 3669da14cebeSEric Cheng void *idd_tx_dh; /* dld_str_t *dsp */ 3670da14cebeSEric Cheng ip_dld_callb_t idd_tx_cb_df; /* mac_tx_srs_notify */ 3671da14cebeSEric Cheng void *idd_tx_cb_dh; /* mac_client_handle_t *mch */ 3672ae6aa22aSVenugopal Iyer ip_dld_fctl_t idd_tx_fctl_df; /* mac_tx_is_flow_blocked */ 3673ae6aa22aSVenugopal Iyer void *idd_tx_fctl_dh; /* mac_client_handle */ 3674da14cebeSEric Cheng } ill_dld_direct_t; 3675da14cebeSEric Cheng 3676da14cebeSEric Cheng /* IP - DLD polling capability */ 3677da14cebeSEric Cheng typedef struct ill_dld_poll_s { 3678da14cebeSEric Cheng ill_rx_ring_t idp_ring_tbl[ILL_MAX_RINGS]; 3679da14cebeSEric Cheng } ill_dld_poll_t; 3680da14cebeSEric Cheng 3681da14cebeSEric Cheng /* Describes ill->ill_dld_capab */ 3682da14cebeSEric Cheng struct ill_dld_capab_s { 3683da14cebeSEric Cheng ip_capab_func_t idc_capab_df; /* dld_capab_func */ 3684da14cebeSEric Cheng void *idc_capab_dh; /* dld_str_t *dsp */ 3685da14cebeSEric Cheng ill_dld_direct_t idc_direct; 3686da14cebeSEric Cheng ill_dld_poll_t idc_poll; 36877c478bd9Sstevel@tonic-gate }; 36887c478bd9Sstevel@tonic-gate 36897c478bd9Sstevel@tonic-gate /* 36907c478bd9Sstevel@tonic-gate * IP squeues exports 36917c478bd9Sstevel@tonic-gate */ 36927c478bd9Sstevel@tonic-gate extern boolean_t ip_squeue_fanout; 36937c478bd9Sstevel@tonic-gate 3694da14cebeSEric Cheng #define IP_SQUEUE_GET(hint) ip_squeue_random(hint) 36957c478bd9Sstevel@tonic-gate 36967c478bd9Sstevel@tonic-gate extern void ip_squeue_init(void (*)(squeue_t *)); 36977c478bd9Sstevel@tonic-gate extern squeue_t *ip_squeue_random(uint_t); 36987c478bd9Sstevel@tonic-gate extern squeue_t *ip_squeue_get(ill_rx_ring_t *); 3699da14cebeSEric Cheng extern squeue_t *ip_squeue_getfree(pri_t); 3700da14cebeSEric Cheng extern int ip_squeue_cpu_move(squeue_t *, processorid_t); 3701da14cebeSEric Cheng extern void *ip_squeue_add_ring(ill_t *, void *); 3702da14cebeSEric Cheng extern void ip_squeue_bind_ring(ill_t *, ill_rx_ring_t *, processorid_t); 3703da14cebeSEric Cheng extern void ip_squeue_clean_ring(ill_t *, ill_rx_ring_t *); 3704da14cebeSEric Cheng extern void ip_squeue_quiesce_ring(ill_t *, ill_rx_ring_t *); 3705da14cebeSEric Cheng extern void ip_squeue_restart_ring(ill_t *, ill_rx_ring_t *); 37068df01f76Smeem extern void ip_squeue_clean_all(ill_t *); 37077c478bd9Sstevel@tonic-gate 3708ff550d0eSmasputra extern void tcp_wput(queue_t *, mblk_t *); 3709ff550d0eSmasputra 37107c478bd9Sstevel@tonic-gate extern int ip_fill_mtuinfo(struct in6_addr *, in_port_t, 3711f4b3ec61Sdh155122 struct ip6_mtuinfo *, netstack_t *); 3712ff550d0eSmasputra extern ipif_t *conn_get_held_ipif(conn_t *, ipif_t **, int *); 3713b127ac41SPhilip Kirk extern void ipobs_register_hook(netstack_t *, ipobs_cbfunc_t *); 3714b127ac41SPhilip Kirk extern void ipobs_unregister_hook(netstack_t *, ipobs_cbfunc_t *); 3715b127ac41SPhilip Kirk extern void ipobs_hook(mblk_t *, int, zoneid_t, zoneid_t, const ill_t *, int, 3716b127ac41SPhilip Kirk uint32_t, ip_stack_t *); 37177c478bd9Sstevel@tonic-gate typedef void (*ipsq_func_t)(ipsq_t *, queue_t *, mblk_t *, void *); 37187c478bd9Sstevel@tonic-gate 37197c478bd9Sstevel@tonic-gate /* 37207c478bd9Sstevel@tonic-gate * Squeue tags. Tags only need to be unique when the callback function is the 37217c478bd9Sstevel@tonic-gate * same to distinguish between different calls, but we use unique tags for 37227c478bd9Sstevel@tonic-gate * convenience anyway. 37237c478bd9Sstevel@tonic-gate */ 37247c478bd9Sstevel@tonic-gate #define SQTAG_IP_INPUT 1 37257c478bd9Sstevel@tonic-gate #define SQTAG_TCP_INPUT_ICMP_ERR 2 37267c478bd9Sstevel@tonic-gate #define SQTAG_TCP6_INPUT_ICMP_ERR 3 37277c478bd9Sstevel@tonic-gate #define SQTAG_IP_TCP_INPUT 4 37287c478bd9Sstevel@tonic-gate #define SQTAG_IP6_TCP_INPUT 5 37297c478bd9Sstevel@tonic-gate #define SQTAG_IP_TCP_CLOSE 6 37307c478bd9Sstevel@tonic-gate #define SQTAG_TCP_OUTPUT 7 37317c478bd9Sstevel@tonic-gate #define SQTAG_TCP_TIMER 8 37327c478bd9Sstevel@tonic-gate #define SQTAG_TCP_TIMEWAIT 9 37337c478bd9Sstevel@tonic-gate #define SQTAG_TCP_ACCEPT_FINISH 10 37347c478bd9Sstevel@tonic-gate #define SQTAG_TCP_ACCEPT_FINISH_Q0 11 37357c478bd9Sstevel@tonic-gate #define SQTAG_TCP_ACCEPT_PENDING 12 37367c478bd9Sstevel@tonic-gate #define SQTAG_TCP_LISTEN_DISCON 13 37370163a147Sjprakash #define SQTAG_TCP_CONN_REQ_1 14 37387c478bd9Sstevel@tonic-gate #define SQTAG_TCP_EAGER_BLOWOFF 15 37397c478bd9Sstevel@tonic-gate #define SQTAG_TCP_EAGER_CLEANUP 16 37407c478bd9Sstevel@tonic-gate #define SQTAG_TCP_EAGER_CLEANUP_Q0 17 37417c478bd9Sstevel@tonic-gate #define SQTAG_TCP_CONN_IND 18 37427c478bd9Sstevel@tonic-gate #define SQTAG_TCP_RSRV 19 37437c478bd9Sstevel@tonic-gate #define SQTAG_TCP_ABORT_BUCKET 20 37447c478bd9Sstevel@tonic-gate #define SQTAG_TCP_REINPUT 21 37457c478bd9Sstevel@tonic-gate #define SQTAG_TCP_REINPUT_EAGER 22 37467c478bd9Sstevel@tonic-gate #define SQTAG_TCP_INPUT_MCTL 23 37477c478bd9Sstevel@tonic-gate #define SQTAG_TCP_RPUTOTHER 24 37487c478bd9Sstevel@tonic-gate #define SQTAG_IP_PROTO_AGAIN 25 37497c478bd9Sstevel@tonic-gate #define SQTAG_IP_FANOUT_TCP 26 37507c478bd9Sstevel@tonic-gate #define SQTAG_IPSQ_CLEAN_RING 27 37517c478bd9Sstevel@tonic-gate #define SQTAG_TCP_WPUT_OTHER 28 37527c478bd9Sstevel@tonic-gate #define SQTAG_TCP_CONN_REQ_UNBOUND 29 37537c478bd9Sstevel@tonic-gate #define SQTAG_TCP_SEND_PENDING 30 3754ff550d0eSmasputra #define SQTAG_BIND_RETRY 31 3755ff550d0eSmasputra #define SQTAG_UDP_FANOUT 32 3756ff550d0eSmasputra #define SQTAG_UDP_INPUT 33 3757ff550d0eSmasputra #define SQTAG_UDP_WPUT 34 3758ff550d0eSmasputra #define SQTAG_UDP_OUTPUT 35 3759c28749e9Skais #define SQTAG_TCP_KSSL_INPUT 36 3760866ba9ddSjprakash #define SQTAG_TCP_DROP_Q0 37 37610163a147Sjprakash #define SQTAG_TCP_CONN_REQ_2 38 3762da14cebeSEric Cheng #define SQTAG_IP_INPUT_RX_RING 39 3763da14cebeSEric Cheng #define SQTAG_SQUEUE_CHANGE 40 3764da14cebeSEric Cheng #define SQTAG_CONNECT_FINISH 41 37650f1702c5SYu Xiangning #define SQTAG_SYNCHRONOUS_OP 42 37660f1702c5SYu Xiangning #define SQTAG_TCP_SHUTDOWN_OUTPUT 43 37670854dd28SPhilip Kirk #define SQTAG_XMIT_EARLY_RESET 44 37687c478bd9Sstevel@tonic-gate 376919a30e1aSrshoaib #define NOT_OVER_IP(ip_wq) \ 377019a30e1aSrshoaib (ip_wq->q_next != NULL || \ 377119a30e1aSrshoaib (ip_wq->q_qinfo->qi_minfo->mi_idname) == NULL || \ 377219a30e1aSrshoaib strcmp(ip_wq->q_qinfo->qi_minfo->mi_idname, \ 377319a30e1aSrshoaib IP_MOD_NAME) != 0 || \ 377419a30e1aSrshoaib ip_wq->q_qinfo->qi_minfo->mi_idnum != IP_MOD_ID) 377519a30e1aSrshoaib 37760f1702c5SYu Xiangning #define PROTO_FLOW_CNTRLD(connp) (connp->conn_flow_cntrld) 37777c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 37787c478bd9Sstevel@tonic-gate 37797c478bd9Sstevel@tonic-gate #ifdef __cplusplus 37807c478bd9Sstevel@tonic-gate } 37817c478bd9Sstevel@tonic-gate #endif 37827c478bd9Sstevel@tonic-gate 37837c478bd9Sstevel@tonic-gate #endif /* _INET_IP_H */ 3784