iproute2: cake: support new operating modes
There has been recent significant activity with the cake qdisc of late Some of that effort is related to upstreaming to kernel & iproute2 mainline but we're not quite there yet. This commit teaches tc how to activate and interprete the latest cake operating modes, namely: ingress mode: Instead of only counting packets that make it past the shaper, include packets we've decided to drop as well, since they did arrive with us on the link and took link capacity. This mode is more suitable for shaping the ingress of a link (e.g. from ISP) rather than the more normal egress. ack-filter/ack-filter-aggressive: Filter excessive TCP ACKS. Useful in highly assymetric links (downstream v upstream capacity) where the majority of upstream link capacity is occupied with ACKS for downstream traffic. Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
This commit is contained in:
parent
0589979f7b
commit
a9940ca2d7
2 changed files with 129 additions and 50 deletions
|
@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=iproute2
|
PKG_NAME:=iproute2
|
||||||
PKG_VERSION:=4.14.1
|
PKG_VERSION:=4.14.1
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=2
|
||||||
|
|
||||||
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
|
||||||
PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
|
PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
TCMODULES += e_bpf.o
|
TCMODULES += e_bpf.o
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/tc/q_cake.c
|
+++ b/tc/q_cake.c
|
||||||
@@ -0,0 +1,692 @@
|
@@ -0,0 +1,771 @@
|
||||||
+/*
|
+/*
|
||||||
+ * Common Applications Kept Enhanced -- CAKE
|
+ * Common Applications Kept Enhanced -- CAKE
|
||||||
+ *
|
+ *
|
||||||
|
@ -140,9 +140,10 @@
|
||||||
+" dual-srchost | dual-dsthost | triple-isolate* ]\n"
|
+" dual-srchost | dual-dsthost | triple-isolate* ]\n"
|
||||||
+" [ nat | nonat* ]\n"
|
+" [ nat | nonat* ]\n"
|
||||||
+" [ wash | nowash * ]\n"
|
+" [ wash | nowash * ]\n"
|
||||||
|
+" [ ack-filter | ack-filter-aggressive | no-ack-filter * ]\n"
|
||||||
+" [ memlimit LIMIT ]\n"
|
+" [ memlimit LIMIT ]\n"
|
||||||
+" [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
|
+" [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
|
||||||
+" [ mpu N ]\n"
|
+" [ mpu N ] [ ingress | egress* ]\n"
|
||||||
+" (* marks defaults)\n");
|
+" (* marks defaults)\n");
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
@ -158,12 +159,14 @@
|
||||||
+ int overhead = 0;
|
+ int overhead = 0;
|
||||||
+ bool overhead_set = false;
|
+ bool overhead_set = false;
|
||||||
+ bool overhead_override = false;
|
+ bool overhead_override = false;
|
||||||
+ int wash = -1;
|
|
||||||
+ int mpu = 0;
|
+ int mpu = 0;
|
||||||
+ int flowmode = -1;
|
+ int flowmode = -1;
|
||||||
+ int nat = -1;
|
+ int nat = -1;
|
||||||
+ int atm = -1;
|
+ int atm = -1;
|
||||||
+ int autorate = -1;
|
+ int autorate = -1;
|
||||||
|
+ int wash = -1;
|
||||||
|
+ int ingress = -1;
|
||||||
|
+ int ack_filter = -1;
|
||||||
+ struct rtattr *tail;
|
+ struct rtattr *tail;
|
||||||
+
|
+
|
||||||
+ while (argc > 0) {
|
+ while (argc > 0) {
|
||||||
|
@ -317,12 +320,22 @@
|
||||||
+ /* Typical VDSL2 framing schemes, both over PTM */
|
+ /* Typical VDSL2 framing schemes, both over PTM */
|
||||||
+ /* PTM has 64b/65b coding which absorbs some bandwidth */
|
+ /* PTM has 64b/65b coding which absorbs some bandwidth */
|
||||||
+ } else if (strcmp(*argv, "pppoe-ptm") == 0) {
|
+ } else if (strcmp(*argv, "pppoe-ptm") == 0) {
|
||||||
|
+ /* 2B PPP + 6B PPPoE + 6B dest MAC + 6B src MAC
|
||||||
|
+ * + 2B ethertype + 4B Frame Check Sequence
|
||||||
|
+ * + 1B Start of Frame (S) + 1B End of Frame (Ck)
|
||||||
|
+ * + 2B TC-CRC (PTM-FCS) = 30B
|
||||||
|
+ */
|
||||||
+ atm = 2;
|
+ atm = 2;
|
||||||
+ overhead += 27;
|
+ overhead += 30;
|
||||||
+ overhead_set = true;
|
+ overhead_set = true;
|
||||||
+ } else if (strcmp(*argv, "bridged-ptm") == 0) {
|
+ } else if (strcmp(*argv, "bridged-ptm") == 0) {
|
||||||
|
+ /* 6B dest MAC + 6B src MAC + 2B ethertype
|
||||||
|
+ * + 4B Frame Check Sequence
|
||||||
|
+ * + 1B Start of Frame (S) + 1B End of Frame (Ck)
|
||||||
|
+ * + 2B TC-CRC (PTM-FCS) = 22B
|
||||||
|
+ */
|
||||||
+ atm = 2;
|
+ atm = 2;
|
||||||
+ overhead += 19;
|
+ overhead += 22;
|
||||||
+ overhead_set = true;
|
+ overhead_set = true;
|
||||||
+
|
+
|
||||||
+ } else if (strcmp(*argv, "via-ethernet") == 0) {
|
+ } else if (strcmp(*argv, "via-ethernet") == 0) {
|
||||||
|
@ -335,9 +348,27 @@
|
||||||
+ * that automatically, and is thus ignored.
|
+ * that automatically, and is thus ignored.
|
||||||
+ *
|
+ *
|
||||||
+ * It would be deleted entirely, but it appears in the
|
+ * It would be deleted entirely, but it appears in the
|
||||||
+ * stats output when the automatic compensation is active.
|
+ * stats output when the automatic compensation is
|
||||||
|
+ * active.
|
||||||
+ */
|
+ */
|
||||||
+
|
+
|
||||||
|
+ } else if (strcmp(*argv, "total_overhead") == 0) {
|
||||||
|
+ /*
|
||||||
|
+ * This is the overhead cake accounts for; added here so
|
||||||
|
+ * that cake's "tc -s qdisc" output can be directly
|
||||||
|
+ * pasted into the tc command to instantate a new cake..
|
||||||
|
+ */
|
||||||
|
+ NEXT_ARG();
|
||||||
|
+
|
||||||
|
+ } else if (strcmp(*argv, "hard_header_len") == 0) {
|
||||||
|
+ /*
|
||||||
|
+ * This is the overhead the kernel automatically
|
||||||
|
+ * accounted for; added here so that cake's "tc -s
|
||||||
|
+ * qdisc" output can be directly pasted into the tc
|
||||||
|
+ * command to instantiate a new cake..
|
||||||
|
+ */
|
||||||
|
+ NEXT_ARG();
|
||||||
|
+
|
||||||
+ } else if (strcmp(*argv, "ethernet") == 0) {
|
+ } else if (strcmp(*argv, "ethernet") == 0) {
|
||||||
+ /* ethernet pre-amble & interframe gap & FCS
|
+ /* ethernet pre-amble & interframe gap & FCS
|
||||||
+ * you may need to add vlan tag */
|
+ * you may need to add vlan tag */
|
||||||
|
@ -353,7 +384,7 @@
|
||||||
+
|
+
|
||||||
+ /*
|
+ /*
|
||||||
+ * DOCSIS cable shapers account for Ethernet frame with FCS,
|
+ * DOCSIS cable shapers account for Ethernet frame with FCS,
|
||||||
+ * but not interframe gap nor preamble.
|
+ * but not interframe gap or preamble.
|
||||||
+ */
|
+ */
|
||||||
+ } else if (strcmp(*argv, "docsis") == 0) {
|
+ } else if (strcmp(*argv, "docsis") == 0) {
|
||||||
+ atm = 0;
|
+ atm = 0;
|
||||||
|
@ -380,6 +411,18 @@
|
||||||
+ return -1;
|
+ return -1;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ } else if (strcmp(*argv, "ingress") == 0) {
|
||||||
|
+ ingress = 1;
|
||||||
|
+ } else if (strcmp(*argv, "egress") == 0) {
|
||||||
|
+ ingress = 0;
|
||||||
|
+
|
||||||
|
+ } else if (strcmp(*argv, "no-ack-filter") == 0) {
|
||||||
|
+ ack_filter = 0;
|
||||||
|
+ } else if (strcmp(*argv, "ack-filter") == 0) {
|
||||||
|
+ ack_filter = 0x0200;
|
||||||
|
+ } else if (strcmp(*argv, "ack-filter-aggressive") == 0) {
|
||||||
|
+ ack_filter = 0x0600;
|
||||||
|
+
|
||||||
+ } else if (strcmp(*argv, "memlimit") == 0) {
|
+ } else if (strcmp(*argv, "memlimit") == 0) {
|
||||||
+ NEXT_ARG();
|
+ NEXT_ARG();
|
||||||
+ if(get_size(&memlimit, *argv)) {
|
+ if(get_size(&memlimit, *argv)) {
|
||||||
|
@ -428,6 +471,10 @@
|
||||||
+ addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat));
|
+ addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat));
|
||||||
+ if (wash != -1)
|
+ if (wash != -1)
|
||||||
+ addattr_l(n, 1024, TCA_CAKE_WASH, &wash, sizeof(wash));
|
+ addattr_l(n, 1024, TCA_CAKE_WASH, &wash, sizeof(wash));
|
||||||
|
+ if (ingress != -1)
|
||||||
|
+ addattr_l(n, 1024, TCA_CAKE_INGRESS, &ingress, sizeof(ingress));
|
||||||
|
+ if (ack_filter != -1)
|
||||||
|
+ addattr_l(n, 1024, TCA_CAKE_ACK_FILTER, &ack_filter, sizeof(ack_filter));
|
||||||
+
|
+
|
||||||
+ tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
|
+ tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
|
||||||
+ return 0;
|
+ return 0;
|
||||||
|
@ -449,6 +496,8 @@
|
||||||
+ int nat = 0;
|
+ int nat = 0;
|
||||||
+ int autorate = 0;
|
+ int autorate = 0;
|
||||||
+ int wash = 0;
|
+ int wash = 0;
|
||||||
|
+ int ingress = 0;
|
||||||
|
+ int ack_filter = 0;
|
||||||
+ SPRINT_BUF(b1);
|
+ SPRINT_BUF(b1);
|
||||||
+ SPRINT_BUF(b2);
|
+ SPRINT_BUF(b2);
|
||||||
+
|
+
|
||||||
|
@ -554,6 +603,14 @@
|
||||||
+ RTA_PAYLOAD(tb[TCA_CAKE_MPU]) >= sizeof(__u32)) {
|
+ RTA_PAYLOAD(tb[TCA_CAKE_MPU]) >= sizeof(__u32)) {
|
||||||
+ mpu = rta_getattr_u32(tb[TCA_CAKE_MPU]);
|
+ mpu = rta_getattr_u32(tb[TCA_CAKE_MPU]);
|
||||||
+ }
|
+ }
|
||||||
|
+ if (tb[TCA_CAKE_INGRESS] &&
|
||||||
|
+ RTA_PAYLOAD(tb[TCA_CAKE_INGRESS]) >= sizeof(__u32)) {
|
||||||
|
+ ingress = rta_getattr_u32(tb[TCA_CAKE_INGRESS]);
|
||||||
|
+ }
|
||||||
|
+ if (tb[TCA_CAKE_ACK_FILTER] &&
|
||||||
|
+ RTA_PAYLOAD(tb[TCA_CAKE_ACK_FILTER]) >= sizeof(__u32)) {
|
||||||
|
+ ack_filter = rta_getattr_u32(tb[TCA_CAKE_ACK_FILTER]);
|
||||||
|
+ }
|
||||||
+ if (tb[TCA_CAKE_ETHERNET] &&
|
+ if (tb[TCA_CAKE_ETHERNET] &&
|
||||||
+ RTA_PAYLOAD(tb[TCA_CAKE_ETHERNET]) >= sizeof(__u32)) {
|
+ RTA_PAYLOAD(tb[TCA_CAKE_ETHERNET]) >= sizeof(__u32)) {
|
||||||
+ ethernet = rta_getattr_u32(tb[TCA_CAKE_ETHERNET]);
|
+ ethernet = rta_getattr_u32(tb[TCA_CAKE_ETHERNET]);
|
||||||
|
@ -566,6 +623,14 @@
|
||||||
+ if (wash)
|
+ if (wash)
|
||||||
+ fprintf(f,"wash ");
|
+ fprintf(f,"wash ");
|
||||||
+
|
+
|
||||||
|
+ if (ingress)
|
||||||
|
+ fprintf(f,"ingress ");
|
||||||
|
+
|
||||||
|
+ if (ack_filter == 0x0600)
|
||||||
|
+ fprintf(f,"ack-filter-aggressive ");
|
||||||
|
+ else if (ack_filter)
|
||||||
|
+ fprintf(f,"ack-filter ");
|
||||||
|
+
|
||||||
+ if (interval)
|
+ if (interval)
|
||||||
+ fprintf(f, "rtt %s ", sprint_time(interval, b2));
|
+ fprintf(f, "rtt %s ", sprint_time(interval, b2));
|
||||||
+
|
+
|
||||||
|
@ -581,12 +646,19 @@
|
||||||
+
|
+
|
||||||
+ fprintf(f, "overhead %d ", overhead);
|
+ fprintf(f, "overhead %d ", overhead);
|
||||||
+
|
+
|
||||||
+ // This is actually the *amount* of automatic compensation, but we only report
|
+ /* This is actually the *amount* of automatic compensation, but
|
||||||
+ // its presence as a boolean for now.
|
+ * we only report its presence as a boolean for now.
|
||||||
|
+ */
|
||||||
+ if (ethernet)
|
+ if (ethernet)
|
||||||
+ fprintf(f, "via-ethernet ");
|
+ fprintf(f, "via-ethernet ");
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ /* unconditionally report the overhead and hard_header_len overhead the
|
||||||
|
+ * kernel added automatically
|
||||||
|
+ */
|
||||||
|
+ fprintf(f, "total_overhead %d ", overhead);
|
||||||
|
+ fprintf(f, "hard_header_len %d ", ethernet);
|
||||||
|
+
|
||||||
+ if (mpu) {
|
+ if (mpu) {
|
||||||
+ fprintf(f, "mpu %d ", mpu);
|
+ fprintf(f, "mpu %d ", mpu);
|
||||||
+ }
|
+ }
|
||||||
|
@ -736,6 +808,13 @@
|
||||||
+ fprintf(f, " %12u", stnc->ecn_marked[i].packets);
|
+ fprintf(f, " %12u", stnc->ecn_marked[i].packets);
|
||||||
+ fprintf(f, "\n");
|
+ fprintf(f, "\n");
|
||||||
+
|
+
|
||||||
|
+ if(stnc->version >= 5) {
|
||||||
|
+ fprintf(f, " ack_drop");
|
||||||
|
+ for(i=0; i < stnc->tin_cnt; i++)
|
||||||
|
+ fprintf(f, " %12u", stnc->ack_drops[i].packets);
|
||||||
|
+ fprintf(f, "\n");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
+ fprintf(f, " sp_flows");
|
+ fprintf(f, " sp_flows");
|
||||||
+ for(i=0; i < stnc->tin_cnt; i++)
|
+ for(i=0; i < stnc->tin_cnt; i++)
|
||||||
+ fprintf(f, " %12u", stnc->sparse_flows[i]);
|
+ fprintf(f, " %12u", stnc->sparse_flows[i]);
|
||||||
|
|
Loading…
Reference in a new issue