summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-08 16:34:30 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-03-08 16:34:30 -0700
commit194f211880c0c8e0537ab9ab5c606d2769dc92c5 (patch)
treeb6ae15e1924a6d2d43ee5c2433862211c9bf39f5 /scripts
parent0e2782beb0b1bdeb5f43d329f17591cad7575f6a (diff)
downloadvyatta-cfg-qos-194f211880c0c8e0537ab9ab5c606d2769dc92c5.tar.gz
vyatta-cfg-qos-194f211880c0c8e0537ab9ab5c606d2769dc92c5.zip
Use hash rather than if/else for delete_interface
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-qos.pl23
1 files changed, 11 insertions, 12 deletions
diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index 4245e5e..8b8b978 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -104,24 +104,23 @@ sub list_policy {
}
}
+my %delcmd = (
+ 'out' => 'root',
+ 'in' => 'parent ffff:',
+);
+
## delete_interface('eth0', 'out')
# remove all filters and qdisc's
sub delete_interface {
my ( $interface, $direction ) = @_;
+ my $arg = $delcmd{$direction};
- for ($direction) {
+ die "bad direction $direction\n" unless $arg;
+
+ my $cmd = "sudo tc qdisc del dev $interface ". $arg . " 2>/dev/null";
- # delete old qdisc - silence error if no qdisc loaded
- if (/^out$/) {
- qx(sudo /sbin/tc qdisc del dev "$interface" root 2>/dev/null);
- }
- elsif (/^in$/) {
-qx(sudo /sbin/tc qdisc del dev "$interface" parent ffff: 2>/dev/null);
- }
- else {
- croak "bad direction $direction";
- }
- }
+ # ignore errors (may have no qdisc)
+ system($cmd);
}
## start_interface('ppp0')