1*de1e4e89SAndroid Build Coastguard Worker 2*de1e4e89SAndroid Build Coastguard WorkerIFB is intended to replace IMQ. 3*de1e4e89SAndroid Build Coastguard WorkerAdvantage over current IMQ; cleaner in particular in in SMP; 4*de1e4e89SAndroid Build Coastguard Workerwith a _lot_ less code. 5*de1e4e89SAndroid Build Coastguard Worker 6*de1e4e89SAndroid Build Coastguard WorkerKnown IMQ/IFB USES 7*de1e4e89SAndroid Build Coastguard Worker------------------ 8*de1e4e89SAndroid Build Coastguard Worker 9*de1e4e89SAndroid Build Coastguard WorkerAs far as i know the reasons listed below is why people use IMQ. 10*de1e4e89SAndroid Build Coastguard WorkerIt would be nice to know of anything else that i missed. 11*de1e4e89SAndroid Build Coastguard Worker 12*de1e4e89SAndroid Build Coastguard Worker1) qdiscs/policies that are per device as opposed to system wide. 13*de1e4e89SAndroid Build Coastguard WorkerIFB allows for sharing. 14*de1e4e89SAndroid Build Coastguard Worker 15*de1e4e89SAndroid Build Coastguard Worker2) Allows for queueing incoming traffic for shaping instead of 16*de1e4e89SAndroid Build Coastguard Workerdropping. I am not aware of any study that shows policing is 17*de1e4e89SAndroid Build Coastguard Workerworse than shaping in achieving the end goal of rate control. 18*de1e4e89SAndroid Build Coastguard WorkerI would be interested if anyone is experimenting. 19*de1e4e89SAndroid Build Coastguard Worker 20*de1e4e89SAndroid Build Coastguard Worker3) Very interesting use: if you are serving p2p you may wanna give 21*de1e4e89SAndroid Build Coastguard Workerpreference to your own localy originated traffic (when responses come back) 22*de1e4e89SAndroid Build Coastguard Workervs someone using your system to do bittorent. So QoSing based on state 23*de1e4e89SAndroid Build Coastguard Workercomes in as the solution. What people did to achive this was stick 24*de1e4e89SAndroid Build Coastguard Workerthe IMQ somewhere prelocal hook. 25*de1e4e89SAndroid Build Coastguard WorkerI think this is a pretty neat feature to have in Linux in general. 26*de1e4e89SAndroid Build Coastguard Worker(i.e not just for IMQ). 27*de1e4e89SAndroid Build Coastguard WorkerBut i wont go back to putting netfilter hooks in the device to satisfy 28*de1e4e89SAndroid Build Coastguard Workerthis. I also dont think its worth it hacking ifb some more to be 29*de1e4e89SAndroid Build Coastguard Workeraware of say L3 info and play ip rule tricks to achieve this. 30*de1e4e89SAndroid Build Coastguard Worker--> Instead the plan is to have a contrack related action. This action will 31*de1e4e89SAndroid Build Coastguard Workerselectively either query/create contrack state on incoming packets. 32*de1e4e89SAndroid Build Coastguard WorkerPackets could then be redirected to ifb based on what happens -> eg 33*de1e4e89SAndroid Build Coastguard Workeron incoming packets; if we find they are of known state we could send to 34*de1e4e89SAndroid Build Coastguard Workera different queue than one which didnt have existing state. This 35*de1e4e89SAndroid Build Coastguard Workerall however is dependent on whatever rules the admin enters. 36*de1e4e89SAndroid Build Coastguard Worker 37*de1e4e89SAndroid Build Coastguard WorkerAt the moment this 3rd function does not exist yet. I have decided that 38*de1e4e89SAndroid Build Coastguard Workerinstead of sitting on the patch for another year, to release it and then 39*de1e4e89SAndroid Build Coastguard Workerif theres pressure i will add this feature. 40*de1e4e89SAndroid Build Coastguard Worker 41*de1e4e89SAndroid Build Coastguard WorkerAn example, to provide functionality that most people use IMQ for below: 42*de1e4e89SAndroid Build Coastguard Worker 43*de1e4e89SAndroid Build Coastguard Worker-------- 44*de1e4e89SAndroid Build Coastguard Workerexport TC="/sbin/tc" 45*de1e4e89SAndroid Build Coastguard Worker 46*de1e4e89SAndroid Build Coastguard Worker$TC qdisc add dev ifb0 root handle 1: prio 47*de1e4e89SAndroid Build Coastguard Worker$TC qdisc add dev ifb0 parent 1:1 handle 10: sfq 48*de1e4e89SAndroid Build Coastguard Worker$TC qdisc add dev ifb0 parent 1:2 handle 20: tbf rate 20kbit buffer 1600 limit 3000 49*de1e4e89SAndroid Build Coastguard Worker$TC qdisc add dev ifb0 parent 1:3 handle 30: sfq 50*de1e4e89SAndroid Build Coastguard Worker$TC filter add dev ifb0 protocol ip pref 1 parent 1: handle 1 fw classid 1:1 51*de1e4e89SAndroid Build Coastguard Worker$TC filter add dev ifb0 protocol ip pref 2 parent 1: handle 2 fw classid 1:2 52*de1e4e89SAndroid Build Coastguard Worker 53*de1e4e89SAndroid Build Coastguard Workerifconfig ifb0 up 54*de1e4e89SAndroid Build Coastguard Worker 55*de1e4e89SAndroid Build Coastguard Worker$TC qdisc add dev eth0 ingress 56*de1e4e89SAndroid Build Coastguard Worker 57*de1e4e89SAndroid Build Coastguard Worker# redirect all IP packets arriving in eth0 to ifb0 58*de1e4e89SAndroid Build Coastguard Worker# use mark 1 --> puts them onto class 1:1 59*de1e4e89SAndroid Build Coastguard Worker$TC filter add dev eth0 parent ffff: protocol ip prio 10 u32 \ 60*de1e4e89SAndroid Build Coastguard Workermatch u32 0 0 flowid 1:1 \ 61*de1e4e89SAndroid Build Coastguard Workeraction ipt -j MARK --set-mark 1 \ 62*de1e4e89SAndroid Build Coastguard Workeraction mirred egress redirect dev ifb0 63*de1e4e89SAndroid Build Coastguard Worker 64*de1e4e89SAndroid Build Coastguard Worker-------- 65*de1e4e89SAndroid Build Coastguard Worker 66*de1e4e89SAndroid Build Coastguard Worker 67*de1e4e89SAndroid Build Coastguard WorkerRun A Little test: 68*de1e4e89SAndroid Build Coastguard Worker 69*de1e4e89SAndroid Build Coastguard Workerfrom another machine ping so that you have packets going into the box: 70*de1e4e89SAndroid Build Coastguard Worker----- 71*de1e4e89SAndroid Build Coastguard Worker[root@jzny action-tests]# ping 10.22 72*de1e4e89SAndroid Build Coastguard WorkerPING 10.22 (10.0.0.22): 56 data bytes 73*de1e4e89SAndroid Build Coastguard Worker64 bytes from 10.0.0.22: icmp_seq=0 ttl=64 time=2.8 ms 74*de1e4e89SAndroid Build Coastguard Worker64 bytes from 10.0.0.22: icmp_seq=1 ttl=64 time=0.6 ms 75*de1e4e89SAndroid Build Coastguard Worker64 bytes from 10.0.0.22: icmp_seq=2 ttl=64 time=0.6 ms 76*de1e4e89SAndroid Build Coastguard Worker 77*de1e4e89SAndroid Build Coastguard Worker--- 10.22 ping statistics --- 78*de1e4e89SAndroid Build Coastguard Worker3 packets transmitted, 3 packets received, 0% packet loss 79*de1e4e89SAndroid Build Coastguard Workerround-trip min/avg/max = 0.6/1.3/2.8 ms 80*de1e4e89SAndroid Build Coastguard Worker[root@jzny action-tests]# 81*de1e4e89SAndroid Build Coastguard Worker----- 82*de1e4e89SAndroid Build Coastguard WorkerNow look at some stats: 83*de1e4e89SAndroid Build Coastguard Worker 84*de1e4e89SAndroid Build Coastguard Worker--- 85*de1e4e89SAndroid Build Coastguard Worker[root@jmandrake]:~# $TC -s filter show parent ffff: dev eth0 86*de1e4e89SAndroid Build Coastguard Workerfilter protocol ip pref 10 u32 87*de1e4e89SAndroid Build Coastguard Workerfilter protocol ip pref 10 u32 fh 800: ht divisor 1 88*de1e4e89SAndroid Build Coastguard Workerfilter protocol ip pref 10 u32 fh 800::800 order 2048 key ht 800 bkt 0 flowid 1:1 89*de1e4e89SAndroid Build Coastguard Worker match 00000000/00000000 at 0 90*de1e4e89SAndroid Build Coastguard Worker action order 1: tablename: mangle hook: NF_IP_PRE_ROUTING 91*de1e4e89SAndroid Build Coastguard Worker target MARK set 0x1 92*de1e4e89SAndroid Build Coastguard Worker index 1 ref 1 bind 1 installed 4195sec used 27sec 93*de1e4e89SAndroid Build Coastguard Worker Sent 252 bytes 3 pkts (dropped 0, overlimits 0) 94*de1e4e89SAndroid Build Coastguard Worker 95*de1e4e89SAndroid Build Coastguard Worker action order 2: mirred (Egress Redirect to device ifb0) stolen 96*de1e4e89SAndroid Build Coastguard Worker index 1 ref 1 bind 1 installed 165 sec used 27 sec 97*de1e4e89SAndroid Build Coastguard Worker Sent 252 bytes 3 pkts (dropped 0, overlimits 0) 98*de1e4e89SAndroid Build Coastguard Worker 99*de1e4e89SAndroid Build Coastguard Worker[root@jmandrake]:~# $TC -s qdisc 100*de1e4e89SAndroid Build Coastguard Workerqdisc sfq 30: dev ifb0 limit 128p quantum 1514b 101*de1e4e89SAndroid Build Coastguard Worker Sent 0 bytes 0 pkts (dropped 0, overlimits 0) 102*de1e4e89SAndroid Build Coastguard Workerqdisc tbf 20: dev ifb0 rate 20Kbit burst 1575b lat 2147.5s 103*de1e4e89SAndroid Build Coastguard Worker Sent 210 bytes 3 pkts (dropped 0, overlimits 0) 104*de1e4e89SAndroid Build Coastguard Workerqdisc sfq 10: dev ifb0 limit 128p quantum 1514b 105*de1e4e89SAndroid Build Coastguard Worker Sent 294 bytes 3 pkts (dropped 0, overlimits 0) 106*de1e4e89SAndroid Build Coastguard Workerqdisc prio 1: dev ifb0 bands 3 priomap 1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1 107*de1e4e89SAndroid Build Coastguard Worker Sent 504 bytes 6 pkts (dropped 0, overlimits 0) 108*de1e4e89SAndroid Build Coastguard Workerqdisc ingress ffff: dev eth0 ---------------- 109*de1e4e89SAndroid Build Coastguard Worker Sent 308 bytes 5 pkts (dropped 0, overlimits 0) 110*de1e4e89SAndroid Build Coastguard Worker 111*de1e4e89SAndroid Build Coastguard Worker[root@jmandrake]:~# ifconfig ifb0 112*de1e4e89SAndroid Build Coastguard Workerifb0 Link encap:Ethernet HWaddr 00:00:00:00:00:00 113*de1e4e89SAndroid Build Coastguard Worker inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link 114*de1e4e89SAndroid Build Coastguard Worker UP BROADCAST RUNNING NOARP MTU:1500 Metric:1 115*de1e4e89SAndroid Build Coastguard Worker RX packets:6 errors:0 dropped:3 overruns:0 frame:0 116*de1e4e89SAndroid Build Coastguard Worker TX packets:3 errors:0 dropped:0 overruns:0 carrier:0 117*de1e4e89SAndroid Build Coastguard Worker collisions:0 txqueuelen:32 118*de1e4e89SAndroid Build Coastguard Worker RX bytes:504 (504.0 b) TX bytes:252 (252.0 b) 119*de1e4e89SAndroid Build Coastguard Worker----- 120*de1e4e89SAndroid Build Coastguard Worker 121*de1e4e89SAndroid Build Coastguard WorkerYou send it any packet not originating from the actions it will drop them. 122*de1e4e89SAndroid Build Coastguard Worker[In this case the three dropped packets were ipv6 ndisc]. 123*de1e4e89SAndroid Build Coastguard Worker 124*de1e4e89SAndroid Build Coastguard Workercheers, 125*de1e4e89SAndroid Build Coastguard Workerjamal 126