iproute2: tc cake qdisc add nat, docsis & ptm modes
authorKevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
Wed, 21 Sep 2016 08:45:33 +0000 (09:45 +0100)
committerJohn Crispin <john@phrozen.org>
Tue, 4 Oct 2016 09:50:48 +0000 (11:50 +0200)
Add cake nat de-masquerading mode: nat, nonat.
Also docsis & ptm overhead related keywords: nat, nonat,
ptm, docsis-downstream-ip, docsis-downstream, docsis-upstream-ip
& docsis-upstream.

Signed-off-by: Kevin Darbyshire-Bryant <kevin@darbyshire-bryant.me.uk>
package/network/utils/iproute2/Makefile
package/network/utils/iproute2/patches/950-add-cake-to-tc.patch

index 4b17e19..9575ff1 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=iproute2
 PKG_VERSION:=4.4.0
 
 PKG_NAME:=iproute2
 PKG_VERSION:=4.4.0
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
index 5e51784..ffb3e63 100644 (file)
@@ -1,6 +1,6 @@
 --- a/include/linux/pkt_sched.h
 +++ b/include/linux/pkt_sched.h
 --- a/include/linux/pkt_sched.h
 +++ b/include/linux/pkt_sched.h
-@@ -850,4 +850,56 @@ struct tc_pie_xstats {
+@@ -850,4 +850,57 @@ struct tc_pie_xstats {
        __u32 maxq;             /* maximum queue size */
        __u32 ecn_mark;         /* packets marked with ecn*/
  };
        __u32 maxq;             /* maximum queue size */
        __u32 ecn_mark;         /* packets marked with ecn*/
  };
@@ -17,6 +17,7 @@
 +      TCA_CAKE_TARGET,
 +      TCA_CAKE_AUTORATE,
 +      TCA_CAKE_MEMORY,
 +      TCA_CAKE_TARGET,
 +      TCA_CAKE_AUTORATE,
 +      TCA_CAKE_MEMORY,
++      TCA_CAKE_NAT,
 +      __TCA_CAKE_MAX
 +};
 +#define TCA_CAKE_MAX  (__TCA_CAKE_MAX - 1)
 +      __TCA_CAKE_MAX
 +};
 +#define TCA_CAKE_MAX  (__TCA_CAKE_MAX - 1)
@@ -69,7 +70,7 @@
  
 --- /dev/null
 +++ b/tc/q_cake.c
  
 --- /dev/null
 +++ b/tc/q_cake.c
