]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
tc: move RED flag printing to helper
authorJakub Kicinski <jakub.kicinski@netronome.com>
Mon, 19 Nov 2018 23:03:30 +0000 (15:03 -0800)
committerDavid Ahern <dsahern@gmail.com>
Sat, 24 Nov 2018 15:10:58 +0000 (07:10 -0800)
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@netronome.com>
Reviewed-by: Quentin Monnet <quentin.monnet@netronome.com>
Signed-off-by: David Ahern <dsahern@gmail.com>
tc/q_choke.c
tc/q_red.c
tc/q_sfq.c
tc/tc_red.c
tc/tc_red.h

index b269b1338b6d92377645cc65dc542c6a454dc2a6..1353c80c806ba1bea44ce3c066c51166cca480ec 100644 (file)
@@ -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);
index 49fd4ac8051309189526a48d5c008a83687bfa90..3b3a1204198979d2392ba344ea3c7a5584441064 100644 (file)
@@ -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)
index 6a1d853b7c9351534836f20f1d2c86e47369d9e1..eee31ec54d331976abcda8d7b2b995aa43794f73 100644 (file)
@@ -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,
index 178fe088f73260711e5ed1e9bc31644334918b59..3ce3ca4287d3f6441740af34e9fb55d1d64c2baf 100644 (file)
@@ -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);
+}
index 6c6e6b039732729541c1eb1666256e47245b6484..3882c8310d76cd5576d2c4d722a9efc87f262470 100644 (file)
@@ -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