Blame SOURCES/0133-tc-actions-introduce-support-for-goto-chain-action.patch

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