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