Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f1e9d89 authored by WANG Cong's avatar WANG Cong Committed by David S. Miller
Browse files

net_sched: act: move tcf_hashinfo_init() into tcf_register_action()



Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a5b5c958
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ int tcf_hash_create(u32 index, struct nlattr *est, struct tc_action *a,
void tcf_hash_cleanup(struct tc_action *a, struct nlattr *est);
void tcf_hash_insert(struct tc_action *a);

int tcf_register_action(struct tc_action_ops *a);
int tcf_register_action(struct tc_action_ops *a, unsigned int mask);
int tcf_unregister_action(struct tc_action_ops *a);
void tcf_action_destroy(struct list_head *actions, int bind);
int tcf_action_exec(struct sk_buff *skb, const struct list_head *actions,
+15 −1
Original line number Diff line number Diff line
@@ -275,9 +275,10 @@ EXPORT_SYMBOL(tcf_hash_insert);
static LIST_HEAD(act_base);
static DEFINE_RWLOCK(act_mod_lock);

int tcf_register_action(struct tc_action_ops *act)
int tcf_register_action(struct tc_action_ops *act, unsigned int mask)
{
	struct tc_action_ops *a;
	int err;

	/* Must supply act, dump and init */
	if (!act->act || !act->dump || !act->init)
@@ -289,10 +290,21 @@ int tcf_register_action(struct tc_action_ops *act)
	if (!act->walk)
		act->walk = tcf_generic_walker;

	act->hinfo = kmalloc(sizeof(struct tcf_hashinfo), GFP_KERNEL);
	if (!act->hinfo)
		return -ENOMEM;
	err = tcf_hashinfo_init(act->hinfo, mask);
	if (err) {
		kfree(act->hinfo);
		return err;
	}

	write_lock(&act_mod_lock);
	list_for_each_entry(a, &act_base, head) {
		if (act->type == a->type || (strcmp(act->kind, a->kind) == 0)) {
			write_unlock(&act_mod_lock);
			tcf_hashinfo_destroy(act->hinfo);
			kfree(act->hinfo);
			return -EEXIST;
		}
	}
@@ -311,6 +323,8 @@ int tcf_unregister_action(struct tc_action_ops *act)
	list_for_each_entry(a, &act_base, head) {
		if (a == act) {
			list_del(&act->head);
			tcf_hashinfo_destroy(act->hinfo);
			kfree(act->hinfo);
			err = 0;
			break;
		}
+1 −7
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@
#include <net/tc_act/tc_csum.h>

#define CSUM_TAB_MASK 15
static struct tcf_hashinfo csum_hash_info;

static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = {
	[TCA_CSUM_PARMS] = { .len = sizeof(struct tc_csum), },
@@ -561,7 +560,6 @@ static int tcf_csum_dump(struct sk_buff *skb,

static struct tc_action_ops act_csum_ops = {
	.kind		= "csum",
	.hinfo		= &csum_hash_info,
	.type		= TCA_ACT_CSUM,
	.owner		= THIS_MODULE,
	.act		= tcf_csum,
@@ -574,11 +572,7 @@ MODULE_LICENSE("GPL");

static int __init csum_init_module(void)
{
	int err = tcf_hashinfo_init(&csum_hash_info, CSUM_TAB_MASK);
	if (err)
		return err;

	return tcf_register_action(&act_csum_ops);
	return tcf_register_action(&act_csum_ops, CSUM_TAB_MASK);
}

static void __exit csum_cleanup_module(void)
+1 −7
Original line number Diff line number Diff line
@@ -24,7 +24,6 @@
#include <net/tc_act/tc_gact.h>

#define GACT_TAB_MASK	15
static struct tcf_hashinfo gact_hash_info;

#ifdef CONFIG_GACT_PROB
static int gact_net_rand(struct tcf_gact *gact)
@@ -180,7 +179,6 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int

static struct tc_action_ops act_gact_ops = {
	.kind		=	"gact",
	.hinfo		=	&gact_hash_info,
	.type		=	TCA_ACT_GACT,
	.owner		=	THIS_MODULE,
	.act		=	tcf_gact,
@@ -194,21 +192,17 @@ MODULE_LICENSE("GPL");

static int __init gact_init_module(void)
{
	int err = tcf_hashinfo_init(&gact_hash_info, GACT_TAB_MASK);
	if (err)
		return err;
#ifdef CONFIG_GACT_PROB
	pr_info("GACT probability on\n");
#else
	pr_info("GACT probability NOT on\n");
#endif
	return tcf_register_action(&act_gact_ops);
	return tcf_register_action(&act_gact_ops, GACT_TAB_MASK);
}

static void __exit gact_cleanup_module(void)
{
	tcf_unregister_action(&act_gact_ops);
	tcf_hashinfo_destroy(&gact_hash_info);
}

module_init(gact_init_module);
+3 −11
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@


#define IPT_TAB_MASK     15
static struct tcf_hashinfo ipt_hash_info;

static int ipt_init_target(struct xt_entry_target *t, char *table, unsigned int hook)
{
@@ -262,7 +261,6 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int

static struct tc_action_ops act_ipt_ops = {
	.kind		=	"ipt",
	.hinfo		=	&ipt_hash_info,
	.type		=	TCA_ACT_IPT,
	.owner		=	THIS_MODULE,
	.act		=	tcf_ipt,
@@ -273,7 +271,6 @@ static struct tc_action_ops act_ipt_ops = {

static struct tc_action_ops act_xt_ops = {
	.kind		=	"xt",
	.hinfo		=	&ipt_hash_info,
	.type		=	TCA_ACT_XT,
	.owner		=	THIS_MODULE,
	.act		=	tcf_ipt,
@@ -289,20 +286,16 @@ MODULE_ALIAS("act_xt");

static int __init ipt_init_module(void)
{
	int ret1, ret2, err;
	err = tcf_hashinfo_init(&ipt_hash_info, IPT_TAB_MASK);
	if (err)
		return err;
	int ret1, ret2;

	ret1 = tcf_register_action(&act_xt_ops);
	ret1 = tcf_register_action(&act_xt_ops, IPT_TAB_MASK);
	if (ret1 < 0)
		printk("Failed to load xt action\n");
	ret2 = tcf_register_action(&act_ipt_ops);
	ret2 = tcf_register_action(&act_ipt_ops, IPT_TAB_MASK);
	if (ret2 < 0)
		printk("Failed to load ipt action\n");

	if (ret1 < 0 && ret2 < 0) {
		tcf_hashinfo_destroy(&ipt_hash_info);
		return ret1;
	} else
		return 0;
@@ -312,7 +305,6 @@ static void __exit ipt_cleanup_module(void)
{
	tcf_unregister_action(&act_xt_ops);
	tcf_unregister_action(&act_ipt_ops);
	tcf_hashinfo_destroy(&ipt_hash_info);
}

module_init(ipt_init_module);
Loading