From 3720b90870a67e3920f6a03b6b8d68c84988a2c5 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 31 Mar 2009 07:37:19 -0700 Subject: Yet another logic error in vyatta-bgp Check for remote-as/peer-group was backwards. --- scripts/bgp/vyatta-bgp.pl | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'scripts') diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl index f6ae9e72..4bc27c53 100755 --- a/scripts/bgp/vyatta-bgp.pl +++ b/scripts/bgp/vyatta-bgp.pl @@ -18,10 +18,10 @@ GetOptions( "check-if-peer-group" => \$checkifpeergroup, ); -check_peer_name($peername) if ($peername); -check_for_peer_groups( $pg, $as ) if ($checkpeergroups); -check_as( ( $pg ? $pg : -1 ), $neighbor, $as ) if ($checkas); -check_if_peer_group($pg) if ($checkifpeergroup); +check_peer_name($peername) if ($peername); +check_for_peer_groups( $pg, $as ) if ($checkpeergroups); +check_as( $pg, $neighbor, $as ) if ($checkas); +check_if_peer_group($pg) if ($checkifpeergroup); exit 0; @@ -85,30 +85,25 @@ sub check_for_peer_groups { # make sure nodes are either in a peer group of have # a remote AS assigned to them. sub check_as { - my $pg = shift; - my $neighbor = shift; + my ($pg,$neighbor, $as) = @_; + die "Neighbor not defined" unless $neighbor; - my $as = shift; + die "neighbor must be address" unless is_ip_v4_or_v6($neighbor); die "AS not defined\n" unless $as; - my $config = new Vyatta::Config; - my $pgtest = $neighbor; # if this is peer-group then short circuit this - return unless is_ip_v4_or_v6($pg); - + my $config = new Vyatta::Config; $config->setLevel("protocols bgp $as neighbor $neighbor"); my $remoteas = $config->returnValue("remote-as"); - return if defined $remoteas; - return if ( $pg > 0 ); + return if $pg; my $peergroup = $config->returnValue("peer-group"); - my $peergroupas = $config->returnValue(" .. $peergroup remote-as"); - die "protocols bgp $as neighbor $neighbor: must define a remote-as or peer-group\n" unless $peergroup; + my $peergroupas = $config->returnValue(" .. $peergroup remote-as"); die "protocols bgp $as neighbor $neighbor: must define a remote-as in neighbor or peer-group $peergroup\n" unless $peergroupas; } -- cgit v1.2.3