net_sched: cls: refactor out struct tcf_ext_map
These information can be saved in tcf_exts, and this will simplify the code. Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: David S. Miller <davem@davemloft.net> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
33be627159
commit
5da57f422d
@@ -46,11 +46,6 @@ static const struct nla_policy bpf_policy[TCA_BPF_MAX + 1] = {
|
||||
.len = sizeof(struct sock_filter) * BPF_MAXINSNS },
|
||||
};
|
||||
|
||||
static const struct tcf_ext_map bpf_ext_map = {
|
||||
.action = TCA_BPF_ACT,
|
||||
.police = TCA_BPF_POLICE,
|
||||
};
|
||||
|
||||
static int cls_bpf_classify(struct sk_buff *skb, const struct tcf_proto *tp,
|
||||
struct tcf_result *res)
|
||||
{
|
||||
@@ -174,7 +169,8 @@ static int cls_bpf_modify_existing(struct net *net, struct tcf_proto *tp,
|
||||
if (!tb[TCA_BPF_OPS_LEN] || !tb[TCA_BPF_OPS] || !tb[TCA_BPF_CLASSID])
|
||||
return -EINVAL;
|
||||
|
||||
ret = tcf_exts_validate(net, tp, tb, est, &exts, &bpf_ext_map);
|
||||
tcf_exts_init(&exts, TCA_BPF_ACT, TCA_BPF_POLICE);
|
||||
ret = tcf_exts_validate(net, tp, tb, est, &exts);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -271,7 +267,7 @@ static int cls_bpf_change(struct net *net, struct sk_buff *in_skb,
|
||||
if (prog == NULL)
|
||||
return -ENOBUFS;
|
||||
|
||||
tcf_exts_init(&prog->exts);
|
||||
tcf_exts_init(&prog->exts, TCA_BPF_ACT, TCA_BPF_POLICE);
|
||||
if (handle == 0)
|
||||
prog->handle = cls_bpf_grab_new_handle(tp, head);
|
||||
else
|
||||
@@ -326,12 +322,12 @@ static int cls_bpf_dump(struct tcf_proto *tp, unsigned long fh,
|
||||
|
||||
memcpy(nla_data(nla), prog->bpf_ops, nla_len(nla));
|
||||
|
||||
if (tcf_exts_dump(skb, &prog->exts, &bpf_ext_map) < 0)
|
||||
if (tcf_exts_dump(skb, &prog->exts) < 0)
|
||||
goto nla_put_failure;
|
||||
|
||||
nla_nest_end(skb, nest);
|
||||
|
||||
if (tcf_exts_dump_stats(skb, &prog->exts, &bpf_ext_map) < 0)
|
||||
if (tcf_exts_dump_stats(skb, &prog->exts) < 0)
|
||||
goto nla_put_failure;
|
||||
|
||||
return skb->len;
|
||||
|
Reference in New Issue
Block a user