diff options
author | d. johnson <fenris02@fedoraproject.org> | 2014-10-01 01:13:14 -0500 |
---|---|---|
committer | d. johnson <fenris02@fedoraproject.org> | 2014-10-01 01:13:14 -0500 |
commit | a61a8ad5f2501614b667a23f1091b9734e0f9c48 (patch) | |
tree | 99597f185d748d6548de51d7476bb66fc3ca37d7 | |
parent | f59794a19d23e6b1724d841185f89328ab81993b (diff) | |
download | cleanup-a61a8ad5f2501614b667a23f1091b9734e0f9c48.tar.gz cleanup-a61a8ad5f2501614b667a23f1091b9734e0f9c48.tar.xz cleanup-a61a8ad5f2501614b667a23f1091b9734e0f9c48.zip |
re-pull debloat files from https://github.com/dtaht/deBloat/tree/master/src
-rwxr-xr-x | debloat | 224 | ||||
-rwxr-xr-x | debloat.sh | 21 |
2 files changed, 123 insertions, 122 deletions
@@ -3,35 +3,35 @@ -- Use of various qdiscs for ethernet and wireless -- This script expects to be run in /etc/network/if-pre-up.d To run it --- manually, do a IFACE=yournetworkcard ./debloat +-- manually, do a IFACE=yournetworkcard ./debloat --- For NATTED interfaces, use a NAT=y for a better filter --- To select QFQ use QMODEL=qfq. +-- For NATTED interfaces, use a NAT=y for a better filter +-- To select QFQ use QMODEL=qfq. -- Some options currently require a new version of tc. Build a version -- of iproute2 and stick it somewhere and change the TC variable to --- suit. +-- suit. -- These are the possible parameters that can be changed via -- environment variables. -params = { "MDISC", "BIGDISC", "NORMDISC", "BINS", "MAX_HWQ_BYTES", +params = { "MDISC", "BIGDISC", "NORMDISC", "BINS", "MAX_HWQ_BYTES", "QMODEL", "FORCE_SPEED", "FORCE_RING", "QDEBUG", "VERBOSE", "UPLINK", "DOWNLINK", "IFACE", "SPEED", "DEPTH", "DEBLOATLOG", "NAT", "NAT64", "CLAMP_MSS", "SYN_FLOOD", "MTU", "INGRESS", "TC", "TCARG", "ETHTOOL", "INSMOD", "LSMOD", "IPTABLES", "IP6TABLES", "PINGOPT", "FLOWS", "TSO", "BURST", "IPV6", "OVERHEAD", "LINKLAYER", "MPU", "PPPOE", "ADSL", - "NOPRIOHOSTSRC","NOPRIOHOSTDST","NOPRIOPORTSRC", + "NOPRIOHOSTSRC","NOPRIOHOSTDST","NOPRIOPORTSRC", "NOPRIOPORTDST", "EST_MIN", "EST_MAX", "HEADDROP", "ECNMASK", "qlen_vo", "qlen_vi", "qlen_be", "qlen_bk", "CODEL_LL_QUANTUM" } -- Useful defaults -env = { ["TC"] = "/sbin/tc", - ["TCARG"] = "-b", +env = { ["TC"] = "/sbin/tc", + ["TCARG"] = "-b", ["INSMOD"] = "/sbin/modprobe", - ["ETHTOOL"] = "/sbin/ethtool", + ["ETHTOOL"] = "/sbin/ethtool", ["LSMOD"] = "/sbin/lsmod", ["IPTABLES"] = "/sbin/iptables", ["IP6TABLES"] = "/sbin/ip6tables", @@ -71,7 +71,7 @@ local open=io.open VO=0x10; VI=0x20; BE=0x30; BK=0x40 local WQUEUES = { BE, VO, VI, BK } -local function usage(s) o=[[ +local function usage(s) o=[[ The debloat tool aims for minimal latency (particularly under load) on the network, for hosts, servers, wireless devices, and routers. @@ -81,10 +81,10 @@ this is an unsolved problem! Most of the known techniques are in here, however, and the results can be quite remarkable. At tested rates of 100Mbit and 4Mbit, we see interstream latencies drop by over two orders of magnitude. - + This script expects to be run in /etc/network/if-pre-up.d -To run it manually, do a: +To run it manually, do a: IFACE=yournetworkcard ./this_script @@ -112,13 +112,13 @@ is helpful. * Some general overall design notes: This started out life as a shell script to exercise qfq, -Now it does a lot more than that and is getting crufty. +Now it does a lot more than that and is getting crufty. FQ_CODEL is now the default. SFQ has been improved significantly in Linux 3.3 (eliminating a head of line problem), and in this case no new TC utility is required. Also a bug in red was fixed, and no new tc utility is required there either. So if you were using either -or both of these qdiscs, you should automagically see your life +or both of these qdiscs, you should automagically see your life improve... QFQ is too buggy prior to 3.3 to use. @@ -128,7 +128,7 @@ version of TC. Also, most builds for the linux kernel do not enable QFQ by default. QFQ and SFQ are behaving competitively now in most circumstances, however. -* Byte Queue Limits is supposed to have a rate limiter that works. +* Byte Queue Limits is supposed to have a rate limiter that works. It is not very effective at less than 100Mbit. I get ~32k peak there and with GSO on, at 100Mbit, I have seen latency spikes of up to 70ms. @@ -186,7 +186,7 @@ question. How this interacts with bittorrent etc is also a good question. 512 is 4x as many bins as the old SFQ implementation. I have tested as many as 2048 bins, problems ensue with kernel -memory allocation at various levels higher than that. +memory allocation at various levels higher than that. The 'bin creation' problem is why this code uses tc in batch mode. It used to take minutes to create the bins. Now, a split second. (there @@ -223,7 +223,7 @@ need to be larger on gigE+. Might be wrong headed entirely. ** Multicast -We try to maltreat multicast especially in the QFQ implementation. +We try to maltreat multicast especially in the QFQ implementation. When handed to a load balancing filter based on IPs, multicast addresses are all over the map. It would be trivial to do a DOS with @@ -251,7 +251,7 @@ notably - the QMODEL var has various forms of AQM/FQ/shaper available. Available QMODELS are qfq, sfq, sfqred, efq and various combinations thereof, as well as a hard coded 4mbit htb_sfq_red model, and emulations -of the original wondershaper and a mildly improved one. See the +of the original wondershaper and a mildly improved one. See the tail end of the code for what is available. Most work on either ethernet or wireless and try to deal with @@ -284,17 +284,17 @@ function file_exists(name) if f ~= nil then f:close(); return true else return false end end -local function is_openwrt() - if file_exists("/etc/uci-defaults") then - return true - else - return false +local function is_openwrt() + if file_exists("/etc/uci-defaults") then + return true + else + return false end end -- Override various defaults with env vars -if is_openwrt() then +if is_openwrt() then env.INSMOD = "/sbin/insmod" env.ETHTOOL = "/usr/sbin/ethtool" env.TC = "/usr/sbin/tc" @@ -305,14 +305,14 @@ end local function getconf() end --- getenv pulls in everything as strings, +-- getenv pulls in everything as strings, -- so do the conversion here local function fromenv(v) local s = os.getenv(v) if s == nil then return nil end -- FIXME allow . - local m = string.match(s,"^%d+") + local m = string.match(s,"^%d+") if m ~= nil then return tonumber(s) end if s == "true" then return true end if s == "false" then return false end @@ -331,7 +331,7 @@ end env = getenvs(params, env) -if (env["IFACE"] == nil) then +if (env["IFACE"] == nil) then usage("Error: The IFACE environment variable must be set") end @@ -341,13 +341,13 @@ BINS=env.BINS MULTICAST=BINS+1 DEFAULTB=BINS+2 -PREREQS = { "sch_qfq", "sch_codel", "sch_fq_codel", "cls_u32", "cls_flow", +PREREQS = { "sch_qfq", "sch_codel", "sch_fq_codel", "cls_u32", "cls_flow", "sch_sfq", "sch_red", "sch_htb", "cls_fw", "sch_efq_codel", "sch_ns2_codel", "sch_nfq_codel" } -- we can get more complex later -PREREQS2 = { +PREREQS2 = { ["qfq"] = { "sch_qfq", "cls_u32", "cls_flow" }, ["sfq"] = { "sch_sfq", "cls_u32", "cls_flow" }, ["red"] = { "sch_qfq", "sch_red", "cls_u32", "cls_flow" }, @@ -371,7 +371,7 @@ end function slurpf(file) local f = open(file,"r") - if f ~= nil then + if f ~= nil then local s = f:read("*all") f:close() return s @@ -384,7 +384,7 @@ end function spewc(command,s) local f = popen(command,"w") if f ~= nil then - local v = f:write(s) + local v = f:write(s) f:close() return v end @@ -396,7 +396,7 @@ end function spewf(file,s) local f = open(file,"w") if f ~= nil then - local v = f:write(s) + local v = f:write(s) f:close() return v end @@ -415,7 +415,7 @@ end function slurpc(command) local f = popen(command,"r") - if f ~= nil then + if f ~= nil then local s = f:read("*all") f:close() return s @@ -524,7 +524,7 @@ function kleinrock(bandwidth, delay, flows) end function bound(v,min,max) - if max < min then + if max < min then local t = max max = min min = t @@ -545,7 +545,7 @@ end -- Don't like these side effects -local function htb_est() +local function htb_est() s = " " if env.PPPOE then env.OVERHEAD=40 end if env.ADSL then env.LINKLAYER="adsl" end @@ -579,7 +579,7 @@ end target = 50 -- The problem with byte oriented red is that it will never --- kick in or mark acks. +-- kick in or mark acks. local function redflowlimit(up,down) local OVERHEAD=0 @@ -718,7 +718,7 @@ end -- test the offloads problem -- we have a wide range of possible inputs to test against as yet -function test_offloads(iface) +function test_offloads(iface) local o = offloads(iface) if o ~= nil then for i,v in pairs(o) do @@ -750,7 +750,7 @@ function ring_params(iface) return t end -function test_ring_params(iface) +function test_ring_params(iface) local o = ring_params(iface) for i,v in pairs(o) do print(sf("%s %s",i,v)) @@ -776,12 +776,12 @@ end -- Maybe better done with ethtool -local function speed_set(iface,speed) +local function speed_set(iface,speed) return spewf(sf("/sys/class/net/%s/speed",iface),speed) end -local function speed_get(iface) - return slurpf(sf("/sys/class/net/%s/speed",iface)) +local function speed_get(iface) + return slurpf(sf("/sys/class/net/%s/speed",iface)) end local function rate_quantum(rate) @@ -791,7 +791,7 @@ end -- Doing this as a lookup table hurt lua -- FIXME: Not clear how to reset to advertising all --- Not clear how to reset this parameter from +-- Not clear how to reset this parameter from -- userspace to autonegotiate -- What to do with non-sensical values that you -- get before an interface is live? @@ -846,7 +846,7 @@ end -- does this need to be integer? -- FIXME the effect of rounding really isn't what we want -local function r2s(rate) +local function r2s(rate) if round(rate) < 1000 then return round(rate) .. "kbit" end local r = rate/1000 if round(r) < 1000 then return round(r) .. "mbit" end @@ -879,28 +879,28 @@ local capstring=sf("class add dev %s parent ", env.IFACE) local fapstring=sf("filter add dev %s parent ",env.IFACE) local qapstring=sf("qdisc add dev %s parent ", env.IFACE) -local function ca(...) - return tc:write(castring,sf(...),"\n") +local function ca(...) + return tc:write(castring,sf(...),"\n") end -local function cap(...) - return tc:write(capstring,sf(...),"\n") +local function cap(...) + return tc:write(capstring,sf(...),"\n") end -local function fa(...) - return tc:write(fastring,sf(...),"\n") +local function fa(...) + return tc:write(fastring,sf(...),"\n") end -local function fap(...) - return tc:write(fapstring,sf(...),"\n") +local function fap(...) + return tc:write(fapstring,sf(...),"\n") end -local function qa(...) - return tc:write(qastring,sf(...),"\n") +local function qa(...) + return tc:write(qastring,sf(...),"\n") end -local function qap(...) - return tc:write(qapstring,sf(...),"\n") +local function qap(...) + return tc:write(qapstring,sf(...),"\n") end -- FIXME sanely calculate htb rate, overhead, etc, etc @@ -939,13 +939,13 @@ end -- FIXME: It would be nice to have a cleaner way to match all multicast -local function fa_mcast(parent) +local function fa_mcast(parent) fap("%x: protocol ip prio 5 u32 match u8 0x01 0x01 at -14 flowid %x:%x",parent,parent,MULTICAST) fap("%x: protocol ipv6 prio 6 u32 match u8 0x01 0x01 at -14 flowid %x:%x",parent,parent,MULTICAST) fap("%x: protocol arp prio 7 u32 match u8 0x01 0x01 at -14 flowid %x:%x",parent,parent,MULTICAST) end -local function fa_defb(parent) +local function fa_defb(parent) fap("%x: protocol all prio 999 u32 match ip protocol 0 0x00 flowid %x:%x",parent,parent,DEFAULTB) end @@ -980,7 +980,7 @@ end local function q_bins(parent) for i=0,env.BINS do - cap("%x: classid %x:%x qfq",parent,parent,i) + cap("%x: classid %x:%x qfq",parent,parent,i) qap("%x:%x %s",parent,i,env.BIGDISC) end end @@ -999,11 +999,11 @@ end -- fa("protocol ipv6 parent %x: handle 4 prio 98 flow hash keys proto-dst,rxhash divisor %d",parent,BINS) end --- Eric's Enhanced SFQ +-- Eric's Enhanced SFQ -- FIXME: originally hard coded for 200Mbit -- I'm going to argue that depth, flows, speed all need to be --- done via something kleinrock-like. The problem is that +-- done via something kleinrock-like. The problem is that -- we don't know the delay without hitting the next hop -- And we can't get the next hop until after the interface is -- up. And even then we can only measure RTT, which is off @@ -1111,7 +1111,7 @@ end -- Note: awkward in previous call due to hold space usage -- Magic borrowed from openwrt generate.sh -function iptables_aqm_clean() +function iptables_aqm_clean() tstr="-t mangle -S | grep '^-N qos_\|-j qos_' | grep -v '^-A qos_' | sed -e '/^-N/{s/^-N/-X/;H;s/^-X/-F/}' -e 's/^-A/-D/' -e '${p;g}' | sed -n -e 's/^./iptables -t mangle &/p'" iptables4(tstr) tstr="-t mangle -S | grep '^-N qos_\|-j qos_' | grep -v '^-A qos_' | sed -e '/^-N/{s/^-N/-X/;H;s/^-X/-F/}' -e 's/^-A/-D/' -e '${p;g}' | sed -n -e 's/^./ip6tables -t mangle &/p'" @@ -1142,7 +1142,7 @@ function aqm_init(cg) -- $up$N${down:+${down}$N} end -local function mcast_classify(chain,class) +local function mcast_classify(chain,class) iptables(sf("-t mangle -A %s -m pkttype ! --pkt-type unicast -j CLASSIFY --set-class %s",chain,class)) end @@ -1155,20 +1155,20 @@ local ds = { ["BE"]=0, ["AF11"]=10, ["AF12"]=12, ["AF13"]=14, } -- No matter what I try I get this wrong. You would think 1:1,2,3,4 --- was the right thing. Nope. +-- was the right thing. Nope. -- So 1:1 doesn't work. 1:10 doesn't work. Trying 1:101 etc because -- that's a magic value and.... -- And IPv6 multicast is never matched. -local function mac80211e() +local function mac80211e() local t = "-t mangle -A W80211e -m dscp --dscp %d -j CLASSIFY --set-class 0:%d -m comment --comment '%s'" local function f(...) iptables(sf(t,...)) end - + recreate_filter({table="mangle",chain="W80211e"}) - + iptables("-t mangle -A W80211e -j CLASSIFY --set-class 0:103 -m comment --comment 'Reclassify BE'") f(ds.EF, 106,'Voice (EF)') f(ds.CS6, 106,'Critical (VO)') @@ -1202,7 +1202,7 @@ end -- Basic SFQ on wireless -- FIXME: We must get ALL multicast out of the other queues --- and into the VO queue. Always. Somehow. +-- and into the VO queue. Always. Somehow. -- It also makes sense to do EF into the VO queue and match the -- default behavior inside of the MAC80211 code for scheduling @@ -1224,7 +1224,7 @@ local function wireless_setup(queuetype) end -local function wireless_qlen_change(base) +local function wireless_qlen_change(base) for i=1, # qlens do q = qlens[i] d = sf("%s/%s",base,q) @@ -1235,7 +1235,7 @@ local function wireless_qlen_change(base) end end -local function wireless_qlen() +local function wireless_qlen() -- Sure we could inspect things here but whatever wireless_qlen_change(sf("%s/%s",wireless_debug,"phy0/ath9k")) wireless_qlen_change(sf("%s/%s",wireless_debug,"phy1/ath9k")) @@ -1254,7 +1254,7 @@ end -- ingress model -- this is why I wanted my tc things -- to be objects, e.g: --- dev = tc.new() +-- dev = tc.new() -- dev:qa ifb:qa local function sfqred_ingress() @@ -1274,7 +1274,7 @@ local function sfqred_ingress() -- Class for traffic coming from Internet : limited to X Mbits tc:write(sf("class add dev %s parent 1:1 classid 1:11 cbq allot %d mpu 64 rate %dkbit bandwidth %dkbit maxburst 80 minburst 40 prio 2 avpkt 1400 bounded\n", IFB, ALLOT, RATE, RATE)) - + tc:write(sf("qdisc add dev %s parent 1:11 handle 11: sfq limit 300 quantum 1500 headdrop flows 2048 divisor 16384 redflowlimit 60000 min 9000 max 27000 probability 0.20 ecn harddrop\n", IFB)) -- Traffic from machines in our LAN : no limit @@ -1324,7 +1324,7 @@ local function wireless_sfq() wireless_setup("sfq limit 40 perturb 6000") end --- erics sfq and erics sfqred with +-- erics sfq and erics sfqred with -- some arbitrary speeds and bandwidths (unused) -- TiQ would be better @@ -1357,9 +1357,9 @@ local function model_qfq_subdisc(base) cb(base,MULTICAST,env.MDISC) cb(base,DEFAULTB,env.NORMDISC) fa_defb(base) - fa_mcast(base); + fa_mcast(base); q_bins(base); - fa_bins(base); + fa_bins(base); end local function model_choke_subdisc(base) @@ -1371,9 +1371,9 @@ local function one_over_ip(base) cb(base,MULTICAST,env.MDISC) cb(base,DEFAULTB,env.NORMDISC) fa_defb(base) - fa_mcast(base); + fa_mcast(base); q_bins(base); - faip_bins(base); + faip_bins(base); end -- DRR @@ -1404,14 +1404,14 @@ local function choke(queues) local est = sf("est %dsec %dsec", env.EST_MIN, env.EST_MAX) local mtu = env.MTU -- local limit,min,max = chokelimit(up,env.DOWNLINK) - qa("root handle 1: choke bandwidth %dkbit limit 32 min 4 max 12 probability .2 ecn", + qa("root handle 1: choke bandwidth %dkbit limit 32 min 4 max 12 probability .2 ecn", up) end end -- hap - + -- Using the same parameters as in Section V, we can estimate , queue -- size oscillates the minimal N to be 8.08. When packets, constantly -- turning CHOKe on and off, around as shown in Fig. 9 (compare with @@ -1431,13 +1431,13 @@ local function htb_choke(queues) local est = sf("est %dsec %dsec", env.EST_MIN, env.EST_MAX) local mtu = env.MTU qa("root handle 1: %s htb default 1", est) - cap("1: classid 1:1 %s htb burst 64 rate %dkibit mtu 1500 mpu 64", est, up) --- qap("1:1 handle 10: choke bandwidth %dkbit limit 32 min 4 max 16 probability .2 ecn", + cap("1: classid 1:1 %s htb burst 64 rate %dkibit mtu 1500 mpu 64", est, up) +-- qap("1:1 handle 10: choke bandwidth %dkbit limit 32 min 4 max 16 probability .2 ecn", -- up) --- at 4Mbit, choke will keep 2 .. 8 packets for min, max if +-- at 4Mbit, choke will keep 2 .. 8 packets for min, max if -- you just set the bandwidth -- at 40mbit choke will keep 4..12 --- from the doc, this is bytes. From the code, this turns pkts into avpkts?? +-- from the doc, this is bytes. From the code, this turns pkts into avpkts?? qap("1:1 handle 10: choke bandwidth %dkbit limit 24 min 2 max 12 probability .2 ecn", up) end end @@ -1529,18 +1529,18 @@ local function model_qfq_ared(base) cb(base,MULTICAST,env.MDISC) cb(base,DEFAULTB,env.NORMDISC) fa_defb(base) - fa_mcast(base); + fa_mcast(base); q_bins(base); - fa_bins(base); + fa_bins(base); end local function model_qfq_red(base) cb(base,MULTICAST,env.MDISC) cb(base,DEFAULTB,env.NORMDISC) fa_defb(base) - fa_mcast(base); + fa_mcast(base); q_bins(base); - fa_bins(base); + fa_bins(base); end local function model_sfq(base) @@ -1569,7 +1569,7 @@ end -- FIXME: just stubs for now local function wireless_ared() - qa("handle 1 root mq") + qa("handle 1 root mq") for i,v in ipairs(WQUEUES) do model_qfq_ared(v) end @@ -1662,19 +1662,19 @@ local function fw_fap(parent, class, v, pref) -- tc filter add dev ge00 parent 1: prio 4 protocol ip handle 4/0xff fw flowid 1:40 -- fap("%s protocol ip pref %d fw 0x%x/0x%x classid %s", parent,pref, v, mask, class ) --- fap("%s protocol ipv6 pref %d fw 0x%x/0x%x classid %s", parent,pref, v, mask, class +-- fap("%s protocol ipv6 pref %d fw 0x%x/0x%x classid %s", parent,pref, v, mask, class fap("%s protocol all pref %d handle %x/0x%x fw flowid %s", parent, pref, v, mask, class ) end -- return min, max local function uplink_to_red(uplink) - + end local function wireless_sfqr(queues) -- local quantum = rate_quantum(up) -- convert to number - local quantum = rate_quantum(4000) + local quantum = rate_quantum(4000) local mtu = env.MTU -- local mtu = 1500 @@ -1687,7 +1687,7 @@ local function wireless_sfqr(queues) -- qap("1:%x handle %x: sfq limit 120 headdrop perturb 60000 flows %d divisor 16384 quantum 4500 depth 24 redflowlimit 30000 min 6000 max 18000 probability 0.20 ecn harddrop", parent, handle, 2000) -- fw_fap("1:",sf("1:%x",handle),prio,mark) end - + qa("root handle 1: mq ") red(1,10,1,1) red(2,20,2,2) @@ -1709,7 +1709,7 @@ local function fourtier(queues) -- just straight sfq local function red4(parent,handle,prio,mark) - cap("1: classid 1:%x %s htb rate %skibit mtu %d mpu 64 quantum %d", + cap("1: classid 1:%x %s htb rate %skibit mtu %d mpu 64 quantum %d", parent, est, up, mtu, quantum) qap("1:%x handle %x: %s sfq limit 200", parent, handle, est) @@ -1719,7 +1719,7 @@ local function fourtier(queues) -- Hammered down on the defaults local function red(parent,handle,prio,mark) - cap("1: classid 1:%x %s htb rate %skibit mtu %d mpu 64 quantum %d", + cap("1: classid 1:%x %s htb rate %skibit mtu %d mpu 64 quantum %d", parent, est, up, mtu, quantum) qap("1:%x handle %x: %s sfq limit 200 headdrop quantum 1524 perturb 60000 flows %d divisor 16384 depth 24 redflowlimit 9000 min 1500 max 4500 probability 0.20 ecn harddrop", parent, handle, est, 2000) @@ -1729,13 +1729,13 @@ local function fourtier(queues) -- still trying to find a useful operating point local function red2(parent,handle,prio,mark) - cap("1: classid 1:%x %s htb rate %skibit mtu %d mpu 64 quantum %d", + cap("1: classid 1:%x %s htb rate %skibit mtu %d mpu 64 quantum %d", parent, est, up, mtu, quantum) qap("1:%x handle %x: %s sfq limit 200 headdrop quantum 1524 perturb 60000 flows %d divisor 16384 depth 24 redflowlimit 40000 min 4500 max 9000 probability 0.20 ecn harddrop", parent, handle, est, 2000) fw_fap("1:",sf("1:%x",handle),prio,mark) end - + qa("root handle 1: %s htb default 1", est) red(1,10,1,1) red(2,20,2,2) @@ -1749,7 +1749,7 @@ end -- The current openwrt shaper uses a combination of -- HFSC, SFQ, and RED -function tcrules(cstr,rate) +function tcrules(cstr,rate) dir="/usr/lib/aqm" if file(sf("%s/tcrules.awk")) then spewc(sf("awk -v device=\"%s\" -v linespeed=\"%s\" -f %s/tcrules.awk",env.IFACE,rate,dir), cstr) @@ -1766,7 +1766,7 @@ function oopenwrt(queues) usage("Not complete yet") if env.DOWNLOAD then qa("ingress") - fap("ffff: protocol ip prio 1 u32 match u32 0 0 flowid 1:1 action connmark action mirred egress redirect dev ifb%d",ifbdev,n) + fap("ffff: protocol ip prio 1 u32 match u32 0 0 flowid 1:1 action connmark action mirred egress redirect dev ifb%d",ifbdev,n) end end @@ -1776,7 +1776,7 @@ local function unsupported_shaper(queues) usage("Shaper not supported for wireless") end --- The wondershaper +-- The wondershaper -- This is improved over the original wondershaper with -- Correct ECN support -- FIXME: IPv6 support @@ -1820,7 +1820,7 @@ local function wshaper(queues) fap("1:0 protocol ip prio 10 u32 match ip tos 0x10 0x%x flowid 1:10",env.ECNMASK) --- ICMP (ip protocol 1) in the interactive class 1:10 so we +-- ICMP (ip protocol 1) in the interactive class 1:10 so we -- can do measurements & impress our friends: pingopt("1:0","1:10") @@ -1852,7 +1852,7 @@ local function np(args,prio,match,h) end end -if env.NOPRIOPORTDST ~= nil then +if env.NOPRIOPORTDST ~= nil then np(env.NOPRIOPORTDST,14,"dport","0xffff") end @@ -1864,7 +1864,7 @@ if env.NOPRIOHOSTSRC ~= nil then np(env.NOPRIOHOSTSRC,16,"src"," ") end -if env.NOPRIOHOSTDST ~= nil then +if env.NOPRIOHOSTDST ~= nil then np(env.NOPRIOHOSTDST,17,"dst"," ") end @@ -1910,14 +1910,14 @@ end -- first. Need to also be able to stick HSFC, netem, or HTB -- on top of this -WCALLBACKS = { ["qfq"] = wireless_qfq, +WCALLBACKS = { ["qfq"] = wireless_qfq, ["qfqred"] = wireless_qfqr, ["red"] = wireless_red, ["ared"] = wireless_ared, ["sfq"] = wireless_sfq, ["efq"] = wireless_efq, - ["sfqred"] = wireless_efqr, - ["sfqr"] = wireless_sfqr, + ["sfqred"] = wireless_efqr, + ["sfqr"] = wireless_sfqr, ["codel"] = wireless_codel, ["fq_codel"] = wireless_fq_codel, ["fq_codel_ll"] = wireless_fq_codel_ll, @@ -1928,14 +1928,14 @@ WCALLBACKS = { ["qfq"] = wireless_qfq, ["ns2_codel"] = wireless_ns2_codel, ["ns2_codel_ll"] = wireless_ns2_codel_ll, ["htb_sfq_red"] = unsupported_shaper, - ["oopenwrt"] = unsupported_shaper, + ["oopenwrt"] = unsupported_shaper, ["owshaper"] = unsupported_shaper, ["wshaper"] = wireless_wshaper, ["twotier"] = unsupported_shaper, ["fourtier"] = unsupported_shaper } -ECALLBACKS = { ["qfq"] = ethernet_qfq, +ECALLBACKS = { ["qfq"] = ethernet_qfq, ["qfqred"] = ethernet_qfqr, ["red"] = ethernet_red, ["ared"] = ethernet_ared, @@ -1977,7 +1977,7 @@ local function wireless(model) print(model) if WCALLBACKS[model] ~= nil then wireless_qlen() - return WCALLBACKS[model]() + return WCALLBACKS[model]() else usage("AQM model not found") end @@ -1985,8 +1985,8 @@ local function wireless(model) end local function ethernet(model) - if ECALLBACKS[model] ~= nil then - return ECALLBACKS[model](ethernet_setup(IFACE)) + if ECALLBACKS[model] ~= nil then + return ECALLBACKS[model](ethernet_setup(IFACE)) else usage("AQM model not found") end @@ -1997,7 +1997,7 @@ end -- And confusing to the user if env.PINGOPT then - pingopt = function(parent,flow) + pingopt = function(parent,flow) fap("%s protocol ip prio 10 u32 match ip protocol 1 0xff flowid %s",parent,flow) if(env.IPV6) then -- arguably we should only match echo and echo reply but... @@ -2020,8 +2020,8 @@ if itype == 'wireless' or itype == 'ethernet' then kernel_prereqs(PREREQS) tc = resettc() - if itype == 'wireless' then - wireless(env.QMODEL) + if itype == 'wireless' then + wireless(env.QMODEL) -- FIXME: you watch this code set the class, then not show up in tc -- mac80211e() -- iptables_insert(IFACE,"W80211e") @@ -1,18 +1,20 @@ #!/bin/bash -# debloat.sh - improves network latency by reducing excessive buffering +# debloat.sh - improves network latency by reducing excessive buffering # and offloads on common devices and enabling fq_codel. # Copyright 2012 M D Taht. Released into the public domain. -# This script is presently targetted to go into +# This script is presently targetted to go into # /etc/network/ifup.d on debian derived systems +[[ "$IFACE" == "lo" ]] && exit 0 + LL=1 # go for lowest latency ECN=1 # enable ECN BQLLIMIT100=3000 # at speeds below 100Mbit, 2 big packets is enough -BQLLIMIT10=1514 # at speeds below 10Mbit, 1 big packet is enough. +BQLLIMIT10=1514 # at speeds below 10Mbit, 1 big packet is enough. # Actually it would be nice to go to just one packet QDISC=fq_codel # There are multiple variants of fq_codel in testing -FQ_LIMIT="" # the default 10000 packet limit mucks with slow start at speeds +FQ_LIMIT="" # the default 10000 packet limit mucks with slow start at speeds # at 1Gbit and below. Somewhat arbitrary figures selected. [ -z "$IFACE" ] && echo error: $0 expects IFACE parameter in environment && exit 1 @@ -20,7 +22,7 @@ FQ_LIMIT="" # the default 10000 packet limit mucks with slow start at speeds [ -z `which tc` ] && echo error: tc is required && exit 1 # FIXME see if $QDISC is available. modprobe? -# BUGS - need to detect bridges. +# BUGS - need to detect bridges. # - Need filter to distribute across mq ethernet devices # - needs an "undebloat" script for ifdown to restore BQL autotuning @@ -55,7 +57,7 @@ et() { # to be voice, video, best effort and background wifi() { - tc qdisc add dev $IFACE handle 1 root mq + tc qdisc add dev $IFACE handle 1 root mq tc qdisc add dev $IFACE parent 1:1 $QDISC $FQ_OPTS noecn tc qdisc add dev $IFACE parent 1:2 $QDISC $FQ_OPTS tc qdisc add dev $IFACE parent 1:3 $QDISC $FQ_OPTS @@ -67,7 +69,7 @@ wifi() { mq() { local I=1 - tc qdisc add dev $IFACE handle 1 root mq + tc qdisc add dev $IFACE handle 1 root mq for i in $S/$IFACE/queues/tx-* do @@ -88,7 +90,7 @@ local SPEED=`cat $S/$IFACE/speed` 2> /dev/null if [ -n "$SPEED" ] then [ "$SPEED" = 4294967295 ] && echo "no ethernet speed selected. debloat estimate will be WRONG" - [ "$SPEED" -lt 1001 ] && FQ_LIMIT=1200 + [ "$SPEED" -lt 1001 ] && FQ_LIMIT="limit 1200" if [ "$SPEED" -lt 101 ] then [ $LL -eq 1 ] && et # for lowest latency disable offloads @@ -107,7 +109,7 @@ fix_queues() { local QUEUES=`ls -d $S/$IFACE/queues/tx-* | wc -l | awk '{print $1}'` if [ $QUEUES -gt 1 ] then - if [ -x $S/$IFACE/phy80211 ] + if [ -x $S/$IFACE/phy80211 ] then wifi else @@ -124,4 +126,3 @@ fix_speed fix_queues exit 0 - |