]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/tc_red.c
tc: m_action: check cookie hex string len
[mirror_iproute2.git] / tc / tc_red.c
index e9b2f0ee3baa5db935e235895262f932aea587be..88f5ff358ce5596cac86790bd9acdd2e4edc278a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * tc_red.c            RED maintanance routines.
+ * tc_red.c            RED maintenance routines.
  *
  *             This program is free software; you can redistribute it and/or
  *             modify it under the terms of the GNU General Public License
@@ -13,7 +13,6 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
-#include <syslog.h>
 #include <fcntl.h>
 #include <math.h>
 #include <sys/socket.h>
@@ -21,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"
 
 /*
@@ -31,7 +32,9 @@ int tc_red_eval_P(unsigned int qmin, unsigned int qmax, double prob)
 {
        int i = qmax - qmin;
 
-       if (i <= 0)
+       if (!i)
+               return 0;
+       if (i < 0)
                return -1;
 
        prob /= i;
@@ -96,3 +99,26 @@ 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);
+
+       if (flags & TC_RED_NODROP)
+               print_bool(PRINT_ANY, "nodrop", "nodrop ", true);
+       else
+               print_bool(PRINT_ANY, "nodrop", NULL, false);
+}