diff options
-rwxr-xr-x | scripts/bgp/vyatta-bgp.pl | 22 | ||||
-rw-r--r-- | templates/protocols/bgp/node.tag/neighbor/node.tag/remote-as/node.def | 9 |
2 files changed, 25 insertions, 6 deletions
diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl index 25dd4328..d572c0ba 100755 --- a/scripts/bgp/vyatta-bgp.pl +++ b/scripts/bgp/vyatta-bgp.pl @@ -1126,8 +1126,8 @@ if ( ! -e "/usr/sbin/zebra" ) { } my ( $pg, $as, $neighbor ); -my ( $main, $peername, $isneighbor, $checkpeergroups, $checkpeergroups6, $checksource, - $isiBGPpeer, $wasiBGPpeer, $confedibgpasn, $listpeergroups); +my ( $main, $peername, $isneighbor, $checkpeergroups, $checkpeergroups6, $checksource, + $isiBGPpeer, $wasiBGPpeer, $confedibgpasn, $listpeergroups, $checkremoteas); GetOptions( "peergroup=s" => \$pg, @@ -1142,6 +1142,7 @@ GetOptions( "was-iBGP" => \$wasiBGPpeer, "confed-iBGP-ASN-check=s" => \$confedibgpasn, "list-peer-groups" => \$listpeergroups, + "check-remote-as=s" => \$checkremoteas, "main" => \$main, ); @@ -1155,6 +1156,7 @@ confed_iBGP_ASN($as, $confedibgpasn) if ($confedibgpasn); is_iBGP_peer($neighbor, $as) if ($isiBGPpeer); was_iBGP_peer($neighbor, $as) if ($wasiBGPpeer); list_peer_groups($as) if ($listpeergroups); +check_remote_as($checkremoteas) if ($checkremoteas); exit 0; @@ -1195,6 +1197,22 @@ sub check_peergroup_name { } } +sub check_remote_as { + my $remote_as = shift; + + if ($remote_as =~ /^(\d+)$/) { + if ( $remote_as >= 1 && $remote_as <= 4294967294) { + exit 0; + } + die "remote-as must be between 1 and 4294967294 or external or internal"; + } + + if ( $remote_as eq "external" || $remote_as eq "internal") { + exit 0; + } + die "remote-as must be between 1 and 4294967294 or external or internal"; +} + # Make sure we aren't deleteing a peer-group that has # neighbors configured to it sub check_for_peer_groups6 { diff --git a/templates/protocols/bgp/node.tag/neighbor/node.tag/remote-as/node.def b/templates/protocols/bgp/node.tag/neighbor/node.tag/remote-as/node.def index 5fbec1ae..61cd13a0 100644 --- a/templates/protocols/bgp/node.tag/neighbor/node.tag/remote-as/node.def +++ b/templates/protocols/bgp/node.tag/neighbor/node.tag/remote-as/node.def @@ -1,5 +1,6 @@ -type: u32 +type: txt help: Neighbor BGP AS number [REQUIRED] -val_help: u32: 1-4294967294; Neighbor AS number -syntax:expression: $VAR(@) >= 1 && $VAR(@) <= 4294967294; \ - "remote-as must be between 1 and 4294967294" +val_help: txt: 1-4294967294; Neighbor AS number +val_help: txt: external; except that if the peers ASN is different than mine +val_help: txt: internal; except that if the peers ASN is the same as mine +syntax:expression: exec "/opt/vyatta/sbin/vyatta-bgp.pl --check-remote-as $VAR(@)" |