xref: /titanic_52/usr/src/uts/common/inet/ilb/ilb_stack.h (revision 68c47f65208790c466e5e484f2293d3baed71c6a)
1 /*
2  * CDDL HEADER START
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _INET_ILB_STACK_H
28 #define	_INET_ILB_STACK_H
29 
30 #include <sys/netstack.h>
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 struct ilb_rule_s;
37 struct ilb_hash_s;
38 struct ilb_timer_s;
39 struct ilb_conn_s;
40 struct ilb_conn_hash_s;
41 struct ilb_sticky_s;
42 struct ilb_sticky_hash_s;
43 struct ilb_g_kstat_s;
44 struct ilb_nat_src_hash_s;
45 
46 /* Per network stack ILB information */
47 typedef struct ilb_stack {
48 	netstack_t			*ilbs_netstack;
49 
50 	/*
51 	 * Rule info in a network stack.
52 	 *
53 	 * ilbs_rule_head: list of all rules
54 	 * ilbs_g_lock: lock to protect the rule list
55 	 * ilbs_rule_hash_size: size of the rule hash table
56 	 * ilbs_g_hash: the rule hash table
57 	 * ilbs_rule_taskq: taskq for rule related delayed processing
58 	 */
59 	struct ilb_rule_s		*ilbs_rule_head;
60 	kmutex_t			ilbs_g_lock;
61 	size_t				ilbs_rule_hash_size;
62 	struct ilb_hash_s		*ilbs_g_hash;
63 	taskq_t				*ilbs_rule_taskq;
64 
65 	/*
66 	 * NAT connection cache info
67 	 *
68 	 * ilbs_conn_hash_szie: size of the conn cache hash table
69 	 * ilbs_c2s_conn_hash: client to server conn cache hash table
70 	 * ilbs_s2c_conn_hash: server to client conn cache hash table
71 	 * ilbs_conn_timer_list: list of all timers for handling conn cache
72 	 * ilbs_conn_taskq: taskq for conn cache related delayed processing
73 	 */
74 	size_t				ilbs_conn_hash_size;
75 	struct ilb_conn_hash_s		*ilbs_c2s_conn_hash;
76 	struct ilb_conn_hash_s		*ilbs_s2c_conn_hash;
77 	struct ilb_timer_s		*ilbs_conn_timer_list;
78 	taskq_t				*ilbs_conn_taskq;
79 
80 	/*
81 	 * Sticky (persistent) cache info
82 	 *
83 	 * ilbs_sticky_hash_szie: size of the sticky cache hash table
84 	 * ilbs_sticky_hash: sticky cache hash table
85 	 * ilbs_sticky_timer_list: list of all timers for handling sticky cache
86 	 * ilbs_sticky_taskq: taskq for sticky cache related delayed processing
87 	 */
88 	size_t				ilbs_sticky_hash_size;
89 	struct ilb_sticky_hash_s	*ilbs_sticky_hash;
90 	struct ilb_timer_s		*ilbs_sticky_timer_list;
91 	taskq_t				*ilbs_sticky_taskq;
92 
93 	/*
94 	 * Info of NAT source address for
95 	 *
96 	 * ilbs_nat_src: NAT source hash table
97 	 * ilbs_nat_src_hash_size: size of the NAT source hash table
98 	 * ilbs_nat_src_lock: lock for protecting ilbs_nat_src_tid
99 	 * ilbs_nat_src_tid: ID of the timer handling garbage colllection
100 	 */
101 	struct ilb_nat_src_hash_s	*ilbs_nat_src;
102 	size_t				ilbs_nat_src_hash_size;
103 	kmutex_t			ilbs_nat_src_lock;
104 	timeout_id_t			ilbs_nat_src_tid;
105 
106 	/* NAT conn cache and sticky cache listing related info */
107 
108 	/* Lock to ensure that all nat listing ops are serialized */
109 	kmutex_t			ilbs_conn_list_lock;
110 	kcondvar_t			ilbs_conn_list_cv;
111 	boolean_t			ilbs_conn_list_busy;
112 	/* Current position for	listing all conn hash entries */
113 	size_t				ilbs_conn_list_cur;
114 	struct ilb_conn_s		*ilbs_conn_list_connp;
115 
116 	/* Lock to ensure that all sticky listing ops are serialized */
117 	kmutex_t			ilbs_sticky_list_lock;
118 	kcondvar_t			ilbs_sticky_list_cv;
119 	boolean_t			ilbs_sticky_list_busy;
120 	/* Current position for	listing all sticky hash entries */
121 	size_t				ilbs_sticky_list_cur;
122 	struct ilb_sticky_s		*ilbs_sticky_list_curp;
123 
124 	/* Stack wide ILB kstat */
125 	kstat_t				*ilbs_ksp;
126 	struct ilb_g_kstat_s		*ilbs_kstat;
127 } ilb_stack_t;
128 
129 
130 #ifdef __cplusplus
131 }
132 #endif
133 
134 #endif /* _INET_ILB_STACK_H */
135