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 /* 23aa92d85bSgt145670 * Copyright 2008 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> 59c793af95Ssangeeta #include <net/radix.h> 606a8288c7Scarlsonj #include <sys/modhash.h> 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate #ifdef DEBUG 637c478bd9Sstevel@tonic-gate #define CONN_DEBUG 647c478bd9Sstevel@tonic-gate #endif 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate #define IP_DEBUG 677c478bd9Sstevel@tonic-gate /* 687c478bd9Sstevel@tonic-gate * The mt-streams(9F) flags for the IP module; put here so that other 697c478bd9Sstevel@tonic-gate * "drivers" that are actually IP (e.g., ICMP, UDP) can use the same set 707c478bd9Sstevel@tonic-gate * of flags. 717c478bd9Sstevel@tonic-gate */ 727c478bd9Sstevel@tonic-gate #define IP_DEVMTFLAGS D_MP 73ff550d0eSmasputra #endif /* _KERNEL */ 74ff550d0eSmasputra 75ff550d0eSmasputra #define IP_MOD_NAME "ip" 76ff550d0eSmasputra #define IP_DEV_NAME "/dev/ip" 77ff550d0eSmasputra #define IP6_DEV_NAME "/dev/ip6" 78ff550d0eSmasputra 79ff550d0eSmasputra #define UDP_MOD_NAME "udp" 80ff550d0eSmasputra #define UDP_DEV_NAME "/dev/udp" 81ff550d0eSmasputra #define UDP6_DEV_NAME "/dev/udp6" 82ff550d0eSmasputra 83ff550d0eSmasputra #define TCP_MOD_NAME "tcp" 84ff550d0eSmasputra #define TCP_DEV_NAME "/dev/tcp" 85ff550d0eSmasputra #define TCP6_DEV_NAME "/dev/tcp6" 867c478bd9Sstevel@tonic-gate 8777c67f2fSkcpoon #define SCTP_MOD_NAME "sctp" 8877c67f2fSkcpoon 897c478bd9Sstevel@tonic-gate #ifndef _IPADDR_T 907c478bd9Sstevel@tonic-gate #define _IPADDR_T 917c478bd9Sstevel@tonic-gate typedef uint32_t ipaddr_t; 927c478bd9Sstevel@tonic-gate #endif 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate /* Number of bits in an address */ 957c478bd9Sstevel@tonic-gate #define IP_ABITS 32 967c478bd9Sstevel@tonic-gate #define IPV6_ABITS 128 977c478bd9Sstevel@tonic-gate 987c478bd9Sstevel@tonic-gate #define IP_HOST_MASK (ipaddr_t)0xffffffffU 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate #define IP_CSUM(mp, off, sum) (~ip_cksum(mp, off, sum) & 0xFFFF) 1017c478bd9Sstevel@tonic-gate #define IP_CSUM_PARTIAL(mp, off, sum) ip_cksum(mp, off, sum) 1027c478bd9Sstevel@tonic-gate #define IP_BCSUM_PARTIAL(bp, len, sum) bcksum(bp, len, sum) 1037c478bd9Sstevel@tonic-gate #define IP_MD_CSUM(pd, off, sum) (~ip_md_cksum(pd, off, sum) & 0xffff) 1047c478bd9Sstevel@tonic-gate #define IP_MD_CSUM_PARTIAL(pd, off, sum) ip_md_cksum(pd, off, sum) 1057c478bd9Sstevel@tonic-gate 1067c478bd9Sstevel@tonic-gate /* 1077c478bd9Sstevel@tonic-gate * Flag to IP write side to indicate that the appln has sent in a pre-built 1087c478bd9Sstevel@tonic-gate * IP header. Stored in ipha_ident (which is otherwise zero). 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate #define IP_HDR_INCLUDED 0xFFFF 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate #define ILL_FRAG_HASH_TBL_COUNT ((unsigned int)64) 1137c478bd9Sstevel@tonic-gate #define ILL_FRAG_HASH_TBL_SIZE (ILL_FRAG_HASH_TBL_COUNT * sizeof (ipfb_t)) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate #define IPV4_ADDR_LEN 4 1167c478bd9Sstevel@tonic-gate #define IP_ADDR_LEN IPV4_ADDR_LEN 1177c478bd9Sstevel@tonic-gate #define IP_ARP_PROTO_TYPE 0x0800 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate #define IPV4_VERSION 4 1207c478bd9Sstevel@tonic-gate #define IP_VERSION IPV4_VERSION 1217c478bd9Sstevel@tonic-gate #define IP_SIMPLE_HDR_LENGTH_IN_WORDS 5 1227c478bd9Sstevel@tonic-gate #define IP_SIMPLE_HDR_LENGTH 20 1237c478bd9Sstevel@tonic-gate #define IP_MAX_HDR_LENGTH 60 1247c478bd9Sstevel@tonic-gate 12545916cd2Sjpk #define IP_MAX_OPT_LENGTH (IP_MAX_HDR_LENGTH-IP_SIMPLE_HDR_LENGTH) 12645916cd2Sjpk 1277c478bd9Sstevel@tonic-gate #define IP_MIN_MTU (IP_MAX_HDR_LENGTH + 8) /* 68 bytes */ 1287c478bd9Sstevel@tonic-gate 1297c478bd9Sstevel@tonic-gate /* 1307c478bd9Sstevel@tonic-gate * XXX IP_MAXPACKET is defined in <netinet/ip.h> as well. At some point the 1317c478bd9Sstevel@tonic-gate * 2 files should be cleaned up to remove all redundant definitions. 1327c478bd9Sstevel@tonic-gate */ 1337c478bd9Sstevel@tonic-gate #define IP_MAXPACKET 65535 1347c478bd9Sstevel@tonic-gate #define IP_SIMPLE_HDR_VERSION \ 1357c478bd9Sstevel@tonic-gate ((IP_VERSION << 4) | IP_SIMPLE_HDR_LENGTH_IN_WORDS) 1367c478bd9Sstevel@tonic-gate 13745916cd2Sjpk #define UDPH_SIZE 8 13845916cd2Sjpk 139c793af95Ssangeeta /* Leave room for ip_newroute to tack on the src and target addresses */ 140c793af95Ssangeeta #define OK_RESOLVER_MP(mp) \ 141c793af95Ssangeeta ((mp) && ((mp)->b_wptr - (mp)->b_rptr) >= (2 * IP_ADDR_LEN)) 142c793af95Ssangeeta 1437c478bd9Sstevel@tonic-gate /* 1447c478bd9Sstevel@tonic-gate * Constants and type definitions to support IP IOCTL commands 1457c478bd9Sstevel@tonic-gate */ 1467c478bd9Sstevel@tonic-gate #define IP_IOCTL (('i'<<8)|'p') 1477c478bd9Sstevel@tonic-gate #define IP_IOC_IRE_DELETE 4 1487c478bd9Sstevel@tonic-gate #define IP_IOC_IRE_DELETE_NO_REPLY 5 1497c478bd9Sstevel@tonic-gate #define IP_IOC_IRE_ADVISE_NO_REPLY 6 1507c478bd9Sstevel@tonic-gate #define IP_IOC_RTS_REQUEST 7 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* Common definitions used by IP IOCTL data structures */ 1537c478bd9Sstevel@tonic-gate typedef struct ipllcmd_s { 1547c478bd9Sstevel@tonic-gate uint_t ipllc_cmd; 1557c478bd9Sstevel@tonic-gate uint_t ipllc_name_offset; 1567c478bd9Sstevel@tonic-gate uint_t ipllc_name_length; 1577c478bd9Sstevel@tonic-gate } ipllc_t; 1587c478bd9Sstevel@tonic-gate 1597c478bd9Sstevel@tonic-gate /* IP IRE Change Command Structure. */ 1607c478bd9Sstevel@tonic-gate typedef struct ipic_s { 1617c478bd9Sstevel@tonic-gate ipllc_t ipic_ipllc; 1627c478bd9Sstevel@tonic-gate uint_t ipic_ire_type; 1637c478bd9Sstevel@tonic-gate uint_t ipic_max_frag; 1647c478bd9Sstevel@tonic-gate uint_t ipic_addr_offset; 1657c478bd9Sstevel@tonic-gate uint_t ipic_addr_length; 1667c478bd9Sstevel@tonic-gate uint_t ipic_mask_offset; 1677c478bd9Sstevel@tonic-gate uint_t ipic_mask_length; 1687c478bd9Sstevel@tonic-gate uint_t ipic_src_addr_offset; 1697c478bd9Sstevel@tonic-gate uint_t ipic_src_addr_length; 1707c478bd9Sstevel@tonic-gate uint_t ipic_ll_hdr_offset; 1717c478bd9Sstevel@tonic-gate uint_t ipic_ll_hdr_length; 1727c478bd9Sstevel@tonic-gate uint_t ipic_gateway_addr_offset; 1737c478bd9Sstevel@tonic-gate uint_t ipic_gateway_addr_length; 1747c478bd9Sstevel@tonic-gate clock_t ipic_rtt; 1757c478bd9Sstevel@tonic-gate uint32_t ipic_ssthresh; 1767c478bd9Sstevel@tonic-gate clock_t ipic_rtt_sd; 1777c478bd9Sstevel@tonic-gate uchar_t ipic_ire_marks; 1787c478bd9Sstevel@tonic-gate } ipic_t; 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate #define ipic_cmd ipic_ipllc.ipllc_cmd 1817c478bd9Sstevel@tonic-gate #define ipic_ll_name_length ipic_ipllc.ipllc_name_length 1827c478bd9Sstevel@tonic-gate #define ipic_ll_name_offset ipic_ipllc.ipllc_name_offset 1837c478bd9Sstevel@tonic-gate 1847c478bd9Sstevel@tonic-gate /* IP IRE Delete Command Structure. */ 1857c478bd9Sstevel@tonic-gate typedef struct ipid_s { 1867c478bd9Sstevel@tonic-gate ipllc_t ipid_ipllc; 1877c478bd9Sstevel@tonic-gate uint_t ipid_ire_type; 1887c478bd9Sstevel@tonic-gate uint_t ipid_addr_offset; 1897c478bd9Sstevel@tonic-gate uint_t ipid_addr_length; 1907c478bd9Sstevel@tonic-gate uint_t ipid_mask_offset; 1917c478bd9Sstevel@tonic-gate uint_t ipid_mask_length; 1927c478bd9Sstevel@tonic-gate } ipid_t; 1937c478bd9Sstevel@tonic-gate 1947c478bd9Sstevel@tonic-gate #define ipid_cmd ipid_ipllc.ipllc_cmd 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate #ifdef _KERNEL 1977c478bd9Sstevel@tonic-gate /* 1987c478bd9Sstevel@tonic-gate * Temporary state for ip options parser. 1997c478bd9Sstevel@tonic-gate */ 2007c478bd9Sstevel@tonic-gate typedef struct ipoptp_s 2017c478bd9Sstevel@tonic-gate { 2027c478bd9Sstevel@tonic-gate uint8_t *ipoptp_next; /* next option to look at */ 2037c478bd9Sstevel@tonic-gate uint8_t *ipoptp_end; /* end of options */ 2047c478bd9Sstevel@tonic-gate uint8_t *ipoptp_cur; /* start of current option */ 2057c478bd9Sstevel@tonic-gate uint8_t ipoptp_len; /* length of current option */ 2067c478bd9Sstevel@tonic-gate uint32_t ipoptp_flags; 2077c478bd9Sstevel@tonic-gate } ipoptp_t; 2087c478bd9Sstevel@tonic-gate 2097c478bd9Sstevel@tonic-gate /* 2107c478bd9Sstevel@tonic-gate * Flag(s) for ipoptp_flags 2117c478bd9Sstevel@tonic-gate */ 2127c478bd9Sstevel@tonic-gate #define IPOPTP_ERROR 0x00000001 2137c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 2147c478bd9Sstevel@tonic-gate 2157c478bd9Sstevel@tonic-gate /* Controls forwarding of IP packets, set via ndd */ 2167c478bd9Sstevel@tonic-gate #define IP_FORWARD_NEVER 0 2177c478bd9Sstevel@tonic-gate #define IP_FORWARD_ALWAYS 1 2187c478bd9Sstevel@tonic-gate 219f4b3ec61Sdh155122 #define WE_ARE_FORWARDING(ipst) ((ipst)->ips_ip_g_forward == IP_FORWARD_ALWAYS) 2207c478bd9Sstevel@tonic-gate 2217c478bd9Sstevel@tonic-gate #define IPH_HDR_LENGTH(ipha) \ 2227c478bd9Sstevel@tonic-gate ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length & 0xF) << 2) 2237c478bd9Sstevel@tonic-gate 2247c478bd9Sstevel@tonic-gate #define IPH_HDR_VERSION(ipha) \ 2257c478bd9Sstevel@tonic-gate ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length) >> 4) 2267c478bd9Sstevel@tonic-gate 2277c478bd9Sstevel@tonic-gate #ifdef _KERNEL 2287c478bd9Sstevel@tonic-gate /* 2297c478bd9Sstevel@tonic-gate * IP reassembly macros. We hide starting and ending offsets in b_next and 2307c478bd9Sstevel@tonic-gate * b_prev of messages on the reassembly queue. The messages are chained using 2317c478bd9Sstevel@tonic-gate * b_cont. These macros are used in ip_reassemble() so we don't have to see 2327c478bd9Sstevel@tonic-gate * the ugly casts and assignments. 2337c478bd9Sstevel@tonic-gate * Note that the offsets are <= 64k i.e. a uint_t is sufficient to represent 2347c478bd9Sstevel@tonic-gate * them. 2357c478bd9Sstevel@tonic-gate */ 2367c478bd9Sstevel@tonic-gate #define IP_REASS_START(mp) ((uint_t)(uintptr_t)((mp)->b_next)) 2377c478bd9Sstevel@tonic-gate #define IP_REASS_SET_START(mp, u) \ 2387c478bd9Sstevel@tonic-gate ((mp)->b_next = (mblk_t *)(uintptr_t)(u)) 2397c478bd9Sstevel@tonic-gate #define IP_REASS_END(mp) ((uint_t)(uintptr_t)((mp)->b_prev)) 2407c478bd9Sstevel@tonic-gate #define IP_REASS_SET_END(mp, u) \ 2417c478bd9Sstevel@tonic-gate ((mp)->b_prev = (mblk_t *)(uintptr_t)(u)) 2427c478bd9Sstevel@tonic-gate 2437c478bd9Sstevel@tonic-gate #define IP_REASS_COMPLETE 0x1 2447c478bd9Sstevel@tonic-gate #define IP_REASS_PARTIAL 0x2 2457c478bd9Sstevel@tonic-gate #define IP_REASS_FAILED 0x4 2467c478bd9Sstevel@tonic-gate 2477c478bd9Sstevel@tonic-gate /* 2487c478bd9Sstevel@tonic-gate * Test to determine whether this is a module instance of IP or a 2497c478bd9Sstevel@tonic-gate * driver instance of IP. 2507c478bd9Sstevel@tonic-gate */ 2517c478bd9Sstevel@tonic-gate #define CONN_Q(q) (WR(q)->q_next == NULL) 2527c478bd9Sstevel@tonic-gate 2537c478bd9Sstevel@tonic-gate #define Q_TO_CONN(q) ((conn_t *)(q)->q_ptr) 2547c478bd9Sstevel@tonic-gate #define Q_TO_TCP(q) (Q_TO_CONN((q))->conn_tcp) 255ff550d0eSmasputra #define Q_TO_UDP(q) (Q_TO_CONN((q))->conn_udp) 256fc80c0dfSnordmark #define Q_TO_ICMP(q) (Q_TO_CONN((q))->conn_icmp) 257fc80c0dfSnordmark #define Q_TO_RTS(q) (Q_TO_CONN((q))->conn_rts) 2587c478bd9Sstevel@tonic-gate 2597c478bd9Sstevel@tonic-gate /* 2607c478bd9Sstevel@tonic-gate * The following two macros are used by IP to get the appropriate 2617c478bd9Sstevel@tonic-gate * wq and rq for a conn. If it is a TCP conn, then we need 2627c478bd9Sstevel@tonic-gate * tcp_wq/tcp_rq else, conn_wq/conn_rq. IP can use conn_wq and conn_rq 2637c478bd9Sstevel@tonic-gate * from a conn directly if it knows that the conn is not TCP. 2647c478bd9Sstevel@tonic-gate */ 2657c478bd9Sstevel@tonic-gate #define CONNP_TO_WQ(connp) \ 266ff550d0eSmasputra (IPCL_IS_TCP(connp) ? (connp)->conn_tcp->tcp_wq : (connp)->conn_wq) 2677c478bd9Sstevel@tonic-gate 2687c478bd9Sstevel@tonic-gate #define CONNP_TO_RQ(connp) RD(CONNP_TO_WQ(connp)) 2697c478bd9Sstevel@tonic-gate 2707c478bd9Sstevel@tonic-gate #define GRAB_CONN_LOCK(q) { \ 2717c478bd9Sstevel@tonic-gate if (q != NULL && CONN_Q(q)) \ 2727c478bd9Sstevel@tonic-gate mutex_enter(&(Q_TO_CONN(q))->conn_lock); \ 2737c478bd9Sstevel@tonic-gate } 2747c478bd9Sstevel@tonic-gate 2757c478bd9Sstevel@tonic-gate #define RELEASE_CONN_LOCK(q) { \ 2767c478bd9Sstevel@tonic-gate if (q != NULL && CONN_Q(q)) \ 2777c478bd9Sstevel@tonic-gate mutex_exit(&(Q_TO_CONN(q))->conn_lock); \ 2787c478bd9Sstevel@tonic-gate } 2797c478bd9Sstevel@tonic-gate 2807c478bd9Sstevel@tonic-gate /* "Congestion controlled" protocol */ 2817c478bd9Sstevel@tonic-gate #define IP_FLOW_CONTROLLED_ULP(p) ((p) == IPPROTO_TCP || (p) == IPPROTO_SCTP) 2827c478bd9Sstevel@tonic-gate 2837c478bd9Sstevel@tonic-gate /* 2847c478bd9Sstevel@tonic-gate * Complete the pending operation. Usually an ioctl. Can also 2857c478bd9Sstevel@tonic-gate * be a bind or option management request that got enqueued 2867c478bd9Sstevel@tonic-gate * in an ipsq_t. Called on completion of the operation. 2877c478bd9Sstevel@tonic-gate */ 2887c478bd9Sstevel@tonic-gate #define CONN_OPER_PENDING_DONE(connp) { \ 2897c478bd9Sstevel@tonic-gate mutex_enter(&(connp)->conn_lock); \ 2907c478bd9Sstevel@tonic-gate (connp)->conn_oper_pending_ill = NULL; \ 2917c478bd9Sstevel@tonic-gate cv_broadcast(&(connp)->conn_refcv); \ 2927c478bd9Sstevel@tonic-gate mutex_exit(&(connp)->conn_lock); \ 2937c478bd9Sstevel@tonic-gate CONN_DEC_REF(connp); \ 2947c478bd9Sstevel@tonic-gate } 2957c478bd9Sstevel@tonic-gate 2967c478bd9Sstevel@tonic-gate /* Get the credential of an IP queue of unknown type */ 2977c478bd9Sstevel@tonic-gate #define GET_QUEUE_CRED(wq) \ 2987c478bd9Sstevel@tonic-gate ((wq)->q_next ? (((ill_t *)(wq)->q_ptr)->ill_credp) \ 2997c478bd9Sstevel@tonic-gate : ((Q_TO_CONN((wq)))->conn_cred)) 3007c478bd9Sstevel@tonic-gate 3017c478bd9Sstevel@tonic-gate /* 3027c478bd9Sstevel@tonic-gate * Flags for the various ip_fanout_* routines. 3037c478bd9Sstevel@tonic-gate */ 3047c478bd9Sstevel@tonic-gate #define IP_FF_SEND_ICMP 0x01 /* Send an ICMP error */ 3057c478bd9Sstevel@tonic-gate #define IP_FF_HDR_COMPLETE 0x02 /* Call ip_hdr_complete if error */ 3067c478bd9Sstevel@tonic-gate #define IP_FF_CKSUM 0x04 /* Recompute ipha_cksum if error */ 3077c478bd9Sstevel@tonic-gate #define IP_FF_RAWIP 0x08 /* Use rawip mib variable */ 3087c478bd9Sstevel@tonic-gate #define IP_FF_SRC_QUENCH 0x10 /* OK to send ICMP_SOURCE_QUENCH */ 3097c478bd9Sstevel@tonic-gate #define IP_FF_SYN_ADDIRE 0x20 /* Add IRE if TCP syn packet */ 31019a30e1aSrshoaib #define IP_FF_IPINFO 0x80 /* Used for both V4 and V6 */ 3117c478bd9Sstevel@tonic-gate #define IP_FF_SEND_SLLA 0x100 /* Send source link layer info ? */ 3127c478bd9Sstevel@tonic-gate #define IPV6_REACHABILITY_CONFIRMATION 0x200 /* Flags for ip_xmit_v6 */ 3137c478bd9Sstevel@tonic-gate #define IP_FF_NO_MCAST_LOOP 0x400 /* No multicasts for sending zone */ 3147c478bd9Sstevel@tonic-gate 3157c478bd9Sstevel@tonic-gate /* 3167c478bd9Sstevel@tonic-gate * Following flags are used by IPQoS to determine if policy processing is 3177c478bd9Sstevel@tonic-gate * required. 3187c478bd9Sstevel@tonic-gate */ 3197c478bd9Sstevel@tonic-gate #define IP6_NO_IPPOLICY 0x800 /* Don't do IPQoS processing */ 3207c478bd9Sstevel@tonic-gate #define IP6_IN_LLMCAST 0x1000 /* Multicast */ 3217c478bd9Sstevel@tonic-gate 322ff550d0eSmasputra #define IP_FF_LOOPBACK 0x2000 /* Loopback fanout */ 323b043aa6fSgeorges #define IP_FF_SCTP_CSUM_ERR 0x4000 /* sctp pkt has failed chksum */ 3247c478bd9Sstevel@tonic-gate 3257c478bd9Sstevel@tonic-gate #ifndef IRE_DB_TYPE 3267c478bd9Sstevel@tonic-gate #define IRE_DB_TYPE M_SIG 3277c478bd9Sstevel@tonic-gate #endif 3287c478bd9Sstevel@tonic-gate 3297c478bd9Sstevel@tonic-gate #ifndef IRE_DB_REQ_TYPE 3307c478bd9Sstevel@tonic-gate #define IRE_DB_REQ_TYPE M_PCSIG 3317c478bd9Sstevel@tonic-gate #endif 3327c478bd9Sstevel@tonic-gate 333c793af95Ssangeeta #ifndef IRE_ARPRESOLVE_TYPE 334c793af95Ssangeeta #define IRE_ARPRESOLVE_TYPE M_EVENT 335c793af95Ssangeeta #endif 336c793af95Ssangeeta 3377c478bd9Sstevel@tonic-gate /* 3387c478bd9Sstevel@tonic-gate * Values for squeue switch: 3397c478bd9Sstevel@tonic-gate */ 3407c478bd9Sstevel@tonic-gate 3417c478bd9Sstevel@tonic-gate #define IP_SQUEUE_ENTER_NODRAIN 1 3427c478bd9Sstevel@tonic-gate #define IP_SQUEUE_ENTER 2 3437c478bd9Sstevel@tonic-gate /* 3447c478bd9Sstevel@tonic-gate * This is part of the interface between Transport provider and 3457c478bd9Sstevel@tonic-gate * IP which can be used to set policy information. This is usually 3467c478bd9Sstevel@tonic-gate * accompanied with O_T_BIND_REQ/T_BIND_REQ.ip_bind assumes that 3477c478bd9Sstevel@tonic-gate * only IPSEC_POLICY_SET is there when it is found in the chain. 3487c478bd9Sstevel@tonic-gate * The information contained is an struct ipsec_req_t. On success 3497c478bd9Sstevel@tonic-gate * or failure, either the T_BIND_ACK or the T_ERROR_ACK is returned. 3507c478bd9Sstevel@tonic-gate * IPSEC_POLICY_SET is never returned. 3517c478bd9Sstevel@tonic-gate */ 3527c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_SET M_SETOPTS 3537c478bd9Sstevel@tonic-gate 3547c478bd9Sstevel@tonic-gate #define IRE_IS_LOCAL(ire) ((ire != NULL) && \ 3557c478bd9Sstevel@tonic-gate ((ire)->ire_type & (IRE_LOCAL | IRE_LOOPBACK))) 3567c478bd9Sstevel@tonic-gate 3577c478bd9Sstevel@tonic-gate #define IRE_IS_TARGET(ire) ((ire != NULL) && \ 3587c478bd9Sstevel@tonic-gate ((ire)->ire_type != IRE_BROADCAST)) 3597c478bd9Sstevel@tonic-gate 3607c478bd9Sstevel@tonic-gate /* IP Fragmentation Reassembly Header */ 3617c478bd9Sstevel@tonic-gate typedef struct ipf_s { 3627c478bd9Sstevel@tonic-gate struct ipf_s *ipf_hash_next; 3637c478bd9Sstevel@tonic-gate struct ipf_s **ipf_ptphn; /* Pointer to previous hash next. */ 3647c478bd9Sstevel@tonic-gate uint32_t ipf_ident; /* Ident to match. */ 3657c478bd9Sstevel@tonic-gate uint8_t ipf_protocol; /* Protocol to match. */ 3667c478bd9Sstevel@tonic-gate uchar_t ipf_last_frag_seen : 1; /* Last fragment seen ? */ 3677c478bd9Sstevel@tonic-gate time_t ipf_timestamp; /* Reassembly start time. */ 3687c478bd9Sstevel@tonic-gate mblk_t *ipf_mp; /* mblk we live in. */ 3697c478bd9Sstevel@tonic-gate mblk_t *ipf_tail_mp; /* Frag queue tail pointer. */ 3707c478bd9Sstevel@tonic-gate int ipf_hole_cnt; /* Number of holes (hard-case). */ 3717c478bd9Sstevel@tonic-gate int ipf_end; /* Tail end offset (0 -> hard-case). */ 3727c478bd9Sstevel@tonic-gate uint_t ipf_gen; /* Frag queue generation */ 3737c478bd9Sstevel@tonic-gate size_t ipf_count; /* Count of bytes used by frag */ 3747c478bd9Sstevel@tonic-gate uint_t ipf_nf_hdr_len; /* Length of nonfragmented header */ 3757c478bd9Sstevel@tonic-gate in6_addr_t ipf_v6src; /* IPv6 source address */ 3767c478bd9Sstevel@tonic-gate in6_addr_t ipf_v6dst; /* IPv6 dest address */ 3777c478bd9Sstevel@tonic-gate uint_t ipf_prev_nexthdr_offset; /* Offset for nexthdr value */ 3787c478bd9Sstevel@tonic-gate uint8_t ipf_ecn; /* ECN info for the fragments */ 3797c478bd9Sstevel@tonic-gate uint8_t ipf_num_dups; /* Number of times dup frags recvd */ 380ff550d0eSmasputra uint16_t ipf_checksum_flags; /* Hardware checksum flags */ 381ff550d0eSmasputra uint32_t ipf_checksum; /* Partial checksum of fragment data */ 3827c478bd9Sstevel@tonic-gate } ipf_t; 3837c478bd9Sstevel@tonic-gate 384da14cebeSEric Cheng /* 385da14cebeSEric Cheng * IPv4 Fragments 386da14cebeSEric Cheng */ 387da14cebeSEric Cheng #define IS_V4_FRAGMENT(ipha_fragment_offset_and_flags) \ 388da14cebeSEric Cheng (((ntohs(ipha_fragment_offset_and_flags) & IPH_OFFSET) != 0) || \ 389da14cebeSEric Cheng ((ntohs(ipha_fragment_offset_and_flags) & IPH_MF) != 0)) 390da14cebeSEric Cheng 3917c478bd9Sstevel@tonic-gate #define ipf_src V4_PART_OF_V6(ipf_v6src) 3927c478bd9Sstevel@tonic-gate #define ipf_dst V4_PART_OF_V6(ipf_v6dst) 3937c478bd9Sstevel@tonic-gate 3947c478bd9Sstevel@tonic-gate typedef enum { 3957c478bd9Sstevel@tonic-gate IB_PKT = 0x01, 3967c478bd9Sstevel@tonic-gate OB_PKT = 0x02 3977c478bd9Sstevel@tonic-gate } ip_pkt_t; 3987c478bd9Sstevel@tonic-gate 3997c478bd9Sstevel@tonic-gate #define UPDATE_IB_PKT_COUNT(ire)\ 4007c478bd9Sstevel@tonic-gate { \ 4017c478bd9Sstevel@tonic-gate (ire)->ire_ib_pkt_count++; \ 4027c478bd9Sstevel@tonic-gate if ((ire)->ire_ipif != NULL) { \ 4037c478bd9Sstevel@tonic-gate /* \ 4047c478bd9Sstevel@tonic-gate * forwarding packet \ 4057c478bd9Sstevel@tonic-gate */ \ 4067c478bd9Sstevel@tonic-gate if ((ire)->ire_type & (IRE_LOCAL|IRE_BROADCAST)) \ 4077c478bd9Sstevel@tonic-gate atomic_add_32(&(ire)->ire_ipif->ipif_ib_pkt_count, 1);\ 4087c478bd9Sstevel@tonic-gate else \ 4097c478bd9Sstevel@tonic-gate atomic_add_32(&(ire)->ire_ipif->ipif_fo_pkt_count, 1);\ 4107c478bd9Sstevel@tonic-gate } \ 4117c478bd9Sstevel@tonic-gate } 4127924222fSmeem 4137c478bd9Sstevel@tonic-gate #define UPDATE_OB_PKT_COUNT(ire)\ 4147c478bd9Sstevel@tonic-gate { \ 4157c478bd9Sstevel@tonic-gate (ire)->ire_ob_pkt_count++;\ 4167c478bd9Sstevel@tonic-gate if ((ire)->ire_ipif != NULL) { \ 4177c478bd9Sstevel@tonic-gate atomic_add_32(&(ire)->ire_ipif->ipif_ob_pkt_count, 1); \ 4187c478bd9Sstevel@tonic-gate } \ 4197c478bd9Sstevel@tonic-gate } 4207c478bd9Sstevel@tonic-gate 4217c478bd9Sstevel@tonic-gate #define IP_RPUT_LOCAL(q, mp, ipha, ire, recv_ill) \ 4227c478bd9Sstevel@tonic-gate { \ 4237c478bd9Sstevel@tonic-gate switch (ipha->ipha_protocol) { \ 4247c478bd9Sstevel@tonic-gate case IPPROTO_UDP: \ 4257c478bd9Sstevel@tonic-gate ip_udp_input(q, mp, ipha, ire, recv_ill); \ 4267c478bd9Sstevel@tonic-gate break; \ 4277c478bd9Sstevel@tonic-gate default: \ 4284a179720Sdanmcd ip_proto_input(q, mp, ipha, ire, recv_ill, 0); \ 4297c478bd9Sstevel@tonic-gate break; \ 4307c478bd9Sstevel@tonic-gate } \ 4317c478bd9Sstevel@tonic-gate } 4327c478bd9Sstevel@tonic-gate 433c793af95Ssangeeta /* 434c793af95Ssangeeta * NCE_EXPIRED is TRUE when we have a non-permanent nce that was 435c793af95Ssangeeta * found to be REACHABLE more than ip_ire_arp_interval ms ago. 436b9c344b3Ssowmini * This macro is used to age existing nce_t entries. The 437b9c344b3Ssowmini * nce's will get cleaned up in the following circumstances: 438c793af95Ssangeeta * - ip_ire_trash_reclaim will free nce's using ndp_cache_reclaim 439c793af95Ssangeeta * when memory is low, 440c793af95Ssangeeta * - ip_arp_news, when updates are received. 441b9c344b3Ssowmini * - if the nce is NCE_EXPIRED(), it will deleted, so that a new 442b9c344b3Ssowmini * arp request will need to be triggered from an ND_INITIAL nce. 443b9c344b3Ssowmini * 444b9c344b3Ssowmini * Note that the nce state transition follows the pattern: 445b9c344b3Ssowmini * ND_INITIAL -> ND_INCOMPLETE -> ND_REACHABLE 446b9c344b3Ssowmini * after which the nce is deleted when it has expired. 447b9c344b3Ssowmini * 448c793af95Ssangeeta * nce_last is the timestamp that indicates when the nce_res_mp in the 449c793af95Ssangeeta * nce_t was last updated to a valid link-layer address. nce_last gets 450c793af95Ssangeeta * modified/updated : 451b9c344b3Ssowmini * - when the nce is created 452c793af95Ssangeeta * - every time we get a sane arp response for the nce. 453c793af95Ssangeeta */ 454f4b3ec61Sdh155122 #define NCE_EXPIRED(nce, ipst) (nce->nce_last > 0 && \ 455c793af95Ssangeeta ((nce->nce_flags & NCE_F_PERMANENT) == 0) && \ 456f4b3ec61Sdh155122 ((TICK_TO_MSEC(lbolt64) - nce->nce_last) > \ 457f4b3ec61Sdh155122 (ipst)->ips_ip_ire_arp_interval)) 4587c478bd9Sstevel@tonic-gate 4597c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 4607c478bd9Sstevel@tonic-gate 4617c478bd9Sstevel@tonic-gate /* ICMP types */ 4627c478bd9Sstevel@tonic-gate #define ICMP_ECHO_REPLY 0 4637c478bd9Sstevel@tonic-gate #define ICMP_DEST_UNREACHABLE 3 4647c478bd9Sstevel@tonic-gate #define ICMP_SOURCE_QUENCH 4 4657c478bd9Sstevel@tonic-gate #define ICMP_REDIRECT 5 4667c478bd9Sstevel@tonic-gate #define ICMP_ECHO_REQUEST 8 4677c478bd9Sstevel@tonic-gate #define ICMP_ROUTER_ADVERTISEMENT 9 4687c478bd9Sstevel@tonic-gate #define ICMP_ROUTER_SOLICITATION 10 4697c478bd9Sstevel@tonic-gate #define ICMP_TIME_EXCEEDED 11 4707c478bd9Sstevel@tonic-gate #define ICMP_PARAM_PROBLEM 12 4717c478bd9Sstevel@tonic-gate #define ICMP_TIME_STAMP_REQUEST 13 4727c478bd9Sstevel@tonic-gate #define ICMP_TIME_STAMP_REPLY 14 4737c478bd9Sstevel@tonic-gate #define ICMP_INFO_REQUEST 15 4747c478bd9Sstevel@tonic-gate #define ICMP_INFO_REPLY 16 4757c478bd9Sstevel@tonic-gate #define ICMP_ADDRESS_MASK_REQUEST 17 4767c478bd9Sstevel@tonic-gate #define ICMP_ADDRESS_MASK_REPLY 18 4777c478bd9Sstevel@tonic-gate 4787c478bd9Sstevel@tonic-gate /* ICMP_TIME_EXCEEDED codes */ 4797c478bd9Sstevel@tonic-gate #define ICMP_TTL_EXCEEDED 0 4807c478bd9Sstevel@tonic-gate #define ICMP_REASSEMBLY_TIME_EXCEEDED 1 4817c478bd9Sstevel@tonic-gate 4827c478bd9Sstevel@tonic-gate /* ICMP_DEST_UNREACHABLE codes */ 4837c478bd9Sstevel@tonic-gate #define ICMP_NET_UNREACHABLE 0 4847c478bd9Sstevel@tonic-gate #define ICMP_HOST_UNREACHABLE 1 4857c478bd9Sstevel@tonic-gate #define ICMP_PROTOCOL_UNREACHABLE 2 4867c478bd9Sstevel@tonic-gate #define ICMP_PORT_UNREACHABLE 3 4877c478bd9Sstevel@tonic-gate #define ICMP_FRAGMENTATION_NEEDED 4 4887c478bd9Sstevel@tonic-gate #define ICMP_SOURCE_ROUTE_FAILED 5 4897c478bd9Sstevel@tonic-gate #define ICMP_DEST_NET_UNKNOWN 6 4907c478bd9Sstevel@tonic-gate #define ICMP_DEST_HOST_UNKNOWN 7 4917c478bd9Sstevel@tonic-gate #define ICMP_SRC_HOST_ISOLATED 8 4927c478bd9Sstevel@tonic-gate #define ICMP_DEST_NET_UNREACH_ADMIN 9 4937c478bd9Sstevel@tonic-gate #define ICMP_DEST_HOST_UNREACH_ADMIN 10 4947c478bd9Sstevel@tonic-gate #define ICMP_DEST_NET_UNREACH_TOS 11 4957c478bd9Sstevel@tonic-gate #define ICMP_DEST_HOST_UNREACH_TOS 12 4967c478bd9Sstevel@tonic-gate 4977c478bd9Sstevel@tonic-gate /* ICMP Header Structure */ 4987c478bd9Sstevel@tonic-gate typedef struct icmph_s { 4997c478bd9Sstevel@tonic-gate uint8_t icmph_type; 5007c478bd9Sstevel@tonic-gate uint8_t icmph_code; 5017c478bd9Sstevel@tonic-gate uint16_t icmph_checksum; 5027c478bd9Sstevel@tonic-gate union { 5037c478bd9Sstevel@tonic-gate struct { /* ECHO request/response structure */ 5047c478bd9Sstevel@tonic-gate uint16_t u_echo_ident; 5057c478bd9Sstevel@tonic-gate uint16_t u_echo_seqnum; 5067c478bd9Sstevel@tonic-gate } u_echo; 5077c478bd9Sstevel@tonic-gate struct { /* Destination unreachable structure */ 5087c478bd9Sstevel@tonic-gate uint16_t u_du_zero; 5097c478bd9Sstevel@tonic-gate uint16_t u_du_mtu; 5107c478bd9Sstevel@tonic-gate } u_du; 5117c478bd9Sstevel@tonic-gate struct { /* Parameter problem structure */ 5127c478bd9Sstevel@tonic-gate uint8_t u_pp_ptr; 5137c478bd9Sstevel@tonic-gate uint8_t u_pp_rsvd[3]; 5147c478bd9Sstevel@tonic-gate } u_pp; 5157c478bd9Sstevel@tonic-gate struct { /* Redirect structure */ 5167c478bd9Sstevel@tonic-gate ipaddr_t u_rd_gateway; 5177c478bd9Sstevel@tonic-gate } u_rd; 5187c478bd9Sstevel@tonic-gate } icmph_u; 5197c478bd9Sstevel@tonic-gate } icmph_t; 5207c478bd9Sstevel@tonic-gate 5217c478bd9Sstevel@tonic-gate #define icmph_echo_ident icmph_u.u_echo.u_echo_ident 5227c478bd9Sstevel@tonic-gate #define icmph_echo_seqnum icmph_u.u_echo.u_echo_seqnum 5237c478bd9Sstevel@tonic-gate #define icmph_du_zero icmph_u.u_du.u_du_zero 5247c478bd9Sstevel@tonic-gate #define icmph_du_mtu icmph_u.u_du.u_du_mtu 5257c478bd9Sstevel@tonic-gate #define icmph_pp_ptr icmph_u.u_pp.u_pp_ptr 5267c478bd9Sstevel@tonic-gate #define icmph_rd_gateway icmph_u.u_rd.u_rd_gateway 5277c478bd9Sstevel@tonic-gate 5287c478bd9Sstevel@tonic-gate #define ICMPH_SIZE 8 5297c478bd9Sstevel@tonic-gate 5307c478bd9Sstevel@tonic-gate /* 5317c478bd9Sstevel@tonic-gate * Minimum length of transport layer header included in an ICMP error 5327c478bd9Sstevel@tonic-gate * message for it to be considered valid. 5337c478bd9Sstevel@tonic-gate */ 5347c478bd9Sstevel@tonic-gate #define ICMP_MIN_TP_HDR_LEN 8 5357c478bd9Sstevel@tonic-gate 5367c478bd9Sstevel@tonic-gate /* Aligned IP header */ 5377c478bd9Sstevel@tonic-gate typedef struct ipha_s { 5387c478bd9Sstevel@tonic-gate uint8_t ipha_version_and_hdr_length; 5397c478bd9Sstevel@tonic-gate uint8_t ipha_type_of_service; 5407c478bd9Sstevel@tonic-gate uint16_t ipha_length; 5417c478bd9Sstevel@tonic-gate uint16_t ipha_ident; 5427c478bd9Sstevel@tonic-gate uint16_t ipha_fragment_offset_and_flags; 5437c478bd9Sstevel@tonic-gate uint8_t ipha_ttl; 5447c478bd9Sstevel@tonic-gate uint8_t ipha_protocol; 5457c478bd9Sstevel@tonic-gate uint16_t ipha_hdr_checksum; 5467c478bd9Sstevel@tonic-gate ipaddr_t ipha_src; 5477c478bd9Sstevel@tonic-gate ipaddr_t ipha_dst; 5487c478bd9Sstevel@tonic-gate } ipha_t; 5497c478bd9Sstevel@tonic-gate 55010e6dadfSbrendan /* 55110e6dadfSbrendan * IP Flags 55210e6dadfSbrendan * 55310e6dadfSbrendan * Some of these constant names are copied for the DTrace IP provider in 55410e6dadfSbrendan * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept 55510e6dadfSbrendan * in sync. 55610e6dadfSbrendan */ 5577c478bd9Sstevel@tonic-gate #define IPH_DF 0x4000 /* Don't fragment */ 5587c478bd9Sstevel@tonic-gate #define IPH_MF 0x2000 /* More fragments to come */ 5597c478bd9Sstevel@tonic-gate #define IPH_OFFSET 0x1FFF /* Where the offset lives */ 5607c478bd9Sstevel@tonic-gate #define IPH_FRAG_HDR 0x8000 /* IPv6 don't fragment bit */ 5617c478bd9Sstevel@tonic-gate 5627c478bd9Sstevel@tonic-gate /* ECN code points for IPv4 TOS byte and IPv6 traffic class octet. */ 5637924222fSmeem #define IPH_ECN_NECT 0x0 /* Not ECN-Capable Transport */ 5647c478bd9Sstevel@tonic-gate #define IPH_ECN_ECT1 0x1 /* ECN-Capable Transport, ECT(1) */ 5657c478bd9Sstevel@tonic-gate #define IPH_ECN_ECT0 0x2 /* ECN-Capable Transport, ECT(0) */ 5667c478bd9Sstevel@tonic-gate #define IPH_ECN_CE 0x3 /* ECN-Congestion Experienced (CE) */ 5677c478bd9Sstevel@tonic-gate 5687c478bd9Sstevel@tonic-gate /* IP Mac info structure */ 5697c478bd9Sstevel@tonic-gate typedef struct ip_m_s { 5707c478bd9Sstevel@tonic-gate t_uscalar_t ip_m_mac_type; /* From <sys/dlpi.h> */ 5717c478bd9Sstevel@tonic-gate int ip_m_type; /* From <net/if_types.h> */ 5727c478bd9Sstevel@tonic-gate boolean_t (*ip_m_v4mapinfo)(uint_t, uint8_t *, uint8_t *, 5737c478bd9Sstevel@tonic-gate uint32_t *, ipaddr_t *); 5747c478bd9Sstevel@tonic-gate boolean_t (*ip_m_v6mapinfo)(uint_t, uint8_t *, uint8_t *, 5757c478bd9Sstevel@tonic-gate uint32_t *, in6_addr_t *); 5767c478bd9Sstevel@tonic-gate boolean_t (*ip_m_v6intfid)(uint_t, uint8_t *, in6_addr_t *); 5777c478bd9Sstevel@tonic-gate } ip_m_t; 5787c478bd9Sstevel@tonic-gate 5797c478bd9Sstevel@tonic-gate /* 5807c478bd9Sstevel@tonic-gate * The following functions attempt to reduce the link layer dependency 5817c478bd9Sstevel@tonic-gate * of the IP stack. The current set of link specific operations are: 5827c478bd9Sstevel@tonic-gate * a. map from IPv4 class D (224.0/4) multicast address range to the link 5837c478bd9Sstevel@tonic-gate * layer multicast address range. 5847c478bd9Sstevel@tonic-gate * b. map from IPv6 multicast address range (ff00::/8) to the link 5857c478bd9Sstevel@tonic-gate * layer multicast address range. 5867c478bd9Sstevel@tonic-gate * c. derive the default IPv6 interface identifier from the link layer 5877c478bd9Sstevel@tonic-gate * address. 5887c478bd9Sstevel@tonic-gate */ 5897c478bd9Sstevel@tonic-gate #define MEDIA_V4MINFO(ip_m, plen, bphys, maddr, hwxp, v4ptr) \ 5907c478bd9Sstevel@tonic-gate (((ip_m)->ip_m_v4mapinfo != NULL) && \ 5917c478bd9Sstevel@tonic-gate (*(ip_m)->ip_m_v4mapinfo)(plen, bphys, maddr, hwxp, v4ptr)) 5927c478bd9Sstevel@tonic-gate #define MEDIA_V6INTFID(ip_m, plen, phys, v6ptr) \ 5937c478bd9Sstevel@tonic-gate (((ip_m)->ip_m_v6intfid != NULL) && \ 5947c478bd9Sstevel@tonic-gate (*(ip_m)->ip_m_v6intfid)(plen, phys, v6ptr)) 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)) 5987c478bd9Sstevel@tonic-gate 5997c478bd9Sstevel@tonic-gate /* Router entry types */ 6007c478bd9Sstevel@tonic-gate #define IRE_BROADCAST 0x0001 /* Route entry for broadcast address */ 6017c478bd9Sstevel@tonic-gate #define IRE_DEFAULT 0x0002 /* Route entry for default gateway */ 6027c478bd9Sstevel@tonic-gate #define IRE_LOCAL 0x0004 /* Route entry for local address */ 6037c478bd9Sstevel@tonic-gate #define IRE_LOOPBACK 0x0008 /* Route entry for loopback address */ 6047c478bd9Sstevel@tonic-gate #define IRE_PREFIX 0x0010 /* Route entry for prefix routes */ 6057c478bd9Sstevel@tonic-gate #define IRE_CACHE 0x0020 /* Cached Route entry */ 6067c478bd9Sstevel@tonic-gate #define IRE_IF_NORESOLVER 0x0040 /* Route entry for local interface */ 6077c478bd9Sstevel@tonic-gate /* net without any address mapping. */ 6087c478bd9Sstevel@tonic-gate #define IRE_IF_RESOLVER 0x0080 /* Route entry for local interface */ 6097c478bd9Sstevel@tonic-gate /* net with resolver. */ 6107c478bd9Sstevel@tonic-gate #define IRE_HOST 0x0100 /* Host route entry */ 6116bdb8e66Sdd193516 #define IRE_HOST_REDIRECT 0x0200 /* only used for T_SVR4_OPTMGMT_REQ */ 6127c478bd9Sstevel@tonic-gate 6137c478bd9Sstevel@tonic-gate #define IRE_INTERFACE (IRE_IF_NORESOLVER | IRE_IF_RESOLVER) 6146bdb8e66Sdd193516 #define IRE_OFFSUBNET (IRE_DEFAULT | IRE_PREFIX | IRE_HOST) 6157c478bd9Sstevel@tonic-gate #define IRE_CACHETABLE (IRE_CACHE | IRE_BROADCAST | IRE_LOCAL | \ 6167c478bd9Sstevel@tonic-gate IRE_LOOPBACK) 6177c478bd9Sstevel@tonic-gate #define IRE_FORWARDTABLE (IRE_INTERFACE | IRE_OFFSUBNET) 6187c478bd9Sstevel@tonic-gate 6197c478bd9Sstevel@tonic-gate /* 6207c478bd9Sstevel@tonic-gate * If an IRE is marked with IRE_MARK_CONDEMNED, the last walker of 6217c478bd9Sstevel@tonic-gate * the bucket should delete this IRE from this bucket. 6227c478bd9Sstevel@tonic-gate */ 6237c478bd9Sstevel@tonic-gate #define IRE_MARK_CONDEMNED 0x0001 6247c478bd9Sstevel@tonic-gate /* 6257c478bd9Sstevel@tonic-gate * If a broadcast IRE is marked with IRE_MARK_NORECV, ip_rput will drop the 6267c478bd9Sstevel@tonic-gate * broadcast packets received on that interface. This is marked only 6277c478bd9Sstevel@tonic-gate * on broadcast ires. Employed by IPMP, where we have multiple NICs on the 6287c478bd9Sstevel@tonic-gate * same subnet receiving the same broadcast packet. 6297c478bd9Sstevel@tonic-gate */ 6307c478bd9Sstevel@tonic-gate #define IRE_MARK_NORECV 0x0002 6317c478bd9Sstevel@tonic-gate /* 6327c478bd9Sstevel@tonic-gate * IRE_CACHE marked this way won't be returned by ire_cache_lookup. Need 6337c478bd9Sstevel@tonic-gate * to look specifically using MATCH_IRE_MARK_HIDDEN. Used by IPMP. 6347c478bd9Sstevel@tonic-gate */ 6357c478bd9Sstevel@tonic-gate #define IRE_MARK_HIDDEN 0x0004 /* Typically Used by in.mpathd */ 6367c478bd9Sstevel@tonic-gate 6377c478bd9Sstevel@tonic-gate /* 638e704a8f2Smeem * An IRE with IRE_MARK_NOADD is created in ip_newroute_ipif when the outgoing 639e704a8f2Smeem * interface is specified by e.g. IP_PKTINFO. The IRE is not added to the IRE 640e704a8f2Smeem * cache table. 6417c478bd9Sstevel@tonic-gate */ 6427c478bd9Sstevel@tonic-gate #define IRE_MARK_NOADD 0x0008 /* Mark not to add ire in cache */ 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate /* 6457c478bd9Sstevel@tonic-gate * IRE marked with IRE_MARK_TEMPORARY means that this IRE has been used 6467c478bd9Sstevel@tonic-gate * either for forwarding a packet or has not been used for sending 6477c478bd9Sstevel@tonic-gate * traffic on TCP connections terminated on this system. In both 6487c478bd9Sstevel@tonic-gate * cases, this IRE is the first to go when IRE is being cleaned up. 6497c478bd9Sstevel@tonic-gate */ 6507c478bd9Sstevel@tonic-gate #define IRE_MARK_TEMPORARY 0x0010 6517c478bd9Sstevel@tonic-gate 6527c478bd9Sstevel@tonic-gate /* 6537c478bd9Sstevel@tonic-gate * IRE marked with IRE_MARK_USESRC_CHECK means that while adding an IRE with 6547c478bd9Sstevel@tonic-gate * this mark, additional atomic checks need to be performed. For eg: by the 6557c478bd9Sstevel@tonic-gate * time an IRE_CACHE is created, sent up to ARP and then comes back to IP; the 6567c478bd9Sstevel@tonic-gate * usesrc grouping could have changed in which case we want to fail adding 6577c478bd9Sstevel@tonic-gate * the IRE_CACHE entry 6587c478bd9Sstevel@tonic-gate */ 6597c478bd9Sstevel@tonic-gate #define IRE_MARK_USESRC_CHECK 0x0020 6607c478bd9Sstevel@tonic-gate 66143d18f1cSpriyanka /* 66243d18f1cSpriyanka * IRE_MARK_PRIVATE_ADDR is used for IP_NEXTHOP. When IP_NEXTHOP is set, the 66343d18f1cSpriyanka * routing table lookup for the destination is bypassed and the packet is 66443d18f1cSpriyanka * sent directly to the specified nexthop. The associated IRE_CACHE entries 66543d18f1cSpriyanka * should be marked with IRE_MARK_PRIVATE_ADDR flag so that they don't show up 66643d18f1cSpriyanka * in regular ire cache lookups. 66743d18f1cSpriyanka */ 66843d18f1cSpriyanka #define IRE_MARK_PRIVATE_ADDR 0x0040 66943d18f1cSpriyanka 670c793af95Ssangeeta /* 671c793af95Ssangeeta * When we send an ARP resolution query for the nexthop gateway's ire, 672c793af95Ssangeeta * we use esballoc to create the ire_t in the AR_ENTRY_QUERY mblk 673c793af95Ssangeeta * chain, and mark its ire_marks with IRE_MARK_UNCACHED. This flag 674c793af95Ssangeeta * indicates that information from ARP has not been transferred to a 675c793af95Ssangeeta * permanent IRE_CACHE entry. The flag is reset only when the 676c793af95Ssangeeta * information is successfully transferred to an ire_cache entry (in 677c793af95Ssangeeta * ire_add()). Attempting to free the AR_ENTRY_QUERY mblk chain prior 678c793af95Ssangeeta * to ire_add (e.g., from arp, or from ip`ip_wput_nondata) will 679c793af95Ssangeeta * require that the resources (incomplete ire_cache and/or nce) must 680c793af95Ssangeeta * be cleaned up. The free callback routine (ire_freemblk()) checks 681c793af95Ssangeeta * for IRE_MARK_UNCACHED to see if any resources that are pinned down 682c793af95Ssangeeta * will need to be cleaned up or not. 683c793af95Ssangeeta */ 684c793af95Ssangeeta 685c793af95Ssangeeta #define IRE_MARK_UNCACHED 0x0080 686c793af95Ssangeeta 687f4b3ec61Sdh155122 /* 688f4b3ec61Sdh155122 * The comment below (and for other netstack_t references) refers 689f4b3ec61Sdh155122 * to the fact that we only do netstack_hold in particular cases, 690f4b3ec61Sdh155122 * such as the references from open streams (ill_t and conn_t's 691f4b3ec61Sdh155122 * pointers). Internally within IP we rely on IP's ability to cleanup e.g. 692f4b3ec61Sdh155122 * ire_t's when an ill goes away. 693f4b3ec61Sdh155122 */ 694f4b3ec61Sdh155122 typedef struct ire_expire_arg_s { 695f4b3ec61Sdh155122 int iea_flush_flag; 696f4b3ec61Sdh155122 ip_stack_t *iea_ipst; /* Does not have a netstack_hold */ 697f4b3ec61Sdh155122 } ire_expire_arg_t; 698f4b3ec61Sdh155122 6997c478bd9Sstevel@tonic-gate /* Flags with ire_expire routine */ 7007c478bd9Sstevel@tonic-gate #define FLUSH_ARP_TIME 0x0001 /* ARP info potentially stale timer */ 7017c478bd9Sstevel@tonic-gate #define FLUSH_REDIRECT_TIME 0x0002 /* Redirects potentially stale */ 7027c478bd9Sstevel@tonic-gate #define FLUSH_MTU_TIME 0x0004 /* Include path MTU per RFC 1191 */ 7037c478bd9Sstevel@tonic-gate 7047c478bd9Sstevel@tonic-gate /* Arguments to ire_flush_cache() */ 7057c478bd9Sstevel@tonic-gate #define IRE_FLUSH_DELETE 0 7067c478bd9Sstevel@tonic-gate #define IRE_FLUSH_ADD 1 7077c478bd9Sstevel@tonic-gate 7087c478bd9Sstevel@tonic-gate /* 7097c478bd9Sstevel@tonic-gate * Open/close synchronization flags. 7107c478bd9Sstevel@tonic-gate * These are kept in a separate field in the conn and the synchronization 7117c478bd9Sstevel@tonic-gate * depends on the atomic 32 bit access to that field. 7127c478bd9Sstevel@tonic-gate */ 7137c478bd9Sstevel@tonic-gate #define CONN_CLOSING 0x01 /* ip_close waiting for ip_wsrv */ 714ff550d0eSmasputra #define CONN_IPSEC_LOAD_WAIT 0x02 /* waiting for load */ 715ff550d0eSmasputra #define CONN_CONDEMNED 0x04 /* conn is closing, no more refs */ 716ff550d0eSmasputra #define CONN_INCIPIENT 0x08 /* conn not yet visible, no refs */ 717ff550d0eSmasputra #define CONN_QUIESCED 0x10 /* conn is now quiescent */ 7187c478bd9Sstevel@tonic-gate 719325b8068Sgeorges /* Used to check connection state flags before caching the IRE */ 720325b8068Sgeorges #define CONN_CACHE_IRE(connp) \ 721325b8068Sgeorges (!((connp)->conn_state_flags & (CONN_CLOSING|CONN_CONDEMNED))) 722325b8068Sgeorges 7237c478bd9Sstevel@tonic-gate /* 7247c478bd9Sstevel@tonic-gate * Parameter to ip_output giving the identity of the caller. 7257c478bd9Sstevel@tonic-gate * IP_WSRV means the packet was enqueued in the STREAMS queue 7267c478bd9Sstevel@tonic-gate * due to flow control and is now being reprocessed in the context of 7277c478bd9Sstevel@tonic-gate * the STREAMS service procedure, consequent to flow control relief. 7287c478bd9Sstevel@tonic-gate * IRE_SEND means the packet is being reprocessed consequent to an 7297c478bd9Sstevel@tonic-gate * ire cache creation and addition and this may or may not be happening 7307c478bd9Sstevel@tonic-gate * in the service procedure context. Anything other than the above 2 7317c478bd9Sstevel@tonic-gate * cases is identified as IP_WPUT. Most commonly this is the case of 7327c478bd9Sstevel@tonic-gate * packets coming down from the application. 7337c478bd9Sstevel@tonic-gate */ 7347c478bd9Sstevel@tonic-gate #ifdef _KERNEL 7357c478bd9Sstevel@tonic-gate #define IP_WSRV 1 /* Called from ip_wsrv */ 7367c478bd9Sstevel@tonic-gate #define IP_WPUT 2 /* Called from ip_wput */ 7377c478bd9Sstevel@tonic-gate #define IRE_SEND 3 /* Called from ire_send */ 7387c478bd9Sstevel@tonic-gate 7397c478bd9Sstevel@tonic-gate /* 7407c478bd9Sstevel@tonic-gate * Extra structures need for per-src-addr filtering (IGMPv3/MLDv2) 7417c478bd9Sstevel@tonic-gate */ 7427c478bd9Sstevel@tonic-gate #define MAX_FILTER_SIZE 64 7437c478bd9Sstevel@tonic-gate 7447c478bd9Sstevel@tonic-gate typedef struct slist_s { 7457c478bd9Sstevel@tonic-gate int sl_numsrc; 7467c478bd9Sstevel@tonic-gate in6_addr_t sl_addr[MAX_FILTER_SIZE]; 7477c478bd9Sstevel@tonic-gate } slist_t; 7487c478bd9Sstevel@tonic-gate 7497c478bd9Sstevel@tonic-gate /* 7507c478bd9Sstevel@tonic-gate * Following struct is used to maintain retransmission state for 7517c478bd9Sstevel@tonic-gate * a multicast group. One rtx_state_t struct is an in-line field 7527c478bd9Sstevel@tonic-gate * of the ilm_t struct; the slist_ts in the rtx_state_t struct are 7537c478bd9Sstevel@tonic-gate * alloc'd as needed. 7547c478bd9Sstevel@tonic-gate */ 7557c478bd9Sstevel@tonic-gate typedef struct rtx_state_s { 7567c478bd9Sstevel@tonic-gate uint_t rtx_timer; /* retrans timer */ 7577c478bd9Sstevel@tonic-gate int rtx_cnt; /* retrans count */ 7587c478bd9Sstevel@tonic-gate int rtx_fmode_cnt; /* retrans count for fmode change */ 7597c478bd9Sstevel@tonic-gate slist_t *rtx_allow; 7607c478bd9Sstevel@tonic-gate slist_t *rtx_block; 7617c478bd9Sstevel@tonic-gate } rtx_state_t; 7627c478bd9Sstevel@tonic-gate 7637c478bd9Sstevel@tonic-gate /* 7647c478bd9Sstevel@tonic-gate * Used to construct list of multicast address records that will be 7657c478bd9Sstevel@tonic-gate * sent in a single listener report. 7667c478bd9Sstevel@tonic-gate */ 7677c478bd9Sstevel@tonic-gate typedef struct mrec_s { 7687c478bd9Sstevel@tonic-gate struct mrec_s *mrec_next; 7697c478bd9Sstevel@tonic-gate uint8_t mrec_type; 7707c478bd9Sstevel@tonic-gate uint8_t mrec_auxlen; /* currently unused */ 7717c478bd9Sstevel@tonic-gate in6_addr_t mrec_group; 7727c478bd9Sstevel@tonic-gate slist_t mrec_srcs; 7737c478bd9Sstevel@tonic-gate } mrec_t; 7747c478bd9Sstevel@tonic-gate 7757c478bd9Sstevel@tonic-gate /* Group membership list per upper conn */ 7767c478bd9Sstevel@tonic-gate /* 7777c478bd9Sstevel@tonic-gate * XXX add ilg info for ifaddr/ifindex. 7787c478bd9Sstevel@tonic-gate * XXX can we make ilg survive an ifconfig unplumb + plumb 7797c478bd9Sstevel@tonic-gate * by setting the ipif/ill to NULL and recover that later? 7807c478bd9Sstevel@tonic-gate * 7817c478bd9Sstevel@tonic-gate * ilg_ipif is used by IPv4 as multicast groups are joined using an interface 7827c478bd9Sstevel@tonic-gate * address (ipif). 7837c478bd9Sstevel@tonic-gate * ilg_ill is used by IPv6 as multicast groups are joined using an interface 7847c478bd9Sstevel@tonic-gate * index (phyint->phyint_ifindex). 7857c478bd9Sstevel@tonic-gate * ilg_ill is NULL for IPv4 and ilg_ipif is NULL for IPv6. 7867c478bd9Sstevel@tonic-gate * 7877c478bd9Sstevel@tonic-gate * ilg records the state of multicast memberships of a socket end point. 7887c478bd9Sstevel@tonic-gate * ilm records the state of multicast memberships with the driver and is 7897c478bd9Sstevel@tonic-gate * maintained per interface. 7907c478bd9Sstevel@tonic-gate * 7917c478bd9Sstevel@tonic-gate * Notes : 7927c478bd9Sstevel@tonic-gate * 7937c478bd9Sstevel@tonic-gate * 1) There is no direct link between a given ilg and ilm. If the 7947c478bd9Sstevel@tonic-gate * application has joined a group G with ifindex I, we will have 7957c478bd9Sstevel@tonic-gate * an ilg with ilg_v6group and ilg_ill. There will be a corresponding 7967c478bd9Sstevel@tonic-gate * ilm with ilm_ill/ilm_v6addr recording the multicast membership. 7977c478bd9Sstevel@tonic-gate * To delete the membership, 7987c478bd9Sstevel@tonic-gate * 7997c478bd9Sstevel@tonic-gate * a) Search for ilg matching on G and I with ilg_v6group 8007c478bd9Sstevel@tonic-gate * and ilg_ill. Delete ilg_ill. 8017c478bd9Sstevel@tonic-gate * b) Search the corresponding ilm matching on G and I with 8027c478bd9Sstevel@tonic-gate * ilm_v6addr and ilm_ill. Delete ilm. 8037c478bd9Sstevel@tonic-gate * 8047c478bd9Sstevel@tonic-gate * In IPv4, the only difference is, we look using ipifs instead of 8057c478bd9Sstevel@tonic-gate * ills. 8067c478bd9Sstevel@tonic-gate * 8077c478bd9Sstevel@tonic-gate * 2) With IP multipathing, we want to keep receiving even after the 8087c478bd9Sstevel@tonic-gate * interface has failed. We do this by moving multicast memberships 8097924222fSmeem * to a new_ill within the group. This is achieved by sending 8107c478bd9Sstevel@tonic-gate * DL_DISABMULTI_REQS on ilg_ill/ilm_ill and sending DL_ENABMULTIREQS 8117c478bd9Sstevel@tonic-gate * on the new_ill and changing ilg_ill/ilm_ill to new_ill. But, we 8127c478bd9Sstevel@tonic-gate * need to be able to delete memberships which will still come down 8137c478bd9Sstevel@tonic-gate * with the ifindex of the old ill which is what the application 8147c478bd9Sstevel@tonic-gate * knows of. Thus we store the ilm_/ilg_orig_ifindex to keep track 8157c478bd9Sstevel@tonic-gate * of where we joined initially so that we can lookup even after we 8167c478bd9Sstevel@tonic-gate * moved the membership. It is also used for moving back the membership 8177c478bd9Sstevel@tonic-gate * when the old ill has been repaired. This is done by looking up for 8187c478bd9Sstevel@tonic-gate * ilms with ilm_orig_ifindex matching on the old ill's ifindex. Only 8197c478bd9Sstevel@tonic-gate * ilms actually move from old ill to new ill. ilgs don't move (just 8207c478bd9Sstevel@tonic-gate * the ilg_ill is changed when it moves) as it just records the state 8217c478bd9Sstevel@tonic-gate * of the application that has joined a group G where as ilm records 8227c478bd9Sstevel@tonic-gate * the state joined with the driver. Thus when we send DL_XXXMULTI_REQs 8237c478bd9Sstevel@tonic-gate * we also need to keep the ilm in the right ill. 8247c478bd9Sstevel@tonic-gate * 8257c478bd9Sstevel@tonic-gate * In IPv4, as ipifs move from old ill to new_ill, ilgs and ilms move 8267c478bd9Sstevel@tonic-gate * implicitly as we use only ipifs in IPv4. Thus, one can always lookup 8277c478bd9Sstevel@tonic-gate * a given ilm/ilg even after it fails without the support of 8287c478bd9Sstevel@tonic-gate * orig_ifindex. We move ilms still to record the driver state as 8297c478bd9Sstevel@tonic-gate * mentioned above. 8307c478bd9Sstevel@tonic-gate */ 8317c478bd9Sstevel@tonic-gate 8327c478bd9Sstevel@tonic-gate /* 8337c478bd9Sstevel@tonic-gate * The ilg_t and ilm_t members are protected by ipsq. They can be changed only 8347c478bd9Sstevel@tonic-gate * by a thread executing in the ipsq. In other words add/delete of a 8357c478bd9Sstevel@tonic-gate * multicast group has to execute in the ipsq. 8367c478bd9Sstevel@tonic-gate */ 8377c478bd9Sstevel@tonic-gate #define ILG_DELETED 0x1 /* ilg_flags */ 8387c478bd9Sstevel@tonic-gate typedef struct ilg_s { 8397c478bd9Sstevel@tonic-gate in6_addr_t ilg_v6group; 8407c478bd9Sstevel@tonic-gate struct ipif_s *ilg_ipif; /* Logical interface we are member on */ 8417c478bd9Sstevel@tonic-gate struct ill_s *ilg_ill; /* Used by IPv6 */ 8427c478bd9Sstevel@tonic-gate int ilg_orig_ifindex; /* Interface originally joined on */ 8437c478bd9Sstevel@tonic-gate uint_t ilg_flags; 8447c478bd9Sstevel@tonic-gate mcast_record_t ilg_fmode; /* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */ 8457c478bd9Sstevel@tonic-gate slist_t *ilg_filter; 8467c478bd9Sstevel@tonic-gate } ilg_t; 8477c478bd9Sstevel@tonic-gate 8487c478bd9Sstevel@tonic-gate /* 8497924222fSmeem * Multicast address list entry for ill. 8507c478bd9Sstevel@tonic-gate * ilm_ipif is used by IPv4 as multicast groups are joined using ipif. 8517c478bd9Sstevel@tonic-gate * ilm_ill is used by IPv6 as multicast groups are joined using ill. 8527c478bd9Sstevel@tonic-gate * ilm_ill is NULL for IPv4 and ilm_ipif is NULL for IPv6. 853f4b3ec61Sdh155122 * 854f4b3ec61Sdh155122 * The comment below (and for other netstack_t references) refers 855f4b3ec61Sdh155122 * to the fact that we only do netstack_hold in particular cases, 856f4b3ec61Sdh155122 * such as the references from open streams (ill_t and conn_t's 857f4b3ec61Sdh155122 * pointers). Internally within IP we rely on IP's ability to cleanup e.g. 858f4b3ec61Sdh155122 * ire_t's when an ill goes away. 8597c478bd9Sstevel@tonic-gate */ 8607c478bd9Sstevel@tonic-gate #define ILM_DELETED 0x1 /* ilm_flags */ 8617c478bd9Sstevel@tonic-gate typedef struct ilm_s { 8627c478bd9Sstevel@tonic-gate in6_addr_t ilm_v6addr; 8637c478bd9Sstevel@tonic-gate int ilm_refcnt; 8647c478bd9Sstevel@tonic-gate uint_t ilm_timer; /* IGMP/MLD query resp timer, in msec */ 8657c478bd9Sstevel@tonic-gate struct ipif_s *ilm_ipif; /* Back pointer to ipif for IPv4 */ 8667c478bd9Sstevel@tonic-gate struct ilm_s *ilm_next; /* Linked list for each ill */ 8677c478bd9Sstevel@tonic-gate uint_t ilm_state; /* state of the membership */ 8687c478bd9Sstevel@tonic-gate struct ill_s *ilm_ill; /* Back pointer to ill for IPv6 */ 8697c478bd9Sstevel@tonic-gate int ilm_orig_ifindex; /* V6_MULTICAST_IF/ilm_ipif index */ 8707c478bd9Sstevel@tonic-gate uint_t ilm_flags; 8717c478bd9Sstevel@tonic-gate boolean_t ilm_is_new; /* new ilm */ 8727c478bd9Sstevel@tonic-gate boolean_t ilm_notify_driver; /* Need to notify the driver */ 8737c478bd9Sstevel@tonic-gate zoneid_t ilm_zoneid; 8747c478bd9Sstevel@tonic-gate int ilm_no_ilg_cnt; /* number of joins w/ no ilg */ 8757c478bd9Sstevel@tonic-gate mcast_record_t ilm_fmode; /* MODE_IS_INCLUDE/MODE_IS_EXCLUDE */ 8767c478bd9Sstevel@tonic-gate slist_t *ilm_filter; /* source filter list */ 8777c478bd9Sstevel@tonic-gate slist_t *ilm_pendsrcs; /* relevant src addrs for pending req */ 8787c478bd9Sstevel@tonic-gate rtx_state_t ilm_rtx; /* SCR retransmission state */ 879f4b3ec61Sdh155122 ip_stack_t *ilm_ipst; /* Does not have a netstack_hold */ 8807c478bd9Sstevel@tonic-gate } ilm_t; 8817c478bd9Sstevel@tonic-gate 8827c478bd9Sstevel@tonic-gate #define ilm_addr V4_PART_OF_V6(ilm_v6addr) 8837c478bd9Sstevel@tonic-gate 8847c478bd9Sstevel@tonic-gate /* 8857c478bd9Sstevel@tonic-gate * ilm_walker_cleanup needs to execute when the ilm_walker_cnt goes down to 8867c478bd9Sstevel@tonic-gate * zero. In addition it needs to block new walkers while it is unlinking ilm's 8877c478bd9Sstevel@tonic-gate * from the list. Thus simple atomics for the ill_ilm_walker_cnt don't suffice. 8887c478bd9Sstevel@tonic-gate */ 8897c478bd9Sstevel@tonic-gate #define ILM_WALKER_HOLD(ill) { \ 8907c478bd9Sstevel@tonic-gate mutex_enter(&(ill)->ill_lock); \ 8917c478bd9Sstevel@tonic-gate ill->ill_ilm_walker_cnt++; \ 8927c478bd9Sstevel@tonic-gate mutex_exit(&(ill)->ill_lock); \ 8937c478bd9Sstevel@tonic-gate } 8947c478bd9Sstevel@tonic-gate 895968d2fd1Ssowmini /* 896968d2fd1Ssowmini * ilm_walker_cleanup releases ill_lock 897968d2fd1Ssowmini */ 8987c478bd9Sstevel@tonic-gate #define ILM_WALKER_RELE(ill) { \ 8997c478bd9Sstevel@tonic-gate mutex_enter(&(ill)->ill_lock); \ 9007c478bd9Sstevel@tonic-gate (ill)->ill_ilm_walker_cnt--; \ 9017c478bd9Sstevel@tonic-gate if ((ill)->ill_ilm_walker_cnt == 0 && (ill)->ill_ilm_cleanup_reqd) \ 9027c478bd9Sstevel@tonic-gate ilm_walker_cleanup(ill); \ 903968d2fd1Ssowmini else \ 9047c478bd9Sstevel@tonic-gate mutex_exit(&(ill)->ill_lock); \ 9057c478bd9Sstevel@tonic-gate } 9067c478bd9Sstevel@tonic-gate 9077c478bd9Sstevel@tonic-gate /* 9087c478bd9Sstevel@tonic-gate * Soft reference to an IPsec SA. 9097c478bd9Sstevel@tonic-gate * 9107924222fSmeem * On relative terms, conn's can be persistent (living as long as the 9117c478bd9Sstevel@tonic-gate * processes which create them), while SA's are ephemeral (dying when 9127c478bd9Sstevel@tonic-gate * they hit their time-based or byte-based lifetimes). 9137c478bd9Sstevel@tonic-gate * 9147c478bd9Sstevel@tonic-gate * We could hold a hard reference to an SA from an ipsec_latch_t, 9157c478bd9Sstevel@tonic-gate * but this would cause expired SA's to linger for a potentially 9167c478bd9Sstevel@tonic-gate * unbounded time. 9177c478bd9Sstevel@tonic-gate * 9187c478bd9Sstevel@tonic-gate * Instead, we remember the hash bucket number and bucket generation 9197c478bd9Sstevel@tonic-gate * in addition to the pointer. The bucket generation is incremented on 9207c478bd9Sstevel@tonic-gate * each deletion. 9217c478bd9Sstevel@tonic-gate */ 9227c478bd9Sstevel@tonic-gate typedef struct ipsa_ref_s 9237c478bd9Sstevel@tonic-gate { 9247c478bd9Sstevel@tonic-gate struct ipsa_s *ipsr_sa; 9257c478bd9Sstevel@tonic-gate struct isaf_s *ipsr_bucket; 9267c478bd9Sstevel@tonic-gate uint64_t ipsr_gen; 9277c478bd9Sstevel@tonic-gate } ipsa_ref_t; 9287c478bd9Sstevel@tonic-gate 9297c478bd9Sstevel@tonic-gate /* 9307c478bd9Sstevel@tonic-gate * IPsec "latching" state. 9317c478bd9Sstevel@tonic-gate * 9327c478bd9Sstevel@tonic-gate * In the presence of IPsec policy, fully-bound conn's bind a connection 9337c478bd9Sstevel@tonic-gate * to more than just the 5-tuple, but also a specific IPsec action and 9347c478bd9Sstevel@tonic-gate * identity-pair. 9357c478bd9Sstevel@tonic-gate * 9367c478bd9Sstevel@tonic-gate * As an optimization, we also cache soft references to IPsec SA's 9377c478bd9Sstevel@tonic-gate * here so that we can fast-path around most of the work needed for 9387c478bd9Sstevel@tonic-gate * outbound IPsec SA selection. 9397c478bd9Sstevel@tonic-gate * 9407c478bd9Sstevel@tonic-gate * Were it not for TCP's detached connections, this state would be 9417c478bd9Sstevel@tonic-gate * in-line in conn_t; instead, this is in a separate structure so it 9427c478bd9Sstevel@tonic-gate * can be handed off to TCP when a connection is detached. 9437c478bd9Sstevel@tonic-gate */ 9447c478bd9Sstevel@tonic-gate typedef struct ipsec_latch_s 9457c478bd9Sstevel@tonic-gate { 9467c478bd9Sstevel@tonic-gate kmutex_t ipl_lock; 9477c478bd9Sstevel@tonic-gate uint32_t ipl_refcnt; 9487c478bd9Sstevel@tonic-gate 9497c478bd9Sstevel@tonic-gate uint64_t ipl_unique; 9507c478bd9Sstevel@tonic-gate struct ipsec_policy_s *ipl_in_policy; /* latched policy (in) */ 9517c478bd9Sstevel@tonic-gate struct ipsec_policy_s *ipl_out_policy; /* latched policy (out) */ 9527c478bd9Sstevel@tonic-gate struct ipsec_action_s *ipl_in_action; /* latched action (in) */ 9537c478bd9Sstevel@tonic-gate struct ipsec_action_s *ipl_out_action; /* latched action (out) */ 9547c478bd9Sstevel@tonic-gate cred_t *ipl_local_id; 9557c478bd9Sstevel@tonic-gate struct ipsid_s *ipl_local_cid; 9567c478bd9Sstevel@tonic-gate struct ipsid_s *ipl_remote_cid; 9577c478bd9Sstevel@tonic-gate unsigned int 9587c478bd9Sstevel@tonic-gate ipl_out_action_latched : 1, 9597c478bd9Sstevel@tonic-gate ipl_in_action_latched : 1, 9607c478bd9Sstevel@tonic-gate ipl_out_policy_latched : 1, 9617c478bd9Sstevel@tonic-gate ipl_in_policy_latched : 1, 9627c478bd9Sstevel@tonic-gate 9637c478bd9Sstevel@tonic-gate ipl_ids_latched : 1, 9647c478bd9Sstevel@tonic-gate 9657c478bd9Sstevel@tonic-gate ipl_pad_to_bit_31 : 27; 9667c478bd9Sstevel@tonic-gate 9677c478bd9Sstevel@tonic-gate ipsa_ref_t ipl_ref[2]; /* 0: ESP, 1: AH */ 9687c478bd9Sstevel@tonic-gate 9697c478bd9Sstevel@tonic-gate } ipsec_latch_t; 9707c478bd9Sstevel@tonic-gate 9717c478bd9Sstevel@tonic-gate #define IPLATCH_REFHOLD(ipl) { \ 9727c478bd9Sstevel@tonic-gate atomic_add_32(&(ipl)->ipl_refcnt, 1); \ 9737c478bd9Sstevel@tonic-gate ASSERT((ipl)->ipl_refcnt != 0); \ 9747c478bd9Sstevel@tonic-gate } 9757c478bd9Sstevel@tonic-gate 976f4b3ec61Sdh155122 #define IPLATCH_REFRELE(ipl, ns) { \ 9777c478bd9Sstevel@tonic-gate ASSERT((ipl)->ipl_refcnt != 0); \ 9787c478bd9Sstevel@tonic-gate membar_exit(); \ 9797c478bd9Sstevel@tonic-gate if (atomic_add_32_nv(&(ipl)->ipl_refcnt, -1) == 0) \ 980f4b3ec61Sdh155122 iplatch_free(ipl, ns); \ 9817c478bd9Sstevel@tonic-gate } 9827c478bd9Sstevel@tonic-gate 9837c478bd9Sstevel@tonic-gate /* 9847c478bd9Sstevel@tonic-gate * peer identity structure. 9857c478bd9Sstevel@tonic-gate */ 9867c478bd9Sstevel@tonic-gate 9877c478bd9Sstevel@tonic-gate typedef struct conn_s conn_t; 9887c478bd9Sstevel@tonic-gate 9897c478bd9Sstevel@tonic-gate /* 9907c478bd9Sstevel@tonic-gate * The old IP client structure "ipc_t" is gone. All the data is stored in the 9917c478bd9Sstevel@tonic-gate * connection structure "conn_t" now. The mapping of old and new fields looks 9927c478bd9Sstevel@tonic-gate * like this: 9937c478bd9Sstevel@tonic-gate * 9947c478bd9Sstevel@tonic-gate * ipc_ulp conn_ulp 9957c478bd9Sstevel@tonic-gate * ipc_rq conn_rq 9967c478bd9Sstevel@tonic-gate * ipc_wq conn_wq 9977c478bd9Sstevel@tonic-gate * 9987c478bd9Sstevel@tonic-gate * ipc_laddr conn_src 9997c478bd9Sstevel@tonic-gate * ipc_faddr conn_rem 10007c478bd9Sstevel@tonic-gate * ipc_v6laddr conn_srcv6 10017c478bd9Sstevel@tonic-gate * ipc_v6faddr conn_remv6 10027c478bd9Sstevel@tonic-gate * 10037c478bd9Sstevel@tonic-gate * ipc_lport conn_lport 10047c478bd9Sstevel@tonic-gate * ipc_fport conn_fport 10057c478bd9Sstevel@tonic-gate * ipc_ports conn_ports 10067c478bd9Sstevel@tonic-gate * 10077c478bd9Sstevel@tonic-gate * ipc_policy conn_policy 10087c478bd9Sstevel@tonic-gate * ipc_latch conn_latch 10097c478bd9Sstevel@tonic-gate * 10107c478bd9Sstevel@tonic-gate * ipc_irc_lock conn_lock 10117c478bd9Sstevel@tonic-gate * ipc_ire_cache conn_ire_cache 10127c478bd9Sstevel@tonic-gate * 10137c478bd9Sstevel@tonic-gate * ipc_state_flags conn_state_flags 10147c478bd9Sstevel@tonic-gate * ipc_outgoing_ill conn_outgoing_ill 10157c478bd9Sstevel@tonic-gate * 10167c478bd9Sstevel@tonic-gate * ipc_dontroute conn_dontroute 10177c478bd9Sstevel@tonic-gate * ipc_loopback conn_loopback 10187c478bd9Sstevel@tonic-gate * ipc_broadcast conn_broadcast 10197c478bd9Sstevel@tonic-gate * ipc_reuseaddr conn_reuseaddr 10207c478bd9Sstevel@tonic-gate * 10217c478bd9Sstevel@tonic-gate * ipc_multicast_loop conn_multicast_loop 10227c478bd9Sstevel@tonic-gate * ipc_multi_router conn_multi_router 10237c478bd9Sstevel@tonic-gate * ipc_draining conn_draining 10247c478bd9Sstevel@tonic-gate * 10257c478bd9Sstevel@tonic-gate * ipc_did_putbq conn_did_putbq 10267c478bd9Sstevel@tonic-gate * ipc_unspec_src conn_unspec_src 10277c478bd9Sstevel@tonic-gate * ipc_policy_cached conn_policy_cached 10287c478bd9Sstevel@tonic-gate * 10297c478bd9Sstevel@tonic-gate * ipc_in_enforce_policy conn_in_enforce_policy 10307c478bd9Sstevel@tonic-gate * ipc_out_enforce_policy conn_out_enforce_policy 10317c478bd9Sstevel@tonic-gate * ipc_af_isv6 conn_af_isv6 10327c478bd9Sstevel@tonic-gate * ipc_pkt_isv6 conn_pkt_isv6 10337c478bd9Sstevel@tonic-gate * 10347c478bd9Sstevel@tonic-gate * ipc_ipv6_recvpktinfo conn_ipv6_recvpktinfo 10357c478bd9Sstevel@tonic-gate * 10367c478bd9Sstevel@tonic-gate * ipc_ipv6_recvhoplimit conn_ipv6_recvhoplimit 10377c478bd9Sstevel@tonic-gate * ipc_ipv6_recvhopopts conn_ipv6_recvhopopts 10387c478bd9Sstevel@tonic-gate * ipc_ipv6_recvdstopts conn_ipv6_recvdstopts 10397c478bd9Sstevel@tonic-gate * 10407c478bd9Sstevel@tonic-gate * ipc_ipv6_recvrthdr conn_ipv6_recvrthdr 10417c478bd9Sstevel@tonic-gate * ipc_ipv6_recvrtdstopts conn_ipv6_recvrtdstopts 10427c478bd9Sstevel@tonic-gate * ipc_fully_bound conn_fully_bound 10437c478bd9Sstevel@tonic-gate * 10447c478bd9Sstevel@tonic-gate * ipc_recvif conn_recvif 10457c478bd9Sstevel@tonic-gate * 10467c478bd9Sstevel@tonic-gate * ipc_recvslla conn_recvslla 10477c478bd9Sstevel@tonic-gate * ipc_acking_unbind conn_acking_unbind 10487c478bd9Sstevel@tonic-gate * ipc_pad_to_bit_31 conn_pad_to_bit_31 10497c478bd9Sstevel@tonic-gate * 10507c478bd9Sstevel@tonic-gate * ipc_nofailover_ill conn_nofailover_ill 10517c478bd9Sstevel@tonic-gate * 10527c478bd9Sstevel@tonic-gate * ipc_proto conn_proto 10537c478bd9Sstevel@tonic-gate * ipc_incoming_ill conn_incoming_ill 10547c478bd9Sstevel@tonic-gate * ipc_outgoing_pill conn_outgoing_pill 10557c478bd9Sstevel@tonic-gate * ipc_pending_ill conn_pending_ill 10567c478bd9Sstevel@tonic-gate * ipc_unbind_mp conn_unbind_mp 10577c478bd9Sstevel@tonic-gate * ipc_ilg conn_ilg 10587c478bd9Sstevel@tonic-gate * ipc_ilg_allocated conn_ilg_allocated 10597c478bd9Sstevel@tonic-gate * ipc_ilg_inuse conn_ilg_inuse 10607c478bd9Sstevel@tonic-gate * ipc_ilg_walker_cnt conn_ilg_walker_cnt 10617c478bd9Sstevel@tonic-gate * ipc_refcv conn_refcv 10627c478bd9Sstevel@tonic-gate * ipc_multicast_ipif conn_multicast_ipif 10637c478bd9Sstevel@tonic-gate * ipc_multicast_ill conn_multicast_ill 10647c478bd9Sstevel@tonic-gate * ipc_orig_bound_ifindex conn_orig_bound_ifindex 10657c478bd9Sstevel@tonic-gate * ipc_orig_multicast_ifindex conn_orig_multicast_ifindex 10667c478bd9Sstevel@tonic-gate * ipc_drain_next conn_drain_next 10677c478bd9Sstevel@tonic-gate * ipc_drain_prev conn_drain_prev 10687c478bd9Sstevel@tonic-gate * ipc_idl conn_idl 10697c478bd9Sstevel@tonic-gate */ 10707c478bd9Sstevel@tonic-gate 10717c478bd9Sstevel@tonic-gate /* 10727924222fSmeem * This is used to match an inbound/outbound datagram with policy. 10737c478bd9Sstevel@tonic-gate */ 10747c478bd9Sstevel@tonic-gate typedef struct ipsec_selector { 10757c478bd9Sstevel@tonic-gate in6_addr_t ips_local_addr_v6; 10767c478bd9Sstevel@tonic-gate in6_addr_t ips_remote_addr_v6; 10777c478bd9Sstevel@tonic-gate uint16_t ips_local_port; 10787c478bd9Sstevel@tonic-gate uint16_t ips_remote_port; 10797c478bd9Sstevel@tonic-gate uint8_t ips_icmp_type; 10807c478bd9Sstevel@tonic-gate uint8_t ips_icmp_code; 10817c478bd9Sstevel@tonic-gate uint8_t ips_protocol; 10827c478bd9Sstevel@tonic-gate uint8_t ips_isv4 : 1, 10837c478bd9Sstevel@tonic-gate ips_is_icmp_inv_acq: 1; 10847c478bd9Sstevel@tonic-gate } ipsec_selector_t; 10857c478bd9Sstevel@tonic-gate 10867c478bd9Sstevel@tonic-gate /* 10877c478bd9Sstevel@tonic-gate * Note that we put v4 addresses in the *first* 32-bit word of the 10887c478bd9Sstevel@tonic-gate * selector rather than the last to simplify the prefix match/mask code 10897c478bd9Sstevel@tonic-gate * in spd.c 10907c478bd9Sstevel@tonic-gate */ 10917c478bd9Sstevel@tonic-gate #define ips_local_addr_v4 ips_local_addr_v6.s6_addr32[0] 10927c478bd9Sstevel@tonic-gate #define ips_remote_addr_v4 ips_remote_addr_v6.s6_addr32[0] 10937c478bd9Sstevel@tonic-gate 10947c478bd9Sstevel@tonic-gate /* Values used in IP by IPSEC Code */ 10957c478bd9Sstevel@tonic-gate #define IPSEC_OUTBOUND B_TRUE 10967c478bd9Sstevel@tonic-gate #define IPSEC_INBOUND B_FALSE 10977c478bd9Sstevel@tonic-gate 10987c478bd9Sstevel@tonic-gate /* 10997c478bd9Sstevel@tonic-gate * There are two variants in policy failures. The packet may come in 11007c478bd9Sstevel@tonic-gate * secure when not needed (IPSEC_POLICY_???_NOT_NEEDED) or it may not 11017c478bd9Sstevel@tonic-gate * have the desired level of protection (IPSEC_POLICY_MISMATCH). 11027c478bd9Sstevel@tonic-gate */ 11037c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_NOT_NEEDED 0 11047c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_MISMATCH 1 11057c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_AUTH_NOT_NEEDED 2 11067c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_ENCR_NOT_NEEDED 3 11077c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_SE_NOT_NEEDED 4 11087c478bd9Sstevel@tonic-gate #define IPSEC_POLICY_MAX 5 /* Always max + 1. */ 11097c478bd9Sstevel@tonic-gate 11107c478bd9Sstevel@tonic-gate /* 11117c478bd9Sstevel@tonic-gate * Folowing macro is used whenever the code does not know whether there 11127c478bd9Sstevel@tonic-gate * is a M_CTL present in the front and it needs to examine the actual mp 11137c478bd9Sstevel@tonic-gate * i.e the IP header. As a M_CTL message could be in the front, this 11147c478bd9Sstevel@tonic-gate * extracts the packet into mp and the M_CTL mp into first_mp. If M_CTL 11157c478bd9Sstevel@tonic-gate * mp is not present, both first_mp and mp point to the same message. 11167c478bd9Sstevel@tonic-gate */ 11177c478bd9Sstevel@tonic-gate #define EXTRACT_PKT_MP(mp, first_mp, mctl_present) \ 11187c478bd9Sstevel@tonic-gate (first_mp) = (mp); \ 11197c478bd9Sstevel@tonic-gate if ((mp)->b_datap->db_type == M_CTL) { \ 11207c478bd9Sstevel@tonic-gate (mp) = (mp)->b_cont; \ 11217c478bd9Sstevel@tonic-gate (mctl_present) = B_TRUE; \ 11227c478bd9Sstevel@tonic-gate } else { \ 11237c478bd9Sstevel@tonic-gate (mctl_present) = B_FALSE; \ 11247c478bd9Sstevel@tonic-gate } 11257c478bd9Sstevel@tonic-gate 11267c478bd9Sstevel@tonic-gate /* 11277c478bd9Sstevel@tonic-gate * Check with IPSEC inbound policy if 11287c478bd9Sstevel@tonic-gate * 11297c478bd9Sstevel@tonic-gate * 1) per-socket policy is present - indicated by conn_in_enforce_policy. 11307c478bd9Sstevel@tonic-gate * 2) Or if we have not cached policy on the conn and the global policy is 11317c478bd9Sstevel@tonic-gate * non-empty. 11327c478bd9Sstevel@tonic-gate */ 1133f4b3ec61Sdh155122 #define CONN_INBOUND_POLICY_PRESENT(connp, ipss) \ 11347c478bd9Sstevel@tonic-gate ((connp)->conn_in_enforce_policy || \ 11357c478bd9Sstevel@tonic-gate (!((connp)->conn_policy_cached) && \ 1136f4b3ec61Sdh155122 (ipss)->ipsec_inbound_v4_policy_present)) 11377c478bd9Sstevel@tonic-gate 1138f4b3ec61Sdh155122 #define CONN_INBOUND_POLICY_PRESENT_V6(connp, ipss) \ 11397c478bd9Sstevel@tonic-gate ((connp)->conn_in_enforce_policy || \ 11407c478bd9Sstevel@tonic-gate (!(connp)->conn_policy_cached && \ 1141f4b3ec61Sdh155122 (ipss)->ipsec_inbound_v6_policy_present)) 11427c478bd9Sstevel@tonic-gate 1143f4b3ec61Sdh155122 #define CONN_OUTBOUND_POLICY_PRESENT(connp, ipss) \ 11447c478bd9Sstevel@tonic-gate ((connp)->conn_out_enforce_policy || \ 11457c478bd9Sstevel@tonic-gate (!((connp)->conn_policy_cached) && \ 1146f4b3ec61Sdh155122 (ipss)->ipsec_outbound_v4_policy_present)) 11477c478bd9Sstevel@tonic-gate 1148f4b3ec61Sdh155122 #define CONN_OUTBOUND_POLICY_PRESENT_V6(connp, ipss) \ 11497c478bd9Sstevel@tonic-gate ((connp)->conn_out_enforce_policy || \ 11507c478bd9Sstevel@tonic-gate (!(connp)->conn_policy_cached && \ 1151f4b3ec61Sdh155122 (ipss)->ipsec_outbound_v6_policy_present)) 11527c478bd9Sstevel@tonic-gate 11537c478bd9Sstevel@tonic-gate /* 11547c478bd9Sstevel@tonic-gate * Information cached in IRE for upper layer protocol (ULP). 11557c478bd9Sstevel@tonic-gate * 11567c478bd9Sstevel@tonic-gate * Notice that ire_max_frag is not included in the iulp_t structure, which 11577c478bd9Sstevel@tonic-gate * it may seem that it should. But ire_max_frag cannot really be cached. It 11587c478bd9Sstevel@tonic-gate * is fixed for each interface. For MTU found by PMTUd, we may want to cache 11597c478bd9Sstevel@tonic-gate * it. But currently, we do not do that. 11607c478bd9Sstevel@tonic-gate */ 11617c478bd9Sstevel@tonic-gate typedef struct iulp_s { 11627c478bd9Sstevel@tonic-gate boolean_t iulp_set; /* Is any metric set? */ 11637c478bd9Sstevel@tonic-gate uint32_t iulp_ssthresh; /* Slow start threshold (TCP). */ 11647c478bd9Sstevel@tonic-gate clock_t iulp_rtt; /* Guestimate in millisecs. */ 11657c478bd9Sstevel@tonic-gate clock_t iulp_rtt_sd; /* Cached value of RTT variance. */ 11667c478bd9Sstevel@tonic-gate uint32_t iulp_spipe; /* Send pipe size. */ 11677c478bd9Sstevel@tonic-gate uint32_t iulp_rpipe; /* Receive pipe size. */ 11687c478bd9Sstevel@tonic-gate uint32_t iulp_rtomax; /* Max round trip timeout. */ 11697c478bd9Sstevel@tonic-gate uint32_t iulp_sack; /* Use SACK option (TCP)? */ 11707c478bd9Sstevel@tonic-gate uint32_t 11717c478bd9Sstevel@tonic-gate iulp_tstamp_ok : 1, /* Use timestamp option (TCP)? */ 11727c478bd9Sstevel@tonic-gate iulp_wscale_ok : 1, /* Use window scale option (TCP)? */ 11737c478bd9Sstevel@tonic-gate iulp_ecn_ok : 1, /* Enable ECN (for TCP)? */ 11747c478bd9Sstevel@tonic-gate iulp_pmtud_ok : 1, /* Enable PMTUd? */ 11757c478bd9Sstevel@tonic-gate 11767c478bd9Sstevel@tonic-gate iulp_not_used : 28; 11777c478bd9Sstevel@tonic-gate } iulp_t; 11787c478bd9Sstevel@tonic-gate 11797c478bd9Sstevel@tonic-gate /* Zero iulp_t. */ 11807c478bd9Sstevel@tonic-gate extern const iulp_t ire_uinfo_null; 11817c478bd9Sstevel@tonic-gate 11827c478bd9Sstevel@tonic-gate /* 11837c478bd9Sstevel@tonic-gate * The conn drain list structure. 11847c478bd9Sstevel@tonic-gate * The list is protected by idl_lock. Each conn_t inserted in the list 11857c478bd9Sstevel@tonic-gate * points back at this idl_t using conn_idl. IP primes the draining of the 11867c478bd9Sstevel@tonic-gate * conns queued in these lists, by qenabling the 1st conn of each list. This 11877c478bd9Sstevel@tonic-gate * occurs when STREAMS backenables ip_wsrv on the IP module. Each conn instance 11887c478bd9Sstevel@tonic-gate * of ip_wsrv successively qenables the next conn in the list. 11897c478bd9Sstevel@tonic-gate * idl_lock protects all other members of idl_t and conn_drain_next 11907c478bd9Sstevel@tonic-gate * and conn_drain_prev of conn_t. The conn_lock protects IPCF_DRAIN_DISABLED 11917c478bd9Sstevel@tonic-gate * flag of the conn_t and conn_idl. 11927c478bd9Sstevel@tonic-gate */ 11937c478bd9Sstevel@tonic-gate typedef struct idl_s { 11947c478bd9Sstevel@tonic-gate conn_t *idl_conn; /* Head of drain list */ 11957c478bd9Sstevel@tonic-gate kmutex_t idl_lock; /* Lock for this list */ 11967c478bd9Sstevel@tonic-gate conn_t *idl_conn_draining; /* conn that is draining */ 11977c478bd9Sstevel@tonic-gate uint32_t 11987c478bd9Sstevel@tonic-gate idl_repeat : 1, /* Last conn must re-enable */ 11997c478bd9Sstevel@tonic-gate /* drain list again */ 12007c478bd9Sstevel@tonic-gate idl_unused : 31; 12017c478bd9Sstevel@tonic-gate } idl_t; 12027c478bd9Sstevel@tonic-gate 12037c478bd9Sstevel@tonic-gate #define CONN_DRAIN_LIST_LOCK(connp) (&((connp)->conn_idl->idl_lock)) 12047c478bd9Sstevel@tonic-gate /* 12057c478bd9Sstevel@tonic-gate * Interface route structure which holds the necessary information to recreate 12067c478bd9Sstevel@tonic-gate * routes that are tied to an interface (namely where ire_ipif != NULL). 12077c478bd9Sstevel@tonic-gate * These routes which were initially created via a routing socket or via the 12087c478bd9Sstevel@tonic-gate * SIOCADDRT ioctl may be gateway routes (RTF_GATEWAY being set) or may be 12097c478bd9Sstevel@tonic-gate * traditional interface routes. When an interface comes back up after being 12107c478bd9Sstevel@tonic-gate * marked down, this information will be used to recreate the routes. These 12117c478bd9Sstevel@tonic-gate * are part of an mblk_t chain that hangs off of the IPIF (ipif_saved_ire_mp). 12127c478bd9Sstevel@tonic-gate */ 12137c478bd9Sstevel@tonic-gate typedef struct ifrt_s { 12147c478bd9Sstevel@tonic-gate ushort_t ifrt_type; /* Type of IRE */ 12157c478bd9Sstevel@tonic-gate in6_addr_t ifrt_v6addr; /* Address IRE represents. */ 12167c478bd9Sstevel@tonic-gate in6_addr_t ifrt_v6gateway_addr; /* Gateway if IRE_OFFSUBNET */ 12177c478bd9Sstevel@tonic-gate in6_addr_t ifrt_v6src_addr; /* Src addr if RTF_SETSRC */ 12187c478bd9Sstevel@tonic-gate in6_addr_t ifrt_v6mask; /* Mask for matching IRE. */ 12197c478bd9Sstevel@tonic-gate uint32_t ifrt_flags; /* flags related to route */ 12207c478bd9Sstevel@tonic-gate uint_t ifrt_max_frag; /* MTU (next hop or path). */ 12217c478bd9Sstevel@tonic-gate iulp_t ifrt_iulp_info; /* Cached IRE ULP info. */ 12227c478bd9Sstevel@tonic-gate } ifrt_t; 12237c478bd9Sstevel@tonic-gate 12247c478bd9Sstevel@tonic-gate #define ifrt_addr V4_PART_OF_V6(ifrt_v6addr) 12257c478bd9Sstevel@tonic-gate #define ifrt_gateway_addr V4_PART_OF_V6(ifrt_v6gateway_addr) 12267c478bd9Sstevel@tonic-gate #define ifrt_src_addr V4_PART_OF_V6(ifrt_v6src_addr) 12277c478bd9Sstevel@tonic-gate #define ifrt_mask V4_PART_OF_V6(ifrt_v6mask) 12287c478bd9Sstevel@tonic-gate 12297c478bd9Sstevel@tonic-gate /* Number of IP addresses that can be hosted on a physical interface */ 12307c478bd9Sstevel@tonic-gate #define MAX_ADDRS_PER_IF 8192 12317c478bd9Sstevel@tonic-gate /* 12327c478bd9Sstevel@tonic-gate * Number of Source addresses to be considered for source address 12337c478bd9Sstevel@tonic-gate * selection. Used by ipif_select_source[_v6]. 12347c478bd9Sstevel@tonic-gate */ 12357c478bd9Sstevel@tonic-gate #define MAX_IPIF_SELECT_SOURCE 50 12367c478bd9Sstevel@tonic-gate 12377c478bd9Sstevel@tonic-gate #ifdef IP_DEBUG 12387c478bd9Sstevel@tonic-gate /* 12397924222fSmeem * Trace refholds and refreles for debugging. 12407c478bd9Sstevel@tonic-gate */ 12416a8288c7Scarlsonj #define TR_STACK_DEPTH 14 12427c478bd9Sstevel@tonic-gate typedef struct tr_buf_s { 12437c478bd9Sstevel@tonic-gate int tr_depth; 12446a8288c7Scarlsonj clock_t tr_time; 12456a8288c7Scarlsonj pc_t tr_stack[TR_STACK_DEPTH]; 12467c478bd9Sstevel@tonic-gate } tr_buf_t; 12477c478bd9Sstevel@tonic-gate 12487c478bd9Sstevel@tonic-gate typedef struct th_trace_s { 12497c478bd9Sstevel@tonic-gate int th_refcnt; 12507c478bd9Sstevel@tonic-gate uint_t th_trace_lastref; 12516a8288c7Scarlsonj kthread_t *th_id; 12527c478bd9Sstevel@tonic-gate #define TR_BUF_MAX 38 12537c478bd9Sstevel@tonic-gate tr_buf_t th_trbuf[TR_BUF_MAX]; 12547c478bd9Sstevel@tonic-gate } th_trace_t; 12556a8288c7Scarlsonj 12566a8288c7Scarlsonj typedef struct th_hash_s { 12576a8288c7Scarlsonj list_node_t thh_link; 12586a8288c7Scarlsonj mod_hash_t *thh_hash; 12596a8288c7Scarlsonj ip_stack_t *thh_ipst; 12606a8288c7Scarlsonj } th_hash_t; 12617c478bd9Sstevel@tonic-gate #endif 12627c478bd9Sstevel@tonic-gate 12637c478bd9Sstevel@tonic-gate /* The following are ipif_state_flags */ 12647c478bd9Sstevel@tonic-gate #define IPIF_CONDEMNED 0x1 /* The ipif is being removed */ 12657c478bd9Sstevel@tonic-gate #define IPIF_CHANGING 0x2 /* A critcal ipif field is changing */ 12667c478bd9Sstevel@tonic-gate #define IPIF_MOVING 0x8 /* The ipif is being moved */ 12677c478bd9Sstevel@tonic-gate #define IPIF_SET_LINKLOCAL 0x10 /* transient flag during bringup */ 12687c478bd9Sstevel@tonic-gate #define IPIF_ZERO_SOURCE 0x20 /* transient flag during bringup */ 12697c478bd9Sstevel@tonic-gate 12707c478bd9Sstevel@tonic-gate /* IP interface structure, one per local address */ 12717c478bd9Sstevel@tonic-gate typedef struct ipif_s { 12727c478bd9Sstevel@tonic-gate struct ipif_s *ipif_next; 12737c478bd9Sstevel@tonic-gate struct ill_s *ipif_ill; /* Back pointer to our ill */ 12747c478bd9Sstevel@tonic-gate int ipif_id; /* Logical unit number */ 12757c478bd9Sstevel@tonic-gate uint_t ipif_mtu; /* Starts at ipif_ill->ill_max_frag */ 12767c478bd9Sstevel@tonic-gate uint_t ipif_saved_mtu; /* Save of mtu during ipif_move() */ 12777c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6lcl_addr; /* Local IP address for this if. */ 12787c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6src_addr; /* Source IP address for this if. */ 12797c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6subnet; /* Subnet prefix for this if. */ 12807c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6net_mask; /* Net mask for this interface. */ 12817c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6brd_addr; /* Broadcast addr for this interface. */ 12827c478bd9Sstevel@tonic-gate in6_addr_t ipif_v6pp_dst_addr; /* Point-to-point dest address. */ 12837c478bd9Sstevel@tonic-gate uint64_t ipif_flags; /* Interface flags. */ 12847c478bd9Sstevel@tonic-gate uint_t ipif_metric; /* BSD if metric, for compatibility. */ 12857c478bd9Sstevel@tonic-gate uint_t ipif_ire_type; /* IRE_LOCAL or IRE_LOOPBACK */ 12867c478bd9Sstevel@tonic-gate mblk_t *ipif_arp_del_mp; /* Allocated at time arp comes up, to */ 12877c478bd9Sstevel@tonic-gate /* prevent awkward out of mem */ 12887c478bd9Sstevel@tonic-gate /* condition later */ 12897c478bd9Sstevel@tonic-gate mblk_t *ipif_saved_ire_mp; /* Allocated for each extra */ 12907c478bd9Sstevel@tonic-gate /* IRE_IF_NORESOLVER/IRE_IF_RESOLVER */ 12917c478bd9Sstevel@tonic-gate /* on this interface so that they */ 12927c478bd9Sstevel@tonic-gate /* can survive ifconfig down. */ 12937c478bd9Sstevel@tonic-gate kmutex_t ipif_saved_ire_lock; /* Protects ipif_saved_ire_mp */ 12947c478bd9Sstevel@tonic-gate 12957c478bd9Sstevel@tonic-gate mrec_t *ipif_igmp_rpt; /* List of group memberships which */ 12967c478bd9Sstevel@tonic-gate /* will be reported on. Used when */ 12977c478bd9Sstevel@tonic-gate /* handling an igmp timeout. */ 12987c478bd9Sstevel@tonic-gate 12997c478bd9Sstevel@tonic-gate /* 13007c478bd9Sstevel@tonic-gate * The packet counts in the ipif contain the sum of the 13017c478bd9Sstevel@tonic-gate * packet counts in dead IREs that were affiliated with 13027c478bd9Sstevel@tonic-gate * this ipif. 13037c478bd9Sstevel@tonic-gate */ 13047c478bd9Sstevel@tonic-gate uint_t ipif_fo_pkt_count; /* Forwarded thru our dead IREs */ 13057c478bd9Sstevel@tonic-gate uint_t ipif_ib_pkt_count; /* Inbound packets for our dead IREs */ 13067c478bd9Sstevel@tonic-gate uint_t ipif_ob_pkt_count; /* Outbound packets to our dead IREs */ 13077c478bd9Sstevel@tonic-gate /* Exclusive bit fields, protected by ipsq_t */ 13087c478bd9Sstevel@tonic-gate unsigned int 13097c478bd9Sstevel@tonic-gate ipif_multicast_up : 1, /* We have joined the allhosts group */ 13107c478bd9Sstevel@tonic-gate ipif_replace_zero : 1, /* Replacement for zero */ 13117c478bd9Sstevel@tonic-gate ipif_was_up : 1, /* ipif was up before */ 131269bb4bb4Scarlsonj ipif_addr_ready : 1, /* DAD is done */ 1313e6ed03fcSmeem 131469bb4bb4Scarlsonj ipif_was_dup : 1, /* DAD had failed */ 1315e6ed03fcSmeem ipif_pad_to_31 : 27; 13167c478bd9Sstevel@tonic-gate 13177c478bd9Sstevel@tonic-gate int ipif_orig_ifindex; /* ifindex before SLIFFAILOVER */ 13187c478bd9Sstevel@tonic-gate uint_t ipif_seqid; /* unique index across all ills */ 13197c478bd9Sstevel@tonic-gate uint_t ipif_orig_ipifid; /* ipif_id before SLIFFAILOVER */ 13207c478bd9Sstevel@tonic-gate uint_t ipif_state_flags; /* See IPIF_* flag defs above */ 13217c478bd9Sstevel@tonic-gate uint_t ipif_refcnt; /* active consistent reader cnt */ 1322968d2fd1Ssowmini 1323384ad179Ssowmini /* Number of ire's and ilm's referencing this ipif */ 1324384ad179Ssowmini uint_t ipif_ire_cnt; 1325384ad179Ssowmini uint_t ipif_ilm_cnt; 1326968d2fd1Ssowmini 13277c478bd9Sstevel@tonic-gate uint_t ipif_saved_ire_cnt; 1328968d2fd1Ssowmini zoneid_t ipif_zoneid; /* zone ID number */ 132969bb4bb4Scarlsonj timeout_id_t ipif_recovery_id; /* Timer for DAD recovery */ 13307c478bd9Sstevel@tonic-gate boolean_t ipif_trace_disable; /* True when alloc fails */ 13317c478bd9Sstevel@tonic-gate } ipif_t; 13327c478bd9Sstevel@tonic-gate 13337c478bd9Sstevel@tonic-gate /* 1334968d2fd1Ssowmini * IPIF_FREE_OK() means that there are no incoming references 1335968d2fd1Ssowmini * to the ipif. Incoming refs would prevent the ipif from being freed. 1336968d2fd1Ssowmini */ 1337968d2fd1Ssowmini #define IPIF_FREE_OK(ipif) \ 1338384ad179Ssowmini ((ipif)->ipif_ire_cnt == 0 && (ipif)->ipif_ilm_cnt == 0) 1339968d2fd1Ssowmini /* 1340968d2fd1Ssowmini * IPIF_DOWN_OK() determines whether the incoming pointer reference counts 1341968d2fd1Ssowmini * would permit the ipif to be considered quiescent. In order for 1342968d2fd1Ssowmini * an ipif or ill to be considered quiescent, the ire and nce references 1343968d2fd1Ssowmini * to that ipif/ill must be zero. 1344968d2fd1Ssowmini * 1345968d2fd1Ssowmini * We do not require the ilm references to go to zero for quiescence 1346968d2fd1Ssowmini * because the quiescence checks are done to ensure that 1347968d2fd1Ssowmini * outgoing packets do not use addresses from the ipif/ill after it 1348968d2fd1Ssowmini * has been marked down, and incoming packets to addresses on a 1349968d2fd1Ssowmini * queiscent interface are rejected. This implies that all the 1350968d2fd1Ssowmini * ire/nce's using that source address need to be deleted and future 1351968d2fd1Ssowmini * creation of any ires using that source address must be prevented. 1352968d2fd1Ssowmini * Similarly incoming unicast packets destined to the 'down' address 1353968d2fd1Ssowmini * will not be accepted once that ire is gone. However incoming 1354968d2fd1Ssowmini * multicast packets are not destined to the downed address. 1355968d2fd1Ssowmini * They are only related to the ill in question. Furthermore 1356968d2fd1Ssowmini * the current API behavior allows applications to join or leave 1357968d2fd1Ssowmini * multicast groups, i.e., IP_ADD_MEMBERSHIP / LEAVE_MEMBERSHIP, using a 1358968d2fd1Ssowmini * down address. Therefore the ilm references are not included in 1359968d2fd1Ssowmini * the _DOWN_OK macros. 1360968d2fd1Ssowmini */ 1361384ad179Ssowmini #define IPIF_DOWN_OK(ipif) ((ipif)->ipif_ire_cnt == 0) 1362968d2fd1Ssowmini 1363968d2fd1Ssowmini /* 13647c478bd9Sstevel@tonic-gate * The following table lists the protection levels of the various members 13657c478bd9Sstevel@tonic-gate * of the ipif_t. The following notation is used. 13667c478bd9Sstevel@tonic-gate * 13677c478bd9Sstevel@tonic-gate * Write once - Written to only once at the time of bringing up 13687c478bd9Sstevel@tonic-gate * the interface and can be safely read after the bringup without any lock. 13697c478bd9Sstevel@tonic-gate * 13707c478bd9Sstevel@tonic-gate * ipsq - Need to execute in the ipsq to perform the indicated access. 13717c478bd9Sstevel@tonic-gate * 13727c478bd9Sstevel@tonic-gate * ill_lock - Need to hold this mutex to perform the indicated access. 13737c478bd9Sstevel@tonic-gate * 13747c478bd9Sstevel@tonic-gate * ill_g_lock - Need to hold this rw lock as reader/writer for read access or 13757c478bd9Sstevel@tonic-gate * write access respectively. 13767c478bd9Sstevel@tonic-gate * 13777c478bd9Sstevel@tonic-gate * down ill - Written to only when the ill is down (i.e all ipifs are down) 13787c478bd9Sstevel@tonic-gate * up ill - Read only when the ill is up (i.e. at least 1 ipif is up) 13797c478bd9Sstevel@tonic-gate * 13807c478bd9Sstevel@tonic-gate * Table of ipif_t members and their protection 13817c478bd9Sstevel@tonic-gate * 13828df01f76Smeem * ipif_next ipsq + ill_lock + ipsq OR ill_lock OR 13838df01f76Smeem * ill_g_lock ill_g_lock 13847c478bd9Sstevel@tonic-gate * ipif_ill ipsq + down ipif write once 13857c478bd9Sstevel@tonic-gate * ipif_id ipsq + down ipif write once 13867c478bd9Sstevel@tonic-gate * ipif_mtu ipsq 13877c478bd9Sstevel@tonic-gate * ipif_v6lcl_addr ipsq + down ipif up ipif 13887c478bd9Sstevel@tonic-gate * ipif_v6src_addr ipsq + down ipif up ipif 13897c478bd9Sstevel@tonic-gate * ipif_v6subnet ipsq + down ipif up ipif 13907c478bd9Sstevel@tonic-gate * ipif_v6net_mask ipsq + down ipif up ipif 13917c478bd9Sstevel@tonic-gate * 13927c478bd9Sstevel@tonic-gate * ipif_v6brd_addr 13937c478bd9Sstevel@tonic-gate * ipif_v6pp_dst_addr 13947c478bd9Sstevel@tonic-gate * ipif_flags ill_lock ill_lock 13957c478bd9Sstevel@tonic-gate * ipif_metric 13967c478bd9Sstevel@tonic-gate * ipif_ire_type ipsq + down ill up ill 13977c478bd9Sstevel@tonic-gate * 13987c478bd9Sstevel@tonic-gate * ipif_arp_del_mp ipsq ipsq 13997c478bd9Sstevel@tonic-gate * ipif_saved_ire_mp ipif_saved_ire_lock ipif_saved_ire_lock 14007c478bd9Sstevel@tonic-gate * ipif_igmp_rpt ipsq ipsq 14017c478bd9Sstevel@tonic-gate * 14027c478bd9Sstevel@tonic-gate * ipif_fo_pkt_count Approx 14037c478bd9Sstevel@tonic-gate * ipif_ib_pkt_count Approx 14047c478bd9Sstevel@tonic-gate * ipif_ob_pkt_count Approx 14057c478bd9Sstevel@tonic-gate * 14067c478bd9Sstevel@tonic-gate * bit fields ill_lock ill_lock 14077c478bd9Sstevel@tonic-gate * 14087c478bd9Sstevel@tonic-gate * ipif_orig_ifindex ipsq None 14097c478bd9Sstevel@tonic-gate * ipif_orig_ipifid ipsq None 14107c478bd9Sstevel@tonic-gate * ipif_seqid ipsq Write once 14117c478bd9Sstevel@tonic-gate * 14127c478bd9Sstevel@tonic-gate * ipif_state_flags ill_lock ill_lock 14137c478bd9Sstevel@tonic-gate * ipif_refcnt ill_lock ill_lock 1414384ad179Ssowmini * ipif_ire_cnt ill_lock ill_lock 1415384ad179Ssowmini * ipif_ilm_cnt ill_lock ill_lock 14167c478bd9Sstevel@tonic-gate * ipif_saved_ire_cnt 14177c478bd9Sstevel@tonic-gate */ 14187c478bd9Sstevel@tonic-gate 14197c478bd9Sstevel@tonic-gate #define IP_TR_HASH(tid) ((((uintptr_t)tid) >> 6) & (IP_TR_HASH_MAX - 1)) 14207c478bd9Sstevel@tonic-gate 14216a8288c7Scarlsonj #ifdef DEBUG 14227c478bd9Sstevel@tonic-gate #define IPIF_TRACE_REF(ipif) ipif_trace_ref(ipif) 14237c478bd9Sstevel@tonic-gate #define ILL_TRACE_REF(ill) ill_trace_ref(ill) 14247c478bd9Sstevel@tonic-gate #define IPIF_UNTRACE_REF(ipif) ipif_untrace_ref(ipif) 14257c478bd9Sstevel@tonic-gate #define ILL_UNTRACE_REF(ill) ill_untrace_ref(ill) 14267c478bd9Sstevel@tonic-gate #else 14277c478bd9Sstevel@tonic-gate #define IPIF_TRACE_REF(ipif) 14287c478bd9Sstevel@tonic-gate #define ILL_TRACE_REF(ill) 14297c478bd9Sstevel@tonic-gate #define IPIF_UNTRACE_REF(ipif) 14307c478bd9Sstevel@tonic-gate #define ILL_UNTRACE_REF(ill) 14317c478bd9Sstevel@tonic-gate #endif 14327c478bd9Sstevel@tonic-gate 14337924222fSmeem /* IPv4 compatibility macros */ 14347c478bd9Sstevel@tonic-gate #define ipif_lcl_addr V4_PART_OF_V6(ipif_v6lcl_addr) 14357c478bd9Sstevel@tonic-gate #define ipif_src_addr V4_PART_OF_V6(ipif_v6src_addr) 14367c478bd9Sstevel@tonic-gate #define ipif_subnet V4_PART_OF_V6(ipif_v6subnet) 14377c478bd9Sstevel@tonic-gate #define ipif_net_mask V4_PART_OF_V6(ipif_v6net_mask) 14387c478bd9Sstevel@tonic-gate #define ipif_brd_addr V4_PART_OF_V6(ipif_v6brd_addr) 14397c478bd9Sstevel@tonic-gate #define ipif_pp_dst_addr V4_PART_OF_V6(ipif_v6pp_dst_addr) 14407c478bd9Sstevel@tonic-gate 14417c478bd9Sstevel@tonic-gate /* Macros for easy backreferences to the ill. */ 14427c478bd9Sstevel@tonic-gate #define ipif_wq ipif_ill->ill_wq 14437c478bd9Sstevel@tonic-gate #define ipif_rq ipif_ill->ill_rq 14447c478bd9Sstevel@tonic-gate #define ipif_net_type ipif_ill->ill_net_type 14457c478bd9Sstevel@tonic-gate #define ipif_ipif_up_count ipif_ill->ill_ipif_up_count 14467c478bd9Sstevel@tonic-gate #define ipif_type ipif_ill->ill_type 14477c478bd9Sstevel@tonic-gate #define ipif_isv6 ipif_ill->ill_isv6 14487c478bd9Sstevel@tonic-gate 14497c478bd9Sstevel@tonic-gate #define SIOCLIFADDR_NDX 112 /* ndx of SIOCLIFADDR in the ndx ioctl table */ 14507c478bd9Sstevel@tonic-gate 14517c478bd9Sstevel@tonic-gate /* 14527c478bd9Sstevel@tonic-gate * mode value for ip_ioctl_finish for finishing an ioctl 14537c478bd9Sstevel@tonic-gate */ 14547c478bd9Sstevel@tonic-gate #define CONN_CLOSE 1 /* No mi_copy */ 14557c478bd9Sstevel@tonic-gate #define COPYOUT 2 /* do an mi_copyout if needed */ 14567c478bd9Sstevel@tonic-gate #define NO_COPYOUT 3 /* do an mi_copy_done */ 1457b051ecf6Smeem #define IPI2MODE(ipi) ((ipi)->ipi_flags & IPI_GET_CMD ? COPYOUT : NO_COPYOUT) 14587c478bd9Sstevel@tonic-gate 14597c478bd9Sstevel@tonic-gate /* 14607c478bd9Sstevel@tonic-gate * The IP-MT design revolves around the serialization object ipsq_t. 14617c478bd9Sstevel@tonic-gate * It is associated with an IPMP group. If IPMP is not enabled, there is 14627c478bd9Sstevel@tonic-gate * 1 ipsq_t per phyint. Eg. an ipsq_t would cover both hme0's IPv4 stream 14637c478bd9Sstevel@tonic-gate * 14647c478bd9Sstevel@tonic-gate * ipsq_lock protects 14657c478bd9Sstevel@tonic-gate * ipsq_reentry_cnt, ipsq_writer, ipsq_xopq_mphead, ipsq_xopq_mptail, 14667c478bd9Sstevel@tonic-gate * ipsq_mphead, ipsq_mptail, ipsq_split 14677c478bd9Sstevel@tonic-gate * 14687c478bd9Sstevel@tonic-gate * ipsq_pending_ipif, ipsq_current_ipif, ipsq_pending_mp, ipsq_flags, 14697c478bd9Sstevel@tonic-gate * ipsq_waitfor 14707c478bd9Sstevel@tonic-gate * 14717c478bd9Sstevel@tonic-gate * The fields in the last line above below are set mostly by a writer thread 14727c478bd9Sstevel@tonic-gate * But there is an exception in the last call to ipif_ill_refrele_tail which 14737c478bd9Sstevel@tonic-gate * could also race with a conn close which could be cleaning up the 14747c478bd9Sstevel@tonic-gate * fields. So we choose to protect using ipsq_lock instead of depending on 14757c478bd9Sstevel@tonic-gate * the property of the writer. 14767c478bd9Sstevel@tonic-gate * ill_g_lock protects 14777c478bd9Sstevel@tonic-gate * ipsq_refs, ipsq_phyint_list 14787c478bd9Sstevel@tonic-gate */ 14797c478bd9Sstevel@tonic-gate typedef struct ipsq_s { 14807c478bd9Sstevel@tonic-gate kmutex_t ipsq_lock; 14817c478bd9Sstevel@tonic-gate int ipsq_reentry_cnt; 14827c478bd9Sstevel@tonic-gate kthread_t *ipsq_writer; /* current owner (thread id) */ 14837c478bd9Sstevel@tonic-gate int ipsq_flags; 14847c478bd9Sstevel@tonic-gate mblk_t *ipsq_xopq_mphead; /* list of excl ops mostly ioctls */ 14857c478bd9Sstevel@tonic-gate mblk_t *ipsq_xopq_mptail; 14867c478bd9Sstevel@tonic-gate mblk_t *ipsq_mphead; /* msgs on ipsq linked thru b_next */ 14877c478bd9Sstevel@tonic-gate mblk_t *ipsq_mptail; /* msgs on ipsq linked thru b_next */ 1488b051ecf6Smeem int ipsq_current_ioctl; /* current ioctl, or 0 if no ioctl */ 14899c3e527fSmeem boolean_t ipsq_current_done; /* is the current op done? */ 1490b051ecf6Smeem ipif_t *ipsq_current_ipif; /* ipif associated with current op */ 14917c478bd9Sstevel@tonic-gate ipif_t *ipsq_pending_ipif; /* ipif associated w. ipsq_pending_mp */ 14927c478bd9Sstevel@tonic-gate mblk_t *ipsq_pending_mp; /* current ioctl mp while waiting for */ 14937c478bd9Sstevel@tonic-gate /* response from another module */ 14947c478bd9Sstevel@tonic-gate struct ipsq_s *ipsq_next; /* list of all syncq's (ipsq_g_list) */ 14957c478bd9Sstevel@tonic-gate uint_t ipsq_refs; /* Number of phyints on this ipsq */ 14967c478bd9Sstevel@tonic-gate struct phyint *ipsq_phyint_list; /* List of phyints on this ipsq */ 14977c478bd9Sstevel@tonic-gate boolean_t ipsq_split; /* ipsq may need to be split */ 14987c478bd9Sstevel@tonic-gate int ipsq_waitfor; /* Values encoded below */ 14997c478bd9Sstevel@tonic-gate char ipsq_name[LIFNAMSIZ+1]; /* same as phyint_groupname */ 1500f4b3ec61Sdh155122 ip_stack_t *ipsq_ipst; /* Does not have a netstack_hold */ 15016a8288c7Scarlsonj 15026a8288c7Scarlsonj #ifdef DEBUG 15036a8288c7Scarlsonj int ipsq_depth; /* debugging aid */ 15046a8288c7Scarlsonj #define IPSQ_STACK_DEPTH 15 15056a8288c7Scarlsonj pc_t ipsq_stack[IPSQ_STACK_DEPTH]; /* debugging aid */ 15066a8288c7Scarlsonj #endif 15077c478bd9Sstevel@tonic-gate } ipsq_t; 15087c478bd9Sstevel@tonic-gate 15097c478bd9Sstevel@tonic-gate /* ipsq_flags */ 15107c478bd9Sstevel@tonic-gate #define IPSQ_GROUP 0x1 /* This ipsq belongs to an IPMP group */ 15117c478bd9Sstevel@tonic-gate 15127c478bd9Sstevel@tonic-gate /* 15137c478bd9Sstevel@tonic-gate * ipsq_waitfor: 15147c478bd9Sstevel@tonic-gate * 15157c478bd9Sstevel@tonic-gate * IPIF_DOWN 1 ipif_down waiting for refcnts to drop 15167c478bd9Sstevel@tonic-gate * ILL_DOWN 2 ill_down waiting for refcnts to drop 15177c478bd9Sstevel@tonic-gate * IPIF_FREE 3 ipif_free waiting for refcnts to drop 15187c478bd9Sstevel@tonic-gate * ILL_FREE 4 ill unplumb waiting for refcnts to drop 15197c478bd9Sstevel@tonic-gate * ILL_MOVE_OK 5 failover waiting for refcnts to drop 15207c478bd9Sstevel@tonic-gate */ 15217c478bd9Sstevel@tonic-gate 15227c478bd9Sstevel@tonic-gate enum { IPIF_DOWN = 1, ILL_DOWN, IPIF_FREE, ILL_FREE, ILL_MOVE_OK }; 15237c478bd9Sstevel@tonic-gate 15247c478bd9Sstevel@tonic-gate /* Flags passed to ipsq_try_enter */ 15257c478bd9Sstevel@tonic-gate #define CUR_OP 0 /* Current ioctl continuing again */ 15267c478bd9Sstevel@tonic-gate #define NEW_OP 1 /* New ioctl starting afresh */ 15277c478bd9Sstevel@tonic-gate 15287c478bd9Sstevel@tonic-gate /* 15297c478bd9Sstevel@tonic-gate * phyint represents state that is common to both IPv4 and IPv6 interfaces. 15307c478bd9Sstevel@tonic-gate * There is a separate ill_t representing IPv4 and IPv6 which has a 15317924222fSmeem * backpointer to the phyint structure for accessing common state. 15327c478bd9Sstevel@tonic-gate * 15337c478bd9Sstevel@tonic-gate * NOTE : It just stores the group name as there is only one name for 15347c478bd9Sstevel@tonic-gate * IPv4 and IPv6 i.e it is a underlying link property. Actually 15357c478bd9Sstevel@tonic-gate * IPv4 and IPv6 ill are grouped together when their phyints have 15367c478bd9Sstevel@tonic-gate * the same name. 15377c478bd9Sstevel@tonic-gate */ 15387c478bd9Sstevel@tonic-gate typedef struct phyint { 15397c478bd9Sstevel@tonic-gate struct ill_s *phyint_illv4; 15407c478bd9Sstevel@tonic-gate struct ill_s *phyint_illv6; 15417c478bd9Sstevel@tonic-gate uint_t phyint_ifindex; /* SIOCLSLIFINDEX */ 15427c478bd9Sstevel@tonic-gate char *phyint_groupname; /* SIOCSLIFGROUPNAME */ 15437c478bd9Sstevel@tonic-gate uint_t phyint_groupname_len; 15447c478bd9Sstevel@tonic-gate uint64_t phyint_flags; 15457c478bd9Sstevel@tonic-gate avl_node_t phyint_avl_by_index; /* avl tree by index */ 15467c478bd9Sstevel@tonic-gate avl_node_t phyint_avl_by_name; /* avl tree by name */ 15477c478bd9Sstevel@tonic-gate kmutex_t phyint_lock; 15487c478bd9Sstevel@tonic-gate struct ipsq_s *phyint_ipsq; /* back pointer to ipsq */ 15497c478bd9Sstevel@tonic-gate struct phyint *phyint_ipsq_next; /* phyint list on this ipsq */ 155067c1caeeSnordmark /* Once Clearview IPMP is added the follow two fields can be removed */ 155167c1caeeSnordmark uint_t phyint_group_ifindex; /* index assigned to group */ 155267c1caeeSnordmark uint_t phyint_hook_ifindex; /* index used with neti/hook */ 15537c478bd9Sstevel@tonic-gate } phyint_t; 15547c478bd9Sstevel@tonic-gate 15557c478bd9Sstevel@tonic-gate #define CACHE_ALIGN_SIZE 64 15567c478bd9Sstevel@tonic-gate 15577c478bd9Sstevel@tonic-gate #define CACHE_ALIGN(align_struct) P2ROUNDUP(sizeof (struct align_struct),\ 15587c478bd9Sstevel@tonic-gate CACHE_ALIGN_SIZE) 15597c478bd9Sstevel@tonic-gate struct _phyint_list_s_ { 15607c478bd9Sstevel@tonic-gate avl_tree_t phyint_list_avl_by_index; /* avl tree by index */ 15617c478bd9Sstevel@tonic-gate avl_tree_t phyint_list_avl_by_name; /* avl tree by name */ 15627c478bd9Sstevel@tonic-gate }; 15637c478bd9Sstevel@tonic-gate 15647c478bd9Sstevel@tonic-gate typedef union phyint_list_u { 15657c478bd9Sstevel@tonic-gate struct _phyint_list_s_ phyint_list_s; 15667c478bd9Sstevel@tonic-gate char phyint_list_filler[CACHE_ALIGN(_phyint_list_s_)]; 15677c478bd9Sstevel@tonic-gate } phyint_list_t; 15687c478bd9Sstevel@tonic-gate 15697c478bd9Sstevel@tonic-gate #define phyint_list_avl_by_index phyint_list_s.phyint_list_avl_by_index 15707c478bd9Sstevel@tonic-gate #define phyint_list_avl_by_name phyint_list_s.phyint_list_avl_by_name 15717c478bd9Sstevel@tonic-gate /* 15727c478bd9Sstevel@tonic-gate * ILL groups. We group ills, 15737c478bd9Sstevel@tonic-gate * 15747c478bd9Sstevel@tonic-gate * - if the ills have the same group name. (New way) 15757c478bd9Sstevel@tonic-gate * 15767c478bd9Sstevel@tonic-gate * ill_group locking notes: 15777c478bd9Sstevel@tonic-gate * 15787c478bd9Sstevel@tonic-gate * illgrp_lock protects ill_grp_ill_schednext. 15797c478bd9Sstevel@tonic-gate * 15807c478bd9Sstevel@tonic-gate * ill_g_lock protects ill_grp_next, illgrp_ill, illgrp_ill_count. 15817c478bd9Sstevel@tonic-gate * Holding ill_g_lock freezes the memberships of ills in IPMP groups. 15827c478bd9Sstevel@tonic-gate * It also freezes the global list of ills and all ipifs in all ills. 15837c478bd9Sstevel@tonic-gate * 15847c478bd9Sstevel@tonic-gate * To remove an ipif from the linked list of ipifs of that ill ipif_free_tail 15857c478bd9Sstevel@tonic-gate * holds both ill_g_lock, and ill_lock. Similarly to remove an ill from the 158698e93c29Smeem * global list of ills, ill_glist_delete() holds ill_g_lock as writer. 15877c478bd9Sstevel@tonic-gate * This simplifies things for ipif_select_source, illgrp_scheduler etc. 15887c478bd9Sstevel@tonic-gate * that need to walk the members of an illgrp. They just hold ill_g_lock 15897c478bd9Sstevel@tonic-gate * as reader to do the walk. 15907c478bd9Sstevel@tonic-gate * 15917c478bd9Sstevel@tonic-gate */ 15927c478bd9Sstevel@tonic-gate typedef struct ill_group { 15937c478bd9Sstevel@tonic-gate kmutex_t illgrp_lock; 15947c478bd9Sstevel@tonic-gate struct ill_group *illgrp_next; /* Next ill_group */ 15957c478bd9Sstevel@tonic-gate struct ill_s *illgrp_ill_schednext; /* Next ill to be scheduled */ 15967c478bd9Sstevel@tonic-gate struct ill_s *illgrp_ill; /* First ill in the group */ 15977c478bd9Sstevel@tonic-gate int illgrp_ill_count; 15987c478bd9Sstevel@tonic-gate } ill_group_t; 15997c478bd9Sstevel@tonic-gate 16007c478bd9Sstevel@tonic-gate /* 16017c478bd9Sstevel@tonic-gate * Fragmentation hash bucket 16027c478bd9Sstevel@tonic-gate */ 16037c478bd9Sstevel@tonic-gate typedef struct ipfb_s { 16047c478bd9Sstevel@tonic-gate struct ipf_s *ipfb_ipf; /* List of ... */ 16057c478bd9Sstevel@tonic-gate size_t ipfb_count; /* Count of bytes used by frag(s) */ 16067c478bd9Sstevel@tonic-gate kmutex_t ipfb_lock; /* Protect all ipf in list */ 16077c478bd9Sstevel@tonic-gate uint_t ipfb_frag_pkts; /* num of distinct fragmented pkts */ 16087c478bd9Sstevel@tonic-gate } ipfb_t; 16097c478bd9Sstevel@tonic-gate 16107c478bd9Sstevel@tonic-gate /* 16117c478bd9Sstevel@tonic-gate * IRE bucket structure. Usually there is an array of such structures, 16127c478bd9Sstevel@tonic-gate * each pointing to a linked list of ires. irb_refcnt counts the number 16137c478bd9Sstevel@tonic-gate * of walkers of a given hash bucket. Usually the reference count is 16147c478bd9Sstevel@tonic-gate * bumped up if the walker wants no IRES to be DELETED while walking the 16157c478bd9Sstevel@tonic-gate * list. Bumping up does not PREVENT ADDITION. This allows walking a given 16167c478bd9Sstevel@tonic-gate * hash bucket without stumbling up on a free pointer. 1617c793af95Ssangeeta * 1618c793af95Ssangeeta * irb_t structures in ip_ftable are dynamically allocated and freed. 16193173664eSapersson * In order to identify the irb_t structures that can be safely kmem_free'd 1620c793af95Ssangeeta * we need to ensure that 1621c793af95Ssangeeta * - the irb_refcnt is quiescent, indicating no other walkers, 1622c793af95Ssangeeta * - no other threads or ire's are holding references to the irb, 1623c793af95Ssangeeta * i.e., irb_nire == 0, 1624c793af95Ssangeeta * - there are no active ire's in the bucket, i.e., irb_ire_cnt == 0 16257c478bd9Sstevel@tonic-gate */ 16267c478bd9Sstevel@tonic-gate typedef struct irb { 16277c478bd9Sstevel@tonic-gate struct ire_s *irb_ire; /* First ire in this bucket */ 16287c478bd9Sstevel@tonic-gate /* Should be first in this struct */ 16297c478bd9Sstevel@tonic-gate krwlock_t irb_lock; /* Protect this bucket */ 16307c478bd9Sstevel@tonic-gate uint_t irb_refcnt; /* Protected by irb_lock */ 16317c478bd9Sstevel@tonic-gate uchar_t irb_marks; /* CONDEMNED ires in this bucket ? */ 1632c793af95Ssangeeta #define IRB_MARK_CONDEMNED 0x0001 1633c793af95Ssangeeta #define IRB_MARK_FTABLE 0x0002 1634c793af95Ssangeeta uint_t irb_ire_cnt; /* Num of active IRE in this bucket */ 16357c478bd9Sstevel@tonic-gate uint_t irb_tmp_ire_cnt; /* Num of temporary IRE */ 1636c793af95Ssangeeta struct ire_s *irb_rr_origin; /* origin for round-robin */ 1637c793af95Ssangeeta int irb_nire; /* Num of ftable ire's that ref irb */ 1638f4b3ec61Sdh155122 ip_stack_t *irb_ipst; /* Does not have a netstack_hold */ 16397c478bd9Sstevel@tonic-gate } irb_t; 16407c478bd9Sstevel@tonic-gate 1641c793af95Ssangeeta #define IRB2RT(irb) (rt_t *)((caddr_t)(irb) - offsetof(rt_t, rt_irb)) 1642c793af95Ssangeeta 1643c793af95Ssangeeta /* The following are return values of ip_xmit_v4() */ 1644c793af95Ssangeeta typedef enum { 1645c793af95Ssangeeta SEND_PASSED = 0, /* sent packet out on wire */ 1646c793af95Ssangeeta SEND_FAILED, /* sending of packet failed */ 1647c793af95Ssangeeta LOOKUP_IN_PROGRESS, /* ire cache found, ARP resolution in progress */ 1648c793af95Ssangeeta LLHDR_RESLV_FAILED /* macaddr resl of onlink dst or nexthop failed */ 1649c793af95Ssangeeta } ipxmit_state_t; 1650c793af95Ssangeeta 16517c478bd9Sstevel@tonic-gate #define IP_V4_G_HEAD 0 16527c478bd9Sstevel@tonic-gate #define IP_V6_G_HEAD 1 16537c478bd9Sstevel@tonic-gate 16547c478bd9Sstevel@tonic-gate #define MAX_G_HEADS 2 16557c478bd9Sstevel@tonic-gate 16567c478bd9Sstevel@tonic-gate /* 16577c478bd9Sstevel@tonic-gate * unpadded ill_if structure 16587c478bd9Sstevel@tonic-gate */ 16597c478bd9Sstevel@tonic-gate struct _ill_if_s_ { 16607c478bd9Sstevel@tonic-gate union ill_if_u *illif_next; 16617c478bd9Sstevel@tonic-gate union ill_if_u *illif_prev; 16627c478bd9Sstevel@tonic-gate avl_tree_t illif_avl_by_ppa; /* AVL tree sorted on ppa */ 16637c478bd9Sstevel@tonic-gate vmem_t *illif_ppa_arena; /* ppa index space */ 16647c478bd9Sstevel@tonic-gate uint16_t illif_mcast_v1; /* hints for */ 16657c478bd9Sstevel@tonic-gate uint16_t illif_mcast_v2; /* [igmp|mld]_slowtimo */ 16667c478bd9Sstevel@tonic-gate int illif_name_len; /* name length */ 16677c478bd9Sstevel@tonic-gate char illif_name[LIFNAMSIZ]; /* name of interface type */ 16687c478bd9Sstevel@tonic-gate }; 16697c478bd9Sstevel@tonic-gate 16707c478bd9Sstevel@tonic-gate /* cache aligned ill_if structure */ 16717c478bd9Sstevel@tonic-gate typedef union ill_if_u { 16727c478bd9Sstevel@tonic-gate struct _ill_if_s_ ill_if_s; 16737c478bd9Sstevel@tonic-gate char illif_filler[CACHE_ALIGN(_ill_if_s_)]; 16747c478bd9Sstevel@tonic-gate } ill_if_t; 16757c478bd9Sstevel@tonic-gate 16767c478bd9Sstevel@tonic-gate #define illif_next ill_if_s.illif_next 16777c478bd9Sstevel@tonic-gate #define illif_prev ill_if_s.illif_prev 16787c478bd9Sstevel@tonic-gate #define illif_avl_by_ppa ill_if_s.illif_avl_by_ppa 16797c478bd9Sstevel@tonic-gate #define illif_ppa_arena ill_if_s.illif_ppa_arena 16807c478bd9Sstevel@tonic-gate #define illif_mcast_v1 ill_if_s.illif_mcast_v1 16817c478bd9Sstevel@tonic-gate #define illif_mcast_v2 ill_if_s.illif_mcast_v2 16827c478bd9Sstevel@tonic-gate #define illif_name ill_if_s.illif_name 16837c478bd9Sstevel@tonic-gate #define illif_name_len ill_if_s.illif_name_len 16847c478bd9Sstevel@tonic-gate 16857c478bd9Sstevel@tonic-gate typedef struct ill_walk_context_s { 16867c478bd9Sstevel@tonic-gate int ctx_current_list; /* current list being searched */ 16877c478bd9Sstevel@tonic-gate int ctx_last_list; /* last list to search */ 16887c478bd9Sstevel@tonic-gate } ill_walk_context_t; 16897c478bd9Sstevel@tonic-gate 16907c478bd9Sstevel@tonic-gate /* 1691f4b3ec61Sdh155122 * ill_g_heads structure, one for IPV4 and one for IPV6 16927c478bd9Sstevel@tonic-gate */ 16937c478bd9Sstevel@tonic-gate struct _ill_g_head_s_ { 16947c478bd9Sstevel@tonic-gate ill_if_t *ill_g_list_head; 16957c478bd9Sstevel@tonic-gate ill_if_t *ill_g_list_tail; 16967c478bd9Sstevel@tonic-gate }; 16977c478bd9Sstevel@tonic-gate 16987c478bd9Sstevel@tonic-gate typedef union ill_g_head_u { 16997c478bd9Sstevel@tonic-gate struct _ill_g_head_s_ ill_g_head_s; 17007c478bd9Sstevel@tonic-gate char ill_g_head_filler[CACHE_ALIGN(_ill_g_head_s_)]; 17017c478bd9Sstevel@tonic-gate } ill_g_head_t; 17027c478bd9Sstevel@tonic-gate 17037c478bd9Sstevel@tonic-gate #define ill_g_list_head ill_g_head_s.ill_g_list_head 17047c478bd9Sstevel@tonic-gate #define ill_g_list_tail ill_g_head_s.ill_g_list_tail 17057c478bd9Sstevel@tonic-gate 1706f4b3ec61Sdh155122 #define IP_V4_ILL_G_LIST(ipst) \ 1707f4b3ec61Sdh155122 (ipst)->ips_ill_g_heads[IP_V4_G_HEAD].ill_g_list_head 1708f4b3ec61Sdh155122 #define IP_V6_ILL_G_LIST(ipst) \ 1709f4b3ec61Sdh155122 (ipst)->ips_ill_g_heads[IP_V6_G_HEAD].ill_g_list_head 1710f4b3ec61Sdh155122 #define IP_VX_ILL_G_LIST(i, ipst) \ 1711f4b3ec61Sdh155122 (ipst)->ips_ill_g_heads[i].ill_g_list_head 17127c478bd9Sstevel@tonic-gate 1713f4b3ec61Sdh155122 #define ILL_START_WALK_V4(ctx_ptr, ipst) \ 1714f4b3ec61Sdh155122 ill_first(IP_V4_G_HEAD, IP_V4_G_HEAD, ctx_ptr, ipst) 1715f4b3ec61Sdh155122 #define ILL_START_WALK_V6(ctx_ptr, ipst) \ 1716f4b3ec61Sdh155122 ill_first(IP_V6_G_HEAD, IP_V6_G_HEAD, ctx_ptr, ipst) 1717f4b3ec61Sdh155122 #define ILL_START_WALK_ALL(ctx_ptr, ipst) \ 1718f4b3ec61Sdh155122 ill_first(MAX_G_HEADS, MAX_G_HEADS, ctx_ptr, ipst) 17197c478bd9Sstevel@tonic-gate 17207c478bd9Sstevel@tonic-gate /* 17217c478bd9Sstevel@tonic-gate * Capabilities, possible flags for ill_capabilities. 17227c478bd9Sstevel@tonic-gate */ 17237c478bd9Sstevel@tonic-gate 17247c478bd9Sstevel@tonic-gate #define ILL_CAPAB_AH 0x01 /* IPsec AH acceleration */ 17257c478bd9Sstevel@tonic-gate #define ILL_CAPAB_ESP 0x02 /* IPsec ESP acceleration */ 17267c478bd9Sstevel@tonic-gate #define ILL_CAPAB_MDT 0x04 /* Multidata Transmit */ 17277c478bd9Sstevel@tonic-gate #define ILL_CAPAB_HCKSUM 0x08 /* Hardware checksumming */ 17287c478bd9Sstevel@tonic-gate #define ILL_CAPAB_ZEROCOPY 0x10 /* Zero-copy */ 1729da14cebeSEric Cheng #define ILL_CAPAB_DLD 0x20 /* DLD capabilities */ 1730da14cebeSEric Cheng #define ILL_CAPAB_DLD_POLL 0x40 /* Polling */ 1731da14cebeSEric Cheng #define ILL_CAPAB_DLD_DIRECT 0x80 /* Direct function call */ 1732da14cebeSEric Cheng #define ILL_CAPAB_DLD_LSO 0x100 /* Large Segment Offload */ 17337c478bd9Sstevel@tonic-gate 17347c478bd9Sstevel@tonic-gate /* 17357c478bd9Sstevel@tonic-gate * Per-ill Multidata Transmit capabilities. 17367c478bd9Sstevel@tonic-gate */ 17377c478bd9Sstevel@tonic-gate typedef struct ill_mdt_capab_s ill_mdt_capab_t; 17387c478bd9Sstevel@tonic-gate 17397c478bd9Sstevel@tonic-gate /* 17407c478bd9Sstevel@tonic-gate * Per-ill IPsec capabilities. 17417c478bd9Sstevel@tonic-gate */ 17427c478bd9Sstevel@tonic-gate typedef struct ill_ipsec_capab_s ill_ipsec_capab_t; 17437c478bd9Sstevel@tonic-gate 17447c478bd9Sstevel@tonic-gate /* 17457c478bd9Sstevel@tonic-gate * Per-ill Hardware Checksumming capbilities. 17467c478bd9Sstevel@tonic-gate */ 17477c478bd9Sstevel@tonic-gate typedef struct ill_hcksum_capab_s ill_hcksum_capab_t; 17487c478bd9Sstevel@tonic-gate 17497c478bd9Sstevel@tonic-gate /* 17507c478bd9Sstevel@tonic-gate * Per-ill Zero-copy capabilities. 17517c478bd9Sstevel@tonic-gate */ 17527c478bd9Sstevel@tonic-gate typedef struct ill_zerocopy_capab_s ill_zerocopy_capab_t; 17537c478bd9Sstevel@tonic-gate 17547c478bd9Sstevel@tonic-gate /* 1755da14cebeSEric Cheng * DLD capbilities. 17567c478bd9Sstevel@tonic-gate */ 1757da14cebeSEric Cheng typedef struct ill_dld_capab_s ill_dld_capab_t; 17587c478bd9Sstevel@tonic-gate 17597c478bd9Sstevel@tonic-gate /* 17607c478bd9Sstevel@tonic-gate * Per-ill polling resource map. 17617c478bd9Sstevel@tonic-gate */ 17627c478bd9Sstevel@tonic-gate typedef struct ill_rx_ring ill_rx_ring_t; 17637c478bd9Sstevel@tonic-gate 17648347601bSyl150051 /* 17658347601bSyl150051 * Per-ill Large Segment Offload capabilities. 17668347601bSyl150051 */ 17678347601bSyl150051 typedef struct ill_lso_capab_s ill_lso_capab_t; 17688347601bSyl150051 17697c478bd9Sstevel@tonic-gate /* The following are ill_state_flags */ 17707c478bd9Sstevel@tonic-gate #define ILL_LL_SUBNET_PENDING 0x01 /* Waiting for DL_INFO_ACK from drv */ 17717c478bd9Sstevel@tonic-gate #define ILL_CONDEMNED 0x02 /* No more new ref's to the ILL */ 17727c478bd9Sstevel@tonic-gate #define ILL_CHANGING 0x04 /* ILL not globally visible */ 1773a5e428f7Skrgopi #define ILL_DL_UNBIND_IN_PROGRESS 0x08 /* UNBIND_REQ is sent */ 17747c478bd9Sstevel@tonic-gate 17757c478bd9Sstevel@tonic-gate /* Is this an ILL whose source address is used by other ILL's ? */ 17767c478bd9Sstevel@tonic-gate #define IS_USESRC_ILL(ill) \ 17777c478bd9Sstevel@tonic-gate (((ill)->ill_usesrc_ifindex == 0) && \ 17785dddb8baSkcpoon ((ill)->ill_usesrc_grp_next != NULL)) 17797c478bd9Sstevel@tonic-gate 17807c478bd9Sstevel@tonic-gate /* Is this a client/consumer of the usesrc ILL ? */ 17817c478bd9Sstevel@tonic-gate #define IS_USESRC_CLI_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 an virtual network interface (vni) ILL ? */ 17867c478bd9Sstevel@tonic-gate #define IS_VNI(ill) \ 1787c793af95Ssangeeta (((ill) != NULL) && \ 1788c793af95Ssangeeta (((ill)->ill_phyint->phyint_flags & (PHYI_LOOPBACK|PHYI_VIRTUAL)) == \ 17895dddb8baSkcpoon PHYI_VIRTUAL)) 17907c478bd9Sstevel@tonic-gate 179148de1bd2Skcpoon /* Is this a loopback ILL? */ 179248de1bd2Skcpoon #define IS_LOOPBACK(ill) \ 179348de1bd2Skcpoon ((ill)->ill_phyint->phyint_flags & PHYI_LOOPBACK) 179448de1bd2Skcpoon 17957c478bd9Sstevel@tonic-gate /* 17967c478bd9Sstevel@tonic-gate * IP Lower level Structure. 17977c478bd9Sstevel@tonic-gate * Instance data structure in ip_open when there is a device below us. 17987c478bd9Sstevel@tonic-gate */ 17997c478bd9Sstevel@tonic-gate typedef struct ill_s { 18007c478bd9Sstevel@tonic-gate ill_if_t *ill_ifptr; /* pointer to interface type */ 18017c478bd9Sstevel@tonic-gate queue_t *ill_rq; /* Read queue. */ 18027c478bd9Sstevel@tonic-gate queue_t *ill_wq; /* Write queue. */ 18037c478bd9Sstevel@tonic-gate 18047c478bd9Sstevel@tonic-gate int ill_error; /* Error value sent up by device. */ 18057c478bd9Sstevel@tonic-gate 18067c478bd9Sstevel@tonic-gate ipif_t *ill_ipif; /* Interface chain for this ILL. */ 18077c478bd9Sstevel@tonic-gate 18087c478bd9Sstevel@tonic-gate uint_t ill_ipif_up_count; /* Number of IPIFs currently up. */ 18097c478bd9Sstevel@tonic-gate uint_t ill_max_frag; /* Max IDU from DLPI. */ 18107c478bd9Sstevel@tonic-gate char *ill_name; /* Our name. */ 181169bb4bb4Scarlsonj uint_t ill_ipif_dup_count; /* Number of duplicate addresses. */ 18127c478bd9Sstevel@tonic-gate uint_t ill_name_length; /* Name length, incl. terminator. */ 18137c478bd9Sstevel@tonic-gate char *ill_ndd_name; /* Name + ":ip?_forwarding" for NDD. */ 18147c478bd9Sstevel@tonic-gate uint_t ill_net_type; /* IRE_IF_RESOLVER/IRE_IF_NORESOLVER. */ 18157c478bd9Sstevel@tonic-gate /* 18167c478bd9Sstevel@tonic-gate * Physical Point of Attachment num. If DLPI style 1 provider 18177c478bd9Sstevel@tonic-gate * then this is derived from the devname. 18187c478bd9Sstevel@tonic-gate */ 18197c478bd9Sstevel@tonic-gate uint_t ill_ppa; 18207c478bd9Sstevel@tonic-gate t_uscalar_t ill_sap; 18217c478bd9Sstevel@tonic-gate t_scalar_t ill_sap_length; /* Including sign (for position) */ 18227c478bd9Sstevel@tonic-gate uint_t ill_phys_addr_length; /* Excluding the sap. */ 18237c478bd9Sstevel@tonic-gate uint_t ill_bcast_addr_length; /* Only set when the DL provider */ 18247c478bd9Sstevel@tonic-gate /* supports broadcast. */ 18257c478bd9Sstevel@tonic-gate t_uscalar_t ill_mactype; 18267c478bd9Sstevel@tonic-gate uint8_t *ill_frag_ptr; /* Reassembly state. */ 18277c478bd9Sstevel@tonic-gate timeout_id_t ill_frag_timer_id; /* timeout id for the frag timer */ 18287c478bd9Sstevel@tonic-gate ipfb_t *ill_frag_hash_tbl; /* Fragment hash list head. */ 18297c478bd9Sstevel@tonic-gate ipif_t *ill_pending_ipif; /* IPIF waiting for DL operation. */ 18307c478bd9Sstevel@tonic-gate 18317924222fSmeem ilm_t *ill_ilm; /* Multicast membership for ill */ 18327c478bd9Sstevel@tonic-gate uint_t ill_global_timer; /* for IGMPv3/MLDv2 general queries */ 18337c478bd9Sstevel@tonic-gate int ill_mcast_type; /* type of router which is querier */ 18347c478bd9Sstevel@tonic-gate /* on this interface */ 18357c478bd9Sstevel@tonic-gate uint16_t ill_mcast_v1_time; /* # slow timeouts since last v1 qry */ 18367c478bd9Sstevel@tonic-gate uint16_t ill_mcast_v2_time; /* # slow timeouts since last v2 qry */ 18377c478bd9Sstevel@tonic-gate uint8_t ill_mcast_v1_tset; /* 1 => timer is set; 0 => not set */ 18387c478bd9Sstevel@tonic-gate uint8_t ill_mcast_v2_tset; /* 1 => timer is set; 0 => not set */ 18397c478bd9Sstevel@tonic-gate 18407c478bd9Sstevel@tonic-gate uint8_t ill_mcast_rv; /* IGMPv3/MLDv2 robustness variable */ 18417c478bd9Sstevel@tonic-gate int ill_mcast_qi; /* IGMPv3/MLDv2 query interval var */ 18427c478bd9Sstevel@tonic-gate 18437c478bd9Sstevel@tonic-gate mblk_t *ill_pending_mp; /* IOCTL/DLPI awaiting completion. */ 18447c478bd9Sstevel@tonic-gate /* 18457c478bd9Sstevel@tonic-gate * All non-NULL cells between 'ill_first_mp_to_free' and 18467c478bd9Sstevel@tonic-gate * 'ill_last_mp_to_free' are freed in ill_delete. 18477c478bd9Sstevel@tonic-gate */ 18487c478bd9Sstevel@tonic-gate #define ill_first_mp_to_free ill_bcast_mp 18497c478bd9Sstevel@tonic-gate mblk_t *ill_bcast_mp; /* DLPI header for broadcasts. */ 18507c478bd9Sstevel@tonic-gate mblk_t *ill_resolver_mp; /* Resolver template. */ 18517c478bd9Sstevel@tonic-gate mblk_t *ill_unbind_mp; /* unbind mp from ill_dl_up() */ 1852b127ac41SPhilip Kirk mblk_t *ill_promiscoff_mp; /* for ill_leave_allmulti() */ 18537c478bd9Sstevel@tonic-gate mblk_t *ill_dlpi_deferred; /* b_next chain of control messages */ 18547c478bd9Sstevel@tonic-gate mblk_t *ill_phys_addr_mp; /* mblk which holds ill_phys_addr */ 18557c478bd9Sstevel@tonic-gate #define ill_last_mp_to_free ill_phys_addr_mp 18567c478bd9Sstevel@tonic-gate 18577c478bd9Sstevel@tonic-gate cred_t *ill_credp; /* opener's credentials */ 18587c478bd9Sstevel@tonic-gate uint8_t *ill_phys_addr; /* ill_phys_addr_mp->b_rptr + off */ 18597c478bd9Sstevel@tonic-gate 18607c478bd9Sstevel@tonic-gate uint_t ill_state_flags; /* see ILL_* flags above */ 18617c478bd9Sstevel@tonic-gate 18627c478bd9Sstevel@tonic-gate /* Following bit fields protected by ipsq_t */ 18637c478bd9Sstevel@tonic-gate uint_t 18647c478bd9Sstevel@tonic-gate ill_needs_attach : 1, 18657c478bd9Sstevel@tonic-gate ill_reserved : 1, 18667c478bd9Sstevel@tonic-gate ill_isv6 : 1, 18677c478bd9Sstevel@tonic-gate ill_dlpi_style_set : 1, 18687c478bd9Sstevel@tonic-gate 18697c478bd9Sstevel@tonic-gate ill_ifname_pending : 1, 18707c478bd9Sstevel@tonic-gate ill_move_in_progress : 1, /* FAILOVER/FAILBACK in progress */ 18717c478bd9Sstevel@tonic-gate ill_join_allmulti : 1, 18727c478bd9Sstevel@tonic-gate ill_logical_down : 1, 18737c478bd9Sstevel@tonic-gate 18747c478bd9Sstevel@tonic-gate ill_is_6to4tun : 1, /* Interface is a 6to4 tunnel */ 18757c478bd9Sstevel@tonic-gate ill_promisc_on_phys : 1, /* phys interface in promisc mode */ 18767c478bd9Sstevel@tonic-gate ill_dl_up : 1, 18777c478bd9Sstevel@tonic-gate ill_up_ipifs : 1, 18787c478bd9Sstevel@tonic-gate 187969bb4bb4Scarlsonj ill_note_link : 1, /* supports link-up notification */ 18808fb46f24Syz147064 ill_capab_reneg : 1, /* capability renegotiation to be done */ 1881da14cebeSEric Cheng ill_dld_capab_inprog : 1, /* direct dld capab call in prog */ 1882b127ac41SPhilip Kirk ill_need_recover_multicast : 1, 1883da14cebeSEric Cheng 1884da14cebeSEric Cheng ill_pad_to_bit_31 : 16; 18857c478bd9Sstevel@tonic-gate 18867c478bd9Sstevel@tonic-gate /* Following bit fields protected by ill_lock */ 18877c478bd9Sstevel@tonic-gate uint_t 18887c478bd9Sstevel@tonic-gate ill_fragtimer_executing : 1, 18897c478bd9Sstevel@tonic-gate ill_fragtimer_needrestart : 1, 18907c478bd9Sstevel@tonic-gate ill_ilm_cleanup_reqd : 1, 18917c478bd9Sstevel@tonic-gate ill_arp_closing : 1, 18927c478bd9Sstevel@tonic-gate 18937c478bd9Sstevel@tonic-gate ill_arp_bringup_pending : 1, 1894e704a8f2Smeem ill_mtu_userspecified : 1, /* SIOCSLIFLNKINFO has set the mtu */ 189569bb4bb4Scarlsonj ill_arp_extend : 1, /* ARP has DAD extensions */ 1896da14cebeSEric Cheng 189769bb4bb4Scarlsonj ill_pad_bit_31 : 25; 18987c478bd9Sstevel@tonic-gate 18997c478bd9Sstevel@tonic-gate /* 19007c478bd9Sstevel@tonic-gate * Used in SIOCSIFMUXID and SIOCGIFMUXID for 'ifconfig unplumb'. 19017c478bd9Sstevel@tonic-gate */ 19027c478bd9Sstevel@tonic-gate int ill_arp_muxid; /* muxid returned from plink for arp */ 19037c478bd9Sstevel@tonic-gate int ill_ip_muxid; /* muxid returned from plink for ip */ 19047c478bd9Sstevel@tonic-gate 19050a5d959fSgeorges /* Used for IP frag reassembly throttling on a per ILL basis. */ 19067c478bd9Sstevel@tonic-gate uint_t ill_ipf_gen; /* Generation of next fragment queue */ 19070a5d959fSgeorges uint_t ill_frag_count; /* Count of all reassembly mblk bytes */ 19087c478bd9Sstevel@tonic-gate uint_t ill_frag_free_num_pkts; /* num of fragmented packets to free */ 19097c478bd9Sstevel@tonic-gate clock_t ill_last_frag_clean_time; /* time when frag's were pruned */ 19107c478bd9Sstevel@tonic-gate int ill_type; /* From <net/if_types.h> */ 19114d876314Sja97890 uint_t ill_dlpi_multicast_state; /* See below IDS_* */ 19124d876314Sja97890 uint_t ill_dlpi_fastpath_state; /* See below IDS_* */ 19137c478bd9Sstevel@tonic-gate 19147c478bd9Sstevel@tonic-gate /* 19157c478bd9Sstevel@tonic-gate * Capabilities related fields. 19167c478bd9Sstevel@tonic-gate */ 1917da14cebeSEric Cheng uint_t ill_dlpi_capab_state; /* State of capability query, IDCS_* */ 1918da14cebeSEric Cheng uint_t ill_capab_pending_cnt; 19197c478bd9Sstevel@tonic-gate uint64_t ill_capabilities; /* Enabled capabilities, ILL_CAPAB_* */ 19207c478bd9Sstevel@tonic-gate ill_mdt_capab_t *ill_mdt_capab; /* Multidata Transmit capabilities */ 19217c478bd9Sstevel@tonic-gate ill_ipsec_capab_t *ill_ipsec_capab_ah; /* IPsec AH capabilities */ 19227c478bd9Sstevel@tonic-gate ill_ipsec_capab_t *ill_ipsec_capab_esp; /* IPsec ESP capabilities */ 19237c478bd9Sstevel@tonic-gate ill_hcksum_capab_t *ill_hcksum_capab; /* H/W cksumming capabilities */ 19247c478bd9Sstevel@tonic-gate ill_zerocopy_capab_t *ill_zerocopy_capab; /* Zero-copy capabilities */ 1925da14cebeSEric Cheng ill_dld_capab_t *ill_dld_capab; /* DLD capabilities */ 19268347601bSyl150051 ill_lso_capab_t *ill_lso_capab; /* Large Segment Offload capabilities */ 1927da14cebeSEric Cheng mblk_t *ill_capab_reset_mp; /* Preallocated mblk for capab reset */ 19287c478bd9Sstevel@tonic-gate 19297c478bd9Sstevel@tonic-gate /* 19307c478bd9Sstevel@tonic-gate * New fields for IPv6 19317c478bd9Sstevel@tonic-gate */ 19327c478bd9Sstevel@tonic-gate uint8_t ill_max_hops; /* Maximum hops for any logical interface */ 19337c478bd9Sstevel@tonic-gate uint_t ill_max_mtu; /* Maximum MTU for any logical interface */ 19347c478bd9Sstevel@tonic-gate uint32_t ill_reachable_time; /* Value for ND algorithm in msec */ 19357c478bd9Sstevel@tonic-gate uint32_t ill_reachable_retrans_time; /* Value for ND algorithm msec */ 19367c478bd9Sstevel@tonic-gate uint_t ill_max_buf; /* Max # of req to buffer for ND */ 19377c478bd9Sstevel@tonic-gate in6_addr_t ill_token; 19387c478bd9Sstevel@tonic-gate uint_t ill_token_length; 19397c478bd9Sstevel@tonic-gate uint32_t ill_xmit_count; /* ndp max multicast xmits */ 19403173664eSapersson mib2_ipIfStatsEntry_t *ill_ip_mib; /* ver indep. interface mib */ 19417c478bd9Sstevel@tonic-gate mib2_ipv6IfIcmpEntry_t *ill_icmp6_mib; /* Per interface mib */ 19427c478bd9Sstevel@tonic-gate /* 19437c478bd9Sstevel@tonic-gate * Following two mblks are allocated common to all 19447c478bd9Sstevel@tonic-gate * the ipifs when the first interface is coming up. 19457c478bd9Sstevel@tonic-gate * It is sent up to arp when the last ipif is coming 19467c478bd9Sstevel@tonic-gate * down. 19477c478bd9Sstevel@tonic-gate */ 19487c478bd9Sstevel@tonic-gate mblk_t *ill_arp_down_mp; 19497c478bd9Sstevel@tonic-gate mblk_t *ill_arp_del_mapping_mp; 19507c478bd9Sstevel@tonic-gate /* 19517c478bd9Sstevel@tonic-gate * Used for implementing IFF_NOARP. As IFF_NOARP is used 19527c478bd9Sstevel@tonic-gate * to turn off for all the logicals, it is here instead 19537c478bd9Sstevel@tonic-gate * of the ipif. 19547c478bd9Sstevel@tonic-gate */ 19557c478bd9Sstevel@tonic-gate mblk_t *ill_arp_on_mp; 19567c478bd9Sstevel@tonic-gate /* Peer ill of an IPMP move operation */ 19577c478bd9Sstevel@tonic-gate struct ill_s *ill_move_peer; 19587c478bd9Sstevel@tonic-gate 19597c478bd9Sstevel@tonic-gate phyint_t *ill_phyint; 19607c478bd9Sstevel@tonic-gate uint64_t ill_flags; 19617c478bd9Sstevel@tonic-gate ill_group_t *ill_group; 19627c478bd9Sstevel@tonic-gate struct ill_s *ill_group_next; 19637c478bd9Sstevel@tonic-gate 19647c478bd9Sstevel@tonic-gate kmutex_t ill_lock; /* Please see table below */ 19657c478bd9Sstevel@tonic-gate /* 19667c478bd9Sstevel@tonic-gate * The ill_nd_lla* fields handle the link layer address option 19677c478bd9Sstevel@tonic-gate * from neighbor discovery. This is used for external IPv6 19687c478bd9Sstevel@tonic-gate * address resolution. 19697c478bd9Sstevel@tonic-gate */ 19707c478bd9Sstevel@tonic-gate mblk_t *ill_nd_lla_mp; /* mblk which holds ill_nd_lla */ 19717c478bd9Sstevel@tonic-gate uint8_t *ill_nd_lla; /* Link Layer Address */ 19727c478bd9Sstevel@tonic-gate uint_t ill_nd_lla_len; /* Link Layer Address length */ 19737c478bd9Sstevel@tonic-gate /* 19747c478bd9Sstevel@tonic-gate * We now have 3 phys_addr_req's sent down. This field keeps track 19757c478bd9Sstevel@tonic-gate * of which one is pending. 19767c478bd9Sstevel@tonic-gate */ 19777c478bd9Sstevel@tonic-gate t_uscalar_t ill_phys_addr_pend; /* which dl_phys_addr_req pending */ 19787c478bd9Sstevel@tonic-gate /* 19797c478bd9Sstevel@tonic-gate * Used to save errors that occur during plumbing 19807c478bd9Sstevel@tonic-gate */ 19817c478bd9Sstevel@tonic-gate uint_t ill_ifname_pending_err; 19827c478bd9Sstevel@tonic-gate avl_node_t ill_avl_byppa; /* avl node based on ppa */ 19837c478bd9Sstevel@tonic-gate void *ill_fastpath_list; /* both ire and nce hang off this */ 19847c478bd9Sstevel@tonic-gate uint_t ill_refcnt; /* active refcnt by threads */ 1985384ad179Ssowmini uint_t ill_ire_cnt; /* ires associated with this ill */ 19867c478bd9Sstevel@tonic-gate kcondvar_t ill_cv; 19877c478bd9Sstevel@tonic-gate uint_t ill_ilm_walker_cnt; /* snmp ilm walkers */ 1988384ad179Ssowmini uint_t ill_nce_cnt; /* nces associated with this ill */ 19897c478bd9Sstevel@tonic-gate uint_t ill_waiters; /* threads waiting in ipsq_enter */ 19907c478bd9Sstevel@tonic-gate /* 19917c478bd9Sstevel@tonic-gate * Contains the upper read queue pointer of the module immediately 19927c478bd9Sstevel@tonic-gate * beneath IP. This field allows IP to validate sub-capability 19937c478bd9Sstevel@tonic-gate * acknowledgments coming up from downstream. 19947c478bd9Sstevel@tonic-gate */ 19957c478bd9Sstevel@tonic-gate queue_t *ill_lmod_rq; /* read queue pointer of module below */ 19967c478bd9Sstevel@tonic-gate uint_t ill_lmod_cnt; /* number of modules beneath IP */ 19977c478bd9Sstevel@tonic-gate ip_m_t *ill_media; /* media specific params/functions */ 19987c478bd9Sstevel@tonic-gate t_uscalar_t ill_dlpi_pending; /* Last DLPI primitive issued */ 19997c478bd9Sstevel@tonic-gate uint_t ill_usesrc_ifindex; /* use src addr from this ILL */ 20007c478bd9Sstevel@tonic-gate struct ill_s *ill_usesrc_grp_next; /* Next ILL in the usesrc group */ 20017c478bd9Sstevel@tonic-gate boolean_t ill_trace_disable; /* True when alloc fails */ 2002f4b3ec61Sdh155122 zoneid_t ill_zoneid; 2003f4b3ec61Sdh155122 ip_stack_t *ill_ipst; /* Corresponds to a netstack_hold */ 2004e704a8f2Smeem uint32_t ill_dhcpinit; /* IP_DHCPINIT_IFs for ill */ 2005da14cebeSEric Cheng void *ill_flownotify_mh; /* Tx flow ctl, mac cb handle */ 2006384ad179Ssowmini uint_t ill_ilm_cnt; /* ilms referencing this ill */ 2007b127ac41SPhilip Kirk uint_t ill_ipallmulti_cnt; /* ip_join_allmulti() calls */ 20087c478bd9Sstevel@tonic-gate } ill_t; 20097c478bd9Sstevel@tonic-gate 20107c478bd9Sstevel@tonic-gate /* 2011384ad179Ssowmini * ILL_FREE_OK() means that there are no incoming pointer references 2012968d2fd1Ssowmini * to the ill. 2013968d2fd1Ssowmini */ 2014968d2fd1Ssowmini #define ILL_FREE_OK(ill) \ 2015384ad179Ssowmini ((ill)->ill_ire_cnt == 0 && (ill)->ill_ilm_cnt == 0 && \ 2016384ad179Ssowmini (ill)->ill_nce_cnt == 0) 2017968d2fd1Ssowmini 2018968d2fd1Ssowmini /* 2019968d2fd1Ssowmini * An ipif/ill can be marked down only when the ire and nce references 2020968d2fd1Ssowmini * to that ipif/ill goes to zero. ILL_DOWN_OK() is a necessary condition 2021968d2fd1Ssowmini * quiescence checks. See comments above IPIF_DOWN_OK for details 2022968d2fd1Ssowmini * on why ires and nces are selectively considered for this macro. 2023968d2fd1Ssowmini */ 2024384ad179Ssowmini #define ILL_DOWN_OK(ill) (ill->ill_ire_cnt == 0 && ill->ill_nce_cnt == 0) 2025968d2fd1Ssowmini 2026968d2fd1Ssowmini /* 20277c478bd9Sstevel@tonic-gate * The following table lists the protection levels of the various members 20287c478bd9Sstevel@tonic-gate * of the ill_t. Same notation as that used for ipif_t above is used. 20297c478bd9Sstevel@tonic-gate * 20307c478bd9Sstevel@tonic-gate * Write Read 20317c478bd9Sstevel@tonic-gate * 20327c478bd9Sstevel@tonic-gate * ill_ifptr ill_g_lock + s Write once 20337c478bd9Sstevel@tonic-gate * ill_rq ipsq Write once 20347c478bd9Sstevel@tonic-gate * ill_wq ipsq Write once 20357c478bd9Sstevel@tonic-gate * 20367c478bd9Sstevel@tonic-gate * ill_error ipsq None 20377c478bd9Sstevel@tonic-gate * ill_ipif ill_g_lock + ipsq ill_g_lock OR ipsq 20388df01f76Smeem * ill_ipif_up_count ill_lock + ipsq ill_lock OR ipsq 20397c478bd9Sstevel@tonic-gate * ill_max_frag ipsq Write once 20407c478bd9Sstevel@tonic-gate * 20417c478bd9Sstevel@tonic-gate * ill_name ill_g_lock + ipsq Write once 20427c478bd9Sstevel@tonic-gate * ill_name_length ill_g_lock + ipsq Write once 20437c478bd9Sstevel@tonic-gate * ill_ndd_name ipsq Write once 20447c478bd9Sstevel@tonic-gate * ill_net_type ipsq Write once 20457c478bd9Sstevel@tonic-gate * ill_ppa ill_g_lock + ipsq Write once 20467c478bd9Sstevel@tonic-gate * ill_sap ipsq + down ill Write once 20477c478bd9Sstevel@tonic-gate * ill_sap_length ipsq + down ill Write once 20487c478bd9Sstevel@tonic-gate * ill_phys_addr_length ipsq + down ill Write once 20497c478bd9Sstevel@tonic-gate * 20507c478bd9Sstevel@tonic-gate * ill_bcast_addr_length ipsq ipsq 20517c478bd9Sstevel@tonic-gate * ill_mactype ipsq ipsq 20527c478bd9Sstevel@tonic-gate * ill_frag_ptr ipsq ipsq 20537c478bd9Sstevel@tonic-gate * 20547c478bd9Sstevel@tonic-gate * ill_frag_timer_id ill_lock ill_lock 20557c478bd9Sstevel@tonic-gate * ill_frag_hash_tbl ipsq up ill 20567c478bd9Sstevel@tonic-gate * ill_ilm ipsq + ill_lock ill_lock 20577c478bd9Sstevel@tonic-gate * ill_mcast_type ill_lock ill_lock 20587c478bd9Sstevel@tonic-gate * ill_mcast_v1_time ill_lock ill_lock 20597c478bd9Sstevel@tonic-gate * ill_mcast_v2_time ill_lock ill_lock 20607c478bd9Sstevel@tonic-gate * ill_mcast_v1_tset ill_lock ill_lock 20617c478bd9Sstevel@tonic-gate * ill_mcast_v2_tset ill_lock ill_lock 20627c478bd9Sstevel@tonic-gate * ill_mcast_rv ill_lock ill_lock 20637c478bd9Sstevel@tonic-gate * ill_mcast_qi ill_lock ill_lock 20647c478bd9Sstevel@tonic-gate * ill_pending_mp ill_lock ill_lock 20657c478bd9Sstevel@tonic-gate * 20667c478bd9Sstevel@tonic-gate * ill_bcast_mp ipsq ipsq 20677c478bd9Sstevel@tonic-gate * ill_resolver_mp ipsq only when ill is up 20687c478bd9Sstevel@tonic-gate * ill_down_mp ipsq ipsq 20698df01f76Smeem * ill_dlpi_deferred ill_lock ill_lock 20708df01f76Smeem * ill_dlpi_pending ill_lock ill_lock 2071b051ecf6Smeem * ill_phys_addr_mp ipsq + down ill only when ill is up 2072b051ecf6Smeem * ill_phys_addr ipsq + down ill only when ill is up 20737c478bd9Sstevel@tonic-gate * 20747c478bd9Sstevel@tonic-gate * ill_state_flags ill_lock ill_lock 20757c478bd9Sstevel@tonic-gate * exclusive bit flags ipsq_t ipsq_t 20767c478bd9Sstevel@tonic-gate * shared bit flags ill_lock ill_lock 20777c478bd9Sstevel@tonic-gate * 20787c478bd9Sstevel@tonic-gate * ill_arp_muxid ipsq Not atomic 20797c478bd9Sstevel@tonic-gate * ill_ip_muxid ipsq Not atomic 20807c478bd9Sstevel@tonic-gate * 20817c478bd9Sstevel@tonic-gate * ill_ipf_gen Not atomic 20820a5d959fSgeorges * ill_frag_count atomics atomics 20837c478bd9Sstevel@tonic-gate * ill_type ipsq + down ill only when ill is up 20847c478bd9Sstevel@tonic-gate * ill_dlpi_multicast_state ill_lock ill_lock 20857c478bd9Sstevel@tonic-gate * ill_dlpi_fastpath_state ill_lock ill_lock 2086da14cebeSEric Cheng * ill_dlpi_capab_state ipsq ipsq 20877c478bd9Sstevel@tonic-gate * ill_max_hops ipsq Not atomic 20887c478bd9Sstevel@tonic-gate * 20897c478bd9Sstevel@tonic-gate * ill_max_mtu 20907c478bd9Sstevel@tonic-gate * 20917c478bd9Sstevel@tonic-gate * ill_reachable_time ipsq + ill_lock ill_lock 20927c478bd9Sstevel@tonic-gate * ill_reachable_retrans_time ipsq + ill_lock ill_lock 20937c478bd9Sstevel@tonic-gate * ill_max_buf ipsq + ill_lock ill_lock 20947c478bd9Sstevel@tonic-gate * 20957c478bd9Sstevel@tonic-gate * Next 2 fields need ill_lock because of the get ioctls. They should not 20967c478bd9Sstevel@tonic-gate * report partially updated results without executing in the ipsq. 20977c478bd9Sstevel@tonic-gate * ill_token ipsq + ill_lock ill_lock 20987c478bd9Sstevel@tonic-gate * ill_token_length ipsq + ill_lock ill_lock 20997c478bd9Sstevel@tonic-gate * ill_xmit_count ipsq + down ill write once 21007c478bd9Sstevel@tonic-gate * ill_ip6_mib ipsq + down ill only when ill is up 21017c478bd9Sstevel@tonic-gate * ill_icmp6_mib ipsq + down ill only when ill is up 21027c478bd9Sstevel@tonic-gate * ill_arp_down_mp ipsq ipsq 21037c478bd9Sstevel@tonic-gate * ill_arp_del_mapping_mp ipsq ipsq 21047c478bd9Sstevel@tonic-gate * ill_arp_on_mp ipsq ipsq 21057c478bd9Sstevel@tonic-gate * ill_move_peer ipsq ipsq 21067c478bd9Sstevel@tonic-gate * 21077c478bd9Sstevel@tonic-gate * ill_phyint ipsq, ill_g_lock, ill_lock Any of them 21087c478bd9Sstevel@tonic-gate * ill_flags ill_lock ill_lock 21097c478bd9Sstevel@tonic-gate * ill_group ipsq, ill_g_lock, ill_lock Any of them 21107c478bd9Sstevel@tonic-gate * ill_group_next ipsq, ill_g_lock, ill_lock Any of them 2111b051ecf6Smeem * ill_nd_lla_mp ipsq + down ill only when ill is up 2112b051ecf6Smeem * ill_nd_lla ipsq + down ill only when ill is up 2113b051ecf6Smeem * ill_nd_lla_len ipsq + down ill only when ill is up 21147c478bd9Sstevel@tonic-gate * ill_phys_addr_pend ipsq + down ill only when ill is up 21157c478bd9Sstevel@tonic-gate * ill_ifname_pending_err ipsq ipsq 2116b051ecf6Smeem * ill_avl_byppa ipsq, ill_g_lock write once 21177c478bd9Sstevel@tonic-gate * 21187c478bd9Sstevel@tonic-gate * ill_fastpath_list ill_lock ill_lock 21197c478bd9Sstevel@tonic-gate * ill_refcnt ill_lock ill_lock 2120384ad179Ssowmini * ill_ire_cnt ill_lock ill_lock 21217c478bd9Sstevel@tonic-gate * ill_cv ill_lock ill_lock 21227c478bd9Sstevel@tonic-gate * ill_ilm_walker_cnt ill_lock ill_lock 2123384ad179Ssowmini * ill_nce_cnt ill_lock ill_lock 2124384ad179Ssowmini * ill_ilm_cnt ill_lock ill_lock 21257c478bd9Sstevel@tonic-gate * ill_trace ill_lock ill_lock 21267c478bd9Sstevel@tonic-gate * ill_usesrc_grp_next ill_g_usesrc_lock ill_g_usesrc_lock 2127e704a8f2Smeem * ill_dhcpinit atomics atomics 2128da14cebeSEric Cheng * ill_flownotify_mh write once write once 2129da14cebeSEric Cheng * ill_capab_pending_cnt ipsq ipsq 21307c478bd9Sstevel@tonic-gate */ 21317c478bd9Sstevel@tonic-gate 21327c478bd9Sstevel@tonic-gate /* 21337c478bd9Sstevel@tonic-gate * For ioctl restart mechanism see ip_reprocess_ioctl() 21347c478bd9Sstevel@tonic-gate */ 21357c478bd9Sstevel@tonic-gate struct ip_ioctl_cmd_s; 21367c478bd9Sstevel@tonic-gate 21377c478bd9Sstevel@tonic-gate typedef int (*ifunc_t)(ipif_t *, struct sockaddr_in *, queue_t *, mblk_t *, 21387c478bd9Sstevel@tonic-gate struct ip_ioctl_cmd_s *, void *); 21397c478bd9Sstevel@tonic-gate 21407c478bd9Sstevel@tonic-gate typedef struct ip_ioctl_cmd_s { 21417c478bd9Sstevel@tonic-gate int ipi_cmd; 21427c478bd9Sstevel@tonic-gate size_t ipi_copyin_size; 21437c478bd9Sstevel@tonic-gate uint_t ipi_flags; 21447c478bd9Sstevel@tonic-gate uint_t ipi_cmd_type; 21457c478bd9Sstevel@tonic-gate ifunc_t ipi_func; 21467c478bd9Sstevel@tonic-gate ifunc_t ipi_func_restart; 21477c478bd9Sstevel@tonic-gate } ip_ioctl_cmd_t; 21487c478bd9Sstevel@tonic-gate 21497c478bd9Sstevel@tonic-gate /* 21507c478bd9Sstevel@tonic-gate * ipi_cmd_type: 21517c478bd9Sstevel@tonic-gate * 21527c478bd9Sstevel@tonic-gate * IF_CMD 1 old style ifreq cmd 21537c478bd9Sstevel@tonic-gate * LIF_CMD 2 new style lifreq cmd 215498e93c29Smeem * TUN_CMD 3 tunnel related 215598e93c29Smeem * ARP_CMD 4 arpreq cmd 215698e93c29Smeem * XARP_CMD 5 xarpreq cmd 215798e93c29Smeem * MSFILT_CMD 6 multicast source filter cmd 215898e93c29Smeem * MISC_CMD 7 misc cmd (not a more specific one above) 21597c478bd9Sstevel@tonic-gate */ 21607c478bd9Sstevel@tonic-gate 216198e93c29Smeem enum { IF_CMD = 1, LIF_CMD, TUN_CMD, ARP_CMD, XARP_CMD, MSFILT_CMD, MISC_CMD }; 21627c478bd9Sstevel@tonic-gate 21637c478bd9Sstevel@tonic-gate #define IPI_DONTCARE 0 /* For ioctl encoded values that don't matter */ 21647c478bd9Sstevel@tonic-gate 21657c478bd9Sstevel@tonic-gate /* Flag values in ipi_flags */ 21667c478bd9Sstevel@tonic-gate #define IPI_PRIV 0x1 /* Root only command */ 21677c478bd9Sstevel@tonic-gate #define IPI_MODOK 0x2 /* Permitted on mod instance of IP */ 21687c478bd9Sstevel@tonic-gate #define IPI_WR 0x4 /* Need to grab writer access */ 21697c478bd9Sstevel@tonic-gate #define IPI_GET_CMD 0x8 /* branch to mi_copyout on success */ 21707c478bd9Sstevel@tonic-gate #define IPI_REPL 0x10 /* valid for replacement ipif created in MOVE */ 21717c478bd9Sstevel@tonic-gate #define IPI_NULL_BCONT 0x20 /* ioctl has not data and hence no b_cont */ 21727c478bd9Sstevel@tonic-gate #define IPI_PASS_DOWN 0x40 /* pass this ioctl down when a module only */ 21737c478bd9Sstevel@tonic-gate 21747c478bd9Sstevel@tonic-gate extern ip_ioctl_cmd_t ip_ndx_ioctl_table[]; 21757c478bd9Sstevel@tonic-gate extern ip_ioctl_cmd_t ip_misc_ioctl_table[]; 21767c478bd9Sstevel@tonic-gate extern int ip_ndx_ioctl_count; 21777c478bd9Sstevel@tonic-gate extern int ip_misc_ioctl_count; 21787c478bd9Sstevel@tonic-gate 21797c478bd9Sstevel@tonic-gate #define ILL_CLEAR_MOVE(ill) { \ 21807c478bd9Sstevel@tonic-gate ill_t *peer_ill; \ 21817c478bd9Sstevel@tonic-gate \ 21827c478bd9Sstevel@tonic-gate peer_ill = (ill)->ill_move_peer; \ 21837c478bd9Sstevel@tonic-gate ASSERT(peer_ill != NULL); \ 21847c478bd9Sstevel@tonic-gate (ill)->ill_move_in_progress = B_FALSE; \ 21857c478bd9Sstevel@tonic-gate peer_ill->ill_move_in_progress = B_FALSE; \ 21867c478bd9Sstevel@tonic-gate (ill)->ill_move_peer = NULL; \ 21877c478bd9Sstevel@tonic-gate peer_ill->ill_move_peer = NULL; \ 21887c478bd9Sstevel@tonic-gate } 21897c478bd9Sstevel@tonic-gate 21907c478bd9Sstevel@tonic-gate /* Passed down by ARP to IP during I_PLINK/I_PUNLINK */ 21917c478bd9Sstevel@tonic-gate typedef struct ipmx_s { 21927c478bd9Sstevel@tonic-gate char ipmx_name[LIFNAMSIZ]; /* if name */ 21937c478bd9Sstevel@tonic-gate uint_t 21947c478bd9Sstevel@tonic-gate ipmx_arpdev_stream : 1, /* This is the arp stream */ 21957c478bd9Sstevel@tonic-gate ipmx_notused : 31; 21967c478bd9Sstevel@tonic-gate } ipmx_t; 21977c478bd9Sstevel@tonic-gate 21987c478bd9Sstevel@tonic-gate /* 21997c478bd9Sstevel@tonic-gate * State for detecting if a driver supports certain features. 22007c478bd9Sstevel@tonic-gate * Support for DL_ENABMULTI_REQ uses ill_dlpi_multicast_state. 22017c478bd9Sstevel@tonic-gate * Support for DLPI M_DATA fastpath uses ill_dlpi_fastpath_state. 22027c478bd9Sstevel@tonic-gate */ 22034d876314Sja97890 #define IDS_UNKNOWN 0 /* No DLPI request sent */ 22044d876314Sja97890 #define IDS_INPROGRESS 1 /* DLPI request sent */ 22054d876314Sja97890 #define IDS_OK 2 /* DLPI request completed successfully */ 22064d876314Sja97890 #define IDS_FAILED 3 /* DLPI request failed */ 22077c478bd9Sstevel@tonic-gate 2208da14cebeSEric Cheng /* Support for DL_CAPABILITY_REQ uses ill_dlpi_capab_state. */ 2209da14cebeSEric Cheng enum { 2210da14cebeSEric Cheng IDCS_UNKNOWN, 2211da14cebeSEric Cheng IDCS_PROBE_SENT, 2212da14cebeSEric Cheng IDCS_OK, 2213da14cebeSEric Cheng IDCS_RESET_SENT, 2214da14cebeSEric Cheng IDCS_RENEG, 2215da14cebeSEric Cheng IDCS_FAILED 2216da14cebeSEric Cheng }; 2217da14cebeSEric Cheng 22187c478bd9Sstevel@tonic-gate /* Named Dispatch Parameter Management Structure */ 22197c478bd9Sstevel@tonic-gate typedef struct ipparam_s { 22207c478bd9Sstevel@tonic-gate uint_t ip_param_min; 22217c478bd9Sstevel@tonic-gate uint_t ip_param_max; 22227c478bd9Sstevel@tonic-gate uint_t ip_param_value; 22237c478bd9Sstevel@tonic-gate char *ip_param_name; 22247c478bd9Sstevel@tonic-gate } ipparam_t; 22257c478bd9Sstevel@tonic-gate 22267c478bd9Sstevel@tonic-gate /* Extended NDP Management Structure */ 22277c478bd9Sstevel@tonic-gate typedef struct ipndp_s { 22287c478bd9Sstevel@tonic-gate ndgetf_t ip_ndp_getf; 22297c478bd9Sstevel@tonic-gate ndsetf_t ip_ndp_setf; 22307c478bd9Sstevel@tonic-gate caddr_t ip_ndp_data; 22317c478bd9Sstevel@tonic-gate char *ip_ndp_name; 22327c478bd9Sstevel@tonic-gate } ipndp_t; 22337c478bd9Sstevel@tonic-gate 22347c478bd9Sstevel@tonic-gate /* 223545916cd2Sjpk * The kernel stores security attributes of all gateways in a database made 223645916cd2Sjpk * up of one or more tsol_gcdb_t elements. Each tsol_gcdb_t contains the 223745916cd2Sjpk * security-related credentials of the gateway. More than one gateways may 223845916cd2Sjpk * share entries in the database. 223945916cd2Sjpk * 224045916cd2Sjpk * The tsol_gc_t structure represents the gateway to credential association, 224145916cd2Sjpk * and refers to an entry in the database. One or more tsol_gc_t entities are 224245916cd2Sjpk * grouped together to form one or more tsol_gcgrp_t, each representing the 224345916cd2Sjpk * list of security attributes specific to the gateway. A gateway may be 224445916cd2Sjpk * associated with at most one credentials group. 224545916cd2Sjpk */ 224645916cd2Sjpk struct tsol_gcgrp_s; 224745916cd2Sjpk 224845916cd2Sjpk extern uchar_t ip6opt_ls; /* TX IPv6 enabler */ 224945916cd2Sjpk 225045916cd2Sjpk /* 225145916cd2Sjpk * Gateway security credential record. 225245916cd2Sjpk */ 225345916cd2Sjpk typedef struct tsol_gcdb_s { 225445916cd2Sjpk uint_t gcdb_refcnt; /* reference count */ 225545916cd2Sjpk struct rtsa_s gcdb_attr; /* security attributes */ 225645916cd2Sjpk #define gcdb_mask gcdb_attr.rtsa_mask 225745916cd2Sjpk #define gcdb_doi gcdb_attr.rtsa_doi 225845916cd2Sjpk #define gcdb_slrange gcdb_attr.rtsa_slrange 225945916cd2Sjpk } tsol_gcdb_t; 226045916cd2Sjpk 226145916cd2Sjpk /* 226245916cd2Sjpk * Gateway to credential association. 226345916cd2Sjpk */ 226445916cd2Sjpk typedef struct tsol_gc_s { 226545916cd2Sjpk uint_t gc_refcnt; /* reference count */ 226645916cd2Sjpk struct tsol_gcgrp_s *gc_grp; /* pointer to group */ 226745916cd2Sjpk struct tsol_gc_s *gc_prev; /* previous in list */ 226845916cd2Sjpk struct tsol_gc_s *gc_next; /* next in list */ 226945916cd2Sjpk tsol_gcdb_t *gc_db; /* pointer to actual credentials */ 227045916cd2Sjpk } tsol_gc_t; 227145916cd2Sjpk 227245916cd2Sjpk /* 227345916cd2Sjpk * Gateway credentials group address. 227445916cd2Sjpk */ 227545916cd2Sjpk typedef struct tsol_gcgrp_addr_s { 227645916cd2Sjpk int ga_af; /* address family */ 227745916cd2Sjpk in6_addr_t ga_addr; /* IPv4 mapped or IPv6 address */ 227845916cd2Sjpk } tsol_gcgrp_addr_t; 227945916cd2Sjpk 228045916cd2Sjpk /* 228145916cd2Sjpk * Gateway credentials group. 228245916cd2Sjpk */ 228345916cd2Sjpk typedef struct tsol_gcgrp_s { 228445916cd2Sjpk uint_t gcgrp_refcnt; /* reference count */ 228545916cd2Sjpk krwlock_t gcgrp_rwlock; /* lock to protect following */ 228645916cd2Sjpk uint_t gcgrp_count; /* number of credentials */ 228745916cd2Sjpk tsol_gc_t *gcgrp_head; /* first credential in list */ 228845916cd2Sjpk tsol_gc_t *gcgrp_tail; /* last credential in list */ 228945916cd2Sjpk tsol_gcgrp_addr_t gcgrp_addr; /* next-hop gateway address */ 229045916cd2Sjpk } tsol_gcgrp_t; 229145916cd2Sjpk 229245916cd2Sjpk extern kmutex_t gcgrp_lock; 229345916cd2Sjpk 229445916cd2Sjpk #define GC_REFRELE(p) { \ 229545916cd2Sjpk ASSERT((p)->gc_grp != NULL); \ 229645916cd2Sjpk rw_enter(&(p)->gc_grp->gcgrp_rwlock, RW_WRITER); \ 229745916cd2Sjpk ASSERT((p)->gc_refcnt > 0); \ 229845916cd2Sjpk if (--((p)->gc_refcnt) == 0) \ 229945916cd2Sjpk gc_inactive(p); \ 230045916cd2Sjpk else \ 230145916cd2Sjpk rw_exit(&(p)->gc_grp->gcgrp_rwlock); \ 230245916cd2Sjpk } 230345916cd2Sjpk 230445916cd2Sjpk #define GCGRP_REFHOLD(p) { \ 230545916cd2Sjpk mutex_enter(&gcgrp_lock); \ 230645916cd2Sjpk ++((p)->gcgrp_refcnt); \ 230745916cd2Sjpk ASSERT((p)->gcgrp_refcnt != 0); \ 230845916cd2Sjpk mutex_exit(&gcgrp_lock); \ 230945916cd2Sjpk } 231045916cd2Sjpk 231145916cd2Sjpk #define GCGRP_REFRELE(p) { \ 231245916cd2Sjpk mutex_enter(&gcgrp_lock); \ 231345916cd2Sjpk ASSERT((p)->gcgrp_refcnt > 0); \ 231445916cd2Sjpk if (--((p)->gcgrp_refcnt) == 0) \ 231545916cd2Sjpk gcgrp_inactive(p); \ 231645916cd2Sjpk ASSERT(MUTEX_HELD(&gcgrp_lock)); \ 231745916cd2Sjpk mutex_exit(&gcgrp_lock); \ 231845916cd2Sjpk } 231945916cd2Sjpk 232045916cd2Sjpk /* 232145916cd2Sjpk * IRE gateway security attributes structure, pointed to by tsol_ire_gw_secattr 232245916cd2Sjpk */ 232345916cd2Sjpk struct tsol_tnrhc; 232445916cd2Sjpk 232545916cd2Sjpk typedef struct tsol_ire_gw_secattr_s { 232645916cd2Sjpk kmutex_t igsa_lock; /* lock to protect following */ 232745916cd2Sjpk struct tsol_tnrhc *igsa_rhc; /* host entry for gateway */ 232845916cd2Sjpk tsol_gc_t *igsa_gc; /* for prefix IREs */ 232945916cd2Sjpk tsol_gcgrp_t *igsa_gcgrp; /* for cache IREs */ 233045916cd2Sjpk } tsol_ire_gw_secattr_t; 233145916cd2Sjpk 233245916cd2Sjpk /* 23337c478bd9Sstevel@tonic-gate * Following are the macros to increment/decrement the reference 23347c478bd9Sstevel@tonic-gate * count of the IREs and IRBs (ire bucket). 23357c478bd9Sstevel@tonic-gate * 23367c478bd9Sstevel@tonic-gate * 1) We bump up the reference count of an IRE to make sure that 23377c478bd9Sstevel@tonic-gate * it does not get deleted and freed while we are using it. 23387c478bd9Sstevel@tonic-gate * Typically all the lookup functions hold the bucket lock, 23397c478bd9Sstevel@tonic-gate * and look for the IRE. If it finds an IRE, it bumps up the 23407c478bd9Sstevel@tonic-gate * reference count before dropping the lock. Sometimes we *may* want 23417c478bd9Sstevel@tonic-gate * to bump up the reference count after we *looked* up i.e without 23427c478bd9Sstevel@tonic-gate * holding the bucket lock. So, the IRE_REFHOLD macro does not assert 23437c478bd9Sstevel@tonic-gate * on the bucket lock being held. Any thread trying to delete from 23447c478bd9Sstevel@tonic-gate * the hash bucket can still do so but cannot free the IRE if 23457c478bd9Sstevel@tonic-gate * ire_refcnt is not 0. 23467c478bd9Sstevel@tonic-gate * 23477c478bd9Sstevel@tonic-gate * 2) We bump up the reference count on the bucket where the IRE resides 23487c478bd9Sstevel@tonic-gate * (IRB), when we want to prevent the IREs getting deleted from a given 23497c478bd9Sstevel@tonic-gate * hash bucket. This makes life easier for ire_walk type functions which 23507c478bd9Sstevel@tonic-gate * wants to walk the IRE list, call a function, but needs to drop 23517c478bd9Sstevel@tonic-gate * the bucket lock to prevent recursive rw_enters. While the 23527c478bd9Sstevel@tonic-gate * lock is dropped, the list could be changed by other threads or 23537c478bd9Sstevel@tonic-gate * the same thread could end up deleting the ire or the ire pointed by 23547c478bd9Sstevel@tonic-gate * ire_next. IRE_REFHOLDing the ire or ire_next is not sufficient as 23557c478bd9Sstevel@tonic-gate * a delete will still remove the ire from the bucket while we have 23567c478bd9Sstevel@tonic-gate * dropped the lock and hence the ire_next would be NULL. Thus, we 23577c478bd9Sstevel@tonic-gate * need a mechanism to prevent deletions from a given bucket. 23587c478bd9Sstevel@tonic-gate * 23597c478bd9Sstevel@tonic-gate * To prevent deletions, we bump up the reference count on the 23607c478bd9Sstevel@tonic-gate * bucket. If the bucket is held, ire_delete just marks IRE_MARK_CONDEMNED 23617c478bd9Sstevel@tonic-gate * both on the ire's ire_marks and the bucket's irb_marks. When the 23627c478bd9Sstevel@tonic-gate * reference count on the bucket drops to zero, all the CONDEMNED ires 23637c478bd9Sstevel@tonic-gate * are deleted. We don't have to bump up the reference count on the 23647c478bd9Sstevel@tonic-gate * bucket if we are walking the bucket and never have to drop the bucket 23657c478bd9Sstevel@tonic-gate * lock. Note that IRB_REFHOLD does not prevent addition of new ires 23667c478bd9Sstevel@tonic-gate * in the list. It is okay because addition of new ires will not cause 23677c478bd9Sstevel@tonic-gate * ire_next to point to freed memory. We do IRB_REFHOLD only when 23687c478bd9Sstevel@tonic-gate * all of the 3 conditions are true : 23697c478bd9Sstevel@tonic-gate * 23707c478bd9Sstevel@tonic-gate * 1) The code needs to walk the IRE bucket from start to end. 23717c478bd9Sstevel@tonic-gate * 2) It may have to drop the bucket lock sometimes while doing (1) 23727c478bd9Sstevel@tonic-gate * 3) It does not want any ires to be deleted meanwhile. 23737c478bd9Sstevel@tonic-gate */ 23747c478bd9Sstevel@tonic-gate 23757c478bd9Sstevel@tonic-gate /* 23767c478bd9Sstevel@tonic-gate * Bump up the reference count on the IRE. We cannot assert that the 23777c478bd9Sstevel@tonic-gate * bucket lock is being held as it is legal to bump up the reference 23787c478bd9Sstevel@tonic-gate * count after the first lookup has returned the IRE without 23797c478bd9Sstevel@tonic-gate * holding the lock. Currently ip_wput does this for caching IRE_CACHEs. 23807c478bd9Sstevel@tonic-gate */ 23817c478bd9Sstevel@tonic-gate 23826a8288c7Scarlsonj #ifdef DEBUG 23836a8288c7Scarlsonj #define IRE_UNTRACE_REF(ire) ire_untrace_ref(ire); 23846a8288c7Scarlsonj #define IRE_TRACE_REF(ire) ire_trace_ref(ire); 23856a8288c7Scarlsonj #else 23867c478bd9Sstevel@tonic-gate #define IRE_UNTRACE_REF(ire) 23877c478bd9Sstevel@tonic-gate #define IRE_TRACE_REF(ire) 23886a8288c7Scarlsonj #endif 23897c478bd9Sstevel@tonic-gate 23907c478bd9Sstevel@tonic-gate #define IRE_REFHOLD_NOTR(ire) { \ 23917c478bd9Sstevel@tonic-gate atomic_add_32(&(ire)->ire_refcnt, 1); \ 23927c478bd9Sstevel@tonic-gate ASSERT((ire)->ire_refcnt != 0); \ 23937c478bd9Sstevel@tonic-gate } 23947c478bd9Sstevel@tonic-gate 23957c478bd9Sstevel@tonic-gate #define IRE_REFHOLD(ire) { \ 23966a8288c7Scarlsonj IRE_REFHOLD_NOTR(ire); \ 23977c478bd9Sstevel@tonic-gate IRE_TRACE_REF(ire); \ 23987c478bd9Sstevel@tonic-gate } 23997c478bd9Sstevel@tonic-gate 24007c478bd9Sstevel@tonic-gate #define IRE_REFHOLD_LOCKED(ire) { \ 24017c478bd9Sstevel@tonic-gate IRE_TRACE_REF(ire); \ 24027c478bd9Sstevel@tonic-gate (ire)->ire_refcnt++; \ 24037c478bd9Sstevel@tonic-gate } 24047c478bd9Sstevel@tonic-gate 24057c478bd9Sstevel@tonic-gate /* 24067c478bd9Sstevel@tonic-gate * Decrement the reference count on the IRE. 24077c478bd9Sstevel@tonic-gate * In architectures e.g sun4u, where atomic_add_32_nv is just 24087c478bd9Sstevel@tonic-gate * a cas, we need to maintain the right memory barrier semantics 24097c478bd9Sstevel@tonic-gate * as that of mutex_exit i.e all the loads and stores should complete 24107c478bd9Sstevel@tonic-gate * before the cas is executed. membar_exit() does that here. 24117c478bd9Sstevel@tonic-gate * 24127c478bd9Sstevel@tonic-gate * NOTE : This macro is used only in places where we want performance. 24137c478bd9Sstevel@tonic-gate * To avoid bloating the code, we use the function "ire_refrele" 24147c478bd9Sstevel@tonic-gate * which essentially calls the macro. 24157c478bd9Sstevel@tonic-gate */ 24167c478bd9Sstevel@tonic-gate #define IRE_REFRELE_NOTR(ire) { \ 24177c478bd9Sstevel@tonic-gate ASSERT((ire)->ire_refcnt != 0); \ 24187c478bd9Sstevel@tonic-gate membar_exit(); \ 24197c478bd9Sstevel@tonic-gate if (atomic_add_32_nv(&(ire)->ire_refcnt, -1) == 0) \ 24207c478bd9Sstevel@tonic-gate ire_inactive(ire); \ 24217c478bd9Sstevel@tonic-gate } 24226a8288c7Scarlsonj 24236a8288c7Scarlsonj #define IRE_REFRELE(ire) { \ 24246a8288c7Scarlsonj if (ire->ire_bucket != NULL) { \ 24256a8288c7Scarlsonj IRE_UNTRACE_REF(ire); \ 24266a8288c7Scarlsonj } \ 24276a8288c7Scarlsonj IRE_REFRELE_NOTR(ire); \ 24286a8288c7Scarlsonj } 24297c478bd9Sstevel@tonic-gate 24307c478bd9Sstevel@tonic-gate /* 24317c478bd9Sstevel@tonic-gate * Bump up the reference count on the hash bucket - IRB to 24327c478bd9Sstevel@tonic-gate * prevent ires from being deleted in this bucket. 24337c478bd9Sstevel@tonic-gate */ 24347c478bd9Sstevel@tonic-gate #define IRB_REFHOLD(irb) { \ 24357c478bd9Sstevel@tonic-gate rw_enter(&(irb)->irb_lock, RW_WRITER); \ 24367c478bd9Sstevel@tonic-gate (irb)->irb_refcnt++; \ 24377c478bd9Sstevel@tonic-gate ASSERT((irb)->irb_refcnt != 0); \ 24387c478bd9Sstevel@tonic-gate rw_exit(&(irb)->irb_lock); \ 24397c478bd9Sstevel@tonic-gate } 2440c793af95Ssangeeta #define IRB_REFHOLD_LOCKED(irb) { \ 2441c793af95Ssangeeta ASSERT(RW_WRITE_HELD(&(irb)->irb_lock)); \ 2442c793af95Ssangeeta (irb)->irb_refcnt++; \ 2443c793af95Ssangeeta ASSERT((irb)->irb_refcnt != 0); \ 2444c793af95Ssangeeta } 24457c478bd9Sstevel@tonic-gate 2446c793af95Ssangeeta void irb_refrele_ftable(irb_t *); 2447c793af95Ssangeeta /* 2448c793af95Ssangeeta * Note: when IRB_MARK_FTABLE (i.e., IRE_CACHETABLE entry), the irb_t 2449c793af95Ssangeeta * is statically allocated, so that when the irb_refcnt goes to 0, 2450c793af95Ssangeeta * we simply clean up the ire list and continue. 2451c793af95Ssangeeta */ 24527c478bd9Sstevel@tonic-gate #define IRB_REFRELE(irb) { \ 2453c793af95Ssangeeta if ((irb)->irb_marks & IRB_MARK_FTABLE) { \ 2454c793af95Ssangeeta irb_refrele_ftable((irb)); \ 2455c793af95Ssangeeta } else { \ 24567c478bd9Sstevel@tonic-gate rw_enter(&(irb)->irb_lock, RW_WRITER); \ 24577c478bd9Sstevel@tonic-gate ASSERT((irb)->irb_refcnt != 0); \ 24587c478bd9Sstevel@tonic-gate if (--(irb)->irb_refcnt == 0 && \ 24597c478bd9Sstevel@tonic-gate ((irb)->irb_marks & IRE_MARK_CONDEMNED)) { \ 24607c478bd9Sstevel@tonic-gate ire_t *ire_list; \ 24617c478bd9Sstevel@tonic-gate \ 24627c478bd9Sstevel@tonic-gate ire_list = ire_unlink(irb); \ 24637c478bd9Sstevel@tonic-gate rw_exit(&(irb)->irb_lock); \ 24647c478bd9Sstevel@tonic-gate ASSERT(ire_list != NULL); \ 24657c478bd9Sstevel@tonic-gate ire_cleanup(ire_list); \ 24667c478bd9Sstevel@tonic-gate } else { \ 24677c478bd9Sstevel@tonic-gate rw_exit(&(irb)->irb_lock); \ 24687c478bd9Sstevel@tonic-gate } \ 2469c793af95Ssangeeta } \ 24707c478bd9Sstevel@tonic-gate } 24717c478bd9Sstevel@tonic-gate 2472c793af95Ssangeeta extern struct kmem_cache *rt_entry_cache; 2473c793af95Ssangeeta 24747c478bd9Sstevel@tonic-gate /* 2475c793af95Ssangeeta * Lock the fast path mp for access, since the fp_mp can be deleted 24765c0b7edeSseb * due a DL_NOTE_FASTPATH_FLUSH in the case of IRE_BROADCAST 24777c478bd9Sstevel@tonic-gate */ 24787c478bd9Sstevel@tonic-gate 24797c478bd9Sstevel@tonic-gate #define LOCK_IRE_FP_MP(ire) { \ 24805c0b7edeSseb if ((ire)->ire_type == IRE_BROADCAST) \ 2481c793af95Ssangeeta mutex_enter(&ire->ire_nce->nce_lock); \ 24827c478bd9Sstevel@tonic-gate } 24837c478bd9Sstevel@tonic-gate #define UNLOCK_IRE_FP_MP(ire) { \ 24845c0b7edeSseb if ((ire)->ire_type == IRE_BROADCAST) \ 2485c793af95Ssangeeta mutex_exit(&ire->ire_nce->nce_lock); \ 24867c478bd9Sstevel@tonic-gate } 24877c478bd9Sstevel@tonic-gate 24887c478bd9Sstevel@tonic-gate typedef struct ire4 { 24897c478bd9Sstevel@tonic-gate ipaddr_t ire4_src_addr; /* Source address to use. */ 24907c478bd9Sstevel@tonic-gate ipaddr_t ire4_mask; /* Mask for matching this IRE. */ 24917c478bd9Sstevel@tonic-gate ipaddr_t ire4_addr; /* Address this IRE represents. */ 24927c478bd9Sstevel@tonic-gate ipaddr_t ire4_gateway_addr; /* Gateway if IRE_CACHE/IRE_OFFSUBNET */ 24937c478bd9Sstevel@tonic-gate ipaddr_t ire4_cmask; /* Mask from parent prefix route */ 24947c478bd9Sstevel@tonic-gate } ire4_t; 24957c478bd9Sstevel@tonic-gate 24967c478bd9Sstevel@tonic-gate typedef struct ire6 { 24977c478bd9Sstevel@tonic-gate in6_addr_t ire6_src_addr; /* Source address to use. */ 24987c478bd9Sstevel@tonic-gate in6_addr_t ire6_mask; /* Mask for matching this IRE. */ 24997c478bd9Sstevel@tonic-gate in6_addr_t ire6_addr; /* Address this IRE represents. */ 25007c478bd9Sstevel@tonic-gate in6_addr_t ire6_gateway_addr; /* Gateway if IRE_CACHE/IRE_OFFSUBNET */ 25017c478bd9Sstevel@tonic-gate in6_addr_t ire6_cmask; /* Mask from parent prefix route */ 25027c478bd9Sstevel@tonic-gate } ire6_t; 25037c478bd9Sstevel@tonic-gate 25047c478bd9Sstevel@tonic-gate typedef union ire_addr { 25057c478bd9Sstevel@tonic-gate ire6_t ire6_u; 25067c478bd9Sstevel@tonic-gate ire4_t ire4_u; 25077c478bd9Sstevel@tonic-gate } ire_addr_u_t; 25087c478bd9Sstevel@tonic-gate 25097c478bd9Sstevel@tonic-gate /* Internet Routing Entry */ 25107c478bd9Sstevel@tonic-gate typedef struct ire_s { 25117c478bd9Sstevel@tonic-gate struct ire_s *ire_next; /* The hash chain must be first. */ 25127c478bd9Sstevel@tonic-gate struct ire_s **ire_ptpn; /* Pointer to previous next. */ 25137c478bd9Sstevel@tonic-gate uint32_t ire_refcnt; /* Number of references */ 25147c478bd9Sstevel@tonic-gate mblk_t *ire_mp; /* Non-null if allocated as mblk */ 25157c478bd9Sstevel@tonic-gate queue_t *ire_rfq; /* recv from this queue */ 25167c478bd9Sstevel@tonic-gate queue_t *ire_stq; /* send to this queue */ 25177c478bd9Sstevel@tonic-gate union { 25187c478bd9Sstevel@tonic-gate uint_t *max_fragp; /* Used only during ire creation */ 25197c478bd9Sstevel@tonic-gate uint_t max_frag; /* MTU (next hop or path). */ 25207c478bd9Sstevel@tonic-gate } imf_u; 25217c478bd9Sstevel@tonic-gate #define ire_max_frag imf_u.max_frag 25227c478bd9Sstevel@tonic-gate #define ire_max_fragp imf_u.max_fragp 25237c478bd9Sstevel@tonic-gate uint32_t ire_frag_flag; /* IPH_DF or zero. */ 25247c478bd9Sstevel@tonic-gate uint32_t ire_ident; /* Per IRE IP ident. */ 25257c478bd9Sstevel@tonic-gate uint32_t ire_tire_mark; /* Used for reclaim of unused. */ 25267c478bd9Sstevel@tonic-gate uchar_t ire_ipversion; /* IPv4/IPv6 version */ 25277c478bd9Sstevel@tonic-gate uchar_t ire_marks; /* IRE_MARK_CONDEMNED etc. */ 25287c478bd9Sstevel@tonic-gate ushort_t ire_type; /* Type of IRE */ 25297c478bd9Sstevel@tonic-gate uint_t ire_ib_pkt_count; /* Inbound packets for ire_addr */ 25307c478bd9Sstevel@tonic-gate uint_t ire_ob_pkt_count; /* Outbound packets to ire_addr */ 25317c478bd9Sstevel@tonic-gate uint_t ire_ll_hdr_length; /* Non-zero if we do M_DATA prepends */ 25327c478bd9Sstevel@tonic-gate time_t ire_create_time; /* Time (in secs) IRE was created. */ 25337c478bd9Sstevel@tonic-gate uint32_t ire_phandle; /* Associate prefix IREs to cache */ 25347c478bd9Sstevel@tonic-gate uint32_t ire_ihandle; /* Associate interface IREs to cache */ 25357c478bd9Sstevel@tonic-gate ipif_t *ire_ipif; /* the interface that this ire uses */ 25367c478bd9Sstevel@tonic-gate uint32_t ire_flags; /* flags related to route (RTF_*) */ 25377c478bd9Sstevel@tonic-gate uint_t ire_ipsec_overhead; /* IPSEC overhead */ 2538c793af95Ssangeeta /* 2539c793af95Ssangeeta * Neighbor Cache Entry for IPv6; arp info for IPv4 2540c793af95Ssangeeta */ 2541c793af95Ssangeeta struct nce_s *ire_nce; 25427c478bd9Sstevel@tonic-gate uint_t ire_masklen; /* # bits in ire_mask{,_v6} */ 25437c478bd9Sstevel@tonic-gate ire_addr_u_t ire_u; /* IPv4/IPv6 address info. */ 25447c478bd9Sstevel@tonic-gate 25457c478bd9Sstevel@tonic-gate irb_t *ire_bucket; /* Hash bucket when ire_ptphn is set */ 25467c478bd9Sstevel@tonic-gate iulp_t ire_uinfo; /* Upper layer protocol info. */ 25477c478bd9Sstevel@tonic-gate /* 25487c478bd9Sstevel@tonic-gate * Protects ire_uinfo, ire_max_frag, and ire_frag_flag. 25497c478bd9Sstevel@tonic-gate */ 25507c478bd9Sstevel@tonic-gate kmutex_t ire_lock; 25517c478bd9Sstevel@tonic-gate uint_t ire_ipif_seqid; /* ipif_seqid of ire_ipif */ 25525b17e9bdSJon Anderson uint_t ire_ipif_ifindex; /* ifindex associated with ipif */ 25537c478bd9Sstevel@tonic-gate clock_t ire_last_used_time; /* Last used time */ 255445916cd2Sjpk tsol_ire_gw_secattr_t *ire_gw_secattr; /* gateway security attributes */ 255569bb4bb4Scarlsonj zoneid_t ire_zoneid; /* for local address discrimination */ 2556c793af95Ssangeeta /* 2557c793af95Ssangeeta * ire's that are embedded inside mblk_t and sent to the external 2558c793af95Ssangeeta * resolver use the ire_stq_ifindex to track the ifindex of the 2559c793af95Ssangeeta * ire_stq, so that the ill (if it exists) can be correctly recovered 25601bf5e2aeSSowmini Varadhan * for cleanup in the esbfree routine when arp failure occurs. 25611bf5e2aeSSowmini Varadhan * Similarly, the ire_stackid is used to recover the ip_stack_t. 2562c793af95Ssangeeta */ 2563c793af95Ssangeeta uint_t ire_stq_ifindex; 25641bf5e2aeSSowmini Varadhan netstackid_t ire_stackid; 256569bb4bb4Scarlsonj uint_t ire_defense_count; /* number of ARP conflicts */ 256669bb4bb4Scarlsonj uint_t ire_defense_time; /* last time defended (secs) */ 256769bb4bb4Scarlsonj boolean_t ire_trace_disable; /* True when alloc fails */ 25686a8288c7Scarlsonj ip_stack_t *ire_ipst; /* Does not have a netstack_hold */ 25697c478bd9Sstevel@tonic-gate } ire_t; 25707c478bd9Sstevel@tonic-gate 25717924222fSmeem /* IPv4 compatibility macros */ 25727c478bd9Sstevel@tonic-gate #define ire_src_addr ire_u.ire4_u.ire4_src_addr 25737c478bd9Sstevel@tonic-gate #define ire_mask ire_u.ire4_u.ire4_mask 25747c478bd9Sstevel@tonic-gate #define ire_addr ire_u.ire4_u.ire4_addr 25757c478bd9Sstevel@tonic-gate #define ire_gateway_addr ire_u.ire4_u.ire4_gateway_addr 25767c478bd9Sstevel@tonic-gate #define ire_cmask ire_u.ire4_u.ire4_cmask 25777c478bd9Sstevel@tonic-gate 25787c478bd9Sstevel@tonic-gate #define ire_src_addr_v6 ire_u.ire6_u.ire6_src_addr 25797c478bd9Sstevel@tonic-gate #define ire_mask_v6 ire_u.ire6_u.ire6_mask 25807c478bd9Sstevel@tonic-gate #define ire_addr_v6 ire_u.ire6_u.ire6_addr 25817c478bd9Sstevel@tonic-gate #define ire_gateway_addr_v6 ire_u.ire6_u.ire6_gateway_addr 25827c478bd9Sstevel@tonic-gate #define ire_cmask_v6 ire_u.ire6_u.ire6_cmask 25837c478bd9Sstevel@tonic-gate 25847c478bd9Sstevel@tonic-gate /* Convenient typedefs for sockaddrs */ 25857c478bd9Sstevel@tonic-gate typedef struct sockaddr_in sin_t; 25867c478bd9Sstevel@tonic-gate typedef struct sockaddr_in6 sin6_t; 25877c478bd9Sstevel@tonic-gate 25887c478bd9Sstevel@tonic-gate /* Address structure used for internal bind with IP */ 25897c478bd9Sstevel@tonic-gate typedef struct ipa_conn_s { 25907c478bd9Sstevel@tonic-gate ipaddr_t ac_laddr; 25917c478bd9Sstevel@tonic-gate ipaddr_t ac_faddr; 25927c478bd9Sstevel@tonic-gate uint16_t ac_fport; 25937c478bd9Sstevel@tonic-gate uint16_t ac_lport; 25947c478bd9Sstevel@tonic-gate } ipa_conn_t; 25957c478bd9Sstevel@tonic-gate 25967c478bd9Sstevel@tonic-gate typedef struct ipa6_conn_s { 25977c478bd9Sstevel@tonic-gate in6_addr_t ac6_laddr; 25987c478bd9Sstevel@tonic-gate in6_addr_t ac6_faddr; 25997c478bd9Sstevel@tonic-gate uint16_t ac6_fport; 26007c478bd9Sstevel@tonic-gate uint16_t ac6_lport; 26017c478bd9Sstevel@tonic-gate } ipa6_conn_t; 26027c478bd9Sstevel@tonic-gate 26037c478bd9Sstevel@tonic-gate /* 26047c478bd9Sstevel@tonic-gate * Using ipa_conn_x_t or ipa6_conn_x_t allows us to modify the behavior of IP's 26057c478bd9Sstevel@tonic-gate * bind handler. 26067c478bd9Sstevel@tonic-gate */ 26077c478bd9Sstevel@tonic-gate typedef struct ipa_conn_extended_s { 26087c478bd9Sstevel@tonic-gate uint64_t acx_flags; 26097c478bd9Sstevel@tonic-gate ipa_conn_t acx_conn; 26107c478bd9Sstevel@tonic-gate } ipa_conn_x_t; 26117c478bd9Sstevel@tonic-gate 26127c478bd9Sstevel@tonic-gate typedef struct ipa6_conn_extended_s { 26137c478bd9Sstevel@tonic-gate uint64_t ac6x_flags; 26147c478bd9Sstevel@tonic-gate ipa6_conn_t ac6x_conn; 26157c478bd9Sstevel@tonic-gate } ipa6_conn_x_t; 26167c478bd9Sstevel@tonic-gate 26177c478bd9Sstevel@tonic-gate /* flag values for ipa_conn_x_t and ipa6_conn_x_t. */ 26187c478bd9Sstevel@tonic-gate #define ACX_VERIFY_DST 0x1ULL /* verify destination address is reachable */ 26197c478bd9Sstevel@tonic-gate 26207c478bd9Sstevel@tonic-gate /* Name/Value Descriptor. */ 26217c478bd9Sstevel@tonic-gate typedef struct nv_s { 26227c478bd9Sstevel@tonic-gate uint64_t nv_value; 26237c478bd9Sstevel@tonic-gate char *nv_name; 26247c478bd9Sstevel@tonic-gate } nv_t; 26257c478bd9Sstevel@tonic-gate 26267c478bd9Sstevel@tonic-gate #define ILL_FRAG_HASH(s, i) \ 26277c478bd9Sstevel@tonic-gate ((ntohl(s) ^ ((i) ^ ((i) >> 8))) % ILL_FRAG_HASH_TBL_COUNT) 26287c478bd9Sstevel@tonic-gate 26297c478bd9Sstevel@tonic-gate /* 26307c478bd9Sstevel@tonic-gate * The MAX number of allowed fragmented packets per hash bucket 26317c478bd9Sstevel@tonic-gate * calculation is based on the most common mtu size of 1500. This limit 26327c478bd9Sstevel@tonic-gate * will work well for other mtu sizes as well. 26337c478bd9Sstevel@tonic-gate */ 26347c478bd9Sstevel@tonic-gate #define COMMON_IP_MTU 1500 26357c478bd9Sstevel@tonic-gate #define MAX_FRAG_MIN 10 2636f4b3ec61Sdh155122 #define MAX_FRAG_PKTS(ipst) \ 2637f4b3ec61Sdh155122 MAX(MAX_FRAG_MIN, (2 * (ipst->ips_ip_reass_queue_bytes / \ 26387c478bd9Sstevel@tonic-gate (COMMON_IP_MTU * ILL_FRAG_HASH_TBL_COUNT)))) 26397c478bd9Sstevel@tonic-gate 26407c478bd9Sstevel@tonic-gate /* 26417c478bd9Sstevel@tonic-gate * Maximum dups allowed per packet. 26427c478bd9Sstevel@tonic-gate */ 26437c478bd9Sstevel@tonic-gate extern uint_t ip_max_frag_dups; 26447c478bd9Sstevel@tonic-gate 26457c478bd9Sstevel@tonic-gate /* 26467c478bd9Sstevel@tonic-gate * Per-packet information for received packets and transmitted. 26477c478bd9Sstevel@tonic-gate * Used by the transport protocols when converting between the packet 26487c478bd9Sstevel@tonic-gate * and ancillary data and socket options. 26497c478bd9Sstevel@tonic-gate * 26507c478bd9Sstevel@tonic-gate * Note: This private data structure and related IPPF_* constant 26517c478bd9Sstevel@tonic-gate * definitions are exposed to enable compilation of some debugging tools 26527c478bd9Sstevel@tonic-gate * like lsof which use struct tcp_t in <inet/tcp.h>. This is intended to be 26537c478bd9Sstevel@tonic-gate * a temporary hack and long term alternate interfaces should be defined 26547c478bd9Sstevel@tonic-gate * to support the needs of such tools and private definitions moved to 26557c478bd9Sstevel@tonic-gate * private headers. 26567c478bd9Sstevel@tonic-gate */ 26577c478bd9Sstevel@tonic-gate struct ip6_pkt_s { 26587c478bd9Sstevel@tonic-gate uint_t ipp_fields; /* Which fields are valid */ 26597c478bd9Sstevel@tonic-gate uint_t ipp_sticky_ignored; /* sticky fields to ignore */ 26607c478bd9Sstevel@tonic-gate uint_t ipp_ifindex; /* pktinfo ifindex */ 26617c478bd9Sstevel@tonic-gate in6_addr_t ipp_addr; /* pktinfo src/dst addr */ 2662b3d0fa4fSseb uint_t ipp_unicast_hops; /* IPV6_UNICAST_HOPS */ 2663b3d0fa4fSseb uint_t ipp_multicast_hops; /* IPV6_MULTICAST_HOPS */ 2664b3d0fa4fSseb uint_t ipp_hoplimit; /* IPV6_HOPLIMIT */ 26657c478bd9Sstevel@tonic-gate uint_t ipp_hopoptslen; 26667c478bd9Sstevel@tonic-gate uint_t ipp_rtdstoptslen; 26677c478bd9Sstevel@tonic-gate uint_t ipp_rthdrlen; 26687c478bd9Sstevel@tonic-gate uint_t ipp_dstoptslen; 26697c478bd9Sstevel@tonic-gate uint_t ipp_pathmtulen; 26708810c16bSdanmcd uint_t ipp_fraghdrlen; 26717c478bd9Sstevel@tonic-gate ip6_hbh_t *ipp_hopopts; 26727c478bd9Sstevel@tonic-gate ip6_dest_t *ipp_rtdstopts; 26737c478bd9Sstevel@tonic-gate ip6_rthdr_t *ipp_rthdr; 26747c478bd9Sstevel@tonic-gate ip6_dest_t *ipp_dstopts; 26758810c16bSdanmcd ip6_frag_t *ipp_fraghdr; 26767c478bd9Sstevel@tonic-gate struct ip6_mtuinfo *ipp_pathmtu; 26777c478bd9Sstevel@tonic-gate in6_addr_t ipp_nexthop; /* Transmit only */ 26787c478bd9Sstevel@tonic-gate uint8_t ipp_tclass; 26797c478bd9Sstevel@tonic-gate int8_t ipp_use_min_mtu; 26807c478bd9Sstevel@tonic-gate }; 26817c478bd9Sstevel@tonic-gate typedef struct ip6_pkt_s ip6_pkt_t; 26827c478bd9Sstevel@tonic-gate 268345916cd2Sjpk extern void ip6_pkt_free(ip6_pkt_t *); /* free storage inside ip6_pkt_t */ 268445916cd2Sjpk 26857c478bd9Sstevel@tonic-gate /* 268619a30e1aSrshoaib * This struct is used by ULP_opt_set() functions to return value of IPv4 268719a30e1aSrshoaib * ancillary options. Currently this is only used by udp and icmp and only 268819a30e1aSrshoaib * IP_PKTINFO option is supported. 26897c478bd9Sstevel@tonic-gate */ 269019a30e1aSrshoaib typedef struct ip4_pkt_s { 269119a30e1aSrshoaib uint_t ip4_ill_index; /* interface index */ 269219a30e1aSrshoaib ipaddr_t ip4_addr; /* source address */ 269319a30e1aSrshoaib } ip4_pkt_t; 269419a30e1aSrshoaib 269519a30e1aSrshoaib /* 269619a30e1aSrshoaib * Used by ULP's to pass options info to ip_output 269719a30e1aSrshoaib * currently only IP_PKTINFO is supported. 269819a30e1aSrshoaib */ 269919a30e1aSrshoaib typedef struct ip_opt_info_s { 270019a30e1aSrshoaib uint_t ip_opt_ill_index; 270119a30e1aSrshoaib uint_t ip_opt_flags; 270219a30e1aSrshoaib } ip_opt_info_t; 270319a30e1aSrshoaib 270419a30e1aSrshoaib /* 270519a30e1aSrshoaib * value for ip_opt_flags 270619a30e1aSrshoaib */ 270719a30e1aSrshoaib #define IP_VERIFY_SRC 0x1 270819a30e1aSrshoaib 270919a30e1aSrshoaib /* 271019a30e1aSrshoaib * This structure is used to convey information from IP and the ULP. 271119a30e1aSrshoaib * Currently used for the IP_RECVSLLA, IP_RECVIF and IP_RECVPKTINFO options. 271219a30e1aSrshoaib * The type of information field is set to IN_PKTINFO (i.e inbound pkt info) 271319a30e1aSrshoaib */ 271419a30e1aSrshoaib typedef struct ip_pktinfo { 271519a30e1aSrshoaib uint32_t ip_pkt_ulp_type; /* type of info sent */ 271619a30e1aSrshoaib uint32_t ip_pkt_flags; /* what is sent up by IP */ 271719a30e1aSrshoaib uint32_t ip_pkt_ifindex; /* inbound interface index */ 271819a30e1aSrshoaib struct sockaddr_dl ip_pkt_slla; /* has source link layer addr */ 271919a30e1aSrshoaib struct in_addr ip_pkt_match_addr; /* matched address */ 272019a30e1aSrshoaib } ip_pktinfo_t; 27217c478bd9Sstevel@tonic-gate 27227c478bd9Sstevel@tonic-gate /* 272345916cd2Sjpk * flags to tell UDP what IP is sending; in_pkt_flags 27247c478bd9Sstevel@tonic-gate */ 27257c478bd9Sstevel@tonic-gate #define IPF_RECVIF 0x01 /* inbound interface index */ 27267c478bd9Sstevel@tonic-gate #define IPF_RECVSLLA 0x02 /* source link layer address */ 272719a30e1aSrshoaib /* 272819a30e1aSrshoaib * Inbound interface index + matched address. 272919a30e1aSrshoaib * Used only by IPV4. 273019a30e1aSrshoaib */ 273119a30e1aSrshoaib #define IPF_RECVADDR 0x04 27327c478bd9Sstevel@tonic-gate 27337c478bd9Sstevel@tonic-gate /* ipp_fields values */ 27347c478bd9Sstevel@tonic-gate #define IPPF_IFINDEX 0x0001 /* Part of in6_pktinfo: ifindex */ 27357c478bd9Sstevel@tonic-gate #define IPPF_ADDR 0x0002 /* Part of in6_pktinfo: src/dst addr */ 27367c478bd9Sstevel@tonic-gate #define IPPF_SCOPE_ID 0x0004 /* Add xmit ip6i_t for sin6_scope_id */ 27377c478bd9Sstevel@tonic-gate #define IPPF_NO_CKSUM 0x0008 /* Add xmit ip6i_t for IP6I_NO_*_CKSUM */ 27387c478bd9Sstevel@tonic-gate 27397c478bd9Sstevel@tonic-gate #define IPPF_RAW_CKSUM 0x0010 /* Add xmit ip6i_t for IP6I_RAW_CHECKSUM */ 27407c478bd9Sstevel@tonic-gate #define IPPF_HOPLIMIT 0x0020 27417c478bd9Sstevel@tonic-gate #define IPPF_HOPOPTS 0x0040 27427c478bd9Sstevel@tonic-gate #define IPPF_RTHDR 0x0080 27437c478bd9Sstevel@tonic-gate 27447c478bd9Sstevel@tonic-gate #define IPPF_RTDSTOPTS 0x0100 27457c478bd9Sstevel@tonic-gate #define IPPF_DSTOPTS 0x0200 27467c478bd9Sstevel@tonic-gate #define IPPF_NEXTHOP 0x0400 27477c478bd9Sstevel@tonic-gate #define IPPF_PATHMTU 0x0800 27487c478bd9Sstevel@tonic-gate 27497c478bd9Sstevel@tonic-gate #define IPPF_TCLASS 0x1000 27507c478bd9Sstevel@tonic-gate #define IPPF_DONTFRAG 0x2000 2751b3d0fa4fSseb #define IPPF_USE_MIN_MTU 0x04000 2752b3d0fa4fSseb #define IPPF_MULTICAST_HOPS 0x08000 27538810c16bSdanmcd 2754b3d0fa4fSseb #define IPPF_UNICAST_HOPS 0x10000 27558810c16bSdanmcd #define IPPF_FRAGHDR 0x20000 27567c478bd9Sstevel@tonic-gate 27577c478bd9Sstevel@tonic-gate #define IPPF_HAS_IP6I \ 27587c478bd9Sstevel@tonic-gate (IPPF_IFINDEX|IPPF_ADDR|IPPF_NEXTHOP|IPPF_SCOPE_ID| \ 27597c478bd9Sstevel@tonic-gate IPPF_NO_CKSUM|IPPF_RAW_CKSUM|IPPF_HOPLIMIT|IPPF_DONTFRAG| \ 2760b3d0fa4fSseb IPPF_USE_MIN_MTU|IPPF_MULTICAST_HOPS|IPPF_UNICAST_HOPS) 27617c478bd9Sstevel@tonic-gate 27627c478bd9Sstevel@tonic-gate #define TCP_PORTS_OFFSET 0 27637c478bd9Sstevel@tonic-gate #define UDP_PORTS_OFFSET 0 27647c478bd9Sstevel@tonic-gate 27657c478bd9Sstevel@tonic-gate /* 27667c478bd9Sstevel@tonic-gate * lookups return the ill/ipif only if the flags are clear OR Iam writer. 27677c478bd9Sstevel@tonic-gate * ill / ipif lookup functions increment the refcnt on the ill / ipif only 27687c478bd9Sstevel@tonic-gate * after calling these macros. This ensures that the refcnt on the ipif or 27697c478bd9Sstevel@tonic-gate * ill will eventually drop down to zero. 27707c478bd9Sstevel@tonic-gate */ 27717c478bd9Sstevel@tonic-gate #define ILL_LOOKUP_FAILED 1 /* Used as error code */ 27727c478bd9Sstevel@tonic-gate #define IPIF_LOOKUP_FAILED 2 /* Used as error code */ 27737c478bd9Sstevel@tonic-gate 27747c478bd9Sstevel@tonic-gate #define ILL_CAN_LOOKUP(ill) \ 27757c478bd9Sstevel@tonic-gate (!((ill)->ill_state_flags & (ILL_CONDEMNED | ILL_CHANGING)) || \ 27767c478bd9Sstevel@tonic-gate IAM_WRITER_ILL(ill)) 27777c478bd9Sstevel@tonic-gate 27787c478bd9Sstevel@tonic-gate #define ILL_CAN_WAIT(ill, q) \ 27797c478bd9Sstevel@tonic-gate (((q) != NULL) && !((ill)->ill_state_flags & (ILL_CONDEMNED))) 27807c478bd9Sstevel@tonic-gate 27817c478bd9Sstevel@tonic-gate #define ILL_CAN_LOOKUP_WALKER(ill) \ 27827c478bd9Sstevel@tonic-gate (!((ill)->ill_state_flags & ILL_CONDEMNED)) 27837c478bd9Sstevel@tonic-gate 27847c478bd9Sstevel@tonic-gate #define IPIF_CAN_LOOKUP(ipif) \ 27857c478bd9Sstevel@tonic-gate (!((ipif)->ipif_state_flags & (IPIF_CONDEMNED | IPIF_CHANGING)) || \ 27867c478bd9Sstevel@tonic-gate IAM_WRITER_IPIF(ipif)) 27877c478bd9Sstevel@tonic-gate 27887c478bd9Sstevel@tonic-gate /* 27897c478bd9Sstevel@tonic-gate * If the parameter 'q' is NULL, the caller is not interested in wait and 27907c478bd9Sstevel@tonic-gate * restart of the operation if the ILL or IPIF cannot be looked up when it is 27917c478bd9Sstevel@tonic-gate * marked as 'CHANGING'. Typically a thread that tries to send out data will 27927c478bd9Sstevel@tonic-gate * end up passing NULLs as the last 4 parameters to ill_lookup_on_ifindex and 27937c478bd9Sstevel@tonic-gate * in this case 'q' is NULL 27947c478bd9Sstevel@tonic-gate */ 27957c478bd9Sstevel@tonic-gate #define IPIF_CAN_WAIT(ipif, q) \ 27967c478bd9Sstevel@tonic-gate (((q) != NULL) && !((ipif)->ipif_state_flags & (IPIF_CONDEMNED))) 27977c478bd9Sstevel@tonic-gate 27987c478bd9Sstevel@tonic-gate #define IPIF_CAN_LOOKUP_WALKER(ipif) \ 27997c478bd9Sstevel@tonic-gate (!((ipif)->ipif_state_flags & (IPIF_CONDEMNED)) || \ 28007c478bd9Sstevel@tonic-gate IAM_WRITER_IPIF(ipif)) 28017c478bd9Sstevel@tonic-gate 28027c478bd9Sstevel@tonic-gate /* 28037c478bd9Sstevel@tonic-gate * These macros are used by critical set ioctls and failover ioctls to 28047c478bd9Sstevel@tonic-gate * mark the ipif appropriately before starting the operation and to clear the 28057c478bd9Sstevel@tonic-gate * marks after completing the operation. 28067c478bd9Sstevel@tonic-gate */ 28077c478bd9Sstevel@tonic-gate #define IPIF_UNMARK_MOVING(ipif) \ 28087c478bd9Sstevel@tonic-gate (ipif)->ipif_state_flags &= ~IPIF_MOVING & ~IPIF_CHANGING; 28097c478bd9Sstevel@tonic-gate 28107c478bd9Sstevel@tonic-gate #define ILL_UNMARK_CHANGING(ill) \ 28117c478bd9Sstevel@tonic-gate (ill)->ill_state_flags &= ~ILL_CHANGING; 28127c478bd9Sstevel@tonic-gate 28137c478bd9Sstevel@tonic-gate /* Macros used to assert that this thread is a writer */ 28147c478bd9Sstevel@tonic-gate #define IAM_WRITER_IPSQ(ipsq) ((ipsq)->ipsq_writer == curthread) 28157924222fSmeem #define IAM_WRITER_ILL(ill) IAM_WRITER_IPSQ((ill)->ill_phyint->phyint_ipsq) 28167924222fSmeem #define IAM_WRITER_IPIF(ipif) IAM_WRITER_ILL((ipif)->ipif_ill) 28177c478bd9Sstevel@tonic-gate 28187c478bd9Sstevel@tonic-gate /* 28197c478bd9Sstevel@tonic-gate * Grab ill locks in the proper order. The order is highest addressed 28207c478bd9Sstevel@tonic-gate * ill is locked first. 28217c478bd9Sstevel@tonic-gate */ 28227c478bd9Sstevel@tonic-gate #define GRAB_ILL_LOCKS(ill_1, ill_2) \ 28237c478bd9Sstevel@tonic-gate { \ 28247c478bd9Sstevel@tonic-gate if ((ill_1) > (ill_2)) { \ 28257c478bd9Sstevel@tonic-gate if (ill_1 != NULL) \ 28267c478bd9Sstevel@tonic-gate mutex_enter(&(ill_1)->ill_lock); \ 28277c478bd9Sstevel@tonic-gate if (ill_2 != NULL) \ 28287c478bd9Sstevel@tonic-gate mutex_enter(&(ill_2)->ill_lock); \ 28297c478bd9Sstevel@tonic-gate } else { \ 28307c478bd9Sstevel@tonic-gate if (ill_2 != NULL) \ 28317c478bd9Sstevel@tonic-gate mutex_enter(&(ill_2)->ill_lock); \ 28327c478bd9Sstevel@tonic-gate if (ill_1 != NULL && ill_1 != ill_2) \ 28337c478bd9Sstevel@tonic-gate mutex_enter(&(ill_1)->ill_lock); \ 28347c478bd9Sstevel@tonic-gate } \ 28357c478bd9Sstevel@tonic-gate } 28367c478bd9Sstevel@tonic-gate 28377c478bd9Sstevel@tonic-gate #define RELEASE_ILL_LOCKS(ill_1, ill_2) \ 28387c478bd9Sstevel@tonic-gate { \ 28397c478bd9Sstevel@tonic-gate if (ill_1 != NULL) \ 28407c478bd9Sstevel@tonic-gate mutex_exit(&(ill_1)->ill_lock); \ 28417c478bd9Sstevel@tonic-gate if (ill_2 != NULL && ill_2 != ill_1) \ 28427c478bd9Sstevel@tonic-gate mutex_exit(&(ill_2)->ill_lock); \ 28437c478bd9Sstevel@tonic-gate } 28447c478bd9Sstevel@tonic-gate 28457c478bd9Sstevel@tonic-gate /* Get the other protocol instance ill */ 28467c478bd9Sstevel@tonic-gate #define ILL_OTHER(ill) \ 28477c478bd9Sstevel@tonic-gate ((ill)->ill_isv6 ? (ill)->ill_phyint->phyint_illv4 : \ 28487c478bd9Sstevel@tonic-gate (ill)->ill_phyint->phyint_illv6) 28497c478bd9Sstevel@tonic-gate 28507c478bd9Sstevel@tonic-gate #define MATCH_V4_ONLY 0x1 28517c478bd9Sstevel@tonic-gate #define MATCH_V6_ONLY 0x2 28527c478bd9Sstevel@tonic-gate #define MATCH_ILL_ONLY 0x4 28537c478bd9Sstevel@tonic-gate 28547c478bd9Sstevel@tonic-gate /* ioctl command info: Ioctl properties extracted and stored in here */ 28557c478bd9Sstevel@tonic-gate typedef struct cmd_info_s 28567c478bd9Sstevel@tonic-gate { 28577c478bd9Sstevel@tonic-gate char ci_groupname[LIFNAMSIZ + 1]; /* SIOCSLIFGROUPNAME */ 28587c478bd9Sstevel@tonic-gate ipif_t *ci_ipif; /* ipif associated with [l]ifreq ioctl's */ 28597c478bd9Sstevel@tonic-gate sin_t *ci_sin; /* the sin struct passed down */ 28607c478bd9Sstevel@tonic-gate sin6_t *ci_sin6; /* the sin6_t struct passed down */ 28617c478bd9Sstevel@tonic-gate struct lifreq *ci_lifr; /* the lifreq struct passed down */ 28627c478bd9Sstevel@tonic-gate } cmd_info_t; 28637c478bd9Sstevel@tonic-gate 2864f4b3ec61Sdh155122 /* 2865f4b3ec61Sdh155122 * List of AH and ESP IPsec acceleration capable ills 2866f4b3ec61Sdh155122 */ 2867f4b3ec61Sdh155122 typedef struct ipsec_capab_ill_s { 2868f4b3ec61Sdh155122 uint_t ill_index; 2869f4b3ec61Sdh155122 boolean_t ill_isv6; 2870f4b3ec61Sdh155122 struct ipsec_capab_ill_s *next; 2871f4b3ec61Sdh155122 } ipsec_capab_ill_t; 28727c478bd9Sstevel@tonic-gate 28737c478bd9Sstevel@tonic-gate extern struct kmem_cache *ire_cache; 28747c478bd9Sstevel@tonic-gate 28757c478bd9Sstevel@tonic-gate extern ipaddr_t ip_g_all_ones; 28767c478bd9Sstevel@tonic-gate 2877f4b3ec61Sdh155122 extern uint_t ip_loopback_mtu; /* /etc/system */ 28787c478bd9Sstevel@tonic-gate 2879aa92d85bSgt145670 extern vmem_t *ip_minor_arena_sa; 2880aa92d85bSgt145670 extern vmem_t *ip_minor_arena_la; 28817c478bd9Sstevel@tonic-gate 2882f4b3ec61Sdh155122 /* 2883f4b3ec61Sdh155122 * ip_g_forward controls IP forwarding. It takes two values: 2884f4b3ec61Sdh155122 * 0: IP_FORWARD_NEVER Don't forward packets ever. 2885f4b3ec61Sdh155122 * 1: IP_FORWARD_ALWAYS Forward packets for elsewhere. 2886f4b3ec61Sdh155122 * 2887f4b3ec61Sdh155122 * RFC1122 says there must be a configuration switch to control forwarding, 2888f4b3ec61Sdh155122 * but that the default MUST be to not forward packets ever. Implicit 2889f4b3ec61Sdh155122 * control based on configuration of multiple interfaces MUST NOT be 2890f4b3ec61Sdh155122 * implemented (Section 3.1). SunOS 4.1 did provide the "automatic" capability 2891f4b3ec61Sdh155122 * and, in fact, it was the default. That capability is now provided in the 2892f4b3ec61Sdh155122 * /etc/rc2.d/S69inet script. 2893f4b3ec61Sdh155122 */ 2894f4b3ec61Sdh155122 2895f4b3ec61Sdh155122 #define ips_ip_respond_to_address_mask_broadcast ips_param_arr[0].ip_param_value 2896f4b3ec61Sdh155122 #define ips_ip_g_resp_to_echo_bcast ips_param_arr[1].ip_param_value 2897f4b3ec61Sdh155122 #define ips_ip_g_resp_to_echo_mcast ips_param_arr[2].ip_param_value 2898f4b3ec61Sdh155122 #define ips_ip_g_resp_to_timestamp ips_param_arr[3].ip_param_value 2899f4b3ec61Sdh155122 #define ips_ip_g_resp_to_timestamp_bcast ips_param_arr[4].ip_param_value 2900f4b3ec61Sdh155122 #define ips_ip_g_send_redirects ips_param_arr[5].ip_param_value 2901f4b3ec61Sdh155122 #define ips_ip_g_forward_directed_bcast ips_param_arr[6].ip_param_value 2902ae43f94fSnordmark #define ips_ip_mrtdebug ips_param_arr[7].ip_param_value 2903ae43f94fSnordmark #define ips_ip_timer_interval ips_param_arr[8].ip_param_value 2904ae43f94fSnordmark #define ips_ip_ire_arp_interval ips_param_arr[9].ip_param_value 2905ae43f94fSnordmark #define ips_ip_ire_redir_interval ips_param_arr[10].ip_param_value 2906ae43f94fSnordmark #define ips_ip_def_ttl ips_param_arr[11].ip_param_value 2907ae43f94fSnordmark #define ips_ip_forward_src_routed ips_param_arr[12].ip_param_value 2908ae43f94fSnordmark #define ips_ip_wroff_extra ips_param_arr[13].ip_param_value 2909ae43f94fSnordmark #define ips_ip_ire_pathmtu_interval ips_param_arr[14].ip_param_value 2910ae43f94fSnordmark #define ips_ip_icmp_return ips_param_arr[15].ip_param_value 2911ae43f94fSnordmark #define ips_ip_path_mtu_discovery ips_param_arr[16].ip_param_value 2912ae43f94fSnordmark #define ips_ip_ignore_delete_time ips_param_arr[17].ip_param_value 2913ae43f94fSnordmark #define ips_ip_ignore_redirect ips_param_arr[18].ip_param_value 2914ae43f94fSnordmark #define ips_ip_output_queue ips_param_arr[19].ip_param_value 2915ae43f94fSnordmark #define ips_ip_broadcast_ttl ips_param_arr[20].ip_param_value 2916ae43f94fSnordmark #define ips_ip_icmp_err_interval ips_param_arr[21].ip_param_value 2917ae43f94fSnordmark #define ips_ip_icmp_err_burst ips_param_arr[22].ip_param_value 2918ae43f94fSnordmark #define ips_ip_reass_queue_bytes ips_param_arr[23].ip_param_value 2919ae43f94fSnordmark #define ips_ip_strict_dst_multihoming ips_param_arr[24].ip_param_value 2920ae43f94fSnordmark #define ips_ip_addrs_per_if ips_param_arr[25].ip_param_value 2921ae43f94fSnordmark #define ips_ipsec_override_persocket_policy ips_param_arr[26].ip_param_value 2922ae43f94fSnordmark #define ips_icmp_accept_clear_messages ips_param_arr[27].ip_param_value 2923ae43f94fSnordmark #define ips_igmp_accept_clear_messages ips_param_arr[28].ip_param_value 292469bb4bb4Scarlsonj 292569bb4bb4Scarlsonj /* IPv6 configuration knobs */ 2926ae43f94fSnordmark #define ips_delay_first_probe_time ips_param_arr[29].ip_param_value 2927ae43f94fSnordmark #define ips_max_unicast_solicit ips_param_arr[30].ip_param_value 2928ae43f94fSnordmark #define ips_ipv6_def_hops ips_param_arr[31].ip_param_value 2929ae43f94fSnordmark #define ips_ipv6_icmp_return ips_param_arr[32].ip_param_value 2930ae43f94fSnordmark #define ips_ipv6_forward_src_routed ips_param_arr[33].ip_param_value 2931ae43f94fSnordmark #define ips_ipv6_resp_echo_mcast ips_param_arr[34].ip_param_value 2932ae43f94fSnordmark #define ips_ipv6_send_redirects ips_param_arr[35].ip_param_value 2933ae43f94fSnordmark #define ips_ipv6_ignore_redirect ips_param_arr[36].ip_param_value 2934ae43f94fSnordmark #define ips_ipv6_strict_dst_multihoming ips_param_arr[37].ip_param_value 2935ae43f94fSnordmark #define ips_ip_ire_reclaim_fraction ips_param_arr[38].ip_param_value 2936ae43f94fSnordmark #define ips_ipsec_policy_log_interval ips_param_arr[39].ip_param_value 2937ae43f94fSnordmark #define ips_pim_accept_clear_messages ips_param_arr[40].ip_param_value 2938ae43f94fSnordmark #define ips_ip_ndp_unsolicit_interval ips_param_arr[41].ip_param_value 2939ae43f94fSnordmark #define ips_ip_ndp_unsolicit_count ips_param_arr[42].ip_param_value 2940ae43f94fSnordmark #define ips_ipv6_ignore_home_address_opt ips_param_arr[43].ip_param_value 294116c9d76cSKacheong Poon 294216c9d76cSKacheong Poon /* Misc IP configuration knobs */ 2943ae43f94fSnordmark #define ips_ip_policy_mask ips_param_arr[44].ip_param_value 2944ae43f94fSnordmark #define ips_ip_multirt_resolution_interval ips_param_arr[45].ip_param_value 2945ae43f94fSnordmark #define ips_ip_multirt_ttl ips_param_arr[46].ip_param_value 2946ae43f94fSnordmark #define ips_ip_multidata_outbound ips_param_arr[47].ip_param_value 2947ae43f94fSnordmark #define ips_ip_ndp_defense_interval ips_param_arr[48].ip_param_value 2948ae43f94fSnordmark #define ips_ip_max_temp_idle ips_param_arr[49].ip_param_value 2949ae43f94fSnordmark #define ips_ip_max_temp_defend ips_param_arr[50].ip_param_value 2950ae43f94fSnordmark #define ips_ip_max_defend ips_param_arr[51].ip_param_value 2951ae43f94fSnordmark #define ips_ip_defend_interval ips_param_arr[52].ip_param_value 2952ae43f94fSnordmark #define ips_ip_dup_recovery ips_param_arr[53].ip_param_value 2953ae43f94fSnordmark #define ips_ip_restrict_interzone_loopback ips_param_arr[54].ip_param_value 2954ae43f94fSnordmark #define ips_ip_lso_outbound ips_param_arr[55].ip_param_value 2955ae43f94fSnordmark #define ips_igmp_max_version ips_param_arr[56].ip_param_value 2956ae43f94fSnordmark #define ips_mld_max_version ips_param_arr[57].ip_param_value 295716c9d76cSKacheong Poon #define ips_ip_pmtu_min ips_param_arr[58].ip_param_value 295816c9d76cSKacheong Poon #define ips_ipv6_drop_inbound_icmpv6 ips_param_arr[59].ip_param_value 29597c478bd9Sstevel@tonic-gate 29607c478bd9Sstevel@tonic-gate extern int dohwcksum; /* use h/w cksum if supported by the h/w */ 29617c478bd9Sstevel@tonic-gate #ifdef ZC_TEST 29627c478bd9Sstevel@tonic-gate extern int noswcksum; 29637c478bd9Sstevel@tonic-gate #endif 29647c478bd9Sstevel@tonic-gate 29657c478bd9Sstevel@tonic-gate extern char ipif_loopback_name[]; 29667c478bd9Sstevel@tonic-gate 29677c478bd9Sstevel@tonic-gate extern nv_t *ire_nv_tbl; 29687c478bd9Sstevel@tonic-gate 29697c478bd9Sstevel@tonic-gate extern struct module_info ip_mod_info; 29707c478bd9Sstevel@tonic-gate 2971f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_PHYSICAL_IN(ipst) \ 2972f4b3ec61Sdh155122 ((ipst)->ips_ip4_physical_in_event.he_interested) 2973f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_PHYSICAL_IN(ipst) \ 2974f4b3ec61Sdh155122 ((ipst)->ips_ip6_physical_in_event.he_interested) 2975f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_PHYSICAL_OUT(ipst) \ 2976f4b3ec61Sdh155122 ((ipst)->ips_ip4_physical_out_event.he_interested) 2977f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_PHYSICAL_OUT(ipst) \ 2978f4b3ec61Sdh155122 ((ipst)->ips_ip6_physical_out_event.he_interested) 2979f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_FORWARDING(ipst) \ 2980f4b3ec61Sdh155122 ((ipst)->ips_ip4_forwarding_event.he_interested) 2981f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_FORWARDING(ipst) \ 2982f4b3ec61Sdh155122 ((ipst)->ips_ip6_forwarding_event.he_interested) 2983f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_LOOPBACK_IN(ipst) \ 2984f4b3ec61Sdh155122 ((ipst)->ips_ip4_loopback_in_event.he_interested) 2985f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_LOOPBACK_IN(ipst) \ 2986f4b3ec61Sdh155122 ((ipst)->ips_ip6_loopback_in_event.he_interested) 2987f4b3ec61Sdh155122 #define HOOKS4_INTERESTED_LOOPBACK_OUT(ipst) \ 2988f4b3ec61Sdh155122 ((ipst)->ips_ip4_loopback_out_event.he_interested) 2989f4b3ec61Sdh155122 #define HOOKS6_INTERESTED_LOOPBACK_OUT(ipst) \ 2990f4b3ec61Sdh155122 ((ipst)->ips_ip6_loopback_out_event.he_interested) 2991381a2a9aSdr146992 2992381a2a9aSdr146992 /* 2993381a2a9aSdr146992 * Hooks marcos used inside of ip 2994381a2a9aSdr146992 */ 2995381a2a9aSdr146992 #define IPHA_VHL ipha_version_and_hdr_length 2996381a2a9aSdr146992 29971b47e080Sdr146992 #define FW_HOOKS(_hook, _event, _ilp, _olp, _iph, _fm, _m, _llm, ipst) \ 2998381a2a9aSdr146992 \ 2999381a2a9aSdr146992 if ((_hook).he_interested) { \ 3000381a2a9aSdr146992 hook_pkt_event_t info; \ 3001381a2a9aSdr146992 \ 3002381a2a9aSdr146992 _NOTE(CONSTCOND) \ 3003381a2a9aSdr146992 ASSERT((_ilp != NULL) || (_olp != NULL)); \ 3004381a2a9aSdr146992 \ 3005381a2a9aSdr146992 _NOTE(CONSTCOND) \ 3006381a2a9aSdr146992 if ((_ilp != NULL) && \ 3007381a2a9aSdr146992 (((ill_t *)(_ilp))->ill_phyint != NULL)) \ 3008381a2a9aSdr146992 info.hpe_ifp = (phy_if_t)((ill_t *) \ 300967c1caeeSnordmark (_ilp))->ill_phyint->phyint_hook_ifindex; \ 3010381a2a9aSdr146992 else \ 3011381a2a9aSdr146992 info.hpe_ifp = 0; \ 3012381a2a9aSdr146992 \ 3013381a2a9aSdr146992 _NOTE(CONSTCOND) \ 3014381a2a9aSdr146992 if ((_olp != NULL) && \ 3015381a2a9aSdr146992 (((ill_t *)(_olp))->ill_phyint != NULL)) \ 3016381a2a9aSdr146992 info.hpe_ofp = (phy_if_t)((ill_t *) \ 301767c1caeeSnordmark (_olp))->ill_phyint->phyint_hook_ifindex; \ 3018381a2a9aSdr146992 else \ 3019381a2a9aSdr146992 info.hpe_ofp = 0; \ 30207ddc9b1aSDarren Reed info.hpe_protocol = ipst->ips_ipv4_net_data; \ 3021381a2a9aSdr146992 info.hpe_hdr = _iph; \ 3022381a2a9aSdr146992 info.hpe_mp = &(_fm); \ 3023381a2a9aSdr146992 info.hpe_mb = _m; \ 30241b47e080Sdr146992 info.hpe_flags = _llm; \ 30257ddc9b1aSDarren Reed if (hook_run(ipst->ips_ipv4_net_data->netd_hooks, \ 30267ddc9b1aSDarren Reed _event, (hook_data_t)&info) != 0) { \ 3027381a2a9aSdr146992 ip2dbg(("%s hook dropped mblk chain %p hdr %p\n",\ 3028381a2a9aSdr146992 (_hook).he_name, (void *)_fm, (void *)_m)); \ 3029381a2a9aSdr146992 if (_fm != NULL) { \ 3030381a2a9aSdr146992 freemsg(_fm); \ 3031381a2a9aSdr146992 _fm = NULL; \ 3032381a2a9aSdr146992 } \ 3033381a2a9aSdr146992 _iph = NULL; \ 3034381a2a9aSdr146992 _m = NULL; \ 3035381a2a9aSdr146992 } else { \ 3036381a2a9aSdr146992 _iph = info.hpe_hdr; \ 3037381a2a9aSdr146992 _m = info.hpe_mb; \ 3038381a2a9aSdr146992 } \ 3039381a2a9aSdr146992 } 3040381a2a9aSdr146992 30411b47e080Sdr146992 #define FW_HOOKS6(_hook, _event, _ilp, _olp, _iph, _fm, _m, _llm, ipst) \ 3042381a2a9aSdr146992 \ 3043381a2a9aSdr146992 if ((_hook).he_interested) { \ 3044381a2a9aSdr146992 hook_pkt_event_t info; \ 3045381a2a9aSdr146992 \ 3046381a2a9aSdr146992 _NOTE(CONSTCOND) \ 3047381a2a9aSdr146992 ASSERT((_ilp != NULL) || (_olp != NULL)); \ 3048381a2a9aSdr146992 \ 3049381a2a9aSdr146992 _NOTE(CONSTCOND) \ 3050381a2a9aSdr146992 if ((_ilp != NULL) && \ 3051381a2a9aSdr146992 (((ill_t *)(_ilp))->ill_phyint != NULL)) \ 3052381a2a9aSdr146992 info.hpe_ifp = (phy_if_t)((ill_t *) \ 305367c1caeeSnordmark (_ilp))->ill_phyint->phyint_hook_ifindex; \ 3054381a2a9aSdr146992 else \ 3055381a2a9aSdr146992 info.hpe_ifp = 0; \ 3056381a2a9aSdr146992 \ 3057381a2a9aSdr146992 _NOTE(CONSTCOND) \ 3058381a2a9aSdr146992 if ((_olp != NULL) && \ 3059381a2a9aSdr146992 (((ill_t *)(_olp))->ill_phyint != NULL)) \ 3060381a2a9aSdr146992 info.hpe_ofp = (phy_if_t)((ill_t *) \ 306167c1caeeSnordmark (_olp))->ill_phyint->phyint_hook_ifindex; \ 3062381a2a9aSdr146992 else \ 3063381a2a9aSdr146992 info.hpe_ofp = 0; \ 30647ddc9b1aSDarren Reed info.hpe_protocol = ipst->ips_ipv6_net_data; \ 3065381a2a9aSdr146992 info.hpe_hdr = _iph; \ 3066381a2a9aSdr146992 info.hpe_mp = &(_fm); \ 3067381a2a9aSdr146992 info.hpe_mb = _m; \ 30681b47e080Sdr146992 info.hpe_flags = _llm; \ 30697ddc9b1aSDarren Reed if (hook_run(ipst->ips_ipv6_net_data->netd_hooks, \ 30707ddc9b1aSDarren Reed _event, (hook_data_t)&info) != 0) { \ 3071381a2a9aSdr146992 ip2dbg(("%s hook dropped mblk chain %p hdr %p\n",\ 3072381a2a9aSdr146992 (_hook).he_name, (void *)_fm, (void *)_m)); \ 3073381a2a9aSdr146992 if (_fm != NULL) { \ 3074381a2a9aSdr146992 freemsg(_fm); \ 3075381a2a9aSdr146992 _fm = NULL; \ 3076381a2a9aSdr146992 } \ 3077381a2a9aSdr146992 _iph = NULL; \ 3078381a2a9aSdr146992 _m = NULL; \ 3079381a2a9aSdr146992 } else { \ 3080381a2a9aSdr146992 _iph = info.hpe_hdr; \ 3081381a2a9aSdr146992 _m = info.hpe_mb; \ 3082381a2a9aSdr146992 } \ 3083381a2a9aSdr146992 } 3084381a2a9aSdr146992 3085381a2a9aSdr146992 /* 30867c478bd9Sstevel@tonic-gate * Network byte order macros 30877c478bd9Sstevel@tonic-gate */ 30887c478bd9Sstevel@tonic-gate #ifdef _BIG_ENDIAN 30892a9459bdSsangeeta #define N_IN_CLASSA_NET IN_CLASSA_NET 30907c478bd9Sstevel@tonic-gate #define N_IN_CLASSD_NET IN_CLASSD_NET 30917c478bd9Sstevel@tonic-gate #define N_INADDR_UNSPEC_GROUP INADDR_UNSPEC_GROUP 30922a9459bdSsangeeta #define N_IN_LOOPBACK_NET (ipaddr_t)0x7f000000U 30937c478bd9Sstevel@tonic-gate #else /* _BIG_ENDIAN */ 30942a9459bdSsangeeta #define N_IN_CLASSA_NET (ipaddr_t)0x000000ffU 30957c478bd9Sstevel@tonic-gate #define N_IN_CLASSD_NET (ipaddr_t)0x000000f0U 30967c478bd9Sstevel@tonic-gate #define N_INADDR_UNSPEC_GROUP (ipaddr_t)0x000000e0U 30972a9459bdSsangeeta #define N_IN_LOOPBACK_NET (ipaddr_t)0x0000007fU 30987c478bd9Sstevel@tonic-gate #endif /* _BIG_ENDIAN */ 30997c478bd9Sstevel@tonic-gate #define CLASSD(addr) (((addr) & N_IN_CLASSD_NET) == N_INADDR_UNSPEC_GROUP) 31002a9459bdSsangeeta #define CLASSE(addr) (((addr) & N_IN_CLASSD_NET) == N_IN_CLASSD_NET) 3101c793af95Ssangeeta #define IP_LOOPBACK_ADDR(addr) \ 31022a9459bdSsangeeta (((addr) & N_IN_CLASSA_NET == N_IN_LOOPBACK_NET)) 3103c793af95Ssangeeta 31047c478bd9Sstevel@tonic-gate #ifdef DEBUG 31057c478bd9Sstevel@tonic-gate /* IPsec HW acceleration debugging support */ 31067c478bd9Sstevel@tonic-gate 31077c478bd9Sstevel@tonic-gate #define IPSECHW_CAPAB 0x0001 /* capability negotiation */ 31087c478bd9Sstevel@tonic-gate #define IPSECHW_SADB 0x0002 /* SADB exchange */ 31097c478bd9Sstevel@tonic-gate #define IPSECHW_PKT 0x0004 /* general packet flow */ 31107c478bd9Sstevel@tonic-gate #define IPSECHW_PKTIN 0x0008 /* driver in pkt processing details */ 31117c478bd9Sstevel@tonic-gate #define IPSECHW_PKTOUT 0x0010 /* driver out pkt processing details */ 31127c478bd9Sstevel@tonic-gate 31137c478bd9Sstevel@tonic-gate #define IPSECHW_DEBUG(f, x) if (ipsechw_debug & (f)) { (void) printf x; } 31147c478bd9Sstevel@tonic-gate #define IPSECHW_CALL(f, r, x) if (ipsechw_debug & (f)) { (void) r x; } 31157c478bd9Sstevel@tonic-gate 31167c478bd9Sstevel@tonic-gate extern uint32_t ipsechw_debug; 31177c478bd9Sstevel@tonic-gate #else 31187c478bd9Sstevel@tonic-gate #define IPSECHW_DEBUG(f, x) {} 31197c478bd9Sstevel@tonic-gate #define IPSECHW_CALL(f, r, x) {} 31207c478bd9Sstevel@tonic-gate #endif 31217c478bd9Sstevel@tonic-gate 3122f4b3ec61Sdh155122 extern int ip_debug; 31236a8288c7Scarlsonj extern uint_t ip_thread_data; 31246a8288c7Scarlsonj extern krwlock_t ip_thread_rwlock; 31256a8288c7Scarlsonj extern list_t ip_thread_list; 3126f4b3ec61Sdh155122 31277c478bd9Sstevel@tonic-gate #ifdef IP_DEBUG 31287c478bd9Sstevel@tonic-gate #include <sys/debug.h> 31297c478bd9Sstevel@tonic-gate #include <sys/promif.h> 31307c478bd9Sstevel@tonic-gate 31317c478bd9Sstevel@tonic-gate #define ip0dbg(a) printf a 31327c478bd9Sstevel@tonic-gate #define ip1dbg(a) if (ip_debug > 2) printf a 31337c478bd9Sstevel@tonic-gate #define ip2dbg(a) if (ip_debug > 3) printf a 31347c478bd9Sstevel@tonic-gate #define ip3dbg(a) if (ip_debug > 4) printf a 31357c478bd9Sstevel@tonic-gate #else 31367c478bd9Sstevel@tonic-gate #define ip0dbg(a) /* */ 31377c478bd9Sstevel@tonic-gate #define ip1dbg(a) /* */ 31387c478bd9Sstevel@tonic-gate #define ip2dbg(a) /* */ 31397c478bd9Sstevel@tonic-gate #define ip3dbg(a) /* */ 31407c478bd9Sstevel@tonic-gate #endif /* IP_DEBUG */ 31417c478bd9Sstevel@tonic-gate 314269bb4bb4Scarlsonj /* Default MAC-layer address string length for mac_colon_addr */ 314369bb4bb4Scarlsonj #define MAC_STR_LEN 128 314469bb4bb4Scarlsonj 3145c793af95Ssangeeta struct ipsec_out_s; 3146c793af95Ssangeeta 3147605445d5Sdg199075 struct mac_header_info_s; 3148605445d5Sdg199075 314967c1caeeSnordmark extern boolean_t ip_assign_ifindex(uint_t *, ip_stack_t *); 31507c478bd9Sstevel@tonic-gate extern void ill_frag_timer(void *); 3151f4b3ec61Sdh155122 extern ill_t *ill_first(int, int, ill_walk_context_t *, ip_stack_t *); 31527c478bd9Sstevel@tonic-gate extern ill_t *ill_next(ill_walk_context_t *, ill_t *); 31537c478bd9Sstevel@tonic-gate extern void ill_frag_timer_start(ill_t *); 3154b127ac41SPhilip Kirk extern void ill_nic_event_dispatch(ill_t *, lif_if_t, nic_event_t, 3155b127ac41SPhilip Kirk nic_event_data_t, size_t); 3156b127ac41SPhilip Kirk extern void ill_nic_event_plumb(ill_t *, boolean_t); 31577c478bd9Sstevel@tonic-gate extern mblk_t *ip_carve_mp(mblk_t **, ssize_t); 31587c478bd9Sstevel@tonic-gate extern mblk_t *ip_dlpi_alloc(size_t, t_uscalar_t); 31597c478bd9Sstevel@tonic-gate extern char *ip_dot_addr(ipaddr_t, char *); 316069bb4bb4Scarlsonj extern const char *mac_colon_addr(const uint8_t *, size_t, char *, size_t); 31617c478bd9Sstevel@tonic-gate extern void ip_lwput(queue_t *, mblk_t *); 3162f4b3ec61Sdh155122 extern boolean_t icmp_err_rate_limit(ip_stack_t *); 3163f4b3ec61Sdh155122 extern void icmp_time_exceeded(queue_t *, mblk_t *, uint8_t, zoneid_t, 3164f4b3ec61Sdh155122 ip_stack_t *); 3165f4b3ec61Sdh155122 extern void icmp_unreachable(queue_t *, mblk_t *, uint8_t, zoneid_t, 3166f4b3ec61Sdh155122 ip_stack_t *); 3167f4b3ec61Sdh155122 extern mblk_t *ip_add_info(mblk_t *, ill_t *, uint_t, zoneid_t, ip_stack_t *); 31687c478bd9Sstevel@tonic-gate extern mblk_t *ip_bind_v4(queue_t *, mblk_t *, conn_t *); 31697c478bd9Sstevel@tonic-gate extern boolean_t ip_bind_ipsec_policy_set(conn_t *, mblk_t *); 3170*0f1702c5SYu Xiangning extern int ip_bind_laddr_v4(conn_t *, mblk_t **, uint8_t, ipaddr_t, 3171*0f1702c5SYu Xiangning uint16_t, boolean_t); 3172*0f1702c5SYu Xiangning extern int ip_proto_bind_laddr_v4(conn_t *, mblk_t **, uint8_t, ipaddr_t, 3173*0f1702c5SYu Xiangning uint16_t, boolean_t); 3174*0f1702c5SYu Xiangning extern int ip_proto_bind_connected_v4(conn_t *, mblk_t **, 3175*0f1702c5SYu Xiangning uint8_t, ipaddr_t *, uint16_t, ipaddr_t, uint16_t, boolean_t, boolean_t); 3176*0f1702c5SYu Xiangning extern int ip_bind_connected_v4(conn_t *, mblk_t **, uint8_t, ipaddr_t *, 3177*0f1702c5SYu Xiangning uint16_t, ipaddr_t, uint16_t, boolean_t, boolean_t); 31787c478bd9Sstevel@tonic-gate extern uint_t ip_cksum(mblk_t *, int, uint32_t); 31797c478bd9Sstevel@tonic-gate extern int ip_close(queue_t *, int); 31807c478bd9Sstevel@tonic-gate extern uint16_t ip_csum_hdr(ipha_t *); 3181f4b3ec61Sdh155122 extern void ip_proto_not_sup(queue_t *, mblk_t *, uint_t, zoneid_t, 3182f4b3ec61Sdh155122 ip_stack_t *); 3183f4b3ec61Sdh155122 extern void ip_ire_g_fini(void); 3184f4b3ec61Sdh155122 extern void ip_ire_g_init(void); 3185f4b3ec61Sdh155122 extern void ip_ire_fini(ip_stack_t *); 3186f4b3ec61Sdh155122 extern void ip_ire_init(ip_stack_t *); 3187fc80c0dfSnordmark extern int ip_openv4(queue_t *q, dev_t *devp, int flag, int sflag, 3188fc80c0dfSnordmark cred_t *credp); 3189fc80c0dfSnordmark extern int ip_openv6(queue_t *q, dev_t *devp, int flag, int sflag, 3190fc80c0dfSnordmark cred_t *credp); 31917c478bd9Sstevel@tonic-gate extern int ip_reassemble(mblk_t *, ipf_t *, uint_t, boolean_t, ill_t *, 31927c478bd9Sstevel@tonic-gate size_t); 31937c478bd9Sstevel@tonic-gate extern int ip_opt_set_ill(conn_t *, int, boolean_t, boolean_t, 31947c478bd9Sstevel@tonic-gate int, int, mblk_t *); 31957c478bd9Sstevel@tonic-gate extern void ip_rput(queue_t *, mblk_t *); 3196605445d5Sdg199075 extern void ip_input(ill_t *, ill_rx_ring_t *, mblk_t *, 3197605445d5Sdg199075 struct mac_header_info_s *); 3198da14cebeSEric Cheng extern mblk_t *ip_accept_tcp(ill_t *, ill_rx_ring_t *, squeue_t *, 3199da14cebeSEric Cheng mblk_t *, mblk_t **, uint_t *cnt); 32007c478bd9Sstevel@tonic-gate extern void ip_rput_dlpi(queue_t *, mblk_t *); 32017c478bd9Sstevel@tonic-gate extern void ip_rput_forward(ire_t *, ipha_t *, mblk_t *, ill_t *); 32027c478bd9Sstevel@tonic-gate extern void ip_rput_forward_multicast(ipaddr_t, mblk_t *, ipif_t *); 3203ff550d0eSmasputra 32043173664eSapersson extern void ip_mib2_add_ip_stats(mib2_ipIfStatsEntry_t *, 32053173664eSapersson mib2_ipIfStatsEntry_t *); 32063173664eSapersson extern void ip_mib2_add_icmp6_stats(mib2_ipv6IfIcmpEntry_t *, 32073173664eSapersson mib2_ipv6IfIcmpEntry_t *); 32087c478bd9Sstevel@tonic-gate extern void ip_udp_input(queue_t *, mblk_t *, ipha_t *, ire_t *, ill_t *); 3209437220cdSdanmcd extern void ip_proto_input(queue_t *, mblk_t *, ipha_t *, ire_t *, ill_t *, 32104a179720Sdanmcd uint32_t); 32117c478bd9Sstevel@tonic-gate extern void ip_rput_other(ipsq_t *, queue_t *, mblk_t *, void *); 321212dfe4f0Sja97890 extern ire_t *ip_check_multihome(void *, ire_t *, ill_t *); 3213fc80c0dfSnordmark extern void ip_setpktversion(conn_t *, boolean_t, boolean_t, ip_stack_t *); 32147c478bd9Sstevel@tonic-gate extern void ip_trash_ire_reclaim(void *); 32157c478bd9Sstevel@tonic-gate extern void ip_trash_timer_expire(void *); 32167c478bd9Sstevel@tonic-gate extern void ip_wput(queue_t *, mblk_t *); 32177c478bd9Sstevel@tonic-gate extern void ip_output(void *, mblk_t *, void *, int); 321819a30e1aSrshoaib extern void ip_output_options(void *, mblk_t *, void *, int, 321919a30e1aSrshoaib ip_opt_info_t *); 32207c478bd9Sstevel@tonic-gate 32215597b60aSnordmark extern void ip_wput_ire(queue_t *, mblk_t *, ire_t *, conn_t *, int, 32225597b60aSnordmark zoneid_t); 32237c478bd9Sstevel@tonic-gate extern void ip_wput_local(queue_t *, ill_t *, ipha_t *, mblk_t *, ire_t *, 32247c478bd9Sstevel@tonic-gate int, zoneid_t); 32255597b60aSnordmark extern void ip_wput_multicast(queue_t *, mblk_t *, ipif_t *, zoneid_t); 32267c478bd9Sstevel@tonic-gate extern void ip_wput_nondata(ipsq_t *, queue_t *, mblk_t *, void *); 32277c478bd9Sstevel@tonic-gate extern void ip_wsrv(queue_t *); 32287c478bd9Sstevel@tonic-gate extern char *ip_nv_lookup(nv_t *, int); 32297c478bd9Sstevel@tonic-gate extern boolean_t ip_local_addr_ok_v6(const in6_addr_t *, const in6_addr_t *); 32307c478bd9Sstevel@tonic-gate extern boolean_t ip_remote_addr_ok_v6(const in6_addr_t *, const in6_addr_t *); 3231f4b3ec61Sdh155122 extern ipaddr_t ip_massage_options(ipha_t *, netstack_t *); 32327c478bd9Sstevel@tonic-gate extern ipaddr_t ip_net_mask(ipaddr_t); 32335c0b7edeSseb extern void ip_newroute(queue_t *, mblk_t *, ipaddr_t, conn_t *, zoneid_t, 32345c0b7edeSseb ip_stack_t *); 3235c793af95Ssangeeta extern ipxmit_state_t ip_xmit_v4(mblk_t *, ire_t *, struct ipsec_out_s *, 3236da14cebeSEric Cheng boolean_t, conn_t *); 3237f4b3ec61Sdh155122 extern int ip_hdr_complete(ipha_t *, zoneid_t, ip_stack_t *); 32387c478bd9Sstevel@tonic-gate 3239fc80c0dfSnordmark extern struct qinit iprinitv6; 3240fc80c0dfSnordmark extern struct qinit ipwinitv6; 32417c478bd9Sstevel@tonic-gate 32427c478bd9Sstevel@tonic-gate extern void conn_drain_insert(conn_t *connp); 32437c478bd9Sstevel@tonic-gate extern int conn_ipsec_length(conn_t *connp); 32447c478bd9Sstevel@tonic-gate extern void ip_wput_ipsec_out(queue_t *, mblk_t *, ipha_t *, ill_t *, 32457c478bd9Sstevel@tonic-gate ire_t *); 32467c478bd9Sstevel@tonic-gate extern ipaddr_t ip_get_dst(ipha_t *); 32477c478bd9Sstevel@tonic-gate extern int ipsec_out_extra_length(mblk_t *); 32487c478bd9Sstevel@tonic-gate extern int ipsec_in_extra_length(mblk_t *); 3249f4b3ec61Sdh155122 extern mblk_t *ipsec_in_alloc(boolean_t, netstack_t *); 32507c478bd9Sstevel@tonic-gate extern boolean_t ipsec_in_is_secure(mblk_t *); 32517c478bd9Sstevel@tonic-gate extern void ipsec_out_process(queue_t *, mblk_t *, ire_t *, uint_t); 32527c478bd9Sstevel@tonic-gate extern void ipsec_out_to_in(mblk_t *); 32537c478bd9Sstevel@tonic-gate extern void ip_fanout_proto_again(mblk_t *, ill_t *, ill_t *, ire_t *); 32547c478bd9Sstevel@tonic-gate 32557c478bd9Sstevel@tonic-gate extern void ire_cleanup(ire_t *); 32567c478bd9Sstevel@tonic-gate extern void ire_inactive(ire_t *); 3257c793af95Ssangeeta extern boolean_t irb_inactive(irb_t *); 32587c478bd9Sstevel@tonic-gate extern ire_t *ire_unlink(irb_t *); 32596a8288c7Scarlsonj 32606a8288c7Scarlsonj #ifdef DEBUG 32616a8288c7Scarlsonj extern boolean_t th_trace_ref(const void *, ip_stack_t *); 32626a8288c7Scarlsonj extern void th_trace_unref(const void *); 32636a8288c7Scarlsonj extern void th_trace_cleanup(const void *, boolean_t); 32646a8288c7Scarlsonj extern void ire_trace_ref(ire_t *); 32656a8288c7Scarlsonj extern void ire_untrace_ref(ire_t *); 32667c478bd9Sstevel@tonic-gate #endif 32677c478bd9Sstevel@tonic-gate 3268f4b3ec61Sdh155122 extern int ip_srcid_insert(const in6_addr_t *, zoneid_t, ip_stack_t *); 3269f4b3ec61Sdh155122 extern int ip_srcid_remove(const in6_addr_t *, zoneid_t, ip_stack_t *); 3270f4b3ec61Sdh155122 extern void ip_srcid_find_id(uint_t, in6_addr_t *, zoneid_t, netstack_t *); 3271f4b3ec61Sdh155122 extern uint_t ip_srcid_find_addr(const in6_addr_t *, zoneid_t, netstack_t *); 32727c478bd9Sstevel@tonic-gate extern int ip_srcid_report(queue_t *, mblk_t *, caddr_t, cred_t *); 32737c478bd9Sstevel@tonic-gate 32747c478bd9Sstevel@tonic-gate extern uint8_t ipoptp_next(ipoptp_t *); 32757c478bd9Sstevel@tonic-gate extern uint8_t ipoptp_first(ipoptp_t *, ipha_t *); 327645916cd2Sjpk extern int ip_opt_get_user(const ipha_t *, uchar_t *); 3277f4b3ec61Sdh155122 extern ill_t *ip_grab_attach_ill(ill_t *, mblk_t *, int, boolean_t, 3278f4b3ec61Sdh155122 ip_stack_t *); 32797c478bd9Sstevel@tonic-gate extern ire_t *conn_set_outgoing_ill(conn_t *, ire_t *, ill_t **); 32807c478bd9Sstevel@tonic-gate extern int ipsec_req_from_conn(conn_t *, ipsec_req_t *, int); 3281fc80c0dfSnordmark extern int ip_snmp_get(queue_t *q, mblk_t *mctl, int level); 32827c478bd9Sstevel@tonic-gate extern int ip_snmp_set(queue_t *q, int, int, uchar_t *, int); 32837c478bd9Sstevel@tonic-gate extern void ip_process_ioctl(ipsq_t *, queue_t *, mblk_t *, void *); 3284ff550d0eSmasputra extern void ip_quiesce_conn(conn_t *); 32857c478bd9Sstevel@tonic-gate extern void ip_reprocess_ioctl(ipsq_t *, queue_t *, mblk_t *, void *); 32867c478bd9Sstevel@tonic-gate extern void ip_restart_optmgmt(ipsq_t *, queue_t *, mblk_t *, void *); 3287b051ecf6Smeem extern void ip_ioctl_finish(queue_t *, mblk_t *, int, int, ipsq_t *); 32887c478bd9Sstevel@tonic-gate 328945916cd2Sjpk extern boolean_t ip_cmpbuf(const void *, uint_t, boolean_t, const void *, 329045916cd2Sjpk uint_t); 329145916cd2Sjpk extern boolean_t ip_allocbuf(void **, uint_t *, boolean_t, const void *, 329245916cd2Sjpk uint_t); 329345916cd2Sjpk extern void ip_savebuf(void **, uint_t *, boolean_t, const void *, uint_t); 329445916cd2Sjpk 32957c478bd9Sstevel@tonic-gate extern boolean_t ipsq_pending_mp_cleanup(ill_t *, conn_t *); 32967c478bd9Sstevel@tonic-gate extern void conn_ioctl_cleanup(conn_t *); 32977c478bd9Sstevel@tonic-gate extern ill_t *conn_get_held_ill(conn_t *, ill_t **, int *); 3298c793af95Ssangeeta extern ill_t *ip_newroute_get_dst_ill(ill_t *); 32997c478bd9Sstevel@tonic-gate 33007c478bd9Sstevel@tonic-gate struct multidata_s; 33017c478bd9Sstevel@tonic-gate struct pdesc_s; 33027c478bd9Sstevel@tonic-gate 33037c478bd9Sstevel@tonic-gate extern mblk_t *ip_mdinfo_alloc(ill_mdt_capab_t *); 33047c478bd9Sstevel@tonic-gate extern mblk_t *ip_mdinfo_return(ire_t *, conn_t *, char *, ill_mdt_capab_t *); 33058347601bSyl150051 extern mblk_t *ip_lsoinfo_alloc(ill_lso_capab_t *); 33068347601bSyl150051 extern mblk_t *ip_lsoinfo_return(ire_t *, conn_t *, char *, 33078347601bSyl150051 ill_lso_capab_t *); 33087c478bd9Sstevel@tonic-gate extern uint_t ip_md_cksum(struct pdesc_s *, int, uint_t); 33097c478bd9Sstevel@tonic-gate extern boolean_t ip_md_addr_attr(struct multidata_s *, struct pdesc_s *, 33107c478bd9Sstevel@tonic-gate const mblk_t *); 33117c478bd9Sstevel@tonic-gate extern boolean_t ip_md_hcksum_attr(struct multidata_s *, struct pdesc_s *, 33127c478bd9Sstevel@tonic-gate uint32_t, uint32_t, uint32_t, uint32_t); 33137c478bd9Sstevel@tonic-gate extern boolean_t ip_md_zcopy_attr(struct multidata_s *, struct pdesc_s *, 33147c478bd9Sstevel@tonic-gate uint_t); 3315*0f1702c5SYu Xiangning extern void ip_unbind(conn_t *connp); 33167c478bd9Sstevel@tonic-gate 331767c1caeeSnordmark extern phyint_t *phyint_lookup_group(char *, boolean_t, ip_stack_t *); 331867c1caeeSnordmark extern phyint_t *phyint_lookup_group_ifindex(uint_t, ip_stack_t *); 331967c1caeeSnordmark 332045916cd2Sjpk extern void tnet_init(void); 332145916cd2Sjpk extern void tnet_fini(void); 332245916cd2Sjpk 33237c478bd9Sstevel@tonic-gate /* Hooks for CGTP (multirt routes) filtering module */ 33247c478bd9Sstevel@tonic-gate #define CGTP_FILTER_REV_1 1 33257c478bd9Sstevel@tonic-gate #define CGTP_FILTER_REV_2 2 3326655a42e2Snordmark #define CGTP_FILTER_REV_3 3 3327655a42e2Snordmark #define CGTP_FILTER_REV CGTP_FILTER_REV_3 33287c478bd9Sstevel@tonic-gate 3329655a42e2Snordmark /* cfo_filter and cfo_filter_v6 hooks return values */ 33307c478bd9Sstevel@tonic-gate #define CGTP_IP_PKT_NOT_CGTP 0 33317c478bd9Sstevel@tonic-gate #define CGTP_IP_PKT_PREMIUM 1 33327c478bd9Sstevel@tonic-gate #define CGTP_IP_PKT_DUPLICATE 2 33337c478bd9Sstevel@tonic-gate 3334655a42e2Snordmark /* Version 3 of the filter interface */ 33357c478bd9Sstevel@tonic-gate typedef struct cgtp_filter_ops { 3336655a42e2Snordmark int cfo_filter_rev; /* CGTP_FILTER_REV_3 */ 3337655a42e2Snordmark int (*cfo_change_state)(netstackid_t, int); 3338655a42e2Snordmark int (*cfo_add_dest_v4)(netstackid_t, ipaddr_t, ipaddr_t, 3339655a42e2Snordmark ipaddr_t, ipaddr_t); 3340655a42e2Snordmark int (*cfo_del_dest_v4)(netstackid_t, ipaddr_t, ipaddr_t); 3341655a42e2Snordmark int (*cfo_add_dest_v6)(netstackid_t, in6_addr_t *, in6_addr_t *, 3342655a42e2Snordmark in6_addr_t *, in6_addr_t *); 3343655a42e2Snordmark int (*cfo_del_dest_v6)(netstackid_t, in6_addr_t *, in6_addr_t *); 3344655a42e2Snordmark int (*cfo_filter)(netstackid_t, uint_t, mblk_t *); 3345655a42e2Snordmark int (*cfo_filter_v6)(netstackid_t, uint_t, ip6_t *, 3346655a42e2Snordmark ip6_frag_t *); 33477c478bd9Sstevel@tonic-gate } cgtp_filter_ops_t; 33487c478bd9Sstevel@tonic-gate 33497c478bd9Sstevel@tonic-gate #define CGTP_MCAST_SUCCESS 1 33507c478bd9Sstevel@tonic-gate 3351f4b3ec61Sdh155122 /* 3352655a42e2Snordmark * The separate CGTP module needs this global symbol so that it 3353655a42e2Snordmark * can check the version and determine whether to use the old or the new 3354655a42e2Snordmark * version of the filtering interface. 3355f4b3ec61Sdh155122 */ 3356655a42e2Snordmark extern int ip_cgtp_filter_rev; 33577c478bd9Sstevel@tonic-gate 33587c478bd9Sstevel@tonic-gate extern int ip_cgtp_filter_supported(void); 3359655a42e2Snordmark extern int ip_cgtp_filter_register(netstackid_t, cgtp_filter_ops_t *); 3360655a42e2Snordmark extern int ip_cgtp_filter_unregister(netstackid_t); 3361655a42e2Snordmark extern int ip_cgtp_filter_is_registered(netstackid_t); 33627c478bd9Sstevel@tonic-gate 33637c478bd9Sstevel@tonic-gate /* Flags for ire_multirt_lookup() */ 33647c478bd9Sstevel@tonic-gate 33657c478bd9Sstevel@tonic-gate #define MULTIRT_USESTAMP 0x0001 33667c478bd9Sstevel@tonic-gate #define MULTIRT_SETSTAMP 0x0002 33677c478bd9Sstevel@tonic-gate #define MULTIRT_CACHEGW 0x0004 33687c478bd9Sstevel@tonic-gate 33697c478bd9Sstevel@tonic-gate /* Debug stuff for multirt route resolution. */ 33707c478bd9Sstevel@tonic-gate #if defined(DEBUG) && !defined(__lint) 33717c478bd9Sstevel@tonic-gate /* Our "don't send, rather drop" flag. */ 33727c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_FLAG 0x8000 33737c478bd9Sstevel@tonic-gate 33747c478bd9Sstevel@tonic-gate #define MULTIRT_TRACE(x) ip2dbg(x) 33757c478bd9Sstevel@tonic-gate 33767c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_TAG(mblk) \ 33777c478bd9Sstevel@tonic-gate do { \ 33787c478bd9Sstevel@tonic-gate ASSERT(mblk != NULL); \ 33797c478bd9Sstevel@tonic-gate MULTIRT_TRACE(("%s[%d]: tagging mblk %p, tag was %d\n", \ 33807c478bd9Sstevel@tonic-gate __FILE__, __LINE__, \ 33817c478bd9Sstevel@tonic-gate (void *)(mblk), (mblk)->b_flag & MULTIRT_DEBUG_FLAG)); \ 33827c478bd9Sstevel@tonic-gate (mblk)->b_flag |= MULTIRT_DEBUG_FLAG; \ 33837c478bd9Sstevel@tonic-gate } while (0) 33847c478bd9Sstevel@tonic-gate 33857c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_UNTAG(mblk) \ 33867c478bd9Sstevel@tonic-gate do { \ 33877c478bd9Sstevel@tonic-gate ASSERT(mblk != NULL); \ 33887c478bd9Sstevel@tonic-gate MULTIRT_TRACE(("%s[%d]: untagging mblk %p, tag was %d\n", \ 33897c478bd9Sstevel@tonic-gate __FILE__, __LINE__, \ 33907c478bd9Sstevel@tonic-gate (void *)(mblk), (mblk)->b_flag & MULTIRT_DEBUG_FLAG)); \ 33917c478bd9Sstevel@tonic-gate (mblk)->b_flag &= ~MULTIRT_DEBUG_FLAG; \ 33927c478bd9Sstevel@tonic-gate } while (0) 33937c478bd9Sstevel@tonic-gate 33947c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_TAGGED(mblk) \ 33957c478bd9Sstevel@tonic-gate (((mblk)->b_flag & MULTIRT_DEBUG_FLAG) ? B_TRUE : B_FALSE) 33967c478bd9Sstevel@tonic-gate #else 33977c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_TAG(mblk) ASSERT(mblk != NULL) 33987c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_UNTAG(mblk) ASSERT(mblk != NULL) 33997c478bd9Sstevel@tonic-gate #define MULTIRT_DEBUG_TAGGED(mblk) B_FALSE 34007c478bd9Sstevel@tonic-gate #endif 34017c478bd9Sstevel@tonic-gate 34027c478bd9Sstevel@tonic-gate /* 3403b127ac41SPhilip Kirk * IP observability hook support 3404b127ac41SPhilip Kirk */ 3405b127ac41SPhilip Kirk 3406b127ac41SPhilip Kirk /* 3407b127ac41SPhilip Kirk * ipobs_hooktype_t describes the hook types supported 3408b127ac41SPhilip Kirk * by the ip module. IPOBS_HOOK_LOCAL refers to packets 3409b127ac41SPhilip Kirk * which are looped back internally within the ip module. 3410b127ac41SPhilip Kirk */ 3411b127ac41SPhilip Kirk 3412b127ac41SPhilip Kirk typedef enum ipobs_hook_type { 3413b127ac41SPhilip Kirk IPOBS_HOOK_LOCAL, 3414b127ac41SPhilip Kirk IPOBS_HOOK_OUTBOUND, 3415b127ac41SPhilip Kirk IPOBS_HOOK_INBOUND 3416b127ac41SPhilip Kirk } ipobs_hook_type_t; 3417b127ac41SPhilip Kirk 3418b127ac41SPhilip Kirk typedef void ipobs_cbfunc_t(mblk_t *); 3419b127ac41SPhilip Kirk 3420b127ac41SPhilip Kirk typedef struct ipobs_cb { 3421b127ac41SPhilip Kirk ipobs_cbfunc_t *ipobs_cbfunc; 3422b127ac41SPhilip Kirk list_node_t ipobs_cbnext; 3423b127ac41SPhilip Kirk } ipobs_cb_t; 3424b127ac41SPhilip Kirk 3425b127ac41SPhilip Kirk /* 3426b127ac41SPhilip Kirk * This structure holds the data passed back from the ip module to 3427b127ac41SPhilip Kirk * observability consumers. 3428b127ac41SPhilip Kirk * 3429b127ac41SPhilip Kirk * ihd_mp Pointer to the IP packet. 3430b127ac41SPhilip Kirk * ihd_zsrc Source zoneid; set to ALL_ZONES when unknown. 3431b127ac41SPhilip Kirk * ihd_zdst Destination zoneid; set to ALL_ZONES when unknown. 3432b127ac41SPhilip Kirk * ihd_htype IPobs hook type, see above for the defined types. 3433b127ac41SPhilip Kirk * ihd_ipver IP version of the packet. 3434b127ac41SPhilip Kirk * ihd_ifindex Interface index that the packet was received/sent over. 3435b127ac41SPhilip Kirk * For local packets, this is the index of the interface 3436b127ac41SPhilip Kirk * associated with the local destination address. 3437b127ac41SPhilip Kirk * ihd_stack Netstack the packet is from. 3438b127ac41SPhilip Kirk */ 3439b127ac41SPhilip Kirk typedef struct ipobs_hook_data { 3440b127ac41SPhilip Kirk mblk_t *ihd_mp; 3441b127ac41SPhilip Kirk zoneid_t ihd_zsrc; 3442b127ac41SPhilip Kirk zoneid_t ihd_zdst; 3443b127ac41SPhilip Kirk ipobs_hook_type_t ihd_htype; 3444b127ac41SPhilip Kirk uint16_t ihd_ipver; 3445b127ac41SPhilip Kirk uint64_t ihd_ifindex; 3446b127ac41SPhilip Kirk netstack_t *ihd_stack; 3447b127ac41SPhilip Kirk } ipobs_hook_data_t; 3448b127ac41SPhilip Kirk 3449b127ac41SPhilip Kirk /* 34507c478bd9Sstevel@tonic-gate * Per-ILL Multidata Transmit capabilities. 34517c478bd9Sstevel@tonic-gate */ 34527c478bd9Sstevel@tonic-gate struct ill_mdt_capab_s { 34537c478bd9Sstevel@tonic-gate uint_t ill_mdt_version; /* interface version */ 34547c478bd9Sstevel@tonic-gate uint_t ill_mdt_on; /* on/off switch for MDT on this ILL */ 34557c478bd9Sstevel@tonic-gate uint_t ill_mdt_hdr_head; /* leading header fragment extra space */ 34567c478bd9Sstevel@tonic-gate uint_t ill_mdt_hdr_tail; /* trailing header fragment extra space */ 34577c478bd9Sstevel@tonic-gate uint_t ill_mdt_max_pld; /* maximum payload buffers per Multidata */ 34587c478bd9Sstevel@tonic-gate uint_t ill_mdt_span_limit; /* maximum payload span per packet */ 34597c478bd9Sstevel@tonic-gate }; 34607c478bd9Sstevel@tonic-gate 34617c478bd9Sstevel@tonic-gate struct ill_hcksum_capab_s { 34627c478bd9Sstevel@tonic-gate uint_t ill_hcksum_version; /* interface version */ 34637c478bd9Sstevel@tonic-gate uint_t ill_hcksum_txflags; /* capabilities on transmit */ 34647c478bd9Sstevel@tonic-gate }; 34657c478bd9Sstevel@tonic-gate 34667c478bd9Sstevel@tonic-gate struct ill_zerocopy_capab_s { 34677c478bd9Sstevel@tonic-gate uint_t ill_zerocopy_version; /* interface version */ 34687c478bd9Sstevel@tonic-gate uint_t ill_zerocopy_flags; /* capabilities */ 34697c478bd9Sstevel@tonic-gate }; 34707c478bd9Sstevel@tonic-gate 34718347601bSyl150051 struct ill_lso_capab_s { 34728347601bSyl150051 uint_t ill_lso_on; /* on/off switch for LSO on this ILL */ 34738347601bSyl150051 uint_t ill_lso_flags; /* capabilities */ 34748347601bSyl150051 uint_t ill_lso_max; /* maximum size of payload */ 34758347601bSyl150051 }; 34768347601bSyl150051 3477da14cebeSEric Cheng /* 3478da14cebeSEric Cheng * rr_ring_state cycles in the order shown below from RR_FREE through 3479da14cebeSEric Cheng * RR_FREE_IN_PROG and back to RR_FREE. 3480da14cebeSEric Cheng */ 3481da14cebeSEric Cheng typedef enum { 3482da14cebeSEric Cheng RR_FREE, /* Free slot */ 3483da14cebeSEric Cheng RR_SQUEUE_UNBOUND, /* Ring's squeue is unbound */ 3484da14cebeSEric Cheng RR_SQUEUE_BIND_INPROG, /* Ring's squeue bind in progress */ 3485da14cebeSEric Cheng RR_SQUEUE_BOUND, /* Ring's squeue bound to cpu */ 3486da14cebeSEric Cheng RR_FREE_INPROG /* Ring is being freed */ 3487da14cebeSEric Cheng } ip_ring_state_t; 34887c478bd9Sstevel@tonic-gate 34897c478bd9Sstevel@tonic-gate #define ILL_MAX_RINGS 256 /* Max num of rx rings we can manage */ 34907c478bd9Sstevel@tonic-gate #define ILL_POLLING 0x01 /* Polling in use */ 34917c478bd9Sstevel@tonic-gate 34927c478bd9Sstevel@tonic-gate /* 34934b46d1efSkrgopi * These functions pointer types are exported by the mac/dls layer. 34944b46d1efSkrgopi * we need to duplicate the definitions here because we cannot 34954b46d1efSkrgopi * include mac/dls header files here. 34967c478bd9Sstevel@tonic-gate */ 3497da14cebeSEric Cheng typedef void *ip_mac_tx_cookie_t; 3498da14cebeSEric Cheng typedef void (*ip_mac_intr_disable_t)(void *); 3499da14cebeSEric Cheng typedef void (*ip_mac_intr_enable_t)(void *); 3500da14cebeSEric Cheng typedef void *(*ip_dld_tx_t)(void *, mblk_t *, uint64_t, uint16_t); 3501da14cebeSEric Cheng typedef void (*ip_flow_enable_t)(void *, ip_mac_tx_cookie_t); 3502da14cebeSEric Cheng typedef void *(*ip_dld_callb_t)(void *, ip_flow_enable_t, void *); 3503da14cebeSEric Cheng typedef int (*ip_capab_func_t)(void *, uint_t, void *, uint_t); 35044b46d1efSkrgopi 3505da14cebeSEric Cheng /* 3506da14cebeSEric Cheng * POLLING README 3507da14cebeSEric Cheng * sq_get_pkts() is called to pick packets from softring in poll mode. It 3508da14cebeSEric Cheng * calls rr_rx to get the chain and process it with rr_ip_accept. 3509da14cebeSEric Cheng * rr_rx = mac_soft_ring_poll() to pick packets 3510da14cebeSEric Cheng * rr_ip_accept = ip_accept_tcp() to process packets 3511da14cebeSEric Cheng */ 35127c478bd9Sstevel@tonic-gate 3513da14cebeSEric Cheng /* 3514da14cebeSEric Cheng * XXX: With protocol, service specific squeues, they will have 3515da14cebeSEric Cheng * specific acceptor functions. 3516da14cebeSEric Cheng */ 3517da14cebeSEric Cheng typedef mblk_t *(*ip_mac_rx_t)(void *, size_t); 3518da14cebeSEric Cheng typedef mblk_t *(*ip_accept_t)(ill_t *, ill_rx_ring_t *, 3519da14cebeSEric Cheng squeue_t *, mblk_t *, mblk_t **, uint_t *); 3520da14cebeSEric Cheng 3521da14cebeSEric Cheng /* 3522da14cebeSEric Cheng * rr_intr_enable, rr_intr_disable, rr_rx_handle, rr_rx: 3523da14cebeSEric Cheng * May be accessed while in the squeue AND after checking that SQS_POLL_CAPAB 3524da14cebeSEric Cheng * is set. 3525da14cebeSEric Cheng * 3526da14cebeSEric Cheng * rr_ring_state: Protected by ill_lock. 3527da14cebeSEric Cheng */ 35287c478bd9Sstevel@tonic-gate struct ill_rx_ring { 3529da14cebeSEric Cheng ip_mac_intr_disable_t rr_intr_disable; /* Interrupt disabling func */ 3530da14cebeSEric Cheng ip_mac_intr_enable_t rr_intr_enable; /* Interrupt enabling func */ 3531da14cebeSEric Cheng void *rr_intr_handle; /* Handle interrupt funcs */ 3532da14cebeSEric Cheng ip_mac_rx_t rr_rx; /* Driver receive function */ 3533da14cebeSEric Cheng ip_accept_t rr_ip_accept; /* IP accept function */ 3534da14cebeSEric Cheng void *rr_rx_handle; /* Handle for Rx ring */ 35357c478bd9Sstevel@tonic-gate squeue_t *rr_sqp; /* Squeue the ring is bound to */ 35367c478bd9Sstevel@tonic-gate ill_t *rr_ill; /* back pointer to ill */ 3537da14cebeSEric Cheng ip_ring_state_t rr_ring_state; /* State of this ring */ 35387c478bd9Sstevel@tonic-gate }; 35397c478bd9Sstevel@tonic-gate 3540da14cebeSEric Cheng /* 3541da14cebeSEric Cheng * IP - DLD direct function call capability 3542da14cebeSEric Cheng * Suffixes, df - dld function, dh - dld handle, 3543da14cebeSEric Cheng * cf - client (IP) function, ch - client handle 3544da14cebeSEric Cheng */ 3545da14cebeSEric Cheng typedef struct ill_dld_direct_s { /* DLD provided driver Tx */ 3546da14cebeSEric Cheng ip_dld_tx_t idd_tx_df; /* str_mdata_fastpath_put */ 3547da14cebeSEric Cheng void *idd_tx_dh; /* dld_str_t *dsp */ 3548da14cebeSEric Cheng ip_dld_callb_t idd_tx_cb_df; /* mac_tx_srs_notify */ 3549da14cebeSEric Cheng void *idd_tx_cb_dh; /* mac_client_handle_t *mch */ 3550da14cebeSEric Cheng } ill_dld_direct_t; 3551da14cebeSEric Cheng 3552da14cebeSEric Cheng /* IP - DLD polling capability */ 3553da14cebeSEric Cheng typedef struct ill_dld_poll_s { 3554da14cebeSEric Cheng ill_rx_ring_t idp_ring_tbl[ILL_MAX_RINGS]; 3555da14cebeSEric Cheng } ill_dld_poll_t; 3556da14cebeSEric Cheng 3557da14cebeSEric Cheng /* Describes ill->ill_dld_capab */ 3558da14cebeSEric Cheng struct ill_dld_capab_s { 3559da14cebeSEric Cheng ip_capab_func_t idc_capab_df; /* dld_capab_func */ 3560da14cebeSEric Cheng void *idc_capab_dh; /* dld_str_t *dsp */ 3561da14cebeSEric Cheng ill_dld_direct_t idc_direct; 3562da14cebeSEric Cheng ill_dld_poll_t idc_poll; 35637c478bd9Sstevel@tonic-gate }; 35647c478bd9Sstevel@tonic-gate 35657c478bd9Sstevel@tonic-gate /* 35667c478bd9Sstevel@tonic-gate * IP squeues exports 35677c478bd9Sstevel@tonic-gate */ 35687c478bd9Sstevel@tonic-gate extern boolean_t ip_squeue_fanout; 35697c478bd9Sstevel@tonic-gate 3570da14cebeSEric Cheng #define IP_SQUEUE_GET(hint) ip_squeue_random(hint) 35717c478bd9Sstevel@tonic-gate 35727c478bd9Sstevel@tonic-gate extern void ip_squeue_init(void (*)(squeue_t *)); 35737c478bd9Sstevel@tonic-gate extern squeue_t *ip_squeue_random(uint_t); 35747c478bd9Sstevel@tonic-gate extern squeue_t *ip_squeue_get(ill_rx_ring_t *); 3575da14cebeSEric Cheng extern squeue_t *ip_squeue_getfree(pri_t); 3576da14cebeSEric Cheng extern int ip_squeue_cpu_move(squeue_t *, processorid_t); 3577da14cebeSEric Cheng extern void *ip_squeue_add_ring(ill_t *, void *); 3578da14cebeSEric Cheng extern void ip_squeue_bind_ring(ill_t *, ill_rx_ring_t *, processorid_t); 3579da14cebeSEric Cheng extern void ip_squeue_clean_ring(ill_t *, ill_rx_ring_t *); 3580da14cebeSEric Cheng extern void ip_squeue_quiesce_ring(ill_t *, ill_rx_ring_t *); 3581da14cebeSEric Cheng extern void ip_squeue_restart_ring(ill_t *, ill_rx_ring_t *); 35828df01f76Smeem extern void ip_squeue_clean_all(ill_t *); 35837c478bd9Sstevel@tonic-gate 3584ff550d0eSmasputra extern void tcp_wput(queue_t *, mblk_t *); 3585ff550d0eSmasputra 35867c478bd9Sstevel@tonic-gate extern int ip_fill_mtuinfo(struct in6_addr *, in_port_t, 3587f4b3ec61Sdh155122 struct ip6_mtuinfo *, netstack_t *); 3588ff550d0eSmasputra extern ipif_t *conn_get_held_ipif(conn_t *, ipif_t **, int *); 3589b127ac41SPhilip Kirk extern void ipobs_register_hook(netstack_t *, ipobs_cbfunc_t *); 3590b127ac41SPhilip Kirk extern void ipobs_unregister_hook(netstack_t *, ipobs_cbfunc_t *); 3591b127ac41SPhilip Kirk extern void ipobs_hook(mblk_t *, int, zoneid_t, zoneid_t, const ill_t *, int, 3592b127ac41SPhilip Kirk uint32_t, ip_stack_t *); 35937c478bd9Sstevel@tonic-gate typedef void (*ipsq_func_t)(ipsq_t *, queue_t *, mblk_t *, void *); 35947c478bd9Sstevel@tonic-gate 35957c478bd9Sstevel@tonic-gate /* 35967c478bd9Sstevel@tonic-gate * Squeue tags. Tags only need to be unique when the callback function is the 35977c478bd9Sstevel@tonic-gate * same to distinguish between different calls, but we use unique tags for 35987c478bd9Sstevel@tonic-gate * convenience anyway. 35997c478bd9Sstevel@tonic-gate */ 36007c478bd9Sstevel@tonic-gate #define SQTAG_IP_INPUT 1 36017c478bd9Sstevel@tonic-gate #define SQTAG_TCP_INPUT_ICMP_ERR 2 36027c478bd9Sstevel@tonic-gate #define SQTAG_TCP6_INPUT_ICMP_ERR 3 36037c478bd9Sstevel@tonic-gate #define SQTAG_IP_TCP_INPUT 4 36047c478bd9Sstevel@tonic-gate #define SQTAG_IP6_TCP_INPUT 5 36057c478bd9Sstevel@tonic-gate #define SQTAG_IP_TCP_CLOSE 6 36067c478bd9Sstevel@tonic-gate #define SQTAG_TCP_OUTPUT 7 36077c478bd9Sstevel@tonic-gate #define SQTAG_TCP_TIMER 8 36087c478bd9Sstevel@tonic-gate #define SQTAG_TCP_TIMEWAIT 9 36097c478bd9Sstevel@tonic-gate #define SQTAG_TCP_ACCEPT_FINISH 10 36107c478bd9Sstevel@tonic-gate #define SQTAG_TCP_ACCEPT_FINISH_Q0 11 36117c478bd9Sstevel@tonic-gate #define SQTAG_TCP_ACCEPT_PENDING 12 36127c478bd9Sstevel@tonic-gate #define SQTAG_TCP_LISTEN_DISCON 13 36130163a147Sjprakash #define SQTAG_TCP_CONN_REQ_1 14 36147c478bd9Sstevel@tonic-gate #define SQTAG_TCP_EAGER_BLOWOFF 15 36157c478bd9Sstevel@tonic-gate #define SQTAG_TCP_EAGER_CLEANUP 16 36167c478bd9Sstevel@tonic-gate #define SQTAG_TCP_EAGER_CLEANUP_Q0 17 36177c478bd9Sstevel@tonic-gate #define SQTAG_TCP_CONN_IND 18 36187c478bd9Sstevel@tonic-gate #define SQTAG_TCP_RSRV 19 36197c478bd9Sstevel@tonic-gate #define SQTAG_TCP_ABORT_BUCKET 20 36207c478bd9Sstevel@tonic-gate #define SQTAG_TCP_REINPUT 21 36217c478bd9Sstevel@tonic-gate #define SQTAG_TCP_REINPUT_EAGER 22 36227c478bd9Sstevel@tonic-gate #define SQTAG_TCP_INPUT_MCTL 23 36237c478bd9Sstevel@tonic-gate #define SQTAG_TCP_RPUTOTHER 24 36247c478bd9Sstevel@tonic-gate #define SQTAG_IP_PROTO_AGAIN 25 36257c478bd9Sstevel@tonic-gate #define SQTAG_IP_FANOUT_TCP 26 36267c478bd9Sstevel@tonic-gate #define SQTAG_IPSQ_CLEAN_RING 27 36277c478bd9Sstevel@tonic-gate #define SQTAG_TCP_WPUT_OTHER 28 36287c478bd9Sstevel@tonic-gate #define SQTAG_TCP_CONN_REQ_UNBOUND 29 36297c478bd9Sstevel@tonic-gate #define SQTAG_TCP_SEND_PENDING 30 3630ff550d0eSmasputra #define SQTAG_BIND_RETRY 31 3631ff550d0eSmasputra #define SQTAG_UDP_FANOUT 32 3632ff550d0eSmasputra #define SQTAG_UDP_INPUT 33 3633ff550d0eSmasputra #define SQTAG_UDP_WPUT 34 3634ff550d0eSmasputra #define SQTAG_UDP_OUTPUT 35 3635c28749e9Skais #define SQTAG_TCP_KSSL_INPUT 36 3636866ba9ddSjprakash #define SQTAG_TCP_DROP_Q0 37 36370163a147Sjprakash #define SQTAG_TCP_CONN_REQ_2 38 3638da14cebeSEric Cheng #define SQTAG_IP_INPUT_RX_RING 39 3639da14cebeSEric Cheng #define SQTAG_SQUEUE_CHANGE 40 3640da14cebeSEric Cheng #define SQTAG_CONNECT_FINISH 41 3641*0f1702c5SYu Xiangning #define SQTAG_SYNCHRONOUS_OP 42 3642*0f1702c5SYu Xiangning #define SQTAG_TCP_SHUTDOWN_OUTPUT 43 36437c478bd9Sstevel@tonic-gate 364419a30e1aSrshoaib #define NOT_OVER_IP(ip_wq) \ 364519a30e1aSrshoaib (ip_wq->q_next != NULL || \ 364619a30e1aSrshoaib (ip_wq->q_qinfo->qi_minfo->mi_idname) == NULL || \ 364719a30e1aSrshoaib strcmp(ip_wq->q_qinfo->qi_minfo->mi_idname, \ 364819a30e1aSrshoaib IP_MOD_NAME) != 0 || \ 364919a30e1aSrshoaib ip_wq->q_qinfo->qi_minfo->mi_idnum != IP_MOD_ID) 365019a30e1aSrshoaib 3651*0f1702c5SYu Xiangning #define PROTO_FLOW_CNTRLD(connp) (connp->conn_flow_cntrld) 36527c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 36537c478bd9Sstevel@tonic-gate 36547c478bd9Sstevel@tonic-gate #ifdef __cplusplus 36557c478bd9Sstevel@tonic-gate } 36567c478bd9Sstevel@tonic-gate #endif 36577c478bd9Sstevel@tonic-gate 36587c478bd9Sstevel@tonic-gate #endif /* _INET_IP_H */ 3659