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

Commit 14215108 authored by Cong Wang's avatar Cong Wang Committed by David S. Miller
Browse files

net_sched: initialize net pointer inside tcf_exts_init()



For tcindex filter, it is too late to initialize the
net pointer in tcf_exts_validate(), as tcf_exts_get_net()
requires a non-NULL net pointer. We can just move its
initialization into tcf_exts_init(), which just requires
an additional parameter.

This makes the code in tcindex_alloc_perfect_hash()
prettier.

Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1a256608
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -289,12 +289,13 @@ struct tcf_exts {
	int police;
};

static inline int tcf_exts_init(struct tcf_exts *exts, int action, int police)
static inline int tcf_exts_init(struct tcf_exts *exts, struct net *net,
				int action, int police)
{
#ifdef CONFIG_NET_CLS_ACT
	exts->type = 0;
	exts->nr_actions = 0;
	exts->net = NULL;
	exts->net = net;
	exts->actions = kcalloc(TCA_ACT_MAX_PRIO, sizeof(struct tc_action *),
				GFP_KERNEL);
	if (!exts->actions)
+0 −1
Original line number Diff line number Diff line
@@ -3051,7 +3051,6 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
				return err;
			exts->nr_actions = err;
		}
		exts->net = net;
	}
#else
	if ((exts->action && tb[exts->action]) ||
+1 −1
Original line number Diff line number Diff line
@@ -199,7 +199,7 @@ static int basic_change(struct net *net, struct sk_buff *in_skb,
	if (!fnew)
		return -ENOBUFS;

	err = tcf_exts_init(&fnew->exts, TCA_BASIC_ACT, TCA_BASIC_POLICE);
	err = tcf_exts_init(&fnew->exts, net, TCA_BASIC_ACT, TCA_BASIC_POLICE);
	if (err < 0)
		goto errout;

+1 −1
Original line number Diff line number Diff line
@@ -477,7 +477,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
	if (!prog)
		return -ENOBUFS;

	ret = tcf_exts_init(&prog->exts, TCA_BPF_ACT, TCA_BPF_POLICE);
	ret = tcf_exts_init(&prog->exts, net, TCA_BPF_ACT, TCA_BPF_POLICE);
	if (ret < 0)
		goto errout;

+1 −1
Original line number Diff line number Diff line
@@ -99,7 +99,7 @@ static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,
	if (!new)
		return -ENOBUFS;

	err = tcf_exts_init(&new->exts, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
	err = tcf_exts_init(&new->exts, net, TCA_CGROUP_ACT, TCA_CGROUP_POLICE);
	if (err < 0)
		goto errout;
	new->handle = handle;
Loading