From fdd02b11dc07222c63d5831965ace2ae7e85fb18 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Mon, 29 Mar 2010 17:22:30 -0700 Subject: Get ifb devices working Need to have a match rule (even it is match all). Change naming convention for ifb devices Don't autocreate ifb0, ifb1 --- scripts/vyatta-qos.pl | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl index 6fc38dc..68af9e1 100755 --- a/scripts/vyatta-qos.pl +++ b/scripts/vyatta-qos.pl @@ -109,8 +109,9 @@ sub delete_interface { system($cmd); # remove IFB device if any - if ($direction eq 'in') { - $cmd = "sudo ip link delete dev $interface-in"; + my $ifb = "ifb.$interface"; + if ( -d "/sys/class/net/$ifb") { + $cmd = "sudo ip link delete dev $ifb"; system ($cmd); } } @@ -175,16 +176,25 @@ sub update_interface { # For non-ingress Qos use ifb device elsif ($direction eq 'in') { - my $ifb = $device . "-in"; + # load module but don't make any ifb's + system("sudo modprobe ifb numifbs=0") unless ( -d '/sys/module/ifb' ); + + # create new ifb device + my $ifb = "ifb.$device"; system("sudo ip link add dev $ifb type ifb") == 0 or die "Can't create $ifb: $!"; - system("sudo ip link set dev $ifb up") == 0 or die "Can't bring $ifb up: $!"; + # create ingress queue discipline print "qdisc add dev $device ingress\n"; + + # redirect incoming packets to ifb print "filter add dev $device parent ffff: protocol all prio 10"; + print " u32 match u32 0 0 flowid 1:1"; print " action mirred egress redirect dev $ifb\n"; + + # tell shaper to use ifb device $device = $ifb; } -- cgit v1.2.3