-@@ -0,0 +1,600 @@
+@@ -0,0 +1,643 @@
 +/*
 + * Common Applications Kept Enhanced  --  CAKE
 + *
 +/*
 + * Common Applications Kept Enhanced  --  CAKE
 + *
 +      fprintf(stderr, "Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n"
 +                      "                [ rtt TIME | datacentre | lan | metro | regional | internet* | oceanic | satellite | interplanetary ]\n"
 +                      "                [ besteffort | precedence | diffserv8 | diffserv4* ]\n"
 +      fprintf(stderr, "Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n"
 +                      "                [ rtt TIME | datacentre | lan | metro | regional | internet* | oceanic | satellite | interplanetary ]\n"
 +                      "                [ besteffort | precedence | diffserv8 | diffserv4* ]\n"
-+                      "                [ flowblind | srchost | dsthost | hosts | flows* | dual-srchost | dual-dsthost | triple-isolate ]\n"
-+                      "                [ atm | noatm* ] [ overhead N | conservative | raw* ]\n"
++                      "                [ flowblind | srchost | dsthost | hosts | flows* | dual-srchost | dual-dsthost | triple-isolate ] [ nat | nonat* ]\n"
++                      "                [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
 +                      "                [ memlimit LIMIT ]\n"
 +                      "    (* marks defaults)\n");
 +}
 +                      "                [ memlimit LIMIT ]\n"
 +                      "    (* marks defaults)\n");
 +}
 +      int  overhead = 0;
 +      bool overhead_set = false;
 +      int flowmode = -1;
 +      int  overhead = 0;
 +      bool overhead_set = false;
 +      int flowmode = -1;
++      int nat = -1;
 +      int atm = -1;
 +      int autorate = -1;
 +      struct rtattr *tail;
 +      int atm = -1;
 +      int autorate = -1;
 +      struct rtattr *tail;
 +              } else if (strcmp(*argv, "triple-isolate") == 0) {
 +                      flowmode = 7;
 +
 +              } else if (strcmp(*argv, "triple-isolate") == 0) {
 +                      flowmode = 7;
 +
++              } else if (strcmp(*argv, "nat") == 0) {
++                      nat = 1;
++              } else if (strcmp(*argv, "nonat") == 0) {
++                      nat = 0;
++
++              } else if (strcmp(*argv, "ptm") == 0) {
++                      atm = 2;
 +              } else if (strcmp(*argv, "atm") == 0) {
 +                      atm = 1;
 +              } else if (strcmp(*argv, "noatm") == 0) {
 +              } else if (strcmp(*argv, "atm") == 0) {
 +                      atm = 1;
 +              } else if (strcmp(*argv, "noatm") == 0) {
 +                      overhead = 48;
 +                      overhead_set = true;
 +
 +                      overhead = 48;
 +                      overhead_set = true;
 +
-+              /* Various ADSL framing schemes */
++              /*
++               * DOCSIS overhead figures courtesy of Greg White @ CableLabs.
++               * The "-ip" versions include the Ethernet frame header, in case
++               * you are shaping an IP interface instead of an Ethernet one.
++               */
++              } else if (strcmp(*argv, "docsis-downstream-ip") == 0) {
++                      atm = 0;
++                      overhead += 35;
++                      overhead_set = true;
++              } else if (strcmp(*argv, "docsis-downstream") == 0) {
++                      atm = 0;
++                      overhead += 35 - 14;
++                      overhead_set = true;
++              } else if (strcmp(*argv, "docsis-upstream-ip") == 0) {
++                      atm = 0;
++                      overhead += 28;
++                      overhead_set = true;
++              } else if (strcmp(*argv, "docsis-upstream") == 0) {
++                      atm = 0;
++                      overhead += 28 - 14;
++                      overhead_set = true;
++
++              /* Various ADSL framing schemes, all over ATM cells */
 +              } else if (strcmp(*argv, "ipoa-vcmux") == 0) {
 +                      atm = 1;
 +                      overhead += 8;
 +              } else if (strcmp(*argv, "ipoa-vcmux") == 0) {
 +                      atm = 1;
 +                      overhead += 8;
 +                      overhead += 40;
 +                      overhead_set = true;
 +
 +                      overhead += 40;
 +                      overhead_set = true;
 +
-+              /* Typical VDSL2 framing schemes */
-+              /* NB: PTM includes HDLC's 0x7D/7E expansion, adds extra 1/128 */
++              /* Typical VDSL2 framing schemes, both over PTM */
++              /* PTM has 64b/65b coding which absorbs some bandwidth */
 +              } else if (strcmp(*argv, "pppoe-ptm") == 0) {
 +              } else if (strcmp(*argv, "pppoe-ptm") == 0) {
-+                      atm = 0;
++                      atm = 2;
 +                      overhead += 27;
 +                      overhead += 27;
++                      overhead_set = true;
 +              } else if (strcmp(*argv, "bridged-ptm") == 0) {
 +              } else if (strcmp(*argv, "bridged-ptm") == 0) {
-+                      atm = 0;
++                      atm = 2;
 +                      overhead += 19;
 +                      overhead += 19;
++                      overhead_set = true;
 +
 +              } else if (strcmp(*argv, "via-ethernet") == 0) {
 +                      /*
 +                       * The above overheads are relative to an IP packet,
 +
 +              } else if (strcmp(*argv, "via-ethernet") == 0) {
 +                      /*
 +                       * The above overheads are relative to an IP packet,
-+                       * but if the physical interface is Ethernet, Linux
-+                       * includes Ethernet framing overhead already.
++                       * but Linux includes Ethernet framing overhead already
++                       * if we are shaping an Ethernet interface rather than
++                       * an IP interface.
 +                       */
 +                      overhead -= 14;
 +                      overhead_set = true;
 +                       */
 +                      overhead -= 14;
 +                      overhead_set = true;
 +              addattr_l(n, 1024, TCA_CAKE_AUTORATE, &autorate, sizeof(autorate));
 +      if (memlimit)
 +              addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit, sizeof(memlimit));
 +              addattr_l(n, 1024, TCA_CAKE_AUTORATE, &autorate, sizeof(autorate));
 +      if (memlimit)
 +              addattr_l(n, 1024, TCA_CAKE_MEMORY, &memlimit, sizeof(memlimit));
++      if (nat != -1)
++              addattr_l(n, 1024, TCA_CAKE_NAT, &nat, sizeof(nat));
 +
 +      tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 +      return 0;
 +
 +      tail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;
 +      return 0;
 +      unsigned memlimit = 0;
 +      int overhead = 0;
 +      int atm = 0;
 +      unsigned memlimit = 0;
 +      int overhead = 0;
 +      int atm = 0;
++      int nat = 0;
 +      int autorate = 0;
 +      SPRINT_BUF(b1);
 +      SPRINT_BUF(b2);
 +      int autorate = 0;
 +      SPRINT_BUF(b1);
 +      SPRINT_BUF(b2);
 +      if (tb[TCA_CAKE_FLOW_MODE] &&
 +          RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) {
 +              flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]);
 +      if (tb[TCA_CAKE_FLOW_MODE] &&
 +          RTA_PAYLOAD(tb[TCA_CAKE_FLOW_MODE]) >= sizeof(__u32)) {
 +              flowmode = rta_getattr_u32(tb[TCA_CAKE_FLOW_MODE]);
++              nat = !!(flowmode & 64);
++              flowmode &= ~64;
 +              switch(flowmode) {
 +              case 0:
 +                      fprintf(f, "flowblind ");
 +              switch(flowmode) {
 +              case 0:
 +                      fprintf(f, "flowblind ");
 +                      fprintf(f, "(?flowmode?) ");
 +                      break;
 +              };
 +                      fprintf(f, "(?flowmode?) ");
 +                      break;
 +              };
++
++              if(nat)
++                      fprintf(f, "nat ");
 +      }
 +      if (tb[TCA_CAKE_ATM] &&
 +          RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) {
 +      }
 +      if (tb[TCA_CAKE_ATM] &&
 +          RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) {
 +      if (interval)
 +              fprintf(f, "rtt %s ", sprint_time(interval, b2));
 +
 +      if (interval)
 +              fprintf(f, "rtt %s ", sprint_time(interval, b2));
 +
-+      if (atm)
++      if (atm == 1)
 +              fprintf(f, "atm ");
 +              fprintf(f, "atm ");
++      else if (atm == 2)
++              fprintf(f, "ptm ");
 +      else if (overhead)
 +              fprintf(f, "noatm ");
 +
 +      else if (overhead)
 +              fprintf(f, "noatm ");
 +