diff mbox series

[iproute2,v2] tc: simple: don't hardcode the control action

Message ID ea2fbb2d36828188d11090d73b648d97988cdcf6.1559687259.git.dcaratti@redhat.com
State Accepted
Delegated to: stephen hemminger
Headers show
Series [iproute2,v2] tc: simple: don't hardcode the control action | expand

Commit Message

Davide Caratti June 4, 2019, 10:30 p.m. UTC
the following TDC test case:

 b776 - Replace simple action with invalid goto chain control

checks if the kernel correctly validates the 'goto chain' control action,
when it is specified in 'act_simple' rules. The test systematically fails
because the control action is hardcoded in parse_simple(), i.e. it is not
parsed by command line arguments, so its value is constantly TC_ACT_PIPE.
Because of that, the following command:

 # tc action add action simple sdata "test" drop index 7

installs an 'act_simple' rule that never drops packets, and whose 'index'
is the first IDR available, plus an 'act_gact' rule with 'index' equal to
7, that drops packets.

Use parse_action_control_dflt(), like we did on many other TC actions, to
make the control action configurable also with 'act_simple'. The expected
results of test b776 are summarized below:

 iproute2
   v       kernel->| 5.1-rc2 (and previous)  | 5.1-rc3 (and subsequent)
 ------------------+-------------------------+-------------------------
 5.1.0             | FAIL (bad IDR)          | FAIL (bad IDR)
 5.1.0(patched)    | FAIL (no rule/bad sdata)| PASS

Changes since v1:
 - reword commit message, thanks Stephen Hemminger

Fixes: 087f46ee4ebd ("tc: introduce simple action")
CC: Andrea Claudi <aclaudi@redhat.com>
CC: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: Davide Caratti <dcaratti@redhat.com>
---
 tc/m_simple.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Stephen Hemminger June 6, 2019, 9:45 p.m. UTC | #1
On Wed,  5 Jun 2019 00:30:16 +0200
Davide Caratti <dcaratti@redhat.com> wrote:

> the following TDC test case:
> 
>  b776 - Replace simple action with invalid goto chain control
> 
> checks if the kernel correctly validates the 'goto chain' control action,
> when it is specified in 'act_simple' rules. The test systematically fails
> because the control action is hardcoded in parse_simple(), i.e. it is not
> parsed by command line arguments, so its value is constantly TC_ACT_PIPE.
> Because of that, the following command:
> 
>  # tc action add action simple sdata "test" drop index 7
> 
> installs an 'act_simple' rule that never drops packets, and whose 'index'
> is the first IDR available, plus an 'act_gact' rule with 'index' equal to
> 7, that drops packets.
> 
> Use parse_action_control_dflt(), like we did on many other TC actions, to
> make the control action configurable also with 'act_simple'. The expected
> results of test b776 are summarized below:
> 
>  iproute2
>    v       kernel->| 5.1-rc2 (and previous)  | 5.1-rc3 (and subsequent)
>  ------------------+-------------------------+-------------------------
>  5.1.0             | FAIL (bad IDR)          | FAIL (bad IDR)
>  5.1.0(patched)    | FAIL (no rule/bad sdata)| PASS
> 
> Changes since v1:
>  - reword commit message, thanks Stephen Hemminger
> 
> Fixes: 087f46ee4ebd ("tc: introduce simple action")
> CC: Andrea Claudi <aclaudi@redhat.com>
> CC: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
> Signed-off-by: Davide Caratti <dcaratti@redhat.com>

Applied, thanks
diff mbox series

Patch

diff --git a/tc/m_simple.c b/tc/m_simple.c
index 886606f9f8b4..e3c8a60ff64a 100644
--- a/tc/m_simple.c
+++ b/tc/m_simple.c
@@ -119,6 +119,9 @@  parse_simple(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 		}
 	}
 
+	parse_action_control_dflt(&argc, &argv, &sel.action, false,
+				  TC_ACT_PIPE);
+
 	if (argc) {
 		if (matches(*argv, "index") == 0) {
 			NEXT_ARG();
@@ -144,8 +147,6 @@  parse_simple(struct action_util *a, int *argc_p, char ***argv_p, int tca_id,
 		return -1;
 	}
 
-	sel.action = TC_ACT_PIPE;
-
 	tail = addattr_nest(n, MAX_MSG, tca_id);
 	addattr_l(n, MAX_MSG, TCA_DEF_PARMS, &sel, sizeof(sel));
 	if (simpdata)