lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181119230335.11771-4-jakub.kicinski@netronome.com>
Date:   Mon, 19 Nov 2018 15:03:30 -0800
From:   Jakub Kicinski <jakub.kicinski@...ronome.com>
To:     dsahern@...il.com, stephen@...workplumber.org
Cc:     oss-drivers@...ronome.com, netdev@...r.kernel.org,
        Jakub Kicinski <jakub.kicinski@...ronome.com>
Subject: [PATCH iproute2-next 3/8] tc: move RED flag printing to helper

Number of qdiscs use the same set of flags to control shared RED
implementation.  Add a helper for printing those flags.

Signed-off-by: Jakub Kicinski <jakub.kicinski@...ronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@...ronome.com>
---
 tc/q_choke.c |  3 +--
 tc/q_red.c   | 14 ++------------
 tc/q_sfq.c   |  3 +--
 tc/tc_red.c  | 20 ++++++++++++++++++++
 tc/tc_red.h  |  1 +
 5 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/tc/q_choke.c b/tc/q_choke.c
index b269b1338b6d..1353c80c806b 100644
--- a/tc/q_choke.c
+++ b/tc/q_choke.c
@@ -188,8 +188,7 @@ static int choke_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	fprintf(f, "limit %up min %up max %up ",
 		qopt->limit, qopt->qth_min, qopt->qth_max);
 
-	if (qopt->flags & TC_RED_ECN)
-		fprintf(f, "ecn ");
+	tc_red_print_flags(qopt->flags);
 
 	if (show_details) {
 		fprintf(f, "ewma %u ", qopt->Wlog);
diff --git a/tc/q_red.c b/tc/q_red.c
index 49fd4ac80513..3b3a12041989 100644
--- a/tc/q_red.c
+++ b/tc/q_red.c
@@ -189,18 +189,8 @@ static int red_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 	print_uint(PRINT_JSON, "max", NULL, qopt->qth_max);
 	print_string(PRINT_FP, NULL, "max %s ", sprint_size(qopt->qth_max, b3));
 
-	if (qopt->flags & TC_RED_ECN)
-		print_bool(PRINT_ANY, "ecn", "ecn ", true);
-	else
-		print_bool(PRINT_ANY, "ecn", NULL, false);
-	if (qopt->flags & TC_RED_HARDDROP)
-		print_bool(PRINT_ANY, "harddrop", "harddrop ", true);
-	else
-		print_bool(PRINT_ANY, "harddrop", NULL, false);
-	if (qopt->flags & TC_RED_ADAPTATIVE)
-		print_bool(PRINT_ANY, "adaptive", "adaptive ", true);
-	else
-		print_bool(PRINT_ANY, "adaptive", NULL, false);
+	tc_red_print_flags(qopt->flags);
+
 	if (show_details) {
 		print_uint(PRINT_ANY, "ewma", "ewma %u ", qopt->Wlog);
 		if (max_P)
diff --git a/tc/q_sfq.c b/tc/q_sfq.c
index 6a1d853b7c93..eee31ec54d33 100644
--- a/tc/q_sfq.c
+++ b/tc/q_sfq.c
@@ -235,8 +235,7 @@ static int sfq_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
 			sprint_size(qopt_ext->qth_min, b2),
 			sprint_size(qopt_ext->qth_max, b3),
 			qopt_ext->max_P / pow(2, 32));
-		if (qopt_ext->flags & TC_RED_ECN)
-			fprintf(f, "ecn ");
+		tc_red_print_flags(qopt_ext->flags);
 		if (show_stats) {
 			fprintf(f, "\n prob_mark %u prob_mark_head %u prob_drop %u",
 				qopt_ext->stats.prob_mark,
diff --git a/tc/tc_red.c b/tc/tc_red.c
index 178fe088f732..3ce3ca4287d3 100644
--- a/tc/tc_red.c
+++ b/tc/tc_red.c
@@ -20,7 +20,9 @@
 #include <arpa/inet.h>
 #include <string.h>
 
+#include "utils.h"
 #include "tc_core.h"
+#include "tc_util.h"
 #include "tc_red.h"
 
 /*
@@ -97,3 +99,21 @@ int tc_red_eval_idle_damping(int Wlog, unsigned int avpkt, unsigned int bps, __u
 	sbuf[255] = 31;
 	return clog;
 }
+
+void tc_red_print_flags(__u32 flags)
+{
+	if (flags & TC_RED_ECN)
+		print_bool(PRINT_ANY, "ecn", "ecn ", true);
+	else
+		print_bool(PRINT_ANY, "ecn", NULL, false);
+
+	if (flags & TC_RED_HARDDROP)
+		print_bool(PRINT_ANY, "harddrop", "harddrop ", true);
+	else
+		print_bool(PRINT_ANY, "harddrop", NULL, false);
+
+	if (flags & TC_RED_ADAPTATIVE)
+		print_bool(PRINT_ANY, "adaptive", "adaptive ", true);
+	else
+		print_bool(PRINT_ANY, "adaptive", NULL, false);
+}
diff --git a/tc/tc_red.h b/tc/tc_red.h
index 6c6e6b039732..3882c8310d76 100644
--- a/tc/tc_red.h
+++ b/tc/tc_red.h
@@ -6,5 +6,6 @@ int tc_red_eval_P(unsigned qmin, unsigned qmax, double prob);
 int tc_red_eval_ewma(unsigned qmin, unsigned burst, unsigned avpkt);
 int tc_red_eval_idle_damping(int wlog, unsigned avpkt, unsigned bandwidth,
 			     __u8 *sbuf);
+void tc_red_print_flags(__u32 flags);
 
 #endif
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