Skip to content

Commit 6839da3

Browse files
jpirkodavem330
authored andcommitted
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: Jiri Pirko <jiri@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ff1f8ca commit 6839da3

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

net/sched/cls_bpf.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp,
387387
struct nlattr **tb, struct nlattr *est, bool ovr)
388388
{
389389
bool is_bpf, is_ebpf, have_exts = false;
390-
struct tcf_exts exts;
391390
u32 gen_flags = 0;
392391
int ret;
393392

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

399-
ret = tcf_exts_init(&exts, TCA_BPF_ACT, TCA_BPF_POLICE);
398+
ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, ovr);
400399
if (ret < 0)
401400
return ret;
402-
ret = tcf_exts_validate(net, tp, tb, est, &exts, ovr);
403-
if (ret < 0)
404-
goto errout;
405401

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

409-
if (bpf_flags & ~TCA_BPF_FLAG_ACT_DIRECT) {
410-
ret = -EINVAL;
411-
goto errout;
412-
}
405+
if (bpf_flags & ~TCA_BPF_FLAG_ACT_DIRECT)
406+
return -EINVAL;
413407

414408
have_exts = bpf_flags & TCA_BPF_FLAG_ACT_DIRECT;
415409
}
416410
if (tb[TCA_BPF_FLAGS_GEN]) {
417411
gen_flags = nla_get_u32(tb[TCA_BPF_FLAGS_GEN]);
418412
if (gen_flags & ~CLS_BPF_SUPPORTED_GEN_FLAGS ||
419-
!tc_flags_valid(gen_flags)) {
420-
ret = -EINVAL;
421-
goto errout;
422-
}
413+
!tc_flags_valid(gen_flags))
414+
return -EINVAL;
423415
}
424416

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

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

438-
tcf_exts_change(tp, &prog->exts, &exts);
439430
return 0;
440-
441-
errout:
442-
tcf_exts_destroy(&exts);
443-
return ret;
444431
}
445432

446433
static u32 cls_bpf_grab_new_handle(struct tcf_proto *tp,

0 commit comments

Comments
 (0)