Print this page
195 Need replacement for nfs/lockd+klm
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Jeremy Jones <jeremy@delphix.com>
Reviewed by: Jeff Biseda <jbiseda@delphix.com>


   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.

  27  */
  28 
  29 /*
  30  * Multithreaded STREAMS Local Transport Provider.
  31  *
  32  * OVERVIEW
  33  * ========
  34  *
  35  * This driver provides TLI as well as socket semantics.  It provides
  36  * connectionless, connection oriented, and connection oriented with orderly
  37  * release transports for TLI and sockets. Each transport type has separate name
  38  * spaces (i.e. it is not possible to connect from a socket to a TLI endpoint) -
  39  * this removes any name space conflicts when binding to socket style transport
  40  * addresses.
  41  *
  42  * NOTE: There is one exception: Socket ticots and ticotsord transports share
  43  * the same namespace. In fact, sockets always use ticotsord type transport.
  44  *
  45  * The driver mode is specified during open() by the minor number used for
  46  * open.


4235                         bcopy(tep->te_abuf, ackmp->b_wptr,
4236                             tep->te_alen);
4237                         ackmp->b_wptr += tep->te_alen;
4238                         ASSERT(ackmp->b_wptr <= ackmp->b_datap->db_lim);
4239                 }
4240 
4241                 (void) qreply(wq, ackmp);
4242         } else {
4243                 ASSERT(tep->te_state == TS_DATA_XFER ||
4244                     tep->te_state == TS_WIND_ORDREL ||
4245                     tep->te_state == TS_WREQ_ORDREL);
4246                 /* connection oriented in data transfer */
4247                 tl_connected_cots_addr_req(mp, tep);
4248         }
4249 }
4250 
4251 
4252 static void
4253 tl_connected_cots_addr_req(mblk_t *mp, tl_endpt_t *tep)
4254 {
4255         tl_endpt_t              *peer_tep;
4256         size_t                  ack_sz;
4257         mblk_t                  *ackmp;
4258         struct T_addr_ack       *taa;
4259         uchar_t                 *addr_startp;
4260 
4261         if (tep->te_closing) {
4262                 freemsg(mp);
4263                 return;
4264         }
4265 





4266         ASSERT(tep->te_state >= TS_IDLE);
4267 
4268         ack_sz = sizeof (struct T_addr_ack);
4269         ack_sz += T_ALIGN(tep->te_alen);
4270         peer_tep = tep->te_conp;
4271         ack_sz += peer_tep->te_alen;
4272 
4273         ackmp = tpi_ack_alloc(mp, ack_sz, M_PCPROTO, T_ADDR_ACK);
4274         if (ackmp == NULL) {
4275                 (void) (STRLOG(TL_ID, tep->te_minor, 1, SL_TRACE|SL_ERROR,
4276                     "tl_connected_cots_addr_req: reallocb failed"));
4277                 tl_memrecover(tep->te_wq, mp, ack_sz);
4278                 return;
4279         }
4280 
4281         taa = (struct T_addr_ack *)ackmp->b_rptr;
4282 
4283         /* endpoint is bound */
4284         taa->LOCADDR_length = tep->te_alen;
4285         taa->LOCADDR_offset = (t_scalar_t)sizeof (*taa);
4286 
4287         addr_startp = (uchar_t *)&taa[1];
4288 
4289         bcopy(tep->te_abuf, addr_startp,
4290             tep->te_alen);




   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 /*
  22  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  23  * Use is subject to license terms.
  24  */
  25 /*
  26  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  27  * Copyright (c) 2012 by Delphix. All rights reserved.
  28  */
  29 
  30 /*
  31  * Multithreaded STREAMS Local Transport Provider.
  32  *
  33  * OVERVIEW
  34  * ========
  35  *
  36  * This driver provides TLI as well as socket semantics.  It provides
  37  * connectionless, connection oriented, and connection oriented with orderly
  38  * release transports for TLI and sockets. Each transport type has separate name
  39  * spaces (i.e. it is not possible to connect from a socket to a TLI endpoint) -
  40  * this removes any name space conflicts when binding to socket style transport
  41  * addresses.
  42  *
  43  * NOTE: There is one exception: Socket ticots and ticotsord transports share
  44  * the same namespace. In fact, sockets always use ticotsord type transport.
  45  *
  46  * The driver mode is specified during open() by the minor number used for
  47  * open.


4236                         bcopy(tep->te_abuf, ackmp->b_wptr,
4237                             tep->te_alen);
4238                         ackmp->b_wptr += tep->te_alen;
4239                         ASSERT(ackmp->b_wptr <= ackmp->b_datap->db_lim);
4240                 }
4241 
4242                 (void) qreply(wq, ackmp);
4243         } else {
4244                 ASSERT(tep->te_state == TS_DATA_XFER ||
4245                     tep->te_state == TS_WIND_ORDREL ||
4246                     tep->te_state == TS_WREQ_ORDREL);
4247                 /* connection oriented in data transfer */
4248                 tl_connected_cots_addr_req(mp, tep);
4249         }
4250 }
4251 
4252 
4253 static void
4254 tl_connected_cots_addr_req(mblk_t *mp, tl_endpt_t *tep)
4255 {
4256         tl_endpt_t              *peer_tep = tep->te_conp;
4257         size_t                  ack_sz;
4258         mblk_t                  *ackmp;
4259         struct T_addr_ack       *taa;
4260         uchar_t                 *addr_startp;
4261 
4262         if (tep->te_closing) {
4263                 freemsg(mp);
4264                 return;
4265         }
4266 
4267         if (peer_tep == NULL || peer_tep->te_closing) {
4268                 tl_error_ack(tep->te_wq, mp, TSYSERR, ECONNRESET, T_ADDR_REQ);
4269                 return;
4270         }
4271 
4272         ASSERT(tep->te_state >= TS_IDLE);
4273 
4274         ack_sz = sizeof (struct T_addr_ack);
4275         ack_sz += T_ALIGN(tep->te_alen);

4276         ack_sz += peer_tep->te_alen;
4277 
4278         ackmp = tpi_ack_alloc(mp, ack_sz, M_PCPROTO, T_ADDR_ACK);
4279         if (ackmp == NULL) {
4280                 (void) (STRLOG(TL_ID, tep->te_minor, 1, SL_TRACE|SL_ERROR,
4281                     "tl_connected_cots_addr_req: reallocb failed"));
4282                 tl_memrecover(tep->te_wq, mp, ack_sz);
4283                 return;
4284         }
4285 
4286         taa = (struct T_addr_ack *)ackmp->b_rptr;
4287 
4288         /* endpoint is bound */
4289         taa->LOCADDR_length = tep->te_alen;
4290         taa->LOCADDR_offset = (t_scalar_t)sizeof (*taa);
4291 
4292         addr_startp = (uchar_t *)&taa[1];
4293 
4294         bcopy(tep->te_abuf, addr_startp,
4295             tep->te_alen);