From: Kevin Darbyshire-Bryant Date: Wed, 21 Sep 2016 08:45:33 +0000 (+0100) Subject: iproute2: tc cake qdisc add nat, docsis & ptm modes X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=4ef1144958eefbfe8e74f571b3e8188a174e6a24;p=openwrt%2Fstaging%2Fzorun.git iproute2: tc cake qdisc add nat, docsis & ptm modes 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 --- diff --git a/package/network/utils/iproute2/Makefile b/package/network/utils/iproute2/Makefile index 4b17e19fb1..9575ff1056 100644 --- a/package/network/utils/iproute2/Makefile +++ b/package/network/utils/iproute2/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk 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 diff --git a/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch b/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch index 5e5178498a..ffb3e63e13 100644 --- a/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch +++ b/package/network/utils/iproute2/patches/950-add-cake-to-tc.patch @@ -1,6 +1,6 @@ --- 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*/ }; @@ -17,6 +17,7 @@ + TCA_CAKE_TARGET, + TCA_CAKE_AUTORATE, + TCA_CAKE_MEMORY, ++ TCA_CAKE_NAT, + __TCA_CAKE_MAX +}; +#define TCA_CAKE_MAX (__TCA_CAKE_MAX - 1) @@ -69,7 +70,7 @@ --- /dev/null +++ b/tc/q_cake.c -@@ -0,0 +1,600 @@ +@@ -0,0 +1,643 @@ +/* + * Common Applications Kept Enhanced -- CAKE + * @@ -126,8 +127,8 @@ + 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"); +} @@ -144,6 +145,7 @@ + int overhead = 0; + bool overhead_set = false; + int flowmode = -1; ++ int nat = -1; + int atm = -1; + int autorate = -1; + struct rtattr *tail; @@ -228,6 +230,13 @@ + } 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) { @@ -247,7 +256,29 @@ + 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; @@ -281,20 +312,23 @@ + 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) { -+ atm = 0; ++ atm = 2; + overhead += 27; ++ overhead_set = true; + } else if (strcmp(*argv, "bridged-ptm") == 0) { -+ atm = 0; ++ atm = 2; + overhead += 19; ++ overhead_set = true; + + } 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; @@ -371,6 +405,8 @@ + 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; @@ -387,6 +423,7 @@ + unsigned memlimit = 0; + int overhead = 0; + int atm = 0; ++ int nat = 0; + int autorate = 0; + SPRINT_BUF(b1); + SPRINT_BUF(b2); @@ -439,6 +476,8 @@ + 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 "); @@ -468,6 +507,9 @@ + fprintf(f, "(?flowmode?) "); + break; + }; ++ ++ if(nat) ++ fprintf(f, "nat "); + } + if (tb[TCA_CAKE_ATM] && + RTA_PAYLOAD(tb[TCA_CAKE_ATM]) >= sizeof(__u32)) { @@ -485,8 +527,10 @@ + if (interval) + fprintf(f, "rtt %s ", sprint_time(interval, b2)); + -+ if (atm) ++ if (atm == 1) + fprintf(f, "atm "); ++ else if (atm == 2) ++ fprintf(f, "ptm "); + else if (overhead) + fprintf(f, "noatm "); +