diff options
-rw-r--r-- | scripts/VyattaQosTrafficShaper.pm | 2 | ||||
-rwxr-xr-x | scripts/vyatta-qos.pl | 26 | ||||
-rw-r--r-- | templates/qos-policy/fair-queue/node.def | 2 | ||||
-rw-r--r-- | templates/qos-policy/traffic-shaper/node.def | 2 |
4 files changed, 14 insertions, 18 deletions
diff --git a/scripts/VyattaQosTrafficShaper.pm b/scripts/VyattaQosTrafficShaper.pm index e051542..2d09244 100644 --- a/scripts/VyattaQosTrafficShaper.pm +++ b/scripts/VyattaQosTrafficShaper.pm @@ -153,7 +153,7 @@ sub _define { my $level = $config->setLevel(); my @classes = ( ); - $self->{_rate} = $config->returnValue("rate"); + $self->{_rate} = $config->returnValue("bandwidth"); $config->exists("default") or die "Configuration not complete: missing default class\n"; diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl index ea9d60d..2aef09c 100755 --- a/scripts/vyatta-qos.pl +++ b/scripts/vyatta-qos.pl @@ -14,11 +14,11 @@ my @deleteInterface = (); my @updatePolicy = (); my $deletePolicy = undef; my $listName = undef; -my $validateName = undef; +my @validateName = (); GetOptions( "list-policy" => \$listName, - "validate-name=s" => \$validateName, + "validate-name=s{2}" => \@validateName, "update-interface=s{3}" => \@updateInterface, "delete-interface=s{2}" => \@deleteInterface, "update-policy=s{2}" => \@updatePolicy, @@ -41,15 +41,17 @@ sub list_inuse { ## check if name is okay sub validate_name { - my $name = shift; + my ($policy, $name) = @_; my $config = new VyattaConfig; ($name =~ '^\w[\w_-]*$') or die "Invalid policy name $name\n"; - foreach my $policy ($config->listNodes($qosNode) ) { - foreach my $node ($config->listNodes("$qosNode $policy") ) { - if ($name eq $node) { - die "Name $name is already in use by $policy\n"; + foreach my $p ($config->listNodes($qosNode) ) { + if ($p ne $policy) { + foreach my $n ($config->listNodes("$qosNode $policy") ) { + if ($n eq $name) { + die "Name $name is already in use by $p\n"; + } } } } @@ -62,14 +64,10 @@ sub delete_interface { my ($interface, $direction ) = @_; if ($direction eq "out" ) { - # delete old qdisc - will give error if no policy in place system("tc qdisc del dev $interface root 2>/dev/null"); system("tc filter del dev $interface 2>/dev/null"); } - else { - return -1; - } } ## update_interface('eth0', 'out', 'my-shaper') @@ -78,8 +76,6 @@ sub update_interface { my ($interface, $direction, $name ) = @_; my $config = new VyattaConfig; - print "update_interface $interface $direction $name\n"; - # TODO: add support for ingress ( $direction eq "out" ) or die "Only out direction supported"; foreach my $policy ( $config->listNodes($qosNode) ) { @@ -146,8 +142,8 @@ if ( defined $listName ) { exit 0; } -if ( defined $validateName ) { - validate_name($validateName); +if ( $#validateName == 1) { + validate_name(@validateName); exit 0; } diff --git a/templates/qos-policy/fair-queue/node.def b/templates/qos-policy/fair-queue/node.def index 3ec844e..ba88e32 100644 --- a/templates/qos-policy/fair-queue/node.def +++ b/templates/qos-policy/fair-queue/node.def @@ -1,6 +1,6 @@ tag: type: txt help: Configure fair queueing policy -syntax:expression: exec " /opt/vyatta/sbin/vyatta-qos.pl --validate-name $VAR(@)" +syntax:expression: exec " /opt/vyatta/sbin/vyatta-qos.pl --validate-name $VAR(../@) $VAR(@)" update:expression: "/opt/vyatta/sbin/vyatta-qos.pl --update-policy $VAR(../@) $VAR(@)" delete:expression: "/opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)" diff --git a/templates/qos-policy/traffic-shaper/node.def b/templates/qos-policy/traffic-shaper/node.def index afb77bd..f8a33f0 100644 --- a/templates/qos-policy/traffic-shaper/node.def +++ b/templates/qos-policy/traffic-shaper/node.def @@ -1,6 +1,6 @@ tag: type: txt help: Configure traffic shaping based policy -syntax:expression: exec " /opt/vyatta/sbin/vyatta-qos.pl --validate-name $VAR(@)" +syntax:expression: exec " /opt/vyatta/sbin/vyatta-qos.pl --validate-name $VAR(../@) $VAR(@)" update:expression: "/opt/vyatta/sbin/vyatta-qos.pl --update-policy $VAR(../@) $VAR(@)" delete:expression: "/opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)" |