ip.h revision aa92d85b088543197e9fb4594eb30d5215fca2c1
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * CDDL HEADER START
1298001ec5e320f9f9b6a9b925c8939b2579396dKay Sievers * The contents of this file are subject to the terms of the
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * Common Development and Distribution License (the "License").
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * You may not use this file except in compliance with the License.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * See the License for the specific language governing permissions
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * and limitations under the License.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * When distributing Covered Code, include this CDDL HEADER in each
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * If applicable, add the following below this CDDL HEADER, with the
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * fields enclosed by brackets "[]" replaced with your own identifying
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * information: Portions Copyright [yyyy] [name of copyright owner]
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * CDDL HEADER END
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * Use is subject to license terms.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/* Copyright (c) 1990 Mentat Inc. */
2001208c2ab631a69896d1f670c26846b70d1fb7Kay Sievers#pragma ident "%Z%%M% %I% %E% SMI"
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * The mt-streams(9F) flags for the IP module; put here so that other
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * "drivers" that are actually IP (e.g., ICMP, UDP) can use the same set
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#endif /* _KERNEL */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/* Number of bits in an address */
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek#define IP_CSUM(mp, off, sum) (~ip_cksum(mp, off, sum) & 0xFFFF)
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek#define IP_CSUM_PARTIAL(mp, off, sum) ip_cksum(mp, off, sum)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_BCSUM_PARTIAL(bp, len, sum) bcksum(bp, len, sum)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_MD_CSUM(pd, off, sum) (~ip_md_cksum(pd, off, sum) & 0xffff)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_MD_CSUM_PARTIAL(pd, off, sum) ip_md_cksum(pd, off, sum)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * Flag to IP write side to indicate that the appln has sent in a pre-built
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * IP header. Stored in ipha_ident (which is otherwise zero).
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define ILL_FRAG_HASH_TBL_COUNT ((unsigned int)64)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define ILL_FRAG_HASH_TBL_SIZE (ILL_FRAG_HASH_TBL_COUNT * sizeof (ipfb_t))
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_MAX_OPT_LENGTH (IP_MAX_HDR_LENGTH-IP_SIMPLE_HDR_LENGTH)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_MIN_MTU (IP_MAX_HDR_LENGTH + 8) /* 68 bytes */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * XXX IP_MAXPACKET is defined in <netinet/ip.h> as well. At some point the
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * 2 files should be cleaned up to remove all redundant definitions.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers ((IP_VERSION << 4) | IP_SIMPLE_HDR_LENGTH_IN_WORDS)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/* Leave room for ip_newroute to tack on the src and target addresses */
c225f2ffc8a44d9796723aa97bbdfcf331a836c5Kay Sievers ((mp) && ((mp)->b_wptr - (mp)->b_rptr) >= (2 * IP_ADDR_LEN))
c225f2ffc8a44d9796723aa97bbdfcf331a836c5Kay Sievers * Constants and type definitions to support IP IOCTL commands
c225f2ffc8a44d9796723aa97bbdfcf331a836c5Kay Sievers/* Common definitions used by IP IOCTL data structures */
c225f2ffc8a44d9796723aa97bbdfcf331a836c5Kay Sieverstypedef struct ipllcmd_s {
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/* IP IRE Change Command Structure. */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sieverstypedef struct ipic_s {
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek#define ipic_ll_name_length ipic_ipllc.ipllc_name_length
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define ipic_ll_name_offset ipic_ipllc.ipllc_name_offset
7fd1b19bc9e9f5574f2877936b8ac267c7706947Harald Hoyer/* IP IRE Delete Command Structure. */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sieverstypedef struct ipid_s {
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek#define ipid_cmd ipid_ipllc.ipllc_cmd
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek * Temporary state for ip options parser.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers uint8_t *ipoptp_next; /* next option to look at */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers uint8_t *ipoptp_cur; /* start of current option */
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek uint8_t ipoptp_len; /* length of current option */
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek * Flag(s) for ipoptp_flags
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#endif /* _KERNEL */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/* Controls forwarding of IP packets, set via ndd */
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek#define WE_ARE_FORWARDING(ipst) ((ipst)->ips_ip_g_forward == IP_FORWARD_ALWAYS)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length & 0xF) << 2)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers ((int)(((ipha_t *)ipha)->ipha_version_and_hdr_length) >> 4)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * IP reassembly macros. We hide starting and ending offsets in b_next and
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * b_prev of messages on the reassembly queue. The messages are chained using
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * b_cont. These macros are used in ip_reassemble() so we don't have to see
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * the ugly casts and assignments.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * Note that the offsets are <= 64k i.e. a uint_t is sufficient to represent
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek#define IP_REASS_START(mp) ((uint_t)(uintptr_t)((mp)->b_next))
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek#define IP_REASS_SET_START(mp, u) \
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_REASS_END(mp) ((uint_t)(uintptr_t)((mp)->b_prev))
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek#define IP_REASS_SET_END(mp, u) \
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek ((mp)->b_prev = (mblk_t *)(uintptr_t)(u))
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek * Test to determine whether this is a module instance of IP or a
8c62ecf1a99ab4a3f69cb81be38715c504ef5723Zbigniew Jędrzejewski-Szmek * driver instance of IP.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * The following two macros are used by IP to get the appropriate
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * wq and rq for a conn. If it is a TCP conn, then we need
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * tcp_wq/tcp_rq else, conn_wq/conn_rq. IP can use conn_wq and conn_rq
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * from a conn directly if it knows that the conn is not TCP.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers (IPCL_IS_TCP(connp) ? (connp)->conn_tcp->tcp_wq : (connp)->conn_wq)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define CONNP_TO_RQ(connp) RD(CONNP_TO_WQ(connp))
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/* "Congestion controlled" protocol */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_FLOW_CONTROLLED_ULP(p) ((p) == IPPROTO_TCP || (p) == IPPROTO_SCTP)
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * Complete the pending operation. Usually an ioctl. Can also
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * be a bind or option management request that got enqueued
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * in an ipsq_t. Called on completion of the operation.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/* Get the credential of an IP queue of unknown type */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers ((wq)->q_next ? (((ill_t *)(wq)->q_ptr)->ill_credp) \
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * Flags for the various ip_fanout_* routines.
ef89eef77ee098a6828169a6d0d74128e236bcbdZbigniew Jędrzejewski-Szmek#define IP_FF_SEND_ICMP 0x01 /* Send an ICMP error */
ef89eef77ee098a6828169a6d0d74128e236bcbdZbigniew Jędrzejewski-Szmek#define IP_FF_HDR_COMPLETE 0x02 /* Call ip_hdr_complete if error */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_FF_CKSUM 0x04 /* Recompute ipha_cksum if error */
ef89eef77ee098a6828169a6d0d74128e236bcbdZbigniew Jędrzejewski-Szmek#define IP_FF_RAWIP 0x08 /* Use rawip mib variable */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_FF_SRC_QUENCH 0x10 /* OK to send ICMP_SOURCE_QUENCH */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_FF_SYN_ADDIRE 0x20 /* Add IRE if TCP syn packet */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_FF_IPINFO 0x80 /* Used for both V4 and V6 */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_FF_SEND_SLLA 0x100 /* Send source link layer info ? */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IPV6_REACHABILITY_CONFIRMATION 0x200 /* Flags for ip_xmit_v6 */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_FF_NO_MCAST_LOOP 0x400 /* No multicasts for sending zone */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * Following flags are used by IPQoS to determine if policy processing is
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP6_NO_IPPOLICY 0x800 /* Don't do IPQoS processing */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_FF_LOOPBACK 0x2000 /* Loopback fanout */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_FF_SCTP_CSUM_ERR 0x4000 /* sctp pkt has failed chksum */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * Values for squeue switch:
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * This is part of the interface between Transport provider and
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * IP which can be used to set policy information. This is usually
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * accompanied with O_T_BIND_REQ/T_BIND_REQ.ip_bind assumes that
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * only IPSEC_POLICY_SET is there when it is found in the chain.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * The information contained is an struct ipsec_req_t. On success
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * or failure, either the T_BIND_ACK or the T_ERROR_ACK is returned.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * IPSEC_POLICY_SET is never returned.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/* IP Fragmentation Reassembly Header */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sieverstypedef struct ipf_s {
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers struct ipf_s **ipf_ptphn; /* Pointer to previous hash next. */
f901aaadd68050bc575c1c15b84f8f31fd4d494dTom Gundersen uchar_t ipf_last_frag_seen : 1; /* Last fragment seen ? */
f901aaadd68050bc575c1c15b84f8f31fd4d494dTom Gundersen time_t ipf_timestamp; /* Reassembly start time. */
f901aaadd68050bc575c1c15b84f8f31fd4d494dTom Gundersen mblk_t *ipf_tail_mp; /* Frag queue tail pointer. */
f901aaadd68050bc575c1c15b84f8f31fd4d494dTom Gundersen int ipf_hole_cnt; /* Number of holes (hard-case). */
f901aaadd68050bc575c1c15b84f8f31fd4d494dTom Gundersen int ipf_end; /* Tail end offset (0 -> hard-case). */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers size_t ipf_count; /* Count of bytes used by frag */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers uint_t ipf_nf_hdr_len; /* Length of nonfragmented header */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers uint_t ipf_prev_nexthdr_offset; /* Offset for nexthdr value */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers uint8_t ipf_ecn; /* ECN info for the fragments */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers uint8_t ipf_num_dups; /* Number of times dup frags recvd */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers uint16_t ipf_checksum_flags; /* Hardware checksum flags */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers uint32_t ipf_checksum; /* Partial checksum of fragment data */
f901aaadd68050bc575c1c15b84f8f31fd4d494dTom Gundersentypedef enum {
d4f1ef4437e59b2cb69a201bb086ab23070ea72dLennart Poettering * forwarding packet \
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers if ((ire)->ire_type & (IRE_LOCAL|IRE_BROADCAST)) \
9f6445e34a57c270f013c9416c123e56261553ddLennart Poettering atomic_add_32(&(ire)->ire_ipif->ipif_ib_pkt_count, 1);\
9f6445e34a57c270f013c9416c123e56261553ddLennart Poettering atomic_add_32(&(ire)->ire_ipif->ipif_fo_pkt_count, 1);\
90b2de37b80603168f4e9c9c81cff7eea4efa21aZbigniew Jędrzejewski-Szmek#define UPDATE_OB_PKT_COUNT(ire)\
90b2de37b80603168f4e9c9c81cff7eea4efa21aZbigniew Jędrzejewski-Szmek if ((ire)->ire_ipif != NULL) { \
90b2de37b80603168f4e9c9c81cff7eea4efa21aZbigniew Jędrzejewski-Szmek atomic_add_32(&(ire)->ire_ipif->ipif_ob_pkt_count, 1); \
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IP_RPUT_LOCAL(q, mp, ipha, ire, recv_ill) \
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers ip_proto_input(q, mp, ipha, ire, recv_ill, B_FALSE); \
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * NCE_EXPIRED is TRUE when we have a non-permanent nce that was
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * found to be REACHABLE more than ip_ire_arp_interval ms ago.
36afca67b67984520c5c9a6ce14af51a68c7c8cfPeter Hutterer * This macro is used to age existing nce_t entries. The
36afca67b67984520c5c9a6ce14af51a68c7c8cfPeter Hutterer * nce's will get cleaned up in the following circumstances:
36afca67b67984520c5c9a6ce14af51a68c7c8cfPeter Hutterer * - ip_ire_trash_reclaim will free nce's using ndp_cache_reclaim
36afca67b67984520c5c9a6ce14af51a68c7c8cfPeter Hutterer * when memory is low,
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * - ip_arp_news, when updates are received.
9f6445e34a57c270f013c9416c123e56261553ddLennart Poettering * - if the nce is NCE_EXPIRED(), it will deleted, so that a new
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * arp request will need to be triggered from an ND_INITIAL nce.
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * Note that the nce state transition follows the pattern:
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * ND_INITIAL -> ND_INCOMPLETE -> ND_REACHABLE
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * after which the nce is deleted when it has expired.
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * nce_last is the timestamp that indicates when the nce_res_mp in the
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * nce_t was last updated to a valid link-layer address. nce_last gets
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * - when the nce is created
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * - every time we get a sane arp response for the nce.
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers#define NCE_EXPIRED(nce, ipst) (nce->nce_last > 0 && \
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers#endif /* _KERNEL */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers/* ICMP types */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers/* ICMP_TIME_EXCEEDED codes */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers/* ICMP_DEST_UNREACHABLE codes */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers/* ICMP Header Structure */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sieverstypedef struct icmph_s {
9f6445e34a57c270f013c9416c123e56261553ddLennart Poettering struct { /* ECHO request/response structure */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers struct { /* Destination unreachable structure */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers struct { /* Parameter problem structure */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers struct { /* Redirect structure */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers#define icmph_echo_ident icmph_u.u_echo.u_echo_ident
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers#define icmph_echo_seqnum icmph_u.u_echo.u_echo_seqnum
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers#define icmph_rd_gateway icmph_u.u_rd.u_rd_gateway
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * Minimum length of transport layer header included in an ICMP error
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers * message for it to be considered valid.
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sievers/* Aligned IP header */
06639c0940ad9a81f085cbaff05bbf3f69a7f88fKay Sieverstypedef struct ipha_s {
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek#define IPH_DF 0x4000 /* Don't fragment */
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek#define IPH_MF 0x2000 /* More fragments to come */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IPH_OFFSET 0x1FFF /* Where the offset lives */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IPH_FRAG_HDR 0x8000 /* IPv6 don't fragment bit */
33488f19793dc0a86fdee27266c5319b5b78d695Martin Pitt/* ECN code points for IPv4 TOS byte and IPv6 traffic class octet. */
33488f19793dc0a86fdee27266c5319b5b78d695Martin Pitt#define IPH_ECN_NECT 0x0 /* Not ECN-Capabable Transport */
33488f19793dc0a86fdee27266c5319b5b78d695Martin Pitt#define IPH_ECN_ECT1 0x1 /* ECN-Capable Transport, ECT(1) */
33488f19793dc0a86fdee27266c5319b5b78d695Martin Pitt#define IPH_ECN_ECT0 0x2 /* ECN-Capable Transport, ECT(0) */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IPH_ECN_CE 0x3 /* ECN-Congestion Experienced (CE) */
33488f19793dc0a86fdee27266c5319b5b78d695Martin Pitt/* IP Mac info structure */
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek t_uscalar_t ip_m_mac_type; /* From <sys/dlpi.h> */
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek int ip_m_type; /* From <net/if_types.h> */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers boolean_t (*ip_m_v4mapinfo)(uint_t, uint8_t *, uint8_t *,
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers boolean_t (*ip_m_v6mapinfo)(uint_t, uint8_t *, uint8_t *,
33488f19793dc0a86fdee27266c5319b5b78d695Martin Pitt boolean_t (*ip_m_v6intfid)(uint_t, uint8_t *, in6_addr_t *);
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * The following functions attempt to reduce the link layer dependency
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * of the IP stack. The current set of link specific operations are:
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek * a. map from IPv4 class D (224.0/4) multicast address range to the link
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek * layer multicast address range.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * b. map from IPv6 multicast address range (ff00::/8) to the link
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * layer multicast address range.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * c. derive the default IPv6 interface identifier from the link layer
33488f19793dc0a86fdee27266c5319b5b78d695Martin Pitt#define MEDIA_V4MINFO(ip_m, plen, bphys, maddr, hwxp, v4ptr) \
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers (*(ip_m)->ip_m_v4mapinfo)(plen, bphys, maddr, hwxp, v4ptr))
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers#define MEDIA_V6INTFID(ip_m, plen, phys, v6ptr) \
3e49f2ecb55185966ee425a45fcd7b8c2526f3afKay Sievers#define MEDIA_V6MINFO(ip_m, plen, bphys, maddr, hwxp, v6ptr) \
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers (*(ip_m)->ip_m_v6mapinfo)(plen, bphys, maddr, hwxp, v6ptr))
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek/* Router entry types */
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek#define IRE_BROADCAST 0x0001 /* Route entry for broadcast address */
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek#define IRE_DEFAULT 0x0002 /* Route entry for default gateway */
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek#define IRE_LOCAL 0x0004 /* Route entry for local address */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IRE_LOOPBACK 0x0008 /* Route entry for loopback address */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IRE_PREFIX 0x0010 /* Route entry for prefix routes */
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers#define IRE_CACHE 0x0020 /* Cached Route entry */
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek#define IRE_IF_NORESOLVER 0x0040 /* Route entry for local interface */
7643ac9a8add1f07ffc237c054feb443b5612717Zbigniew Jędrzejewski-Szmek /* net without any address mapping. */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IRE_IF_RESOLVER 0x0080 /* Route entry for local interface */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers /* net with resolver. */
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers#define IRE_HOST_REDIRECT 0x0200 /* only used for T_SVR4_OPTMGMT_REQ */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define IRE_INTERFACE (IRE_IF_NORESOLVER | IRE_IF_RESOLVER)
955d98c9c1104d469c2989dbfb58f58ee6fe9bdcLennart Poettering#define IRE_OFFSUBNET (IRE_DEFAULT | IRE_PREFIX | IRE_HOST)
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers#define IRE_CACHETABLE (IRE_CACHE | IRE_BROADCAST | IRE_LOCAL | \
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers#define IRE_FORWARDTABLE (IRE_INTERFACE | IRE_OFFSUBNET)
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * If an IRE is marked with IRE_MARK_CONDEMNED, the last walker of
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * the bucket should delete this IRE from this bucket.
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * If a broadcast IRE is marked with IRE_MARK_NORECV, ip_rput will drop the
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * broadcast packets received on that interface. This is marked only
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * on broadcast ires. Employed by IPMP, where we have multiple NICs on the
955d98c9c1104d469c2989dbfb58f58ee6fe9bdcLennart Poettering * same subnet receiving the same broadcast packet.
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * IRE_CACHE marked this way won't be returned by ire_cache_lookup. Need
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * to look specifically using MATCH_IRE_MARK_HIDDEN. Used by IPMP.
844ec79b3c2f246114ea316ebe1f36044bdb688eZbigniew Jędrzejewski-Szmek#define IRE_MARK_HIDDEN 0x0004 /* Typically Used by in.mpathd */
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * An IRE with IRE_MARK_NOADD is created in ip_newroute_ipif when the outgoing
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * interface is specified by e.g. IP_PKTINFO. The IRE is not added to the IRE
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * cache table.
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers#define IRE_MARK_NOADD 0x0008 /* Mark not to add ire in cache */
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * IRE marked with IRE_MARK_TEMPORARY means that this IRE has been used
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * either for forwarding a packet or has not been used for sending
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * traffic on TCP connections terminated on this system. In both
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * cases, this IRE is the first to go when IRE is being cleaned up.
3a4431ef720b18daf2936bf162c0c3946b80e5b3Kay Sievers * IRE marked with IRE_MARK_USESRC_CHECK means that while adding an IRE with
9f6445e34a57c270f013c9416c123e56261553ddLennart Poettering * this mark, additional atomic checks need to be performed. For eg: by the
3a4431ef720b18daf2936bf162c0c3946b80e5b3Kay Sievers * time an IRE_CACHE is created, sent up to ARP and then comes back to IP; the
9f6445e34a57c270f013c9416c123e56261553ddLennart Poettering * usesrc grouping could have changed in which case we want to fail adding
3a4431ef720b18daf2936bf162c0c3946b80e5b3Kay Sievers * the IRE_CACHE entry
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * IRE_MARK_PRIVATE_ADDR is used for IP_NEXTHOP. When IP_NEXTHOP is set, the
33488f19793dc0a86fdee27266c5319b5b78d695Martin Pitt * routing table lookup for the destination is bypassed and the packet is
33488f19793dc0a86fdee27266c5319b5b78d695Martin Pitt * sent directly to the specified nexthop. The associated IRE_CACHE entries
3e49f2ecb55185966ee425a45fcd7b8c2526f3afKay Sievers * should be marked with IRE_MARK_PRIVATE_ADDR flag so that they don't show up
3e49f2ecb55185966ee425a45fcd7b8c2526f3afKay Sievers * in regular ire cache lookups.
da927ba997d68401563b927f92e6e40e021a8e5cMichal Schmidt * When we send an ARP resolution query for the nexthop gateway's ire,
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * we use esballoc to create the ire_t in the AR_ENTRY_QUERY mblk
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * chain, and mark its ire_marks with IRE_MARK_UNCACHED. This flag
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers * indicates that information from ARP has not been transferred to a
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * permanent IRE_CACHE entry. The flag is reset only when the
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * information is successfully transferred to an ire_cache entry (in
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * ire_add()). Attempting to free the AR_ENTRY_QUERY mblk chain prior
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * to ire_add (e.g., from arp, or from ip`ip_wput_nondata) will
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * require that the resources (incomplete ire_cache and/or nce) must
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * be cleaned up. The free callback routine (ire_freemblk()) checks
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * for IRE_MARK_UNCACHED to see if any resources that are pinned down
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * will need to be cleaned up or not.
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * The comment below (and for other netstack_t references) refers
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * to the fact that we only do netstack_hold in particular cases,
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * such as the references from open streams (ill_t and conn_t's
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * pointers). Internally within IP we rely on IP's ability to cleanup e.g.
23b7245397ac3d21b2386e7b33d9e4ae3db3c8a1Kay Sievers * ire_t's when an ill goes away.
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sieverstypedef struct ire_expire_arg_s {
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers ip_stack_t *iea_ipst; /* Does not have a netstack_hold */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers/* Flags with ire_expire routine */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define FLUSH_ARP_TIME 0x0001 /* ARP info potentially stale timer */
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#define FLUSH_REDIRECT_TIME 0x0002 /* Redirects potentially stale */
#define IRE_FLUSH_DELETE 0
#ifdef _KERNEL
typedef struct slist_s {
int sl_numsrc;
} slist_t;
typedef struct rtx_state_s {
} rtx_state_t;
typedef struct mrec_s {
} mrec_t;
* ilm with ilm_ill/ilm_v6addr recording the multicast membership.
* knows of. Thus we store the ilm_/ilg_orig_ifindex to keep track
typedef struct ilg_s {
} ilg_t;
typedef struct ilm_s {
int ilm_refcnt;
} ilm_t;
typedef struct ipsa_ref_s
} ipsa_ref_t;
typedef struct ipsec_latch_s
membar_exit(); \
typedef struct ipsec_selector {
* in spd.c
#define IPSEC_POLICY_NOT_NEEDED 0
typedef struct iulp_s {
} iulp_t;
typedef struct idl_s {
} idl_t;
typedef struct ifrt_s {
} ifrt_t;
#ifdef IP_DEBUG
typedef struct tr_buf_s {
int tr_depth;
} tr_buf_t;
typedef struct th_trace_s {
int th_refcnt;
} th_trace_t;
typedef struct th_hash_s {
} th_hash_t;
typedef struct ipif_s {
} ipif_t;
#ifdef DEBUG
typedef struct ipsq_s {
int ipsq_reentry_cnt;
int ipsq_flags;
#ifdef DEBUG
} ipsq_t;
typedef struct phyint {
} phyint_t;
struct _phyint_list_s_ {
typedef union phyint_list_u {
typedef struct ill_group {
int illgrp_ill_count;
} ill_group_t;
typedef struct ipfb_s {
} ipfb_t;
typedef struct irb {
} irb_t;
#define IP_V4_G_HEAD 0
struct _ill_if_s_ {
typedef union ill_if_u {
} ill_if_t;
typedef struct ill_walk_context_s {
struct _ill_g_head_s_ {
typedef union ill_g_head_u {
} ill_g_head_t;
typedef struct ill_s {
} ill_t;
struct ip_ioctl_cmd_s;
struct ip_ioctl_cmd_s *, void *);
typedef struct ip_ioctl_cmd_s {
int ipi_cmd;
extern int ip_ndx_ioctl_count;
extern int ip_misc_ioctl_count;
typedef struct ipmx_s {
} ipmx_t;
typedef struct ipparam_s {
char *ip_param_name;
} ipparam_t;
typedef struct ipndp_s {
char *ip_ndp_name;
} ipndp_t;
struct tsol_gcgrp_s;
typedef struct tsol_gcdb_s {
} tsol_gcdb_t;
typedef struct tsol_gc_s {
} tsol_gc_t;
typedef struct tsol_gcgrp_addr_s {
typedef struct tsol_gcgrp_s {
} tsol_gcgrp_t;
#define GC_REFRELE(p) { \
if (--((p)->gc_refcnt) == 0) \
gc_inactive(p); \
#define GCGRP_REFHOLD(p) { \
++((p)->gcgrp_refcnt); \
#define GCGRP_REFRELE(p) { \
if (--((p)->gcgrp_refcnt) == 0) \
gcgrp_inactive(p); \
struct tsol_tnrhc;
typedef struct tsol_ire_gw_secattr_s {
#ifdef DEBUG
membar_exit(); \
typedef struct ire4 {
} ire4_t;
typedef struct ire6 {
} ire6_t;
typedef union ire_addr {
} ire_addr_u_t;
typedef struct ire_s {
} imf_u;
} ire_t;
typedef struct ipa_conn_s {
} ipa_conn_t;
typedef struct ipa6_conn_s {
} ipa6_conn_t;
typedef struct ipa_conn_extended_s {
} ipa_conn_x_t;
typedef struct ipa6_conn_extended_s {
typedef struct nv_s {
char *nv_name;
} nv_t;
#define ILL_FRAG_HASH(s, i) \
struct ip6_pkt_s {
typedef struct ip4_pkt_s {
} ip4_pkt_t;
typedef struct ip_opt_info_s {
typedef struct ip_pktinfo {
} ip_pktinfo_t;
#define IPPF_HAS_IP6I \
#define TCP_PORTS_OFFSET 0
#define UDP_PORTS_OFFSET 0
typedef struct cmd_info_s
} cmd_info_t;
typedef struct ipsec_capab_ill_s {
#ifdef ZC_TEST
extern int noswcksum;
extern char ipif_loopback_name[];
#ifdef _BIG_ENDIAN
#ifdef DEBUG
#define IPSECHW_DEBUG(f, x) {}
#define IPSECHW_CALL(f, r, x) {}
extern int ip_debug;
#ifdef IP_DEBUG
struct ipsec_out_s;
struct mac_header_info_s;
extern const char *dlpi_prim_str(int);
extern const char *dlpi_err_str(int);
extern void ill_frag_timer(void *);
ip_stack_t *);
ip_stack_t *);
ip_stack_t *);
extern void ip_ire_g_fini(void);
extern void ip_ire_g_init(void);
size_t);
int, int, mblk_t *);
struct mac_header_info_s *);
extern void ip_trash_ire_reclaim(void *);
extern void ip_trash_timer_expire(void *);
ip_opt_info_t *);
zoneid_t);
int, zoneid_t);
ip_stack_t *);
ire_t *);
#ifdef DEBUG
extern void th_trace_unref(const void *);
ip_stack_t *);
uint_t);
uint_t);
struct multidata_s;
struct pdesc_s;
ill_lso_capab_t *);
const mblk_t *);
uint_t);
extern void tnet_init(void);
extern void tnet_fini(void);
#define CGTP_IP_PKT_NOT_CGTP 0
typedef struct cgtp_filter_ops {
ip6_frag_t *);
extern int ip_cgtp_filter_rev;
extern int ip_cgtp_filter_supported(void);
struct ill_mdt_capab_s {
struct ill_hcksum_capab_s {
struct ill_zerocopy_capab_s {
struct ill_lso_capab_s {
typedef void (*ip_dls_chg_soft_ring_t)(void *, int);
typedef void (*ip_dls_unbind_t)(void *);
struct ill_rx_ring {
struct ill_dls_capab_s {
extern int ip_squeue_profile;
extern int ip_squeue_bind;
typedef struct squeue_set_s {
int sqs_size;
int sqs_max_size;
} squeue_set_t;
IP_MOD_NAME) != 0 || \
#ifdef __cplusplus