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>


   3  *
   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  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright (c) 2011, Joyent, Inc. All rights reserved.
  24  * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright (c) 2014 by Delphix. All rights reserved.
  26  */
  27 /* Copyright (c) 1990 Mentat Inc. */
  28 
  29 #ifndef _INET_TCP_H
  30 #define _INET_TCP_H
  31 
  32 #ifdef  __cplusplus
  33 extern "C" {
  34 #endif
  35 
  36 #include <sys/inttypes.h>
  37 #include <netinet/ip6.h>
  38 #include <netinet/tcp.h>
  39 #include <sys/socket.h>
  40 #include <sys/socket_proto.h>
  41 #include <sys/md5.h>
  42 #include <inet/common.h>
  43 #include <inet/ip.h>


 117 
 118 #define TCPIP_HDR_LENGTH(mp, n)                                 \
 119         (n) = IPH_HDR_LENGTH((mp)->b_rptr),                  \
 120         (n) += TCP_HDR_LENGTH((tcpha_t *)&(mp)->b_rptr[(n)])
 121 
 122 /* TCP Protocol header (used if the header is known to be 32-bit aligned) */
 123 typedef struct tcphdra_s {
 124         in_port_t       tha_lport;      /* Source port */
 125         in_port_t       tha_fport;      /* Destination port */
 126         uint32_t        tha_seq;        /* Sequence number */
 127         uint32_t        tha_ack;        /* Acknowledgement number */
 128         uint8_t tha_offset_and_reserved; /* Offset to the packet data */
 129         uint8_t         tha_flags;
 130         uint16_t        tha_win;        /* Allocation number */
 131         uint16_t        tha_sum;        /* TCP checksum */
 132         uint16_t        tha_urp;        /* Urgent pointer */
 133 } tcpha_t;
 134 
 135 struct conn_s;
 136 struct tcp_listen_cnt_s;

 137 
 138 /*
 139  * Control structure for each open TCP stream,
 140  * defined only within the kernel or for a kmem user.
 141  * NOTE: tcp_reinit_values MUST have a line for each field in this structure!
 142  */
 143 #if (defined(_KERNEL) || defined(_KMEMUSER))
 144 
 145 typedef struct tcp_s {
 146         struct tcp_s    *tcp_time_wait_next;
 147                                 /* Pointer to next T/W block */
 148         struct tcp_s    *tcp_time_wait_prev;
 149                                 /* Pointer to previous T/W next */
 150         int64_t         tcp_time_wait_expire;
 151 
 152         struct conn_s   *tcp_connp;     /* back pointer to conn_t */
 153         tcp_stack_t     *tcp_tcps;      /* back pointer to tcp_stack_t */
 154 
 155         int32_t tcp_state;
 156         int32_t tcp_rcv_ws;             /* My window scale power */


 387         uint_t          tcp_hopoptslen;
 388         uint_t          tcp_dstoptslen;
 389         uint_t          tcp_rthdrdstoptslen;
 390         uint_t          tcp_rthdrlen;
 391 
 392         mblk_t          *tcp_timercache;
 393 
 394         kmutex_t        tcp_closelock;
 395         kcondvar_t      tcp_closecv;
 396         uint8_t         tcp_closed;
 397         uint8_t         tcp_closeflags;
 398         mblk_t          tcp_closemp;
 399         timeout_id_t    tcp_linger_tid; /* Linger timer ID */
 400 
 401         struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */
 402         struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */
 403         struct tcp_s *tcp_bind_hash; /* Bind hash chain */
 404         struct tcp_s *tcp_bind_hash_port; /* tcp_t's bound to the same lport */
 405         struct tcp_s **tcp_ptpbhn;
 406 







 407         uint_t          tcp_maxpsz_multiplier;
 408 
 409         uint32_t        tcp_lso_max; /* maximum LSO payload */
 410 
 411         uint32_t        tcp_ofo_fin_seq; /* Recv out of order FIN seq num */
 412         uint32_t        tcp_cwr_snd_max;
 413 
 414         struct tcp_s *tcp_saved_listener;       /* saved value of listener */
 415 
 416         uint32_t        tcp_in_ack_unsent;      /* ACK for unsent data cnt. */
 417 
 418         /*
 419          * All fusion-related fields are protected by squeue.
 420          */
 421         struct tcp_s *tcp_loopback_peer;        /* peer tcp for loopback */
 422         mblk_t  *tcp_fused_sigurg_mp;           /* M_PCSIG mblk for SIGURG */
 423 
 424         uint32_t
 425                 tcp_fused : 1,          /* loopback tcp in fusion mode */
 426                 tcp_unfusable : 1,      /* fusion not allowed on endpoint */




   3  *
   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  * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2015 Joyent, Inc.
  24  * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
  25  * Copyright (c) 2014 by Delphix. All rights reserved.
  26  */
  27 /* Copyright (c) 1990 Mentat Inc. */
  28 
  29 #ifndef _INET_TCP_H
  30 #define _INET_TCP_H
  31 
  32 #ifdef  __cplusplus
  33 extern "C" {
  34 #endif
  35 
  36 #include <sys/inttypes.h>
  37 #include <netinet/ip6.h>
  38 #include <netinet/tcp.h>
  39 #include <sys/socket.h>
  40 #include <sys/socket_proto.h>
  41 #include <sys/md5.h>
  42 #include <inet/common.h>
  43 #include <inet/ip.h>


 117 
 118 #define TCPIP_HDR_LENGTH(mp, n)                                 \
 119         (n) = IPH_HDR_LENGTH((mp)->b_rptr),                  \
 120         (n) += TCP_HDR_LENGTH((tcpha_t *)&(mp)->b_rptr[(n)])
 121 
 122 /* TCP Protocol header (used if the header is known to be 32-bit aligned) */
 123 typedef struct tcphdra_s {
 124         in_port_t       tha_lport;      /* Source port */
 125         in_port_t       tha_fport;      /* Destination port */
 126         uint32_t        tha_seq;        /* Sequence number */
 127         uint32_t        tha_ack;        /* Acknowledgement number */
 128         uint8_t tha_offset_and_reserved; /* Offset to the packet data */
 129         uint8_t         tha_flags;
 130         uint16_t        tha_win;        /* Allocation number */
 131         uint16_t        tha_sum;        /* TCP checksum */
 132         uint16_t        tha_urp;        /* Urgent pointer */
 133 } tcpha_t;
 134 
 135 struct conn_s;
 136 struct tcp_listen_cnt_s;
 137 struct tcp_rg_s;
 138 
 139 /*
 140  * Control structure for each open TCP stream,
 141  * defined only within the kernel or for a kmem user.
 142  * NOTE: tcp_reinit_values MUST have a line for each field in this structure!
 143  */
 144 #if (defined(_KERNEL) || defined(_KMEMUSER))
 145 
 146 typedef struct tcp_s {
 147         struct tcp_s    *tcp_time_wait_next;
 148                                 /* Pointer to next T/W block */
 149         struct tcp_s    *tcp_time_wait_prev;
 150                                 /* Pointer to previous T/W next */
 151         int64_t         tcp_time_wait_expire;
 152 
 153         struct conn_s   *tcp_connp;     /* back pointer to conn_t */
 154         tcp_stack_t     *tcp_tcps;      /* back pointer to tcp_stack_t */
 155 
 156         int32_t tcp_state;
 157         int32_t tcp_rcv_ws;             /* My window scale power */


 388         uint_t          tcp_hopoptslen;
 389         uint_t          tcp_dstoptslen;
 390         uint_t          tcp_rthdrdstoptslen;
 391         uint_t          tcp_rthdrlen;
 392 
 393         mblk_t          *tcp_timercache;
 394 
 395         kmutex_t        tcp_closelock;
 396         kcondvar_t      tcp_closecv;
 397         uint8_t         tcp_closed;
 398         uint8_t         tcp_closeflags;
 399         mblk_t          tcp_closemp;
 400         timeout_id_t    tcp_linger_tid; /* Linger timer ID */
 401 
 402         struct tcp_s *tcp_acceptor_hash; /* Acceptor hash chain */
 403         struct tcp_s **tcp_ptpahn; /* Pointer to previous accept hash next. */
 404         struct tcp_s *tcp_bind_hash; /* Bind hash chain */
 405         struct tcp_s *tcp_bind_hash_port; /* tcp_t's bound to the same lport */
 406         struct tcp_s **tcp_ptpbhn;
 407 
 408         /*
 409          * Group of tcp_t entries bound to the same adress and port via
 410          * SO_REUSEPORT.  The pointer itself is protected by tf_lock in the
 411          * containing tcps_bind_fanout slot.
 412          */
 413         struct tcp_rg_s *tcp_rg_bind;
 414 
 415         uint_t          tcp_maxpsz_multiplier;
 416 
 417         uint32_t        tcp_lso_max; /* maximum LSO payload */
 418 
 419         uint32_t        tcp_ofo_fin_seq; /* Recv out of order FIN seq num */
 420         uint32_t        tcp_cwr_snd_max;
 421 
 422         struct tcp_s *tcp_saved_listener;       /* saved value of listener */
 423 
 424         uint32_t        tcp_in_ack_unsent;      /* ACK for unsent data cnt. */
 425 
 426         /*
 427          * All fusion-related fields are protected by squeue.
 428          */
 429         struct tcp_s *tcp_loopback_peer;        /* peer tcp for loopback */
 430         mblk_t  *tcp_fused_sigurg_mp;           /* M_PCSIG mblk for SIGURG */
 431 
 432         uint32_t
 433                 tcp_fused : 1,          /* loopback tcp in fusion mode */
 434                 tcp_unfusable : 1,      /* fusion not allowed on endpoint */