Print this page
*** NO COMMENTS ***


   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 (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 
  25 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  26 /*        All Rights Reserved   */
  27 
  28 /*




  29  * Portions of this source code were derived from Berkeley 4.3 BSD
  30  * under license from the Regents of the University of California.
  31  */
  32 
  33 /*
  34  * svc_clts.c
  35  * Server side for RPC in the kernel.
  36  *
  37  */
  38 
  39 #include <sys/param.h>
  40 #include <sys/types.h>
  41 #include <sys/sysmacros.h>
  42 #include <sys/file.h>
  43 #include <sys/stream.h>
  44 #include <sys/strsun.h>
  45 #include <sys/strsubr.h>
  46 #include <sys/tihdr.h>
  47 #include <sys/tiuser.h>
  48 #include <sys/t_kuser.h>


  91         svc_clts_ksend,         /* Send reply */
  92         svc_clts_kfreeargs,     /* Free argument data space */
  93         svc_clts_kdestroy,      /* Destroy transport handle */
  94         svc_clts_kdup,          /* Check entry in dup req cache */
  95         svc_clts_kdupdone,      /* Mark entry in dup req cache as done */
  96         svc_clts_kgetres,       /* Get pointer to response buffer */
  97         svc_clts_kfreeres,      /* Destroy pre-serialized response header */
  98         svc_clts_kclone_destroy, /* Destroy a clone xprt */
  99         svc_clts_kstart,        /* Tell `ready-to-receive' to rpcmod */
 100         svc_clts_kclone_xprt,   /* transport specific clone xprt function */
 101         svc_clts_ktattrs        /* Transport specific attributes. */
 102 };
 103 
 104 /*
 105  * Transport private data.
 106  * Kept in xprt->xp_p2buf.
 107  */
 108 struct udp_data {
 109         mblk_t  *ud_resp;                       /* buffer for response */
 110         mblk_t  *ud_inmp;                       /* mblk chain of request */

 111 };
 112 
 113 #define UD_MAXSIZE      8800
 114 #define UD_INITSIZE     2048
 115 
 116 /*
 117  * Connectionless server statistics
 118  */
 119 static const struct rpc_clts_server {
 120         kstat_named_t   rscalls;
 121         kstat_named_t   rsbadcalls;
 122         kstat_named_t   rsnullrecv;
 123         kstat_named_t   rsbadlen;
 124         kstat_named_t   rsxdrcall;
 125         kstat_named_t   rsdupchecks;
 126         kstat_named_t   rsdupreqs;
 127 } clts_rsstat_tmpl = {
 128         { "calls",      KSTAT_DATA_UINT64 },
 129         { "badcalls",   KSTAT_DATA_UINT64 },
 130         { "nullrecv",   KSTAT_DATA_UINT64 },


 304             pptr->unitdata_ind.OPT_length) ||
 305             hdrsz < (pptr->unitdata_ind.SRC_offset +
 306             pptr->unitdata_ind.SRC_length)) {
 307                 goto bad;
 308         }
 309 
 310         /*
 311          * Make sure that the transport provided a usable address.
 312          */
 313         if (pptr->unitdata_ind.SRC_length <= 0) {
 314                 goto bad;
 315         }
 316         /*
 317          * Point the remote transport address in the service_transport
 318          * handle at the address in the request.
 319          */
 320         clone_xprt->xp_rtaddr.buf = (char *)mp->b_rptr +
 321             pptr->unitdata_ind.SRC_offset;
 322         clone_xprt->xp_rtaddr.len = pptr->unitdata_ind.SRC_length;
 323 


 324         /*
 325          * Copy the local transport address in the service_transport
 326          * handle at the address in the request. We will have only
 327          * the local IP address in options.
 328          */
 329         ((sin_t *)(clone_xprt->xp_lcladdr.buf))->sin_family = AF_UNSPEC;
 330         if (pptr->unitdata_ind.OPT_length && pptr->unitdata_ind.OPT_offset) {
 331                 char *dstopt = (char *)mp->b_rptr +
 332                     pptr->unitdata_ind.OPT_offset;
 333                 struct T_opthdr *toh = (struct T_opthdr *)dstopt;
 334 
 335                 if (toh->level == IPPROTO_IPV6 && toh->status == 0 &&
 336                     toh->name == IPV6_PKTINFO) {
 337                         struct in6_pktinfo *pkti;
 338 
 339                         dstopt += sizeof (struct T_opthdr);
 340                         pkti = (struct in6_pktinfo *)dstopt;
 341                         ((sin6_t *)(clone_xprt->xp_lcladdr.buf))->sin6_addr
 342                             = pkti->ipi6_addr;
 343                         ((sin6_t *)(clone_xprt->xp_lcladdr.buf))->sin6_family




   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 (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
  23  */
  24 
  25 /*      Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
  26 /*        All Rights Reserved   */
  27 
  28 /*
  29  * Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
  30  */
  31 
  32 /*
  33  * Portions of this source code were derived from Berkeley 4.3 BSD
  34  * under license from the Regents of the University of California.
  35  */
  36 
  37 /*
  38  * svc_clts.c
  39  * Server side for RPC in the kernel.
  40  *
  41  */
  42 
  43 #include <sys/param.h>
  44 #include <sys/types.h>
  45 #include <sys/sysmacros.h>
  46 #include <sys/file.h>
  47 #include <sys/stream.h>
  48 #include <sys/strsun.h>
  49 #include <sys/strsubr.h>
  50 #include <sys/tihdr.h>
  51 #include <sys/tiuser.h>
  52 #include <sys/t_kuser.h>


  95         svc_clts_ksend,         /* Send reply */
  96         svc_clts_kfreeargs,     /* Free argument data space */
  97         svc_clts_kdestroy,      /* Destroy transport handle */
  98         svc_clts_kdup,          /* Check entry in dup req cache */
  99         svc_clts_kdupdone,      /* Mark entry in dup req cache as done */
 100         svc_clts_kgetres,       /* Get pointer to response buffer */
 101         svc_clts_kfreeres,      /* Destroy pre-serialized response header */
 102         svc_clts_kclone_destroy, /* Destroy a clone xprt */
 103         svc_clts_kstart,        /* Tell `ready-to-receive' to rpcmod */
 104         svc_clts_kclone_xprt,   /* transport specific clone xprt function */
 105         svc_clts_ktattrs        /* Transport specific attributes. */
 106 };
 107 
 108 /*
 109  * Transport private data.
 110  * Kept in xprt->xp_p2buf.
 111  */
 112 struct udp_data {
 113         mblk_t  *ud_resp;                       /* buffer for response */
 114         mblk_t  *ud_inmp;                       /* mblk chain of request */
 115         sin6_t  ud_local;                       /* local address */
 116 };
 117 
 118 #define UD_MAXSIZE      8800
 119 #define UD_INITSIZE     2048
 120 
 121 /*
 122  * Connectionless server statistics
 123  */
 124 static const struct rpc_clts_server {
 125         kstat_named_t   rscalls;
 126         kstat_named_t   rsbadcalls;
 127         kstat_named_t   rsnullrecv;
 128         kstat_named_t   rsbadlen;
 129         kstat_named_t   rsxdrcall;
 130         kstat_named_t   rsdupchecks;
 131         kstat_named_t   rsdupreqs;
 132 } clts_rsstat_tmpl = {
 133         { "calls",      KSTAT_DATA_UINT64 },
 134         { "badcalls",   KSTAT_DATA_UINT64 },
 135         { "nullrecv",   KSTAT_DATA_UINT64 },


 309             pptr->unitdata_ind.OPT_length) ||
 310             hdrsz < (pptr->unitdata_ind.SRC_offset +
 311             pptr->unitdata_ind.SRC_length)) {
 312                 goto bad;
 313         }
 314 
 315         /*
 316          * Make sure that the transport provided a usable address.
 317          */
 318         if (pptr->unitdata_ind.SRC_length <= 0) {
 319                 goto bad;
 320         }
 321         /*
 322          * Point the remote transport address in the service_transport
 323          * handle at the address in the request.
 324          */
 325         clone_xprt->xp_rtaddr.buf = (char *)mp->b_rptr +
 326             pptr->unitdata_ind.SRC_offset;
 327         clone_xprt->xp_rtaddr.len = pptr->unitdata_ind.SRC_length;
 328 
 329         clone_xprt->xp_lcladdr.buf = (char *)&ud->ud_local;
 330 
 331         /*
 332          * Copy the local transport address in the service_transport
 333          * handle at the address in the request. We will have only
 334          * the local IP address in options.
 335          */
 336         ((sin_t *)(clone_xprt->xp_lcladdr.buf))->sin_family = AF_UNSPEC;
 337         if (pptr->unitdata_ind.OPT_length && pptr->unitdata_ind.OPT_offset) {
 338                 char *dstopt = (char *)mp->b_rptr +
 339                     pptr->unitdata_ind.OPT_offset;
 340                 struct T_opthdr *toh = (struct T_opthdr *)dstopt;
 341 
 342                 if (toh->level == IPPROTO_IPV6 && toh->status == 0 &&
 343                     toh->name == IPV6_PKTINFO) {
 344                         struct in6_pktinfo *pkti;
 345 
 346                         dstopt += sizeof (struct T_opthdr);
 347                         pkti = (struct in6_pktinfo *)dstopt;
 348                         ((sin6_t *)(clone_xprt->xp_lcladdr.buf))->sin6_addr
 349                             = pkti->ipi6_addr;
 350                         ((sin6_t *)(clone_xprt->xp_lcladdr.buf))->sin6_family