<div dir="ltr">I had figured I could override the default iproute2 with the one in ceropackages with:<br><br>./scripts/feeds install -f -p cero iproute2<br><div><div class="gmail_extra"><br></div><div class="gmail_extra">But so far no luck. Tried removing and installing, no luck either. ?<br><br></div><div class="gmail_extra">Aside from that I have kmod-sched-fq_pie and kmod-sched-cake building, at least, and everything<br></div><div class="gmail_extra">else wrapped up for a test build of chaos calmer with all the new stuff.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Will try harder in the morning, brute forcing if I have to.<br><br></div><div class="gmail_extra"><div class="gmail_quote">On Fri, May 1, 2015 at 9:09 AM, Kevin Darbyshire-Bryant <span dir="ltr"><<a href="mailto:kevin@darbyshire-bryant.me.uk" target="_blank">kevin@darbyshire-bryant.me.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hi Dave,<br>
    <br>
    Forwarding to you in case it helps.  Replied to the list but my
    emails appear to stuck somewhere.<br>
    <br>
    Kevin<br>
    <div><br>
      <br>
      -------- Forwarded Message --------
      <table cellpadding="0" cellspacing="0" border="0">
        <tbody>
          <tr>
            <th valign="BASELINE" align="RIGHT" nowrap>Subject:
            </th>
            <td>Re: [Cerowrt-devel] [Cake] documentation review request
              and out of tree cake builds for openwrt/etc.</td>
          </tr>
          <tr>
            <th valign="BASELINE" align="RIGHT" nowrap>Date: </th>
            <td>Fri, 01 May 2015 10:50:25 +0100</td>
          </tr>
          <tr>
            <th valign="BASELINE" align="RIGHT" nowrap>From: </th>
            <td>Kevin Darbyshire-Bryant
              <a href="mailto:kevin@darbyshire-bryant.me.uk" target="_blank"><kevin@darbyshire-bryant.me.uk></a></td>
          </tr>
          <tr>
            <th valign="BASELINE" align="RIGHT" nowrap>To: </th>
            <td><a href="mailto:cerowrt-devel@lists.bufferbloat.net" target="_blank">cerowrt-devel@lists.bufferbloat.net</a></td>
          </tr>
        </tbody>
      </table>
      <br>
      <br>
      <pre>On 30/04/2015 16:17, Dave Taht wrote:
> On Thu, Apr 30, 2015 at 7:38 AM, Jonathan Morton <a href="mailto:chromatix99@gmail.com" target="_blank"><chromatix99@gmail.com></a> wrote:
>> It took me a while to get around to thinking about this, partly because my
>> phone inexplicably refuses to believe snapon exists.
> It has an old dnssec signed dns tree, using the isc dlv, which turned
> out to somewhat break older versions of dnsmasq, if that helps any.
OpenWrt CC trunk is now up to dnsmasq2.73rc7 - the latest fix was for a dnssec fallback to tcp
problem.  Highly recommended.
> So the next step for me is to get cake working in openwrt on hardware fast enough to run at 110Mbit and returning to the yurtlab to try it... but that won't be til sunday at best. Tho I almost got it built, at least, last night. Still sorting through patches....
I have no idea if this will help you guys.  I was fiddling with getting cake into CC a little earlier
based on the web page instructions.  My totally unsubtle approach was to basically copy over
relevant cerowrt-3.10 packages into the CC build tree:

ceropackages-3.10/net/sqm-scripts openwrt/package/feeds/packages/sqm-scripts
ceropackages-3.10/net/kmod-sched-cake openwrt/feeds/packages/net/kmod-sched-cake *

ceropackages-3.10/luci/luci-app-sqm openwrt/package/feeds/packages/luci-app-sqm

iproute2 140&141 patches to openwrt/package/network/utils/iproute2/patches

You'll need to put a symlink from openwrt/package/feeds/packages/kmod-sched-cake to
openwrt/feeds/packages/net/kmod-sched-cake

* note different directory!

Also to get iproute2 tc to understand cake I basically did a git diff on toke's iproute-cake
vs iproute 4.0.0 which is where CC currently is:  Result 2 patches, 140 & 141, 1st is to get
cake in, the 2nd is to do the required tc makefile tweak.  CC builds, runs on Archer C7,
nothing obviously exploded or broken...yet... your mileage may vary!  VERY VERY
UNTESTED, DRAGONS LURK, I'M AN IDIOT AND DON'T REALLY KNOW WHAT I'M DOING.
Is that clear enough? :-)

Maybe it helps.  What I will say is that a dslreports test appears less jittery for me.

Kevin



141-cake-disable-sfq-codel.patch

diff --git a/tc/Makefile b/tc/Makefile
index e503c8a..3dce533 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -61,7 +61,7 @@ TCMODULES += q_codel.o
 TCMODULES += q_fq_codel.o
 TCMODULES += q_nfq_codel.o
 TCMODULES += q_efq_codel.o
-TCMODULES += q_sfq_codel.o
+#TCMODULES += q_sfq_codel.o
 TCMODULES += q_pfq_codel.o
 TCMODULES += q_ns2_codel.o
 TCMODULES += q_ns4_codel.o


140-cake-add-support.patch

diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
index 534b847..a1d7b67 100644
--- a/include/linux/pkt_sched.h
+++ b/include/linux/pkt_sched.h
@@ -845,4 +845,38 @@ struct tc_pie_xstats {
     __u32 maxq;             /* maximum queue size */
     __u32 ecn_mark;         /* packets marked with ecn*/
 };
+
+/* CAKE */
+enum {
+    TCA_CAKE_UNSPEC,
+    TCA_CAKE_BASE_RATE,
+    TCA_CAKE_DIFFSERV_MODE,
+    TCA_CAKE_ATM,
+    TCA_CAKE_FLOW_MODE,
+    __TCA_CAKE_MAX
+};
+#define TCA_CAKE_MAX    (__TCA_CAKE_MAX - 1)
+
+struct tc_cake_xstats {
+    __u16 type;  /* constant magic 0xCAFE */
+    __u16 class_cnt;
+    struct {
+        __u32 rate;
+        __u32 target_us;
+        __u32 packets;
+        __u32 interval_us;
+        __u64 bytes;
+        __u32 dropped;
+        __u32 ecn_marked;
+        __u32 way_indirect_hits;
+        __u32 way_misses;
+        __u32 way_collisions;
+        __u32 backlog_bytes;
+        __u32 peak_delay; /* delay to fat flows */
+        __u32 avge_delay;
+        __u32 base_delay; /* delay to sparse flows */
+        __u32 dummy2;
+    } cls[8];
+};
+
 #endif
diff --git a/tc/Makefile b/tc/Makefile
index d831a15..e503c8a 100644
--- a/tc/Makefile
+++ b/tc/Makefile
@@ -59,8 +59,17 @@ TCMODULES += em_meta.o
 TCMODULES += q_mqprio.o
 TCMODULES += q_codel.o
 TCMODULES += q_fq_codel.o
+TCMODULES += q_nfq_codel.o
+TCMODULES += q_efq_codel.o
+TCMODULES += q_sfq_codel.o
+TCMODULES += q_pfq_codel.o
+TCMODULES += q_ns2_codel.o
+TCMODULES += q_ns4_codel.o
 TCMODULES += q_fq.o
 TCMODULES += q_pie.o
+TCMODULES += q_cake.o
+TCMODULES += q_cake0.o
+TCMODULES += q_cake2.o
 TCMODULES += q_hhf.o
 
 ifeq ($(TC_CONFIG_IPSET), y)
