Print this page
3942 inject sanity into ipadm tcp buffer size properties
3943 _snd_lowat_fraction tcp tunable has no effect
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Peng Dai <peng.dai@delphix.com>


   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) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011, Joyent Inc. All rights reserved.
  25  * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.

  26  */
  27 /* Copyright (c) 1990 Mentat Inc. */
  28 
  29 #include <sys/types.h>
  30 #include <sys/stream.h>
  31 #include <sys/strsun.h>
  32 #include <sys/strsubr.h>
  33 #include <sys/stropts.h>
  34 #include <sys/strlog.h>
  35 #define _SUN_TPI_VERSION 2
  36 #include <sys/tihdr.h>
  37 #include <sys/timod.h>
  38 #include <sys/ddi.h>
  39 #include <sys/sunddi.h>
  40 #include <sys/suntpi.h>
  41 #include <sys/xti_inet.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/debug.h>
  44 #include <sys/sdt.h>
  45 #include <sys/vtrace.h>


 215  * only exception is tcp_xmit_listeners_reset() which is called
 216  * directly from IP and needs to policy check to see if TH_RST
 217  * can be sent out.
 218  */
 219 
 220 /*
 221  * Values for squeue switch:
 222  * 1: SQ_NODRAIN
 223  * 2: SQ_PROCESS
 224  * 3: SQ_FILL
 225  */
 226 int tcp_squeue_wput = 2;        /* /etc/systems */
 227 int tcp_squeue_flag;
 228 
 229 /*
 230  * To prevent memory hog, limit the number of entries in tcp_free_list
 231  * to 1% of available memory / number of cpus
 232  */
 233 uint_t tcp_free_list_max_cnt = 0;
 234 
 235 #define TCP_XMIT_LOWATER        4096
 236 #define TCP_XMIT_HIWATER        49152
 237 #define TCP_RECV_LOWATER        2048
 238 #define TCP_RECV_HIWATER        128000
 239 
 240 #define TIDUSZ  4096    /* transport interface data unit size */
 241 
 242 /*
 243  * Size of acceptor hash list.  It has to be a power of 2 for hashing.
 244  */
 245 #define TCP_ACCEPTOR_FANOUT_SIZE                512
 246 
 247 #ifdef  _ILP32
 248 #define TCP_ACCEPTOR_HASH(accid)                                        \
 249                 (((uint_t)(accid) >> 8) & (TCP_ACCEPTOR_FANOUT_SIZE - 1))
 250 #else
 251 #define TCP_ACCEPTOR_HASH(accid)                                        \
 252                 ((uint_t)(accid) & (TCP_ACCEPTOR_FANOUT_SIZE - 1))
 253 #endif  /* _ILP32 */
 254 
 255 /*
 256  * Minimum number of connections which can be created per listener.  Used
 257  * when the listener connection count is in effect.
 258  */
 259 static uint32_t tcp_min_conn_listener = 2;


2701         connp->conn_ixa->ixa_zoneid = zoneid;
2702         connp->conn_mlp_type = mlptSingle;
2703         ASSERT(connp->conn_netstack == tcps->tcps_netstack);
2704         ASSERT(tcp->tcp_tcps == tcps);
2705 
2706         /*
2707          * If the caller has the process-wide flag set, then default to MAC
2708          * exempt mode.  This allows read-down to unlabeled hosts.
2709          */
2710         if (getpflags(NET_MAC_AWARE, credp) != 0)
2711                 connp->conn_mac_mode = CONN_MAC_AWARE;
2712 
2713         connp->conn_zone_is_global = (crgetzoneid(credp) == GLOBAL_ZONEID);
2714 
2715         if (issocket) {
2716                 tcp->tcp_issocket = 1;
2717         }
2718 
2719         connp->conn_rcvbuf = tcps->tcps_recv_hiwat;
2720         connp->conn_sndbuf = tcps->tcps_xmit_hiwat;




2721         connp->conn_sndlowat = tcps->tcps_xmit_lowat;

