diff options
-rw-r--r-- | lib/Vyatta/Quagga/Config.pm | 59 | ||||
-rwxr-xr-x | scripts/bgp/vyatta-bgp.pl | 45 |
2 files changed, 52 insertions, 52 deletions
diff --git a/lib/Vyatta/Quagga/Config.pm b/lib/Vyatta/Quagga/Config.pm index 8afc1bed..1730f4e1 100644 --- a/lib/Vyatta/Quagga/Config.pm +++ b/lib/Vyatta/Quagga/Config.pm @@ -95,26 +95,26 @@ sub returnQuaggaCommands { # methods to send the commands to Quagga sub setConfigTree { - my ($self, $level, @skip_list) = @_; - if (_setConfigTree($level, 0, 0, @skip_list)) { return 1; } + my ($self, $level, $skip_list, $ordered_list) = @_; + if (_setConfigTree($level, 0, 0, $skip_list, $ordered_list)) { return 1; } return 0; } sub setConfigTreeRecursive { - my ($self, $level, @skip_list) = @_; - if (_setConfigTree($level, 0, 1, @skip_list)) { return 1; } + my ($self, $level, $skip_list, $ordered_list) = @_; + if (_setConfigTree($level, 0, 1, $skip_list, $ordered_list)) { return 1; } return 0; } sub deleteConfigTree { - my ($self, $level, @skip_list) = @_; - if (_setConfigTree($level, 1, 0, @skip_list)) { return 1; } + my ($self, $level, $skip_list, $ordered_list) = @_; + if (_setConfigTree($level, 1, 0, $skip_list, $ordered_list)) { return 1; } return 0; } sub deleteConfigTreeRecursive { - my ($self, $level, @skip_list) = @_; - if (_setConfigTree($level, 1, 1, @skip_list)) { return 1; } + my ($self, $level, $skip_list, $ordered_list) = @_; + if (_setConfigTree($level, 1, 1, $skip_list, $ordered_list)) { return 1; } return 0; } @@ -132,8 +132,14 @@ sub deleteConfigTreeRecursive { # $4 - arrays of strings to skip # output: none, return failure if needed sub _setConfigTree { - my ($level, $delete, $recurse, @skip_list) = @_; + my ($level, $delete, $recurse, $skip, $ordered) = @_; my $qcom = $_qcomref; + my @com_array = (); + my @skip_list = (); + my @ordered_list = (); + + if (defined $skip) { @skip_list = @$skip; } + if (defined $ordered) { @ordered_list = @$ordered; } if ((! defined $level) || (! defined $delete) || @@ -156,11 +162,11 @@ sub _setConfigTree { print "\n"; } - # This loop walks the list of commands and sends to quagga if appropriate - foreach my $key (sort $sortfunc keys %$vtyshref) { + # This loop walks the arrays of quagga commands and builds list to send to quagga + foreach my $key (keys %$vtyshref) { if ($_DEBUG >= 3) { print "DEBUG: _setConfigTree - key $key\n"; } - # skip parameters in skip_list + # skip parameters listed in skip_list my $found = 0; if ((scalar @skip_list) > 0) { foreach my $node (@skip_list) { @@ -180,12 +186,12 @@ sub _setConfigTree { (($qcom->{$key}->{'noerr'} eq "set") && (!$delete)))) { $noerr = 1; } # this conditional matches key to level exactly or if recurse, start of key to level - if ((($recurse) && ($key =~ /^$level/)) || ((! $recurse) && ($key =~ /^$level$/))) { + if ((($recurse) && ($key =~ /^$level/)) || ((! $recurse) && ($key =~ /^$level$/))) { my $index = 0; foreach my $cmd (@{$vtyshref->{$key}}) { if ($_DEBUG >= 2) { print "DEBUG: _setConfigTree - key: $key \t cmd: $cmd\n"; } - - if (! _sendQuaggaCommand("$cmd", "$noerr")) { return 0; } + + push @com_array, "$cmd !!?? $noerr"; # remove this command so we don't hit it again in another Recurse call delete ${$vtyshref->{$key}}[$index]; $index++; @@ -193,6 +199,29 @@ sub _setConfigTree { } } + # Now let's sort based on ordered_list + my $index = 0; + while (scalar @ordered_list > 0) { + my $prio = shift @ordered_list; + my $str = sprintf "%5d", $index; + foreach my $line (@com_array) { + # add sorting order meta-data to list + $line =~ s/$prio/$str\:::$prio/; + } + $index++; + } + + # and now send the commands to quagga + foreach my $line (sort $sortfunc @com_array) { + my ($command, $noerr); + + # remove the ordered_list sorting meta-data + $line =~ s/\s+\d+:::/ /; + # split for our noeer info + ($command, $noerr) = split / !!\?\? /, $line; + if (! _sendQuaggaCommand("$command", "$noerr")) { return 0; } + } + return 1; } diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl index 20c248b5..67788174 100755 --- a/scripts/bgp/vyatta-bgp.pl +++ b/scripts/bgp/vyatta-bgp.pl @@ -1380,46 +1380,17 @@ sub main { # and that migrations to/from iBGP eBGP are valid check_remote_as(); - # deletes with priority - # delete everything in neighbor except for the important nodes - my @skip_array = ('remote-as', 'route-map', 'filter-list', 'prefix-list', 'distribute-list', 'unsuppress-map'); + ## deletes with priority + # delete everything in neighbor, ordered nodes last + my @ordered = ('remote-as', 'shutdown', 'route-map', 'prefix-list', 'filter-list', 'distribute-list', 'unsuppress-map'); # notice the extra space in the level string. keeps the parent from being deleted. - $qconfig->deleteConfigTreeRecursive('protocols bgp var neighbor var ', @skip_array) || die "exiting $?\n"; - # now delete everything in neighbor except remote-as - @skip_array = ('remote-as'); - $qconfig->deleteConfigTreeRecursive('protocols bgp var neighbor var ', @skip_array) || die "exiting $?\n"; - # now finish off neighbor - $qconfig->deleteConfigTreeRecursive('protocols bgp var neighbor var') || die "exiting $?\n"; - # now delete everything in peer-group except remote-as - @skip_array = ('remote-as'); - $qconfig->deleteConfigTreeRecursive('protocols bgp var peer-group var ', @skip_array) || die "exiting $?\n"; - # now finish off peer-group - $qconfig->deleteConfigTreeRecursive('protocols bgp var peer-group var ') || die "exiting $?\n"; - # now delete everything else in the tree + $qconfig->deleteConfigTreeRecursive('protocols bgp var neighbor var ', undef, \@ordered) || die "exiting $?\n"; + $qconfig->deleteConfigTreeRecursive('protocols bgp var peer-group var ', undef, \@ordered) || die "exiting $?\n"; $qconfig->deleteConfigTreeRecursive('protocols bgp') || die "exiting $?\n"; - # sets with priority + ## sets with priority $qconfig->setConfigTreeRecursive('protocols bgp var parameters') || die "exiting $?\n"; - $qconfig->setConfigTree('protocols bgp var peer-group var remote-as') || die "exiting $?\n"; - $qconfig->setConfigTreeRecursive('protocols bgp var peer-group') || die "exiting $?\n"; - $qconfig->setConfigTree('protocols bgp var neighbor var remote-as') || die "exiting $?\n"; - $qconfig->setConfigTree('protocols bgp var neighbor var peer-group') || die "exiting $?\n"; - $qconfig->setConfigTree('protocols bgp var neighbor var shutdown') || die "exiting $?\n"; - $qconfig->setConfigTreeRecursive('protocols bgp var neighbor var route-map') || die "exiting $?\n"; - $qconfig->setConfigTreeRecursive('protocols bgp var neighbor var filter-list') || die "exiting $?\n"; - $qconfig->setConfigTreeRecursive('protocols bgp var neighbor var prefix-list') || die "exiting $?\n"; - $qconfig->setConfigTreeRecursive('protocols bgp var neighbor var distribute-list') || die "exiting $?\n"; - $qconfig->setConfigTreeRecursive('protocols bgp var neighbor var unsuppress-map') || die "exiting $?\n"; - $qconfig->setConfigTreeRecursive('protocols bgp var neighbor') || die "exiting $?\n"; + $qconfig->setConfigTreeRecursive('protocols bgp var peer-group', undef, \@ordered) || die "exiting $?\n"; + $qconfig->setConfigTreeRecursive('protocols bgp var neighbor var ', undef, \@ordered) || die "exiting $?\n"; $qconfig->setConfigTreeRecursive('protocols bgp') || die "exiting $?\n"; - - # old priorities we are emulating with the above sets - #705 protocols bgp var neighbhor shutdown - #715 protocols bgp var neighbhor route-map - #716 protocols bgp var neighbhor filter-list - #717 protocols bgp var neighbhor prefix-list - #718 protocols bgp var neighbhor distribute-list - #719 protocols bgp var neighbhor unsuppress-map - #720 protocols bgp var neighbhor - #730 protocols bgp var } |