summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/VyattaQosDropTail.pm57
-rwxr-xr-xscripts/vyatta-qos.pl8
2 files changed, 61 insertions, 4 deletions
diff --git a/scripts/VyattaQosDropTail.pm b/scripts/VyattaQosDropTail.pm
new file mode 100644
index 0000000..1345fb0
--- /dev/null
+++ b/scripts/VyattaQosDropTail.pm
@@ -0,0 +1,57 @@
+# This is a wrapper around FIFO queue discipline
+#
+#
+# **** License ****
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# This code was originally developed by Vyatta, Inc.
+# Portions created by Vyatta are Copyright (C) 2008 Vyatta, Inc.
+# All Rights Reserved.
+# **** End License ****
+
+package VyattaQosDropTail;
+
+use strict;
+require VyattaConfig;
+use VyattaQosUtil;
+
+my %fields = (
+ _limit => undef,
+);
+
+sub new {
+ my ( $that, $config ) = @_;
+ my $level = $config->setLevel();
+ my $class = ref($that) || $that;
+ my $self = {%fields};
+
+ $self->{_limit} = $config->returnValue("queue-limit");
+
+ return bless $self, $class;
+}
+
+sub commands {
+ my ( $self, $out, $dev ) = @_;
+ my $limit = $self->{_limit};
+ my $cmd = "qdisc add dev $dev root pfifo";
+
+ $cmd .= " limit $limit" if defined $limit;
+ printf {$out} "%s\n", $cmd;
+}
+
+sub isChanged {
+ my ($self, $name) = @_;
+ my $config = new VyattaConfig;
+
+ $config->setLevel("qos-policy drop-tail $name");
+ return $config->isChanged('queue-limit');
+}
+
+1;
diff --git a/scripts/vyatta-qos.pl b/scripts/vyatta-qos.pl
index 3d8e58b..690894d 100755
--- a/scripts/vyatta-qos.pl
+++ b/scripts/vyatta-qos.pl
@@ -46,10 +46,8 @@ my %policies = (
'traffic-shaper' => "VyattaQosTrafficShaper",
'fair-queue' => "VyattaQosFairQueue",
'rate-limit' => "VyattaQosRateLimiter",
+ 'drop-tail' => "VyattaQosDropTail",
);
-use VyattaQosTrafficShaper;
-use VyattaQosFairQueue;
-use VyattaQosRateLimiter;
sub make_policy {
my ($config, $type, $name) = @_;
@@ -58,8 +56,10 @@ sub make_policy {
# This means template exists but we don't know what it is.
defined $class or die "Unknown policy type $type";
- $config->setLevel("qos-policy $type $name");
+ my $location = "$class.pm";
+ require $location;
+ $config->setLevel("qos-policy $type $name");
return $class->new($config, $name);
}