Commit 8c98d571bb0e9717fd7be7242945e8e0abebbaa3
Committed by
David S. Miller
1 parent
c09fc2e11e
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>
Showing 1 changed file with 9 additions and 21 deletions Side-by-side Diff
net/sched/cls_route.c
... | ... | @@ -372,37 +372,32 @@ |
372 | 372 | struct route4_filter *fp; |
373 | 373 | unsigned int h1; |
374 | 374 | struct route4_bucket *b; |
375 | - struct tcf_exts e; | |
376 | 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 | 378 | if (err < 0) |
380 | 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 | 381 | if (tb[TCA_ROUTE4_TO]) { |
387 | 382 | if (new && handle & 0x8000) |
388 | - goto errout; | |
383 | + return -EINVAL; | |
389 | 384 | to = nla_get_u32(tb[TCA_ROUTE4_TO]); |
390 | 385 | if (to > 0xFF) |
391 | - goto errout; | |
386 | + return -EINVAL; | |
392 | 387 | nhandle = to; |
393 | 388 | } |
394 | 389 | |
395 | 390 | if (tb[TCA_ROUTE4_FROM]) { |
396 | 391 | if (tb[TCA_ROUTE4_IIF]) |
397 | - goto errout; | |
392 | + return -EINVAL; | |
398 | 393 | id = nla_get_u32(tb[TCA_ROUTE4_FROM]); |
399 | 394 | if (id > 0xFF) |
400 | - goto errout; | |
395 | + return -EINVAL; | |
401 | 396 | nhandle |= id << 16; |
402 | 397 | } else if (tb[TCA_ROUTE4_IIF]) { |
403 | 398 | id = nla_get_u32(tb[TCA_ROUTE4_IIF]); |
404 | 399 | if (id > 0x7FFF) |
405 | - goto errout; | |
400 | + return -EINVAL; | |
406 | 401 | nhandle |= (id | 0x8000) << 16; |
407 | 402 | } else |
408 | 403 | nhandle |= 0xFFFF << 16; |
409 | 404 | |
410 | 405 | |
411 | 406 | |
412 | 407 | |
... | ... | @@ -410,27 +405,25 @@ |
410 | 405 | if (handle && new) { |
411 | 406 | nhandle |= handle & 0x7F00; |
412 | 407 | if (nhandle != handle) |
413 | - goto errout; | |
408 | + return -EINVAL; | |
414 | 409 | } |
415 | 410 | |
416 | 411 | h1 = to_hash(nhandle); |
417 | 412 | b = rtnl_dereference(head->table[h1]); |
418 | 413 | if (!b) { |
419 | - err = -ENOBUFS; | |
420 | 414 | b = kzalloc(sizeof(struct route4_bucket), GFP_KERNEL); |
421 | 415 | if (b == NULL) |
422 | - goto errout; | |
416 | + return -ENOBUFS; | |
423 | 417 | |
424 | 418 | rcu_assign_pointer(head->table[h1], b); |
425 | 419 | } else { |
426 | 420 | unsigned int h2 = from_hash(nhandle >> 16); |
427 | 421 | |
428 | - err = -EEXIST; | |
429 | 422 | for (fp = rtnl_dereference(b->ht[h2]); |
430 | 423 | fp; |
431 | 424 | fp = rtnl_dereference(fp->next)) |
432 | 425 | if (fp->handle == f->handle) |
433 | - goto errout; | |
426 | + return -EEXIST; | |
434 | 427 | } |
435 | 428 | |
436 | 429 | if (tb[TCA_ROUTE4_TO]) |
437 | 430 | |
... | ... | @@ -450,12 +443,7 @@ |
450 | 443 | tcf_bind_filter(tp, &f->res, base); |
451 | 444 | } |
452 | 445 | |
453 | - tcf_exts_change(tp, &f->exts, &e); | |
454 | - | |
455 | 446 | return 0; |
456 | -errout: | |
457 | - tcf_exts_destroy(&e); | |
458 | - return err; | |
459 | 447 | } |
460 | 448 | |
461 | 449 | static int route4_change(struct net *net, struct sk_buff *in_skb, |