Print this page
OS-4018 lxbrand support TCP SO_REUSEPORT
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Cody Mello <cody.mello@joyent.com>


   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   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) 2010, Oracle and/or its affiliates. All rights reserved.

  24  */
  25 
  26 /* This file contains all TCP kernel socket related functions. */
  27 
  28 #include <sys/types.h>
  29 #include <sys/strlog.h>
  30 #include <sys/policy.h>
  31 #include <sys/sockio.h>
  32 #include <sys/strsubr.h>
  33 #include <sys/strsun.h>
  34 #include <sys/squeue_impl.h>
  35 #include <sys/squeue.h>
  36 #define _SUN_TPI_VERSION 2
  37 #include <sys/tihdr.h>
  38 #include <sys/timod.h>
  39 #include <sys/tpicommon.h>
  40 #include <sys/socketvar.h>
  41 
  42 #include <inet/common.h>
  43 #include <inet/proto_set.h>


1004 
1005         /* Pre-allocate the T_ordrel_ind mblk. */
1006         ASSERT(tcp->tcp_ordrel_mp == NULL);
1007         ordrel_mp = allocb_wait(sizeof (struct T_ordrel_ind), BPRI_HI,
1008             STR_NOSIG, NULL);
1009         ordrel_mp->b_datap->db_type = M_PROTO;
1010         ((struct T_ordrel_ind *)ordrel_mp->b_rptr)->PRIM_type = T_ORDREL_IND;
1011         ordrel_mp->b_wptr += sizeof (struct T_ordrel_ind);
1012 
1013         /*
1014          * Enter the squeue so that no new packets can come in
1015          */
1016         error = squeue_synch_enter(connp, NULL);
1017         if (error != 0) {
1018                 /* failed to enter, free all the pre-allocated messages. */
1019                 freeb(stropt_mp);
1020                 freeb(ordrel_mp);
1021                 return (ENOMEM);
1022         }
1023 










1024         /*
1025          * Both endpoints must be of the same type (either STREAMS or
1026          * non-STREAMS) for fusion to be enabled. So if we are fused,
1027          * we have to unfuse.
1028          */
1029         if (tcp->tcp_fused)
1030                 tcp_unfuse(tcp);
1031 
1032         if (tcp->tcp_listener != NULL) {
1033                 /* The eager will deal with opts when accept() is called */
1034                 freeb(stropt_mp);
1035                 tcp_fallback_eager(tcp, direct_sockfs, quiesced_cb, arg);
1036         } else {
1037                 tcp_fallback_noneager(tcp, stropt_mp, q, direct_sockfs,
1038                     quiesced_cb, arg);
1039         }
1040 
1041         /*
1042          * No longer a direct socket
1043          *




   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   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) 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2015 Joyent, Inc.
  25  */
  26 
  27 /* This file contains all TCP kernel socket related functions. */
  28 
  29 #include <sys/types.h>
  30 #include <sys/strlog.h>
  31 #include <sys/policy.h>
  32 #include <sys/sockio.h>
  33 #include <sys/strsubr.h>
  34 #include <sys/strsun.h>
  35 #include <sys/squeue_impl.h>
  36 #include <sys/squeue.h>
  37 #define _SUN_TPI_VERSION 2
  38 #include <sys/tihdr.h>
  39 #include <sys/timod.h>
  40 #include <sys/tpicommon.h>
  41 #include <sys/socketvar.h>
  42 
  43 #include <inet/common.h>
  44 #include <inet/proto_set.h>


1005 
1006         /* Pre-allocate the T_ordrel_ind mblk. */
1007         ASSERT(tcp->tcp_ordrel_mp == NULL);
1008         ordrel_mp = allocb_wait(sizeof (struct T_ordrel_ind), BPRI_HI,
1009             STR_NOSIG, NULL);
1010         ordrel_mp->b_datap->db_type = M_PROTO;
1011         ((struct T_ordrel_ind *)ordrel_mp->b_rptr)->PRIM_type = T_ORDREL_IND;
1012         ordrel_mp->b_wptr += sizeof (struct T_ordrel_ind);
1013 
1014         /*
1015          * Enter the squeue so that no new packets can come in
1016          */
1017         error = squeue_synch_enter(connp, NULL);
1018         if (error != 0) {
1019                 /* failed to enter, free all the pre-allocated messages. */
1020                 freeb(stropt_mp);
1021                 freeb(ordrel_mp);
1022                 return (ENOMEM);
1023         }
1024 
1025         /*
1026          * Do not allow fallback on connections making use of SO_REUSEPORT.
1027          */
1028         if (tcp->tcp_rg_bind != NULL) {
1029                 freeb(stropt_mp);
1030                 freeb(ordrel_mp);
1031                 squeue_synch_exit(connp);
1032                 return (EINVAL);
1033         }
1034 
1035         /*
1036          * Both endpoints must be of the same type (either STREAMS or
1037          * non-STREAMS) for fusion to be enabled. So if we are fused,
1038          * we have to unfuse.
1039          */
1040         if (tcp->tcp_fused)
1041                 tcp_unfuse(tcp);
1042 
1043         if (tcp->tcp_listener != NULL) {
1044                 /* The eager will deal with opts when accept() is called */
1045                 freeb(stropt_mp);
1046                 tcp_fallback_eager(tcp, direct_sockfs, quiesced_cb, arg);
1047         } else {
1048                 tcp_fallback_noneager(tcp, stropt_mp, q, direct_sockfs,
1049                     quiesced_cb, arg);
1050         }
1051 
1052         /*
1053          * No longer a direct socket
1054          *