From 5bd5800687492d8fe4811c7d54b7a987ccf2e724 Mon Sep 17 00:00:00 2001 From: Robert Bays Date: Mon, 12 Jul 2010 17:22:35 -0700 Subject: fix for bug 5760: BGP configuration script does not handle "multi:" node values correctly --- lib/Vyatta/Quagga/Config.pm | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) (limited to 'lib/Vyatta/Quagga/Config.pm') diff --git a/lib/Vyatta/Quagga/Config.pm b/lib/Vyatta/Quagga/Config.pm index 4eee2e8f..4f3a9d36 100644 --- a/lib/Vyatta/Quagga/Config.pm +++ b/lib/Vyatta/Quagga/Config.pm @@ -354,19 +354,44 @@ sub _qtree { # if I found a Quagga command template, then replace any vars if ($qcommand) { - # get the apropos config value so we can use it in the Quagga command template - my $val = undef; - if ($action eq 'set') { $val = $config->returnValue($node); } - else { $val = $config->returnOrigValue($node); } + # get the apropos config value so we can use it in the Quagga command template + my @vals = undef; + + # This is either a set or delete on a single or multi: node + if ($action eq 'set') { + my $tmplhash = $config->parseTmplAll(join ' ', "$level $node"); + if ($tmplhash->{'multi'}) { + if ($_DEBUG > 2) { print "DEBUG: multi\n"; } + @vals = $config->returnValues($node); + } + else { + if ($_DEBUG > 2) { print "DEBUG: not a multi\n"; } + $vals[0] = $config->returnValue($node); + } + } + else { + my $tmplhash = $config->parseTmplAll(join ' ', "$level $node"); + if ($tmplhash->{'multi'}) { + if ($_DEBUG > 2) { print "DEBUG: multi\n"; } + @vals = $config->returnOrigValues($node); + } + else { + if ($_DEBUG > 2) { print "DEBUG: not a multi\n"; } + $vals[0] = $config->returnOrigValue($node); + } + } # is this a leaf node? - if ($val) { - my $var = _qVarReplace("$level $node $val", $qcom->{$qcommand}->{$action}); - push @{$vtysh->{"$qcommand"}}, $var; - if ($_DEBUG) { - print "DEBUG: _qtree leaf node command: set $level $action $node $val \n\t\t\t\t\t$var\n"; + if (defined $vals[0]) { + foreach my $val (@vals) { + my $var = _qVarReplace("$level $node $val", $qcom->{$qcommand}->{$action}); + push @{$vtysh->{"$qcommand"}}, $var; + if ($_DEBUG) { + print "DEBUG: _qtree leaf node command: set $level $action $node $val \n\t\t\t\t\t$var\n"; + } } } + else { my $var = _qVarReplace("$level $node", $qcom->{$qcommand}->{$action}); push @{$vtysh->{"$qcommand"}}, $var; -- cgit v1.2.3