diff options
author | David S. Miller <davem@davemloft.net> | 2018-08-30 01:10:59 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-08-30 01:10:59 -0400 |
commit | dc641794929713c30b5c375da0c664d7e00bfded (patch) | |
tree | 5a119bc799c2a00a0b215f958f945b917297f001 | |
parent | c4053ef322081554765e1b708d6cdd8855e1d72d (diff) | |
parent | 25a8238f4cc8425d4aade4f9041be468d0e8aa2e (diff) |
Merge branch 'net_sched-reject-unknown-tcfa_action-values'
Paolo Abeni says:
====================
net_sched: reject unknown tcfa_action values
As agreed some time ago, this changeset reject unknown tcfa_action values,
instead of changing such values under the hood.
A tdc test is included to verify the new behavior.
v1 -> v2:
- helper is now static and renamed according to act_* convention
- updated extack message, according to the new behavior
====================
Reviewed-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/sched/act_api.c | 16 | ||||
-rw-r--r-- | tools/testing/selftests/tc-testing/tc-tests/actions/police.json | 48 |
2 files changed, 59 insertions, 5 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index db83dac1e7f4..316c98bb87e4 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c | |||
@@ -662,6 +662,13 @@ int tcf_action_destroy(struct tc_action *actions[], int bind) | |||
662 | return ret; | 662 | return ret; |
663 | } | 663 | } |
664 | 664 | ||
665 | static int tcf_action_destroy_1(struct tc_action *a, int bind) | ||
666 | { | ||
667 | struct tc_action *actions[] = { a, NULL }; | ||
668 | |||
669 | return tcf_action_destroy(actions, bind); | ||
670 | } | ||
671 | |||
665 | static int tcf_action_put(struct tc_action *p) | 672 | static int tcf_action_put(struct tc_action *p) |
666 | { | 673 | { |
667 | return __tcf_action_put(p, false); | 674 | return __tcf_action_put(p, false); |
@@ -881,17 +888,16 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, | |||
881 | if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN)) { | 888 | if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN)) { |
882 | err = tcf_action_goto_chain_init(a, tp); | 889 | err = tcf_action_goto_chain_init(a, tp); |
883 | if (err) { | 890 | if (err) { |
884 | struct tc_action *actions[] = { a, NULL }; | 891 | tcf_action_destroy_1(a, bind); |
885 | |||
886 | tcf_action_destroy(actions, bind); | ||
887 | NL_SET_ERR_MSG(extack, "Failed to init TC action chain"); | 892 | NL_SET_ERR_MSG(extack, "Failed to init TC action chain"); |
888 | return ERR_PTR(err); | 893 | return ERR_PTR(err); |
889 | } | 894 | } |
890 | } | 895 | } |
891 | 896 | ||
892 | if (!tcf_action_valid(a->tcfa_action)) { | 897 | if (!tcf_action_valid(a->tcfa_action)) { |
893 | NL_SET_ERR_MSG(extack, "invalid action value, using TC_ACT_UNSPEC instead"); | 898 | tcf_action_destroy_1(a, bind); |
894 | a->tcfa_action = TC_ACT_UNSPEC; | 899 | NL_SET_ERR_MSG(extack, "Invalid control action value"); |
900 | return ERR_PTR(-EINVAL); | ||
895 | } | 901 | } |
896 | 902 | ||
897 | return a; | 903 | return a; |
diff --git a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json index f03763d81617..30f9b54bd666 100644 --- a/tools/testing/selftests/tc-testing/tc-tests/actions/police.json +++ b/tools/testing/selftests/tc-testing/tc-tests/actions/police.json | |||
@@ -313,6 +313,54 @@ | |||
313 | ] | 313 | ] |
314 | }, | 314 | }, |
315 | { | 315 | { |
316 | "id": "6aaf", | ||
317 | "name": "Add police actions with conform-exceed control pass/pipe [with numeric values]", | ||
318 | "category": [ | ||
319 | "actions", | ||
320 | "police" | ||
321 | ], | ||
322 | "setup": [ | ||
323 | [ | ||
324 | "$TC actions flush action police", | ||
325 | 0, | ||
326 | 1, | ||
327 | 255 | ||
328 | ] | ||
329 | ], | ||
330 | "cmdUnderTest": "$TC actions add action police rate 3mbit burst 250k conform-exceed 0/3 index 1", | ||
331 | "expExitCode": "0", | ||
332 | "verifyCmd": "$TC actions get action police index 1", | ||
333 | "matchPattern": "action order [0-9]*: police 0x1 rate 3Mbit burst 250Kb mtu 2Kb action pass/pipe", | ||
334 | "matchCount": "1", | ||
335 | "teardown": [ | ||
336 | "$TC actions flush action police" | ||
337 | ] | ||
338 | }, | ||
339 | { | ||
340 | "id": "29b1", | ||
341 | "name": "Add police actions with conform-exceed control <invalid>/drop", | ||
342 | "category": [ | ||
343 | "actions", | ||
344 | "police" | ||
345 | ], | ||
346 | "setup": [ | ||
347 | [ | ||
348 | "$TC actions flush action police", | ||
349 | 0, | ||
350 | 1, | ||
351 | 255 | ||
352 | ] | ||
353 | ], | ||
354 | "cmdUnderTest": "$TC actions add action police rate 3mbit burst 250k conform-exceed 10/drop index 1", | ||
355 | "expExitCode": "255", | ||
356 | "verifyCmd": "$TC actions ls action police", | ||
357 | "matchPattern": "action order [0-9]*: police 0x1 rate 3Mbit burst 250Kb mtu 2Kb action ", | ||
358 | "matchCount": "0", | ||
359 | "teardown": [ | ||
360 | "$TC actions flush action police" | ||
361 | ] | ||
362 | }, | ||
363 | { | ||
316 | "id": "c26f", | 364 | "id": "c26f", |
317 | "name": "Add police action with invalid peakrate value", | 365 | "name": "Add police action with invalid peakrate value", |
318 | "category": [ | 366 | "category": [ |