xref: /onnv-gate/usr/src/uts/common/inet/sctp/sctp_conn.c (revision 13054:feaeaa778d1c)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
51676Sjpk  * Common Development and Distribution License (the "License").
61676Sjpk  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
211735Skcpoon 
220Sstevel@tonic-gate /*
2312534SGeorge.Shepherd@Sun.COM  * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #include <sys/types.h>
270Sstevel@tonic-gate #include <sys/systm.h>
280Sstevel@tonic-gate #include <sys/stream.h>
290Sstevel@tonic-gate #include <sys/cmn_err.h>
300Sstevel@tonic-gate #include <sys/kmem.h>
310Sstevel@tonic-gate #define	_SUN_TPI_VERSION 2
320Sstevel@tonic-gate #include <sys/tihdr.h>
330Sstevel@tonic-gate #include <sys/stropts.h>
340Sstevel@tonic-gate #include <sys/strsubr.h>
350Sstevel@tonic-gate #include <sys/socket.h>
361676Sjpk #include <sys/tsol/tndb.h>
370Sstevel@tonic-gate 
380Sstevel@tonic-gate #include <netinet/in.h>
390Sstevel@tonic-gate #include <netinet/ip6.h>
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #include <inet/common.h>
420Sstevel@tonic-gate #include <inet/ip.h>
430Sstevel@tonic-gate #include <inet/ip6.h>
440Sstevel@tonic-gate #include <inet/ipclassifier.h>
450Sstevel@tonic-gate #include <inet/ipsec_impl.h>
460Sstevel@tonic-gate 
470Sstevel@tonic-gate #include "sctp_impl.h"
480Sstevel@tonic-gate #include "sctp_addr.h"
490Sstevel@tonic-gate 
500Sstevel@tonic-gate /*
510Sstevel@tonic-gate  * Common accept code.  Called by sctp_conn_request.
520Sstevel@tonic-gate  * cr_pkt is the INIT / INIT ACK packet.
530Sstevel@tonic-gate  */
540Sstevel@tonic-gate static int
sctp_accept_comm(sctp_t * listener,sctp_t * acceptor,mblk_t * cr_pkt,uint_t ip_hdr_len,sctp_init_chunk_t * iack)550Sstevel@tonic-gate sctp_accept_comm(sctp_t *listener, sctp_t *acceptor, mblk_t *cr_pkt,
560Sstevel@tonic-gate     uint_t ip_hdr_len, sctp_init_chunk_t *iack)
570Sstevel@tonic-gate {
580Sstevel@tonic-gate 
590Sstevel@tonic-gate 	sctp_hdr_t		*sctph;
600Sstevel@tonic-gate 	sctp_chunk_hdr_t	*ich;
610Sstevel@tonic-gate 	sctp_init_chunk_t	*init;
620Sstevel@tonic-gate 	int			err;
630Sstevel@tonic-gate 	uint_t			sctp_options;
642776Skp158701 	conn_t			*aconnp;
651676Sjpk 	conn_t			*lconnp;
6612869SKacheong.Poon@Sun.COM 	sctp_stack_t		*sctps = listener->sctp_sctps;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	sctph = (sctp_hdr_t *)(cr_pkt->b_rptr + ip_hdr_len);
690Sstevel@tonic-gate 	ASSERT(OK_32PTR(sctph));
700Sstevel@tonic-gate 
7111042SErik.Nordmark@Sun.COM 	aconnp = acceptor->sctp_connp;
7211042SErik.Nordmark@Sun.COM 	lconnp = listener->sctp_connp;
7311042SErik.Nordmark@Sun.COM 	aconnp->conn_lport = lconnp->conn_lport;
7411042SErik.Nordmark@Sun.COM 	aconnp->conn_fport = sctph->sh_sport;
750Sstevel@tonic-gate 
760Sstevel@tonic-gate 	ich = (sctp_chunk_hdr_t *)(iack + 1);
770Sstevel@tonic-gate 	init = (sctp_init_chunk_t *)(ich + 1);
780Sstevel@tonic-gate 
790Sstevel@tonic-gate 	/* acceptor isn't in any fanouts yet, so don't need to hold locks */
800Sstevel@tonic-gate 	ASSERT(acceptor->sctp_faddrs == NULL);
810Sstevel@tonic-gate 	err = sctp_get_addrparams(acceptor, listener, cr_pkt, ich,
820Sstevel@tonic-gate 	    &sctp_options);
830Sstevel@tonic-gate 	if (err != 0)
840Sstevel@tonic-gate 		return (err);
850Sstevel@tonic-gate 
861735Skcpoon 	if ((err = sctp_set_hdraddrs(acceptor)) != 0)
871676Sjpk 		return (err);
881676Sjpk 
8911042SErik.Nordmark@Sun.COM 	if ((err = sctp_build_hdrs(acceptor, KM_NOSLEEP)) != 0)
9011042SErik.Nordmark@Sun.COM 		return (err);
9111042SErik.Nordmark@Sun.COM 
920Sstevel@tonic-gate 	if ((sctp_options & SCTP_PRSCTP_OPTION) &&
933448Sdh155122 	    listener->sctp_prsctp_aware && sctps->sctps_prsctp_enabled) {
940Sstevel@tonic-gate 		acceptor->sctp_prsctp_aware = B_TRUE;
950Sstevel@tonic-gate 	} else {
960Sstevel@tonic-gate 		acceptor->sctp_prsctp_aware = B_FALSE;
970Sstevel@tonic-gate 	}
980Sstevel@tonic-gate 
990Sstevel@tonic-gate 	/* Get  initial TSNs */
1000Sstevel@tonic-gate 	acceptor->sctp_ltsn = ntohl(iack->sic_inittsn);
1010Sstevel@tonic-gate 	acceptor->sctp_recovery_tsn = acceptor->sctp_lastack_rxd =
1020Sstevel@tonic-gate 	    acceptor->sctp_ltsn - 1;
1030Sstevel@tonic-gate 	acceptor->sctp_adv_pap = acceptor->sctp_lastack_rxd;
1040Sstevel@tonic-gate 	/* Serial numbers are initialized to the same value as the TSNs */
1050Sstevel@tonic-gate 	acceptor->sctp_lcsn = acceptor->sctp_ltsn;
1060Sstevel@tonic-gate 
1070Sstevel@tonic-gate 	if (!sctp_initialize_params(acceptor, init, iack))
1080Sstevel@tonic-gate 		return (ENOMEM);
1090Sstevel@tonic-gate 
1100Sstevel@tonic-gate 	/*
1110Sstevel@tonic-gate 	 * Copy sctp_secret from the listener in case we need to validate
1120Sstevel@tonic-gate 	 * a possibly delayed cookie.
1130Sstevel@tonic-gate 	 */
1140Sstevel@tonic-gate 	bcopy(listener->sctp_secret, acceptor->sctp_secret, SCTP_SECRET_LEN);
1150Sstevel@tonic-gate 	bcopy(listener->sctp_old_secret, acceptor->sctp_old_secret,
1160Sstevel@tonic-gate 	    SCTP_SECRET_LEN);
11711066Srafael.vanoni@sun.com 	acceptor->sctp_last_secret_update = ddi_get_lbolt64();
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate 	/*
1200Sstevel@tonic-gate 	 * After acceptor is inserted in the hash list, it can be found.
1210Sstevel@tonic-gate 	 * So we need to lock it here.
1220Sstevel@tonic-gate 	 */
1230Sstevel@tonic-gate 	RUN_SCTP(acceptor);
1240Sstevel@tonic-gate 
1253448Sdh155122 	sctp_conn_hash_insert(&sctps->sctps_conn_fanout[
12611042SErik.Nordmark@Sun.COM 	    SCTP_CONN_HASH(sctps, aconnp->conn_ports)], acceptor, 0);
1273448Sdh155122 	sctp_bind_hash_insert(&sctps->sctps_bind_fanout[
12811042SErik.Nordmark@Sun.COM 	    SCTP_BIND_HASH(ntohs(aconnp->conn_lport))], acceptor, 0);
1290Sstevel@tonic-gate 
13012869SKacheong.Poon@Sun.COM 	SCTP_ASSOC_EST(sctps, acceptor);
1310Sstevel@tonic-gate 	return (0);
1320Sstevel@tonic-gate }
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate /* Process the COOKIE packet, mp, directed at the listener 'sctp' */
1350Sstevel@tonic-gate sctp_t *
sctp_conn_request(sctp_t * sctp,mblk_t * mp,uint_t ifindex,uint_t ip_hdr_len,sctp_init_chunk_t * iack,ip_recv_attr_t * ira)1360Sstevel@tonic-gate sctp_conn_request(sctp_t *sctp, mblk_t *mp, uint_t ifindex, uint_t ip_hdr_len,
13711042SErik.Nordmark@Sun.COM     sctp_init_chunk_t *iack, ip_recv_attr_t *ira)
1380Sstevel@tonic-gate {
1390Sstevel@tonic-gate 	sctp_t	*eager;
1400Sstevel@tonic-gate 	ip6_t	*ip6h;
1410Sstevel@tonic-gate 	int	err;
1420Sstevel@tonic-gate 	conn_t	*connp, *econnp;
1433448Sdh155122 	sctp_stack_t	*sctps;
1448778SErik.Nordmark@Sun.COM 	cred_t		*cr;
1458778SErik.Nordmark@Sun.COM 	pid_t		cpid;
14611042SErik.Nordmark@Sun.COM 	in6_addr_t	faddr, laddr;
14711042SErik.Nordmark@Sun.COM 	ip_xmit_attr_t	*ixa;
14812869SKacheong.Poon@Sun.COM 	sctp_listen_cnt_t *slc = sctp->sctp_listen_cnt;
14912869SKacheong.Poon@Sun.COM 	boolean_t	slc_set = B_FALSE;
1500Sstevel@tonic-gate 
1510Sstevel@tonic-gate 	/*
1520Sstevel@tonic-gate 	 * No need to check for duplicate as this is the listener
1530Sstevel@tonic-gate 	 * and we are holding the lock.  This means that no new
1540Sstevel@tonic-gate 	 * connection can be created out of it.  And since the
1550Sstevel@tonic-gate 	 * fanout already done cannot find a match, it means that
1560Sstevel@tonic-gate 	 * there is no duplicate.
1570Sstevel@tonic-gate 	 */
1580Sstevel@tonic-gate 	ASSERT(OK_32PTR(mp->b_rptr));
1590Sstevel@tonic-gate 
16012869SKacheong.Poon@Sun.COM 	connp = sctp->sctp_connp;
16112869SKacheong.Poon@Sun.COM 	sctps = sctp->sctp_sctps;
16212869SKacheong.Poon@Sun.COM 
16312869SKacheong.Poon@Sun.COM 	/*
16412869SKacheong.Poon@Sun.COM 	 * Enforce the limit set on the number of connections per listener.
16512869SKacheong.Poon@Sun.COM 	 * Note that tlc_cnt starts with 1.  So need to add 1 to tlc_max
16612869SKacheong.Poon@Sun.COM 	 * for comparison.
16712869SKacheong.Poon@Sun.COM 	 */
16812869SKacheong.Poon@Sun.COM 	if (slc != NULL) {
16912869SKacheong.Poon@Sun.COM 		int64_t now;
17012869SKacheong.Poon@Sun.COM 
17112869SKacheong.Poon@Sun.COM 		if (atomic_add_32_nv(&slc->slc_cnt, 1) > slc->slc_max + 1) {
17212869SKacheong.Poon@Sun.COM 			now = ddi_get_lbolt64();
17312869SKacheong.Poon@Sun.COM 			atomic_add_32(&slc->slc_cnt, -1);
17412869SKacheong.Poon@Sun.COM 			SCTP_KSTAT(sctps, sctp_listen_cnt_drop);
17512869SKacheong.Poon@Sun.COM 			slc->slc_drop++;
17612869SKacheong.Poon@Sun.COM 			if (now - slc->slc_report_time >
17712869SKacheong.Poon@Sun.COM 			    MSEC_TO_TICK(SCTP_SLC_REPORT_INTERVAL)) {
17812869SKacheong.Poon@Sun.COM 				zcmn_err(connp->conn_zoneid, CE_WARN,
17912869SKacheong.Poon@Sun.COM 				    "SCTP listener (port %d) association max "
18012869SKacheong.Poon@Sun.COM 				    "(%u) reached: %u attempts dropped total\n",
18112869SKacheong.Poon@Sun.COM 				    ntohs(connp->conn_lport),
18212869SKacheong.Poon@Sun.COM 				    slc->slc_max, slc->slc_drop);
18312869SKacheong.Poon@Sun.COM 				slc->slc_report_time = now;
18412869SKacheong.Poon@Sun.COM 			}
18512869SKacheong.Poon@Sun.COM 			return (NULL);
18612869SKacheong.Poon@Sun.COM 		}
18712869SKacheong.Poon@Sun.COM 		slc_set = B_TRUE;
18812869SKacheong.Poon@Sun.COM 	}
18912869SKacheong.Poon@Sun.COM 
1900Sstevel@tonic-gate 	if ((eager = sctp_create_eager(sctp)) == NULL) {
19112869SKacheong.Poon@Sun.COM 		if (slc_set)
19212869SKacheong.Poon@Sun.COM 			atomic_add_32(&slc->slc_cnt, -1);
1930Sstevel@tonic-gate 		return (NULL);
1940Sstevel@tonic-gate 	}
1950Sstevel@tonic-gate 	econnp = eager->sctp_connp;
1960Sstevel@tonic-gate 
1970Sstevel@tonic-gate 	if (connp->conn_policy != NULL) {
19811042SErik.Nordmark@Sun.COM 		/* Inherit the policy from the listener; use actions from ira */
19911042SErik.Nordmark@Sun.COM 		if (!ip_ipsec_policy_inherit(econnp, connp, ira)) {
2000Sstevel@tonic-gate 			sctp_close_eager(eager);
20112869SKacheong.Poon@Sun.COM 			SCTPS_BUMP_MIB(sctps, sctpListenDrop);
2020Sstevel@tonic-gate 			return (NULL);
2030Sstevel@tonic-gate 		}
2040Sstevel@tonic-gate 	}
2050Sstevel@tonic-gate 
20611042SErik.Nordmark@Sun.COM 	ip6h = (ip6_t *)mp->b_rptr;
20711042SErik.Nordmark@Sun.COM 	if (ira->ira_flags & IXAF_IS_IPV4) {
20811042SErik.Nordmark@Sun.COM 		ipha_t	*ipha;
20911042SErik.Nordmark@Sun.COM 
21011042SErik.Nordmark@Sun.COM 		ipha = (ipha_t *)ip6h;
21111042SErik.Nordmark@Sun.COM 		IN6_IPADDR_TO_V4MAPPED(ipha->ipha_dst, &laddr);
21211042SErik.Nordmark@Sun.COM 		IN6_IPADDR_TO_V4MAPPED(ipha->ipha_src, &faddr);
21311042SErik.Nordmark@Sun.COM 	} else {
21411042SErik.Nordmark@Sun.COM 		laddr = ip6h->ip6_dst;
21511042SErik.Nordmark@Sun.COM 		faddr = ip6h->ip6_src;
21611042SErik.Nordmark@Sun.COM 	}
21711042SErik.Nordmark@Sun.COM 
21811042SErik.Nordmark@Sun.COM 	if (ira->ira_flags & IRAF_IPSEC_SECURE) {
2190Sstevel@tonic-gate 		/*
2200Sstevel@tonic-gate 		 * XXX need to fix the cached policy issue here.
22111042SErik.Nordmark@Sun.COM 		 * We temporarily set the conn_laddr/conn_faddr here so
2220Sstevel@tonic-gate 		 * that IPsec can use it for the latched policy
2230Sstevel@tonic-gate 		 * selector.  This is obvioursly wrong as SCTP can
2240Sstevel@tonic-gate 		 * use different addresses...
2250Sstevel@tonic-gate 		 */
22611042SErik.Nordmark@Sun.COM 		econnp->conn_laddr_v6 = laddr;
22711042SErik.Nordmark@Sun.COM 		econnp->conn_faddr_v6 = faddr;
22811042SErik.Nordmark@Sun.COM 		econnp->conn_saddr_v6 = laddr;
2290Sstevel@tonic-gate 	}
23011042SErik.Nordmark@Sun.COM 	if (ipsec_conn_cache_policy(econnp,
23111042SErik.Nordmark@Sun.COM 	    (ira->ira_flags & IRAF_IS_IPV4) != 0) != 0) {
2320Sstevel@tonic-gate 		sctp_close_eager(eager);
23312869SKacheong.Poon@Sun.COM 		SCTPS_BUMP_MIB(sctps, sctpListenDrop);
2340Sstevel@tonic-gate 		return (NULL);
2350Sstevel@tonic-gate 	}
2360Sstevel@tonic-gate 
2378778SErik.Nordmark@Sun.COM 	/* Save for getpeerucred */
23811042SErik.Nordmark@Sun.COM 	cr = ira->ira_cred;
23911042SErik.Nordmark@Sun.COM 	cpid = ira->ira_cpid;
24011042SErik.Nordmark@Sun.COM 
24111042SErik.Nordmark@Sun.COM 	if (is_system_labeled()) {
24211042SErik.Nordmark@Sun.COM 		ip_xmit_attr_t *ixa = econnp->conn_ixa;
24311042SErik.Nordmark@Sun.COM 
24411042SErik.Nordmark@Sun.COM 		ASSERT(ira->ira_tsl != NULL);
24511042SErik.Nordmark@Sun.COM 
24611042SErik.Nordmark@Sun.COM 		/* Discard any old label */
24711042SErik.Nordmark@Sun.COM 		if (ixa->ixa_free_flags & IXA_FREE_TSL) {
24811042SErik.Nordmark@Sun.COM 			ASSERT(ixa->ixa_tsl != NULL);
24911042SErik.Nordmark@Sun.COM 			label_rele(ixa->ixa_tsl);
25011042SErik.Nordmark@Sun.COM 			ixa->ixa_free_flags &= ~IXA_FREE_TSL;
25111042SErik.Nordmark@Sun.COM 			ixa->ixa_tsl = NULL;
25211042SErik.Nordmark@Sun.COM 		}
25311042SErik.Nordmark@Sun.COM 
25411042SErik.Nordmark@Sun.COM 		if ((connp->conn_mlp_type != mlptSingle ||
25511042SErik.Nordmark@Sun.COM 		    connp->conn_mac_mode != CONN_MAC_DEFAULT) &&
25611042SErik.Nordmark@Sun.COM 		    ira->ira_tsl != NULL) {
25711042SErik.Nordmark@Sun.COM 			/*
25811042SErik.Nordmark@Sun.COM 			 * If this is an MLP connection or a MAC-Exempt
25911042SErik.Nordmark@Sun.COM 			 * connection with an unlabeled node, packets are to be
26011042SErik.Nordmark@Sun.COM 			 * exchanged using the security label of the received
26111042SErik.Nordmark@Sun.COM 			 * Cookie packet instead of the server application's
26211042SErik.Nordmark@Sun.COM 			 * label.
26311042SErik.Nordmark@Sun.COM 			 * tsol_check_dest called from ip_set_destination
26411042SErik.Nordmark@Sun.COM 			 * might later update TSF_UNLABELED by replacing
26511042SErik.Nordmark@Sun.COM 			 * ixa_tsl with a new label.
26611042SErik.Nordmark@Sun.COM 			 */
26711042SErik.Nordmark@Sun.COM 			label_hold(ira->ira_tsl);
26811042SErik.Nordmark@Sun.COM 			ip_xmit_attr_replace_tsl(ixa, ira->ira_tsl);
26911042SErik.Nordmark@Sun.COM 		} else {
27011042SErik.Nordmark@Sun.COM 			ixa->ixa_tsl = crgetlabel(econnp->conn_cred);
27111042SErik.Nordmark@Sun.COM 		}
27211042SErik.Nordmark@Sun.COM 	}
2738778SErik.Nordmark@Sun.COM 
2740Sstevel@tonic-gate 	err = sctp_accept_comm(sctp, eager, mp, ip_hdr_len, iack);
27511042SErik.Nordmark@Sun.COM 	if (err != 0) {
2760Sstevel@tonic-gate 		sctp_close_eager(eager);
27712869SKacheong.Poon@Sun.COM 		SCTPS_BUMP_MIB(sctps, sctpListenDrop);
2780Sstevel@tonic-gate 		return (NULL);
2790Sstevel@tonic-gate 	}
2800Sstevel@tonic-gate 
281*13009SChandrasekar.Marimuthu@Sun.COM 	ASSERT(eager->sctp_current->sf_ixa != NULL);
28211042SErik.Nordmark@Sun.COM 
283*13009SChandrasekar.Marimuthu@Sun.COM 	ixa = eager->sctp_current->sf_ixa;
28411042SErik.Nordmark@Sun.COM 	if (!(ira->ira_flags & IXAF_IS_IPV4)) {
28511042SErik.Nordmark@Sun.COM 		ASSERT(!(ixa->ixa_flags & IXAF_IS_IPV4));
28611042SErik.Nordmark@Sun.COM 
28711042SErik.Nordmark@Sun.COM 		if (IN6_IS_ADDR_LINKLOCAL(&ip6h->ip6_src) ||
28811042SErik.Nordmark@Sun.COM 		    IN6_IS_ADDR_LINKLOCAL(&ip6h->ip6_dst)) {
28911042SErik.Nordmark@Sun.COM 			eager->sctp_linklocal = 1;
29011042SErik.Nordmark@Sun.COM 
29111042SErik.Nordmark@Sun.COM 			ixa->ixa_flags |= IXAF_SCOPEID_SET;
29211042SErik.Nordmark@Sun.COM 			ixa->ixa_scopeid = ifindex;
29311042SErik.Nordmark@Sun.COM 			econnp->conn_incoming_ifindex = ifindex;
29411042SErik.Nordmark@Sun.COM 		}
29511042SErik.Nordmark@Sun.COM 	}
29611042SErik.Nordmark@Sun.COM 
297852Svi117747 	/*
298852Svi117747 	 * On a clustered note send this notification to the clustering
299852Svi117747 	 * subsystem.
300852Svi117747 	 */
301852Svi117747 	if (cl_sctp_connect != NULL) {
302852Svi117747 		uchar_t	*slist;
303852Svi117747 		uchar_t	*flist;
304852Svi117747 		size_t	fsize;
305852Svi117747 		size_t	ssize;
306852Svi117747 
307852Svi117747 		fsize = sizeof (in6_addr_t) * eager->sctp_nfaddrs;
308852Svi117747 		ssize = sizeof (in6_addr_t) * eager->sctp_nsaddrs;
309852Svi117747 		slist = kmem_alloc(ssize, KM_NOSLEEP);
310852Svi117747 		flist = kmem_alloc(fsize, KM_NOSLEEP);
311852Svi117747 		if (slist == NULL || flist == NULL) {
312852Svi117747 			if (slist != NULL)
313852Svi117747 				kmem_free(slist, ssize);
314852Svi117747 			if (flist != NULL)
315852Svi117747 				kmem_free(flist, fsize);
316852Svi117747 			sctp_close_eager(eager);
31712869SKacheong.Poon@Sun.COM 			SCTPS_BUMP_MIB(sctps, sctpListenDrop);
3183448Sdh155122 			SCTP_KSTAT(sctps, sctp_cl_connect);
319852Svi117747 			return (NULL);
320852Svi117747 		}
321852Svi117747 		/* The clustering module frees these list */
322852Svi117747 		sctp_get_saddr_list(eager, slist, ssize);
323852Svi117747 		sctp_get_faddr_list(eager, flist, fsize);
32411042SErik.Nordmark@Sun.COM 		(*cl_sctp_connect)(econnp->conn_family, slist,
32511042SErik.Nordmark@Sun.COM 		    eager->sctp_nsaddrs, econnp->conn_lport, flist,
32611042SErik.Nordmark@Sun.COM 		    eager->sctp_nfaddrs, econnp->conn_fport, B_FALSE,
327852Svi117747 		    (cl_sctp_handle_t)eager);
328852Svi117747 	}
329852Svi117747 
3300Sstevel@tonic-gate 	/* Connection established, so send up the conn_ind */
3310Sstevel@tonic-gate 	if ((eager->sctp_ulpd = sctp->sctp_ulp_newconn(sctp->sctp_ulpd,
3328778SErik.Nordmark@Sun.COM 	    (sock_lower_handle_t)eager, NULL, cr, cpid,
3338348SEric.Yu@Sun.COM 	    &eager->sctp_upcalls)) == NULL) {
3340Sstevel@tonic-gate 		sctp_close_eager(eager);
33512869SKacheong.Poon@Sun.COM 		SCTPS_BUMP_MIB(sctps, sctpListenDrop);
3360Sstevel@tonic-gate 		return (NULL);
3370Sstevel@tonic-gate 	}
3380Sstevel@tonic-gate 	ASSERT(SCTP_IS_DETACHED(eager));
3390Sstevel@tonic-gate 	eager->sctp_detached = B_FALSE;
3400Sstevel@tonic-gate 	return (eager);
3410Sstevel@tonic-gate }
3420Sstevel@tonic-gate 
3430Sstevel@tonic-gate /*
3440Sstevel@tonic-gate  * Connect to a peer - this function inserts the sctp in the
3450Sstevel@tonic-gate  * bind and conn fanouts, sends the INIT, and replies to the client
3460Sstevel@tonic-gate  * with an OK ack.
3470Sstevel@tonic-gate  */
3480Sstevel@tonic-gate int
sctp_connect(sctp_t * sctp,const struct sockaddr * dst,uint32_t addrlen,cred_t * cr,pid_t pid)34911042SErik.Nordmark@Sun.COM sctp_connect(sctp_t *sctp, const struct sockaddr *dst, uint32_t addrlen,
35011042SErik.Nordmark@Sun.COM     cred_t *cr, pid_t pid)
3510Sstevel@tonic-gate {
3520Sstevel@tonic-gate 	sin_t		*sin;
3530Sstevel@tonic-gate 	sin6_t		*sin6;
3540Sstevel@tonic-gate 	in6_addr_t	dstaddr;
3550Sstevel@tonic-gate 	in_port_t	dstport;
3560Sstevel@tonic-gate 	mblk_t		*initmp;
3570Sstevel@tonic-gate 	sctp_tf_t	*tbf;
3580Sstevel@tonic-gate 	sctp_t		*lsctp;
3590Sstevel@tonic-gate 	char		buf[INET6_ADDRSTRLEN];
3600Sstevel@tonic-gate 	int		sleep = sctp->sctp_cansleep ? KM_SLEEP : KM_NOSLEEP;
3611676Sjpk 	int		err;
3620Sstevel@tonic-gate 	sctp_faddr_t	*cur_fp;
3633448Sdh155122 	sctp_stack_t	*sctps = sctp->sctp_sctps;
36411042SErik.Nordmark@Sun.COM 	conn_t		*connp = sctp->sctp_connp;
36511042SErik.Nordmark@Sun.COM 	uint_t		scope_id = 0;
36611042SErik.Nordmark@Sun.COM 	ip_xmit_attr_t	*ixa;
3670Sstevel@tonic-gate 
3680Sstevel@tonic-gate 	/*
3690Sstevel@tonic-gate 	 * Determine packet type based on type of address passed in
3700Sstevel@tonic-gate 	 * the request should contain an IPv4 or IPv6 address.
3710Sstevel@tonic-gate 	 * Make sure that address family matches the type of
37211042SErik.Nordmark@Sun.COM 	 * family of the address passed down.
3730Sstevel@tonic-gate 	 */
3740Sstevel@tonic-gate 	if (addrlen < sizeof (sin_t)) {
3750Sstevel@tonic-gate 		return (EINVAL);
3760Sstevel@tonic-gate 	}
3770Sstevel@tonic-gate 	switch (dst->sa_family) {
3780Sstevel@tonic-gate 	case AF_INET:
3790Sstevel@tonic-gate 		sin = (sin_t *)dst;
3800Sstevel@tonic-gate 
3810Sstevel@tonic-gate 		/* Check for attempt to connect to non-unicast */
3825215Skcpoon 		if (CLASSD(sin->sin_addr.s_addr) ||
3830Sstevel@tonic-gate 		    (sin->sin_addr.s_addr == INADDR_BROADCAST)) {
3840Sstevel@tonic-gate 			ip0dbg(("sctp_connect: non-unicast\n"));
3850Sstevel@tonic-gate 			return (EINVAL);
3860Sstevel@tonic-gate 		}
38711042SErik.Nordmark@Sun.COM 		if (connp->conn_ipv6_v6only)
3880Sstevel@tonic-gate 			return (EAFNOSUPPORT);
3890Sstevel@tonic-gate 
3900Sstevel@tonic-gate 		/* convert to v6 mapped */
3910Sstevel@tonic-gate 		/* Check for attempt to connect to INADDR_ANY */
3920Sstevel@tonic-gate 		if (sin->sin_addr.s_addr == INADDR_ANY)  {
3930Sstevel@tonic-gate 			struct in_addr v4_addr;
3940Sstevel@tonic-gate 			/*
3950Sstevel@tonic-gate 			 * SunOS 4.x and 4.3 BSD allow an application
3960Sstevel@tonic-gate 			 * to connect a TCP socket to INADDR_ANY.
3970Sstevel@tonic-gate 			 * When they do this, the kernel picks the
3980Sstevel@tonic-gate 			 * address of one interface and uses it
3990Sstevel@tonic-gate 			 * instead.  The kernel usually ends up
4000Sstevel@tonic-gate 			 * picking the address of the loopback
4010Sstevel@tonic-gate 			 * interface.  This is an undocumented feature.
4020Sstevel@tonic-gate 			 * However, we provide the same thing here
4030Sstevel@tonic-gate 			 * in case any TCP apps that use this feature
4040Sstevel@tonic-gate 			 * are being ported to SCTP...
4050Sstevel@tonic-gate 			 */
4060Sstevel@tonic-gate 			v4_addr.s_addr = htonl(INADDR_LOOPBACK);
4070Sstevel@tonic-gate 			IN6_INADDR_TO_V4MAPPED(&v4_addr, &dstaddr);
4080Sstevel@tonic-gate 		} else {
4090Sstevel@tonic-gate 			IN6_INADDR_TO_V4MAPPED(&sin->sin_addr, &dstaddr);
4100Sstevel@tonic-gate 		}
4110Sstevel@tonic-gate 		dstport = sin->sin_port;
4120Sstevel@tonic-gate 		break;
4130Sstevel@tonic-gate 	case AF_INET6:
4140Sstevel@tonic-gate 		sin6 = (sin6_t *)dst;
4150Sstevel@tonic-gate 		/* Check for attempt to connect to non-unicast. */
4160Sstevel@tonic-gate 		if ((addrlen < sizeof (sin6_t)) ||
4170Sstevel@tonic-gate 		    IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) {
4180Sstevel@tonic-gate 			ip0dbg(("sctp_connect: non-unicast\n"));
4190Sstevel@tonic-gate 			return (EINVAL);
4200Sstevel@tonic-gate 		}
42111042SErik.Nordmark@Sun.COM 		if (connp->conn_ipv6_v6only &&
4220Sstevel@tonic-gate 		    IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
4230Sstevel@tonic-gate 			return (EAFNOSUPPORT);
4240Sstevel@tonic-gate 		}
4250Sstevel@tonic-gate 		/* check for attempt to connect to unspec */
4260Sstevel@tonic-gate 		if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) {
4270Sstevel@tonic-gate 			dstaddr = ipv6_loopback;
4280Sstevel@tonic-gate 		} else {
4290Sstevel@tonic-gate 			dstaddr = sin6->sin6_addr;
43011042SErik.Nordmark@Sun.COM 			if (IN6_IS_ADDR_LINKLOCAL(&dstaddr)) {
431432Svi117747 				sctp->sctp_linklocal = 1;
43211042SErik.Nordmark@Sun.COM 				scope_id = sin6->sin6_scope_id;
43311042SErik.Nordmark@Sun.COM 			}
4340Sstevel@tonic-gate 		}
4350Sstevel@tonic-gate 		dstport = sin6->sin6_port;
43611042SErik.Nordmark@Sun.COM 		connp->conn_flowinfo = sin6->sin6_flowinfo;
4370Sstevel@tonic-gate 		break;
4380Sstevel@tonic-gate 	default:
4390Sstevel@tonic-gate 		dprint(1, ("sctp_connect: unknown family %d\n",
4404505Skcpoon 		    dst->sa_family));
4410Sstevel@tonic-gate 		return (EAFNOSUPPORT);
4420Sstevel@tonic-gate 	}
4430Sstevel@tonic-gate 
4440Sstevel@tonic-gate 	(void) inet_ntop(AF_INET6, &dstaddr, buf, sizeof (buf));
4450Sstevel@tonic-gate 	dprint(1, ("sctp_connect: attempting connect to %s...\n", buf));
4460Sstevel@tonic-gate 
4470Sstevel@tonic-gate 	RUN_SCTP(sctp);
4480Sstevel@tonic-gate 
44911042SErik.Nordmark@Sun.COM 	if (connp->conn_family != dst->sa_family ||
45011042SErik.Nordmark@Sun.COM 	    (connp->conn_state_flags & CONN_CLOSING)) {
4510Sstevel@tonic-gate 		WAKE_SCTP(sctp);
4520Sstevel@tonic-gate 		return (EINVAL);
4530Sstevel@tonic-gate 	}
4540Sstevel@tonic-gate 
45511042SErik.Nordmark@Sun.COM 	/* We update our cred/cpid based on the caller of connect */
45611042SErik.Nordmark@Sun.COM 	if (connp->conn_cred != cr) {
45711042SErik.Nordmark@Sun.COM 		crhold(cr);
45811042SErik.Nordmark@Sun.COM 		crfree(connp->conn_cred);
45911042SErik.Nordmark@Sun.COM 		connp->conn_cred = cr;
46011042SErik.Nordmark@Sun.COM 	}
46111042SErik.Nordmark@Sun.COM 	connp->conn_cpid = pid;
46211042SErik.Nordmark@Sun.COM 
46311042SErik.Nordmark@Sun.COM 	/* Cache things in conn_ixa without any refhold */
46411042SErik.Nordmark@Sun.COM 	ixa = connp->conn_ixa;
46511849SErik.Nordmark@Sun.COM 	ASSERT(!(ixa->ixa_free_flags & IXA_FREE_CRED));
46611042SErik.Nordmark@Sun.COM 	ixa->ixa_cred = cr;
46711042SErik.Nordmark@Sun.COM 	ixa->ixa_cpid = pid;
46811042SErik.Nordmark@Sun.COM 	if (is_system_labeled()) {
46911042SErik.Nordmark@Sun.COM 		/* We need to restart with a label based on the cred */
47011042SErik.Nordmark@Sun.COM 		ip_xmit_attr_restore_tsl(ixa, ixa->ixa_cred);
47111042SErik.Nordmark@Sun.COM 	}
47211042SErik.Nordmark@Sun.COM 
4730Sstevel@tonic-gate 	switch (sctp->sctp_state) {
4740Sstevel@tonic-gate 	case SCTPS_IDLE: {
475852Svi117747 		struct sockaddr_storage	ss;
476852Svi117747 
4770Sstevel@tonic-gate 		/*
4780Sstevel@tonic-gate 		 * We support a quick connect capability here, allowing
4790Sstevel@tonic-gate 		 * clients to transition directly from IDLE to COOKIE_WAIT.
4800Sstevel@tonic-gate 		 * sctp_bindi will pick an unused port, insert the connection
4810Sstevel@tonic-gate 		 * in the bind hash and transition to BOUND state. SCTP
4820Sstevel@tonic-gate 		 * picks and uses what it considers the optimal local address
4830Sstevel@tonic-gate 		 * set (just like specifiying INADDR_ANY to bind()).
4840Sstevel@tonic-gate 		 */
4850Sstevel@tonic-gate 		dprint(1, ("sctp_connect: idle, attempting bind...\n"));
4860Sstevel@tonic-gate 		ASSERT(sctp->sctp_nsaddrs == 0);
4870Sstevel@tonic-gate 
488852Svi117747 		bzero(&ss, sizeof (ss));
48911042SErik.Nordmark@Sun.COM 		ss.ss_family = connp->conn_family;
490852Svi117747 		WAKE_SCTP(sctp);
491852Svi117747 		if ((err = sctp_bind(sctp, (struct sockaddr *)&ss,
492852Svi117747 		    sizeof (ss))) != 0) {
4930Sstevel@tonic-gate 			return (err);
4940Sstevel@tonic-gate 		}
495852Svi117747 		RUN_SCTP(sctp);
4960Sstevel@tonic-gate 		/* FALLTHRU */
4970Sstevel@tonic-gate 	}
4980Sstevel@tonic-gate 
4990Sstevel@tonic-gate 	case SCTPS_BOUND:
5000Sstevel@tonic-gate 		ASSERT(sctp->sctp_nsaddrs > 0);
5010Sstevel@tonic-gate 
5020Sstevel@tonic-gate 		/* do the connect */
5030Sstevel@tonic-gate 		/* XXX check for attempt to connect to self */
50411042SErik.Nordmark@Sun.COM 		connp->conn_fport = dstport;
5050Sstevel@tonic-gate 
5060Sstevel@tonic-gate 		/*
5070Sstevel@tonic-gate 		 * Don't allow this connection to completely duplicate
5080Sstevel@tonic-gate 		 * an existing connection.
5090Sstevel@tonic-gate 		 *
5100Sstevel@tonic-gate 		 * Ensure that the duplicate check and insertion is atomic.
5110Sstevel@tonic-gate 		 */
5120Sstevel@tonic-gate 		sctp_conn_hash_remove(sctp);
5133448Sdh155122 		tbf = &sctps->sctps_conn_fanout[SCTP_CONN_HASH(sctps,
51411042SErik.Nordmark@Sun.COM 		    connp->conn_ports)];
5150Sstevel@tonic-gate 		mutex_enter(&tbf->tf_lock);
51611042SErik.Nordmark@Sun.COM 		lsctp = sctp_lookup(sctp, &dstaddr, tbf, &connp->conn_ports,
5170Sstevel@tonic-gate 		    SCTPS_COOKIE_WAIT);
5180Sstevel@tonic-gate 		if (lsctp != NULL) {
5190Sstevel@tonic-gate 			/* found a duplicate connection */
5200Sstevel@tonic-gate 			mutex_exit(&tbf->tf_lock);
5210Sstevel@tonic-gate 			SCTP_REFRELE(lsctp);
5220Sstevel@tonic-gate 			WAKE_SCTP(sctp);
5230Sstevel@tonic-gate 			return (EADDRINUSE);
5240Sstevel@tonic-gate 		}
52511042SErik.Nordmark@Sun.COM 
5260Sstevel@tonic-gate 		/*
5270Sstevel@tonic-gate 		 * OK; set up the peer addr (this may grow after we get
5280Sstevel@tonic-gate 		 * the INIT ACK from the peer with additional addresses).
5290Sstevel@tonic-gate 		 */
5301735Skcpoon 		if ((err = sctp_add_faddr(sctp, &dstaddr, sleep,
5311735Skcpoon 		    B_FALSE)) != 0) {
5320Sstevel@tonic-gate 			mutex_exit(&tbf->tf_lock);
5330Sstevel@tonic-gate 			WAKE_SCTP(sctp);
5341676Sjpk 			return (err);
5350Sstevel@tonic-gate 		}
5364818Skcpoon 		cur_fp = sctp->sctp_faddrs;
537*13009SChandrasekar.Marimuthu@Sun.COM 		ASSERT(cur_fp->sf_ixa != NULL);
5384818Skcpoon 
5390Sstevel@tonic-gate 		/* No valid src addr, return. */
540*13009SChandrasekar.Marimuthu@Sun.COM 		if (cur_fp->sf_state == SCTP_FADDRS_UNREACH) {
5410Sstevel@tonic-gate 			mutex_exit(&tbf->tf_lock);
5420Sstevel@tonic-gate 			WAKE_SCTP(sctp);
5430Sstevel@tonic-gate 			return (EADDRNOTAVAIL);
5440Sstevel@tonic-gate 		}
5454818Skcpoon 
5464818Skcpoon 		sctp->sctp_primary = cur_fp;
5474818Skcpoon 		sctp->sctp_current = cur_fp;
548*13009SChandrasekar.Marimuthu@Sun.COM 		sctp->sctp_mss = cur_fp->sf_pmss;
5490Sstevel@tonic-gate 		sctp_conn_hash_insert(tbf, sctp, 1);
5500Sstevel@tonic-gate 		mutex_exit(&tbf->tf_lock);
5510Sstevel@tonic-gate 
552*13009SChandrasekar.Marimuthu@Sun.COM 		ixa = cur_fp->sf_ixa;
55311042SErik.Nordmark@Sun.COM 		ASSERT(ixa->ixa_cred != NULL);
55411042SErik.Nordmark@Sun.COM 
55511042SErik.Nordmark@Sun.COM 		if (scope_id != 0) {
55611042SErik.Nordmark@Sun.COM 			ixa->ixa_flags |= IXAF_SCOPEID_SET;
55711042SErik.Nordmark@Sun.COM 			ixa->ixa_scopeid = scope_id;
55811042SErik.Nordmark@Sun.COM 		} else {
55911042SErik.Nordmark@Sun.COM 			ixa->ixa_flags &= ~IXAF_SCOPEID_SET;
56011042SErik.Nordmark@Sun.COM 		}
56111042SErik.Nordmark@Sun.COM 
5620Sstevel@tonic-gate 		/* initialize composite headers */
5631735Skcpoon 		if ((err = sctp_set_hdraddrs(sctp)) != 0) {
5641676Sjpk 			sctp_conn_hash_remove(sctp);
5651676Sjpk 			WAKE_SCTP(sctp);
5661676Sjpk 			return (err);
5671676Sjpk 		}
5680Sstevel@tonic-gate 
56911042SErik.Nordmark@Sun.COM 		if ((err = sctp_build_hdrs(sctp, KM_SLEEP)) != 0) {
57011042SErik.Nordmark@Sun.COM 			sctp_conn_hash_remove(sctp);
57111042SErik.Nordmark@Sun.COM 			WAKE_SCTP(sctp);
57211042SErik.Nordmark@Sun.COM 			return (err);
5733448Sdh155122 		}
5740Sstevel@tonic-gate 
5750Sstevel@tonic-gate 		/*
5760Sstevel@tonic-gate 		 * Turn off the don't fragment bit on the (only) faddr,
5770Sstevel@tonic-gate 		 * so that if one of the messages exchanged during the
5780Sstevel@tonic-gate 		 * initialization sequence exceeds the path mtu, it
5790Sstevel@tonic-gate 		 * at least has a chance to get there. SCTP does no
5800Sstevel@tonic-gate 		 * fragmentation of initialization messages.  The DF bit
5810Sstevel@tonic-gate 		 * will be turned on again in sctp_send_cookie_echo()
5820Sstevel@tonic-gate 		 * (but the cookie echo will still be sent with the df bit
5830Sstevel@tonic-gate 		 * off).
5840Sstevel@tonic-gate 		 */
585*13009SChandrasekar.Marimuthu@Sun.COM 		cur_fp->sf_df = B_FALSE;
5860Sstevel@tonic-gate 
5870Sstevel@tonic-gate 		/* Mark this address as alive */
588*13009SChandrasekar.Marimuthu@Sun.COM 		cur_fp->sf_state = SCTP_FADDRS_ALIVE;
5890Sstevel@tonic-gate 
5900Sstevel@tonic-gate 		/* Send the INIT to the peer */
591*13009SChandrasekar.Marimuthu@Sun.COM 		SCTP_FADDR_TIMER_RESTART(sctp, cur_fp, cur_fp->sf_rto);
5924818Skcpoon 		sctp->sctp_state = SCTPS_COOKIE_WAIT;
593432Svi117747 		/*
594432Svi117747 		 * sctp_init_mp() could result in modifying the source
595432Svi117747 		 * address list, so take the hash lock.
596432Svi117747 		 */
597432Svi117747 		mutex_enter(&tbf->tf_lock);
59811042SErik.Nordmark@Sun.COM 		initmp = sctp_init_mp(sctp, cur_fp);
5990Sstevel@tonic-gate 		if (initmp == NULL) {
600432Svi117747 			mutex_exit(&tbf->tf_lock);
6014818Skcpoon 			/*
6024818Skcpoon 			 * It may happen that all the source addresses
6034818Skcpoon 			 * (loopback/link local) are removed.  In that case,
6044818Skcpoon 			 * faile the connect.
6054818Skcpoon 			 */
6064818Skcpoon 			if (sctp->sctp_nsaddrs == 0) {
6074818Skcpoon 				sctp_conn_hash_remove(sctp);
6084818Skcpoon 				SCTP_FADDR_TIMER_STOP(cur_fp);
6094818Skcpoon 				WAKE_SCTP(sctp);
6104818Skcpoon 				return (EADDRNOTAVAIL);
6114818Skcpoon 			}
6124818Skcpoon 
6134818Skcpoon 			/* Otherwise, let the retransmission timer retry */
6140Sstevel@tonic-gate 			WAKE_SCTP(sctp);
6154818Skcpoon 			goto notify_ulp;
6160Sstevel@tonic-gate 		}
617432Svi117747 		mutex_exit(&tbf->tf_lock);
6184818Skcpoon 
619852Svi117747 		/*
620852Svi117747 		 * On a clustered note send this notification to the clustering
621852Svi117747 		 * subsystem.
622852Svi117747 		 */
623852Svi117747 		if (cl_sctp_connect != NULL) {
624852Svi117747 			uchar_t		*slist;
625852Svi117747 			uchar_t		*flist;
626852Svi117747 			size_t		ssize;
627852Svi117747 			size_t		fsize;
628852Svi117747 
629852Svi117747 			fsize = sizeof (in6_addr_t) * sctp->sctp_nfaddrs;
630852Svi117747 			ssize = sizeof (in6_addr_t) * sctp->sctp_nsaddrs;
631852Svi117747 			slist = kmem_alloc(ssize, KM_SLEEP);
632852Svi117747 			flist = kmem_alloc(fsize, KM_SLEEP);
633852Svi117747 			/* The clustering module frees the lists */
634852Svi117747 			sctp_get_saddr_list(sctp, slist, ssize);
635852Svi117747 			sctp_get_faddr_list(sctp, flist, fsize);
63611042SErik.Nordmark@Sun.COM 			(*cl_sctp_connect)(connp->conn_family, slist,
63711042SErik.Nordmark@Sun.COM 			    sctp->sctp_nsaddrs, connp->conn_lport,
63811042SErik.Nordmark@Sun.COM 			    flist, sctp->sctp_nfaddrs, connp->conn_fport,
639852Svi117747 			    B_TRUE, (cl_sctp_handle_t)sctp);
640852Svi117747 		}
64111042SErik.Nordmark@Sun.COM 		ASSERT(ixa->ixa_cred != NULL);
64211042SErik.Nordmark@Sun.COM 		ASSERT(ixa->ixa_ire != NULL);
64311042SErik.Nordmark@Sun.COM 
64411042SErik.Nordmark@Sun.COM 		(void) conn_ip_output(initmp, ixa);
64511042SErik.Nordmark@Sun.COM 		BUMP_LOCAL(sctp->sctp_opkts);
6460Sstevel@tonic-gate 		WAKE_SCTP(sctp);
6470Sstevel@tonic-gate 
6484818Skcpoon notify_ulp:
64911042SErik.Nordmark@Sun.COM 		sctp_set_ulp_prop(sctp);
6500Sstevel@tonic-gate 
6510Sstevel@tonic-gate 		return (0);
6520Sstevel@tonic-gate 	default:
6530Sstevel@tonic-gate 		ip0dbg(("sctp_connect: invalid state. %d\n", sctp->sctp_state));
6540Sstevel@tonic-gate 		WAKE_SCTP(sctp);
6550Sstevel@tonic-gate 		return (EINVAL);
6560Sstevel@tonic-gate 	}
6570Sstevel@tonic-gate }
658