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

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

net_sched: act: fetch hinfo from a->ops->hinfo



Every action ops has a pointer to hash info, so we don't need to
hard-code it in each module.

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 75e4364f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -103,10 +103,10 @@ int tcf_hash_release(struct tcf_common *p, int bind,
		     struct tcf_hashinfo *hinfo);
u32 tcf_hash_new_index(struct tcf_hashinfo *hinfo);
struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a,
				  int bind, struct tcf_hashinfo *hinfo);
				  int bind);
struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
				   struct tc_action *a, int size,
				   int bind, struct tcf_hashinfo *hinfo);
				   int bind);
void tcf_hash_insert(struct tcf_common *p, struct tcf_hashinfo *hinfo);

int tcf_register_action(struct tc_action_ops *a);
+11 −12
Original line number Diff line number Diff line
@@ -62,8 +62,9 @@ int tcf_hash_release(struct tcf_common *p, int bind,
EXPORT_SYMBOL(tcf_hash_release);

static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
			   struct tc_action *a, struct tcf_hashinfo *hinfo)
			   struct tc_action *a)
{
	struct tcf_hashinfo *hinfo = a->ops->hinfo;
	struct hlist_head *head;
	struct tcf_common *p;
	int err = 0, index = -1, i = 0, s_i = 0, n_i = 0;
@@ -109,9 +110,9 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
	goto done;
}

static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
			  struct tcf_hashinfo *hinfo)
static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a)
{
	struct tcf_hashinfo *hinfo = a->ops->hinfo;
	struct hlist_head *head;
	struct hlist_node *n;
	struct tcf_common *p;
@@ -145,12 +146,10 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
static int tcf_generic_walker(struct sk_buff *skb, struct netlink_callback *cb,
			      int type, struct tc_action *a)
{
	struct tcf_hashinfo *hinfo = a->ops->hinfo;

	if (type == RTM_DELACTION) {
		return tcf_del_walker(skb, a, hinfo);
		return tcf_del_walker(skb, a);
	} else if (type == RTM_GETACTION) {
		return tcf_dump_walker(skb, cb, a, hinfo);
		return tcf_dump_walker(skb, cb, a);
	} else {
		WARN(1, "tcf_generic_walker: unknown action %d\n", type);
		return -EINVAL;
@@ -199,9 +198,9 @@ static int tcf_hash_search(struct tc_action *a, u32 index)
	return 0;
}

struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind,
				  struct tcf_hashinfo *hinfo)
struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind)
{
	struct tcf_hashinfo *hinfo = a->ops->hinfo;
	struct tcf_common *p = NULL;
	if (index && (p = tcf_hash_lookup(index, hinfo)) != NULL) {
		if (bind)
@@ -214,9 +213,9 @@ struct tcf_common *tcf_hash_check(u32 index, struct tc_action *a, int bind,
EXPORT_SYMBOL(tcf_hash_check);

struct tcf_common *tcf_hash_create(u32 index, struct nlattr *est,
				   struct tc_action *a, int size, int bind,
				   struct tcf_hashinfo *hinfo)
				   struct tc_action *a, int size, int bind)
{
	struct tcf_hashinfo *hinfo = a->ops->hinfo;
	struct tcf_common *p = kzalloc(size, GFP_KERNEL);

	if (unlikely(!p))
@@ -495,6 +494,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla,
	if (a == NULL)
		goto err_mod;

	a->ops = a_o;
	INIT_LIST_HEAD(&a->list);
	/* backward compatibility for policer */
	if (name == NULL)
@@ -510,7 +510,6 @@ struct tc_action *tcf_action_init_1(struct net *net, struct nlattr *nla,
	 */
	if (err != ACT_P_CREATED)
		module_put(a_o->owner);
	a->ops = a_o;

	return a;

+4 −5
Original line number Diff line number Diff line
@@ -63,17 +63,16 @@ static int tcf_csum_init(struct net *n, struct nlattr *nla, struct nlattr *est,
		return -EINVAL;
	parm = nla_data(tb[TCA_CSUM_PARMS]);

	pc = tcf_hash_check(parm->index, a, bind, &csum_hash_info);
	pc = tcf_hash_check(parm->index, a, bind);
	if (!pc) {
		pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind,
				     &csum_hash_info);
		pc = tcf_hash_create(parm->index, est, a, sizeof(*p), bind);
		if (IS_ERR(pc))
			return PTR_ERR(pc);
		ret = ACT_P_CREATED;
	} else {
		if (bind)/* dont override defaults */
			return 0;
		tcf_hash_release(pc, bind, &csum_hash_info);
		tcf_hash_release(pc, bind, a->ops->hinfo);
		if (!ovr)
			return -EEXIST;
	}
@@ -85,7 +84,7 @@ static int tcf_csum_init(struct net *n, struct nlattr *nla, struct nlattr *est,
	spin_unlock_bh(&p->tcf_lock);

	if (ret == ACT_P_CREATED)
		tcf_hash_insert(pc, &csum_hash_info);
		tcf_hash_insert(pc, a->ops->hinfo);

	return ret;
}
+5 −6
Original line number Diff line number Diff line
@@ -86,17 +86,16 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
	}
#endif

	pc = tcf_hash_check(parm->index, a, bind, &gact_hash_info);
	pc = tcf_hash_check(parm->index, a, bind);
	if (!pc) {
		pc = tcf_hash_create(parm->index, est, a, sizeof(*gact),
				     bind, &gact_hash_info);
		pc = tcf_hash_create(parm->index, est, a, sizeof(*gact), bind);
		if (IS_ERR(pc))
			return PTR_ERR(pc);
		ret = ACT_P_CREATED;
	} else {
		if (bind)/* dont override defaults */
			return 0;
		tcf_hash_release(pc, bind, &gact_hash_info);
		tcf_hash_release(pc, bind, a->ops->hinfo);
		if (!ovr)
			return -EEXIST;
	}
@@ -114,7 +113,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
#endif
	spin_unlock_bh(&gact->tcf_lock);
	if (ret == ACT_P_CREATED)
		tcf_hash_insert(pc, &gact_hash_info);
		tcf_hash_insert(pc, a->ops->hinfo);
	return ret;
}

@@ -123,7 +122,7 @@ static int tcf_gact_cleanup(struct tc_action *a, int bind)
	struct tcf_gact *gact = a->priv;

	if (gact)
		return tcf_hash_release(&gact->common, bind, &gact_hash_info);
		return tcf_hash_release(&gact->common, bind, a->ops->hinfo);
	return 0;
}

+3 −4
Original line number Diff line number Diff line
@@ -125,10 +125,9 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est,
	if (tb[TCA_IPT_INDEX] != NULL)
		index = nla_get_u32(tb[TCA_IPT_INDEX]);

	pc = tcf_hash_check(index, a, bind, &ipt_hash_info);
	pc = tcf_hash_check(index, a, bind);
	if (!pc) {
		pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind,
				     &ipt_hash_info);
		pc = tcf_hash_create(index, est, a, sizeof(*ipt), bind);
		if (IS_ERR(pc))
			return PTR_ERR(pc);
		ret = ACT_P_CREATED;
@@ -171,7 +170,7 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, struct nlattr *est,
	ipt->tcfi_hook  = hook;
	spin_unlock_bh(&ipt->tcf_lock);
	if (ret == ACT_P_CREATED)
		tcf_hash_insert(pc, &ipt_hash_info);
		tcf_hash_insert(pc, a->ops->hinfo);
	return ret;

err3:
Loading