diff --git a/tc/q_cake.c b/tc/q_cake.c
new file mode 100644
index 0000000..d9415d3
--- /dev/null
+++ b/tc/q_cake.c
@@ -0,0 +1,333 @@
+/*
+ * Common Applications Kept Enhanced  --  CAKE
+ *
+ *  Copyright (C) 2014-2015 Jonathan Morton <a href="mailto:chromatix99@gmail.com" target="_blank"><chromatix99@gmail.com></a>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+static void explain(void)
+{
+    fprintf(stderr, "Usage: ... cake [ bandwidth RATE | unlimited ]\n"
+                    "                [ besteffort | precedence | diffserv8 | diffserv4 ]\n"
+                    "                [ flowblind | srchost | dsthost | hosts | flows ]\n"
+                    "                [ atm ]\n");
+}
+
+static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+                  struct nlmsghdr *n)
+{
+    int unlimited = 0;
+    unsigned bandwidth = 0;
+    unsigned diffserv = 0;
+    int flowmode = -1;
+    int atm = -1;
+    struct rtattr *tail;
+
+    while (argc > 0) {
+        if (strcmp(*argv, "bandwidth") == 0) {
+            NEXT_ARG();
+            if (get_rate(&bandwidth, *argv)) {
+                fprintf(stderr, "Illegal \"bandwidth\"\n");
+                return -1;
+            }
+            unlimited = 0;
+        } else if (strcmp(*argv, "unlimited") == 0) {
+            bandwidth = 0;
+            unlimited = 1;
+
+        } else if (strcmp(*argv, "besteffort") == 0) {
+            diffserv = 1;
+        } else if (strcmp(*argv, "precedence") == 0) {
+            diffserv = 2;
+        } else if (strcmp(*argv, "diffserv8") == 0) {
+            diffserv = 3;
+        } else if (strcmp(*argv, "diffserv4") == 0) {
+            diffserv = 4;
+        } else if (strcmp(*argv, "diffserv") == 0) {
+            diffserv = 4;
+
+        } else if (strcmp(*argv, "flowblind") == 0) {
+            flowmode = 0;
+        } else if (strcmp(*argv, "srchost") == 0) {
+            flowmode = 1;
+        } else if (strcmp(*argv, "dsthost") == 0) {
+            flowmode = 2;
+        } else if (strcmp(*argv, "hosts") == 0) {
+            flowmode = 3;
+        } else if (strcmp(*argv, "flows") == 0) {
+            flowmode = 4;
+
+        } else if (strcmp(*argv, "atm") == 0) {
+            atm = 1;
+        } else if (strcmp(*argv, "noatm") == 0) {
+            atm = 0;
+
+        } else if (strcmp(*argv, "help") == 0) {
+            explain();
+            return -1;
+        } else {
+            fprintf(stderr, "What is \"%s\"?\n", *argv);
+            explain();
+            return -1;
+        }
+        argc--; argv++;
+    }
+
+    tail = NLMSG_TAIL(n);
+    addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+    if (bandwidth || unlimited)
+        addattr_l(n, 1024, TCA_CAKE_BASE_RATE, &bandwidth, sizeof(bandwidth));
+    if (diffserv)
+        addattr_l(n, 1024, TCA_CAKE_DIFFSERV_MODE, &diffserv, sizeof(diffserv));
+    if (atm != -1)
+        addattr_l(n, 1024, TCA_CAKE_ATM, &atm, sizeof(atm));
+    if (flowmode != -1)
+        addattr_l(n, 1024, TCA_CAKE_FLOW_MODE, &flowmode, sizeof(flowmode));
+    tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+    return 0;
+}
+
+static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+    struct rtattr *tb[TCA_CAKE_MAX + 1];
+    unsigned bandwidth = 0;
+    unsigned diffserv = 0;
+    unsigned flowmode = 0;
+    int atm = -1;
+    SPRINT_BUF(b1);
+
+    if (opt == NULL)
+        return 0;
+
+    parse_rtattr_nested(tb, TCA_CAKE_MAX, opt);
+
+    if (tb[TCA_CAKE_BASE_RATE] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_BASE_RATE]) >= sizeof(__u32)) {
+        bandwidth = rta_getattr_u32(tb[TCA_CAKE_BASE_RATE]);
+        if(bandwidth)
+            fprintf(f, "bandwidth %s ", sprint_rate(bandwidth, b1));
+        else
+            fprintf(f, "unlimited ");
+    }
+    if (tb[TCA_CAKE_DIFFSERV_MODE] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_DIFFSERV_MODE]) >= sizeof(__u32)) {
+        diffserv = rta_getattr_u32(tb[TCA_CAKE_DIFFSERV_MODE]);
+        switch(diffserv) {
+        case 1:
+            fprintf(f, "besteffort ");
+            break;
+        case 2:
+            fprintf(f, "precedence ");
+            break;
+        case 3:
+            fprintf(f, "diffserv8 ");
+            break;
+        case 4:
+            fprintf(f, "diffserv4 ");
+            break;
+        default:
+            fprintf(f, "(?diffserv?) ");
+            break;
+        };
+    }
+    if (tb[TCA_CAKE_FLOW_MODE] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) {
+        flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]);
+        switch(flowmode) {
+        case 0:
+            fprintf(f, "flowblind ");
+            break;
+        case 1:
+            fprintf(f, "srchost ");
+            break;
+        case 2:
+            fprintf(f, "dsthost ");
+            break;
+        case 3:
+            fprintf(f, "hosts ");
+            break;
+        case 4:
+            fprintf(f, "flows ");
+            break;
+        default:
+            fprintf(f, "(?flowmode?) ");
+            break;
+        };
+    }
+    if (tb[TCA_CAKE_ATM] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) {
+        atm = rta_getattr_u32(tb[TCA_CAKE_ATM]);
+        if (atm)
+            fprintf(f, "atm ");
+    }
+
+    return 0;
+}
+
+static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
+                 struct rtattr *xstats)
+{
+    /* fq_codel stats format borrowed */
+    struct tc_fq_codel_xstats *st;
+    struct tc_cake_xstats     *stc;
+    SPRINT_BUF(b1);
+
+    if (xstats == NULL)
+        return 0;
+
+    if (RTA_PAYLOAD(xstats) < sizeof(st->type))
+        return -1;
+
+    st  = RTA_DATA(xstats);
+    stc = RTA_DATA(xstats);
+
+    if (st->type == TCA_FQ_CODEL_XSTATS_QDISC && RTA_PAYLOAD(xstats) >= sizeof(*st)) {
+        fprintf(f, "  maxpacket %u drop_overlimit %u new_flow_count %u ecn_mark %u",
+            st->qdisc_stats.maxpacket,
+            st->qdisc_stats.drop_overlimit,
+            st->qdisc_stats.new_flow_count,
+            st->qdisc_stats.ecn_mark);
+        fprintf(f, "\n  new_flows_len %u old_flows_len %u",
+            st->qdisc_stats.new_flows_len,
+            st->qdisc_stats.old_flows_len);
+    } else if (st->type == TCA_FQ_CODEL_XSTATS_CLASS && RTA_PAYLOAD(xstats) >= sizeof(*st)) {
+        fprintf(f, "  deficit %d count %u lastcount %u ldelay %s",
+            st->class_stats.deficit,
+            st->class_stats.count,
+            st->class_stats.lastcount,
+            sprint_time(st->class_stats.ldelay, b1));
+        if (st->class_stats.dropping) {
+            fprintf(f, " dropping");
+            if (st->class_stats.drop_next < 0)
+                fprintf(f, " drop_next -%s",
+                    sprint_time(-st->class_stats.drop_next, b1));
+            else
+                fprintf(f, " drop_next %s",
+                    sprint_time(st->class_stats.drop_next, b1));
+        }
+    } else if (stc->type == 0xCAFE && RTA_PAYLOAD(xstats) >= sizeof(*stc)) {
+        int i;
+
+        fprintf(f, "        ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "   Class %u  ", i);
+        fprintf(f, "\n");
+
+        fprintf(f, "  rate  ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12s", sprint_rate(stc->cls[i].rate, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "  target");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12s", sprint_time(stc->cls[i].target_us, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "interval");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12s", sprint_time(stc->cls[i].interval_us, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "Pk delay");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12s", sprint_time(stc->cls[i].peak_delay, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "Av delay");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12s", sprint_time(stc->cls[i].avge_delay, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "Sp delay");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12s", sprint_time(stc->cls[i].base_delay, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "  pkts  ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12u", stc->cls[i].packets);
+        fprintf(f, "\n");
+
+        fprintf(f, "way inds");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12u", stc->cls[i].way_indirect_hits);
+        fprintf(f, "\n");
+
+        fprintf(f, "way miss");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12u", stc->cls[i].way_misses);
+        fprintf(f, "\n");
+
+        fprintf(f, "way cols");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12u", stc->cls[i].way_collisions);
+        fprintf(f, "\n");
+
+        fprintf(f, "  bytes ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12llu", stc->cls[i].bytes);
+        fprintf(f, "\n");
+
+        fprintf(f, "  drops ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12u", stc->cls[i].dropped);
+        fprintf(f, "\n");
+
+        fprintf(f, "  marks ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%12u", stc->cls[i].ecn_marked);
+    } else {
+        return -1;
+    }
+    return 0;
+}
+
+struct qdisc_util cake_qdisc_util = {
+    .id        = "cake",
+    .parse_qopt    = cake_parse_opt,
+    .print_qopt    = cake_print_opt,
+    .print_xstats    = cake_print_xstats,
+};
diff --git a/tc/q_cake0.c b/tc/q_cake0.c
new file mode 100644
index 0000000..9fb63ed
--- /dev/null
+++ b/tc/q_cake0.c
@@ -0,0 +1,301 @@
+/*
+ * Common Applications Kept Enhanced  --  CAKE
+ *
+ *  Copyright (C) 2014 Jonathan Morton <a href="mailto:chromatix99@gmail.com" target="_blank"><chromatix99@gmail.com></a>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+static void explain(void)
+{
+    fprintf(stderr, "Usage: ... cake0 [ bandwidth RATE | unlimited ]\n"
+                    "                 [ besteffort | precedence | diffserv ]\n"
+                    "                 [ flowblind | srchost | dsthost | hosts | flows ]\n"
+                    "                 [ atm ]\n");
+}
+
+static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+                  struct nlmsghdr *n)
+{
+    int unlimited = 0;
+    unsigned bandwidth = 0;
+    unsigned diffserv = 0;
+    int flowmode = -1;
+    int atm = -1;
+    struct rtattr *tail;
+
+    while (argc > 0) {
+        if (strcmp(*argv, "bandwidth") == 0) {
+            NEXT_ARG();
+            if (get_rate(&bandwidth, *argv)) {
+                fprintf(stderr, "Illegal \"bandwidth\"\n");
+                return -1;
+            }
+            unlimited = 0;
+        } else if (strcmp(*argv, "unlimited") == 0) {
+            bandwidth = 0;
+            unlimited = 1;
+
+        } else if (strcmp(*argv, "besteffort") == 0) {
+            diffserv = 1;
+        } else if (strcmp(*argv, "precedence") == 0) {
+            diffserv = 2;
+        } else if (strcmp(*argv, "diffserv") == 0) {
+            diffserv = 3;
+
+        } else if (strcmp(*argv, "flowblind") == 0) {
+            flowmode = 0;
+        } else if (strcmp(*argv, "srchost") == 0) {
+            flowmode = 1;
+        } else if (strcmp(*argv, "dsthost") == 0) {
+            flowmode = 2;
+        } else if (strcmp(*argv, "hosts") == 0) {
+            flowmode = 3;
+        } else if (strcmp(*argv, "flows") == 0) {
+            flowmode = 4;
+
+        } else if (strcmp(*argv, "atm") == 0) {
+            atm = 1;
+        } else if (strcmp(*argv, "noatm") == 0) {
+            atm = 0;
+
+        } else if (strcmp(*argv, "help") == 0) {
+            explain();
+            return -1;
+        } else {
+            fprintf(stderr, "What is \"%s\"?\n", *argv);
+            explain();
+            return -1;
+        }
+        argc--; argv++;
+    }
+
+    tail = NLMSG_TAIL(n);
+    addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+    if (bandwidth || unlimited)
+        addattr_l(n, 1024, TCA_CAKE_BASE_RATE, &bandwidth, sizeof(bandwidth));
+    if (diffserv)
+        addattr_l(n, 1024, TCA_CAKE_DIFFSERV_MODE, &diffserv, sizeof(diffserv));
+    if (atm != -1)
+        addattr_l(n, 1024, TCA_CAKE_ATM, &atm, sizeof(atm));
+    if (flowmode != -1)
+        addattr_l(n, 1024, TCA_CAKE_FLOW_MODE, &flowmode, sizeof(flowmode));
+    tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+    return 0;
+}
+
+static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+    struct rtattr *tb[TCA_CAKE_MAX + 1];
+    unsigned bandwidth = 0;
+    unsigned diffserv = 0;
+    unsigned flowmode = 0;
+    int atm = -1;
+    SPRINT_BUF(b1);
+
+    if (opt == NULL)
+        return 0;
+
+    parse_rtattr_nested(tb, TCA_CAKE_MAX, opt);
+
+    if (tb[TCA_CAKE_BASE_RATE] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_BASE_RATE]) >= sizeof(__u32)) {
+        bandwidth = rta_getattr_u32(tb[TCA_CAKE_BASE_RATE]);
+        if(bandwidth)
+            fprintf(f, "bandwidth %s ", sprint_rate(bandwidth, b1));
+        else
+            fprintf(f, "unlimited");
+    }
+    if (tb[TCA_CAKE_DIFFSERV_MODE] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_DIFFSERV_MODE]) >= sizeof(__u32)) {
+        diffserv = rta_getattr_u32(tb[TCA_CAKE_DIFFSERV_MODE]);
+        switch(diffserv) {
+        case 1:
+            fprintf(f, "besteffort ");
+            break;
+        case 2:
+            fprintf(f, "precedence ");
+            break;
+        case 3:
+            fprintf(f, "diffserv ");
+            break;
+        default:
+            fprintf(f, "(?diffserv?) ");
+            break;
+        };
+    }
+    if (tb[TCA_CAKE_FLOW_MODE] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) {
+        flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]);
+        switch(flowmode) {
+        case 0:
+            fprintf(f, "flowblind ");
+            break;
+        case 1:
+            fprintf(f, "srchost ");
+            break;
+        case 2:
+            fprintf(f, "dsthost ");
+            break;
+        case 3:
+            fprintf(f, "hosts ");
+            break;
+        case 4:
+            fprintf(f, "flows ");
+            break;
+        default:
+            fprintf(f, "(?flowmode?) ");
+            break;
+        };
+    }
+    if (tb[TCA_CAKE_ATM] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) {
+        atm = rta_getattr_u32(tb[TCA_CAKE_ATM]);
+        if (atm)
+            fprintf(f, "atm ");
+    }
+
+    return 0;
+}
+
+static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
+                 struct rtattr *xstats)
+{
+    /* fq_codel stats format borrowed */
+    struct tc_fq_codel_xstats *st;
+    struct tc_cake_xstats     *stc;
+    SPRINT_BUF(b1);
+
+    if (xstats == NULL)
+        return 0;
+
+    if (RTA_PAYLOAD(xstats) < sizeof(st->type))
+        return -1;
+
+    st  = RTA_DATA(xstats);
+    stc = RTA_DATA(xstats);
+
+    if (st->type == TCA_FQ_CODEL_XSTATS_QDISC && RTA_PAYLOAD(xstats) >= sizeof(*st)) {
+        fprintf(f, "  maxpacket %u drop_overlimit %u new_flow_count %u ecn_mark %u",
+            st->qdisc_stats.maxpacket,
+            st->qdisc_stats.drop_overlimit,
+            st->qdisc_stats.new_flow_count,
+            st->qdisc_stats.ecn_mark);
+        fprintf(f, "\n  new_flows_len %u old_flows_len %u",
+            st->qdisc_stats.new_flows_len,
+            st->qdisc_stats.old_flows_len);
+    } else if (st->type == TCA_FQ_CODEL_XSTATS_CLASS && RTA_PAYLOAD(xstats) >= sizeof(*st)) {
+        fprintf(f, "  deficit %d count %u lastcount %u ldelay %s",
+            st->class_stats.deficit,
+            st->class_stats.count,
+            st->class_stats.lastcount,
+            sprint_time(st->class_stats.ldelay, b1));
+        if (st->class_stats.dropping) {
+            fprintf(f, " dropping");
+            if (st->class_stats.drop_next < 0)
+                fprintf(f, " drop_next -%s",
+                    sprint_time(-st->class_stats.drop_next, b1));
+            else
+                fprintf(f, " drop_next %s",
+                    sprint_time(st->class_stats.drop_next, b1));
+        }
+    } else if (stc->type == 0xCAFE && RTA_PAYLOAD(xstats) >= sizeof(*stc)) {
+        int i;
+
+        fprintf(f, "        ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "  Class %u ", i);
+        fprintf(f, "\n");
+
+        fprintf(f, "  rate  ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10s", sprint_rate(stc->cls[i].rate, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "  target");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10s", sprint_time(stc->cls[i].target_us, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "interval");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10s", sprint_time(stc->cls[i].interval_us, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "  delay ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10s", sprint_time(stc->cls[i].peak_delay, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "  pkts  ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10u", stc->cls[i].packets);
+        fprintf(f, "\n");
+
+        fprintf(f, "  bytes ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10llu", stc->cls[i].bytes);
+        fprintf(f, "\n");
+
+        fprintf(f, "  drops ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10u", stc->cls[i].dropped);
+        fprintf(f, "\n");
+
+        fprintf(f, "  marks ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10u", stc->cls[i].ecn_marked);
+    } else {
+        return -1;
+    }
+    return 0;
+}
+
+struct qdisc_util cake0_qdisc_util = {
+    .id        = "cake0",
+    .parse_qopt    = cake_parse_opt,
+    .print_qopt    = cake_print_opt,
+    .print_xstats    = cake_print_xstats,
+};
diff --git a/tc/q_cake2.c b/tc/q_cake2.c
new file mode 100644
index 0000000..a4d3f7c
--- /dev/null
+++ b/tc/q_cake2.c
@@ -0,0 +1,296 @@
+/*
+ * Common Applications Kept Enhanced  --  CAKE
+ *
+ *  Copyright (C) 2014 Jonathan Morton <a href="mailto:chromatix99@gmail.com" target="_blank"><chromatix99@gmail.com></a>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+static void explain(void)
+{
+    fprintf(stderr, "Usage: ... cake2 [ bandwidth RATE | unlimited ]\n"
+                    "                [ besteffort | precedence | diffserv ]\n"
+                    "                [ flowblind | srchost | dsthost | hosts | flows ]\n"
+                    "                [ atm ]\n");
+}
+
+static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+                  struct nlmsghdr *n)
+{
+    int unlimited = 0;
+    unsigned bandwidth = 0;
+    unsigned diffserv = 0;
+    int flowmode = -1;
+    int atm = -1;
+    struct rtattr *tail;
+
+    while (argc > 0) {
+        if (strcmp(*argv, "bandwidth") == 0) {
+            NEXT_ARG();
+            if (get_rate(&bandwidth, *argv)) {
+                fprintf(stderr, "Illegal \"bandwidth\"\n");
+                return -1;
+            }
+            unlimited = 0;
+        } else if (strcmp(*argv, "unlimited") == 0) {
+            bandwidth = 0;
+            unlimited = 1;
+
+        } else if (strcmp(*argv, "besteffort") == 0) {
+            diffserv = 1;
+        } else if (strcmp(*argv, "precedence") == 0) {
+            diffserv = 2;
+        } else if (strcmp(*argv, "diffserv") == 0) {
+            diffserv = 3;
+
+        } else if (strcmp(*argv, "flowblind") == 0) {
+            flowmode = 0;
+        } else if (strcmp(*argv, "srchost") == 0) {
+            flowmode = 1;
+        } else if (strcmp(*argv, "dsthost") == 0) {
+            flowmode = 2;
+        } else if (strcmp(*argv, "hosts") == 0) {
+            flowmode = 3;
+        } else if (strcmp(*argv, "flows") == 0) {
+            flowmode = 4;
+
+        } else if (strcmp(*argv, "atm") == 0) {
+            atm = 1;
+        } else if (strcmp(*argv, "noatm") == 0) {
+            atm = 0;
+
+        } else if (strcmp(*argv, "help") == 0) {
+            explain();
+            return -1;
+        } else {
+            fprintf(stderr, "What is \"%s\"?\n", *argv);
+            explain();
+            return -1;
+        }
+        argc--; argv++;
+    }
+
+    tail = NLMSG_TAIL(n);
+    addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+    if (bandwidth || unlimited)
+        addattr_l(n, 1024, TCA_CAKE_BASE_RATE, &bandwidth, sizeof(bandwidth));
+    if (diffserv)
+        addattr_l(n, 1024, TCA_CAKE_DIFFSERV_MODE, &diffserv, sizeof(diffserv));
+    if (atm != -1)
+        addattr_l(n, 1024, TCA_CAKE_ATM, &atm, sizeof(atm));
+    if (flowmode != -1)
+        addattr_l(n, 1024, TCA_CAKE_FLOW_MODE, &flowmode, sizeof(flowmode));
+    tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+    return 0;
+}
+
+static int cake_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+    struct rtattr *tb[TCA_CAKE_MAX + 1];
+    unsigned bandwidth = 0;
+    unsigned diffserv = 0;
+    unsigned flowmode = 0;
+    int atm = -1;
+    SPRINT_BUF(b1);
+
+    if (opt == NULL)
+        return 0;
+
+    parse_rtattr_nested(tb, TCA_CAKE_MAX, opt);
+
+    if (tb[TCA_CAKE_BASE_RATE] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_BASE_RATE]) >= sizeof(__u32)) {
+        bandwidth = rta_getattr_u32(tb[TCA_CAKE_BASE_RATE]);
+        if(bandwidth)
+            fprintf(f, "bandwidth %s ", sprint_rate(bandwidth, b1));
+        else
+            fprintf(f, "unlimited");
+    }
+    if (tb[TCA_CAKE_DIFFSERV_MODE] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_DIFFSERV_MODE]) >= sizeof(__u32)) {
+        diffserv = rta_getattr_u32(tb[TCA_CAKE_DIFFSERV_MODE]);
+        switch(diffserv) {
+        case 1:
+            fprintf(f, "besteffort ");
+            break;
+        case 2:
+            fprintf(f, "precedence ");
+            break;
+        case 3:
+            fprintf(f, "diffserv ");
+            break;
+        default:
+            fprintf(f, "(?diffserv?) ");
+            break;
+        };
+    }
+    if (tb[TCA_CAKE_FLOW_MODE] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) {
+        flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]);
+        switch(flowmode) {
+        case 0:
+            fprintf(f, "flowblind ");
+            break;
+        case 1:
+            fprintf(f, "srchost ");
+            break;
+        case 2:
+            fprintf(f, "dsthost ");
+            break;
+        case 3:
+            fprintf(f, "hosts ");
+            break;
+        case 4:
+            fprintf(f, "flows ");
+            break;
+        default:
+            fprintf(f, "(?flowmode?) ");
+            break;
+        };
+    }
+    if (tb[TCA_CAKE_ATM] &&
+        RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) {
+        atm = rta_getattr_u32(tb[TCA_CAKE_ATM]);
+        if (atm)
+            fprintf(f, "atm ");
+    }
+
+    return 0;
+}
+
+static int cake_print_xstats(struct qdisc_util *qu, FILE *f,
+                 struct rtattr *xstats)
+{
+    /* fq_codel stats format borrowed */
+    struct tc_fq_codel_xstats *st;
+    struct tc_cake_xstats     *stc;
+    SPRINT_BUF(b1);
+
+    if (xstats == NULL)
+        return 0;
+
+    if (RTA_PAYLOAD(xstats) < sizeof(st->type))
+        return -1;
+
+    st  = RTA_DATA(xstats);
+    stc = RTA_DATA(xstats);
+
+    if (st->type == TCA_FQ_CODEL_XSTATS_QDISC && RTA_PAYLOAD(xstats) >= sizeof(*st)) {
+        fprintf(f, "  maxpacket %u drop_overlimit %u new_flow_count %u ecn_mark %u",
+            st->qdisc_stats.maxpacket,
+            st->qdisc_stats.drop_overlimit,
+            st->qdisc_stats.new_flow_count,
+            st->qdisc_stats.ecn_mark);
+        fprintf(f, "\n  new_flows_len %u old_flows_len %u",
+            st->qdisc_stats.new_flows_len,
+            st->qdisc_stats.old_flows_len);
+    } else if (st->type == TCA_FQ_CODEL_XSTATS_CLASS && RTA_PAYLOAD(xstats) >= sizeof(*st)) {
+        fprintf(f, "  deficit %d count %u lastcount %u ldelay %s",
+            st->class_stats.deficit,
+            st->class_stats.count,
+            st->class_stats.lastcount,
+            sprint_time(st->class_stats.ldelay, b1));
+        if (st->class_stats.dropping) {
+            fprintf(f, " dropping");
+            if (st->class_stats.drop_next < 0)
+                fprintf(f, " drop_next -%s",
+                    sprint_time(-st->class_stats.drop_next, b1));
+            else
+                fprintf(f, " drop_next %s",
+                    sprint_time(st->class_stats.drop_next, b1));
+        }
+    } else if (stc->type == 0xCAFE && RTA_PAYLOAD(xstats) >= sizeof(*stc)) {
+        int i;
+
+        fprintf(f, "        ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "  Class %u ", i);
+        fprintf(f, "\n");
+
+        fprintf(f, "  rate  ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10s", sprint_rate(stc->cls[i].rate, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "  target");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10s", sprint_time(stc->cls[i].target_us, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "interval");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10s", sprint_time(stc->cls[i].interval_us, b1));
+        fprintf(f, "\n");
+
+        fprintf(f, "  pkts  ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10u", stc->cls[i].packets);
+        fprintf(f, "\n");
+
+        fprintf(f, "  bytes ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10llu", stc->cls[i].bytes);
+        fprintf(f, "\n");
+
+        fprintf(f, "  drops ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10u", stc->cls[i].dropped);
+        fprintf(f, "\n");
+
+        fprintf(f, "  marks ");
+        for(i=0; i < stc->class_cnt; i++)
+            fprintf(f, "%10u", stc->cls[i].ecn_marked);
+    } else {
+        return -1;
+    }
+    return 0;
+}
+
+struct qdisc_util cake2_qdisc_util = {
+    .id        = "cake2",
+    .parse_qopt    = cake_parse_opt,
+    .print_qopt    = cake_print_opt,
+    .print_xstats    = cake_print_xstats,
+};
diff --git a/tc/q_efq_codel.c b/tc/q_efq_codel.c
new file mode 100644
index 0000000..b80e5e4
--- /dev/null
+++ b/tc/q_efq_codel.c
@@ -0,0 +1,232 @@
+/*
+ * Fair Queue Codel
+ *
+ *  Copyright (C) 2012 Eric Dumazet <a href="mailto:edumazet@google.com" target="_blank"><edumazet@google.com></a>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+static void explain(void)
+{
+    fprintf(stderr, "Usage: ... efq_codel [ limit PACKETS ] [ flows NUMBER ]\n");
+    fprintf(stderr, "                    [ target TIME] [ interval TIME ]\n");
+    fprintf(stderr, "                    [ quantum BYTES ] [ [no]ecn ]\n");
+}
+
+static int fq_codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+                  struct nlmsghdr *n)
+{
+    unsigned limit = 0;
+    unsigned flows = 0;
+    unsigned target = 0;
+    unsigned interval = 0;
+    unsigned quantum = 0;
+    int ecn = -1;
+    struct rtattr *tail;
+
+    while (argc > 0) {
+        if (strcmp(*argv, "limit") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&limit, *argv, 0)) {
+                fprintf(stderr, "Illegal \"limit\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "flows") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&flows, *argv, 0)) {
+                fprintf(stderr, "Illegal \"flows\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "quantum") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&quantum, *argv, 0)) {
+                fprintf(stderr, "Illegal \"quantum\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "target") == 0) {
+            NEXT_ARG();
+            if (get_time(&target, *argv)) {
+                fprintf(stderr, "Illegal \"target\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "interval") == 0) {
+            NEXT_ARG();
+            if (get_time(&interval, *argv)) {
+                fprintf(stderr, "Illegal \"interval\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "ecn") == 0) {
+            ecn = 1;
+        } else if (strcmp(*argv, "noecn") == 0) {
+            ecn = 0;
+        } else if (strcmp(*argv, "help") == 0) {
+            explain();
+            return -1;
+        } else {
+            fprintf(stderr, "What is \"%s\"?\n", *argv);
+            explain();
+            return -1;
+        }
+        argc--; argv++;
+    }
+
+    tail = NLMSG_TAIL(n);
+    addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+    if (limit)
+        addattr_l(n, 1024, TCA_FQ_CODEL_LIMIT, &limit, sizeof(limit));
+    if (flows)
+        addattr_l(n, 1024, TCA_FQ_CODEL_FLOWS, &flows, sizeof(flows));
+    if (quantum)
+        addattr_l(n, 1024, TCA_FQ_CODEL_QUANTUM, &quantum, sizeof(quantum));
+    if (interval)
+        addattr_l(n, 1024, TCA_FQ_CODEL_INTERVAL, &interval, sizeof(interval));
+    if (target)
+        addattr_l(n, 1024, TCA_FQ_CODEL_TARGET, &target, sizeof(target));
+    if (ecn != -1)
+        addattr_l(n, 1024, TCA_FQ_CODEL_ECN, &ecn, sizeof(ecn));
+    tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+    return 0;
+}
+
+static int fq_codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+    struct rtattr *tb[TCA_FQ_CODEL_MAX + 1];
+    unsigned limit;
+    unsigned flows;
+    unsigned interval;
+    unsigned target;
+    unsigned ecn;
+    unsigned quantum;
+    SPRINT_BUF(b1);
+
+    if (opt == NULL)
+        return 0;
+
+    parse_rtattr_nested(tb, TCA_FQ_CODEL_MAX, opt);
+
+    if (tb[TCA_FQ_CODEL_LIMIT] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_LIMIT]) >= sizeof(__u32)) {
+        limit = rta_getattr_u32(tb[TCA_FQ_CODEL_LIMIT]);
+        fprintf(f, "limit %up ", limit);
+    }
+    if (tb[TCA_FQ_CODEL_FLOWS] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_FLOWS]) >= sizeof(__u32)) {
+        flows = rta_getattr_u32(tb[TCA_FQ_CODEL_FLOWS]);
+        fprintf(f, "flows %u ", flows);
+    }
+    if (tb[TCA_FQ_CODEL_QUANTUM] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_QUANTUM]) >= sizeof(__u32)) {
+        quantum = rta_getattr_u32(tb[TCA_FQ_CODEL_QUANTUM]);
+        fprintf(f, "quantum %u ", quantum);
+    }
+    if (tb[TCA_FQ_CODEL_TARGET] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_TARGET]) >= sizeof(__u32)) {
+        target = rta_getattr_u32(tb[TCA_FQ_CODEL_TARGET]);
+        fprintf(f, "target %s ", sprint_time(target, b1));
+    }
+    if (tb[TCA_FQ_CODEL_INTERVAL] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_INTERVAL]) >= sizeof(__u32)) {
+        interval = rta_getattr_u32(tb[TCA_FQ_CODEL_INTERVAL]);
+        fprintf(f, "interval %s ", sprint_time(interval, b1));
+    }
+    if (tb[TCA_FQ_CODEL_ECN] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_ECN]) >= sizeof(__u32)) {
+        ecn = rta_getattr_u32(tb[TCA_FQ_CODEL_ECN]);
+        if (ecn)
+            fprintf(f, "ecn ");
+    }
+
+    return 0;
+}
+
+static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
+                 struct rtattr *xstats)
+{
+    struct tc_fq_codel_xstats *st;
+    SPRINT_BUF(b1);
+
+    if (xstats == NULL)
+        return 0;
+
+    if (RTA_PAYLOAD(xstats) < sizeof(*st))
+        return -1;
+
+    st = RTA_DATA(xstats);
+    if (st->type == TCA_FQ_CODEL_XSTATS_QDISC) {
+        fprintf(f, "  maxpacket %u drop_overlimit %u new_flow_count %u ecn_mark %u",
+            st->qdisc_stats.maxpacket,
+            st->qdisc_stats.drop_overlimit,
+            st->qdisc_stats.new_flow_count,
+            st->qdisc_stats.ecn_mark);
+        fprintf(f, "\n  new_flows_len %u old_flows_len %u",
+            st->qdisc_stats.new_flows_len,
+            st->qdisc_stats.old_flows_len);
+    }
+    if (st->type == TCA_FQ_CODEL_XSTATS_CLASS) {
+        fprintf(f, "  deficit %d count %u lastcount %u ldelay %s",
+            st->class_stats.deficit,
+            st->class_stats.count,
+            st->class_stats.lastcount,
+            sprint_time(st->class_stats.ldelay, b1));
+        if (st->class_stats.dropping) {
+            fprintf(f, " dropping");
+            if (st->class_stats.drop_next < 0)
+                fprintf(f, " drop_next -%s",
+                    sprint_time(-st->class_stats.drop_next, b1));
+            else
+                fprintf(f, " drop_next %s",
+                    sprint_time(st->class_stats.drop_next, b1));
+        }
+    }
+    return 0;
+
+}
+
+struct qdisc_util efq_codel_qdisc_util = {
+    .id        = "efq_codel",
+    .parse_qopt    = fq_codel_parse_opt,
+    .print_qopt    = fq_codel_print_opt,
+    .print_xstats    = fq_codel_print_xstats,
+};
diff --git a/tc/q_nfq_codel.c b/tc/q_nfq_codel.c
new file mode 100644
index 0000000..ef24909
--- /dev/null
+++ b/tc/q_nfq_codel.c
@@ -0,0 +1,232 @@
+/*
+ * Fair Queue Codel
+ *
+ *  Copyright (C) 2012 Eric Dumazet <a href="mailto:edumazet@google.com" target="_blank"><edumazet@google.com></a>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+static void explain(void)
+{
+    fprintf(stderr, "Usage: ... nfq_codel [ limit PACKETS ] [ flows NUMBER ]\n");
+    fprintf(stderr, "                    [ target TIME] [ interval TIME ]\n");
+    fprintf(stderr, "                    [ quantum BYTES ] [ [no]ecn ]\n");
+}
+
+static int fq_codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+                  struct nlmsghdr *n)
+{
+    unsigned limit = 0;
+    unsigned flows = 0;
+    unsigned target = 0;
+    unsigned interval = 0;
+    unsigned quantum = 0;
+    int ecn = -1;
+    struct rtattr *tail;
+
+    while (argc > 0) {
+        if (strcmp(*argv, "limit") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&limit, *argv, 0)) {
+                fprintf(stderr, "Illegal \"limit\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "flows") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&flows, *argv, 0)) {
+                fprintf(stderr, "Illegal \"flows\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "quantum") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&quantum, *argv, 0)) {
+                fprintf(stderr, "Illegal \"quantum\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "target") == 0) {
+            NEXT_ARG();
+            if (get_time(&target, *argv)) {
+                fprintf(stderr, "Illegal \"target\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "interval") == 0) {
+            NEXT_ARG();
+            if (get_time(&interval, *argv)) {
+                fprintf(stderr, "Illegal \"interval\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "ecn") == 0) {
+            ecn = 1;
+        } else if (strcmp(*argv, "noecn") == 0) {
+            ecn = 0;
+        } else if (strcmp(*argv, "help") == 0) {
+            explain();
+            return -1;
+        } else {
+            fprintf(stderr, "What is \"%s\"?\n", *argv);
+            explain();
+            return -1;
+        }
+        argc--; argv++;
+    }
+
+    tail = NLMSG_TAIL(n);
+    addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+    if (limit)
+        addattr_l(n, 1024, TCA_FQ_CODEL_LIMIT, &limit, sizeof(limit));
+    if (flows)
+        addattr_l(n, 1024, TCA_FQ_CODEL_FLOWS, &flows, sizeof(flows));
+    if (quantum)
+        addattr_l(n, 1024, TCA_FQ_CODEL_QUANTUM, &quantum, sizeof(quantum));
+    if (interval)
+        addattr_l(n, 1024, TCA_FQ_CODEL_INTERVAL, &interval, sizeof(interval));
+    if (target)
+        addattr_l(n, 1024, TCA_FQ_CODEL_TARGET, &target, sizeof(target));
+    if (ecn != -1)
+        addattr_l(n, 1024, TCA_FQ_CODEL_ECN, &ecn, sizeof(ecn));
+    tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+    return 0;
+}
+
+static int fq_codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+    struct rtattr *tb[TCA_FQ_CODEL_MAX + 1];
+    unsigned limit;
+    unsigned flows;
+    unsigned interval;
+    unsigned target;
+    unsigned ecn;
+    unsigned quantum;
+    SPRINT_BUF(b1);
+
+    if (opt == NULL)
+        return 0;
+
+    parse_rtattr_nested(tb, TCA_FQ_CODEL_MAX, opt);
+
+    if (tb[TCA_FQ_CODEL_LIMIT] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_LIMIT]) >= sizeof(__u32)) {
+        limit = rta_getattr_u32(tb[TCA_FQ_CODEL_LIMIT]);
+        fprintf(f, "limit %up ", limit);
+    }
+    if (tb[TCA_FQ_CODEL_FLOWS] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_FLOWS]) >= sizeof(__u32)) {
+        flows = rta_getattr_u32(tb[TCA_FQ_CODEL_FLOWS]);
+        fprintf(f, "flows %u ", flows);
+    }
+    if (tb[TCA_FQ_CODEL_QUANTUM] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_QUANTUM]) >= sizeof(__u32)) {
+        quantum = rta_getattr_u32(tb[TCA_FQ_CODEL_QUANTUM]);
+        fprintf(f, "quantum %u ", quantum);
+    }
+    if (tb[TCA_FQ_CODEL_TARGET] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_TARGET]) >= sizeof(__u32)) {
+        target = rta_getattr_u32(tb[TCA_FQ_CODEL_TARGET]);
+        fprintf(f, "target %s ", sprint_time(target, b1));
+    }
+    if (tb[TCA_FQ_CODEL_INTERVAL] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_INTERVAL]) >= sizeof(__u32)) {
+        interval = rta_getattr_u32(tb[TCA_FQ_CODEL_INTERVAL]);
+        fprintf(f, "interval %s ", sprint_time(interval, b1));
+    }
+    if (tb[TCA_FQ_CODEL_ECN] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_ECN]) >= sizeof(__u32)) {
+        ecn = rta_getattr_u32(tb[TCA_FQ_CODEL_ECN]);
+        if (ecn)
+            fprintf(f, "ecn ");
+    }
+
+    return 0;
+}
+
+static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
+                 struct rtattr *xstats)
+{
+    struct tc_fq_codel_xstats *st;
+    SPRINT_BUF(b1);
+
+    if (xstats == NULL)
+        return 0;
+
+    if (RTA_PAYLOAD(xstats) < sizeof(*st))
+        return -1;
+
+    st = RTA_DATA(xstats);
+    if (st->type == TCA_FQ_CODEL_XSTATS_QDISC) {
+        fprintf(f, "  maxpacket %u drop_overlimit %u new_flow_count %u ecn_mark %u",
+            st->qdisc_stats.maxpacket,
+            st->qdisc_stats.drop_overlimit,
+            st->qdisc_stats.new_flow_count,
+            st->qdisc_stats.ecn_mark);
+        fprintf(f, "\n  new_flows_len %u old_flows_len %u",
+            st->qdisc_stats.new_flows_len,
+            st->qdisc_stats.old_flows_len);
+    }
+    if (st->type == TCA_FQ_CODEL_XSTATS_CLASS) {
+        fprintf(f, "  deficit %d count %u lastcount %u ldelay %s",
+            st->class_stats.deficit,
+            st->class_stats.count,
+            st->class_stats.lastcount,
+            sprint_time(st->class_stats.ldelay, b1));
+        if (st->class_stats.dropping) {
+            fprintf(f, " dropping");
+            if (st->class_stats.drop_next < 0)
+                fprintf(f, " drop_next -%s",
+                    sprint_time(-st->class_stats.drop_next, b1));
+            else
+                fprintf(f, " drop_next %s",
+                    sprint_time(st->class_stats.drop_next, b1));
+        }
+    }
+    return 0;
+
+}
+
+struct qdisc_util nfq_codel_qdisc_util = {
+    .id        = "nfq_codel",
+    .parse_qopt    = fq_codel_parse_opt,
+    .print_qopt    = fq_codel_print_opt,
+    .print_xstats    = fq_codel_print_xstats,
+};
diff --git a/tc/q_ns2_codel.c b/tc/q_ns2_codel.c
new file mode 100644
index 0000000..223a971
--- /dev/null
+++ b/tc/q_ns2_codel.c
@@ -0,0 +1,188 @@
+/*
+ * Codel - The Controlled-Delay Active Queue Management algorithm
+ *
+ *  Copyright (C) 2011-2012 Kathleen Nichols <a href="mailto:nichols@pollere.com" target="_blank"><nichols@pollere.com></a>
+ *  Copyright (C) 2011-2012 Van Jacobson <a href="mailto:van@pollere.com" target="_blank"><van@pollere.com></a>
+ *  Copyright (C) 2012 Michael D. Taht <a href="mailto:dave.taht@bufferbloat.net" target="_blank"><dave.taht@bufferbloat.net></a>
+ *  Copyright (C) 2012 Eric Dumazet <a href="mailto:edumazet@google.com" target="_blank"><edumazet@google.com></a>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+static void explain(void)
+{
+    fprintf(stderr, "Usage: ... ns2_codel [ limit PACKETS ] [ target TIME]\n");
+    fprintf(stderr, "                 [ interval TIME ] [ ecn | noecn ]\n");
+}
+
+static int codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+               struct nlmsghdr *n)
+{
+    unsigned limit = 0;
+    unsigned target = 0;
+    unsigned interval = 0;
+    int ecn = -1;
+    struct rtattr *tail;
+
+    while (argc > 0) {
+        if (strcmp(*argv, "limit") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&limit, *argv, 0)) {
+                fprintf(stderr, "Illegal \"limit\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "target") == 0) {
+            NEXT_ARG();
+            if (get_time(&target, *argv)) {
+                fprintf(stderr, "Illegal \"target\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "interval") == 0) {
+            NEXT_ARG();
+            if (get_time(&interval, *argv)) {
+                fprintf(stderr, "Illegal \"interval\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "ecn") == 0) {
+            ecn = 1;
+        } else if (strcmp(*argv, "noecn") == 0) {
+            ecn = 0;
+        } else if (strcmp(*argv, "help") == 0) {
+            explain();
+            return -1;
+        } else {
+            fprintf(stderr, "What is \"%s\"?\n", *argv);
+            explain();
+            return -1;
+        }
+        argc--; argv++;
+    }
+
+    tail = NLMSG_TAIL(n);
+    addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+    if (limit)
+        addattr_l(n, 1024, TCA_CODEL_LIMIT, &limit, sizeof(limit));
+    if (interval)
+        addattr_l(n, 1024, TCA_CODEL_INTERVAL, &interval, sizeof(interval));
+    if (target)
+        addattr_l(n, 1024, TCA_CODEL_TARGET, &target, sizeof(target));
+    if (ecn != -1)
+        addattr_l(n, 1024, TCA_CODEL_ECN, &ecn, sizeof(ecn));
+    tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+    return 0;
+}
+
+static int codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+    struct rtattr *tb[TCA_CODEL_MAX + 1];
+    unsigned limit;
+    unsigned interval;
+    unsigned target;
+    unsigned ecn;
+    SPRINT_BUF(b1);
+
+    if (opt == NULL)
+        return 0;
+
+    parse_rtattr_nested(tb, TCA_CODEL_MAX, opt);
+
+    if (tb[TCA_CODEL_LIMIT] &&
+        RTA_PAYLOAD(tb[TCA_CODEL_LIMIT]) >= sizeof(__u32)) {
+        limit = rta_getattr_u32(tb[TCA_CODEL_LIMIT]);
+        fprintf(f, "limit %up ", limit);
+    }
+    if (tb[TCA_CODEL_TARGET] &&
+        RTA_PAYLOAD(tb[TCA_CODEL_TARGET]) >= sizeof(__u32)) {
+        target = rta_getattr_u32(tb[TCA_CODEL_TARGET]);
+        fprintf(f, "target %s ", sprint_time(target, b1));
+    }
+    if (tb[TCA_CODEL_INTERVAL] &&
+        RTA_PAYLOAD(tb[TCA_CODEL_INTERVAL]) >= sizeof(__u32)) {
+        interval = rta_getattr_u32(tb[TCA_CODEL_INTERVAL]);
+        fprintf(f, "interval %s ", sprint_time(interval, b1));
+    }
+    if (tb[TCA_CODEL_ECN] &&
+        RTA_PAYLOAD(tb[TCA_CODEL_ECN]) >= sizeof(__u32)) {
+        ecn = rta_getattr_u32(tb[TCA_CODEL_ECN]);
+        if (ecn)
+            fprintf(f, "ecn ");
+    }
+
+    return 0;
+}
+
+static int codel_print_xstats(struct qdisc_util *qu, FILE *f,
+                  struct rtattr *xstats)
+{
+    struct tc_codel_xstats *st;
+    SPRINT_BUF(b1);
+
+    if (xstats == NULL)
+        return 0;
+
+    if (RTA_PAYLOAD(xstats) < sizeof(*st))
+        return -1;
+
+    st = RTA_DATA(xstats);
+    fprintf(f, "  count %u lastcount %u ldelay %s",
+        st->count, st->lastcount, sprint_time(st->ldelay, b1));
+    if (st->dropping)
+        fprintf(f, " dropping");
+    if (st->drop_next < 0)
+        fprintf(f, " drop_next -%s", sprint_time(-st->drop_next, b1));
+    else
+        fprintf(f, " drop_next %s", sprint_time(st->drop_next, b1));
+    fprintf(f, "\n  maxpacket %u ecn_mark %u drop_overlimit %u",
+        st->maxpacket, st->ecn_mark, st->drop_overlimit);
+    return 0;
+
+}
+
+struct qdisc_util ns2_codel_qdisc_util = {
+    .id        = "ns2_codel",
+    .parse_qopt    = codel_parse_opt,
+    .print_qopt    = codel_print_opt,
+    .print_xstats    = codel_print_xstats,
+};
diff --git a/tc/q_ns4_codel.c b/tc/q_ns4_codel.c
new file mode 100644
index 0000000..0aaa349
--- /dev/null
+++ b/tc/q_ns4_codel.c
@@ -0,0 +1,188 @@
+/*
+ * Codel - The Controlled-Delay Active Queue Management algorithm
+ *
+ *  Copyright (C) 2011-2012 Kathleen Nichols <a href="mailto:nichols@pollere.com" target="_blank"><nichols@pollere.com></a>
+ *  Copyright (C) 2011-2012 Van Jacobson <a href="mailto:van@pollere.com" target="_blank"><van@pollere.com></a>
+ *  Copyright (C) 2012 Michael D. Taht <a href="mailto:dave.taht@bufferbloat.net" target="_blank"><dave.taht@bufferbloat.net></a>
+ *  Copyright (C) 2012 Eric Dumazet <a href="mailto:edumazet@google.com" target="_blank"><edumazet@google.com></a>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+static void explain(void)
+{
+    fprintf(stderr, "Usage: ... ns4_codel [ limit PACKETS ] [ target TIME]\n");
+    fprintf(stderr, "                 [ interval TIME ] [ ecn | noecn ]\n");
+}
+
+static int codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+               struct nlmsghdr *n)
+{
+    unsigned limit = 0;
+    unsigned target = 0;
+    unsigned interval = 0;
+    int ecn = -1;
+    struct rtattr *tail;
+
+    while (argc > 0) {
+        if (strcmp(*argv, "limit") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&limit, *argv, 0)) {
+                fprintf(stderr, "Illegal \"limit\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "target") == 0) {
+            NEXT_ARG();
+            if (get_time(&target, *argv)) {
+                fprintf(stderr, "Illegal \"target\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "interval") == 0) {
+            NEXT_ARG();
+            if (get_time(&interval, *argv)) {
+                fprintf(stderr, "Illegal \"interval\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "ecn") == 0) {
+            ecn = 1;
+        } else if (strcmp(*argv, "noecn") == 0) {
+            ecn = 0;
+        } else if (strcmp(*argv, "help") == 0) {
+            explain();
+            return -1;
+        } else {
+            fprintf(stderr, "What is \"%s\"?\n", *argv);
+            explain();
+            return -1;
+        }
+        argc--; argv++;
+    }
+
+    tail = NLMSG_TAIL(n);
+    addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+    if (limit)
+        addattr_l(n, 1024, TCA_CODEL_LIMIT, &limit, sizeof(limit));
+    if (interval)
+        addattr_l(n, 1024, TCA_CODEL_INTERVAL, &interval, sizeof(interval));
+    if (target)
+        addattr_l(n, 1024, TCA_CODEL_TARGET, &target, sizeof(target));
+    if (ecn != -1)
+        addattr_l(n, 1024, TCA_CODEL_ECN, &ecn, sizeof(ecn));
+    tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+    return 0;
+}
+
+static int codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+    struct rtattr *tb[TCA_CODEL_MAX + 1];
+    unsigned limit;
+    unsigned interval;
+    unsigned target;
+    unsigned ecn;
+    SPRINT_BUF(b1);
+
+    if (opt == NULL)
+        return 0;
+
+    parse_rtattr_nested(tb, TCA_CODEL_MAX, opt);
+
+    if (tb[TCA_CODEL_LIMIT] &&
+        RTA_PAYLOAD(tb[TCA_CODEL_LIMIT]) >= sizeof(__u32)) {
+        limit = rta_getattr_u32(tb[TCA_CODEL_LIMIT]);
+        fprintf(f, "limit %up ", limit);
+    }
+    if (tb[TCA_CODEL_TARGET] &&
+        RTA_PAYLOAD(tb[TCA_CODEL_TARGET]) >= sizeof(__u32)) {
+        target = rta_getattr_u32(tb[TCA_CODEL_TARGET]);
+        fprintf(f, "target %s ", sprint_time(target, b1));
+    }
+    if (tb[TCA_CODEL_INTERVAL] &&
+        RTA_PAYLOAD(tb[TCA_CODEL_INTERVAL]) >= sizeof(__u32)) {
+        interval = rta_getattr_u32(tb[TCA_CODEL_INTERVAL]);
+        fprintf(f, "interval %s ", sprint_time(interval, b1));
+    }
+    if (tb[TCA_CODEL_ECN] &&
+        RTA_PAYLOAD(tb[TCA_CODEL_ECN]) >= sizeof(__u32)) {
+        ecn = rta_getattr_u32(tb[TCA_CODEL_ECN]);
+        if (ecn)
+            fprintf(f, "ecn ");
+    }
+
+    return 0;
+}
+
+static int codel_print_xstats(struct qdisc_util *qu, FILE *f,
+                  struct rtattr *xstats)
+{
+    struct tc_codel_xstats *st;
+    SPRINT_BUF(b1);
+
+    if (xstats == NULL)
+        return 0;
+
+    if (RTA_PAYLOAD(xstats) < sizeof(*st))
+        return -1;
+
+    st = RTA_DATA(xstats);
+    fprintf(f, "  count %u lastcount %u ldelay %s",
+        st->count, st->lastcount, sprint_time(st->ldelay, b1));
+    if (st->dropping)
+        fprintf(f, " dropping");
+    if (st->drop_next < 0)
+        fprintf(f, " drop_next -%s", sprint_time(-st->drop_next, b1));
+    else
+        fprintf(f, " drop_next %s", sprint_time(st->drop_next, b1));
+    fprintf(f, "\n  maxpacket %u ecn_mark %u drop_overlimit %u",
+        st->maxpacket, st->ecn_mark, st->drop_overlimit);
+    return 0;
+
+}
+
+struct qdisc_util ns4_codel_qdisc_util = {
+    .id        = "ns4_codel",
+    .parse_qopt    = codel_parse_opt,
+    .print_qopt    = codel_print_opt,
+    .print_xstats    = codel_print_xstats,
+};
diff --git a/tc/q_pfq_codel.c b/tc/q_pfq_codel.c
new file mode 100644
index 0000000..52c5160
--- /dev/null
+++ b/tc/q_pfq_codel.c
@@ -0,0 +1,232 @@
+/*
+ * Fair Queue Codel
+ *
+ *  Copyright (C) 2012 Eric Dumazet <a href="mailto:edumazet@google.com" target="_blank"><edumazet@google.com></a>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions, and the following disclaimer,
+ *    without modification.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. The names of the authors may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * Alternatively, provided that this notice is retained in full, this
+ * software may be distributed under the terms of the GNU General
+ * Public License ("GPL") version 2, in which case the provisions of the
+ * GPL apply INSTEAD OF those given above.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+
+#include "utils.h"
+#include "tc_util.h"
+
+static void explain(void)
+{
+    fprintf(stderr, "Usage: ... pfq_codel [ limit PACKETS ] [ flows NUMBER ]\n");
+    fprintf(stderr, "                    [ target TIME] [ interval TIME ]\n");
+    fprintf(stderr, "                    [ quantum BYTES ] [ [no]ecn ]\n");
+}
+
+static int fq_codel_parse_opt(struct qdisc_util *qu, int argc, char **argv,
+                  struct nlmsghdr *n)
+{
+    unsigned limit = 0;
+    unsigned flows = 0;
+    unsigned target = 0;
+    unsigned interval = 0;
+    unsigned quantum = 0;
+    int ecn = -1;
+    struct rtattr *tail;
+
+    while (argc > 0) {
+        if (strcmp(*argv, "limit") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&limit, *argv, 0)) {
+                fprintf(stderr, "Illegal \"limit\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "flows") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&flows, *argv, 0)) {
+                fprintf(stderr, "Illegal \"flows\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "quantum") == 0) {
+            NEXT_ARG();
+            if (get_unsigned(&quantum, *argv, 0)) {
+                fprintf(stderr, "Illegal \"quantum\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "target") == 0) {
+            NEXT_ARG();
+            if (get_time(&target, *argv)) {
+                fprintf(stderr, "Illegal \"target\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "interval") == 0) {
+            NEXT_ARG();
+            if (get_time(&interval, *argv)) {
+                fprintf(stderr, "Illegal \"interval\"\n");
+                return -1;
+            }
+        } else if (strcmp(*argv, "ecn") == 0) {
+            ecn = 1;
+        } else if (strcmp(*argv, "noecn") == 0) {
+            ecn = 0;
+        } else if (strcmp(*argv, "help") == 0) {
+            explain();
+            return -1;
+        } else {
+            fprintf(stderr, "What is \"%s\"?\n", *argv);
+            explain();
+            return -1;
+        }
+        argc--; argv++;
+    }
+
+    tail = NLMSG_TAIL(n);
+    addattr_l(n, 1024, TCA_OPTIONS, NULL, 0);
+    if (limit)
+        addattr_l(n, 1024, TCA_FQ_CODEL_LIMIT, &limit, sizeof(limit));
+    if (flows)
+        addattr_l(n, 1024, TCA_FQ_CODEL_FLOWS, &flows, sizeof(flows));
+    if (quantum)
+        addattr_l(n, 1024, TCA_FQ_CODEL_QUANTUM, &quantum, sizeof(quantum));
+    if (interval)
+        addattr_l(n, 1024, TCA_FQ_CODEL_INTERVAL, &interval, sizeof(interval));
+    if (target)
+        addattr_l(n, 1024, TCA_FQ_CODEL_TARGET, &target, sizeof(target));
+    if (ecn != -1)
+        addattr_l(n, 1024, TCA_FQ_CODEL_ECN, &ecn, sizeof(ecn));
+    tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
+    return 0;
+}
+
+static int fq_codel_print_opt(struct qdisc_util *qu, FILE *f, struct rtattr *opt)
+{
+    struct rtattr *tb[TCA_FQ_CODEL_MAX + 1];
+    unsigned limit;
+    unsigned flows;
+    unsigned interval;
+    unsigned target;
+    unsigned ecn;
+    unsigned quantum;
+    SPRINT_BUF(b1);
+
+    if (opt == NULL)
+        return 0;
+
+    parse_rtattr_nested(tb, TCA_FQ_CODEL_MAX, opt);
+
+    if (tb[TCA_FQ_CODEL_LIMIT] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_LIMIT]) >= sizeof(__u32)) {
+        limit = rta_getattr_u32(tb[TCA_FQ_CODEL_LIMIT]);
+        fprintf(f, "limit %up ", limit);
+    }
+    if (tb[TCA_FQ_CODEL_FLOWS] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_FLOWS]) >= sizeof(__u32)) {
+        flows = rta_getattr_u32(tb[TCA_FQ_CODEL_FLOWS]);
+        fprintf(f, "flows %u ", flows);
+    }
+    if (tb[TCA_FQ_CODEL_QUANTUM] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_QUANTUM]) >= sizeof(__u32)) {
+        quantum = rta_getattr_u32(tb[TCA_FQ_CODEL_QUANTUM]);
+        fprintf(f, "quantum %u ", quantum);
+    }
+    if (tb[TCA_FQ_CODEL_TARGET] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_TARGET]) >= sizeof(__u32)) {
+        target = rta_getattr_u32(tb[TCA_FQ_CODEL_TARGET]);
+        fprintf(f, "target %s ", sprint_time(target, b1));
+    }
+    if (tb[TCA_FQ_CODEL_INTERVAL] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_INTERVAL]) >= sizeof(__u32)) {
+        interval = rta_getattr_u32(tb[TCA_FQ_CODEL_INTERVAL]);
+        fprintf(f, "interval %s ", sprint_time(interval, b1));
+    }
+    if (tb[TCA_FQ_CODEL_ECN] &&
+        RTA_PAYLOAD(tb[TCA_FQ_CODEL_ECN]) >= sizeof(__u32)) {
+        ecn = rta_getattr_u32(tb[TCA_FQ_CODEL_ECN]);
+        if (ecn)
+            fprintf(f, "ecn ");
+    }
+
+    return 0;
+}
+
+static int fq_codel_print_xstats(struct qdisc_util *qu, FILE *f,
+                 struct rtattr *xstats)
+{
+    struct tc_fq_codel_xstats *st;
+    SPRINT_BUF(b1);
+
+    if (xstats == NULL)
+        return 0;
+
+    if (RTA_PAYLOAD(xstats) < sizeof(*st))
+        return -1;
+
+    st = RTA_DATA(xstats);
+    if (st->type == TCA_FQ_CODEL_XSTATS_QDISC) {
+        fprintf(f, "  maxpacket %u drop_overlimit %u new_flow_count %u ecn_mark %u",
+            st->qdisc_stats.maxpacket,
+            st->qdisc_stats.drop_overlimit,
+            st->qdisc_stats.new_flow_count,
+            st->qdisc_stats.ecn_mark);
+        fprintf(f, "\n  new_flows_len %u old_flows_len %u",
+            st->qdisc_stats.new_flows_len,
+            st->qdisc_stats.old_flows_len);
+    }
+    if (st->type == TCA_FQ_CODEL_XSTATS_CLASS) {
+        fprintf(f, "  deficit %d count %u lastcount %u ldelay %s",
+            st->class_stats.deficit,
+            st->class_stats.count,
+            st->class_stats.lastcount,
+            sprint_time(st->class_stats.ldelay, b1));
+        if (st->class_stats.dropping) {
+            fprintf(f, " dropping");
+            if (st->class_stats.drop_next < 0)
+                fprintf(f, " drop_next -%s",
+                    sprint_time(-st->class_stats.drop_next, b1));
+            else
+                fprintf(f, " drop_next %s",
+                    sprint_time(st->class_stats.drop_next, b1));
+        }
+    }
+    return 0;
+
+}
+
+struct qdisc_util pfq_codel_qdisc_util = {
+    .id        = "pfq_codel",
+    .parse_qopt    = fq_codel_parse_opt,
+    .print_qopt    = fq_codel_print_opt,
+    .print_xstats    = fq_codel_print_xstats,
+};

141-cake-add-support.patch




</pre>
      <br>
    </div>
    <br>
  </div>

</blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Dave Täht<br>Open Networking needs **Open Source Hardware**<br><br><a href="https://plus.google.com/u/0/+EricRaymond/posts/JqxCe2pFr67" target="_blank">https://plus.google.com/u/0/+EricRaymond/posts/JqxCe2pFr67</a></div>
</div></div></div>