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

Commit 6839da32 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

net: sched: cls_bpf: no need to call tcf_exts_change for newly allocated struct



As the prog struct was allocated right before cls_bpf_set_parms call,
no need to use tcf_exts_change to do atomic change, and we can just
fill-up the unused exts struct directly by tcf_exts_validate.

Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ff1f8ca0
Loading
Loading
Loading
Loading
+6 −19
Original line number Original line Diff line number Diff line
@@ -387,7 +387,6 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp,
			     struct nlattr **tb, struct nlattr *est, bool ovr)
			     struct nlattr **tb, struct nlattr *est, bool ovr)
{
{
	bool is_bpf, is_ebpf, have_exts = false;
	bool is_bpf, is_ebpf, have_exts = false;
	struct tcf_exts exts;
	u32 gen_flags = 0;
	u32 gen_flags = 0;
	int ret;
	int ret;


@@ -396,30 +395,23 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp,
	if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf))
	if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf))
		return -EINVAL;
		return -EINVAL;


	ret = tcf_exts_init(&exts, TCA_BPF_ACT, TCA_BPF_POLICE);
	ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr);
	if (ret < 0)
	if (ret < 0)
		return ret;
		return ret;
	ret = tcf_exts_validate(net, tp, tb, est, &exts, ovr);
	if (ret < 0)
		goto errout;


	if (tb[TCA_BPF_FLAGS]) {
	if (tb[TCA_BPF_FLAGS]) {
		u32 bpf_flags = nla_get_u32(tb[TCA_BPF_FLAGS]);
		u32 bpf_flags = nla_get_u32(tb[TCA_BPF_FLAGS]);


		if (bpf_flags & ~TCA_BPF_FLAG_ACT_DIRECT) {
		if (bpf_flags & ~TCA_BPF_FLAG_ACT_DIRECT)
			ret = -EINVAL;
			return -EINVAL;
			goto errout;
		}


		have_exts = bpf_flags & TCA_BPF_FLAG_ACT_DIRECT;
		have_exts = bpf_flags & TCA_BPF_FLAG_ACT_DIRECT;
	}
	}
	if (tb[TCA_BPF_FLAGS_GEN]) {
	if (tb[TCA_BPF_FLAGS_GEN]) {
		gen_flags = nla_get_u32(tb[TCA_BPF_FLAGS_GEN]);
		gen_flags = nla_get_u32(tb[TCA_BPF_FLAGS_GEN]);
		if (gen_flags & ~CLS_BPF_SUPPORTED_GEN_FLAGS ||
		if (gen_flags & ~CLS_BPF_SUPPORTED_GEN_FLAGS ||
		    !tc_flags_valid(gen_flags)) {
		    !tc_flags_valid(gen_flags))
			ret = -EINVAL;
			return -EINVAL;
			goto errout;
		}
	}
	}


	prog->exts_integrated = have_exts;
	prog->exts_integrated = have_exts;
@@ -428,19 +420,14 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp,
	ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog) :
	ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog) :
		       cls_bpf_prog_from_efd(tb, prog, tp);
		       cls_bpf_prog_from_efd(tb, prog, tp);
	if (ret < 0)
	if (ret < 0)
		goto errout;
		return ret;


	if (tb[TCA_BPF_CLASSID]) {
	if (tb[TCA_BPF_CLASSID]) {
		prog->res.classid = nla_get_u32(tb[TCA_BPF_CLASSID]);
		prog->res.classid = nla_get_u32(tb[TCA_BPF_CLASSID]);
		tcf_bind_filter(tp, &prog->res, base);
		tcf_bind_filter(tp, &prog->res, base);
	}
	}


	tcf_exts_change(tp, &prog->exts, &exts);
	return 0;
	return 0;

errout:
	tcf_exts_destroy(&exts);
	return ret;
}
}


static u32 cls_bpf_grab_new_handle(struct tcf_proto *tp,
static u32 cls_bpf_grab_new_handle(struct tcf_proto *tp,