69 /* Unused 0x00400000 */
70 #define IPCL_CL_LISTENER 0x00800000 /* Cluster listener */
71 /* Unused 0x01000000 */
72 /* Unused 0x02000000 */
73 /* Unused 0x04000000 */
74 /* Unused 0x08000000 */
75 /* Unused 0x10000000 */
76 /* Unused 0x20000000 */
77 #define IPCL_CONNECTED 0x40000000 /* Conn in connected table */
78 #define IPCL_BOUND 0x80000000 /* Conn in bind table */
79
80 /* Flags identifying the type of conn */
81 #define IPCL_TCPCONN 0x00000001 /* From tcp_conn_cache */
82 #define IPCL_SCTPCONN 0x00000002 /* From sctp_conn_cache */
83 #define IPCL_IPCCONN 0x00000004 /* From ip_conn_cache */
84 #define IPCL_UDPCONN 0x00000008 /* From udp_conn_cache */
85 #define IPCL_RAWIPCONN 0x00000010 /* From rawip_conn_cache */
86 #define IPCL_RTSCONN 0x00000020 /* From rts_conn_cache */
87 /* Unused 0x00000040 */
88 #define IPCL_IPTUN 0x00000080 /* iptun module above us */
89
90 #define IPCL_NONSTR 0x00001000 /* A non-STREAMS socket */
91 /* Unused 0x10000000 */
92
93 #define IPCL_REMOVED 0x00000100
94 #define IPCL_REUSED 0x00000200
95
96 #define IPCL_IS_CONNECTED(connp) \
97 ((connp)->conn_flags & IPCL_CONNECTED)
98
99 #define IPCL_IS_BOUND(connp) \
100 ((connp)->conn_flags & IPCL_BOUND)
101
102 /*
103 * Can't use conn_proto since we need to tell difference
104 * between a real TCP socket and a SOCK_RAW, IPPROTO_TCP.
105 */
106 #define IPCL_IS_TCP(connp) \
107 ((connp)->conn_flags & IPCL_TCPCONN)
108
109 #define IPCL_IS_SCTP(connp) \
110 ((connp)->conn_flags & IPCL_SCTPCONN)
111
112 #define IPCL_IS_UDP(connp) \
113 ((connp)->conn_flags & IPCL_UDPCONN)
114
115 #define IPCL_IS_RAWIP(connp) \
116 ((connp)->conn_flags & IPCL_RAWIPCONN)
117
118 #define IPCL_IS_RTS(connp) \
119 ((connp)->conn_flags & IPCL_RTSCONN)
120
121 #define IPCL_IS_IPTUN(connp) \
122 ((connp)->conn_flags & IPCL_IPTUN)
123
124 #define IPCL_IS_NONSTR(connp) ((connp)->conn_flags & IPCL_NONSTR)
125
126 typedef struct connf_s connf_t;
127
128 typedef struct
129 {
130 int ctb_depth;
131 #define CONN_STACK_DEPTH 15
132 pc_t ctb_stack[CONN_STACK_DEPTH];
133 } conn_trace_t;
134
135 typedef struct ip_helper_minor_info_s {
136 dev_t ip_minfo_dev; /* Device */
137 vmem_t *ip_minfo_arena; /* Arena */
138 } ip_helper_minfo_t;
139
140 /*
141 * ip helper stream info
142 */
143 typedef struct ip_helper_stream_info_s {
220 * and are preserved when it is freed. Fields after that are bzero'ed when
221 * the conn_t is freed.
222 *
223 * Much of the conn_t is protected by conn_lock.
224 *
225 * conn_lock is also used by some ULPs (like UDP and RAWIP) to protect
226 * their state.
227 */
228 struct conn_s {
229 kmutex_t conn_lock;
230 uint32_t conn_ref; /* Reference counter */
231 uint32_t conn_flags; /* Conn Flags */
232
233 union {
234 tcp_t *cp_tcp; /* Pointer to the tcp struct */
235 struct udp_s *cp_udp; /* Pointer to the udp struct */
236 struct icmp_s *cp_icmp; /* Pointer to rawip struct */
237 struct rts_s *cp_rts; /* Pointer to rts struct */
238 struct iptun_s *cp_iptun; /* Pointer to iptun_t */
239 struct sctp_s *cp_sctp; /* For IPCL_SCTPCONN */
240 void *cp_priv;
241 } conn_proto_priv;
242 #define conn_tcp conn_proto_priv.cp_tcp
243 #define conn_udp conn_proto_priv.cp_udp
244 #define conn_icmp conn_proto_priv.cp_icmp
245 #define conn_rts conn_proto_priv.cp_rts
246 #define conn_iptun conn_proto_priv.cp_iptun
247 #define conn_sctp conn_proto_priv.cp_sctp
248 #define conn_priv conn_proto_priv.cp_priv
249
250 kcondvar_t conn_cv;
251 uint8_t conn_proto; /* protocol type */
252
253 edesc_rpf conn_recv; /* Pointer to recv routine */
254 edesc_rpf conn_recvicmp; /* For ICMP error */
255 edesc_vpf conn_verifyicmp; /* Verify ICMP error */
256
257 ip_xmit_attr_t *conn_ixa; /* Options if no ancil data */
258
259 /* Fields after this are bzero'ed when the conn_t is freed. */
260 #define conn_start_clr conn_recv_ancillary
261
262 /* Options for receive-side ancillary data */
263 crb_t conn_recv_ancillary;
264
265 squeue_t *conn_sqp; /* Squeue for processing */
266 uint_t conn_state_flags; /* IP state flags */
267
634 ((ntohl(laddr) ^ ((ntohl(faddr) << 24) | (ntohl(faddr) >> 8))) % \
635 ipcl_iptun_fanout_size)
636
637 #define IPCL_IPTUN_HASH_V6(laddr, faddr) \
638 IPCL_IPTUN_HASH((laddr)->s6_addr32[0] ^ (laddr)->s6_addr32[1] ^ \
639 (faddr)->s6_addr32[2] ^ (faddr)->s6_addr32[3], \
640 (faddr)->s6_addr32[0] ^ (faddr)->s6_addr32[1] ^ \
641 (laddr)->s6_addr32[2] ^ (laddr)->s6_addr32[3])
642
643 #define IPCL_IPTUN_MATCH(connp, laddr, faddr) \
644 (_IPCL_V4_MATCH((connp)->conn_laddr_v6, (laddr)) && \
645 _IPCL_V4_MATCH((connp)->conn_faddr_v6, (faddr)))
646
647 #define IPCL_IPTUN_MATCH_V6(connp, laddr, faddr) \
648 (IN6_ARE_ADDR_EQUAL(&(connp)->conn_laddr_v6, (laddr)) && \
649 IN6_ARE_ADDR_EQUAL(&(connp)->conn_faddr_v6, (faddr)))
650
651 #define IPCL_UDP_HASH(lport, ipst) \
652 IPCL_PORT_HASH(lport, (ipst)->ips_ipcl_udp_fanout_size)
653
654 #define CONN_G_HASH_SIZE 1024
655
656 /* Raw socket hash function. */
657 #define IPCL_RAW_HASH(lport, ipst) \
658 IPCL_PORT_HASH(lport, (ipst)->ips_ipcl_raw_fanout_size)
659
660 /*
661 * This is similar to IPCL_BIND_MATCH except that the local port check
662 * is changed to a wildcard port check.
663 * We compare conn_laddr since it captures both connected and a bind to
664 * a multicast or broadcast address.
665 */
666 #define IPCL_RAW_MATCH(connp, proto, laddr) \
667 ((connp)->conn_proto == (proto) && \
668 (connp)->conn_lport == 0 && \
669 (_IPCL_V4_MATCH_ANY((connp)->conn_laddr_v6) || \
670 _IPCL_V4_MATCH((connp)->conn_laddr_v6, (laddr))))
671
672 #define IPCL_RAW_MATCH_V6(connp, proto, laddr) \
673 ((connp)->conn_proto == (proto) && \
|
69 /* Unused 0x00400000 */
70 #define IPCL_CL_LISTENER 0x00800000 /* Cluster listener */
71 /* Unused 0x01000000 */
72 /* Unused 0x02000000 */
73 /* Unused 0x04000000 */
74 /* Unused 0x08000000 */
75 /* Unused 0x10000000 */
76 /* Unused 0x20000000 */
77 #define IPCL_CONNECTED 0x40000000 /* Conn in connected table */
78 #define IPCL_BOUND 0x80000000 /* Conn in bind table */
79
80 /* Flags identifying the type of conn */
81 #define IPCL_TCPCONN 0x00000001 /* From tcp_conn_cache */
82 #define IPCL_SCTPCONN 0x00000002 /* From sctp_conn_cache */
83 #define IPCL_IPCCONN 0x00000004 /* From ip_conn_cache */
84 #define IPCL_UDPCONN 0x00000008 /* From udp_conn_cache */
85 #define IPCL_RAWIPCONN 0x00000010 /* From rawip_conn_cache */
86 #define IPCL_RTSCONN 0x00000020 /* From rts_conn_cache */
87 /* Unused 0x00000040 */
88 #define IPCL_IPTUN 0x00000080 /* iptun module above us */
89 #define IPCL_DCCPCONN 0x00000100 /* From dccp_conn_cache */
90
91 #define IPCL_NONSTR 0x00001000 /* A non-STREAMS socket */
92 /* Unused 0x10000000 */
93
94 #define IPCL_REMOVED 0x00000100
95 #define IPCL_REUSED 0x00000200
96
97 #define IPCL_IS_CONNECTED(connp) \
98 ((connp)->conn_flags & IPCL_CONNECTED)
99
100 #define IPCL_IS_BOUND(connp) \
101 ((connp)->conn_flags & IPCL_BOUND)
102
103 /*
104 * Can't use conn_proto since we need to tell difference
105 * between a real TCP socket and a SOCK_RAW, IPPROTO_TCP.
106 */
107 #define IPCL_IS_TCP(connp) \
108 ((connp)->conn_flags & IPCL_TCPCONN)
109
110 #define IPCL_IS_SCTP(connp) \
111 ((connp)->conn_flags & IPCL_SCTPCONN)
112
113 #define IPCL_IS_UDP(connp) \
114 ((connp)->conn_flags & IPCL_UDPCONN)
115
116 #define IPCL_IS_RAWIP(connp) \
117 ((connp)->conn_flags & IPCL_RAWIPCONN)
118
119 #define IPCL_IS_RTS(connp) \
120 ((connp)->conn_flags & IPCL_RTSCONN)
121
122 #define IPCL_IS_IPTUN(connp) \
123 ((connp)->conn_flags & IPCL_IPTUN)
124
125 #define IPCL_IS_DCCP(connp) \
126 ((connp)->conn_flags & IPCL_DCCPCONN)
127
128 #define IPCL_IS_NONSTR(connp) ((connp)->conn_flags & IPCL_NONSTR)
129
130 typedef struct connf_s connf_t;
131
132 typedef struct
133 {
134 int ctb_depth;
135 #define CONN_STACK_DEPTH 15
136 pc_t ctb_stack[CONN_STACK_DEPTH];
137 } conn_trace_t;
138
139 typedef struct ip_helper_minor_info_s {
140 dev_t ip_minfo_dev; /* Device */
141 vmem_t *ip_minfo_arena; /* Arena */
142 } ip_helper_minfo_t;
143
144 /*
145 * ip helper stream info
146 */
147 typedef struct ip_helper_stream_info_s {
224 * and are preserved when it is freed. Fields after that are bzero'ed when
225 * the conn_t is freed.
226 *
227 * Much of the conn_t is protected by conn_lock.
228 *
229 * conn_lock is also used by some ULPs (like UDP and RAWIP) to protect
230 * their state.
231 */
232 struct conn_s {
233 kmutex_t conn_lock;
234 uint32_t conn_ref; /* Reference counter */
235 uint32_t conn_flags; /* Conn Flags */
236
237 union {
238 tcp_t *cp_tcp; /* Pointer to the tcp struct */
239 struct udp_s *cp_udp; /* Pointer to the udp struct */
240 struct icmp_s *cp_icmp; /* Pointer to rawip struct */
241 struct rts_s *cp_rts; /* Pointer to rts struct */
242 struct iptun_s *cp_iptun; /* Pointer to iptun_t */
243 struct sctp_s *cp_sctp; /* For IPCL_SCTPCONN */
244 struct dccp_s *cp_dccp; /* Pointer to dccp struct */
245 void *cp_priv;
246 } conn_proto_priv;
247 #define conn_tcp conn_proto_priv.cp_tcp
248 #define conn_udp conn_proto_priv.cp_udp
249 #define conn_icmp conn_proto_priv.cp_icmp
250 #define conn_rts conn_proto_priv.cp_rts
251 #define conn_iptun conn_proto_priv.cp_iptun
252 #define conn_sctp conn_proto_priv.cp_sctp
253 #define conn_dccp conn_proto_priv.cp_dccp
254 #define conn_priv conn_proto_priv.cp_priv
255
256 kcondvar_t conn_cv;
257 uint8_t conn_proto; /* protocol type */
258
259 edesc_rpf conn_recv; /* Pointer to recv routine */
260 edesc_rpf conn_recvicmp; /* For ICMP error */
261 edesc_vpf conn_verifyicmp; /* Verify ICMP error */
262
263 ip_xmit_attr_t *conn_ixa; /* Options if no ancil data */
264
265 /* Fields after this are bzero'ed when the conn_t is freed. */
266 #define conn_start_clr conn_recv_ancillary
267
268 /* Options for receive-side ancillary data */
269 crb_t conn_recv_ancillary;
270
271 squeue_t *conn_sqp; /* Squeue for processing */
272 uint_t conn_state_flags; /* IP state flags */
273
640 ((ntohl(laddr) ^ ((ntohl(faddr) << 24) | (ntohl(faddr) >> 8))) % \
641 ipcl_iptun_fanout_size)
642
643 #define IPCL_IPTUN_HASH_V6(laddr, faddr) \
644 IPCL_IPTUN_HASH((laddr)->s6_addr32[0] ^ (laddr)->s6_addr32[1] ^ \
645 (faddr)->s6_addr32[2] ^ (faddr)->s6_addr32[3], \
646 (faddr)->s6_addr32[0] ^ (faddr)->s6_addr32[1] ^ \
647 (laddr)->s6_addr32[2] ^ (laddr)->s6_addr32[3])
648
649 #define IPCL_IPTUN_MATCH(connp, laddr, faddr) \
650 (_IPCL_V4_MATCH((connp)->conn_laddr_v6, (laddr)) && \
651 _IPCL_V4_MATCH((connp)->conn_faddr_v6, (faddr)))
652
653 #define IPCL_IPTUN_MATCH_V6(connp, laddr, faddr) \
654 (IN6_ARE_ADDR_EQUAL(&(connp)->conn_laddr_v6, (laddr)) && \
655 IN6_ARE_ADDR_EQUAL(&(connp)->conn_faddr_v6, (faddr)))
656
657 #define IPCL_UDP_HASH(lport, ipst) \
658 IPCL_PORT_HASH(lport, (ipst)->ips_ipcl_udp_fanout_size)
659
660 #define IPCL_DCCP_HASH(lport, ipst) \
661 IPCL_PORT_HASH(lport, (ipst)->ips_ipcl_dccp_fanout_size)
662
663 #define CONN_G_HASH_SIZE 1024
664
665 /* Raw socket hash function. */
666 #define IPCL_RAW_HASH(lport, ipst) \
667 IPCL_PORT_HASH(lport, (ipst)->ips_ipcl_raw_fanout_size)
668
669 /*
670 * This is similar to IPCL_BIND_MATCH except that the local port check
671 * is changed to a wildcard port check.
672 * We compare conn_laddr since it captures both connected and a bind to
673 * a multicast or broadcast address.
674 */
675 #define IPCL_RAW_MATCH(connp, proto, laddr) \
676 ((connp)->conn_proto == (proto) && \
677 (connp)->conn_lport == 0 && \
678 (_IPCL_V4_MATCH_ANY((connp)->conn_laddr_v6) || \
679 _IPCL_V4_MATCH((connp)->conn_laddr_v6, (laddr))))
680
681 #define IPCL_RAW_MATCH_V6(connp, proto, laddr) \
682 ((connp)->conn_proto == (proto) && \
|