Print this page




   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 /*
  23  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2015, Joyent, Inc.  All rights reserved.
  28  */
  29 
  30 #include <sys/types.h>
  31 #include <sys/param.h>
  32 #include <sys/systm.h>
  33 #include <sys/sysmacros.h>
  34 #include <sys/debug.h>
  35 #include <sys/cmn_err.h>
  36 
  37 #include <sys/stropts.h>
  38 #include <sys/socket.h>
  39 #include <sys/socketvar.h>
  40 
  41 #define _SUN_TPI_VERSION        2
  42 #include <sys/tihdr.h>
  43 #include <sys/sockio.h>
  44 #include <sys/kmem_impl.h>
  45 
  46 #include <sys/strsubr.h>
  47 #include <sys/strsun.h>


1307         }
1308 
1309         if (so->so_filter_active > 0) {
1310                 for (; filter != NULL; filter = filter->sofi_prev) {
1311                         if (!SOF_INTERESTED(filter, data_in))
1312                                 continue;
1313                         mp = (*filter->sofi_ops->sofop_data_in)(
1314                             (sof_handle_t)filter, filter->sofi_cookie, mp,
1315                             flags, &msg_size);
1316                         ASSERT(msgdsize(mp) == msg_size);
1317                         DTRACE_PROBE2(filter__data, (sof_instance_t), filter,
1318                             (mblk_t *), mp);
1319                         /* Data was consumed/dropped, just do space check */
1320                         if (msg_size == 0) {
1321                                 mutex_enter(&so->so_lock);
1322                                 goto space_check;
1323                         }
1324                 }
1325         }
1326 
1327         mutex_enter(&so->so_lock);
1328         if (so->so_krecv_cb != NULL) {
1329                 boolean_t cont;
1330                 so_krecv_f func = so->so_krecv_cb;
1331                 void *arg = so->so_krecv_arg;
1332 
1333                 mutex_exit(&so->so_lock);
1334                 cont = func(so, mp, msg_size, flags & MSG_OOB, arg);
1335                 mutex_enter(&so->so_lock);
1336                 if (cont == B_TRUE) {
1337                         space_left = so->so_rcvbuf;
1338                 } else {
1339                         so->so_rcv_queued = so->so_rcvlowat;
1340                         *errorp = ENOSPC;
1341                         space_left = -1;
1342                 }
1343                 goto done_unlock;
1344         }
1345         mutex_exit(&so->so_lock);
1346 
1347         if (flags & MSG_OOB) {
1348                 so_queue_oob(so, mp, msg_size);
1349                 mutex_enter(&so->so_lock);
1350                 goto space_check;
1351         }
1352 
1353         if (force_pushp != NULL)
1354                 force_push = *force_pushp;
1355 
1356         mutex_enter(&so->so_lock);
1357         if (so->so_state & (SS_FALLBACK_DRAIN | SS_FALLBACK_COMP)) {
1358                 if (sodp != NULL)
1359                         SOD_DISABLE(sodp);
1360                 mutex_exit(&so->so_lock);
1361                 *errorp = EOPNOTSUPP;
1362                 return (-1);
1363         }
1364         if (so->so_state & (SS_CANTRCVMORE | SS_CLOSING)) {
1365                 freemsg(mp);
1366                 if (sodp != NULL)


1605 {
1606         rval_t          rval;
1607         int             flags = 0;
1608         t_uscalar_t     controllen, namelen;
1609         int             error = 0;
1610         int ret;
1611         mblk_t          *mctlp = NULL;
1612         union T_primitives *tpr;
1613         void            *control;
1614         ssize_t         saved_resid;
1615         struct uio      *suiop;
1616 
1617         SO_BLOCK_FALLBACK(so, SOP_RECVMSG(so, msg, uiop, cr));
1618 
1619         if ((so->so_state & (SS_ISCONNECTED|SS_CANTRCVMORE)) == 0 &&
1620             (so->so_mode & SM_CONNREQUIRED)) {
1621                 SO_UNBLOCK_FALLBACK(so);
1622                 return (ENOTCONN);
1623         }
1624 
1625         mutex_enter(&so->so_lock);
1626         if (so->so_krecv_cb != NULL) {
1627                 mutex_exit(&so->so_lock);
1628                 return (EOPNOTSUPP);
1629         }
1630         mutex_exit(&so->so_lock);
1631 
1632         if (msg->msg_flags & MSG_PEEK)
1633                 msg->msg_flags &= ~MSG_WAITALL;
1634 
1635         if (so->so_mode & SM_ATOMIC)
1636                 msg->msg_flags |= MSG_TRUNC;
1637 
1638         if (msg->msg_flags & MSG_OOB) {
1639                 if ((so->so_mode & SM_EXDATA) == 0) {
1640                         error = EOPNOTSUPP;
1641                 } else if (so->so_downcalls->sd_recv_uio != NULL) {
1642                         error = (*so->so_downcalls->sd_recv_uio)
1643                             (so->so_proto_handle, uiop, msg, cr);
1644                 } else {
1645                         error = sorecvoob(so, msg, uiop, msg->msg_flags,
1646                             IS_SO_OOB_INLINE(so));
1647                 }
1648                 SO_UNBLOCK_FALLBACK(so);
1649                 return (error);
1650         }
1651 




   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 /*
  23  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
  24  */
  25 
  26 /*
  27  * Copyright (c) 2014, Joyent, Inc.  All rights reserved.
  28  */
  29 
  30 #include <sys/types.h>
  31 #include <sys/param.h>
  32 #include <sys/systm.h>
  33 #include <sys/sysmacros.h>
  34 #include <sys/debug.h>
  35 #include <sys/cmn_err.h>
  36 
  37 #include <sys/stropts.h>
  38 #include <sys/socket.h>
  39 #include <sys/socketvar.h>
  40 
  41 #define _SUN_TPI_VERSION        2
  42 #include <sys/tihdr.h>
  43 #include <sys/sockio.h>
  44 #include <sys/kmem_impl.h>
  45 
  46 #include <sys/strsubr.h>
  47 #include <sys/strsun.h>


1307         }
1308 
1309         if (so->so_filter_active > 0) {
1310                 for (; filter != NULL; filter = filter->sofi_prev) {
1311                         if (!SOF_INTERESTED(filter, data_in))
1312                                 continue;
1313                         mp = (*filter->sofi_ops->sofop_data_in)(
1314                             (sof_handle_t)filter, filter->sofi_cookie, mp,
1315                             flags, &msg_size);
1316                         ASSERT(msgdsize(mp) == msg_size);
1317                         DTRACE_PROBE2(filter__data, (sof_instance_t), filter,
1318                             (mblk_t *), mp);
1319                         /* Data was consumed/dropped, just do space check */
1320                         if (msg_size == 0) {
1321                                 mutex_enter(&so->so_lock);
1322                                 goto space_check;
1323                         }
1324                 }
1325         }
1326 




















1327         if (flags & MSG_OOB) {
1328                 so_queue_oob(so, mp, msg_size);
1329                 mutex_enter(&so->so_lock);
1330                 goto space_check;
1331         }
1332 
1333         if (force_pushp != NULL)
1334                 force_push = *force_pushp;
1335 
1336         mutex_enter(&so->so_lock);
1337         if (so->so_state & (SS_FALLBACK_DRAIN | SS_FALLBACK_COMP)) {
1338                 if (sodp != NULL)
1339                         SOD_DISABLE(sodp);
1340                 mutex_exit(&so->so_lock);
1341                 *errorp = EOPNOTSUPP;
1342                 return (-1);
1343         }
1344         if (so->so_state & (SS_CANTRCVMORE | SS_CLOSING)) {
1345                 freemsg(mp);
1346                 if (sodp != NULL)


1585 {
1586         rval_t          rval;
1587         int             flags = 0;
1588         t_uscalar_t     controllen, namelen;
1589         int             error = 0;
1590         int ret;
1591         mblk_t          *mctlp = NULL;
1592         union T_primitives *tpr;
1593         void            *control;
1594         ssize_t         saved_resid;
1595         struct uio      *suiop;
1596 
1597         SO_BLOCK_FALLBACK(so, SOP_RECVMSG(so, msg, uiop, cr));
1598 
1599         if ((so->so_state & (SS_ISCONNECTED|SS_CANTRCVMORE)) == 0 &&
1600             (so->so_mode & SM_CONNREQUIRED)) {
1601                 SO_UNBLOCK_FALLBACK(so);
1602                 return (ENOTCONN);
1603         }
1604 







1605         if (msg->msg_flags & MSG_PEEK)
1606                 msg->msg_flags &= ~MSG_WAITALL;
1607 
1608         if (so->so_mode & SM_ATOMIC)
1609                 msg->msg_flags |= MSG_TRUNC;
1610 
1611         if (msg->msg_flags & MSG_OOB) {
1612                 if ((so->so_mode & SM_EXDATA) == 0) {
1613                         error = EOPNOTSUPP;
1614                 } else if (so->so_downcalls->sd_recv_uio != NULL) {
1615                         error = (*so->so_downcalls->sd_recv_uio)
1616                             (so->so_proto_handle, uiop, msg, cr);
1617                 } else {
1618                         error = sorecvoob(so, msg, uiop, msg->msg_flags,
1619                             IS_SO_OOB_INLINE(so));
1620                 }
1621                 SO_UNBLOCK_FALLBACK(so);
1622                 return (error);
1623         }
1624