naccyde / rpms / iproute

Forked from rpms/iproute 9 months ago
Clone

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

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