Ingress filtering in Linux traffic control: Redirect traffic to IFB device
- by Dani Camps
I have an openwrt router and I want to shape incoming traffic in order to classify all the traffic addressed to a certain IP address in my home network as low priority. For that purpose I want to redirect all traffic incoming to the eth1 interface, the one connected to the DSL modem, to an IFB device where I will do the shaping. These are the details of my system:
Linux OpenWrt 2.6.32.27 #7 Fri Jul 15 02:43:34 CEST 2011 mips GNU/Linux
Here is the script I am using where the last instruction is failing:
# Variable definition
ETH=eth1
IFB=ifb1
IP_LP="192.168.1.22/32"
DL_RATE="900kbps"
HP_RATE="890kbps"
LP_RATE="10kbps"
TC="tc"
# Configuring the ifbX interface
insmod ifb
insmod sch_htb
insmod sch_ingress
ifconfig $IFB up
# Adding the HTB scheduler to the ingress interface
$TC qdisc add dev $IFB root handle 1: htb default 11
# Set the maximum bandwidth that each priority class can get, and the maximum borrowing they can do
$TC class add dev $IFB parent 1:1 classid 1:10 htb rate $LP_RATE ceil $DL_RATE
$TC class add dev $IFB parent 1:1 classid 1:11 htb rate $HP_RATE ceil $DL_RATE
# Redirect all ingress traffic arriving at $ETH to $IFB
$TC qdisc del dev $ETH ingress 2>/dev/null
$TC qdisc add dev $ETH ingress
$TC filter add dev $ETH parent ffff: protocol ip prio 1 u32 \
match u32 0 0 flowid 1:1 \
action mirred egress redirect dev $IFB
The last instruction fails with:
Action 4 device ifb1 ifindex 9
RTNETLINK answers: No such file or directory
We have an error talking to the kernel
Does anyone know what am I doing wrong ?
Best Regards
Daniel