xref: /titanic_50/usr/src/uts/common/inet/ipclassifier.h (revision f4b3ec61df05330d25f55a36b975b4d7519fdeb1)
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
5ee4701baSericheng  * Common Development and Distribution License (the "License").
6ee4701baSericheng  * 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  */
217c478bd9Sstevel@tonic-gate /*
22*f4b3ec61Sdh155122  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_INET_IPCLASSIFIER_H
277c478bd9Sstevel@tonic-gate #define	_INET_IPCLASSIFIER_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
327c478bd9Sstevel@tonic-gate extern "C" {
337c478bd9Sstevel@tonic-gate #endif
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #include <inet/common.h>
367c478bd9Sstevel@tonic-gate #include <inet/ip.h>
377c478bd9Sstevel@tonic-gate #include <inet/mi.h>
387c478bd9Sstevel@tonic-gate #include <inet/tcp.h>
397c478bd9Sstevel@tonic-gate #include <inet/ip6.h>
407c478bd9Sstevel@tonic-gate #include <netinet/in.h>		/* for IPPROTO_* constants */
417c478bd9Sstevel@tonic-gate #include <sys/sdt.h>
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate typedef void (*edesc_spf)(void *, mblk_t *, void *, int);
447c478bd9Sstevel@tonic-gate typedef void (*edesc_rpf)(void *, mblk_t *, void *);
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * ==============================
487c478bd9Sstevel@tonic-gate  * =	The CONNECTION		=
497c478bd9Sstevel@tonic-gate  * ==============================
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate /*
537c478bd9Sstevel@tonic-gate  * The connection structure contains the common information/flags/ref needed.
547c478bd9Sstevel@tonic-gate  * Implementation will keep the connection struct, the layers (with their
557c478bd9Sstevel@tonic-gate  * respective data for event i.e. tcp_t if event was tcp_input) all in one
567c478bd9Sstevel@tonic-gate  * contiguous memory location.
577c478bd9Sstevel@tonic-gate  */
587c478bd9Sstevel@tonic-gate 
597c478bd9Sstevel@tonic-gate /* Conn Flags */
60ff550d0eSmasputra #define	IPCL_UDPMOD		0x00020000	/* Is UDP module instance */
61ff550d0eSmasputra #define	IPCL_TCPMOD		0x00040000	/* Is TCP module instance */
627c478bd9Sstevel@tonic-gate #define	IPCL_FULLY_BOUND	0x00080000	/* Bound to correct squeue */
63ff550d0eSmasputra #define	IPCL_CHECK_POLICY	0x00100000	/* Needs policy checking */
64ff550d0eSmasputra #define	IPCL_SOCKET		0x00200000	/* Sockfs connection */
65ff550d0eSmasputra #define	IPCL_ACCEPTOR		0x00400000	/* Sockfs priv acceptor */
66ff550d0eSmasputra #define	IPCL_CL_LISTENER	0x00800000	/* Cluster listener */
67ff550d0eSmasputra #define	IPCL_EAGER		0x01000000	/* Incoming connection */
68ff550d0eSmasputra #define	IPCL_UDP		0x02000000	/* A UDP connection */
69ff550d0eSmasputra #define	IPCL_TCP6		0x04000000	/* A TCP6 connection */
70ff550d0eSmasputra #define	IPCL_TCP4		0x08000000	/* A TCP connection */
71ff550d0eSmasputra #define	IPCL_CONNECTED		0x40000000	/* Conn in connected table */
72ff550d0eSmasputra #define	IPCL_BOUND		0x80000000	/* Conn in bind table */
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate /* Flags identifying the type of conn */
757c478bd9Sstevel@tonic-gate #define	IPCL_TCPCONN		0x00000001	/* Flag to indicate cache */
767c478bd9Sstevel@tonic-gate #define	IPCL_SCTPCONN		0x00000002
777c478bd9Sstevel@tonic-gate #define	IPCL_IPCCONN		0x00000004
787c478bd9Sstevel@tonic-gate #define	IPCL_ISV6		0x00000008	/* Is a V6 connection */
798810c16bSdanmcd #define	IPCL_IPTUN		0x00000010	/* Has "tun" plumbed above it */
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate /* Conn Masks */
827c478bd9Sstevel@tonic-gate #define	IPCL_TCP		(IPCL_TCP4|IPCL_TCP6)
837c478bd9Sstevel@tonic-gate #define	IPCL_REMOVED		0x00000020
847c478bd9Sstevel@tonic-gate #define	IPCL_REUSED		0x00000040
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate #define	IPCL_IS_TCP4(connp)						\
877c478bd9Sstevel@tonic-gate 	(((connp)->conn_flags & IPCL_TCP4))
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate #define	IPCL_IS_TCP4_CONNECTED_NO_POLICY(connp)				\
907c478bd9Sstevel@tonic-gate 	(((connp)->conn_flags &						\
917c478bd9Sstevel@tonic-gate 		(IPCL_TCP4|IPCL_CONNECTED|IPCL_CHECK_POLICY|IPCL_TCP6))	\
927c478bd9Sstevel@tonic-gate 		== (IPCL_TCP4|IPCL_CONNECTED))
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #define	IPCL_IS_CONNECTED(connp)					\
957c478bd9Sstevel@tonic-gate 	((connp)->conn_flags & IPCL_CONNECTED)
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate #define	IPCL_IS_BOUND(connp)						\
987c478bd9Sstevel@tonic-gate 	((connp)->conn_flags & IPCL_BOUND)
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate #define	IPCL_IS_TCP4_BOUND(connp)					\
1017c478bd9Sstevel@tonic-gate 	(((connp)->conn_flags &						\
1027c478bd9Sstevel@tonic-gate 		(IPCL_TCP4|IPCL_BOUND|IPCL_TCP6)) ==			\
1037c478bd9Sstevel@tonic-gate 		(IPCL_TCP4|IPCL_BOUND))
1047c478bd9Sstevel@tonic-gate 
1057c478bd9Sstevel@tonic-gate #define	IPCL_IS_FULLY_BOUND(connp)					\
1067c478bd9Sstevel@tonic-gate 	((connp)->conn_flags & IPCL_FULLY_BOUND)
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate #define	IPCL_IS_TCP(connp)						\
1097c478bd9Sstevel@tonic-gate 	((connp)->conn_flags & (IPCL_TCP4|IPCL_TCP6))
1107c478bd9Sstevel@tonic-gate 
111ff550d0eSmasputra /*
112ff550d0eSmasputra  * IPCL_UDP is set on the conn when udp is directly above ip;
113ff550d0eSmasputra  * this flag is cleared the moment udp is popped.
114ff550d0eSmasputra  */
115ff550d0eSmasputra #define	IPCL_IS_UDP(connp)						\
116ff550d0eSmasputra 	((connp)->conn_flags & IPCL_UDP)
117ff550d0eSmasputra 
1187c478bd9Sstevel@tonic-gate #define	IPCL_IS_IPTUN(connp)						\
1198810c16bSdanmcd 	(((connp)->conn_ulp == IPPROTO_ENCAP ||				\
1208810c16bSdanmcd 	(connp)->conn_ulp == IPPROTO_IPV6) &&				\
1218810c16bSdanmcd 	((connp)->conn_flags & IPCL_IPTUN))
1227c478bd9Sstevel@tonic-gate 
1237c478bd9Sstevel@tonic-gate typedef struct connf_s connf_t;
124*f4b3ec61Sdh155122 
1257c478bd9Sstevel@tonic-gate typedef struct
1267c478bd9Sstevel@tonic-gate {
1277c478bd9Sstevel@tonic-gate 	int	ctb_depth;
1287c478bd9Sstevel@tonic-gate #define	IP_STACK_DEPTH	15
1297c478bd9Sstevel@tonic-gate 	pc_t	ctb_stack[IP_STACK_DEPTH];
1307c478bd9Sstevel@tonic-gate } conn_trace_t;
1317c478bd9Sstevel@tonic-gate 
1327c478bd9Sstevel@tonic-gate struct conn_s {
1337c478bd9Sstevel@tonic-gate 	kmutex_t	conn_lock;
1347c478bd9Sstevel@tonic-gate 	uint32_t	conn_ref;		/* Reference counter */
1357c478bd9Sstevel@tonic-gate 	uint_t		conn_state_flags;	/* IP state flags */
1367c478bd9Sstevel@tonic-gate 	ire_t		*conn_ire_cache; 	/* outbound ire cache */
1377c478bd9Sstevel@tonic-gate 	uint32_t	conn_flags;		/* Conn Flags */
1387c478bd9Sstevel@tonic-gate 	unsigned int
1397c478bd9Sstevel@tonic-gate 		conn_on_sqp : 1,		/* Conn is being processed */
1407c478bd9Sstevel@tonic-gate 		conn_dontroute : 1,		/* SO_DONTROUTE state */
1417c478bd9Sstevel@tonic-gate 		conn_loopback : 1,		/* SO_LOOPBACK state */
1427c478bd9Sstevel@tonic-gate 		conn_broadcast : 1,		/* SO_BROADCAST state */
1437c478bd9Sstevel@tonic-gate 
14445916cd2Sjpk 		conn_reuseaddr : 1,		/* SO_REUSEADDR state */
1457c478bd9Sstevel@tonic-gate 		conn_multicast_loop : 1,	/* IP_MULTICAST_LOOP */
1467c478bd9Sstevel@tonic-gate 		conn_multi_router : 1,		/* Wants all multicast pkts */
1477c478bd9Sstevel@tonic-gate 		conn_draining : 1,		/* ip_wsrv running */
1487c478bd9Sstevel@tonic-gate 
14945916cd2Sjpk 		conn_did_putbq : 1,		/* ip_wput did a putbq */
1507c478bd9Sstevel@tonic-gate 		conn_unspec_src : 1,		/* IP_UNSPEC_SRC */
1517c478bd9Sstevel@tonic-gate 		conn_policy_cached : 1,		/* Is policy cached/latched ? */
1527c478bd9Sstevel@tonic-gate 		conn_in_enforce_policy : 1,	/* Enforce Policy on inbound */
1537c478bd9Sstevel@tonic-gate 
15445916cd2Sjpk 		conn_out_enforce_policy : 1,	/* Enforce Policy on outbound */
1557c478bd9Sstevel@tonic-gate 		conn_af_isv6 : 1,		/* ip address family ver 6 */
1567c478bd9Sstevel@tonic-gate 		conn_pkt_isv6 : 1,		/* ip packet format ver 6 */
15719a30e1aSrshoaib 		conn_ip_recvpktinfo : 1,	/* IPV*_RECVPKTINFO option */
1587c478bd9Sstevel@tonic-gate 
15945916cd2Sjpk 		conn_ipv6_recvhoplimit : 1,	/* IPV6_RECVHOPLIMIT option */
1607c478bd9Sstevel@tonic-gate 		conn_ipv6_recvhopopts : 1,	/* IPV6_RECVHOPOPTS option */
1617c478bd9Sstevel@tonic-gate 		conn_ipv6_recvdstopts : 1,	/* IPV6_RECVDSTOPTS option */
1627c478bd9Sstevel@tonic-gate 		conn_ipv6_recvrthdr : 1,	/* IPV6_RECVRTHDR option */
16345916cd2Sjpk 
1647c478bd9Sstevel@tonic-gate 		conn_ipv6_recvrtdstopts : 1,	/* IPV6_RECVRTHDRDSTOPTS */
1657c478bd9Sstevel@tonic-gate 		conn_ipv6_v6only : 1,		/* IPV6_V6ONLY */
1667c478bd9Sstevel@tonic-gate 		conn_ipv6_recvtclass : 1,	/* IPV6_RECVTCLASS */
1677c478bd9Sstevel@tonic-gate 		conn_ipv6_recvpathmtu : 1,	/* IPV6_RECVPATHMTU */
16845916cd2Sjpk 
1697c478bd9Sstevel@tonic-gate 		conn_pathmtu_valid : 1,		/* The cached mtu is valid. */
1707c478bd9Sstevel@tonic-gate 		conn_ipv6_dontfrag : 1,		/* IPV6_DONTFRAG */
1717c478bd9Sstevel@tonic-gate 		conn_fully_bound : 1,		/* Fully bound connection */
1727c478bd9Sstevel@tonic-gate 		conn_recvif : 1,		/* IP_RECVIF option */
17345916cd2Sjpk 
1747c478bd9Sstevel@tonic-gate 		conn_recvslla : 1,		/* IP_RECVSLLA option */
1757c478bd9Sstevel@tonic-gate 		conn_mdt_ok : 1,		/* MDT is permitted */
17643d18f1cSpriyanka 		conn_nexthop_set : 1,
1778347601bSyl150051 		conn_allzones : 1,		/* SO_ALLZONES */
1788347601bSyl150051 
1798347601bSyl150051 		conn_lso_ok : 1;		/* LSO is usable */
1807c478bd9Sstevel@tonic-gate 
1817c478bd9Sstevel@tonic-gate 	tcp_t		*conn_tcp;		/* Pointer to the tcp struct */
182d045b987Smasputra 	struct udp_s	*conn_udp;		/* Pointer to the udp struct */
183ff550d0eSmasputra 
1847c478bd9Sstevel@tonic-gate 	squeue_t	*conn_sqp;		/* Squeue for processing */
1857c478bd9Sstevel@tonic-gate 	edesc_rpf	conn_recv;		/* Pointer to recv routine */
1867c478bd9Sstevel@tonic-gate 	void		*conn_pad1;
1877c478bd9Sstevel@tonic-gate 
1887c478bd9Sstevel@tonic-gate 	ill_t		*conn_xmit_if_ill;	/* Outbound ill */
1897c478bd9Sstevel@tonic-gate 	ill_t		*conn_nofailover_ill;	/* Failover ill */
1907c478bd9Sstevel@tonic-gate 	ipsec_latch_t	*conn_latch;		/* latched state */
1917c478bd9Sstevel@tonic-gate 	ill_t		*conn_outgoing_ill;	/* IP{,V6}_BOUND_IF */
1927c478bd9Sstevel@tonic-gate 	edesc_spf	conn_send;		/* Pointer to send routine */
1937c478bd9Sstevel@tonic-gate 	queue_t		*conn_rq;		/* Read queue */
1947c478bd9Sstevel@tonic-gate 	queue_t		*conn_wq;		/* Write queue */
1957c478bd9Sstevel@tonic-gate 	dev_t		conn_dev;		/* Minor number */
1967c478bd9Sstevel@tonic-gate 
1977c478bd9Sstevel@tonic-gate 	cred_t		*conn_cred;		/* Credentials */
1987c478bd9Sstevel@tonic-gate 	connf_t		*conn_g_fanout;		/* Global Hash bucket head */
1997c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_g_next;		/* Global Hash chain next */
2007c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_g_prev;		/* Global Hash chain prev */
2017c478bd9Sstevel@tonic-gate 	struct ipsec_policy_head_s *conn_policy; /* Configured policy */
2027c478bd9Sstevel@tonic-gate 	in6_addr_t	conn_bound_source_v6;
2037c478bd9Sstevel@tonic-gate #define	conn_bound_source	V4_PART_OF_V6(conn_bound_source_v6)
2047c478bd9Sstevel@tonic-gate 	void		*conn_void[1];
2057c478bd9Sstevel@tonic-gate 
2067c478bd9Sstevel@tonic-gate 	connf_t		*conn_fanout;		/* Hash bucket we're part of */
2077c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_next;		/* Hash chain next */
2087c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_prev;		/* Hash chain prev */
2097c478bd9Sstevel@tonic-gate 	struct {
2107c478bd9Sstevel@tonic-gate 		in6_addr_t connua_laddr;	/* Local address */
2117c478bd9Sstevel@tonic-gate 		in6_addr_t connua_faddr;	/* Remote address */
2127c478bd9Sstevel@tonic-gate 	} connua_v6addr;
2137c478bd9Sstevel@tonic-gate #define	conn_src	V4_PART_OF_V6(connua_v6addr.connua_laddr)
2147c478bd9Sstevel@tonic-gate #define	conn_rem	V4_PART_OF_V6(connua_v6addr.connua_faddr)
2157c478bd9Sstevel@tonic-gate #define	conn_srcv6	connua_v6addr.connua_laddr
2167c478bd9Sstevel@tonic-gate #define	conn_remv6	connua_v6addr.connua_faddr
2177c478bd9Sstevel@tonic-gate 	union {
2187c478bd9Sstevel@tonic-gate 		/* Used for classifier match performance */
2197c478bd9Sstevel@tonic-gate 		uint32_t		conn_ports2;
2207c478bd9Sstevel@tonic-gate 		struct {
2217c478bd9Sstevel@tonic-gate 			in_port_t	tcpu_fport;	/* Remote port */
2227c478bd9Sstevel@tonic-gate 			in_port_t	tcpu_lport;	/* Local port */
2237c478bd9Sstevel@tonic-gate 		} tcpu_ports;
2247c478bd9Sstevel@tonic-gate 	} u_port;
2257c478bd9Sstevel@tonic-gate #define	conn_fport	u_port.tcpu_ports.tcpu_fport
2267c478bd9Sstevel@tonic-gate #define	conn_lport	u_port.tcpu_ports.tcpu_lport
2277c478bd9Sstevel@tonic-gate #define	conn_ports	u_port.conn_ports2
2287c478bd9Sstevel@tonic-gate #define	conn_upq	conn_rq
2297c478bd9Sstevel@tonic-gate 	uint8_t		conn_ulp;		/* protocol type */
2307c478bd9Sstevel@tonic-gate 	uint8_t		conn_unused_byte;
2317c478bd9Sstevel@tonic-gate 	kcondvar_t	conn_cv;
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate 	uint_t		conn_proto;		/* SO_PROTOTYPE state */
2347c478bd9Sstevel@tonic-gate 	ill_t		*conn_incoming_ill;	/* IP{,V6}_BOUND_IF */
2357c478bd9Sstevel@tonic-gate 	ill_t		*conn_outgoing_pill;	/* IP{,V6}_BOUND_PIF */
2367c478bd9Sstevel@tonic-gate 	ill_t		*conn_oper_pending_ill; /* pending shared ioctl */
2377c478bd9Sstevel@tonic-gate 	ill_t		*conn_xioctl_pending_ill; /* pending excl ioctl */
2387c478bd9Sstevel@tonic-gate 
2397c478bd9Sstevel@tonic-gate 	/* this is used only when an unbind is in progress.. */
2407c478bd9Sstevel@tonic-gate 	struct sq_s	*conn_pending_sq; /* waiting for ioctl on sq */
2417c478bd9Sstevel@tonic-gate 	ilg_t	*conn_ilg;		/* Group memberships */
2427c478bd9Sstevel@tonic-gate 	int	conn_ilg_allocated;	/* Number allocated */
2437c478bd9Sstevel@tonic-gate 	int	conn_ilg_inuse;		/* Number currently used */
2447c478bd9Sstevel@tonic-gate 	int	conn_ilg_walker_cnt;	/* No of ilg walkers */
2457c478bd9Sstevel@tonic-gate 	/* XXXX get rid of this, once ilg_delete_all is fixed */
2467c478bd9Sstevel@tonic-gate 	kcondvar_t	conn_refcv;
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate 	struct ipif_s	*conn_multicast_ipif;	/* IP_MULTICAST_IF */
2497c478bd9Sstevel@tonic-gate 	ill_t		*conn_multicast_ill;	/* IPV6_MULTICAST_IF */
2507c478bd9Sstevel@tonic-gate 	int		conn_orig_bound_ifindex; /* BOUND_IF before MOVE */
2517c478bd9Sstevel@tonic-gate 	int		conn_orig_multicast_ifindex;
2527c478bd9Sstevel@tonic-gate 						/* IPv6 MC IF before MOVE */
2537c478bd9Sstevel@tonic-gate 	int		conn_orig_xmit_ifindex; /* IP_XMIT_IF before move */
2547c478bd9Sstevel@tonic-gate 	struct conn_s 	*conn_drain_next;	/* Next conn in drain list */
2557c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_drain_prev;	/* Prev conn in drain list */
2567c478bd9Sstevel@tonic-gate 	idl_t		*conn_idl;		/* Ptr to the drain list head */
2577c478bd9Sstevel@tonic-gate 	mblk_t		*conn_ipsec_opt_mp;	/* ipsec option mblk */
2587c478bd9Sstevel@tonic-gate 	uint32_t	conn_src_preferences;	/* prefs for src addr select */
2597c478bd9Sstevel@tonic-gate 	/* mtuinfo from IPV6_PACKET_TOO_BIG conditional on conn_pathmtu_valid */
2607c478bd9Sstevel@tonic-gate 	struct ip6_mtuinfo mtuinfo;
2617c478bd9Sstevel@tonic-gate 	zoneid_t	conn_zoneid;		/* zone connection is in */
26243d18f1cSpriyanka 	in6_addr_t	conn_nexthop_v6;	/* nexthop IP address */
26343d18f1cSpriyanka #define	conn_nexthop_v4	V4_PART_OF_V6(conn_nexthop_v6)
26445916cd2Sjpk 	cred_t		*conn_peercred;		/* Peer credentials, if any */
26545916cd2Sjpk 
26645916cd2Sjpk 	unsigned int
26745916cd2Sjpk 		conn_ulp_labeled : 1,		/* ULP label is synced */
26845916cd2Sjpk 		conn_mlp_type : 2,		/* mlp_type_t; tsol/tndb.h */
26945916cd2Sjpk 		conn_anon_mlp : 1,		/* user wants anon MLP */
27045916cd2Sjpk 
27145916cd2Sjpk 		conn_anon_port : 1,		/* user bound anonymously */
27245916cd2Sjpk 		conn_mac_exempt : 1,		/* unlabeled with loose MAC */
27345916cd2Sjpk 		conn_spare : 26;
27445916cd2Sjpk 
275*f4b3ec61Sdh155122 	netstack_t	*conn_netstack;	/* Corresponds to a netstack_hold */
2767c478bd9Sstevel@tonic-gate #ifdef CONN_DEBUG
2777c478bd9Sstevel@tonic-gate #define	CONN_TRACE_MAX	10
2787c478bd9Sstevel@tonic-gate 	int		conn_trace_last;	/* ndx of last used tracebuf */
2797c478bd9Sstevel@tonic-gate 	conn_trace_t	conn_trace_buf[CONN_TRACE_MAX];
2807c478bd9Sstevel@tonic-gate #endif
2817c478bd9Sstevel@tonic-gate };
2827c478bd9Sstevel@tonic-gate 
28345916cd2Sjpk #define	CONN_CRED(connp) ((connp)->conn_peercred == NULL ? \
28445916cd2Sjpk 	(connp)->conn_cred : (connp)->conn_peercred)
28545916cd2Sjpk #define	BEST_CRED(mp, connp) ((DB_CRED(mp) != NULL &&	\
28645916cd2Sjpk 	crgetlabel(DB_CRED(mp)) != NULL) ? DB_CRED(mp) : CONN_CRED(connp))
28745916cd2Sjpk 
2887c478bd9Sstevel@tonic-gate /*
2897c478bd9Sstevel@tonic-gate  * connf_t - connection fanout data.
2907c478bd9Sstevel@tonic-gate  *
2917c478bd9Sstevel@tonic-gate  * The hash tables and their linkage (conn_t.{hashnextp, hashprevp} are
2927c478bd9Sstevel@tonic-gate  * protected by the per-bucket lock. Each conn_t inserted in the list
2937c478bd9Sstevel@tonic-gate  * points back at the connf_t that heads the bucket.
2947c478bd9Sstevel@tonic-gate  */
2957c478bd9Sstevel@tonic-gate struct connf_s {
2967c478bd9Sstevel@tonic-gate 	struct conn_s	*connf_head;
2977c478bd9Sstevel@tonic-gate 	kmutex_t	connf_lock;
2987c478bd9Sstevel@tonic-gate };
2997c478bd9Sstevel@tonic-gate 
3007c478bd9Sstevel@tonic-gate #define	CONN_INC_REF(connp)	{				\
3017c478bd9Sstevel@tonic-gate 	mutex_enter(&(connp)->conn_lock);			\
302866ba9ddSjprakash 	DTRACE_PROBE1(conn__inc__ref, conn_t *, connp);		\
3037c478bd9Sstevel@tonic-gate 	ASSERT(conn_trace_ref(connp));				\
3047c478bd9Sstevel@tonic-gate 	(connp)->conn_ref++;					\
3057c478bd9Sstevel@tonic-gate 	ASSERT((connp)->conn_ref != 0);				\
3067c478bd9Sstevel@tonic-gate 	mutex_exit(&(connp)->conn_lock);			\
3077c478bd9Sstevel@tonic-gate }
3087c478bd9Sstevel@tonic-gate 
3097c478bd9Sstevel@tonic-gate #define	CONN_INC_REF_LOCKED(connp)	{			\
3107c478bd9Sstevel@tonic-gate 	DTRACE_PROBE1(conn__inc__ref, conn_t *, connp);		\
3117c478bd9Sstevel@tonic-gate 	ASSERT(MUTEX_HELD(&(connp)->conn_lock));	 	\
3127c478bd9Sstevel@tonic-gate 	ASSERT(conn_trace_ref(connp));				\
3137c478bd9Sstevel@tonic-gate 	(connp)->conn_ref++;					\
3147c478bd9Sstevel@tonic-gate 	ASSERT((connp)->conn_ref != 0);				\
3157c478bd9Sstevel@tonic-gate }
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate #define	CONN_DEC_REF(connp)	{					\
3187c478bd9Sstevel@tonic-gate 	mutex_enter(&(connp)->conn_lock);				\
319866ba9ddSjprakash 	DTRACE_PROBE1(conn__dec__ref, conn_t *, connp);			\
320866ba9ddSjprakash 	/*								\
321866ba9ddSjprakash 	 * The squeue framework always does a CONN_DEC_REF after return	\
322866ba9ddSjprakash 	 * from TCP. Hence the refcnt must be at least 2 if conn_on_sqp	\
323866ba9ddSjprakash 	 * is B_TRUE and conn_ref is being decremented. This is to	\
324866ba9ddSjprakash 	 * account for the mblk being currently processed.		\
325866ba9ddSjprakash 	 */								\
326866ba9ddSjprakash 	if ((connp)->conn_ref <= 0 ||					\
327866ba9ddSjprakash 	    ((connp)->conn_ref == 1 && (connp)->conn_on_sqp))		\
3287c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "CONN_DEC_REF: connp(%p) has ref "	\
3297c478bd9Sstevel@tonic-gate 			"= %d\n", (void *)(connp), (connp)->conn_ref);	\
3307c478bd9Sstevel@tonic-gate 	ASSERT(conn_untrace_ref(connp));				\
3317c478bd9Sstevel@tonic-gate 	(connp)->conn_ref--;						\
3327c478bd9Sstevel@tonic-gate 	if ((connp)->conn_ref == 0) {					\
3337c478bd9Sstevel@tonic-gate 		/* Refcnt can't increase again, safe to drop lock */	\
3347c478bd9Sstevel@tonic-gate 		mutex_exit(&(connp)->conn_lock);			\
3357c478bd9Sstevel@tonic-gate 		ipcl_conn_destroy(connp);				\
3367c478bd9Sstevel@tonic-gate 	} else {							\
3377c478bd9Sstevel@tonic-gate 		cv_broadcast(&(connp)->conn_cv);			\
3387c478bd9Sstevel@tonic-gate 		mutex_exit(&(connp)->conn_lock);			\
3397c478bd9Sstevel@tonic-gate 	}								\
3407c478bd9Sstevel@tonic-gate }
3417c478bd9Sstevel@tonic-gate 
3425d0bc3edSsommerfe /*
3435d0bc3edSsommerfe  * For use with subsystems within ip which use ALL_ZONES as a wildcard
3445d0bc3edSsommerfe  */
3455d0bc3edSsommerfe #define	IPCL_ZONEID(connp)						\
3465d0bc3edSsommerfe 	((connp)->conn_allzones ? ALL_ZONES : (connp)->conn_zoneid)
3475d0bc3edSsommerfe 
3485d0bc3edSsommerfe /*
3495d0bc3edSsommerfe  * For matching between a conn_t and a zoneid.
3505d0bc3edSsommerfe  */
3515d0bc3edSsommerfe #define	IPCL_ZONE_MATCH(connp, zoneid) 					\
3525d0bc3edSsommerfe 	(((connp)->conn_allzones) ||					\
3535d0bc3edSsommerfe 	    ((zoneid) == ALL_ZONES) ||					\
3545d0bc3edSsommerfe 	    (connp)->conn_zoneid == (zoneid))
3555d0bc3edSsommerfe 
3565d0bc3edSsommerfe 
3577c478bd9Sstevel@tonic-gate #define	_IPCL_V4_MATCH(v6addr, v4addr)	\
3587c478bd9Sstevel@tonic-gate 	(V4_PART_OF_V6((v6addr)) == (v4addr) && IN6_IS_ADDR_V4MAPPED(&(v6addr)))
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate #define	_IPCL_V4_MATCH_ANY(addr)	\
3617c478bd9Sstevel@tonic-gate 	(IN6_IS_ADDR_V4MAPPED_ANY(&(addr)) || IN6_IS_ADDR_UNSPECIFIED(&(addr)))
3627c478bd9Sstevel@tonic-gate 
3635d0bc3edSsommerfe 
3647c478bd9Sstevel@tonic-gate /*
3657c478bd9Sstevel@tonic-gate  * IPCL_PROTO_MATCH() only matches conns with the specified zoneid, while
3667c478bd9Sstevel@tonic-gate  * IPCL_PROTO_MATCH_V6() can match other conns in the multicast case, see
3677c478bd9Sstevel@tonic-gate  * ip_fanout_proto().
3687c478bd9Sstevel@tonic-gate  */
3697c478bd9Sstevel@tonic-gate #define	IPCL_PROTO_MATCH(connp, protocol, ipha, ill,			\
3707c478bd9Sstevel@tonic-gate     fanout_flags, zoneid)						\
3717c478bd9Sstevel@tonic-gate 	((((connp)->conn_src == INADDR_ANY) ||				\
3727c478bd9Sstevel@tonic-gate 	(((connp)->conn_src == ((ipha)->ipha_dst)) &&			\
3737c478bd9Sstevel@tonic-gate 	    (((connp)->conn_rem == INADDR_ANY) ||			\
3747c478bd9Sstevel@tonic-gate 	((connp)->conn_rem == ((ipha)->ipha_src))))) &&			\
3755d0bc3edSsommerfe 	IPCL_ZONE_MATCH(connp, zoneid) &&				\
3765d0bc3edSsommerfe 	(conn_wantpacket((connp), (ill), (ipha), (fanout_flags), 	\
3775d0bc3edSsommerfe 	    (zoneid)) || ((protocol) == IPPROTO_PIM) ||			\
3787c478bd9Sstevel@tonic-gate 	    ((protocol) == IPPROTO_RSVP)))
3797c478bd9Sstevel@tonic-gate 
3807c478bd9Sstevel@tonic-gate #define	IPCL_PROTO_MATCH_V6(connp, protocol, ip6h, ill,			   \
3817c478bd9Sstevel@tonic-gate     fanout_flags, zoneid)						   \
3827c478bd9Sstevel@tonic-gate 	((IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_srcv6) ||		   \
3837c478bd9Sstevel@tonic-gate 	(IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &((ip6h)->ip6_dst)) &&   \
3847c478bd9Sstevel@tonic-gate 	(IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_remv6) ||		   \
3857c478bd9Sstevel@tonic-gate 	IN6_ARE_ADDR_EQUAL(&(connp)->conn_remv6, &((ip6h)->ip6_src))))) && \
3867c478bd9Sstevel@tonic-gate 	(conn_wantpacket_v6((connp), (ill), (ip6h),			   \
3877c478bd9Sstevel@tonic-gate 	(fanout_flags), (zoneid)) || ((protocol) == IPPROTO_RSVP)))
3887c478bd9Sstevel@tonic-gate 
389*f4b3ec61Sdh155122 #define	IPCL_CONN_HASH(src, ports, ipst)				\
3907c478bd9Sstevel@tonic-gate 	((unsigned)(ntohl((src)) ^ ((ports) >> 24) ^ ((ports) >> 16) ^	\
391*f4b3ec61Sdh155122 	((ports) >> 8) ^ (ports)) % (ipst)->ips_ipcl_conn_fanout_size)
3927c478bd9Sstevel@tonic-gate 
393*f4b3ec61Sdh155122 #define	IPCL_CONN_HASH_V6(src, ports, ipst)				\
394*f4b3ec61Sdh155122 	IPCL_CONN_HASH(V4_PART_OF_V6((src)), (ports), (ipst))
3957c478bd9Sstevel@tonic-gate 
3967c478bd9Sstevel@tonic-gate #define	IPCL_CONN_MATCH(connp, proto, src, dst, ports)			\
3977c478bd9Sstevel@tonic-gate 	((connp)->conn_ulp == (proto) &&				\
3987c478bd9Sstevel@tonic-gate 		(connp)->conn_ports == (ports) &&      			\
3997c478bd9Sstevel@tonic-gate 		_IPCL_V4_MATCH((connp)->conn_remv6, (src)) &&		\
4007c478bd9Sstevel@tonic-gate 		_IPCL_V4_MATCH((connp)->conn_srcv6, (dst)) &&		\
4017c478bd9Sstevel@tonic-gate 		!(connp)->conn_ipv6_v6only)
4027c478bd9Sstevel@tonic-gate 
4037c478bd9Sstevel@tonic-gate #define	IPCL_CONN_MATCH_V6(connp, proto, src, dst, ports)		\
4047c478bd9Sstevel@tonic-gate 	((connp)->conn_ulp == (proto) &&				\
4057c478bd9Sstevel@tonic-gate 		(connp)->conn_ports == (ports) &&      			\
4067c478bd9Sstevel@tonic-gate 		IN6_ARE_ADDR_EQUAL(&(connp)->conn_remv6, &(src)) &&	\
4077c478bd9Sstevel@tonic-gate 		IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &(dst)))
4087c478bd9Sstevel@tonic-gate 
4097c478bd9Sstevel@tonic-gate #define	IPCL_CONN_INIT(connp, protocol, src, rem, ports) {		\
4107c478bd9Sstevel@tonic-gate 	(connp)->conn_ulp = protocol;					\
4117c478bd9Sstevel@tonic-gate 	IN6_IPADDR_TO_V4MAPPED(src, &(connp)->conn_srcv6);		\
4127c478bd9Sstevel@tonic-gate 	IN6_IPADDR_TO_V4MAPPED(rem, &(connp)->conn_remv6);		\
4137c478bd9Sstevel@tonic-gate 	(connp)->conn_ports = ports;					\
4147c478bd9Sstevel@tonic-gate }
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate #define	IPCL_CONN_INIT_V6(connp, protocol, src, rem, ports) {		\
4177c478bd9Sstevel@tonic-gate 	(connp)->conn_ulp = protocol;					\
4187c478bd9Sstevel@tonic-gate 	(connp)->conn_srcv6 = src;					\
4197c478bd9Sstevel@tonic-gate 	(connp)->conn_remv6 = rem;					\
4207c478bd9Sstevel@tonic-gate 	(connp)->conn_ports = ports;					\
4217c478bd9Sstevel@tonic-gate }
4227c478bd9Sstevel@tonic-gate 
423ee4701baSericheng #define	IPCL_PORT_HASH(port, size) \
424ee4701baSericheng 	((((port) >> 8) ^ (port)) & ((size) - 1))
425ee4701baSericheng 
426*f4b3ec61Sdh155122 #define	IPCL_BIND_HASH(lport, ipst)					\
427*f4b3ec61Sdh155122 	((unsigned)(((lport) >> 8) ^ (lport)) % \
428*f4b3ec61Sdh155122 	    (ipst)->ips_ipcl_bind_fanout_size)
4297c478bd9Sstevel@tonic-gate 
4307c478bd9Sstevel@tonic-gate #define	IPCL_BIND_MATCH(connp, proto, laddr, lport)			\
4317c478bd9Sstevel@tonic-gate 	((connp)->conn_ulp == (proto) &&				\
4327c478bd9Sstevel@tonic-gate 		(connp)->conn_lport == (lport) &&			\
4337c478bd9Sstevel@tonic-gate 		(_IPCL_V4_MATCH_ANY((connp)->conn_srcv6) ||		\
4347c478bd9Sstevel@tonic-gate 		_IPCL_V4_MATCH((connp)->conn_srcv6, (laddr))) &&	\
4357c478bd9Sstevel@tonic-gate 		!(connp)->conn_ipv6_v6only)
4367c478bd9Sstevel@tonic-gate 
4377c478bd9Sstevel@tonic-gate #define	IPCL_BIND_MATCH_V6(connp, proto, laddr, lport)			\
4387c478bd9Sstevel@tonic-gate 	((connp)->conn_ulp == (proto) &&				\
4397c478bd9Sstevel@tonic-gate 		(connp)->conn_lport == (lport) &&			\
4407c478bd9Sstevel@tonic-gate 		(IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &(laddr)) ||	\
4417c478bd9Sstevel@tonic-gate 		IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_srcv6)))
4427c478bd9Sstevel@tonic-gate 
4437c478bd9Sstevel@tonic-gate #define	IPCL_UDP_MATCH(connp, lport, laddr, fport, faddr)		\
4447c478bd9Sstevel@tonic-gate 	(((connp)->conn_lport == (lport)) &&				\
4457c478bd9Sstevel@tonic-gate 	((_IPCL_V4_MATCH_ANY((connp)->conn_srcv6) ||			\
4467c478bd9Sstevel@tonic-gate 	(_IPCL_V4_MATCH((connp)->conn_srcv6, (laddr)) &&		\
4477c478bd9Sstevel@tonic-gate 	(_IPCL_V4_MATCH_ANY((connp)->conn_remv6) ||			\
4487c478bd9Sstevel@tonic-gate 	(_IPCL_V4_MATCH((connp)->conn_remv6, (faddr)) &&		\
4497c478bd9Sstevel@tonic-gate 	(connp)->conn_fport == (fport)))))) &&				\
4507c478bd9Sstevel@tonic-gate 	!(connp)->conn_ipv6_v6only)
4517c478bd9Sstevel@tonic-gate 
4527c478bd9Sstevel@tonic-gate #define	IPCL_UDP_MATCH_V6(connp, lport, laddr, fport, faddr)	\
4537c478bd9Sstevel@tonic-gate 	(((connp)->conn_lport == (lport)) &&			\
4547c478bd9Sstevel@tonic-gate 	(IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_srcv6) ||	\
4557c478bd9Sstevel@tonic-gate 	(IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &(laddr)) &&	\
4567c478bd9Sstevel@tonic-gate 	(IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_remv6) ||	\
4577c478bd9Sstevel@tonic-gate 	(IN6_ARE_ADDR_EQUAL(&(connp)->conn_remv6, &(faddr)) &&	\
4587c478bd9Sstevel@tonic-gate 	(connp)->conn_fport == (fport))))))
4597c478bd9Sstevel@tonic-gate 
4607c478bd9Sstevel@tonic-gate #define	IPCL_TCP_EAGER_INIT(connp, protocol, src, rem, ports) {		\
4617c478bd9Sstevel@tonic-gate 	(connp)->conn_flags |= (IPCL_TCP4|IPCL_EAGER);			\
4627c478bd9Sstevel@tonic-gate 	(connp)->conn_ulp = protocol;					\
4637c478bd9Sstevel@tonic-gate 	IN6_IPADDR_TO_V4MAPPED(src, &(connp)->conn_srcv6);		\
4647c478bd9Sstevel@tonic-gate 	IN6_IPADDR_TO_V4MAPPED(rem, &(connp)->conn_remv6);		\
4657c478bd9Sstevel@tonic-gate 	(connp)->conn_ports = ports;					\
4667c478bd9Sstevel@tonic-gate 	(connp)->conn_send = ip_output;					\
4677c478bd9Sstevel@tonic-gate 	(connp)->conn_sqp = IP_SQUEUE_GET(lbolt);			\
4687c478bd9Sstevel@tonic-gate }
4697c478bd9Sstevel@tonic-gate 
4707c478bd9Sstevel@tonic-gate #define	IPCL_TCP_EAGER_INIT_V6(connp, protocol, src, rem, ports) {	\
4717c478bd9Sstevel@tonic-gate 	(connp)->conn_flags |= (IPCL_TCP6|IPCL_EAGER);			\
4727c478bd9Sstevel@tonic-gate 	(connp)->conn_ulp = protocol;					\
4737c478bd9Sstevel@tonic-gate 	(connp)->conn_srcv6 = src;					\
4747c478bd9Sstevel@tonic-gate 	(connp)->conn_remv6 = rem;					\
4757c478bd9Sstevel@tonic-gate 	(connp)->conn_ports = ports;					\
4767c478bd9Sstevel@tonic-gate 	(connp)->conn_send = ip_output_v6;				\
4777c478bd9Sstevel@tonic-gate 	(connp)->conn_sqp = IP_SQUEUE_GET(lbolt);			\
4787c478bd9Sstevel@tonic-gate }
4797c478bd9Sstevel@tonic-gate 
480*f4b3ec61Sdh155122 #define	IPCL_UDP_HASH(lport, ipst)	\
481*f4b3ec61Sdh155122 	IPCL_PORT_HASH(lport, (ipst)->ips_ipcl_udp_fanout_size)
4827c478bd9Sstevel@tonic-gate 
4837c478bd9Sstevel@tonic-gate #define	CONN_G_HASH_SIZE	1024
4847c478bd9Sstevel@tonic-gate 
4857c478bd9Sstevel@tonic-gate /* Raw socket hash function. */
486*f4b3ec61Sdh155122 #define	IPCL_RAW_HASH(lport, ipst)	\
487*f4b3ec61Sdh155122 	IPCL_PORT_HASH(lport, (ipst)->ips_ipcl_raw_fanout_size)
4887c478bd9Sstevel@tonic-gate 
4897c0c0508Skcpoon /*
4907c0c0508Skcpoon  * This is similar to IPCL_BIND_MATCH except that the local port check
4917c0c0508Skcpoon  * is changed to a wildcard port check.
4927c0c0508Skcpoon  */
4937c0c0508Skcpoon #define	IPCL_RAW_MATCH(connp, proto, laddr)			\
4947c0c0508Skcpoon 	((connp)->conn_ulp == (proto) &&			\
4957c0c0508Skcpoon 	(connp)->conn_lport == 0 &&				\
4967c0c0508Skcpoon 	(_IPCL_V4_MATCH_ANY((connp)->conn_srcv6) ||		\
4977c0c0508Skcpoon 	_IPCL_V4_MATCH((connp)->conn_srcv6, (laddr))))
4987c0c0508Skcpoon 
4997c0c0508Skcpoon #define	IPCL_RAW_MATCH_V6(connp, proto, laddr)			\
5007c0c0508Skcpoon 	((connp)->conn_ulp == (proto) &&			\
5017c0c0508Skcpoon 	(connp)->conn_lport == 0 &&				\
5027c0c0508Skcpoon 	(IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_srcv6) ||	\
5037c0c0508Skcpoon 	IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &(laddr))))
5047c0c0508Skcpoon 
5057c478bd9Sstevel@tonic-gate /* Function prototypes */
506*f4b3ec61Sdh155122 extern void ipcl_g_init(void);
507*f4b3ec61Sdh155122 extern void ipcl_init(ip_stack_t *);
508*f4b3ec61Sdh155122 extern void ipcl_g_destroy(void);
509*f4b3ec61Sdh155122 extern void ipcl_destroy(ip_stack_t *);
510*f4b3ec61Sdh155122 extern conn_t *ipcl_conn_create(uint32_t, int, netstack_t *);
5117c478bd9Sstevel@tonic-gate extern void ipcl_conn_destroy(conn_t *);
5127c478bd9Sstevel@tonic-gate 
5137c478bd9Sstevel@tonic-gate void ipcl_hash_insert_connected(connf_t *, conn_t *);
5147c478bd9Sstevel@tonic-gate void ipcl_hash_insert_bound(connf_t *, conn_t *);
5157c478bd9Sstevel@tonic-gate void ipcl_hash_insert_wildcard(connf_t *, conn_t *);
5167c478bd9Sstevel@tonic-gate void ipcl_hash_remove(conn_t *);
5177c478bd9Sstevel@tonic-gate void ipcl_hash_remove_locked(conn_t *connp, connf_t *connfp);
5187c478bd9Sstevel@tonic-gate 
5197c478bd9Sstevel@tonic-gate extern int	ipcl_bind_insert(conn_t *, uint8_t, ipaddr_t, uint16_t);
5207c478bd9Sstevel@tonic-gate extern int	ipcl_bind_insert_v6(conn_t *, uint8_t, const in6_addr_t *,
5217c478bd9Sstevel@tonic-gate 		    uint16_t);
5227c478bd9Sstevel@tonic-gate extern int	ipcl_conn_insert(conn_t *, uint8_t, ipaddr_t, ipaddr_t,
5237c478bd9Sstevel@tonic-gate 		    uint32_t);
5247c478bd9Sstevel@tonic-gate extern int	ipcl_conn_insert_v6(conn_t *, uint8_t, const in6_addr_t *,
5257c478bd9Sstevel@tonic-gate 		    const in6_addr_t *, uint32_t, uint_t);
526ff550d0eSmasputra extern conn_t	*ipcl_get_next_conn(connf_t *, conn_t *, uint32_t);
5277c478bd9Sstevel@tonic-gate 
5287c478bd9Sstevel@tonic-gate void ipcl_proto_insert(conn_t *, uint8_t);
5297c478bd9Sstevel@tonic-gate void ipcl_proto_insert_v6(conn_t *, uint8_t);
530*f4b3ec61Sdh155122 conn_t *ipcl_classify_v4(mblk_t *, uint8_t, uint_t, zoneid_t, ip_stack_t *);
531*f4b3ec61Sdh155122 conn_t *ipcl_classify_v6(mblk_t *, uint8_t, uint_t, zoneid_t, ip_stack_t *);
532*f4b3ec61Sdh155122 conn_t *ipcl_classify(mblk_t *, zoneid_t, ip_stack_t *);
533*f4b3ec61Sdh155122 conn_t *ipcl_classify_raw(mblk_t *, uint8_t, zoneid_t, uint32_t, ipha_t *,
534*f4b3ec61Sdh155122 	    ip_stack_t *);
5357c478bd9Sstevel@tonic-gate void	ipcl_globalhash_insert(conn_t *);
5367c478bd9Sstevel@tonic-gate void	ipcl_globalhash_remove(conn_t *);
537*f4b3ec61Sdh155122 void	ipcl_walk(pfv_t, void *, ip_stack_t *);
538*f4b3ec61Sdh155122 conn_t	*ipcl_tcp_lookup_reversed_ipv4(ipha_t *, tcph_t *, int, ip_stack_t *);
539*f4b3ec61Sdh155122 conn_t	*ipcl_tcp_lookup_reversed_ipv6(ip6_t *, tcpha_t *, int, uint_t,
540*f4b3ec61Sdh155122 	    ip_stack_t *);
541*f4b3ec61Sdh155122 conn_t	*ipcl_lookup_listener_v4(uint16_t, ipaddr_t, zoneid_t, ip_stack_t *);
542*f4b3ec61Sdh155122 conn_t	*ipcl_lookup_listener_v6(uint16_t, in6_addr_t *, uint_t, zoneid_t,
543*f4b3ec61Sdh155122 	    ip_stack_t *);
5447c478bd9Sstevel@tonic-gate int	conn_trace_ref(conn_t *);
5457c478bd9Sstevel@tonic-gate int	conn_untrace_ref(conn_t *);
546*f4b3ec61Sdh155122 conn_t *ipcl_conn_tcp_lookup_reversed_ipv4(conn_t *, ipha_t *, tcph_t *,
547*f4b3ec61Sdh155122 	    ip_stack_t *);
548*f4b3ec61Sdh155122 conn_t *ipcl_conn_tcp_lookup_reversed_ipv6(conn_t *, ip6_t *, tcph_t *,
549*f4b3ec61Sdh155122 	    ip_stack_t *);
5507c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
5517c478bd9Sstevel@tonic-gate }
5527c478bd9Sstevel@tonic-gate #endif
5537c478bd9Sstevel@tonic-gate 
5547c478bd9Sstevel@tonic-gate #endif	/* _INET_IPCLASSIFIER_H */
555