diff options
-rwxr-xr-x | scripts/bgp/vyatta-bgp.pl | 23 | ||||
-rw-r--r-- | templates/protocols/bgp/node.tag/neighbor/node.tag/local-as/node.def | 3 |
2 files changed, 24 insertions, 2 deletions
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; diff --git a/templates/protocols/bgp/node.tag/neighbor/node.tag/local-as/node.def b/templates/protocols/bgp/node.tag/neighbor/node.tag/local-as/node.def index 353a492b..bf0b1361 100644 --- a/templates/protocols/bgp/node.tag/neighbor/node.tag/local-as/node.def +++ b/templates/protocols/bgp/node.tag/neighbor/node.tag/local-as/node.def @@ -6,4 +6,5 @@ comp_help: possible completions: syntax:expression: $VAR(@) >=1 && $VAR(@) <= 4294967294; "local-as must be between 1 and 4294967294" commit:expression: $VAR(@) != $VAR(../../@); "protocols bgp $VAR(../../@) neighbor $VAR(../@): you can't set local-as the same as the router AS" commit:expression: $VAR(../remote-as/@) != $VAR(../../@); "protocols bgp $VAR(../../@) neighbor $VAR(../@): local-as can't be set on iBGP peers" -commit:expression: $VAR(../remote-as/@) != $VAR(../../parameters/confederation/peers/@); "protocols bgp $VAR(../../@) neighbor $VAR(../@): local-as can't be set on a confederation peer" +commit:expression: exec "/opt/vyatta/sbin/vyatta-bgp.pl --check-local-as --neighbor $VAR(../@) --as $VAR(../../@)" + |