Skip to content

Commit 8c98d57

Browse files
jpirkodavem330
authored andcommitted
net: sched: cls_route: no need to call tcf_exts_change for newly allocated struct
As the f struct was allocated right before route4_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 c09fc2e commit 8c98d57

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

net/sched/cls_route.c

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -372,65 +372,58 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
372372
struct route4_filter *fp;
373373
unsigned int h1;
374374
struct route4_bucket *b;
375-
struct tcf_exts e;
376375
int err;
377376

378-
err = tcf_exts_init(&e, TCA_ROUTE4_ACT, TCA_ROUTE4_POLICE);
377+
err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr);
379378
if (err < 0)
380379
return err;
381-
err = tcf_exts_validate(net, tp, tb, est, &e, ovr);
382-
if (err < 0)
383-
goto errout;
384380

385-
err = -EINVAL;
386381
if (tb[TCA_ROUTE4_TO]) {
387382
if (new && handle & 0x8000)
388-
goto errout;
383+
return -EINVAL;
389384
to = nla_get_u32(tb[TCA_ROUTE4_TO]);
390385
if (to > 0xFF)
391-
goto errout;
386+
return -EINVAL;
392387
nhandle = to;
393388
}
394389

395390
if (tb[TCA_ROUTE4_FROM]) {
396391
if (tb[TCA_ROUTE4_IIF])
397-
goto errout;
392+
return -EINVAL;
398393
id = nla_get_u32(tb[TCA_ROUTE4_FROM]);
399394
if (id > 0xFF)
400-
goto errout;
395+
return -EINVAL;
401396
nhandle |= id << 16;
402397
} else if (tb[TCA_ROUTE4_IIF]) {
403398
id = nla_get_u32(tb[TCA_ROUTE4_IIF]);
404399
if (id > 0x7FFF)
405-
goto errout;
400+
return -EINVAL;
406401
nhandle |= (id | 0x8000) << 16;
407402
} else
408403
nhandle |= 0xFFFF << 16;
409404

410405
if (handle && new) {
411406
nhandle |= handle & 0x7F00;
412407
if (nhandle != handle)
413-
goto errout;
408+
return -EINVAL;
414409
}
415410

416411
h1 = to_hash(nhandle);
417412
b = rtnl_dereference(head->table[h1]);
418413
if (!b) {
419-
err = -ENOBUFS;
420414
b = kzalloc(sizeof(struct route4_bucket), GFP_KERNEL);
421415
if (b == NULL)
422-
goto errout;
416+
return -ENOBUFS;
423417

424418
rcu_assign_pointer(head->table[h1], b);
425419
} else {
426420
unsigned int h2 = from_hash(nhandle >> 16);
427421

428-
err = -EEXIST;
429422
for (fp = rtnl_dereference(b->ht[h2]);
430423
fp;
431424
fp = rtnl_dereference(fp->next))
432425
if (fp->handle == f->handle)
433-
goto errout;
426+
return -EEXIST;
434427
}
435428

436429
if (tb[TCA_ROUTE4_TO])
@@ -450,12 +443,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp,
450443
tcf_bind_filter(tp, &f->res, base);
451444
}
452445

453-
tcf_exts_change(tp, &f->exts, &e);
454-
455446
return 0;
456-
errout:
457-
tcf_exts_destroy(&e);
458-
return err;
459447
}
460448

461449
static int route4_change(struct net *net, struct sk_buff *in_skb,

0 commit comments

Comments
 (0)