Lines Matching refs:hash_alg

98 	hash_t *hash_alg = (hash_t *)alg_data;  in hash_lb()  local
104 mutex_enter(&hash_alg->hash_lock); in hash_lb()
106 if (hash_alg->hash_servers == 0) { in hash_lb()
107 mutex_exit(&hash_alg->hash_lock); in hash_lb()
111 switch (hash_alg->hash_type) { in hash_lb()
113 HASH_IP_V6(i, saddr, hash_alg->hash_servers); in hash_lb()
116 HASH_IP_PORT_V6(i, saddr, sport, hash_alg->hash_servers); in hash_lb()
119 HASH_IP_VIP_V6(i, saddr, daddr, hash_alg->hash_servers); in hash_lb()
122 mutex_exit(&hash_alg->hash_lock); in hash_lb()
125 if (hash_alg->hash_tbl[i].enabled) { in hash_lb()
126 *ret_server = hash_alg->hash_tbl[i].server; in hash_lb()
127 mutex_exit(&hash_alg->hash_lock); in hash_lb()
131 if (hash_alg->hash_enabled_servers == 0) { in hash_lb()
132 mutex_exit(&hash_alg->hash_lock); in hash_lb()
136 switch (hash_alg->hash_type) { in hash_lb()
138 HASH_IP_V6(i, saddr, hash_alg->hash_enabled_servers); in hash_lb()
142 hash_alg->hash_enabled_servers); in hash_lb()
146 hash_alg->hash_enabled_servers); in hash_lb()
152 *ret_server = hash_alg->hash_enabled_tbl[i].server; in hash_lb()
153 mutex_exit(&hash_alg->hash_lock); in hash_lb()
182 hash_t *hash_alg = (hash_t *)alg_data; in hash_server_del() local
185 mutex_enter(&hash_alg->hash_lock); in hash_server_del()
187 ret = del_server(hash_alg->hash_tbl, hash_alg->hash_servers, host); in hash_server_del()
189 mutex_exit(&hash_alg->hash_lock); in hash_server_del()
192 hash_alg->hash_servers--; in hash_server_del()
195 ret = del_server(hash_alg->hash_enabled_tbl, in hash_server_del()
196 hash_alg->hash_enabled_servers, host); in hash_server_del()
198 hash_alg->hash_enabled_servers--; in hash_server_del()
200 mutex_exit(&hash_alg->hash_lock); in hash_server_del()
226 hash_t *hash_alg = (hash_t *)alg_data; in hash_server_add() local
229 mutex_enter(&hash_alg->hash_lock); in hash_server_add()
232 new_size = hash_alg->hash_servers + 1; in hash_server_add()
233 if (new_size > hash_alg->hash_tbl_size) { in hash_server_add()
234 if (grow_tbl(&hash_alg->hash_tbl, &hash_alg->hash_tbl_size) != in hash_server_add()
236 mutex_exit(&hash_alg->hash_lock); in hash_server_add()
241 hash_alg->hash_tbl[hash_alg->hash_servers].server = host; in hash_server_add()
242 hash_alg->hash_tbl[hash_alg->hash_servers].enabled = host->iser_enabled; in hash_server_add()
243 hash_alg->hash_servers++; in hash_server_add()
246 mutex_exit(&hash_alg->hash_lock); in hash_server_add()
252 new_size = hash_alg->hash_enabled_servers + 1; in hash_server_add()
253 if (new_size > hash_alg->hash_enabled_tbl_size) { in hash_server_add()
254 if (grow_tbl(&hash_alg->hash_enabled_tbl, in hash_server_add()
255 &hash_alg->hash_enabled_tbl_size) != 0) { in hash_server_add()
256 mutex_exit(&hash_alg->hash_lock); in hash_server_add()
260 hash_alg->hash_enabled_tbl[hash_alg->hash_enabled_servers].server = in hash_server_add()
262 hash_alg->hash_enabled_tbl[hash_alg->hash_enabled_servers].enabled = in hash_server_add()
264 hash_alg->hash_enabled_servers++; in hash_server_add()
266 mutex_exit(&hash_alg->hash_lock); in hash_server_add()
367 hash_t *hash_alg; in ilb_alg_hash_init() local
372 if ((hash_alg = kmem_alloc(sizeof (hash_t), KM_NOSLEEP)) == NULL) { in ilb_alg_hash_init()
382 alg->ilb_alg_data = hash_alg; in ilb_alg_hash_init()
384 mutex_init(&hash_alg->hash_lock, NULL, MUTEX_DEFAULT, NULL); in ilb_alg_hash_init()
385 hash_alg->hash_type = flags; in ilb_alg_hash_init()
388 hash_alg->hash_servers = 0; in ilb_alg_hash_init()
389 hash_alg->hash_tbl_size = INIT_HASH_TBL_SIZE; in ilb_alg_hash_init()
390 hash_alg->hash_tbl = kmem_zalloc(sizeof (hash_server_t) * in ilb_alg_hash_init()
392 if (hash_alg->hash_tbl == NULL) { in ilb_alg_hash_init()
393 kmem_free(hash_alg, sizeof (hash_t)); in ilb_alg_hash_init()
399 hash_alg->hash_enabled_servers = 0; in ilb_alg_hash_init()
400 hash_alg->hash_enabled_tbl_size = INIT_HASH_TBL_SIZE; in ilb_alg_hash_init()
401 hash_alg->hash_enabled_tbl = kmem_zalloc(sizeof (hash_server_t) * in ilb_alg_hash_init()
403 if (hash_alg->hash_tbl == NULL) { in ilb_alg_hash_init()
404 kmem_free(hash_alg->hash_tbl, INIT_HASH_TBL_SIZE * in ilb_alg_hash_init()
406 kmem_free(hash_alg, sizeof (hash_t)); in ilb_alg_hash_init()
417 hash_t *hash_alg; in hash_fini() local
420 hash_alg = (*alg)->ilb_alg_data; in hash_fini()
421 for (i = 0; i < hash_alg->hash_servers; i++) in hash_fini()
422 ILB_SERVER_REFRELE(hash_alg->hash_tbl[i].server); in hash_fini()
424 kmem_free(hash_alg->hash_tbl, sizeof (hash_server_t) * in hash_fini()
425 hash_alg->hash_tbl_size); in hash_fini()
426 kmem_free(hash_alg->hash_enabled_tbl, sizeof (hash_server_t) * in hash_fini()
427 hash_alg->hash_enabled_tbl_size); in hash_fini()
428 kmem_free(hash_alg, sizeof (hash_t)); in hash_fini()