ip.h revision 0a0e9771ca0211c15f3ac4466b661c145feeb9e4
1N/A * The contents of this file are subject to the terms of the 1N/A * Common Development and Distribution License (the "License"). 1N/A * You may not use this file except in compliance with the License. 1N/A * See the License for the specific language governing permissions 1N/A * and limitations under the License. 1N/A * When distributing Covered Code, include this CDDL HEADER in each 1N/A * If applicable, add the following below this CDDL HEADER, with the 1N/A * fields enclosed by brackets "[]" replaced with your own identifying 1N/A * information: Portions Copyright [yyyy] [name of copyright owner] 1N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 1N/A * Use is subject to license terms. 1N/A/* Copyright (c) 1990 Mentat Inc. */ * The mt-streams(9F) flags for the IP module; put here so that other * "drivers" that are actually IP (e.g., ICMP, UDP) can use the same set /* Number of bits in an address */ * Flag to IP write side to indicate that the appln has sent in a pre-built * IP header. Stored in ipha_ident (which is otherwise zero). * XXX IP_MAXPACKET is defined in <netinet/ip.h> as well. At some point the * 2 files should be cleaned up to remove all redundant definitions. /* Leave room for ip_newroute to tack on the src and target addresses */ * Constants and type definitions to support IP IOCTL commands /* Common definitions used by IP IOCTL data structures */ /* IP IRE Change Command Structure. */ /* IP IRE Delete Command Structure. */ * Temporary state for ip options parser. * Flag(s) for ipoptp_flags /* Controls forwarding of IP packets, set via ndd */ * IP reassembly macros. We hide starting and ending offsets in b_next and * b_prev of messages on the reassembly queue. The messages are chained using * b_cont. These macros are used in ip_reassemble() so we don't have to see * the ugly casts and assignments. * Note that the offsets are <= 64k i.e. a uint_t is sufficient to represent * Test to determine whether this is a module instance of IP or a * The following two macros are used by IP to get the appropriate * wq and rq for a conn. If it is a TCP conn, then we need * from a conn directly if it knows that the conn is not TCP. /* "Congestion controlled" protocol */ * Complete the pending operation. Usually an ioctl. Can also * be a bind or option management request that got enqueued * in an ipsq_t. Called on completion of the operation. * Flags for the various ip_fanout_* routines. #
define IP_FF_CKSUM 0x04 /* Recompute ipha_cksum if error */ * Following flags are used by IPQoS to determine if policy processing is * Values for squeue switch: * This is part of the interface between Transport provider and * IP which can be used to set policy information. This is usually * only IPSEC_POLICY_SET is there when it is found in the chain. * The information contained is an struct ipsec_req_t. On success * or failure, either the T_BIND_ACK or the T_ERROR_ACK is returned. * IPSEC_POLICY_SET is never returned. /* IP Fragmentation Reassembly Header */ int ipf_end;
/* Tail end offset (0 -> hard-case). */ * NCE_EXPIRED is TRUE when we have a non-permanent nce that was * found to be REACHABLE more than ip_ire_arp_interval ms ago. * This macro is used to age existing nce_t entries. The * nce's will get cleaned up in the following circumstances: * - ip_ire_trash_reclaim will free nce's using ndp_cache_reclaim * - ip_arp_news, when updates are received. * - if the nce is NCE_EXPIRED(), it will deleted, so that a new * arp request will need to be triggered from an ND_INITIAL nce. * Note that the nce state transition follows the pattern: * ND_INITIAL -> ND_INCOMPLETE -> ND_REACHABLE * after which the nce is deleted when it has expired. * nce_last is the timestamp that indicates when the nce_res_mp in the * nce_t was last updated to a valid link-layer address. nce_last gets * - when the nce is created * - every time we get a sane arp response for the nce. /* Evaluates to true if the ICMP type is an ICMP error */ /* ICMP_TIME_EXCEEDED codes */ /* ICMP_DEST_UNREACHABLE codes */ /* ICMP Header Structure */ struct {
/* Destination unreachable structure */ struct {
/* Parameter problem structure */ struct {
/* Redirect structure */ * Minimum length of transport layer header included in an ICMP error * message for it to be considered valid. * Some of these constant names are copied for the DTrace IP provider in #
define IPH_DF 0x4000 /* Don't fragment */#
define IPH_MF 0x2000 /* More fragments to come */#
define IPH_OFFSET 0x1FFF /* Where the offset lives *//* ECN code points for IPv4 TOS byte and IPv6 traffic class octet. */ #
define IPH_ECN_ECT1 0x1 /* ECN-Capable Transport, ECT(1) */#
define IPH_ECN_ECT0 0x2 /* ECN-Capable Transport, ECT(0) */#
define IPH_ECN_CE 0x3 /* ECN-Congestion Experienced (CE) *//* IP Mac info structure */ * The following functions attempt to reduce the link layer dependency * of the IP stack. The current set of link specific operations are: * a. map from IPv4 class D (224.0/4) multicast address range to the link * layer multicast address range. * b. map from IPv6 multicast address range (ff00::/8) to the link * layer multicast address range. * c. derive the default IPv6 interface identifier from the interface. * d. derive the default IPv6 destination interface identifier from * the interface (point-to-point only). /* ip_m_v6*intfid return void and are never NULL */ #
define IRE_BROADCAST 0x0001 /* Route entry for broadcast address */#
define IRE_DEFAULT 0x0002 /* Route entry for default gateway */#
define IRE_LOCAL 0x0004 /* Route entry for local address */#
define IRE_LOOPBACK 0x0008 /* Route entry for loopback address */#
define IRE_PREFIX 0x0010 /* Route entry for prefix routes */#
define IRE_CACHE 0x0020 /* Cached Route entry */ /* net without any address mapping. */ #
define IRE_HOST 0x0100 /* Host route entry */ * If an IRE is marked with IRE_MARK_CONDEMNED, the last walker of * the bucket should delete this IRE from this bucket. * An IRE with IRE_MARK_PMTU has ire_max_frag set from an ICMP error. * An IRE with IRE_MARK_TESTHIDDEN is used by in.mpathd for test traffic. It * can only be looked up by requesting MATCH_IRE_MARK_TESTHIDDEN. * An IRE with IRE_MARK_NOADD is created in ip_newroute_ipif when the outgoing * interface is specified by e.g. IP_PKTINFO. The IRE is not added to the IRE * IRE marked with IRE_MARK_TEMPORARY means that this IRE has been used * either for forwarding a packet or has not been used for sending * traffic on TCP connections terminated on this system. In both * cases, this IRE is the first to go when IRE is being cleaned up. * IRE marked with IRE_MARK_USESRC_CHECK means that while adding an IRE with * this mark, additional atomic checks need to be performed. For eg: by the * time an IRE_CACHE is created, sent up to ARP and then comes back to IP; the * usesrc grouping could have changed in which case we want to fail adding * IRE_MARK_PRIVATE_ADDR is used for IP_NEXTHOP. When IP_NEXTHOP is set, the * routing table lookup for the destination is bypassed and the packet is * sent directly to the specified nexthop. The associated IRE_CACHE entries * should be marked with IRE_MARK_PRIVATE_ADDR flag so that they don't show up * in regular ire cache lookups. * When we send an ARP resolution query for the nexthop gateway's ire, * we use esballoc to create the ire_t in the AR_ENTRY_QUERY mblk * chain, and mark its ire_marks with IRE_MARK_UNCACHED. This flag * indicates that information from ARP has not been transferred to a * permanent IRE_CACHE entry. The flag is reset only when the * information is successfully transferred to an ire_cache entry (in * ire_add()). Attempting to free the AR_ENTRY_QUERY mblk chain prior * to ire_add (e.g., from arp, or from ip`ip_wput_nondata) will * require that the resources (incomplete ire_cache and/or nce) must * be cleaned up. The free callback routine (ire_freemblk()) checks * for IRE_MARK_UNCACHED to see if any resources that are pinned down * will need to be cleaned up or not. * The comment below (and for other netstack_t references) refers * to the fact that we only do netstack_hold in particular cases, * such as the references from open streams (ill_t and conn_t's * pointers). Internally within IP we rely on IP's ability to cleanup e.g. * ire_t's when an ill goes away. /* Flags with ire_expire routine */ /* Arguments to ire_flush_cache() */ * These are kept in a separate field in the conn and the synchronization * depends on the atomic 32 bit access to that field. #
define CONN_CLOSING 0x01 /* ip_close waiting for ip_wsrv *//* Used to check connection state flags before caching the IRE */ * Parameter to ip_output giving the identity of the caller. * IP_WSRV means the packet was enqueued in the STREAMS queue * due to flow control and is now being reprocessed in the context of * the STREAMS service procedure, consequent to flow control relief. * IRE_SEND means the packet is being reprocessed consequent to an * ire cache creation and addition and this may or may not be happening * in the service procedure context. Anything other than the above 2 * cases is identified as IP_WPUT. Most commonly this is the case of * packets coming down from the application. #
define IP_WSRV 1 /* Called from ip_wsrv */#
define IP_WPUT 2 /* Called from ip_wput */#
define IRE_SEND 3 /* Called from ire_send */ * Extra structures need for per-src-addr filtering (IGMPv3/MLDv2) * Following struct is used to maintain retransmission state for * a multicast group. One rtx_state_t struct is an in-line field * of the ilm_t struct; the slist_ts in the rtx_state_t struct are * Used to construct list of multicast address records that will be * sent in a single listener report. /* Group membership list per upper conn */ * XXX can we make ilg survive an ifconfig unplumb + plumb * by setting the ipif/ill to NULL and recover that later? * ilg_ipif is used by IPv4 as multicast groups are joined using an interface * ilg_ill is used by IPv6 as multicast groups are joined using an interface * index (phyint->phyint_ifindex). * ilg_ill is NULL for IPv4 and ilg_ipif is NULL for IPv6. * ilg records the state of multicast memberships of a socket end point. * ilm records the state of multicast memberships with the driver and is * maintained per interface. * There is no direct link between a given ilg and ilm. If the * application has joined a group G with ifindex I, we will have * an ilg with ilg_v6group and ilg_ill. There will be a corresponding * To delete the membership: * a) Search for ilg matching on G and I with ilg_v6group * and ilg_ill. Delete ilg_ill. * b) Search the corresponding ilm matching on G and I with * ilm_v6addr and ilm_ill. Delete ilm. * For IPv4 the only difference is that we look using ipifs, not ills. * The ilg_t and ilm_t members are protected by ipsq. They can be changed only * by a thread executing in the ipsq. In other words add/delete of a * multicast group has to execute in the ipsq. * Multicast address list entry for ill. * ilm_ipif is used by IPv4 as multicast groups are joined using ipif. * ilm_ill is used by IPv6 as multicast groups are joined using ill. * ilm_ill is NULL for IPv4 and ilm_ipif is NULL for IPv6. * The comment below (and for other netstack_t references) refers * to the fact that we only do netstack_hold in particular cases, * such as the references from open streams (ill_t and conn_t's * pointers). Internally within IP we rely on IP's ability to cleanup e.g. * ire_t's when an ill goes away. * Soft reference to an IPsec SA. * On relative terms, conn's can be persistent (living as long as the * processes which create them), while SA's are ephemeral (dying when * they hit their time-based or byte-based lifetimes). * We could hold a hard reference to an SA from an ipsec_latch_t, * but this would cause expired SA's to linger for a potentially * Instead, we remember the hash bucket number and bucket generation * in addition to the pointer. The bucket generation is incremented on * IPsec "latching" state. * In the presence of IPsec policy, fully-bound conn's bind a connection * to more than just the 5-tuple, but also a specific IPsec action and * As an optimization, we also cache soft references to IPsec SA's * here so that we can fast-path around most of the work needed for * outbound IPsec SA selection. * Were it not for TCP's detached connections, this state would be * in-line in conn_t; instead, this is in a separate structure so it * can be handed off to TCP when a connection is detached. * peer identity structure. * The old IP client structure "ipc_t" is gone. All the data is stored in the * connection structure "conn_t" now. The mapping of old and new fields looks * ipc_ire_cache conn_ire_cache * ipc_state_flags conn_state_flags * ipc_outgoing_ill conn_outgoing_ill * ipc_dontroute conn_dontroute * ipc_loopback conn_loopback * ipc_broadcast conn_broadcast * ipc_reuseaddr conn_reuseaddr * ipc_multicast_loop conn_multicast_loop * ipc_multi_router conn_multi_router * ipc_draining conn_draining * ipc_did_putbq conn_did_putbq * ipc_unspec_src conn_unspec_src * ipc_policy_cached conn_policy_cached * ipc_in_enforce_policy conn_in_enforce_policy * ipc_out_enforce_policy conn_out_enforce_policy * ipc_af_isv6 conn_af_isv6 * ipc_pkt_isv6 conn_pkt_isv6 * ipc_ipv6_recvpktinfo conn_ipv6_recvpktinfo * ipc_ipv6_recvhoplimit conn_ipv6_recvhoplimit * ipc_ipv6_recvhopopts conn_ipv6_recvhopopts * ipc_ipv6_recvdstopts conn_ipv6_recvdstopts * ipc_ipv6_recvrthdr conn_ipv6_recvrthdr * ipc_ipv6_recvrtdstopts conn_ipv6_recvrtdstopts * ipc_fully_bound conn_fully_bound * ipc_recvslla conn_recvslla * ipc_acking_unbind conn_acking_unbind * ipc_pad_to_bit_31 conn_pad_to_bit_31 * ipc_incoming_ill conn_incoming_ill * ipc_pending_ill conn_pending_ill * ipc_unbind_mp conn_unbind_mp * ipc_ilg_allocated conn_ilg_allocated * ipc_ilg_inuse conn_ilg_inuse * ipc_ilg_walker_cnt conn_ilg_walker_cnt * ipc_multicast_ipif conn_multicast_ipif * ipc_multicast_ill conn_multicast_ill * ipc_drain_next conn_drain_next * ipc_drain_prev conn_drain_prev * Note that we put v4 addresses in the *first* 32-bit word of the * selector rather than the last to simplify the prefix match/mask code /* Values used in IP by IPSEC Code */ * There are two variants in policy failures. The packet may come in * secure when not needed (IPSEC_POLICY_???_NOT_NEEDED) or it may not * have the desired level of protection (IPSEC_POLICY_MISMATCH). * Folowing macro is used whenever the code does not know whether there * is a M_CTL present in the front and it needs to examine the actual mp * i.e the IP header. As a M_CTL message could be in the front, this * extracts the packet into mp and the M_CTL mp into first_mp. If M_CTL * mp is not present, both first_mp and mp point to the same message. * Check with IPSEC inbound policy if * 1) per-socket policy is present - indicated by conn_in_enforce_policy. * 2) Or if we have not cached policy on the conn and the global policy is * Information cached in IRE for upper layer protocol (ULP). * Notice that ire_max_frag is not included in the iulp_t structure, which * it may seem that it should. But ire_max_frag cannot really be cached. It * is fixed for each interface. For MTU found by PMTUd, we may want to cache * it. But currently, we do not do that. * The conn drain list structure (idl_t). * The list is protected by idl_lock. Each conn_t inserted in the list * points back at this idl_t using conn_idl. IP primes the draining of the * conns queued in these lists, by qenabling the 1st conn of each list. This * occurs when STREAMS backenables ip_wsrv on the IP module. Each conn instance * of ip_wsrv successively qenables the next conn in the list. * idl_lock protects all other members of idl_t and conn_drain_next * and conn_drain_prev of conn_t. The conn_lock protects IPCF_DRAIN_DISABLED * flag of the conn_t and conn_idl. * The conn drain list, idl_t, itself is part of tx cookie list structure. * A tx cookie list points to a blocked Tx ring and contains the list of * all conn's that are blocked due to the flow-controlled Tx ring (via * the idl drain list). Note that a link can have multiple Tx rings. The * drain list will store the conn's blocked due to Tx ring being flow * Interface route structure which holds the necessary information to recreate * routes that are tied to an interface (namely where ire_ipif != NULL). * These routes which were initially created via a routing socket or via the * SIOCADDRT ioctl may be gateway routes (RTF_GATEWAY being set) or may be * traditional interface routes. When an interface comes back up after being * marked down, this information will be used to recreate the routes. These * are part of an mblk_t chain that hangs off of the IPIF (ipif_saved_ire_mp). /* Number of IP addresses that can be hosted on a physical interface */ * Number of Source addresses to be considered for source address * selection. Used by ipif_select_source[_v6]. * Trace refholds and refreles for debugging. /* The following are ipif_state_flags */ /* IP interface structure, one per local address */ int ipif_id;
/* Logical unit number */ /* prevent awkward out of mem */ /* on this interface so that they */ /* can survive ifconfig down. */ /* will be reported on. Used when */ /* handling an igmp timeout. */ * The packet counts in the ipif contain the sum of the * packet counts in dead IREs that were affiliated with /* Exclusive bit fields, protected by ipsq_t */ /* Number of ire's and ilm's referencing this ipif */ * For an IPMP interface, ipif_bound_ill tracks the ill whose hardware * information this ipif is associated with via ARP/NDP. We can use * an ill pointer (rather than an index) because only ills that are * part of a group will be pointed to, and an ill cannot disappear * IPIF_FREE_OK() means that there are no incoming references * to the ipif. Incoming refs would prevent the ipif from being freed. * IPIF_DOWN_OK() determines whether the incoming pointer reference counts * would permit the ipif to be considered quiescent. In order for * an ipif or ill to be considered quiescent, the ire and nce references * We do not require the ilm references to go to zero for quiescence * because the quiescence checks are done to ensure that * outgoing packets do not use addresses from the ipif/ill after it * has been marked down, and incoming packets to addresses on a * queiscent interface are rejected. This implies that all the * ire/nce's using that source address need to be deleted and future * creation of any ires using that source address must be prevented. * Similarly incoming unicast packets destined to the 'down' address * will not be accepted once that ire is gone. However incoming * multicast packets are not destined to the downed address. * They are only related to the ill in question. Furthermore * the current API behavior allows applications to join or leave * multicast groups, i.e., IP_ADD_MEMBERSHIP / LEAVE_MEMBERSHIP, using a * down address. Therefore the ilm references are not included in * The following table lists the protection levels of the various members * of the ipif_t. The following notation is used. * Write once - Written to only once at the time of bringing up * the interface and can be safely read after the bringup without any lock. * ipsq - Need to execute in the ipsq to perform the indicated access. * ill_lock - Need to hold this mutex to perform the indicated access. * ill_g_lock - Need to hold this rw lock as reader/writer for read access or * write access respectively. * down ill - Written to only when the ill is down (i.e all ipifs are down) * up ill - Read only when the ill is up (i.e. at least 1 ipif is up) * Table of ipif_t members and their protection * ipif_next ipsq + ill_lock + ipsq OR ill_lock OR * ipif_ill ipsq + down ipif write once * ipif_id ipsq + down ipif write once * ipif_v6lcl_addr ipsq + down ipif up ipif * ipif_v6src_addr ipsq + down ipif up ipif * ipif_v6subnet ipsq + down ipif up ipif * ipif_v6net_mask ipsq + down ipif up ipif * ipif_flags ill_lock ill_lock * ipif_ire_type ipsq + down ill up ill * ipif_arp_del_mp ipsq ipsq * ipif_saved_ire_mp ipif_saved_ire_lock ipif_saved_ire_lock * ipif_igmp_rpt ipsq ipsq * ipif_fo_pkt_count Approx * ipif_ib_pkt_count Approx * ipif_ob_pkt_count Approx * bit fields ill_lock ill_lock * ipif_seqid ipsq Write once * ipif_state_flags ill_lock ill_lock * ipif_refcnt ill_lock ill_lock * ipif_ire_cnt ill_lock ill_lock * ipif_ilm_cnt ill_lock ill_lock * ipif_bound_ill ipsq + ipmp_lock ipsq OR ipmp_lock * ipif_bound_next ipsq ipsq /* IPv4 compatibility macros */ /* Macros for easy backreferences to the ill. */ #
define SIOCLIFADDR_NDX 112 /* ndx of SIOCLIFADDR in the ndx ioctl table */ * mode value for ip_ioctl_finish for finishing an ioctl #
define COPYOUT 2 /* do an mi_copyout if needed */ * The IP-MT design revolves around the serialization objects ipsq_t (IPSQ) * and ipxop_t (exclusive operation or "xop"). Becoming "writer" on an IPSQ * ensures that no other threads can become "writer" on any IPSQs sharing that * IPSQ's xop until the writer thread is done. * Each phyint points to one IPSQ that remains fixed over the phyint's life. * Each IPSQ points to one xop that can change over the IPSQ's life. If a * phyint is *not* in an IPMP group, then its IPSQ will refer to the IPSQ's * "own" xop (ipsq_ownxop). If a phyint *is* part of an IPMP group, then its * IPSQ will refer to the "group" xop, which is shorthand for the xop of the * IPSQ of the IPMP meta-interface's phyint. Thus, all phyints that are part * of the same IPMP group will have their IPSQ's point to the group xop, and * thus becoming "writer" on any phyint in the group will prevent any other * writer on any other phyint in the group. All IPSQs sharing the same xop * are chained together through ipsq_next (in the degenerate common case, * ipsq_next simply refers to itself). Note that the group xop is guaranteed * to exist at least as long as there are members in the group, since the IPMP * meta-interface can only be destroyed if the group is empty. * Incoming exclusive operation requests are enqueued on the IPSQ they arrived * on rather than the xop. This makes switching xop's (as would happen when a * phyint leaves an IPMP group) simple, because after the phyint leaves the * group, any operations enqueued on its IPSQ can be safely processed with * respect to its new xop, and any operations enqueued on the IPSQs of its * former group can be processed with respect to their existing group xop. * Even so, switching xops is a subtle dance; see ipsq_dq() for details. * An IPSQ's "own" xop is embedded within the IPSQ itself since they have have * identical lifetimes, and because doing so simplifies pointer management. * While each phyint and IPSQ point to each other, it is not possible to free * the IPSQ when the phyint is freed, since we may still *inside* the IPSQ * when the phyint is being freed. Thus, ipsq_phyint is set to NULL when the * phyint is freed, and the IPSQ free is later done in ipsq_exit(). * ipsq_t synchronization: read write * ipsq_xopq_mphead ipx_lock ipx_lock * ipsq_xopq_mptail ipx_lock ipx_lock * ipsq_xop_switch_mp ipsq_lock ipsq_lock * ipsq_phyint write once write once * ipsq_next RW_READER ill_g_lock RW_WRITER ill_g_lock * ipsq_xop ipsq_lock or ipsq ipsq_lock + ipsq * ipsq_ownxop see ipxop_t see ipxop_t * ipsq_ipst write once write once * ipxop_t synchronization: read write * ipx_writer ipx_lock ipx_lock * ipx_xop_queued ipx_lock ipx_lock * ipx_mphead ipx_lock ipx_lock * ipx_mptail ipx_lock ipx_lock * ipx_ipsq write once write once * ips_ipsq_queued ipx_lock ipx_lock * ipx_waitfor ipsq or ipx_lock ipsq + ipx_lock * ipx_reentry_cnt ipsq or ipx_lock ipsq + ipx_lock * ipx_current_done ipsq ipsq * ipx_current_ioctl ipsq ipsq * ipx_current_ipif ipsq or ipx_lock ipsq + ipx_lock * ipx_pending_ipif ipsq or ipx_lock ipsq + ipx_lock * ipx_pending_mp ipsq or ipx_lock ipsq + ipx_lock IPIF_DOWN =
1,
/* ipif_down() waiting for refcnts to drop */ ILL_DOWN,
/* ill_down() waiting for refcnts to drop */ IPIF_FREE,
/* ipif_free() waiting for refcnts to drop */ ILL_FREE /* ill unplumb waiting for refcnts to drop */ /* Operation types for ipsq_try_enter() */ #
define CUR_OP 0
/* request writer within current operation */#
define NEW_OP 1 /* request writer for a new operation */#
define SWITCH_OP 2 /* request writer once IPSQ XOP switches */ * Kstats tracked on each IPMP meta-interface. Order here must match * phyint represents state that is common to both IPv4 and IPv6 interfaces. * There is a separate ill_t representing IPv4 and IPv6 which has a * backpointer to the phyint structure for accessing common state. * Fragmentation hash bucket * IRE bucket structure. Usually there is an array of such structures, * each pointing to a linked list of ires. irb_refcnt counts the number * of walkers of a given hash bucket. Usually the reference count is * bumped up if the walker wants no IRES to be DELETED while walking the * list. Bumping up does not PREVENT ADDITION. This allows walking a given * hash bucket without stumbling up on a free pointer. * irb_t structures in ip_ftable are dynamically allocated and freed. * In order to identify the irb_t structures that can be safely kmem_free'd * - the irb_refcnt is quiescent, indicating no other walkers, * - no other threads or ire's are holding references to the irb, * - there are no active ire's in the bucket, i.e., irb_ire_cnt == 0 /* Should be first in this struct */ int irb_nire;
/* Num of ftable ire's that ref irb */ /* The following are return values of ip_xmit_v4() */ * unpadded ill_if structure /* cache aligned ill_if structure */ * ill_g_heads structure, one for IPV4 and one for IPV6 * Capabilities, possible flags for ill_capabilities. * Per-ill Multidata Transmit capabilities. * Per-ill IPsec capabilities. * Per-ill Hardware Checksumming capbilities. * Per-ill Zero-copy capabilities. * Per-ill polling resource map. * Per-ill Large Segment Offload capabilities. /* The following are ill_state_flags */ /* Is this an ILL whose source address is used by other ILL's ? */ /* Is this an virtual network interface (vni) ILL ? */ /* Is this a loopback ILL? */ /* Is this an IPMP meta-interface ILL? */ /* Is this ILL under an IPMP meta-interface? (aka "in a group?") */ /* Is ill1 in the same illgrp as ill2? */ /* Is ill1 on the same LAN as ill2? */ * IPMP group ILL state structure -- up to two per IPMP group (V4 and V6). * Created when the V4 and/or V6 IPMP meta-interface is I_PLINK'd. It is * guaranteed to persist while there are interfaces of that type in the group. * In general, most fields are accessed outside of the IPSQ (e.g., in the * datapath), and thus use locks in addition to the IPSQ for protection. * synchronization: read write * ig_if ipsq or ill_g_lock ipsq and ill_g_lock * ig_actif ipsq or ipmp_lock ipsq and ipmp_lock * ig_nactif ipsq or ipmp_lock ipsq and ipmp_lock * ig_next_ill ipsq or ipmp_lock ipsq and ipmp_lock * ig_ipmp_ill write once write once * ig_cast_ill ipsq or ipmp_lock ipsq and ipmp_lock * IPMP group state structure -- one per IPMP group. Created when the * IPMP meta-interface is plumbed; it is guaranteed to persist while there * ipmp_grp_t synchronization: read write * gr_name ipmp_lock ipmp_lock * gr_ifname write once write once * gr_mactype ipmp_lock ipmp_lock * gr_phyint write once write once * gr_nif ipmp_lock ipmp_lock * gr_v4 ipmp_lock ipmp_lock * gr_v6 ipmp_lock ipmp_lock * gr_nv4 ipmp_lock ipmp_lock * gr_nv6 ipmp_lock ipmp_lock * gr_pendv4 ipmp_lock ipmp_lock * gr_pendv6 ipmp_lock ipmp_lock * gr_linkdownmp ipsq ipsq * gr_ksp ipmp_lock ipmp_lock * gr_kstats0 atomic atomic * IPMP ARP entry -- one per SIOCS*ARP entry tied to the group. Used to keep * ARP up-to-date as the active set of interfaces in the group changes. * IP Lower level Structure. * Instance data structure in ip_open when there is a device below us. int ill_error;
/* Error value sent up by device. */ * Physical Point of Attachment num. If DLPI style 1 provider * then this is derived from the devname. /* supports broadcast. */ * All non-NULL cells between 'ill_first_mp_to_free' and * 'ill_last_mp_to_free' are freed in ill_delete. /* Following bit fields protected by ipsq_t */ /* Following bit fields protected by ill_lock */ * Used in SIOCSIFMUXID and SIOCGIFMUXID for 'ifconfig unplumb'. /* Used for IP frag reassembly throttling on a per ILL basis. */ * Capabilities related fields. * Following two mblks are allocated common to all * the ipifs when the first interface is coming up. * It is sent up to arp when the last ipif is coming * Used for implementing IFF_NOARP. As IFF_NOARP is used * to turn off for all the logicals, it is here instead * The ill_nd_lla* fields handle the link layer address option * from neighbor discovery. This is used for external IPv6 * We have 4 phys_addr_req's sent down. This field keeps track * of which one is pending. * Used to save errors that occur during plumbing * Contains the upper read queue pointer of the module immediately * beneath IP. This field allows IP to validate sub-capability * acknowledgments coming up from downstream. * ILL_FREE_OK() means that there are no incoming pointer references * An ipif/ill can be marked down only when the ire and nce references * to that ipif/ill goes to zero. ILL_DOWN_OK() is a necessary condition * quiescence checks. See comments above IPIF_DOWN_OK for details * on why ires and nces are selectively considered for this macro. * The following table lists the protection levels of the various members * of the ill_t. Same notation as that used for ipif_t above is used. * ill_ifptr ill_g_lock + s Write once * ill_ipif ill_g_lock + ipsq ill_g_lock OR ipsq * ill_ipif_up_count ill_lock + ipsq ill_lock OR ipsq * ill_max_frag ipsq Write once * ill_name ill_g_lock + ipsq Write once * ill_name_length ill_g_lock + ipsq Write once * ill_ndd_name ipsq Write once * ill_net_type ipsq Write once * ill_ppa ill_g_lock + ipsq Write once * ill_sap ipsq + down ill Write once * ill_sap_length ipsq + down ill Write once * ill_phys_addr_length ipsq + down ill Write once * ill_bcast_addr_length ipsq ipsq * ill_frag_timer_id ill_lock ill_lock * ill_frag_hash_tbl ipsq up ill * ill_ilm ipsq + ill_lock ill_lock * ill_mcast_type ill_lock ill_lock * ill_mcast_v1_time ill_lock ill_lock * ill_mcast_v2_time ill_lock ill_lock * ill_mcast_v1_tset ill_lock ill_lock * ill_mcast_v2_tset ill_lock ill_lock * ill_mcast_rv ill_lock ill_lock * ill_mcast_qi ill_lock ill_lock * ill_pending_mp ill_lock ill_lock * ill_resolver_mp ipsq only when ill is up * ill_dlpi_deferred ill_lock ill_lock * ill_dlpi_pending ipsq + ill_lock ipsq or ill_lock or * absence of ipsq writer. * ill_phys_addr_mp ipsq + down ill only when ill is up * ill_phys_addr ipsq + down ill only when ill is up * ill_dest_addr_mp ipsq + down ill only when ill is up * ill_dest_addr ipsq + down ill only when ill is up * ill_state_flags ill_lock ill_lock * exclusive bit flags ipsq_t ipsq_t * shared bit flags ill_lock ill_lock * ill_arp_muxid ipsq Not atomic * ill_ip_muxid ipsq Not atomic * ill_frag_count atomics atomics * ill_type ipsq + down ill only when ill is up * ill_dlpi_multicast_state ill_lock ill_lock * ill_dlpi_fastpath_state ill_lock ill_lock * ill_dlpi_capab_state ipsq ipsq * ill_max_hops ipsq Not atomic * ill_user_mtu ipsq + ill_lock ill_lock * ill_reachable_time ipsq + ill_lock ill_lock * ill_reachable_retrans_time ipsq + ill_lock ill_lock * ill_max_buf ipsq + ill_lock ill_lock * Next 2 fields need ill_lock because of the get ioctls. They should not * report partially updated results without executing in the ipsq. * ill_token ipsq + ill_lock ill_lock * ill_token_length ipsq + ill_lock ill_lock * ill_dest_token ipsq + down ill only when ill is up * ill_xmit_count ipsq + down ill write once * ill_ip6_mib ipsq + down ill only when ill is up * ill_icmp6_mib ipsq + down ill only when ill is up * ill_arp_down_mp ipsq ipsq * ill_arp_del_mapping_mp ipsq ipsq * ill_arp_on_mp ipsq ipsq * ill_phyint ipsq, ill_g_lock, ill_lock Any of them * ill_flags ill_lock ill_lock * ill_nd_lla_mp ipsq + down ill only when ill is up * ill_nd_lla ipsq + down ill only when ill is up * ill_nd_lla_len ipsq + down ill only when ill is up * ill_phys_addr_pend ipsq + down ill only when ill is up * ill_ifname_pending_err ipsq ipsq * ill_avl_byppa ipsq, ill_g_lock write once * ill_fastpath_list ill_lock ill_lock * ill_refcnt ill_lock ill_lock * ill_ire_cnt ill_lock ill_lock * ill_cv ill_lock ill_lock * ill_ilm_walker_cnt ill_lock ill_lock * ill_nce_cnt ill_lock ill_lock * ill_ilm_cnt ill_lock ill_lock * ill_src_ipif ill_g_lock ill_g_lock * ill_trace ill_lock ill_lock * ill_usesrc_grp_next ill_g_usesrc_lock ill_g_usesrc_lock * ill_dhcpinit atomics atomics * ill_flownotify_mh write once write once * ill_capab_pending_cnt ipsq ipsq * ill_bound_cnt ipsq ipsq * ill_bound_ipif ipsq ipsq * ill_actnode ipsq + ipmp_lock ipsq OR ipmp_lock * ill_grpnode ipsq + ill_g_lock ipsq OR ill_g_lock * ill_src_ipif ill_g_lock ill_g_lock * ill_move_ipif ipsq ipsq * ill_nom_cast ipsq ipsq OR advisory * ill_refresh_tid ill_lock ill_lock * ill_grp (for IPMP ill) write once write once * ill_grp (for underlying ill) ipsq + ill_g_lock ipsq OR ill_g_lock * NOTE: It's OK to make heuristic decisions on an underlying interface * by using IS_UNDER_IPMP() or comparing ill_grp's raw pointer value. * For ioctl restart mechanism see ip_reprocess_ioctl() * IF_CMD 1 old style ifreq cmd * LIF_CMD 2 new style lifreq cmd * MSFILT_CMD 5 multicast source filter cmd * MISC_CMD 6 misc cmd (not a more specific one above) #
define IPI_DONTCARE 0
/* For ioctl encoded values that don't matter *//* Flag values in ipi_flags */ #
define IPI_PRIV 0x1 /* Root only command */#
define IPI_MODOK 0x2 /* Permitted on mod instance of IP */#
define IPI_WR 0x4 /* Need to grab writer access */#
define IPI_GET_CMD 0x8 /* branch to mi_copyout on success */#
define IPI_NULL_BCONT 0x20 /* ioctl has not data and hence no b_cont */#
define IPI_PASS_DOWN 0x40 /* pass this ioctl down when a module only */ * State for detecting if a driver supports certain features. * Support for DL_ENABMULTI_REQ uses ill_dlpi_multicast_state. * Support for DLPI M_DATA fastpath uses ill_dlpi_fastpath_state. #
define IDS_OK 2 /* DLPI request completed successfully *//* Support for DL_CAPABILITY_REQ uses ill_dlpi_capab_state. */ /* Named Dispatch Parameter Management Structure */ /* Extended NDP Management Structure */ * The kernel stores security attributes of all gateways in a database made * up of one or more tsol_gcdb_t elements. Each tsol_gcdb_t contains the * security-related credentials of the gateway. More than one gateways may * share entries in the database. * The tsol_gc_t structure represents the gateway to credential association, * and refers to an entry in the database. One or more tsol_gc_t entities are * grouped together to form one or more tsol_gcgrp_t, each representing the * list of security attributes specific to the gateway. A gateway may be * associated with at most one credentials group. * Gateway security credential record. * Gateway to credential association. * Gateway credentials group address. int ga_af;
/* address family */ * Gateway credentials group. * IRE gateway security attributes structure, pointed to by tsol_ire_gw_secattr * count of the IREs and IRBs (ire bucket). * 1) We bump up the reference count of an IRE to make sure that * it does not get deleted and freed while we are using it. * Typically all the lookup functions hold the bucket lock, * and look for the IRE. If it finds an IRE, it bumps up the * reference count before dropping the lock. Sometimes we *may* want * to bump up the reference count after we *looked* up i.e without * holding the bucket lock. So, the IRE_REFHOLD macro does not assert * on the bucket lock being held. Any thread trying to delete from * the hash bucket can still do so but cannot free the IRE if * 2) We bump up the reference count on the bucket where the IRE resides * (IRB), when we want to prevent the IREs getting deleted from a given * hash bucket. This makes life easier for ire_walk type functions which * wants to walk the IRE list, call a function, but needs to drop * the bucket lock to prevent recursive rw_enters. While the * lock is dropped, the list could be changed by other threads or * the same thread could end up deleting the ire or the ire pointed by * ire_next. IRE_REFHOLDing the ire or ire_next is not sufficient as * a delete will still remove the ire from the bucket while we have * dropped the lock and hence the ire_next would be NULL. Thus, we * need a mechanism to prevent deletions from a given bucket. * To prevent deletions, we bump up the reference count on the * bucket. If the bucket is held, ire_delete just marks IRE_MARK_CONDEMNED * both on the ire's ire_marks and the bucket's irb_marks. When the * reference count on the bucket drops to zero, all the CONDEMNED ires * are deleted. We don't have to bump up the reference count on the * bucket if we are walking the bucket and never have to drop the bucket * lock. Note that IRB_REFHOLD does not prevent addition of new ires * in the list. It is okay because addition of new ires will not cause * ire_next to point to freed memory. We do IRB_REFHOLD only when * all of the 3 conditions are true : * 1) The code needs to walk the IRE bucket from start to end. * 2) It may have to drop the bucket lock sometimes while doing (1) * 3) It does not want any ires to be deleted meanwhile. * Bump up the reference count on the IRE. We cannot assert that the * bucket lock is being held as it is legal to bump up the reference * count after the first lookup has returned the IRE without * holding the lock. Currently ip_wput does this for caching IRE_CACHEs. * Decrement the reference count on the IRE. * In architectures e.g sun4u, where atomic_add_32_nv is just * a cas, we need to maintain the right memory barrier semantics * as that of mutex_exit i.e all the loads and stores should complete * before the cas is executed. membar_exit() does that here. * NOTE : This macro is used only in places where we want performance. * To avoid bloating the code, we use the function "ire_refrele" * which essentially calls the macro. * Bump up the reference count on the hash bucket - IRB to * prevent ires from being deleted in this bucket. * Note: when IRB_MARK_FTABLE (i.e., IRE_CACHETABLE entry), the irb_t * is statically allocated, so that when the irb_refcnt goes to 0, * we simply clean up the ire list and continue. * Lock the fast path mp for access, since the fp_mp can be deleted * due a DL_NOTE_FASTPATH_FLUSH in the case of IRE_BROADCAST /* Internet Routing Entry */ * Neighbor Cache Entry for IPv6; arp info for IPv4 * Protects ire_uinfo, ire_max_frag, and ire_frag_flag. * ire's that are embedded inside mblk_t and sent to the external * resolver use the ire_stq_ifindex to track the ifindex of the * ire_stq, so that the ill (if it exists) can be correctly recovered * for cleanup in the esbfree routine when arp failure occurs. * Similarly, the ire_stackid is used to recover the ip_stack_t. /* IPv4 compatibility macros */ /* Convenient typedefs for sockaddrs */ /* Address structure used for internal bind with IP */ * Using ipa_conn_x_t or ipa6_conn_x_t allows us to modify the behavior of IP's /* flag values for ipa_conn_x_t and ipa6_conn_x_t. */ #
define ACX_VERIFY_DST 0x1ULL /* verify destination address is reachable */ * The MAX number of allowed fragmented packets per hash bucket * calculation is based on the most common mtu size of 1500. This limit * will work well for other mtu sizes as well. * Maximum dups allowed per packet. * Per-packet information for received packets and transmitted. * Used by the transport protocols when converting between the packet * and ancillary data and socket options. * Note: This private data structure and related IPPF_* constant * definitions are exposed to enable compilation of some debugging tools * like lsof which use struct tcp_t in <inet/tcp.h>. This is intended to be * a temporary hack and long term alternate interfaces should be defined * to support the needs of such tools and private definitions moved to * This struct is used by ULP_opt_set() functions to return value of IPv4 * ancillary options. Currently this is only used by udp and icmp and only * IP_PKTINFO option is supported. * Used by ULP's to pass options info to ip_output * currently only IP_PKTINFO is supported. * This structure is used to convey information from IP and the ULP. * Currently used for the IP_RECVSLLA, IP_RECVIF and IP_RECVPKTINFO options. * The type of information field is set to IN_PKTINFO (i.e inbound pkt info) * flags to tell UDP what IP is sending; in_pkt_flags #
define IPF_RECVIF 0x01 /* inbound interface index */ * Inbound interface index + matched address. #
define IPPF_IFINDEX 0x0001 /* Part of in6_pktinfo: ifindex */#
define IPPF_SCOPE_ID 0x0004 /* Add xmit ip6i_t for sin6_scope_id */#
define IPPF_NO_CKSUM 0x0008 /* Add xmit ip6i_t for IP6I_NO_*_CKSUM */#
define IPPF_RAW_CKSUM 0x0010 /* Add xmit ip6i_t for IP6I_RAW_CHECKSUM */ * lookups return the ill/ipif only if the flags are clear OR Iam writer. * ill / ipif lookup functions increment the refcnt on the ill / ipif only * after calling these macros. This ensures that the refcnt on the ipif or * ill will eventually drop down to zero. * If the parameter 'q' is NULL, the caller is not interested in wait and * restart of the operation if the ILL or IPIF cannot be looked up when it is * marked as 'CHANGING'. Typically a thread that tries to send out data will * end up passing NULLs as the last 4 parameters to ill_lookup_on_ifindex and * in this case 'q' is NULL /* Macros used to assert that this thread is a writer */ * Grab ill locks in the proper order. The order is highest addressed /* Get the other protocol instance ill */ /* ioctl command info: Ioctl properties extracted and stored in here */ * List of AH and ESP IPsec acceleration capable ills * ip_g_forward controls IP forwarding. It takes two values: * 0: IP_FORWARD_NEVER Don't forward packets ever. * 1: IP_FORWARD_ALWAYS Forward packets for elsewhere. * RFC1122 says there must be a configuration switch to control forwarding, * but that the default MUST be to not forward packets ever. Implicit * control based on configuration of multiple interfaces MUST NOT be * implemented (Section 3.1). SunOS 4.1 did provide the "automatic" capability * and, in fact, it was the default. That capability is now provided in the /* IPv6 configuration knobs */ /* Misc IP configuration knobs */ extern int dohwcksum;
/* use h/w cksum if supported by the h/w */ * Hooks macros used inside of ip ip2dbg((
"%s hook dropped mblk chain %p hdr %p\n",\
ip2dbg((
"%s hook dropped mblk chain %p hdr %p\n",\
* Network byte order macros /* IPsec HW acceleration debugging support */ #
define IPSECHW_PKTIN 0x0008 /* driver in pkt processing details *//* Default MAC-layer address string length for mac_colon_addr */ /* Hooks for CGTP (multirt routes) filtering module */ /* cfo_filter and cfo_filter_v6 hooks return values */ /* Version 3 of the filter interface */ * The separate CGTP module needs this global symbol so that it * can check the version and determine whether to use the old or the new * version of the filtering interface. /* Flags for ire_multirt_lookup() */ /* Debug stuff for multirt route resolution. */ /* Our "don't send, rather drop" flag. */ * Per-ILL Multidata Transmit capabilities. * rr_ring_state cycles in the order shown below from RR_FREE through * RR_FREE_IN_PROG and back to RR_FREE. #
define ILL_MAX_RINGS 256 /* Max num of rx rings we can manage */ * These functions pointer types are exported by the mac/dls layer. * we need to duplicate the definitions here because we cannot * include mac/dls header files here. * sq_get_pkts() is called to pick packets from softring in poll mode. It * calls rr_rx to get the chain and process it with rr_ip_accept. * rr_rx = mac_soft_ring_poll() to pick packets * rr_ip_accept = ip_accept_tcp() to process packets * XXX: With protocol, service specific squeues, they will have * specific acceptor functions. * rr_intr_enable, rr_intr_disable, rr_rx_handle, rr_rx: * May be accessed while in the squeue AND after checking that SQS_POLL_CAPAB * rr_ring_state: Protected by ill_lock. * IP - DLD direct function call capability * Suffixes, df - dld function, dh - dld handle, * cf - client (IP) function, ch - client handle /* IP - DLD polling capability */ /* Describes ill->ill_dld_capab */ * Squeue tags. Tags only need to be unique when the callback function is the * same to distinguish between different calls, but we use unique tags for