From ebe0ccaee6c0aa9ac7ea295cf1f42cbff1917c3b Mon Sep 17 00:00:00 2001 From: Robert Bays Date: Fri, 9 Jul 2010 16:15:38 -0700 Subject: more robust fix for local-as --- scripts/bgp/vyatta-bgp.pl | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl index 4c23cd28..2d49eef8 100755 --- a/scripts/bgp/vyatta-bgp.pl +++ b/scripts/bgp/vyatta-bgp.pl @@ -1092,7 +1092,7 @@ my %qcom = ( ); my ( $pg, $as, $neighbor ); -my ( $main, $peername, $isneighbor, $checkpeergroups, $checksource ); +my ( $main, $peername, $isneighbor, $checkpeergroups, $checksource, $checklocalas ); GetOptions( "peergroup=s" => \$pg, @@ -1102,6 +1102,7 @@ GetOptions( "check-neighbor-ip" => \$isneighbor, "check-peer-groups" => \$checkpeergroups, "check-source=s" => \$checksource, + "check-local-as" => \$checklocalas, "main" => \$main, ); @@ -1110,6 +1111,7 @@ check_peergroup_name($peername) if ($peername); check_neighbor_ip($neighbor) if ($isneighbor); check_for_peer_groups( $pg, $as ) if ($checkpeergroups); check_source($checksource) if ($checksource); +check_local_as($neighbor, $as) if ($checklocalas); exit 0; @@ -1244,6 +1246,25 @@ sub check_remote_as { } +# Verify that is local-as is used, the peer isn't in a confedration +sub check_local_as { + my ($neighbor, $as) = @_; + my $config = new Vyatta::Config; + + $config->setLevel("protocols bgp $as"); + if ($config->exists('parameters confederation peers')) { + my @peers = $config->returnValues('parameters confederation peers'); + my $remoteas = $config->returnValue("neighbor $neighbor remote-as"); + foreach my $peeras (@peers) { + if ("$peeras" eq "$remoteas") { + print "local-as can't be set for neighbors in a peer group\n"; + return 1; + } + } + } + return 0; +} + # check that value is either an IPV4 address on system or an interface sub check_source { my $src = shift; -- cgit v1.2.3