Skip to content

Commit dc64179

Browse files
committed
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
2 parents c4053ef + 25a8238 commit dc64179

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed

net/sched/act_api.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,13 @@ int tcf_action_destroy(struct tc_action *actions[], int bind)
662662
return ret;
663663
}
664664

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+
665672
static int tcf_action_put(struct tc_action *p)
666673
{
667674
return __tcf_action_put(p, false);
@@ -881,17 +888,16 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
881888
if (TC_ACT_EXT_CMP(a->tcfa_action, TC_ACT_GOTO_CHAIN)) {
882889
err = tcf_action_goto_chain_init(a, tp);
883890
if (err) {
884-
struct tc_action *actions[] = { a, NULL };
885-
886-
tcf_action_destroy(actions, bind);
891+
tcf_action_destroy_1(a, bind);
887892
NL_SET_ERR_MSG(extack, "Failed to init TC action chain");
888893
return ERR_PTR(err);
889894
}
890895
}
891896

892897
if (!tcf_action_valid(a->tcfa_action)) {
893-
NL_SET_ERR_MSG(extack, "invalid action value, using TC_ACT_UNSPEC instead");
894-
a->tcfa_action = TC_ACT_UNSPEC;
898+
tcf_action_destroy_1(a, bind);
899+
NL_SET_ERR_MSG(extack, "Invalid control action value");
900+
return ERR_PTR(-EINVAL);
895901
}
896902

897903
return a;

tools/testing/selftests/tc-testing/tc-tests/actions/police.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,54 @@
312312
"$TC actions flush action police"
313313
]
314314
},
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+
},
315363
{
316364
"id": "c26f",
317365
"name": "Add police action with invalid peakrate value",

0 commit comments

Comments
 (0)