summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Southworth <john.southworth@vyatta.com>2013-06-18 11:00:00 -0700
committerJohn Southworth <john.southworth@vyatta.com>2013-06-18 11:00:00 -0700
commitd1b24f46e6427d1fd2b20b1722bf9d92ab124cf0 (patch)
treef141ed38b8609f3b01532cb2d10fd15e18f80f9e
parente758688b38609af03b9fbc63e4472536314a8245 (diff)
downloadvyatta-cfg-qos-d1b24f46e6427d1fd2b20b1722bf9d92ab124cf0.tar.gz
vyatta-cfg-qos-d1b24f46e6427d1fd2b20b1722bf9d92ab124cf0.zip
Bugfix 8469: ensure that matches have data under them
-rw-r--r--lib/Vyatta/Qos/LimiterClass.pm5
-rw-r--r--lib/Vyatta/Qos/Match.pm30
-rw-r--r--lib/Vyatta/Qos/ShaperClass.pm5
3 files changed, 27 insertions, 13 deletions
diff --git a/lib/Vyatta/Qos/LimiterClass.pm b/lib/Vyatta/Qos/LimiterClass.pm
index 8622efd..82dcf98 100644
--- a/lib/Vyatta/Qos/LimiterClass.pm
+++ b/lib/Vyatta/Qos/LimiterClass.pm
@@ -60,7 +60,10 @@ sub _define {
foreach my $match ( $config->listNodes("match") ) {
$config->setLevel("$level match $match");
- push @matches, new Vyatta::Qos::Match($config);
+ my $match = new Vyatta::Qos::Match($config);
+ if (defined($match) {
+ push @matches, $match;
+ }
}
$self->{_match} = \@matches;
}
diff --git a/lib/Vyatta/Qos/Match.pm b/lib/Vyatta/Qos/Match.pm
index 97e4aec..176748c 100644
--- a/lib/Vyatta/Qos/Match.pm
+++ b/lib/Vyatta/Qos/Match.pm
@@ -61,19 +61,27 @@ sub new {
$fields{src} = $config->returnValue("ether source");
$fields{dst} = $config->returnValue("ether destination");
} else {
- $fields{dsfield} = getDsfield( $config->returnValue("$af dscp") );
- my $ipprot = $config->returnValue("$af protocol");
- $fields{protocol} = getProtocol($ipprot);
-
- $fields{src} = $config->returnValue("$af source address");
- $fields{dst} = $config->returnValue("$af destination address");
-
- my $port = $config->returnValue("$af source port");
- $fields{sport} = getPort( $port, $ipprot ) if $port;
- $port = $config->returnValue("$af destination port");
- $fields{dport} = getPort( $port, $ipprot ) if $port;
+ my $dsfield = $config->returnValue("$af dscp");
+ my $ipprot = $config->returnValue("$af protocol");
+ my $src = $config->returnValue("$af source address");
+ my $dst = $config->returnValue("$af destination address");
+ my $sport = $config->returnValue("$af source port");
+ my $dport = $config->returnValue("$af destination port");
+
+ $fields{dsfield} = getDsfield($dsfield) if $dsfield;
+ $fields{protocol} = getProtocol($ipprot) if $ipprot;
+ $fields{src} = $src if $src;
+ $fields{dst} = $dst if $dst;
+ $fields{sport} = getPort( $sport, $ipprot ) if $sport;
+ $fields{dport} = getPort( $dport, $ipprot ) if $dport;
}
+ # if the hash is empty then we didn't generate a match rule
+ # this usually means user left an uncompleted match in the config
+ my @keys = keys(%fields);
+ if ($#keys < 0) {
+ return undef;
+ }
$self->{$af} = \%fields;
die "Can not match on both $af and $lastaf protocol in same match\n"
diff --git a/lib/Vyatta/Qos/ShaperClass.pm b/lib/Vyatta/Qos/ShaperClass.pm
index 1cb7fbe..4d3cf33 100644
--- a/lib/Vyatta/Qos/ShaperClass.pm
+++ b/lib/Vyatta/Qos/ShaperClass.pm
@@ -68,7 +68,10 @@ sub _getMatch {
foreach my $match ( $config->listNodes($level) ) {
$config->setLevel("$level $match");
- push @matches, new Vyatta::Qos::Match($config);
+ my $match = new Vyatta::Qos::Match($config);
+ if (defined($match)) {
+ push @matches, $match;
+ }
}
return @matches;
}