summaryrefslogtreecommitdiff
path: root/scripts/bgp/vyatta-bgp.pl
diff options
context:
space:
mode:
authorzdc <zdc@users.noreply.github.com>2019-08-12 22:54:03 +0300
committerDaniil Baturin <daniil@baturin.org>2019-11-17 19:44:46 +0100
commit46311397716d2059959cee04defcda2efa8a68cf (patch)
treeea5f9748f6b37e2f0d638c6bc09be1ba456c843e /scripts/bgp/vyatta-bgp.pl
parent70bed1ab73fb44997c967078d09997fa3a751699 (diff)
downloadvyatta-cfg-quagga-46311397716d2059959cee04defcda2efa8a68cf.tar.gz
vyatta-cfg-quagga-46311397716d2059959cee04defcda2efa8a68cf.zip
[bfd] T1183: Added some new functionality for BFD in BGP: (#34)
* added option "check-control-plane-failure" for BFD in BGP neighbors * added configuration check for checking if BFD peer is already configured before applying bfd option to BGP neighbor * added configuration check for checking if BFD peers are already configured for all members in peer-group before applying bfd option to BGP peer-group
Diffstat (limited to 'scripts/bgp/vyatta-bgp.pl')
-rwxr-xr-xscripts/bgp/vyatta-bgp.pl48
1 files changed, 47 insertions, 1 deletions
diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl
index b39556af..9a816344 100755
--- a/scripts/bgp/vyatta-bgp.pl
+++ b/scripts/bgp/vyatta-bgp.pl
@@ -579,6 +579,10 @@ my %qcom = (
set => 'router bgp #3 ; neighbor #5 bfd',
del => 'router bgp #3 ; no neighbor #5 bfd',
},
+ 'protocols bgp var neighbor var bfd check-control-plane-failure' => {
+ set => 'router bgp #3 ; neighbor #5 bfd check-control-plane-failure',
+ del => 'router bgp #3 ; no neighbor #5 bfd check-control-plane-failure',
+ },
'protocols bgp var neighbor var password' => {
set => 'router bgp #3 ; neighbor #5 password #7',
del => 'router bgp #3 ; no neighbor #5 password',
@@ -1160,7 +1164,7 @@ if ( ! -e "/usr/sbin/zebra" ) {
my ( $pg, $as, $neighbor );
my ( $main, $peername, $isneighbor, $checkpeergroups, $checkpeergroups6, $checksource,
- $isiBGPpeer, $wasiBGPpeer, $confedibgpasn, $listpeergroups, $checkremoteas);
+ $isiBGPpeer, $wasiBGPpeer, $confedibgpasn, $listpeergroups, $checkremoteas, $checkbfdpeer, $checkbfdgroup);
GetOptions(
"peergroup=s" => \$pg,
@@ -1176,6 +1180,8 @@ GetOptions(
"confed-iBGP-ASN-check=s" => \$confedibgpasn,
"list-peer-groups" => \$listpeergroups,
"check-remote-as=s" => \$checkremoteas,
+ "check-bfd-peer=s" => \$checkbfdpeer,
+ "check-peer-group-bfd=s" => \$checkbfdgroup,
"main" => \$main,
);
@@ -1190,6 +1196,8 @@ 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);
+check_bfd_peer($checkbfdpeer) if ($checkbfdpeer);
+check_bfd_group($checkbfdgroup, $as) if ($checkbfdgroup);
exit 0;
@@ -1707,6 +1715,44 @@ sub check_source {
}
}
+# check if BFD peer exists for configured BGP peer
+sub check_bfd_peer {
+ my $peer = shift;
+ my $config = new Vyatta::Config;
+
+ # check for BFD peer configuration
+ my $bfd_exists = $config->exists("protocols bfd peer $peer");
+ if (!$bfd_exists) { die "BFD peer need to be configured for using BFD protocol\n"; }
+}
+
+# check if BFD peer exists for configured BGP peer-group
+sub check_bfd_group {
+ my $group = shift;
+ my $as = shift;
+ my @group_neighbors = ();
+ my $config = new Vyatta::Config;
+
+ # check if BFD enabled for peer-group and stop check if not
+ if (!$config->exists("protocols bgp $as peer-group $group bfd")) {
+ return 0;
+ }
+
+ # get a list of all BGP neighbors in the defined group
+ my @all_neighbors = $config->listNodes("protocols bgp $as neighbor");
+ foreach my $neighbor (@all_neighbors) {
+ if ($config->exists("protocols bgp $as neighbor $neighbor peer-group")) {
+ if ($config->returnValue("protocols bgp $as neighbor $neighbor peer-group") eq $group) {
+ push @group_neighbors, $neighbor;
+ }
+ }
+ }
+
+ # check if BFD peer exist and raise error if not
+ foreach my $neighbor (@group_neighbors) {
+ if (!$config->exists("protocols bfd peer $neighbor")) { die "BFD peers need to be configured for all neighbors in peer-group $group before enabling for BGP\n"; }
+ }
+}
+
sub main
{
# initialize the Quagga Config object with data from Vyatta config tree