|
|
36cfb7 |
From eaccce1b85efafbea1607ff88d7259541f311ee2 Mon Sep 17 00:00:00 2001
|
|
|
36cfb7 |
From: Andrea Claudi <aclaudi@redhat.com>
|
|
|
36cfb7 |
Date: Wed, 5 Jun 2019 13:10:31 +0200
|
|
|
36cfb7 |
Subject: [PATCH] tc/actions: introduce support for goto chain action
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1714660
|
|
|
36cfb7 |
Upstream Status: iproute2.git commit d19f72f7898a7
|
|
|
36cfb7 |
|
|
|
36cfb7 |
commit d19f72f7898a78ef76628833c204afb96f9a05cd
|
|
|
36cfb7 |
Author: Jiri Pirko <jiri@mellanox.com>
|
|
|
36cfb7 |
Date: Tue May 16 19:29:37 2017 +0200
|
|
|
36cfb7 |
|
|
|
36cfb7 |
tc/actions: introduce support for goto chain action
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Allow user to set control action "goto" with filter chain index as
|
|
|
36cfb7 |
a parameter.
|
|
|
36cfb7 |
|
|
|
36cfb7 |
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
|
|
|
36cfb7 |
---
|
|
|
36cfb7 |
man/man8/tc-ife.8 | 2 +-
|
|
|
36cfb7 |
man/man8/tc-pedit.8 | 2 +-
|
|
|
36cfb7 |
man/man8/tc-police.8 | 2 +-
|
|
|
36cfb7 |
man/man8/tc-vlan.8 | 2 +-
|
|
|
36cfb7 |
tc/m_connmark.c | 3 ++-
|
|
|
36cfb7 |
tc/m_gact.c | 6 ++++--
|
|
|
36cfb7 |
tc/m_pedit.c | 3 ++-
|
|
|
36cfb7 |
tc/m_police.c | 6 ++++--
|
|
|
36cfb7 |
tc/m_skbmod.c | 3 ++-
|
|
|
36cfb7 |
tc/m_vlan.c | 3 ++-
|
|
|
36cfb7 |
tc/tc_util.c | 24 +++++++++++++++++++++++-
|
|
|
36cfb7 |
11 files changed, 43 insertions(+), 13 deletions(-)
|
|
|
36cfb7 |
|
|
|
36cfb7 |
diff --git a/man/man8/tc-ife.8 b/man/man8/tc-ife.8
|
|
|
36cfb7 |
index a8f1f287d1502..24595cc6d615c 100644
|
|
|
36cfb7 |
--- a/man/man8/tc-ife.8
|
|
|
36cfb7 |
+++ b/man/man8/tc-ife.8
|
|
|
36cfb7 |
@@ -34,7 +34,7 @@ IFE - encapsulate/decapsulate metadata
|
|
|
36cfb7 |
|
|
|
36cfb7 |
.ti -8
|
|
|
36cfb7 |
.IR CONTROL " := { "
|
|
|
36cfb7 |
-.BR reclassify " | " use " | " pipe " | " drop " | " continue " | " ok " }"
|
|
|
36cfb7 |
+.BR reclassify " | " use " | " pipe " | " drop " | " continue " | " ok " | " goto " " chain " " CHAIN_INDEX " }"
|
|
|
36cfb7 |
.SH DESCRIPTION
|
|
|
36cfb7 |
The
|
|
|
36cfb7 |
.B ife
|
|
|
36cfb7 |
diff --git a/man/man8/tc-pedit.8 b/man/man8/tc-pedit.8
|
|
|
36cfb7 |
index 82d4217bc9589..bbd725c4d0ba1 100644
|
|
|
36cfb7 |
--- a/man/man8/tc-pedit.8
|
|
|
36cfb7 |
+++ b/man/man8/tc-pedit.8
|
|
|
36cfb7 |
@@ -82,7 +82,7 @@ pedit - generic packet editor action
|
|
|
36cfb7 |
|
|
|
36cfb7 |
.ti -8
|
|
|
36cfb7 |
.IR CONTROL " := {"
|
|
|
36cfb7 |
-.BR reclassify " | " pipe " | " drop " | " shot " | " continue " | " pass " }"
|
|
|
36cfb7 |
+.BR reclassify " | " pipe " | " drop " | " shot " | " continue " | " pass " | " goto " " chain " " CHAIN_INDEX " }"
|
|
|
36cfb7 |
.SH DESCRIPTION
|
|
|
36cfb7 |
The
|
|
|
36cfb7 |
.B pedit
|
|
|
36cfb7 |
diff --git a/man/man8/tc-police.8 b/man/man8/tc-police.8
|
|
|
36cfb7 |
index 620c28813fc7e..bcc5f438825d1 100644
|
|
|
36cfb7 |
--- a/man/man8/tc-police.8
|
|
|
36cfb7 |
+++ b/man/man8/tc-police.8
|
|
|
36cfb7 |
@@ -30,7 +30,7 @@ police - policing action
|
|
|
36cfb7 |
|
|
|
36cfb7 |
.ti -8
|
|
|
36cfb7 |
.IR EXCEEDACT/NOTEXCEEDACT " := { "
|
|
|
36cfb7 |
-.BR pipe " | " ok " | " reclassify " | " drop " | " continue " }"
|
|
|
36cfb7 |
+.BR pipe " | " ok " | " reclassify " | " drop " | " continue " | " goto " " chain " " CHAIN_INDEX " }"
|
|
|
36cfb7 |
.SH DESCRIPTION
|
|
|
36cfb7 |
The
|
|
|
36cfb7 |
.B police
|
|
|
36cfb7 |
diff --git a/man/man8/tc-vlan.8 b/man/man8/tc-vlan.8
|
|
|
36cfb7 |
index a526f66b60b4c..f5ffc25f054ed 100644
|
|
|
36cfb7 |
--- a/man/man8/tc-vlan.8
|
|
|
36cfb7 |
+++ b/man/man8/tc-vlan.8
|
|
|
36cfb7 |
@@ -26,7 +26,7 @@ vlan - vlan manipulation module
|
|
|
36cfb7 |
|
|
|
36cfb7 |
.ti -8
|
|
|
36cfb7 |
.IR CONTROL " := { "
|
|
|
36cfb7 |
-.BR reclassify " | " pipe " | " drop " | " continue " | " pass " }"
|
|
|
36cfb7 |
+.BR reclassify " | " pipe " | " drop " | " continue " | " pass " | " goto " " chain " " CHAIN_INDEX " }"
|
|
|
36cfb7 |
.SH DESCRIPTION
|
|
|
36cfb7 |
The
|
|
|
36cfb7 |
.B vlan
|
|
|
36cfb7 |
diff --git a/tc/m_connmark.c b/tc/m_connmark.c
|
|
|
36cfb7 |
index 3c2274bc0d2af..37d7185415490 100644
|
|
|
36cfb7 |
--- a/tc/m_connmark.c
|
|
|
36cfb7 |
+++ b/tc/m_connmark.c
|
|
|
36cfb7 |
@@ -30,7 +30,8 @@ explain(void)
|
|
|
36cfb7 |
fprintf(stderr, "Usage: ... connmark [zone ZONE] [CONTROL] [index <INDEX>]\n");
|
|
|
36cfb7 |
fprintf(stderr, "where :\n"
|
|
|
36cfb7 |
"\tZONE is the conntrack zone\n"
|
|
|
36cfb7 |
- "\tCONTROL := reclassify|pipe|drop|continue|ok\n");
|
|
|
36cfb7 |
+ "\tCONTROL := reclassify | pipe | drop | continue | ok |\n"
|
|
|
36cfb7 |
+ "\t goto chain <CHAIN_INDEX>\n");
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
|
|
|
36cfb7 |
static void
|
|
|
36cfb7 |
diff --git a/tc/m_gact.c b/tc/m_gact.c
|
|
|
36cfb7 |
index bc3860bbe4441..c04c00bbded3c 100644
|
|
|
36cfb7 |
--- a/tc/m_gact.c
|
|
|
36cfb7 |
+++ b/tc/m_gact.c
|
|
|
36cfb7 |
@@ -45,7 +45,8 @@ explain(void)
|
|
|
36cfb7 |
#ifdef CONFIG_GACT_PROB
|
|
|
36cfb7 |
fprintf(stderr, "Usage: ... gact <ACTION> [RAND] [INDEX]\n");
|
|
|
36cfb7 |
fprintf(stderr,
|
|
|
36cfb7 |
- "Where: \tACTION := reclassify | drop | continue | pass | pipe\n"
|
|
|
36cfb7 |
+ "Where: \tACTION := reclassify | drop | continue | pass | pipe |\n"
|
|
|
36cfb7 |
+ " \t goto chain <CHAIN_INDEX>\n"
|
|
|
36cfb7 |
"\tRAND := random <RANDTYPE> <ACTION> <VAL>\n"
|
|
|
36cfb7 |
"\tRANDTYPE := netrand | determ\n"
|
|
|
36cfb7 |
"\tVAL : = value not exceeding 10000\n"
|
|
|
36cfb7 |
@@ -54,7 +55,8 @@ explain(void)
|
|
|
36cfb7 |
#else
|
|
|
36cfb7 |
fprintf(stderr, "Usage: ... gact <ACTION> [INDEX]\n");
|
|
|
36cfb7 |
fprintf(stderr,
|
|
|
36cfb7 |
- "Where: \tACTION := reclassify | drop | continue | pass | pipe\n"
|
|
|
36cfb7 |
+ "Where: \tACTION := reclassify | drop | continue | pass | pipe |\n"
|
|
|
36cfb7 |
+ " \t goto chain <CHAIN_INDEX>\n"
|
|
|
36cfb7 |
"\tINDEX := index value used\n"
|
|
|
36cfb7 |
"\n");
|
|
|
36cfb7 |
#endif
|
|
|
36cfb7 |
diff --git a/tc/m_pedit.c b/tc/m_pedit.c
|
|
|
36cfb7 |
index b7d26b4540beb..5d89ab1d832ab 100644
|
|
|
36cfb7 |
--- a/tc/m_pedit.c
|
|
|
36cfb7 |
+++ b/tc/m_pedit.c
|
|
|
36cfb7 |
@@ -45,7 +45,8 @@ static void explain(void)
|
|
|
36cfb7 |
"\t\tCMD:= clear | invert | set <setval>| add <addval> | retain\n"
|
|
|
36cfb7 |
"\t<LAYERED>:= ip <ipdata> | ip6 <ip6data>\n"
|
|
|
36cfb7 |
" \t\t| udp <udpdata> | tcp <tcpdata> | icmp <icmpdata>\n"
|
|
|
36cfb7 |
- "\tCONTROL:= reclassify | pipe | drop | continue | pass\n"
|
|
|
36cfb7 |
+ "\tCONTROL:= reclassify | pipe | drop | continue | pass |\n"
|
|
|
36cfb7 |
+ "\t goto chain <CHAIN_INDEX>\n"
|
|
|
36cfb7 |
"\tNOTE: if 'ex' is set, extended functionality will be supported (kernel >= 4.11)\n"
|
|
|
36cfb7 |
"For Example usage look at the examples directory\n");
|
|
|
36cfb7 |
|
|
|
36cfb7 |
diff --git a/tc/m_police.c b/tc/m_police.c
|
|
|
36cfb7 |
index 2b73969de5daf..86117db0482ec 100644
|
|
|
36cfb7 |
--- a/tc/m_police.c
|
|
|
36cfb7 |
+++ b/tc/m_police.c
|
|
|
36cfb7 |
@@ -41,7 +41,8 @@ static void usage(void)
|
|
|
36cfb7 |
fprintf(stderr, "Where: CONTROL := conform-exceed <EXCEEDACT>[/NOTEXCEEDACT]\n");
|
|
|
36cfb7 |
fprintf(stderr, " Define how to handle packets which exceed (<EXCEEDACT>)\n");
|
|
|
36cfb7 |
fprintf(stderr, " or conform (<NOTEXCEEDACT>) the configured bandwidth limit.\n");
|
|
|
36cfb7 |
- fprintf(stderr, " EXCEEDACT/NOTEXCEEDACT := { pipe | ok | reclassify | drop | continue }\n");
|
|
|
36cfb7 |
+ fprintf(stderr, " EXCEEDACT/NOTEXCEEDACT := { pipe | ok | reclassify | drop | continue |\n");
|
|
|
36cfb7 |
+ fprintf(stderr, " goto chain <CHAIN_INDEX> }\n");
|
|
|
36cfb7 |
exit(-1);
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
|
|
|
36cfb7 |
@@ -150,7 +151,8 @@ int act_parse_police(struct action_util *a, int *argc_p, char ***argv_p,
|
|
|
36cfb7 |
matches(*argv, "shot") == 0 ||
|
|
|
36cfb7 |
matches(*argv, "continue") == 0 ||
|
|
|
36cfb7 |
matches(*argv, "pass") == 0 ||
|
|
|
36cfb7 |
- matches(*argv, "pipe") == 0) {
|
|
|
36cfb7 |
+ matches(*argv, "pipe") == 0 ||
|
|
|
36cfb7 |
+ matches(*argv, "goto") == 0) {
|
|
|
36cfb7 |
if (parse_action_control(&argc, &argv, &p.action, false))
|
|
|
36cfb7 |
return -1;
|
|
|
36cfb7 |
} else if (strcmp(*argv, "conform-exceed") == 0) {
|
|
|
36cfb7 |
diff --git a/tc/m_skbmod.c b/tc/m_skbmod.c
|
|
|
36cfb7 |
index 1ccd474309348..ba79308ba8354 100644
|
|
|
36cfb7 |
--- a/tc/m_skbmod.c
|
|
|
36cfb7 |
+++ b/tc/m_skbmod.c
|
|
|
36cfb7 |
@@ -36,7 +36,8 @@ static void skbmod_explain(void)
|
|
|
36cfb7 |
"\tDMAC := 6 byte Destination MAC address\n"
|
|
|
36cfb7 |
"\tSMAC := optional 6 byte Source MAC address\n"
|
|
|
36cfb7 |
"\tETYPE := optional 16 bit ethertype\n"
|
|
|
36cfb7 |
- "\tCONTROL := reclassify|pipe|drop|continue|ok\n"
|
|
|
36cfb7 |
+ "\tCONTROL := reclassify | pipe | drop | continue | ok |\n"
|
|
|
36cfb7 |
+ "\t goto chain <CHAIN_INDEX>\n"
|
|
|
36cfb7 |
"\tINDEX := skbmod index value to use\n");
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
|
|
|
36cfb7 |
diff --git a/tc/m_vlan.c b/tc/m_vlan.c
|
|
|
36cfb7 |
index 2441b06847ecd..cccb4996b05f3 100644
|
|
|
36cfb7 |
--- a/tc/m_vlan.c
|
|
|
36cfb7 |
+++ b/tc/m_vlan.c
|
|
|
36cfb7 |
@@ -32,7 +32,8 @@ static void explain(void)
|
|
|
36cfb7 |
fprintf(stderr, " vlan modify [ protocol VLANPROTO ] id VLANID [ priority VLANPRIO ] [CONTROL]\n");
|
|
|
36cfb7 |
fprintf(stderr, " VLANPROTO is one of 802.1Q or 802.1AD\n");
|
|
|
36cfb7 |
fprintf(stderr, " with default: 802.1Q\n");
|
|
|
36cfb7 |
- fprintf(stderr, " CONTROL := reclassify | pipe | drop | continue | pass\n");
|
|
|
36cfb7 |
+ fprintf(stderr, " CONTROL := reclassify | pipe | drop | continue | pass |\n");
|
|
|
36cfb7 |
+ fprintf(stderr, " goto chain <CHAIN_INDEX>\n");
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
|
|
|
36cfb7 |
static void usage(void)
|
|
|
36cfb7 |
diff --git a/tc/tc_util.c b/tc/tc_util.c
|
|
|
36cfb7 |
index 840222832690b..194185a0fa1d8 100644
|
|
|
36cfb7 |
--- a/tc/tc_util.c
|
|
|
36cfb7 |
+++ b/tc/tc_util.c
|
|
|
36cfb7 |
@@ -415,6 +415,8 @@ static const char *action_n2a(int action)
|
|
|
36cfb7 |
{
|
|
|
36cfb7 |
static char buf[64];
|
|
|
36cfb7 |
|
|
|
36cfb7 |
+ if (TC_ACT_EXT_CMP(action, TC_ACT_GOTO_CHAIN))
|
|
|
36cfb7 |
+ return "goto";
|
|
|
36cfb7 |
switch (action) {
|
|
|
36cfb7 |
case TC_ACT_UNSPEC:
|
|
|
36cfb7 |
return "continue";
|
|
|
36cfb7 |
@@ -458,6 +460,7 @@ static int action_a2n(char *arg, int *result, bool allow_num)
|
|
|
36cfb7 |
{"ok", TC_ACT_OK},
|
|
|
36cfb7 |
{"reclassify", TC_ACT_RECLASSIFY},
|
|
|
36cfb7 |
{"pipe", TC_ACT_PIPE},
|
|
|
36cfb7 |
+ {"goto", TC_ACT_GOTO_CHAIN},
|
|
|
36cfb7 |
{ NULL },
|
|
|
36cfb7 |
}, *iter;
|
|
|
36cfb7 |
|
|
|
36cfb7 |
@@ -497,6 +500,22 @@ int parse_action_control(int *argc_p, char ***argv_p,
|
|
|
36cfb7 |
fprintf(stderr, "Bad action type %s\n", *argv);
|
|
|
36cfb7 |
return -1;
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
+ if (result == TC_ACT_GOTO_CHAIN) {
|
|
|
36cfb7 |
+ __u32 chain_index;
|
|
|
36cfb7 |
+
|
|
|
36cfb7 |
+ NEXT_ARG();
|
|
|
36cfb7 |
+ if (matches(*argv, "chain") != 0) {
|
|
|
36cfb7 |
+ fprintf(stderr, "\"chain index\" expected\n");
|
|
|
36cfb7 |
+ return -1;
|
|
|
36cfb7 |
+ }
|
|
|
36cfb7 |
+ NEXT_ARG();
|
|
|
36cfb7 |
+ if (get_u32(&chain_index, *argv, 10) ||
|
|
|
36cfb7 |
+ chain_index > TC_ACT_EXT_VAL_MASK) {
|
|
|
36cfb7 |
+ fprintf(stderr, "Illegal \"chain index\"\n");
|
|
|
36cfb7 |
+ return -1;
|
|
|
36cfb7 |
+ }
|
|
|
36cfb7 |
+ result |= chain_index;
|
|
|
36cfb7 |
+ }
|
|
|
36cfb7 |
NEXT_ARG_FWD();
|
|
|
36cfb7 |
*argc_p = argc;
|
|
|
36cfb7 |
*argv_p = argv;
|
|
|
36cfb7 |
@@ -604,7 +623,10 @@ int parse_action_control_slash(int *argc_p, char ***argv_p,
|
|
|
36cfb7 |
void print_action_control(FILE *f, const char *prefix,
|
|
|
36cfb7 |
int action, const char *suffix)
|
|
|
36cfb7 |
{
|
|
|
36cfb7 |
- fprintf(f, "%s%s%s", prefix, action_n2a(action), suffix);
|
|
|
36cfb7 |
+ fprintf(f, "%s%s", prefix, action_n2a(action));
|
|
|
36cfb7 |
+ if (TC_ACT_EXT_CMP(action, TC_ACT_GOTO_CHAIN))
|
|
|
36cfb7 |
+ fprintf(f, " chain %u", action & TC_ACT_EXT_VAL_MASK);
|
|
|
36cfb7 |
+ fprintf(f, "%s", suffix);
|
|
|
36cfb7 |
}
|
|
|
36cfb7 |
|
|
|
36cfb7 |
int get_linklayer(unsigned int *val, const char *arg)
|
|
|
36cfb7 |
--
|
|
|
e138d9 |
2.21.0
|
|
|
36cfb7 |
|