コード例 #1
0
/*
 *	register an ipvs protocols netns related data
 */
static int
register_ip_vs_proto_netns(struct netns_ipvs *ipvs, struct ip_vs_protocol *pp)
{
    unsigned int hash = IP_VS_PROTO_HASH(pp->protocol);
    struct ip_vs_proto_data *pd =
        kzalloc(sizeof(struct ip_vs_proto_data), GFP_KERNEL);

    if (!pd)
        return -ENOMEM;

    pd->pp = pp;	/* For speed issues */
    pd->next = ipvs->proto_data_table[hash];
    ipvs->proto_data_table[hash] = pd;
    atomic_set(&pd->appcnt, 0);	/* Init app counter */

    if (pp->init_netns != NULL) {
        int ret = pp->init_netns(ipvs, pd);
        if (ret) {
            /* unlink an free proto data */
            ipvs->proto_data_table[hash] = pd->next;
            kfree(pd);
            return ret;
        }
    }

    return 0;
}
コード例 #2
0
/*
 *	register an ipvs protocol
 */
static int __used __init register_ip_vs_protocol(struct ip_vs_protocol *pp)
{
    unsigned int hash = IP_VS_PROTO_HASH(pp->protocol);

    pp->next = ip_vs_proto_table[hash];
    ip_vs_proto_table[hash] = pp;

    if (pp->init != NULL)
        pp->init(pp);

    return 0;
}
コード例 #3
0
/*
 *	get ip_vs_protocol object by its proto.
 */
struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto)
{
    struct ip_vs_protocol *pp;
    unsigned int hash = IP_VS_PROTO_HASH(proto);

    for (pp = ip_vs_proto_table[hash]; pp; pp = pp->next) {
        if (pp->protocol == proto)
            return pp;
    }

    return NULL;
}
コード例 #4
0
/*
 *	get ip_vs_protocol object data by netns and proto
 */
struct ip_vs_proto_data *
ip_vs_proto_data_get(struct netns_ipvs *ipvs, unsigned short proto)
{
    struct ip_vs_proto_data *pd;
    unsigned int hash = IP_VS_PROTO_HASH(proto);

    for (pd = ipvs->proto_data_table[hash]; pd; pd = pd->next) {
        if (pd->pp->protocol == proto)
            return pd;
    }

    return NULL;
}
コード例 #5
0
/*
 *	unregister an ipvs protocol
 */
static int unregister_ip_vs_protocol(struct ip_vs_protocol *pp)
{
    struct ip_vs_protocol **pp_p;
    unsigned int hash = IP_VS_PROTO_HASH(pp->protocol);

    pp_p = &ip_vs_proto_table[hash];
    for (; *pp_p; pp_p = &(*pp_p)->next) {
        if (*pp_p == pp) {
            *pp_p = pp->next;
            if (pp->exit != NULL)
                pp->exit(pp);
            return 0;
        }
    }

    return -ESRCH;
}
コード例 #6
0
/*
 *	unregister an ipvs protocols netns data
 */
static int
unregister_ip_vs_proto_netns(struct netns_ipvs *ipvs, struct ip_vs_proto_data *pd)
{
    struct ip_vs_proto_data **pd_p;
    unsigned int hash = IP_VS_PROTO_HASH(pd->pp->protocol);

    pd_p = &ipvs->proto_data_table[hash];
    for (; *pd_p; pd_p = &(*pd_p)->next) {
        if (*pd_p == pd) {
            *pd_p = pd->next;
            if (pd->pp->exit_netns != NULL)
                pd->pp->exit_netns(ipvs, pd);
            kfree(pd);
            return 0;
        }
    }

    return -ESRCH;
}
コード例 #7
0
ファイル: ip_vs_proto.c プロジェクト: AbheekG/XIA-for-Linux
/*
 *	register an ipvs protocols netns related data
 */
static int
register_ip_vs_proto_netns(struct net *net, struct ip_vs_protocol *pp)
{
	struct netns_ipvs *ipvs = net_ipvs(net);
	unsigned hash = IP_VS_PROTO_HASH(pp->protocol);
	struct ip_vs_proto_data *pd =
			kzalloc(sizeof(struct ip_vs_proto_data), GFP_ATOMIC);

	if (!pd) {
		pr_err("%s(): no memory.\n", __func__);
		return -ENOMEM;
	}
	pd->pp = pp;	/* For speed issues */
	pd->next = ipvs->proto_data_table[hash];
	ipvs->proto_data_table[hash] = pd;
	atomic_set(&pd->appcnt, 0);	/* Init app counter */

	if (pp->init_netns != NULL)
		pp->init_netns(net, pd);

	return 0;
}