Skip to content

Commit c09fc2e

Browse files
jpirkodavem330
authored andcommitted
net: sched: cls_flow: no need to call tcf_exts_change for newly allocated struct
As the fnew struct just was allocated, so 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 8cc6251 commit c09fc2e

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

net/sched/cls_flow.c

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,6 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
388388
struct flow_filter *fold, *fnew;
389389
struct nlattr *opt = tca[TCA_OPTIONS];
390390
struct nlattr *tb[TCA_FLOW_MAX + 1];
391-
struct tcf_exts e;
392391
unsigned int nkeys = 0;
393392
unsigned int perturb_period = 0;
394393
u32 baseclass = 0;
@@ -424,31 +423,27 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
424423
return -EOPNOTSUPP;
425424
}
426425

427-
err = tcf_exts_init(&e, TCA_FLOW_ACT, TCA_FLOW_POLICE);
428-
if (err < 0)
429-
goto err1;
430-
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &e, ovr);
431-
if (err < 0)
432-
goto err1;
433-
434-
err = -ENOBUFS;
435426
fnew = kzalloc(sizeof(*fnew), GFP_KERNEL);
436427
if (!fnew)
437-
goto err1;
428+
return -ENOBUFS;
438429

439430
err = tcf_em_tree_validate(tp, tb[TCA_FLOW_EMATCHES], &fnew->ematches);
440431
if (err < 0)
441-
goto err2;
432+
goto err1;
442433

443434
err = tcf_exts_init(&fnew->exts, TCA_FLOW_ACT, TCA_FLOW_POLICE);
444435
if (err < 0)
445-
goto err3;
436+
goto err2;
437+
438+
err = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &fnew->exts, ovr);
439+
if (err < 0)
440+
goto err2;
446441

447442
fold = (struct flow_filter *)*arg;
448443
if (fold) {
449444
err = -EINVAL;
450445
if (fold->handle != handle && handle)
451-
goto err3;
446+
goto err2;
452447

453448
/* Copy fold into fnew */
454449
fnew->tp = fold->tp;
@@ -468,31 +463,31 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
468463
if (tb[TCA_FLOW_MODE])
469464
mode = nla_get_u32(tb[TCA_FLOW_MODE]);
470465
if (mode != FLOW_MODE_HASH && nkeys > 1)
471-
goto err3;
466+
goto err2;
472467

473468
if (mode == FLOW_MODE_HASH)
474469
perturb_period = fold->perturb_period;
475470
if (tb[TCA_FLOW_PERTURB]) {
476471
if (mode != FLOW_MODE_HASH)
477-
goto err3;
472+
goto err2;
478473
perturb_period = nla_get_u32(tb[TCA_FLOW_PERTURB]) * HZ;
479474
}
480475
} else {
481476
err = -EINVAL;
482477
if (!handle)
483-
goto err3;
478+
goto err2;
484479
if (!tb[TCA_FLOW_KEYS])
485-
goto err3;
480+
goto err2;
486481

487482
mode = FLOW_MODE_MAP;
488483
if (tb[TCA_FLOW_MODE])
489484
mode = nla_get_u32(tb[TCA_FLOW_MODE]);
490485
if (mode != FLOW_MODE_HASH && nkeys > 1)
491-
goto err3;
486+
goto err2;
492487

493488
if (tb[TCA_FLOW_PERTURB]) {
494489
if (mode != FLOW_MODE_HASH)
495-
goto err3;
490+
goto err2;
496491
perturb_period = nla_get_u32(tb[TCA_FLOW_PERTURB]) * HZ;
497492
}
498493

@@ -510,8 +505,6 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
510505
setup_deferrable_timer(&fnew->perturb_timer, flow_perturbation,
511506
(unsigned long)fnew);
512507

513-
tcf_exts_change(tp, &fnew->exts, &e);
514-
515508
netif_keep_dst(qdisc_dev(tp->q));
516509

517510
if (tb[TCA_FLOW_KEYS]) {
@@ -550,13 +543,11 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
550543
call_rcu(&fold->rcu, flow_destroy_filter);
551544
return 0;
552545

553-
err3:
546+
err2:
554547
tcf_exts_destroy(&fnew->exts);
555548
tcf_em_tree_destroy(&fnew->ematches);
556-
err2:
557-
kfree(fnew);
558549
err1:
559-
tcf_exts_destroy(&e);
550+
kfree(fnew);
560551
return err;
561552
}
562553

0 commit comments

Comments
 (0)