Fresh pull from upstream 17.01 branch
[librecmc/librecmc.git] / package / network / utils / iproute2 / patches / 950-add-cake-to-tc.patch
index 6c73fbaf25cf9b0fda93e959b822917c268a66ba..8da17112be6c43489f31d38953be71923ee7d027 100644 (file)
@@ -1,6 +1,8 @@
+diff --git a/include/linux/pkt_sched.h b/include/linux/pkt_sched.h
+index 8d2530d..c55a9a8 100644
 --- a/include/linux/pkt_sched.h
 +++ b/include/linux/pkt_sched.h
-@@ -850,4 +850,59 @@ struct tc_pie_xstats {
+@@ -850,4 +850,60 @@ struct tc_pie_xstats {
        __u32 maxq;             /* maximum queue size */
        __u32 ecn_mark;         /* packets marked with ecn*/
  };
@@ -20,6 +22,7 @@
 +      TCA_CAKE_NAT,
 +      TCA_CAKE_ETHERNET,
 +      TCA_CAKE_WASH,
++      TCA_CAKE_MPU,
 +      __TCA_CAKE_MAX
 +};
 +#define TCA_CAKE_MAX  (__TCA_CAKE_MAX - 1)
@@ -60,6 +63,8 @@
 +};
 +
  #endif
+diff --git a/tc/Makefile b/tc/Makefile
+index 56acbaa..d421b8e 100644
 --- a/tc/Makefile
 +++ b/tc/Makefile
 @@ -63,6 +63,7 @@ TCMODULES += q_codel.o
  TCMODULES += q_hhf.o
  TCMODULES += e_bpf.o
  
+diff --git a/tc/q_cake.c b/tc/q_cake.c
+new file mode 100644
+index 0000000..acbe56c
 --- /dev/null
 +++ b/tc/q_cake.c
-@@ -0,0 +1,663 @@
+@@ -0,0 +1,692 @@
 +/*
 + * Common Applications Kept Enhanced  --  CAKE
 + *
 +
 +static void explain(void)
 +{
-+      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 | diffserv-llt | diffserv3* ]\n"
-+                      "                [ flowblind | srchost | dsthost | hosts | flows | dual-srchost | dual-dsthost | triple-isolate* ] [ nat | nonat* ]\n"
-+                      "                [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
-+                      "                [ wash | nowash* ]\n"
-+                      "                [ memlimit LIMIT ]\n"
-+                      "    (* marks defaults)\n");
++      fprintf(stderr,
++"Usage: ... cake [ bandwidth RATE | unlimited* | autorate_ingress ]\n"
++"                [ rtt TIME | datacentre | lan | metro | regional |\n"
++"                  internet* | oceanic | satellite | interplanetary ]\n"
++"                [ besteffort | diffserv8 | diffserv4 | diffserv-llt |\n"
++"                  diffserv3* ]\n"
++"                [ flowblind | srchost | dsthost | hosts | flows |\n"
++"                  dual-srchost | dual-dsthost | triple-isolate* ]\n"
++"                [ nat | nonat* ]\n"
++"                [ wash | nowash * ]\n"
++"                [ memlimit LIMIT ]\n"
++"                [ ptm | atm | noatm* ] [ overhead N | conservative | raw* ]\n"
++"                [ mpu N ]\n"
++"                (* marks defaults)\n");
 +}
 +
 +static int cake_parse_opt(struct qdisc_util *qu, int argc, char **argv,
 +      bool overhead_set = false;
 +      bool overhead_override = false;
 +      int wash = -1;
++      int mpu = 0;
 +      int flowmode = -1;
 +      int nat = -1;
 +      int atm = -1;
 +                       * you may need to add vlan tag */
 +                      overhead += 38;
 +                      overhead_set = true;
++                      mpu = 84;
 +
 +              /* Additional Ethernet-related overhead used by some ISPs */
 +              } else if (strcmp(*argv, "ether-vlan") == 0) {
 +                      atm = 0;
 +                      overhead += 18;
 +                      overhead_set = true;
++                      mpu = 64;
 +
 +              } else if (strcmp(*argv, "overhead") == 0) {
 +                      char* p = NULL;
 +                      }
 +                      overhead_set = true;
 +
++              } else if (strcmp(*argv, "mpu") == 0) {
++                      char* p = NULL;
++                      NEXT_ARG();
++                      mpu = strtol(*argv, &p, 10);
++                      if(!p || *p || !*argv || mpu < 0 || mpu > 256) {
++                              fprintf(stderr, "Illegal \"mpu\", valid range is 0 to 256\\n");
++                              return -1;
++                      }
++
 +              } else if (strcmp(*argv, "memlimit") == 0) {
 +                      NEXT_ARG();
 +                      if(get_size(&memlimit, *argv)) {
 +              unsigned zero = 0;
 +              addattr_l(n, 1024, TCA_CAKE_ETHERNET, &zero, sizeof(zero));
 +      }
++      if (mpu > 0)
++              addattr_l(n, 1024, TCA_CAKE_MPU, &mpu, sizeof(mpu));
 +      if (interval)
 +              addattr_l(n, 1024, TCA_CAKE_RTT, &interval, sizeof(interval));
 +      if (target)
 +      unsigned memlimit = 0;
 +      int overhead = 0;
 +      int ethernet = 0;
++      int mpu = 0;
 +      int atm = 0;
 +      int nat = 0;
 +      int autorate = 0;
 +          RTA_PAYLOAD(tb[TCA_CAKE_OVERHEAD]) >= sizeof(__u32)) {
 +              overhead = rta_getattr_u32(tb[TCA_CAKE_OVERHEAD]);
 +      }
++      if (tb[TCA_CAKE_MPU] &&
++          RTA_PAYLOAD(tb[TCA_CAKE_MPU]) >= sizeof(__u32)) {
++              mpu = rta_getattr_u32(tb[TCA_CAKE_MPU]);
++      }
 +      if (tb[TCA_CAKE_ETHERNET] &&
 +          RTA_PAYLOAD(tb[TCA_CAKE_ETHERNET]) >= sizeof(__u32)) {
 +              ethernet = rta_getattr_u32(tb[TCA_CAKE_ETHERNET]);
 +                      fprintf(f, "via-ethernet ");
 +      }
 +
++      if (mpu) {
++              fprintf(f, "mpu %d ", mpu);
++      }
++
 +      if (memlimit)
 +              fprintf(f, "memlimit %s", sprint_size(memlimit, b1));
 +