xref: /titanic_41/usr/src/lib/libnsl/nsl/t_optmgmt.c (revision 61961e0f20c7637a3846bb39786bb9dffa91dfb9)
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
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22*61961e0fSrobinson 
237c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
247c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*
27*61961e0fSrobinson  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
287c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
297c478bd9Sstevel@tonic-gate  */
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include "mt.h"
347c478bd9Sstevel@tonic-gate #include <stdlib.h>
357c478bd9Sstevel@tonic-gate #include <stdio.h>
367c478bd9Sstevel@tonic-gate #include <string.h>
377c478bd9Sstevel@tonic-gate #include <errno.h>
387c478bd9Sstevel@tonic-gate #include <sys/stream.h>
397c478bd9Sstevel@tonic-gate #define	_SUN_TPI_VERSION 2
407c478bd9Sstevel@tonic-gate #include <sys/tihdr.h>
417c478bd9Sstevel@tonic-gate #include <sys/timod.h>
427c478bd9Sstevel@tonic-gate #include <xti.h>
437c478bd9Sstevel@tonic-gate #include <signal.h>
447c478bd9Sstevel@tonic-gate #include <syslog.h>
457c478bd9Sstevel@tonic-gate #include <stropts.h>
467c478bd9Sstevel@tonic-gate #include "tx.h"
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate /*
497c478bd9Sstevel@tonic-gate  * The following is based on XTI standard.
507c478bd9Sstevel@tonic-gate  */
517c478bd9Sstevel@tonic-gate #define	ALIGN_XTI_opthdr_size	(sizeof (t_uscalar_t))
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate #define	ROUNDUP_XTI_opthdr(p)	(((p) +\
547c478bd9Sstevel@tonic-gate 		(ALIGN_XTI_opthdr_size-1)) & ~(ALIGN_XTI_opthdr_size-1))
557c478bd9Sstevel@tonic-gate #define	ISALIGNED_XTI_opthdr(p)	\
567c478bd9Sstevel@tonic-gate 	(((ulong_t)(p) & (ALIGN_XTI_opthdr_size - 1)) == 0)
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate int
_tx_optmgmt(int fd,const struct t_optmgmt * req,struct t_optmgmt * ret,int api_semantics)597c478bd9Sstevel@tonic-gate _tx_optmgmt(
607c478bd9Sstevel@tonic-gate 	int fd,
617c478bd9Sstevel@tonic-gate 	const struct t_optmgmt *req,
627c478bd9Sstevel@tonic-gate 	struct t_optmgmt *ret,
637c478bd9Sstevel@tonic-gate 	int api_semantics
647c478bd9Sstevel@tonic-gate )
657c478bd9Sstevel@tonic-gate {
667c478bd9Sstevel@tonic-gate 	int size, sv_errno;
677c478bd9Sstevel@tonic-gate 	struct strbuf ctlbuf;
687c478bd9Sstevel@tonic-gate 	struct T_optmgmt_req *optreq;
697c478bd9Sstevel@tonic-gate 	struct T_optmgmt_ack *optack;
707c478bd9Sstevel@tonic-gate 	struct _ti_user *tiptr;
717c478bd9Sstevel@tonic-gate 	sigset_t mask;
727c478bd9Sstevel@tonic-gate 	int didalloc, retlen;
737c478bd9Sstevel@tonic-gate 	struct t_opthdr *opt, *next_opt;
747c478bd9Sstevel@tonic-gate 	struct t_opthdr *opt_start, *opt_end;
757c478bd9Sstevel@tonic-gate 	t_uscalar_t first_opt_level;
767c478bd9Sstevel@tonic-gate 	t_scalar_t optlen;
777c478bd9Sstevel@tonic-gate 
78*61961e0fSrobinson 	if ((tiptr = _t_checkfd(fd, 0, api_semantics)) == NULL)
797c478bd9Sstevel@tonic-gate 		return (-1);
807c478bd9Sstevel@tonic-gate 
817c478bd9Sstevel@tonic-gate 	/*
827c478bd9Sstevel@tonic-gate 	 * We block all signals during the TI_OPTMGMT operation
837c478bd9Sstevel@tonic-gate 	 * as option change being done could potentially be a
847c478bd9Sstevel@tonic-gate 	 * non-idempotent operation.
857c478bd9Sstevel@tonic-gate 	 * Note that sig_mutex_lock() only defers signals, it does not
867c478bd9Sstevel@tonic-gate 	 * block them, so interruptible syscalls could still get EINTR.
877c478bd9Sstevel@tonic-gate 	 */
887c478bd9Sstevel@tonic-gate 	(void) thr_sigsetmask(SIG_SETMASK, &fillset, &mask);
897c478bd9Sstevel@tonic-gate 	sig_mutex_lock(&tiptr->ti_lock);
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate 	/*
927c478bd9Sstevel@tonic-gate 	 * Acquire buf for use in sending/receiving of the message.
937c478bd9Sstevel@tonic-gate 	 * Note: assumes (correctly) that ti_ctlsize is large enough
947c478bd9Sstevel@tonic-gate 	 * to hold sizeof (struct T_bind_req)
957c478bd9Sstevel@tonic-gate 	 */
967c478bd9Sstevel@tonic-gate 	if (_t_acquire_ctlbuf(tiptr, &ctlbuf, &didalloc) < 0) {
977c478bd9Sstevel@tonic-gate 		sv_errno = errno;
987c478bd9Sstevel@tonic-gate 		sig_mutex_unlock(&tiptr->ti_lock);
997c478bd9Sstevel@tonic-gate 		(void) thr_sigsetmask(SIG_SETMASK, &mask, NULL);
1007c478bd9Sstevel@tonic-gate 		errno = sv_errno;
1017c478bd9Sstevel@tonic-gate 		return (-1);
1027c478bd9Sstevel@tonic-gate 	}
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate 	/*
1057c478bd9Sstevel@tonic-gate 	 * effective option length in local variable "optlen"
1067c478bd9Sstevel@tonic-gate 	 * Note: can change for XTI for T_ALLOPT. XTI spec states
1077c478bd9Sstevel@tonic-gate 	 * that options after the T_ALLOPT option are to be ignored
1087c478bd9Sstevel@tonic-gate 	 * therefore we trncate the option buffer there and modify
1097c478bd9Sstevel@tonic-gate 	 * the effective length accordingly later.
1107c478bd9Sstevel@tonic-gate 	 */
1117c478bd9Sstevel@tonic-gate 	optlen = req->opt.len;
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate 	if (_T_IS_XTI(api_semantics) && (optlen > 0)) {
1147c478bd9Sstevel@tonic-gate 		/*
1157c478bd9Sstevel@tonic-gate 		 * Verify integrity of option buffer according to
1167c478bd9Sstevel@tonic-gate 		 * XTI t_optmgmt() semantics.
1177c478bd9Sstevel@tonic-gate 		 */
1187c478bd9Sstevel@tonic-gate 
1197c478bd9Sstevel@tonic-gate 		if (req->opt.buf == NULL ||
1207c478bd9Sstevel@tonic-gate 		    optlen < (t_scalar_t)sizeof (struct t_opthdr)) {
1217c478bd9Sstevel@tonic-gate 			/* option buffer should atleast have an t_opthdr */
1227c478bd9Sstevel@tonic-gate 			t_errno = TBADOPT;
1237c478bd9Sstevel@tonic-gate 			goto err_out;
1247c478bd9Sstevel@tonic-gate 		}
1257c478bd9Sstevel@tonic-gate 
126*61961e0fSrobinson 		/* LINTED pointer cast */
1277c478bd9Sstevel@tonic-gate 		opt_start = (struct t_opthdr *)req->opt.buf;
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate 		/*
1307c478bd9Sstevel@tonic-gate 		 * XXX We interpret that an option has to start on an
1317c478bd9Sstevel@tonic-gate 		 * aligned buffer boundary. This is not very explcit in
1327c478bd9Sstevel@tonic-gate 		 * XTI spec in text but the picture in Section 6.2 shows
1337c478bd9Sstevel@tonic-gate 		 * "opt.buf" at start of buffer and in combination with
1347c478bd9Sstevel@tonic-gate 		 * text can be construed to be restricting it to start
1357c478bd9Sstevel@tonic-gate 		 * on an aligned boundary. [Whether similar restriction
1367c478bd9Sstevel@tonic-gate 		 * applies to output buffer "ret->opt.buf" is an "interesting
1377c478bd9Sstevel@tonic-gate 		 * question" but we ignore it for now as that is the problem
1387c478bd9Sstevel@tonic-gate 		 * for the application not our implementation which will
1397c478bd9Sstevel@tonic-gate 		 * does not enforce any alignment requirement.]
1407c478bd9Sstevel@tonic-gate 		 *
1417c478bd9Sstevel@tonic-gate 		 * If start of buffer is not aligned, we signal an error.
1427c478bd9Sstevel@tonic-gate 		 */
1437c478bd9Sstevel@tonic-gate 		if (!(ISALIGNED_XTI_opthdr(opt_start))) {
1447c478bd9Sstevel@tonic-gate 			t_errno = TBADOPT;
1457c478bd9Sstevel@tonic-gate 			goto err_out;
1467c478bd9Sstevel@tonic-gate 		}
1477c478bd9Sstevel@tonic-gate 
148*61961e0fSrobinson 		/* LINTED pointer cast */
1497c478bd9Sstevel@tonic-gate 		opt_end = (struct t_opthdr *)((char *)opt_start +
1507c478bd9Sstevel@tonic-gate 						optlen);
1517c478bd9Sstevel@tonic-gate 
1527c478bd9Sstevel@tonic-gate 		/*
1537c478bd9Sstevel@tonic-gate 		 * Make sure we have enough in the message to dereference
1547c478bd9Sstevel@tonic-gate 		 * the option header.
1557c478bd9Sstevel@tonic-gate 		 */
1567c478bd9Sstevel@tonic-gate 		if ((uchar_t *)opt_start + sizeof (struct t_opthdr)
1577c478bd9Sstevel@tonic-gate 		    > (uchar_t *)opt_end) {
1587c478bd9Sstevel@tonic-gate 			t_errno = TBADOPT;
1597c478bd9Sstevel@tonic-gate 			goto err_out;
1607c478bd9Sstevel@tonic-gate 		}
1617c478bd9Sstevel@tonic-gate 		/*
1627c478bd9Sstevel@tonic-gate 		 * If there are multiple options, they all have to be
1637c478bd9Sstevel@tonic-gate 		 * the same level (so says XTI semantics).
1647c478bd9Sstevel@tonic-gate 		 */
1657c478bd9Sstevel@tonic-gate 		first_opt_level = opt_start->level;
1667c478bd9Sstevel@tonic-gate 
1677c478bd9Sstevel@tonic-gate 		for (opt = opt_start; opt < opt_end; opt = next_opt) {
1687c478bd9Sstevel@tonic-gate 			/*
1697c478bd9Sstevel@tonic-gate 			 * Make sure we have enough in the message to
1707c478bd9Sstevel@tonic-gate 			 * dereference the option header.
1717c478bd9Sstevel@tonic-gate 			 */
1727c478bd9Sstevel@tonic-gate 			if ((uchar_t *)opt_start + sizeof (struct t_opthdr)
1737c478bd9Sstevel@tonic-gate 			    > (uchar_t *)opt_end) {
1747c478bd9Sstevel@tonic-gate 				t_errno = TBADOPT;
1757c478bd9Sstevel@tonic-gate 				goto err_out;
1767c478bd9Sstevel@tonic-gate 			}
1777c478bd9Sstevel@tonic-gate 			/*
1787c478bd9Sstevel@tonic-gate 			 * We now compute pointer to next option in buffer
1797c478bd9Sstevel@tonic-gate 			 * 'next_opt' the next_opt computation above below
1807c478bd9Sstevel@tonic-gate 			 * 'opt->len' initialized by application which cannot
1817c478bd9Sstevel@tonic-gate 			 * be trusted. The usual value too large will be
1827c478bd9Sstevel@tonic-gate 			 * captured by the loop termination condition above.
1837c478bd9Sstevel@tonic-gate 			 * We check for the following which it will miss.
1847c478bd9Sstevel@tonic-gate 			 *	(1)pointer space wraparound arithmetic overflow
1857c478bd9Sstevel@tonic-gate 			 *	(2)last option in buffer with 'opt->len' being
1867c478bd9Sstevel@tonic-gate 			 *	  too large
1877c478bd9Sstevel@tonic-gate 			 *	(only reason 'next_opt' should equal or exceed
1887c478bd9Sstevel@tonic-gate 			 *	'opt_end' for last option is roundup unless
1897c478bd9Sstevel@tonic-gate 			 *	length is too-large/invalid)
1907c478bd9Sstevel@tonic-gate 			 *	(3) we also enforce the XTI restriction that
1917c478bd9Sstevel@tonic-gate 			 *	   all options in the buffer have to be the
1927c478bd9Sstevel@tonic-gate 			 *	   same level.
1937c478bd9Sstevel@tonic-gate 			 */
194*61961e0fSrobinson 			/* LINTED pointer cast */
1957c478bd9Sstevel@tonic-gate 			next_opt = (struct t_opthdr *)((uchar_t *)opt +
1967c478bd9Sstevel@tonic-gate 			    ROUNDUP_XTI_opthdr(opt->len));
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate 			if ((uchar_t *)next_opt < (uchar_t *)opt || /* (1) */
1997c478bd9Sstevel@tonic-gate 			    ((next_opt >= opt_end) &&
2007c478bd9Sstevel@tonic-gate 				(((uchar_t *)next_opt - (uchar_t *)opt_end) >=
2017c478bd9Sstevel@tonic-gate 				    ALIGN_XTI_opthdr_size)) || /* (2) */
2027c478bd9Sstevel@tonic-gate 			    (opt->level != first_opt_level)) { /* (3) */
2037c478bd9Sstevel@tonic-gate 				t_errno = TBADOPT;
2047c478bd9Sstevel@tonic-gate 				goto err_out;
2057c478bd9Sstevel@tonic-gate 			}
2067c478bd9Sstevel@tonic-gate 
2077c478bd9Sstevel@tonic-gate 			/*
2087c478bd9Sstevel@tonic-gate 			 * XTI semantics: options in the buffer after
2097c478bd9Sstevel@tonic-gate 			 * the T_ALLOPT option can be ignored
2107c478bd9Sstevel@tonic-gate 			 */
2117c478bd9Sstevel@tonic-gate 			if (opt->name == T_ALLOPT) {
2127c478bd9Sstevel@tonic-gate 				if (next_opt < opt_end) {
2137c478bd9Sstevel@tonic-gate 					/*
2147c478bd9Sstevel@tonic-gate 					 * there are options following, ignore
2157c478bd9Sstevel@tonic-gate 					 * them and truncate input
2167c478bd9Sstevel@tonic-gate 					 */
2177c478bd9Sstevel@tonic-gate 					optlen = (t_scalar_t)((uchar_t *)
2187c478bd9Sstevel@tonic-gate 					    next_opt - (uchar_t *)opt_start);
2197c478bd9Sstevel@tonic-gate 					opt_end = next_opt;
2207c478bd9Sstevel@tonic-gate 				}
2217c478bd9Sstevel@tonic-gate 			}
2227c478bd9Sstevel@tonic-gate 		}
2237c478bd9Sstevel@tonic-gate 	}
2247c478bd9Sstevel@tonic-gate 
225*61961e0fSrobinson 	/* LINTED pointer cast */
2267c478bd9Sstevel@tonic-gate 	optreq = (struct T_optmgmt_req *)ctlbuf.buf;
2277c478bd9Sstevel@tonic-gate 	if (_T_IS_XTI(api_semantics))
2287c478bd9Sstevel@tonic-gate 		optreq->PRIM_type = T_OPTMGMT_REQ;
2297c478bd9Sstevel@tonic-gate 	else
2307c478bd9Sstevel@tonic-gate 		optreq->PRIM_type = T_SVR4_OPTMGMT_REQ;
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate 	optreq->OPT_length = optlen;
2337c478bd9Sstevel@tonic-gate 	optreq->OPT_offset = 0;
2347c478bd9Sstevel@tonic-gate 	optreq->MGMT_flags = req->flags;
2357c478bd9Sstevel@tonic-gate 	size = (int)sizeof (struct T_optmgmt_req);
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate 	if (optlen) {
2387c478bd9Sstevel@tonic-gate 		if (_t_aligned_copy(&ctlbuf, optlen, size,
2397c478bd9Sstevel@tonic-gate 		    req->opt.buf, &optreq->OPT_offset) < 0) {
2407c478bd9Sstevel@tonic-gate 			/*
2417c478bd9Sstevel@tonic-gate 			 * Aligned copy will overflow buffer allocated
2427c478bd9Sstevel@tonic-gate 			 * based on maximum transport option size information
2437c478bd9Sstevel@tonic-gate 			 */
2447c478bd9Sstevel@tonic-gate 			t_errno = TBADOPT;
2457c478bd9Sstevel@tonic-gate 			goto err_out;
2467c478bd9Sstevel@tonic-gate 		}
2477c478bd9Sstevel@tonic-gate 		size = optreq->OPT_offset + optreq->OPT_length;
2487c478bd9Sstevel@tonic-gate 	}
2497c478bd9Sstevel@tonic-gate 
2507c478bd9Sstevel@tonic-gate 	if (_t_do_ioctl(fd, ctlbuf.buf, size, TI_OPTMGMT, &retlen) < 0)
2517c478bd9Sstevel@tonic-gate 		goto err_out;
2527c478bd9Sstevel@tonic-gate 
2537c478bd9Sstevel@tonic-gate 	if (retlen < (int)sizeof (struct T_optmgmt_ack)) {
2547c478bd9Sstevel@tonic-gate 		t_errno = TSYSERR;
2557c478bd9Sstevel@tonic-gate 		errno = EIO;
2567c478bd9Sstevel@tonic-gate 		goto err_out;
2577c478bd9Sstevel@tonic-gate 	}
2587c478bd9Sstevel@tonic-gate 
259*61961e0fSrobinson 	/* LINTED pointer cast */
2607c478bd9Sstevel@tonic-gate 	optack = (struct T_optmgmt_ack *)ctlbuf.buf;
2617c478bd9Sstevel@tonic-gate 
2627c478bd9Sstevel@tonic-gate 	if (_T_IS_TLI(api_semantics) || ret->opt.maxlen > 0) {
2637c478bd9Sstevel@tonic-gate 		if (TLEN_GT_NLEN(optack->OPT_length, ret->opt.maxlen)) {
2647c478bd9Sstevel@tonic-gate 			t_errno = TBUFOVFLW;
2657c478bd9Sstevel@tonic-gate 			goto err_out;
2667c478bd9Sstevel@tonic-gate 		}
2677c478bd9Sstevel@tonic-gate 		(void) memcpy(ret->opt.buf,
2687c478bd9Sstevel@tonic-gate 		    (char *)(ctlbuf.buf + optack->OPT_offset),
2697c478bd9Sstevel@tonic-gate 		    (unsigned int) optack->OPT_length);
2707c478bd9Sstevel@tonic-gate 		ret->opt.len = optack->OPT_length;
2717c478bd9Sstevel@tonic-gate 	}
2727c478bd9Sstevel@tonic-gate 
2737c478bd9Sstevel@tonic-gate 	/*
2747c478bd9Sstevel@tonic-gate 	 * Note: TPI is not clear about what really is carries in the
2757c478bd9Sstevel@tonic-gate 	 * T_OPTMGMT_ACK MGMT_flags fields. For T_OPTMGMT_ACK in response
2767c478bd9Sstevel@tonic-gate 	 * to T_SVR4_OPTMGMT_REQ, the Internet protocols in Solaris 2.X return
2777c478bd9Sstevel@tonic-gate 	 * the result code only (T_SUCCESS). For T_OPTMGMT_ACK in response
2787c478bd9Sstevel@tonic-gate 	 * to T_OPTMGMT_REQ, currently "worst status" code required for
2797c478bd9Sstevel@tonic-gate 	 * XTI is carried from the set of options OR'd with request flag.
2807c478bd9Sstevel@tonic-gate 	 * (This can change in future and "worst status" computation done
2817c478bd9Sstevel@tonic-gate 	 * with a scan in this routine.
2827c478bd9Sstevel@tonic-gate 	 *
2837c478bd9Sstevel@tonic-gate 	 * Note: Even for T_OPTMGMT_ACK is response to T_SVR4_OPTMGMT_REQ,
2847c478bd9Sstevel@tonic-gate 	 * removing request flag should be OK though it will not be set.
2857c478bd9Sstevel@tonic-gate 	 */
2867c478bd9Sstevel@tonic-gate 	ret->flags = optack->MGMT_flags & ~req->flags;
2877c478bd9Sstevel@tonic-gate 
2887c478bd9Sstevel@tonic-gate 	/*
2897c478bd9Sstevel@tonic-gate 	 * NOTE:
2907c478bd9Sstevel@tonic-gate 	 * There is no real change of state in state table for option
2917c478bd9Sstevel@tonic-gate 	 * management. The state change macro is used below only for its
2927c478bd9Sstevel@tonic-gate 	 * debugging and logging capabilities.
2937c478bd9Sstevel@tonic-gate 	 * The TLI "(mis)feature" (option management only in T_IDLE state)
2947c478bd9Sstevel@tonic-gate 	 * has been deprecated in XTI and our state table reflect updated for
2957c478bd9Sstevel@tonic-gate 	 * both TLI and XTI to reflect that.
2967c478bd9Sstevel@tonic-gate 	 * TLI semantics can be enforced by the transport providers that
2977c478bd9Sstevel@tonic-gate 	 * desire it at TPI level.
2987c478bd9Sstevel@tonic-gate 	 * There is no need to enforce this in the library since
2997c478bd9Sstevel@tonic-gate 	 * sane transport providers that do allow it (e.g TCP and it *needs*
3007c478bd9Sstevel@tonic-gate 	 * to allow it) should be allowed to work fine.
3017c478bd9Sstevel@tonic-gate 	 * The only transport providers that return TOUTSTATE for TLI
3027c478bd9Sstevel@tonic-gate 	 * t_optmgmt() are the drivers used for conformance testing to the
3037c478bd9Sstevel@tonic-gate 	 * broken TLI standard.
3047c478bd9Sstevel@tonic-gate 	 * These are /dev/{ticots,ticotsord,ticlts} used by the Sparc ABI test
3057c478bd9Sstevel@tonic-gate 	 * suite. Others are /dev/{tivc,tidg} used by the SVVS test suite.
3067c478bd9Sstevel@tonic-gate 	 */
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 	_T_TX_NEXTSTATE(T_OPTMGMT, tiptr,
3097c478bd9Sstevel@tonic-gate 	    "t_optmgmt: invalid state event T_OPTMGMT");
3107c478bd9Sstevel@tonic-gate 
3117c478bd9Sstevel@tonic-gate 	if (didalloc)
3127c478bd9Sstevel@tonic-gate 		free(ctlbuf.buf);
3137c478bd9Sstevel@tonic-gate 	else
3147c478bd9Sstevel@tonic-gate 		tiptr->ti_ctlbuf = ctlbuf.buf;
3157c478bd9Sstevel@tonic-gate 	sig_mutex_unlock(&tiptr->ti_lock);
3167c478bd9Sstevel@tonic-gate 	(void) thr_sigsetmask(SIG_SETMASK, &mask, NULL);
3177c478bd9Sstevel@tonic-gate 	return (0);
3187c478bd9Sstevel@tonic-gate 	/* NOTREACHED */
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate err_out:
3217c478bd9Sstevel@tonic-gate 	sv_errno = errno;
3227c478bd9Sstevel@tonic-gate 	if (didalloc)
3237c478bd9Sstevel@tonic-gate 		free(ctlbuf.buf);
3247c478bd9Sstevel@tonic-gate 	else
3257c478bd9Sstevel@tonic-gate 		tiptr->ti_ctlbuf = ctlbuf.buf;
3267c478bd9Sstevel@tonic-gate 	sig_mutex_unlock(&tiptr->ti_lock);
3277c478bd9Sstevel@tonic-gate 	(void) thr_sigsetmask(SIG_SETMASK, &mask, NULL);
3287c478bd9Sstevel@tonic-gate 	errno = sv_errno;
3297c478bd9Sstevel@tonic-gate 	return (-1);
3307c478bd9Sstevel@tonic-gate }
331