Blame SOURCES/0135-tc-don-t-print-error-message-on-miss-when-parsing-ac.patch

99be8f
From 8efbb8de949eedd4341d075175f932245a9f142c Mon Sep 17 00:00:00 2001
99be8f
From: Andrea Claudi <aclaudi@redhat.com>
99be8f
Date: Wed, 5 Jun 2019 13:11:03 +0200
99be8f
Subject: [PATCH] tc: don't print error message on miss when parsing action
99be8f
 with default
99be8f
99be8f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1714660
99be8f
Upstream Status: iproute2.git commit c794b7b179026
99be8f
99be8f
commit c794b7b17902627b19ddc00699d89ea7b6b1edf7
99be8f
Author: Jiri Pirko <jiri@mellanox.com>
99be8f
Date:   Thu Jun 15 14:10:51 2017 +0200
99be8f
99be8f
    tc: don't print error message on miss when parsing action with default
99be8f
99be8f
    In case default control action parsing takes place, it is ok to miss.
99be8f
    So don't print error message.
99be8f
99be8f
    Fixes: e67aba559581 ("tc: actions: add helpers to parse and print control actions")
99be8f
    Reported-by: Jiri Benc <jbenc@redhat.com>
99be8f
    Signed-off-by: Jiri Pirko <jiri@mellanox.com>
99be8f
    Tested-by: Jiri Benc <jbenc@redhat.com>
99be8f
---
99be8f
 tc/tc_util.c | 36 ++++++++++++++++++++++--------------
99be8f
 1 file changed, 22 insertions(+), 14 deletions(-)
99be8f
99be8f
diff --git a/tc/tc_util.c b/tc/tc_util.c
99be8f
index 194185a0fa1d8..cdc23477ada53 100644
99be8f
--- a/tc/tc_util.c
99be8f
+++ b/tc/tc_util.c
99be8f
@@ -477,18 +477,8 @@ static int action_a2n(char *arg, int *result, bool allow_num)
99be8f
 	return 0;
99be8f
 }
99be8f
 
99be8f
-/* Parse action control including possible options.
99be8f
- *
99be8f
- * Parameters:
99be8f
- * @argc_p - pointer to argc to parse
99be8f
- * @argv_p - pointer to argv to parse
99be8f
- * @result_p - pointer to output variable
99be8f
- * @allow_num - whether action may be in numeric format already
99be8f
- *
99be8f
- * In error case, returns -1 and does not touch @result_1p. Otherwise returns 0.
99be8f
- */
99be8f
-int parse_action_control(int *argc_p, char ***argv_p,
99be8f
-			 int *result_p, bool allow_num)
99be8f
+static int __parse_action_control(int *argc_p, char ***argv_p, int *result_p,
99be8f
+				  bool allow_num, bool ignore_a2n_miss)
99be8f
 {
99be8f
 	int argc = *argc_p;
99be8f
 	char **argv = *argv_p;
99be8f
@@ -497,7 +487,8 @@ int parse_action_control(int *argc_p, char ***argv_p,
99be8f
 	if (!argc)
99be8f
 		return -1;
99be8f
 	if (action_a2n(*argv, &result, allow_num) == -1) {
99be8f
-		fprintf(stderr, "Bad action type %s\n", *argv);
99be8f
+		if (!ignore_a2n_miss)
99be8f
+			fprintf(stderr, "Bad action type %s\n", *argv);
99be8f
 		return -1;
99be8f
 	}
99be8f
 	if (result == TC_ACT_GOTO_CHAIN) {
99be8f
@@ -523,6 +514,23 @@ int parse_action_control(int *argc_p, char ***argv_p,
99be8f
 	return 0;
99be8f
 }
99be8f
 
99be8f
+/* Parse action control including possible options.
99be8f
+ *
99be8f
+ * Parameters:
99be8f
+ * @argc_p - pointer to argc to parse
99be8f
+ * @argv_p - pointer to argv to parse
99be8f
+ * @result_p - pointer to output variable
99be8f
+ * @allow_num - whether action may be in numeric format already
99be8f
+ *
99be8f
+ * In error case, returns -1 and does not touch @result_1p. Otherwise returns 0.
99be8f
+ */
99be8f
+int parse_action_control(int *argc_p, char ***argv_p,
99be8f
+			 int *result_p, bool allow_num)
99be8f
+{
99be8f
+	return __parse_action_control(argc_p, argv_p, result_p,
99be8f
+				      allow_num, false);
99be8f
+}
99be8f
+
99be8f
 /* Parse action control including possible options.
99be8f
  *
99be8f
  * Parameters:
99be8f
@@ -538,7 +546,7 @@ void parse_action_control_dflt(int *argc_p, char ***argv_p,
99be8f
 			       int *result_p, bool allow_num,
99be8f
 			       int default_result)
99be8f
 {
99be8f
-	if (parse_action_control(argc_p, argv_p, result_p, allow_num))
99be8f
+	if (__parse_action_control(argc_p, argv_p, result_p, allow_num, true))
99be8f
 		*result_p = default_result;
99be8f
 }
99be8f
 
99be8f
-- 
99be8f
2.20.1
99be8f