2722         connp->conn_so_type = SOCK_STREAM;
2723         connp->conn_wroff = connp->conn_ht_iphc_allocated +
2724             tcps->tcps_wroff_xtra;
2725 
2726         SOCK_CONNID_INIT(tcp->tcp_connid);
2727         /* DTrace ignores this - it isn't a tcp:::state-change */
2728         tcp->tcp_state = TCPS_IDLE;
2729         tcp_init_values(tcp, NULL);
2730         return (connp);
2731 }
2732 
2733 static int
2734 tcp_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp,
2735     boolean_t isv6)
2736 {
2737         tcp_t           *tcp = NULL;
2738         conn_t          *connp = NULL;
2739         int             err;
2740         vmem_t          *minor_arena = NULL;
2741         dev_t           conn_dev;




   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) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright (c) 2011, Joyent Inc. All rights reserved.
  25  * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
  26  * Copyright (c) 2013 by Delphix. All rights reserved.
  27  */
  28 /* Copyright (c) 1990 Mentat Inc. */
  29 
  30 #include <sys/types.h>
  31 #include <sys/stream.h>
  32 #include <sys/strsun.h>
  33 #include <sys/strsubr.h>
  34 #include <sys/stropts.h>
  35 #include <sys/strlog.h>
  36 #define _SUN_TPI_VERSION 2
  37 #include <sys/tihdr.h>
  38 #include <sys/timod.h>
  39 #include <sys/ddi.h>
  40 #include <sys/sunddi.h>
  41 #include <sys/suntpi.h>
  42 #include <sys/xti_inet.h>
  43 #include <sys/cmn_err.h>
  44 #include <sys/debug.h>
  45 #include <sys/sdt.h>
  46 #include <sys/vtrace.h>


 216  * only exception is tcp_xmit_listeners_reset() which is called
 217  * directly from IP and needs to policy check to see if TH_RST
 218  * can be sent out.
 219  */
 220 
 221 /*
 222  * Values for squeue switch:
 223  * 1: SQ_NODRAIN
 224  * 2: SQ_PROCESS
 225  * 3: SQ_FILL
 226  */
 227 int tcp_squeue_wput = 2;        /* /etc/systems */
 228 int tcp_squeue_flag;
 229 
 230 /*
 231  * To prevent memory hog, limit the number of entries in tcp_free_list
 232  * to 1% of available memory / number of cpus
 233  */
 234 uint_t tcp_free_list_max_cnt = 0;
 235 





 236 #define TIDUSZ  4096    /* transport interface data unit size */
 237 
 238 /*
 239  * Size of acceptor hash list.  It has to be a power of 2 for hashing.
 240  */
 241 #define TCP_ACCEPTOR_FANOUT_SIZE                512
 242 
 243 #ifdef  _ILP32
 244 #define TCP_ACCEPTOR_HASH(accid)                                        \
 245                 (((uint_t)(accid) >> 8) & (TCP_ACCEPTOR_FANOUT_SIZE - 1))
 246 #else
 247 #define TCP_ACCEPTOR_HASH(accid)                                        \
 248                 ((uint_t)(accid) & (TCP_ACCEPTOR_FANOUT_SIZE - 1))
 249 #endif  /* _ILP32 */
 250 
 251 /*
 252  * Minimum number of connections which can be created per listener.  Used
 253  * when the listener connection count is in effect.
 254  */
 255 static uint32_t tcp_min_conn_listener = 2;


2697         connp->conn_ixa->ixa_zoneid = zoneid;
2698         connp->conn_mlp_type = mlptSingle;
2699         ASSERT(connp->conn_netstack == tcps->tcps_netstack);
2700         ASSERT(tcp->tcp_tcps == tcps);
2701 
2702         /*
2703          * If the caller has the process-wide flag set, then default to MAC
2704          * exempt mode.  This allows read-down to unlabeled hosts.
2705          */
2706         if (getpflags(NET_MAC_AWARE, credp) != 0)
2707                 connp->conn_mac_mode = CONN_MAC_AWARE;
2708 
2709         connp->conn_zone_is_global = (crgetzoneid(credp) == GLOBAL_ZONEID);
2710 
2711         if (issocket) {
2712                 tcp->tcp_issocket = 1;
2713         }
2714 
2715         connp->conn_rcvbuf = tcps->tcps_recv_hiwat;
2716         connp->conn_sndbuf = tcps->tcps_xmit_hiwat;
2717         if (tcps->tcps_snd_lowat_fraction != 0) {
2718                 connp->conn_sndlowat = connp->conn_sndbuf /
2719                     tcps->tcps_snd_lowat_fraction;
2720         } else {
2721                 connp->conn_sndlowat = tcps->tcps_xmit_lowat;
2722         }
2723         connp->conn_so_type = SOCK_STREAM;
2724         connp->conn_wroff = connp->conn_ht_iphc_allocated +
2725             tcps->tcps_wroff_xtra;
2726 
2727         SOCK_CONNID_INIT(tcp->tcp_connid);
2728         /* DTrace ignores this - it isn't a tcp:::state-change */
2729         tcp->tcp_state = TCPS_IDLE;
2730         tcp_init_values(tcp, NULL);
2731         return (connp);
2732 }
2733 
2734 static int
2735 tcp_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp,
2736     boolean_t isv6)
2737 {
2738         tcp_t           *tcp = NULL;
2739         conn_t          *connp = NULL;
2740         int             err;
2741         vmem_t          *minor_arena = NULL;
2742         dev_t           conn_dev;