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>

@@ -404,10 +404,26 @@
         uint32_t        tlc_cnt;
         int64_t         tlc_report_time;
         uint32_t        tlc_drop;
 } tcp_listen_cnt_t;
 
+/*
+ * Track tcp_t entities bound to the same port/address tuple via SO_REUSEPORT.
+ * - tcprg_lock:        Protects the other fields
+ * - tcprg_size:        Allocated size (in entries) of tcprg_members array
+ * - tcprg_count:       Count of occupied tcprg_members slots
+ * - tcprg_active:      Count of members which still have SO_REUSEPORT set
+ * - tcprg_members:     Connections associated with address/port group
+ */
+typedef struct tcp_rg_s {
+        kmutex_t        tcprg_lock;
+        unsigned int    tcprg_size;
+        unsigned int    tcprg_count;
+        unsigned int    tcprg_active;
+        tcp_t           **tcprg_members;
+} tcp_rg_t;
+
 #define TCP_TLC_REPORT_INTERVAL (30 * MINUTES)
 
 #define TCP_DECR_LISTEN_CNT(tcp)                                        \
 {                                                                       \
         ASSERT((tcp)->tcp_listen_cnt->tlc_cnt > 0);                     \

@@ -647,10 +663,14 @@
 extern void     tcp_bind_hash_remove(tcp_t *);
 extern in_port_t        tcp_bindi(tcp_t *, in_port_t, const in6_addr_t *,
                             int, boolean_t, boolean_t, boolean_t);
 extern in_port_t        tcp_update_next_port(in_port_t, const tcp_t *,
                             boolean_t);
+extern tcp_rg_t *tcp_rg_init(tcp_t *);
+extern boolean_t tcp_rg_remove(tcp_rg_t *, tcp_t *);
+extern void tcp_rg_destroy(tcp_rg_t *);
+extern void tcp_rg_setactive(tcp_rg_t *, boolean_t);
 
 /*
  * Fusion related functions in tcp_fusion.c.
  */
 extern void     tcp_fuse(tcp_t *, uchar_t *, tcpha_t *);