xref: /titanic_44/usr/src/uts/common/inet/ipclassifier.h (revision 5d0bc3ededb82d77f7c33d8f58e517a837ba5140)
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 /*
22d045b987Smasputra  * Copyright 2006 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 */
797c478bd9Sstevel@tonic-gate 
807c478bd9Sstevel@tonic-gate /* Conn Masks */
817c478bd9Sstevel@tonic-gate #define	IPCL_TCP		(IPCL_TCP4|IPCL_TCP6)
827c478bd9Sstevel@tonic-gate #define	IPCL_REMOVED		0x00000020
837c478bd9Sstevel@tonic-gate #define	IPCL_REUSED		0x00000040
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate #define	IPCL_IS_TCP4(connp)						\
867c478bd9Sstevel@tonic-gate 	(((connp)->conn_flags & IPCL_TCP4))
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate #define	IPCL_IS_TCP4_CONNECTED_NO_POLICY(connp)				\
897c478bd9Sstevel@tonic-gate 	(((connp)->conn_flags &						\
907c478bd9Sstevel@tonic-gate 		(IPCL_TCP4|IPCL_CONNECTED|IPCL_CHECK_POLICY|IPCL_TCP6))	\
917c478bd9Sstevel@tonic-gate 		== (IPCL_TCP4|IPCL_CONNECTED))
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate #define	IPCL_IS_CONNECTED(connp)					\
947c478bd9Sstevel@tonic-gate 	((connp)->conn_flags & IPCL_CONNECTED)
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate #define	IPCL_IS_BOUND(connp)						\
977c478bd9Sstevel@tonic-gate 	((connp)->conn_flags & IPCL_BOUND)
987c478bd9Sstevel@tonic-gate 
997c478bd9Sstevel@tonic-gate #define	IPCL_IS_TCP4_BOUND(connp)					\
1007c478bd9Sstevel@tonic-gate 	(((connp)->conn_flags &						\
1017c478bd9Sstevel@tonic-gate 		(IPCL_TCP4|IPCL_BOUND|IPCL_TCP6)) ==			\
1027c478bd9Sstevel@tonic-gate 		(IPCL_TCP4|IPCL_BOUND))
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate #define	IPCL_IS_FULLY_BOUND(connp)					\
1057c478bd9Sstevel@tonic-gate 	((connp)->conn_flags & IPCL_FULLY_BOUND)
1067c478bd9Sstevel@tonic-gate 
1077c478bd9Sstevel@tonic-gate #define	IPCL_IS_TCP(connp)						\
1087c478bd9Sstevel@tonic-gate 	((connp)->conn_flags & (IPCL_TCP4|IPCL_TCP6))
1097c478bd9Sstevel@tonic-gate 
110ff550d0eSmasputra /*
111ff550d0eSmasputra  * IPCL_UDP is set on the conn when udp is directly above ip;
112ff550d0eSmasputra  * this flag is cleared the moment udp is popped.
113ff550d0eSmasputra  */
114ff550d0eSmasputra #define	IPCL_IS_UDP(connp)						\
115ff550d0eSmasputra 	((connp)->conn_flags & IPCL_UDP)
116ff550d0eSmasputra 
1177c478bd9Sstevel@tonic-gate #define	IPCL_IS_IPTUN(connp)						\
1187c478bd9Sstevel@tonic-gate 	((connp)->conn_ulp == IPPROTO_ENCAP || \
1197c478bd9Sstevel@tonic-gate 	(connp)->conn_ulp == IPPROTO_IPV6)
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate typedef struct connf_s connf_t;
1227c478bd9Sstevel@tonic-gate typedef struct
1237c478bd9Sstevel@tonic-gate {
1247c478bd9Sstevel@tonic-gate 	int	ctb_depth;
1257c478bd9Sstevel@tonic-gate #define	IP_STACK_DEPTH	15
1267c478bd9Sstevel@tonic-gate 	pc_t	ctb_stack[IP_STACK_DEPTH];
1277c478bd9Sstevel@tonic-gate } conn_trace_t;
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate struct conn_s {
1307c478bd9Sstevel@tonic-gate 	kmutex_t	conn_lock;
1317c478bd9Sstevel@tonic-gate 	uint32_t	conn_ref;		/* Reference counter */
1327c478bd9Sstevel@tonic-gate 	uint_t		conn_state_flags;	/* IP state flags */
1337c478bd9Sstevel@tonic-gate 	ire_t		*conn_ire_cache; 	/* outbound ire cache */
1347c478bd9Sstevel@tonic-gate 	uint32_t	conn_flags;		/* Conn Flags */
1357c478bd9Sstevel@tonic-gate 	unsigned int
1367c478bd9Sstevel@tonic-gate 		conn_on_sqp : 1,		/* Conn is being processed */
1377c478bd9Sstevel@tonic-gate 		conn_dontroute : 1,		/* SO_DONTROUTE state */
1387c478bd9Sstevel@tonic-gate 		conn_loopback : 1,		/* SO_LOOPBACK state */
1397c478bd9Sstevel@tonic-gate 		conn_broadcast : 1,		/* SO_BROADCAST state */
1407c478bd9Sstevel@tonic-gate 
14145916cd2Sjpk 		conn_reuseaddr : 1,		/* SO_REUSEADDR state */
1427c478bd9Sstevel@tonic-gate 		conn_multicast_loop : 1,	/* IP_MULTICAST_LOOP */
1437c478bd9Sstevel@tonic-gate 		conn_multi_router : 1,		/* Wants all multicast pkts */
1447c478bd9Sstevel@tonic-gate 		conn_draining : 1,		/* ip_wsrv running */
1457c478bd9Sstevel@tonic-gate 
14645916cd2Sjpk 		conn_did_putbq : 1,		/* ip_wput did a putbq */
1477c478bd9Sstevel@tonic-gate 		conn_unspec_src : 1,		/* IP_UNSPEC_SRC */
1487c478bd9Sstevel@tonic-gate 		conn_policy_cached : 1,		/* Is policy cached/latched ? */
1497c478bd9Sstevel@tonic-gate 		conn_in_enforce_policy : 1,	/* Enforce Policy on inbound */
1507c478bd9Sstevel@tonic-gate 
15145916cd2Sjpk 		conn_out_enforce_policy : 1,	/* Enforce Policy on outbound */
1527c478bd9Sstevel@tonic-gate 		conn_af_isv6 : 1,		/* ip address family ver 6 */
1537c478bd9Sstevel@tonic-gate 		conn_pkt_isv6 : 1,		/* ip packet format ver 6 */
1547c478bd9Sstevel@tonic-gate 		conn_ipv6_recvpktinfo : 1,	/* IPV6_RECVPKTINFO option */
1557c478bd9Sstevel@tonic-gate 
15645916cd2Sjpk 		conn_ipv6_recvhoplimit : 1,	/* IPV6_RECVHOPLIMIT option */
1577c478bd9Sstevel@tonic-gate 		conn_ipv6_recvhopopts : 1,	/* IPV6_RECVHOPOPTS option */
1587c478bd9Sstevel@tonic-gate 		conn_ipv6_recvdstopts : 1,	/* IPV6_RECVDSTOPTS option */
1597c478bd9Sstevel@tonic-gate 		conn_ipv6_recvrthdr : 1,	/* IPV6_RECVRTHDR option */
16045916cd2Sjpk 
1617c478bd9Sstevel@tonic-gate 		conn_ipv6_recvrtdstopts : 1,	/* IPV6_RECVRTHDRDSTOPTS */
1627c478bd9Sstevel@tonic-gate 		conn_ipv6_v6only : 1,		/* IPV6_V6ONLY */
1637c478bd9Sstevel@tonic-gate 		conn_ipv6_recvtclass : 1,	/* IPV6_RECVTCLASS */
1647c478bd9Sstevel@tonic-gate 		conn_ipv6_recvpathmtu : 1,	/* IPV6_RECVPATHMTU */
16545916cd2Sjpk 
1667c478bd9Sstevel@tonic-gate 		conn_pathmtu_valid : 1,		/* The cached mtu is valid. */
1677c478bd9Sstevel@tonic-gate 		conn_ipv6_dontfrag : 1,		/* IPV6_DONTFRAG */
1687c478bd9Sstevel@tonic-gate 		conn_fully_bound : 1,		/* Fully bound connection */
1697c478bd9Sstevel@tonic-gate 		conn_recvif : 1,		/* IP_RECVIF option */
17045916cd2Sjpk 
1717c478bd9Sstevel@tonic-gate 		conn_recvslla : 1,		/* IP_RECVSLLA option */
1727c478bd9Sstevel@tonic-gate 		conn_mdt_ok : 1,		/* MDT is permitted */
17343d18f1cSpriyanka 		conn_nexthop_set : 1,
174*5d0bc3edSsommerfe 		conn_allzones : 1;		/* SO_ALLZONES */
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate 	tcp_t		*conn_tcp;		/* Pointer to the tcp struct */
177d045b987Smasputra 	struct udp_s	*conn_udp;		/* Pointer to the udp struct */
178ff550d0eSmasputra 
1797c478bd9Sstevel@tonic-gate 	squeue_t	*conn_sqp;		/* Squeue for processing */
1807c478bd9Sstevel@tonic-gate 	edesc_rpf	conn_recv;		/* Pointer to recv routine */
1817c478bd9Sstevel@tonic-gate 	void		*conn_pad1;
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate 	ill_t		*conn_xmit_if_ill;	/* Outbound ill */
1847c478bd9Sstevel@tonic-gate 	ill_t		*conn_nofailover_ill;	/* Failover ill */
1857c478bd9Sstevel@tonic-gate 	ipsec_latch_t	*conn_latch;		/* latched state */
1867c478bd9Sstevel@tonic-gate 	ill_t		*conn_outgoing_ill;	/* IP{,V6}_BOUND_IF */
1877c478bd9Sstevel@tonic-gate 	edesc_spf	conn_send;		/* Pointer to send routine */
1887c478bd9Sstevel@tonic-gate 	queue_t		*conn_rq;		/* Read queue */
1897c478bd9Sstevel@tonic-gate 	queue_t		*conn_wq;		/* Write queue */
1907c478bd9Sstevel@tonic-gate 	dev_t		conn_dev;		/* Minor number */
1917c478bd9Sstevel@tonic-gate 
1927c478bd9Sstevel@tonic-gate 	cred_t		*conn_cred;		/* Credentials */
1937c478bd9Sstevel@tonic-gate 	connf_t		*conn_g_fanout;		/* Global Hash bucket head */
1947c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_g_next;		/* Global Hash chain next */
1957c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_g_prev;		/* Global Hash chain prev */
1967c478bd9Sstevel@tonic-gate 	struct ipsec_policy_head_s *conn_policy; /* Configured policy */
1977c478bd9Sstevel@tonic-gate 	in6_addr_t	conn_bound_source_v6;
1987c478bd9Sstevel@tonic-gate #define	conn_bound_source	V4_PART_OF_V6(conn_bound_source_v6)
1997c478bd9Sstevel@tonic-gate 	void		*conn_void[1];
2007c478bd9Sstevel@tonic-gate 
2017c478bd9Sstevel@tonic-gate 	connf_t		*conn_fanout;		/* Hash bucket we're part of */
2027c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_next;		/* Hash chain next */
2037c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_prev;		/* Hash chain prev */
2047c478bd9Sstevel@tonic-gate 	struct {
2057c478bd9Sstevel@tonic-gate 		in6_addr_t connua_laddr;	/* Local address */
2067c478bd9Sstevel@tonic-gate 		in6_addr_t connua_faddr;	/* Remote address */
2077c478bd9Sstevel@tonic-gate 	} connua_v6addr;
2087c478bd9Sstevel@tonic-gate #define	conn_src	V4_PART_OF_V6(connua_v6addr.connua_laddr)
2097c478bd9Sstevel@tonic-gate #define	conn_rem	V4_PART_OF_V6(connua_v6addr.connua_faddr)
2107c478bd9Sstevel@tonic-gate #define	conn_srcv6	connua_v6addr.connua_laddr
2117c478bd9Sstevel@tonic-gate #define	conn_remv6	connua_v6addr.connua_faddr
2127c478bd9Sstevel@tonic-gate 	union {
2137c478bd9Sstevel@tonic-gate 		/* Used for classifier match performance */
2147c478bd9Sstevel@tonic-gate 		uint32_t		conn_ports2;
2157c478bd9Sstevel@tonic-gate 		struct {
2167c478bd9Sstevel@tonic-gate 			in_port_t	tcpu_fport;	/* Remote port */
2177c478bd9Sstevel@tonic-gate 			in_port_t	tcpu_lport;	/* Local port */
2187c478bd9Sstevel@tonic-gate 		} tcpu_ports;
2197c478bd9Sstevel@tonic-gate 	} u_port;
2207c478bd9Sstevel@tonic-gate #define	conn_fport	u_port.tcpu_ports.tcpu_fport
2217c478bd9Sstevel@tonic-gate #define	conn_lport	u_port.tcpu_ports.tcpu_lport
2227c478bd9Sstevel@tonic-gate #define	conn_ports	u_port.conn_ports2
2237c478bd9Sstevel@tonic-gate #define	conn_upq	conn_rq
2247c478bd9Sstevel@tonic-gate 	uint8_t		conn_ulp;		/* protocol type */
2257c478bd9Sstevel@tonic-gate 	uint8_t		conn_unused_byte;
2267c478bd9Sstevel@tonic-gate 	kcondvar_t	conn_cv;
2277c478bd9Sstevel@tonic-gate 
2287c478bd9Sstevel@tonic-gate 	uint_t		conn_proto;		/* SO_PROTOTYPE state */
2297c478bd9Sstevel@tonic-gate 	ill_t		*conn_incoming_ill;	/* IP{,V6}_BOUND_IF */
2307c478bd9Sstevel@tonic-gate 	ill_t		*conn_outgoing_pill;	/* IP{,V6}_BOUND_PIF */
2317c478bd9Sstevel@tonic-gate 	ill_t		*conn_oper_pending_ill; /* pending shared ioctl */
2327c478bd9Sstevel@tonic-gate 	ill_t		*conn_xioctl_pending_ill; /* pending excl ioctl */
2337c478bd9Sstevel@tonic-gate 
2347c478bd9Sstevel@tonic-gate 	/* this is used only when an unbind is in progress.. */
2357c478bd9Sstevel@tonic-gate 	struct sq_s	*conn_pending_sq; /* waiting for ioctl on sq */
2367c478bd9Sstevel@tonic-gate 	ilg_t	*conn_ilg;		/* Group memberships */
2377c478bd9Sstevel@tonic-gate 	int	conn_ilg_allocated;	/* Number allocated */
2387c478bd9Sstevel@tonic-gate 	int	conn_ilg_inuse;		/* Number currently used */
2397c478bd9Sstevel@tonic-gate 	int	conn_ilg_walker_cnt;	/* No of ilg walkers */
2407c478bd9Sstevel@tonic-gate 	/* XXXX get rid of this, once ilg_delete_all is fixed */
2417c478bd9Sstevel@tonic-gate 	kcondvar_t	conn_refcv;
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate 	struct ipif_s	*conn_multicast_ipif;	/* IP_MULTICAST_IF */
2447c478bd9Sstevel@tonic-gate 	ill_t		*conn_multicast_ill;	/* IPV6_MULTICAST_IF */
2457c478bd9Sstevel@tonic-gate 	int		conn_orig_bound_ifindex; /* BOUND_IF before MOVE */
2467c478bd9Sstevel@tonic-gate 	int		conn_orig_multicast_ifindex;
2477c478bd9Sstevel@tonic-gate 						/* IPv6 MC IF before MOVE */
2487c478bd9Sstevel@tonic-gate 	int		conn_orig_xmit_ifindex; /* IP_XMIT_IF before move */
2497c478bd9Sstevel@tonic-gate 	struct conn_s 	*conn_drain_next;	/* Next conn in drain list */
2507c478bd9Sstevel@tonic-gate 	struct conn_s	*conn_drain_prev;	/* Prev conn in drain list */
2517c478bd9Sstevel@tonic-gate 	idl_t		*conn_idl;		/* Ptr to the drain list head */
2527c478bd9Sstevel@tonic-gate 	mblk_t		*conn_ipsec_opt_mp;	/* ipsec option mblk */
2537c478bd9Sstevel@tonic-gate 	uint32_t	conn_src_preferences;	/* prefs for src addr select */
2547c478bd9Sstevel@tonic-gate 	/* mtuinfo from IPV6_PACKET_TOO_BIG conditional on conn_pathmtu_valid */
2557c478bd9Sstevel@tonic-gate 	struct ip6_mtuinfo mtuinfo;
2567c478bd9Sstevel@tonic-gate 	zoneid_t	conn_zoneid;		/* zone connection is in */
25743d18f1cSpriyanka 	in6_addr_t	conn_nexthop_v6;	/* nexthop IP address */
25843d18f1cSpriyanka #define	conn_nexthop_v4	V4_PART_OF_V6(conn_nexthop_v6)
25945916cd2Sjpk 	cred_t		*conn_peercred;		/* Peer credentials, if any */
26045916cd2Sjpk 
26145916cd2Sjpk 	unsigned int
26245916cd2Sjpk 		conn_ulp_labeled : 1,		/* ULP label is synced */
26345916cd2Sjpk 		conn_mlp_type : 2,		/* mlp_type_t; tsol/tndb.h */
26445916cd2Sjpk 		conn_anon_mlp : 1,		/* user wants anon MLP */
26545916cd2Sjpk 
26645916cd2Sjpk 		conn_anon_port : 1,		/* user bound anonymously */
26745916cd2Sjpk 		conn_mac_exempt : 1,		/* unlabeled with loose MAC */
26845916cd2Sjpk 		conn_spare : 26;
26945916cd2Sjpk 
2707c478bd9Sstevel@tonic-gate #ifdef CONN_DEBUG
2717c478bd9Sstevel@tonic-gate #define	CONN_TRACE_MAX	10
2727c478bd9Sstevel@tonic-gate 	int		conn_trace_last;	/* ndx of last used tracebuf */
2737c478bd9Sstevel@tonic-gate 	conn_trace_t	conn_trace_buf[CONN_TRACE_MAX];
2747c478bd9Sstevel@tonic-gate #endif
2757c478bd9Sstevel@tonic-gate };
2767c478bd9Sstevel@tonic-gate 
27745916cd2Sjpk #define	CONN_CRED(connp) ((connp)->conn_peercred == NULL ? \
27845916cd2Sjpk 	(connp)->conn_cred : (connp)->conn_peercred)
27945916cd2Sjpk #define	BEST_CRED(mp, connp) ((DB_CRED(mp) != NULL &&	\
28045916cd2Sjpk 	crgetlabel(DB_CRED(mp)) != NULL) ? DB_CRED(mp) : CONN_CRED(connp))
28145916cd2Sjpk 
2827c478bd9Sstevel@tonic-gate /*
2837c478bd9Sstevel@tonic-gate  * connf_t - connection fanout data.
2847c478bd9Sstevel@tonic-gate  *
2857c478bd9Sstevel@tonic-gate  * The hash tables and their linkage (conn_t.{hashnextp, hashprevp} are
2867c478bd9Sstevel@tonic-gate  * protected by the per-bucket lock. Each conn_t inserted in the list
2877c478bd9Sstevel@tonic-gate  * points back at the connf_t that heads the bucket.
2887c478bd9Sstevel@tonic-gate  */
2897c478bd9Sstevel@tonic-gate 
2907c478bd9Sstevel@tonic-gate struct connf_s {
2917c478bd9Sstevel@tonic-gate 	struct conn_s	*connf_head;
2927c478bd9Sstevel@tonic-gate 	kmutex_t	connf_lock;
2937c478bd9Sstevel@tonic-gate };
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate #define	CONN_INC_REF(connp)	{				\
2967c478bd9Sstevel@tonic-gate 	DTRACE_PROBE1(conn__inc__ref, conn_t *, connp);		\
2977c478bd9Sstevel@tonic-gate 	mutex_enter(&(connp)->conn_lock);			\
2987c478bd9Sstevel@tonic-gate 	ASSERT(conn_trace_ref(connp));				\
2997c478bd9Sstevel@tonic-gate 	(connp)->conn_ref++;					\
3007c478bd9Sstevel@tonic-gate 	ASSERT((connp)->conn_ref != 0);				\
3017c478bd9Sstevel@tonic-gate 	mutex_exit(&(connp)->conn_lock);			\
3027c478bd9Sstevel@tonic-gate }
3037c478bd9Sstevel@tonic-gate 
3047c478bd9Sstevel@tonic-gate #define	CONN_INC_REF_LOCKED(connp)	{			\
3057c478bd9Sstevel@tonic-gate 	DTRACE_PROBE1(conn__inc__ref, conn_t *, connp);		\
3067c478bd9Sstevel@tonic-gate 	ASSERT(MUTEX_HELD(&(connp)->conn_lock));	 	\
3077c478bd9Sstevel@tonic-gate 	ASSERT(conn_trace_ref(connp));				\
3087c478bd9Sstevel@tonic-gate 	(connp)->conn_ref++;					\
3097c478bd9Sstevel@tonic-gate 	ASSERT((connp)->conn_ref != 0);				\
3107c478bd9Sstevel@tonic-gate }
3117c478bd9Sstevel@tonic-gate 
3127c478bd9Sstevel@tonic-gate #define	CONN_DEC_REF(connp)	{					\
3137c478bd9Sstevel@tonic-gate 	DTRACE_PROBE1(conn__dec__ref, conn_t *, connp);			\
3147c478bd9Sstevel@tonic-gate 	mutex_enter(&(connp)->conn_lock);				\
3157c478bd9Sstevel@tonic-gate 	if ((connp)->conn_ref <= 0)					\
3167c478bd9Sstevel@tonic-gate 		cmn_err(CE_PANIC, "CONN_DEC_REF: connp(%p) has ref "	\
3177c478bd9Sstevel@tonic-gate 			"= %d\n", (void *)(connp), (connp)->conn_ref);	\
3187c478bd9Sstevel@tonic-gate 	ASSERT(conn_untrace_ref(connp));				\
3197c478bd9Sstevel@tonic-gate 	(connp)->conn_ref--;						\
3207c478bd9Sstevel@tonic-gate 	if ((connp)->conn_ref == 0) {					\
3217c478bd9Sstevel@tonic-gate 		/* Refcnt can't increase again, safe to drop lock */	\
3227c478bd9Sstevel@tonic-gate 		mutex_exit(&(connp)->conn_lock);			\
3237c478bd9Sstevel@tonic-gate 		ipcl_conn_destroy(connp);				\
3247c478bd9Sstevel@tonic-gate 	} else {							\
3257c478bd9Sstevel@tonic-gate 		cv_broadcast(&(connp)->conn_cv);			\
3267c478bd9Sstevel@tonic-gate 		mutex_exit(&(connp)->conn_lock);			\
3277c478bd9Sstevel@tonic-gate 	}								\
3287c478bd9Sstevel@tonic-gate }
3297c478bd9Sstevel@tonic-gate 
330*5d0bc3edSsommerfe /*
331*5d0bc3edSsommerfe  * For use with subsystems within ip which use ALL_ZONES as a wildcard
332*5d0bc3edSsommerfe  */
333*5d0bc3edSsommerfe #define	IPCL_ZONEID(connp)						\
334*5d0bc3edSsommerfe 	((connp)->conn_allzones ? ALL_ZONES : (connp)->conn_zoneid)
335*5d0bc3edSsommerfe 
336*5d0bc3edSsommerfe /*
337*5d0bc3edSsommerfe  * For matching between a conn_t and a zoneid.
338*5d0bc3edSsommerfe  */
339*5d0bc3edSsommerfe #define	IPCL_ZONE_MATCH(connp, zoneid) 					\
340*5d0bc3edSsommerfe 	(((connp)->conn_allzones) ||					\
341*5d0bc3edSsommerfe 	    ((zoneid) == ALL_ZONES) ||					\
342*5d0bc3edSsommerfe 	    (connp)->conn_zoneid == (zoneid))
343*5d0bc3edSsommerfe 
344*5d0bc3edSsommerfe 
3457c478bd9Sstevel@tonic-gate #define	_IPCL_V4_MATCH(v6addr, v4addr)	\
3467c478bd9Sstevel@tonic-gate 	(V4_PART_OF_V6((v6addr)) == (v4addr) && IN6_IS_ADDR_V4MAPPED(&(v6addr)))
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate #define	_IPCL_V4_MATCH_ANY(addr)	\
3497c478bd9Sstevel@tonic-gate 	(IN6_IS_ADDR_V4MAPPED_ANY(&(addr)) || IN6_IS_ADDR_UNSPECIFIED(&(addr)))
3507c478bd9Sstevel@tonic-gate 
351*5d0bc3edSsommerfe 
3527c478bd9Sstevel@tonic-gate /*
3537c478bd9Sstevel@tonic-gate  * IPCL_PROTO_MATCH() only matches conns with the specified zoneid, while
3547c478bd9Sstevel@tonic-gate  * IPCL_PROTO_MATCH_V6() can match other conns in the multicast case, see
3557c478bd9Sstevel@tonic-gate  * ip_fanout_proto().
3567c478bd9Sstevel@tonic-gate  */
3577c478bd9Sstevel@tonic-gate #define	IPCL_PROTO_MATCH(connp, protocol, ipha, ill,			\
3587c478bd9Sstevel@tonic-gate     fanout_flags, zoneid)						\
3597c478bd9Sstevel@tonic-gate 	((((connp)->conn_src == INADDR_ANY) ||				\
3607c478bd9Sstevel@tonic-gate 	(((connp)->conn_src == ((ipha)->ipha_dst)) &&			\
3617c478bd9Sstevel@tonic-gate 	    (((connp)->conn_rem == INADDR_ANY) ||			\
3627c478bd9Sstevel@tonic-gate 	((connp)->conn_rem == ((ipha)->ipha_src))))) &&			\
363*5d0bc3edSsommerfe 	IPCL_ZONE_MATCH(connp, zoneid) &&				\
364*5d0bc3edSsommerfe 	(conn_wantpacket((connp), (ill), (ipha), (fanout_flags), 	\
365*5d0bc3edSsommerfe 	    (zoneid)) || ((protocol) == IPPROTO_PIM) ||			\
3667c478bd9Sstevel@tonic-gate 	    ((protocol) == IPPROTO_RSVP)))
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate #define	IPCL_PROTO_MATCH_V6(connp, protocol, ip6h, ill,			   \
3697c478bd9Sstevel@tonic-gate     fanout_flags, zoneid)						   \
3707c478bd9Sstevel@tonic-gate 	((IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_srcv6) ||		   \
3717c478bd9Sstevel@tonic-gate 	(IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &((ip6h)->ip6_dst)) &&   \
3727c478bd9Sstevel@tonic-gate 	(IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_remv6) ||		   \
3737c478bd9Sstevel@tonic-gate 	IN6_ARE_ADDR_EQUAL(&(connp)->conn_remv6, &((ip6h)->ip6_src))))) && \
3747c478bd9Sstevel@tonic-gate 	(conn_wantpacket_v6((connp), (ill), (ip6h),			   \
3757c478bd9Sstevel@tonic-gate 	(fanout_flags), (zoneid)) || ((protocol) == IPPROTO_RSVP)))
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate #define	IPCL_CONN_HASH(src, ports)					\
3787c478bd9Sstevel@tonic-gate 	((unsigned)(ntohl((src)) ^ ((ports) >> 24) ^ ((ports) >> 16) ^	\
3797c478bd9Sstevel@tonic-gate 	((ports) >> 8) ^ (ports)) % ipcl_conn_fanout_size)
3807c478bd9Sstevel@tonic-gate 
3817c478bd9Sstevel@tonic-gate #define	IPCL_CONN_HASH_V6(src, ports)			\
3827c478bd9Sstevel@tonic-gate 	IPCL_CONN_HASH(V4_PART_OF_V6((src)), (ports))
3837c478bd9Sstevel@tonic-gate 
3847c478bd9Sstevel@tonic-gate #define	IPCL_CONN_MATCH(connp, proto, src, dst, ports)			\
3857c478bd9Sstevel@tonic-gate 	((connp)->conn_ulp == (proto) &&				\
3867c478bd9Sstevel@tonic-gate 		(connp)->conn_ports == (ports) &&      			\
3877c478bd9Sstevel@tonic-gate 		_IPCL_V4_MATCH((connp)->conn_remv6, (src)) &&		\
3887c478bd9Sstevel@tonic-gate 		_IPCL_V4_MATCH((connp)->conn_srcv6, (dst)) &&		\
3897c478bd9Sstevel@tonic-gate 		!(connp)->conn_ipv6_v6only)
3907c478bd9Sstevel@tonic-gate 
3917c478bd9Sstevel@tonic-gate #define	IPCL_CONN_MATCH_V6(connp, proto, src, dst, ports)		\
3927c478bd9Sstevel@tonic-gate 	((connp)->conn_ulp == (proto) &&				\
3937c478bd9Sstevel@tonic-gate 		(connp)->conn_ports == (ports) &&      			\
3947c478bd9Sstevel@tonic-gate 		IN6_ARE_ADDR_EQUAL(&(connp)->conn_remv6, &(src)) &&	\
3957c478bd9Sstevel@tonic-gate 		IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &(dst)))
3967c478bd9Sstevel@tonic-gate 
3977c478bd9Sstevel@tonic-gate #define	IPCL_CONN_INIT(connp, protocol, src, rem, ports) {		\
3987c478bd9Sstevel@tonic-gate 	(connp)->conn_ulp = protocol;					\
3997c478bd9Sstevel@tonic-gate 	IN6_IPADDR_TO_V4MAPPED(src, &(connp)->conn_srcv6);		\
4007c478bd9Sstevel@tonic-gate 	IN6_IPADDR_TO_V4MAPPED(rem, &(connp)->conn_remv6);		\
4017c478bd9Sstevel@tonic-gate 	(connp)->conn_ports = ports;					\
4027c478bd9Sstevel@tonic-gate }
4037c478bd9Sstevel@tonic-gate 
4047c478bd9Sstevel@tonic-gate #define	IPCL_CONN_INIT_V6(connp, protocol, src, rem, ports) {		\
4057c478bd9Sstevel@tonic-gate 	(connp)->conn_ulp = protocol;					\
4067c478bd9Sstevel@tonic-gate 	(connp)->conn_srcv6 = src;					\
4077c478bd9Sstevel@tonic-gate 	(connp)->conn_remv6 = rem;					\
4087c478bd9Sstevel@tonic-gate 	(connp)->conn_ports = ports;					\
4097c478bd9Sstevel@tonic-gate }
4107c478bd9Sstevel@tonic-gate 
411ee4701baSericheng #define	IPCL_PORT_HASH(port, size) \
412ee4701baSericheng 	((((port) >> 8) ^ (port)) & ((size) - 1))
413ee4701baSericheng 
414ee4701baSericheng #define	IPCL_BIND_HASH(lport)	IPCL_PORT_HASH(lport, ipcl_bind_fanout_size)
4157c478bd9Sstevel@tonic-gate 
4167c478bd9Sstevel@tonic-gate #define	IPCL_BIND_MATCH(connp, proto, laddr, lport)			\
4177c478bd9Sstevel@tonic-gate 	((connp)->conn_ulp == (proto) &&				\
4187c478bd9Sstevel@tonic-gate 		(connp)->conn_lport == (lport) &&			\
4197c478bd9Sstevel@tonic-gate 		(_IPCL_V4_MATCH_ANY((connp)->conn_srcv6) ||		\
4207c478bd9Sstevel@tonic-gate 		_IPCL_V4_MATCH((connp)->conn_srcv6, (laddr))) &&	\
4217c478bd9Sstevel@tonic-gate 		!(connp)->conn_ipv6_v6only)
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate #define	IPCL_BIND_MATCH_V6(connp, proto, laddr, lport)			\
4247c478bd9Sstevel@tonic-gate 	((connp)->conn_ulp == (proto) &&				\
4257c478bd9Sstevel@tonic-gate 		(connp)->conn_lport == (lport) &&			\
4267c478bd9Sstevel@tonic-gate 		(IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &(laddr)) ||	\
4277c478bd9Sstevel@tonic-gate 		IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_srcv6)))
4287c478bd9Sstevel@tonic-gate 
4297c478bd9Sstevel@tonic-gate #define	IPCL_UDP_MATCH(connp, lport, laddr, fport, faddr)		\
4307c478bd9Sstevel@tonic-gate 	(((connp)->conn_lport == (lport)) &&				\
4317c478bd9Sstevel@tonic-gate 	((_IPCL_V4_MATCH_ANY((connp)->conn_srcv6) ||			\
4327c478bd9Sstevel@tonic-gate 	(_IPCL_V4_MATCH((connp)->conn_srcv6, (laddr)) &&		\
4337c478bd9Sstevel@tonic-gate 	(_IPCL_V4_MATCH_ANY((connp)->conn_remv6) ||			\
4347c478bd9Sstevel@tonic-gate 	(_IPCL_V4_MATCH((connp)->conn_remv6, (faddr)) &&		\
4357c478bd9Sstevel@tonic-gate 	(connp)->conn_fport == (fport)))))) &&				\
4367c478bd9Sstevel@tonic-gate 	!(connp)->conn_ipv6_v6only)
4377c478bd9Sstevel@tonic-gate 
4387c478bd9Sstevel@tonic-gate #define	IPCL_UDP_MATCH_V6(connp, lport, laddr, fport, faddr)	\
4397c478bd9Sstevel@tonic-gate 	(((connp)->conn_lport == (lport)) &&			\
4407c478bd9Sstevel@tonic-gate 	(IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_srcv6) ||	\
4417c478bd9Sstevel@tonic-gate 	(IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &(laddr)) &&	\
4427c478bd9Sstevel@tonic-gate 	(IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_remv6) ||	\
4437c478bd9Sstevel@tonic-gate 	(IN6_ARE_ADDR_EQUAL(&(connp)->conn_remv6, &(faddr)) &&	\
4447c478bd9Sstevel@tonic-gate 	(connp)->conn_fport == (fport))))))
4457c478bd9Sstevel@tonic-gate 
4467c478bd9Sstevel@tonic-gate #define	IPCL_TCP_EAGER_INIT(connp, protocol, src, rem, ports) {		\
4477c478bd9Sstevel@tonic-gate 	(connp)->conn_flags |= (IPCL_TCP4|IPCL_EAGER);			\
4487c478bd9Sstevel@tonic-gate 	(connp)->conn_ulp = protocol;					\
4497c478bd9Sstevel@tonic-gate 	IN6_IPADDR_TO_V4MAPPED(src, &(connp)->conn_srcv6);		\
4507c478bd9Sstevel@tonic-gate 	IN6_IPADDR_TO_V4MAPPED(rem, &(connp)->conn_remv6);		\
4517c478bd9Sstevel@tonic-gate 	(connp)->conn_ports = ports;					\
4527c478bd9Sstevel@tonic-gate 	(connp)->conn_send = ip_output;					\
4537c478bd9Sstevel@tonic-gate 	(connp)->conn_sqp = IP_SQUEUE_GET(lbolt);			\
4547c478bd9Sstevel@tonic-gate }
4557c478bd9Sstevel@tonic-gate 
4567c478bd9Sstevel@tonic-gate #define	IPCL_TCP_EAGER_INIT_V6(connp, protocol, src, rem, ports) {	\
4577c478bd9Sstevel@tonic-gate 	(connp)->conn_flags |= (IPCL_TCP6|IPCL_EAGER);			\
4587c478bd9Sstevel@tonic-gate 	(connp)->conn_ulp = protocol;					\
4597c478bd9Sstevel@tonic-gate 	(connp)->conn_srcv6 = src;					\
4607c478bd9Sstevel@tonic-gate 	(connp)->conn_remv6 = rem;					\
4617c478bd9Sstevel@tonic-gate 	(connp)->conn_ports = ports;					\
4627c478bd9Sstevel@tonic-gate 	(connp)->conn_send = ip_output_v6;				\
4637c478bd9Sstevel@tonic-gate 	(connp)->conn_sqp = IP_SQUEUE_GET(lbolt);			\
4647c478bd9Sstevel@tonic-gate }
4657c478bd9Sstevel@tonic-gate 
4667c478bd9Sstevel@tonic-gate #define	ipcl_proto_search(protocol)					\
4677c478bd9Sstevel@tonic-gate 	(ipcl_proto_fanout[(protocol)].connf_head)
4687c478bd9Sstevel@tonic-gate 
469ee4701baSericheng #define	IPCL_UDP_HASH(lport)	IPCL_PORT_HASH(lport, ipcl_udp_fanout_size)
4707c478bd9Sstevel@tonic-gate 
4717c478bd9Sstevel@tonic-gate #define	CONN_G_HASH_SIZE	1024
4727c478bd9Sstevel@tonic-gate 
4737c478bd9Sstevel@tonic-gate /* Raw socket hash function. */
474ee4701baSericheng #define	IPCL_RAW_HASH(lport)	IPCL_PORT_HASH(lport, ipcl_raw_fanout_size)
4757c478bd9Sstevel@tonic-gate 
4767c0c0508Skcpoon /*
4777c0c0508Skcpoon  * This is similar to IPCL_BIND_MATCH except that the local port check
4787c0c0508Skcpoon  * is changed to a wildcard port check.
4797c0c0508Skcpoon  */
4807c0c0508Skcpoon #define	IPCL_RAW_MATCH(connp, proto, laddr)			\
4817c0c0508Skcpoon 	((connp)->conn_ulp == (proto) &&			\
4827c0c0508Skcpoon 	(connp)->conn_lport == 0 &&				\
4837c0c0508Skcpoon 	(_IPCL_V4_MATCH_ANY((connp)->conn_srcv6) ||		\
4847c0c0508Skcpoon 	_IPCL_V4_MATCH((connp)->conn_srcv6, (laddr))))
4857c0c0508Skcpoon 
4867c0c0508Skcpoon #define	IPCL_RAW_MATCH_V6(connp, proto, laddr)			\
4877c0c0508Skcpoon 	((connp)->conn_ulp == (proto) &&			\
4887c0c0508Skcpoon 	(connp)->conn_lport == 0 &&				\
4897c0c0508Skcpoon 	(IN6_IS_ADDR_UNSPECIFIED(&(connp)->conn_srcv6) ||	\
4907c0c0508Skcpoon 	IN6_ARE_ADDR_EQUAL(&(connp)->conn_srcv6, &(laddr))))
4917c0c0508Skcpoon 
4927c478bd9Sstevel@tonic-gate /* hash tables */
4937c478bd9Sstevel@tonic-gate extern connf_t	rts_clients;
4947c478bd9Sstevel@tonic-gate extern connf_t	*ipcl_conn_fanout;
4957c478bd9Sstevel@tonic-gate extern connf_t	*ipcl_bind_fanout;
4967c478bd9Sstevel@tonic-gate extern connf_t	ipcl_proto_fanout[IPPROTO_MAX + 1];
4977c478bd9Sstevel@tonic-gate extern connf_t	ipcl_proto_fanout_v6[IPPROTO_MAX + 1];
4987c478bd9Sstevel@tonic-gate extern connf_t	*ipcl_udp_fanout;
4997c478bd9Sstevel@tonic-gate extern connf_t	*ipcl_globalhash_fanout;
5007c478bd9Sstevel@tonic-gate extern connf_t	*ipcl_raw_fanout;
5017c478bd9Sstevel@tonic-gate extern uint_t	ipcl_conn_fanout_size;
5027c478bd9Sstevel@tonic-gate extern uint_t	ipcl_bind_fanout_size;
5037c478bd9Sstevel@tonic-gate extern uint_t	ipcl_udp_fanout_size;
5047c478bd9Sstevel@tonic-gate extern uint_t	ipcl_raw_fanout_size;
5057c478bd9Sstevel@tonic-gate 
5067c478bd9Sstevel@tonic-gate /* Function prototypes */
5077c478bd9Sstevel@tonic-gate extern void ipcl_init(void);
5087c478bd9Sstevel@tonic-gate extern void ipcl_destroy(void);
5097c478bd9Sstevel@tonic-gate extern conn_t *ipcl_conn_create(uint32_t, int);
5107c478bd9Sstevel@tonic-gate extern void ipcl_conn_destroy(conn_t *);
5117c478bd9Sstevel@tonic-gate 
5127c478bd9Sstevel@tonic-gate void ipcl_hash_insert_connected(connf_t *, conn_t *);
5137c478bd9Sstevel@tonic-gate void ipcl_hash_insert_bound(connf_t *, conn_t *);
5147c478bd9Sstevel@tonic-gate void ipcl_hash_insert_wildcard(connf_t *, conn_t *);
5157c478bd9Sstevel@tonic-gate void ipcl_hash_remove(conn_t *);
5167c478bd9Sstevel@tonic-gate void ipcl_hash_remove_locked(conn_t *connp, connf_t *connfp);
5177c478bd9Sstevel@tonic-gate 
5187c478bd9Sstevel@tonic-gate extern int	ipcl_bind_insert(conn_t *, uint8_t, ipaddr_t, uint16_t);
5197c478bd9Sstevel@tonic-gate extern int	ipcl_bind_insert_v6(conn_t *, uint8_t, const in6_addr_t *,
5207c478bd9Sstevel@tonic-gate 		    uint16_t);
5217c478bd9Sstevel@tonic-gate extern int	ipcl_conn_insert(conn_t *, uint8_t, ipaddr_t, ipaddr_t,
5227c478bd9Sstevel@tonic-gate 		    uint32_t);
5237c478bd9Sstevel@tonic-gate extern int	ipcl_conn_insert_v6(conn_t *, uint8_t, const in6_addr_t *,
5247c478bd9Sstevel@tonic-gate 		    const in6_addr_t *, uint32_t, uint_t);
525ff550d0eSmasputra extern conn_t	*ipcl_get_next_conn(connf_t *, conn_t *, uint32_t);
5267c478bd9Sstevel@tonic-gate 
5277c478bd9Sstevel@tonic-gate void ipcl_proto_insert(conn_t *, uint8_t);
5287c478bd9Sstevel@tonic-gate void ipcl_proto_insert_v6(conn_t *, uint8_t);
5297c478bd9Sstevel@tonic-gate conn_t *ipcl_classify_v4(mblk_t *, uint8_t, uint_t, zoneid_t);
5307c478bd9Sstevel@tonic-gate conn_t *ipcl_classify_v6(mblk_t *, uint8_t, uint_t, zoneid_t);
5317c478bd9Sstevel@tonic-gate conn_t *ipcl_classify(mblk_t *, zoneid_t);
53245916cd2Sjpk conn_t *ipcl_classify_raw(mblk_t *, uint8_t, zoneid_t, uint32_t, ipha_t *);
5337c478bd9Sstevel@tonic-gate void	ipcl_globalhash_insert(conn_t *);
5347c478bd9Sstevel@tonic-gate void	ipcl_globalhash_remove(conn_t *);
5357c478bd9Sstevel@tonic-gate void	ipcl_walk(pfv_t, void *);
5367c478bd9Sstevel@tonic-gate conn_t	*ipcl_tcp_lookup_reversed_ipv4(ipha_t *, tcph_t *, int);
5377c478bd9Sstevel@tonic-gate conn_t	*ipcl_tcp_lookup_reversed_ipv6(ip6_t *, tcpha_t *, int, uint_t);
5387c478bd9Sstevel@tonic-gate conn_t	*ipcl_lookup_listener_v4(uint16_t, ipaddr_t, zoneid_t);
5397c478bd9Sstevel@tonic-gate conn_t	*ipcl_lookup_listener_v6(uint16_t, in6_addr_t *, uint_t, zoneid_t);
5407c478bd9Sstevel@tonic-gate int	conn_trace_ref(conn_t *);
5417c478bd9Sstevel@tonic-gate int	conn_untrace_ref(conn_t *);
5427c478bd9Sstevel@tonic-gate conn_t *ipcl_conn_tcp_lookup_reversed_ipv4(conn_t *, ipha_t *, tcph_t *);
5437c478bd9Sstevel@tonic-gate conn_t *ipcl_conn_tcp_lookup_reversed_ipv6(conn_t *, ip6_t *, tcph_t *);
5447c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
5457c478bd9Sstevel@tonic-gate }
5467c478bd9Sstevel@tonic-gate #endif
5477c478bd9Sstevel@tonic-gate 
5487c478bd9Sstevel@tonic-gate #endif	/* _INET_IPCLASSIFIER_H */
549