diff options
author | Jiri Pirko <jiri@mellanox.com> | 2017-08-04 08:29:13 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-08-04 14:21:24 -0400 |
commit | 8c98d571bb0e9717fd7be7242945e8e0abebbaa3 (patch) | |
tree | 4833d11379ac58bb4e93edaa7a1853af0b823d12 /net/sched/cls_route.c | |
parent | c09fc2e11ed1b7fc8cfa97fb1da544225fc32277 (diff) |
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>
Diffstat (limited to 'net/sched/cls_route.c')
-rw-r--r-- | net/sched/cls_route.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/net/sched/cls_route.c b/net/sched/cls_route.c index 26f863634862..f1e7d7850b44 100644 --- a/net/sched/cls_route.c +++ b/net/sched/cls_route.c | |||
@@ -372,37 +372,32 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, | |||
372 | struct route4_filter *fp; | 372 | struct route4_filter *fp; |
373 | unsigned int h1; | 373 | unsigned int h1; |
374 | struct route4_bucket *b; | 374 | struct route4_bucket *b; |
375 | struct tcf_exts e; | ||
376 | int err; | 375 | int err; |
377 | 376 | ||
378 | err = tcf_exts_init(&e, TCA_ROUTE4_ACT, TCA_ROUTE4_POLICE); | 377 | err = tcf_exts_validate(net, tp, tb, est, &f->exts, ovr); |
379 | if (err < 0) | 378 | if (err < 0) |
380 | return err; | 379 | return err; |
381 | err = tcf_exts_validate(net, tp, tb, est, &e, ovr); | ||
382 | if (err < 0) | ||
383 | goto errout; | ||
384 | 380 | ||
385 | err = -EINVAL; | ||
386 | if (tb[TCA_ROUTE4_TO]) { | 381 | if (tb[TCA_ROUTE4_TO]) { |
387 | if (new && handle & 0x8000) | 382 | if (new && handle & 0x8000) |
388 | goto errout; | 383 | return -EINVAL; |
389 | to = nla_get_u32(tb[TCA_ROUTE4_TO]); | 384 | to = nla_get_u32(tb[TCA_ROUTE4_TO]); |
390 | if (to > 0xFF) | 385 | if (to > 0xFF) |
391 | goto errout; | 386 | return -EINVAL; |
392 | nhandle = to; | 387 | nhandle = to; |
393 | } | 388 | } |
394 | 389 | ||
395 | if (tb[TCA_ROUTE4_FROM]) { | 390 | if (tb[TCA_ROUTE4_FROM]) { |
396 | if (tb[TCA_ROUTE4_IIF]) | 391 | if (tb[TCA_ROUTE4_IIF]) |
397 | goto errout; | 392 | return -EINVAL; |
398 | id = nla_get_u32(tb[TCA_ROUTE4_FROM]); | 393 | id = nla_get_u32(tb[TCA_ROUTE4_FROM]); |
399 | if (id > 0xFF) | 394 | if (id > 0xFF) |
400 | goto errout; | 395 | return -EINVAL; |
401 | nhandle |= id << 16; | 396 | nhandle |= id << 16; |
402 | } else if (tb[TCA_ROUTE4_IIF]) { | 397 | } else if (tb[TCA_ROUTE4_IIF]) { |
403 | id = nla_get_u32(tb[TCA_ROUTE4_IIF]); | 398 | id = nla_get_u32(tb[TCA_ROUTE4_IIF]); |
404 | if (id > 0x7FFF) | 399 | if (id > 0x7FFF) |
405 | goto errout; | 400 | return -EINVAL; |
406 | nhandle |= (id | 0x8000) << 16; | 401 | nhandle |= (id | 0x8000) << 16; |
407 | } else | 402 | } else |
408 | nhandle |= 0xFFFF << 16; | 403 | nhandle |= 0xFFFF << 16; |
@@ -410,27 +405,25 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, | |||
410 | if (handle && new) { | 405 | if (handle && new) { |
411 | nhandle |= handle & 0x7F00; | 406 | nhandle |= handle & 0x7F00; |
412 | if (nhandle != handle) | 407 | if (nhandle != handle) |
413 | goto errout; | 408 | return -EINVAL; |
414 | } | 409 | } |
415 | 410 | ||
416 | h1 = to_hash(nhandle); | 411 | h1 = to_hash(nhandle); |
417 | b = rtnl_dereference(head->table[h1]); | 412 | b = rtnl_dereference(head->table[h1]); |
418 | if (!b) { | 413 | if (!b) { |
419 | err = -ENOBUFS; | ||
420 | b = kzalloc(sizeof(struct route4_bucket), GFP_KERNEL); | 414 | b = kzalloc(sizeof(struct route4_bucket), GFP_KERNEL); |
421 | if (b == NULL) | 415 | if (b == NULL) |
422 | goto errout; | 416 | return -ENOBUFS; |
423 | 417 | ||
424 | rcu_assign_pointer(head->table[h1], b); | 418 | rcu_assign_pointer(head->table[h1], b); |
425 | } else { | 419 | } else { |
426 | unsigned int h2 = from_hash(nhandle >> 16); | 420 | unsigned int h2 = from_hash(nhandle >> 16); |
427 | 421 | ||
428 | err = -EEXIST; | ||
429 | for (fp = rtnl_dereference(b->ht[h2]); | 422 | for (fp = rtnl_dereference(b->ht[h2]); |
430 | fp; | 423 | fp; |
431 | fp = rtnl_dereference(fp->next)) | 424 | fp = rtnl_dereference(fp->next)) |
432 | if (fp->handle == f->handle) | 425 | if (fp->handle == f->handle) |
433 | goto errout; | 426 | return -EEXIST; |
434 | } | 427 | } |
435 | 428 | ||
436 | if (tb[TCA_ROUTE4_TO]) | 429 | if (tb[TCA_ROUTE4_TO]) |
@@ -450,12 +443,7 @@ static int route4_set_parms(struct net *net, struct tcf_proto *tp, | |||
450 | tcf_bind_filter(tp, &f->res, base); | 443 | tcf_bind_filter(tp, &f->res, base); |
451 | } | 444 | } |
452 | 445 | ||
453 | tcf_exts_change(tp, &f->exts, &e); | ||
454 | |||
455 | return 0; | 446 | return 0; |
456 | errout: | ||
457 | tcf_exts_destroy(&e); | ||
458 | return err; | ||
459 | } | 447 | } |
460 | 448 | ||
461 | static int route4_change(struct net *net, struct sk_buff *in_skb, | 449 | static int route4_change(struct net *net, struct sk_buff *in_skb, |