/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "ilb_impl.h"
#include "ilb_alg.h"
{ \
}
{ \
}
{ \
}
(size))
typedef struct {
/*
* There are two hash tables. The hash_tbl holds all servers, both enabled
* and disabled. The hash_enabled_tbl only holds enabled servers. Having
* two tables allows the hash on a client request remains the same even when
* some servers are disabled. If a server is disabled and a client's request
* hashes to it, we will do another hash. This time the has is on the enabled
* server table.
*/
typedef struct hash_s {
} hash_t;
static void hash_fini(ilb_alg_data_t **);
/* ARGSUSED */
static boolean_t
{
uint32_t i;
*ret_server = NULL;
if (hash_alg->hash_servers == 0) {
return (B_FALSE);
}
case ILB_ALG_IMPL_HASH_IP:
break;
break;
case ILB_ALG_IMPL_HASH_IP_VIP:
break;
default:
return (B_FALSE);
}
return (B_TRUE);
}
if (hash_alg->hash_enabled_servers == 0) {
return (B_FALSE);
}
case ILB_ALG_IMPL_HASH_IP:
break;
break;
case ILB_ALG_IMPL_HASH_IP_VIP:
break;
default:
ASSERT(0);
break;
}
return (B_TRUE);
}
static boolean_t
{
size_t i, j;
for (i = 0; i < hash_size; i++) {
if (i == hash_size - 1)
break;
for (j = i; j < hash_size - 1; j++)
break;
}
}
/* Not found... */
if (i == hash_size)
return (B_FALSE);
return (B_TRUE);
}
static int
{
if (!ret) {
return (EINVAL);
}
hash_alg->hash_servers--;
/* The server may not be enabled. */
if (ret)
return (0);
}
static int
{
return (ENOMEM);
}
return (0);
}
static int
{
/* First add the server to the hash_tbl. */
0) {
return (ENOMEM);
}
}
hash_alg->hash_servers++;
if (!host->iser_enabled) {
return (0);
}
/* If the server is enabled, add it to the hasn_enabled_tbl. */
&hash_alg->hash_enabled_tbl_size) != 0) {
return (ENOMEM);
}
}
host;
return (0);
}
static int
{
for (i = 0; i < alg->hash_servers; i++) {
return (0);
} else {
break;
}
}
}
if (i == alg->hash_servers) {
return (EINVAL);
}
#if DEBUG
/* The server should not be in the enabled tabled. */
{
size_t j;
for (j = 0; j < alg->hash_enabled_servers; j++) {
"table");
}
}
}
#endif
&alg->hash_enabled_tbl_size) != 0) {
return (ENOMEM);
}
}
return (0);
}
static int
{
size_t i;
for (i = 0; i < alg->hash_servers; i++) {
return (0);
} else {
break;
}
}
}
if (i == alg->hash_servers) {
return (EINVAL);
}
#if DEBUG
host));
#else
host);
#endif
return (0);
}
/* ARGSUSED */
{
return (NULL);
return (NULL);
}
/* Table of all servers */
hash_alg->hash_servers = 0;
return (NULL);
}
/* Table of only enabled servers */
hash_alg->hash_enabled_servers = 0;
sizeof (ilb_server_t *));
return (NULL);
}
return (alg);
}
static void
{
int i;
for (i = 0; i < hash_alg->hash_servers; i++)
}