Skip to content

Commit 97763dc

Browse files
Paolo Abenidavem330
authored andcommitted
net_sched: reject unknown tcfa_action values
After the commit 802bfb1 ("net/sched: user-space can't set unknown tcfa_action values"), unknown tcfa_action values are converted to TC_ACT_UNSPEC, but the common agreement is instead rejecting such configurations. This change also introduces a helper to simplify the destruction of a single action, avoiding code duplication. v1 -> v2: - helper is now static and renamed according to act_* convention - updated extack message, according to the new behavior Fixes: 802bfb1 ("net/sched: user-space can't set unknown tcfa_action values") Signed-off-by: Paolo Abeni <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c4053ef commit 97763dc

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-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;

0 commit comments

Comments
 (0)