diff options
Diffstat (limited to 'lib/Vyatta')
-rw-r--r-- | lib/Vyatta/Qos/LimiterClass.pm | 5 | ||||
-rw-r--r-- | lib/Vyatta/Qos/Match.pm | 30 | ||||
-rw-r--r-- | lib/Vyatta/Qos/ShaperClass.pm | 5 |
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; } |