summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-06-11 16:55:29 -0700
committerStephen Hemminger <shemminger@lenny.localdomain>2009-10-01 13:51:20 -0700
commit4cd540436f0b946ca6b8206d7166c56094a6e9e4 (patch)
treed91578c7594725bf43c2f53307c60011af46fa77
parentba4170471de90b2a32abeff6b48ec13461e7f9b1 (diff)
downloadvyatta-cfg-qos-4cd540436f0b946ca6b8206d7166c56094a6e9e4.tar.gz
vyatta-cfg-qos-4cd540436f0b946ca6b8206d7166c56094a6e9e4.zip
Cleanup how qos-policy change detection works
The CLI end: node does work correctly, so don't need to go walking configuration manually Bug 4545 (cherry picked from commit 377896b296827e4d7c3c20debb3487605c45bbe3)
-rw-r--r--lib/Vyatta/Qos/DropTail.pm8
-rw-r--r--lib/Vyatta/Qos/FairQueue.pm11
-rw-r--r--lib/Vyatta/Qos/NetworkEmulator.pm12
-rw-r--r--lib/Vyatta/Qos/RandomDetect.pm24
-rw-r--r--lib/Vyatta/Qos/RateLimiter.pm11
-rw-r--r--lib/Vyatta/Qos/RoundRobin.pm51
-rw-r--r--lib/Vyatta/Qos/TrafficLimiter.pm45
-rw-r--r--lib/Vyatta/Qos/TrafficShaper.pm62
-rwxr-xr-xscripts/vyatta-qos.pl34
-rw-r--r--templates/qos-policy/drop-tail/node.def6
-rw-r--r--templates/qos-policy/fair-queue/node.def6
-rw-r--r--templates/qos-policy/network-emulator/node.def6
-rw-r--r--templates/qos-policy/random-detect/node.def6
-rw-r--r--templates/qos-policy/rate-limit/node.def6
-rw-r--r--templates/qos-policy/round-robin/node.def6
-rw-r--r--templates/qos-policy/traffic-limiter/node.def6
-rw-r--r--templates/qos-policy/traffic-shaper/node.def6
17 files changed, 42 insertions, 264 deletions
diff --git a/lib/Vyatta/Qos/DropTail.pm b/lib/Vyatta/Qos/DropTail.pm
index 1b14a81..0ff15e9 100644
--- a/lib/Vyatta/Qos/DropTail.pm
+++ b/lib/Vyatta/Qos/DropTail.pm
@@ -47,12 +47,4 @@ sub commands {
printf "%s\n", $cmd;
}
-sub isChanged {
- my ($self, $name) = @_;
- my $config = new Vyatta::Config;
-
- $config->setLevel("qos-policy drop-tail $name");
- return $config->isChanged('queue-limit');
-}
-
1;
diff --git a/lib/Vyatta/Qos/FairQueue.pm b/lib/Vyatta/Qos/FairQueue.pm
index bc3a872..c74cb01 100644
--- a/lib/Vyatta/Qos/FairQueue.pm
+++ b/lib/Vyatta/Qos/FairQueue.pm
@@ -52,15 +52,4 @@ sub commands {
print "\n";
}
-sub isChanged {
- my ( $self, $name ) = @_;
- my $config = new Vyatta::Config;
-
- $config->setLevel("qos-policy fair-queue $name");
- foreach my $attr ('hash-interval', 'queue-limit') {
- return $attr if ($config->isChanged($attr));
- }
- return; # false
-}
-
1;
diff --git a/lib/Vyatta/Qos/NetworkEmulator.pm b/lib/Vyatta/Qos/NetworkEmulator.pm
index d7a3404..602393c 100644
--- a/lib/Vyatta/Qos/NetworkEmulator.pm
+++ b/lib/Vyatta/Qos/NetworkEmulator.pm
@@ -81,16 +81,4 @@ sub commands {
print "\n";
}
-sub isChanged {
- my ( $self, $name ) = @_;
- my $config = new Vyatta::Config;
-
- $config->setLevel("qos-policy network-emulator $name");
- foreach my $attr ( "bandwidth", "burst", "queue-limit", "network-delay",
- "packet-loss", "packet-corruption", "packet-reordering", ) {
- return $attr if ( $config->isChanged($attr) );
- }
- return;
-}
-
1;
diff --git a/lib/Vyatta/Qos/RandomDetect.pm b/lib/Vyatta/Qos/RandomDetect.pm
index 0ceb4d6..6e6dad0 100644
--- a/lib/Vyatta/Qos/RandomDetect.pm
+++ b/lib/Vyatta/Qos/RandomDetect.pm
@@ -130,28 +130,4 @@ sub commands {
}
}
-# Walk configuration tree and look for changed nodes
-# The configuration system should do this but doesn't do it right
-sub isChanged {
- my ( $self, $name ) = @_;
- my $config = new Vyatta::Config;
-
- $config->setLevel("qos-policy random-detect $name");
-
- return 'bandwidth' if ( $config->isChanged('bandwidth') );
-
- my %precedenceNodes = $config->listNodeStatus('precedence');
- while ( my ( $pred, $status ) = each %precedenceNodes ) {
- return "precedence $pred" if ( $status ne 'static' );
-
- foreach my $attr qw(average-packet min-threshold mark-probability
- max-threshold queue-limit) {
- return "precedence $pred $attr"
- if ( $config->isChanged("precedence $pred $attr") );
- }
- }
-
- return; # false
-}
-
1;
diff --git a/lib/Vyatta/Qos/RateLimiter.pm b/lib/Vyatta/Qos/RateLimiter.pm
index c20646e..ac0cd2c 100644
--- a/lib/Vyatta/Qos/RateLimiter.pm
+++ b/lib/Vyatta/Qos/RateLimiter.pm
@@ -55,15 +55,4 @@ sub commands {
$dev, $self->{_rate}, $self->{_latency}, $self->{_burst};
}
-sub isChanged {
- my ($self, $name) = @_;
- my $config = new Vyatta::Config;
-
- $config->setLevel("qos-policy rate-limit $name");
- foreach my $attr ('bandwidth', 'burst', 'latency') {
- return $attr if ($config->isChanged($attr));
- }
- return; # false
-}
-
1;
diff --git a/lib/Vyatta/Qos/RoundRobin.pm b/lib/Vyatta/Qos/RoundRobin.pm
index 7cd6b4f..af45875 100644
--- a/lib/Vyatta/Qos/RoundRobin.pm
+++ b/lib/Vyatta/Qos/RoundRobin.pm
@@ -74,55 +74,4 @@ sub commands {
}
}
-# Walk configuration tree and look for changed nodes
-# The configuration system should do this but doesn't do it right
-sub isChanged {
- my ( $self, $name ) = @_;
- my $config = new Vyatta::Config;
-
- $config->setLevel("qos-policy round-robin $name");
-
- return 'quantum' if ( $config->isChanged('quantum') );
-
- foreach my $attr (qw(queue-limit queue-type)) {
- return "default $attr" if ( $config->isChanged("default $attr") );
- }
-
- my %classNodes = $config->listNodeStatus('class');
- while ( my ( $class, $status ) = each %classNodes ) {
- return "class $class" if ( $status ne 'static' );
-
- foreach my $attr (qw(queue-limit queue-type)) {
- return "class $class $attr"
- if ( $config->isChanged("class $class $attr") );
- }
-
- my %matchNodes = $config->listNodeStatus("class $class match");
- while ( my ( $match, $status ) = each %matchNodes ) {
- my $level = "class $class match $match";
- if ( $status ne 'static' ) {
- return $level;
- }
-
- foreach my $parm (
- (
- 'vif',
- 'interface',
- 'ip protocol',
- 'ip source address',
- 'ip destination address',
- 'ip source port',
- 'ip destination port'
- )
- )
- {
- return "$level $parm"
- if ( $config->isChanged("$level $parm") );
- }
- }
- }
-
- return; # false
-}
-
1;
diff --git a/lib/Vyatta/Qos/TrafficLimiter.pm b/lib/Vyatta/Qos/TrafficLimiter.pm
index fd3460c..b2fd07c 100644
--- a/lib/Vyatta/Qos/TrafficLimiter.pm
+++ b/lib/Vyatta/Qos/TrafficLimiter.pm
@@ -90,49 +90,4 @@ sub commands {
}
}
-# Walk configuration tree and look for changed nodes
-# The configuration system should do this but doesn't do it right
-sub isChanged {
- my ( $self, $name ) = @_;
- my $config = new Vyatta::Config;
-
- $config->setLevel("qos-policy traffic-limiter $name");
- my %classNodes = $config->listNodeStatus('class');
- while ( my ( $class, $status ) = each %classNodes ) {
- if ( $status ne 'static' ) {
- return "class $class";
- }
-
- foreach my $attr ( 'bandwidth', 'burst', 'priority' ) {
- if ( $config->isChanged("class $class $attr") ) {
- return "class $class $attr";
- }
- }
-
- my %matchNodes = $config->listNodeStatus("class $class match");
- while ( my ( $match, $status ) = each %matchNodes ) {
- my $level = "class $class match $match";
- if ( $status ne 'static' ) {
- return $level;
- }
-
- foreach my $parm (
- 'vif',
- 'interface',
- 'ip dscp',
- 'ip protocol',
- 'ip source address',
- 'ip destination address',
- 'ip source port',
- 'ip destination port'
- )
- {
- return "$level $parm" if ( $config->isChanged("$level $parm") );
- }
- }
- }
-
- return; # false
-}
-
1;
diff --git a/lib/Vyatta/Qos/TrafficShaper.pm b/lib/Vyatta/Qos/TrafficShaper.pm
index c808c7d..f51d373 100644
--- a/lib/Vyatta/Qos/TrafficShaper.pm
+++ b/lib/Vyatta/Qos/TrafficShaper.pm
@@ -157,66 +157,4 @@ sub commands {
}
}
-# Walk configuration tree and look for changed nodes
-# The configuration system should do this but doesn't do it right
-sub isChanged {
- my ( $self, $name ) = @_;
- my $config = new Vyatta::Config;
- my @attributes = qw(bandwidth burst ceiling priority queue-limit queue-type);
-
- $config->setLevel("qos-policy traffic-shaper $name");
-
- if ( $config->isChanged('bandwidth') ) {
- return 'bandwidth';
- }
-
- foreach my $attr (@attributes) {
- if ( $config->isChanged("default $attr") ) {
- return "default $attr";
- }
- }
-
- my %classNodes = $config->listNodeStatus('class');
- while ( my ( $class, $status ) = each %classNodes ) {
- if ( $status ne 'static' ) {
- return "class $class";
- }
-
- foreach my $attr (@attributes) {
- if ( $config->isChanged("class $class $attr") ) {
- return "class $class $attr";
- }
- }
-
- my %matchNodes = $config->listNodeStatus("class $class match");
- while ( my ( $match, $status ) = each %matchNodes ) {
- my $level = "class $class match $match";
- if ( $status ne 'static' ) {
- return $level;
- }
-
- foreach my $parm (
- 'vif',
- 'ether destination',
- 'ether source',
- 'ether protocol',
- 'interface',
- 'ip dscp',
- 'ip protocol',
- 'ip source address',
- 'ip destination address',
- 'ip source port',
- 'ip destination port'
- )
- {
- if ( $config->isChanged("$level $parm") ) {
- return "$level $parm";
- }
- }
- }
- }
-
- return; # false
-}
-
1;
diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index 86b8fe2..e0a1b0f 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -192,12 +192,16 @@ sub interfaces_using {
foreach my $name ( getInterfaces() ) {
my $intf = new Vyatta::Interface($name);
next unless $intf;
- $config->setLevel($intf->path() . ' qos-policy');
+ my $level = $intf->path() . ' qos-policy';
+ $config->setLevel($level);
foreach my $direction ($config->listNodes()) {
my $cur = $config->returnValue($direction);
next unless $cur;
- push @inuse, $name if ($cur eq $policy);
+
+ # these are arguments to update_interface()
+ push @inuse, [ $name, $direction, $name ]
+ if ($cur eq $policy);
}
}
return @inuse;
@@ -224,19 +228,17 @@ sub create_policy {
# Configuration changed, reapply to all interfaces.
sub apply_policy {
- my $config = new Vyatta::Config;
-
- while ( my $name = shift ) {
- foreach my $device ( interfaces_using($name) ) {
- my $intf = new Vyatta::Interface($device);
-
- $config->setLevel( $intf->path() );
- foreach my $direction ( $config->listNodes('qos-policy') ) {
- next unless $config->exists("qos-policy $direction $name");
+ my ( $policy, $name ) = @_;
+ my @usedby = interfaces_using($name);
- update_interface( $device, $direction, $name );
- }
- }
+ if (@usedby) {
+ foreach my $args (@usedby) {
+ update_interface( @$args );
+ }
+ } else {
+ # Recheck the policy, might have new errors.
+ my $shaper = make_policy( $policy, $name );
+ exit 1 unless $shaper;
}
}
@@ -245,7 +247,7 @@ sub usage {
usage: vyatta-qos.pl --list-policy direction
vyatta-qos.pl --create-policy policy-type policy-name
vyatta-qos.pl --delete-policy policy-name
- vyatta-qos.pl --apply-policy policy-name
+ vyatta-qos.pl --apply-policy policy-type policy-name
vyatta-qos.pl --update-interface interface direction policy-name
vyatta-qos.pl --delete-interface interface direction
@@ -270,7 +272,7 @@ GetOptions(
"list-policy=s" => \@listPolicy,
"delete-policy=s" => \@deletePolicy,
"create-policy=s{2}" => \@createPolicy,
- "apply-policy=s" => \@applyPolicy,
+ "apply-policy=s{2}" => \@applyPolicy,
) or usage();
delete_interface(@deleteInterface) if ( $#deleteInterface == 1 );
diff --git a/templates/qos-policy/drop-tail/node.def b/templates/qos-policy/drop-tail/node.def
index 111bb63..49561c3 100644
--- a/templates/qos-policy/drop-tail/node.def
+++ b/templates/qos-policy/drop-tail/node.def
@@ -3,6 +3,6 @@ type: txt
help: Set drop tail queue (FIFO) policy
syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
; "only alpha-numeric policy name allowed"
-create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy "$VAR(.)" "$VAR(@)"
-delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy "$VAR(@)"
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy "$VAR(@)"
+create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
+delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
diff --git a/templates/qos-policy/fair-queue/node.def b/templates/qos-policy/fair-queue/node.def
index ac9dc2d..15b995a 100644
--- a/templates/qos-policy/fair-queue/node.def
+++ b/templates/qos-policy/fair-queue/node.def
@@ -3,6 +3,6 @@ type: txt
help: Set fair queueing policy
syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
; "only alpha-numeric policy name allowed"
-create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy "$VAR(.)" "$VAR(@)"
-delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy "$VAR(@)"
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy "$VAR(@)"
+create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
+delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)"
diff --git a/templates/qos-policy/network-emulator/node.def b/templates/qos-policy/network-emulator/node.def
index 4a3e570..2f383f8 100644
--- a/templates/qos-policy/network-emulator/node.def
+++ b/templates/qos-policy/network-emulator/node.def
@@ -3,6 +3,6 @@ type: txt
help: Setup network emulator policy
syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
; "only alpha-numeric policy name allowed"
-create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy "$VAR(.)" "$VAR(@)"
-delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy "$VAR(@)"
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy "$VAR(@)"
+create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
+delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
diff --git a/templates/qos-policy/random-detect/node.def b/templates/qos-policy/random-detect/node.def
index 02911a1..f6da04a 100644
--- a/templates/qos-policy/random-detect/node.def
+++ b/templates/qos-policy/random-detect/node.def
@@ -3,6 +3,6 @@ type: txt
help: Set Weighted Random Early Detect policy
syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
; "only alpha-numeric policy name allowed"
-create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy "$VAR(.)" "$VAR(@)"
-delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy "$VAR(@)"
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy "$VAR(@)"
+create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
+delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
diff --git a/templates/qos-policy/rate-limit/node.def b/templates/qos-policy/rate-limit/node.def
index 2e3eed1..6da6f67 100644
--- a/templates/qos-policy/rate-limit/node.def
+++ b/templates/qos-policy/rate-limit/node.def
@@ -3,6 +3,6 @@ type: txt
help: Set rate limiting policy
syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
; "only alpha-numeric policy name allowed"
-create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy "$VAR(.)" "$VAR(@)"
-delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy "$VAR(@)"
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy "$VAR(@)"
+create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
+delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
diff --git a/templates/qos-policy/round-robin/node.def b/templates/qos-policy/round-robin/node.def
index daf795a..6d15978 100644
--- a/templates/qos-policy/round-robin/node.def
+++ b/templates/qos-policy/round-robin/node.def
@@ -3,6 +3,6 @@ type: txt
help: Set deficit round robin based policy
syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
; "only alpha-numeric policy name allowed"
-create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy "$VAR(.)" "$VAR(@)"
-delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy "$VAR(@)"
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy "$VAR(@)"
+create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
+delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
diff --git a/templates/qos-policy/traffic-limiter/node.def b/templates/qos-policy/traffic-limiter/node.def
index b411273..38bd516 100644
--- a/templates/qos-policy/traffic-limiter/node.def
+++ b/templates/qos-policy/traffic-limiter/node.def
@@ -3,6 +3,6 @@ type: txt
help: Set traffic input limiting policy
syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
; "only alpha-numeric policy name allowed"
-create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy "$VAR(.)" "$VAR(@)"
-delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy "$VAR(@)"
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy "$VAR(@)"
+create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
+delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)
diff --git a/templates/qos-policy/traffic-shaper/node.def b/templates/qos-policy/traffic-shaper/node.def
index e54c093..4c7b73c 100644
--- a/templates/qos-policy/traffic-shaper/node.def
+++ b/templates/qos-policy/traffic-shaper/node.def
@@ -3,6 +3,6 @@ type: txt
help: Set traffic shaping based policy
syntax:expression: pattern $VAR(@) "^[[:alnum:]][-_[:alnum:]]*$"
; "only alpha-numeric policy name allowed"
-create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy "$VAR(.)" "$VAR(@)"
-delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy "$VAR(@)"
-end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy "$VAR(@)"
+create: /opt/vyatta/sbin/vyatta-qos.pl --create-policy $VAR(.) $VAR(@)
+delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-policy $VAR(@)
+end: /opt/vyatta/sbin/vyatta-qos.pl --apply-policy $VAR(.) $VAR(@)