summaryrefslogtreecommitdiff
path: root/scripts/bgp/vyatta-bgp.pl
diff options
context:
space:
mode:
authorRuben Herold <ruben@puettmann.net>2019-05-29 14:38:54 +0200
committerChristian Poessinger <christian@poessinger.com>2019-06-17 22:17:11 +0200
commit9764e08bfa318d379c00f3dd9fb4f42e1b118bc8 (patch)
treeeb4c8fae6847826576e0ba91295f497fb5d1862c /scripts/bgp/vyatta-bgp.pl
parent707e72e9d449beba232599f7af5ac72c0ac8ce16 (diff)
downloadvyatta-cfg-quagga-9764e08bfa318d379c00f3dd9fb4f42e1b118bc8.tar.gz
vyatta-cfg-quagga-9764e08bfa318d379c00f3dd9fb4f42e1b118bc8.zip
T1390: Add Support for ipv6 unnumbered Interface with extended-nexthop
(cherry picked from commit 3c2ff1eac67f2e1df2a5bff301dc74a642d11c88)
Diffstat (limited to 'scripts/bgp/vyatta-bgp.pl')
-rwxr-xr-xscripts/bgp/vyatta-bgp.pl115
1 files changed, 96 insertions, 19 deletions
diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl
index abf3ed4b..1fef8de7 100755
--- a/scripts/bgp/vyatta-bgp.pl
+++ b/scripts/bgp/vyatta-bgp.pl
@@ -204,6 +204,7 @@ my %qcom = (
'protocols bgp var neighbor var' => {
set => undef,
del => 'router bgp #3 ; no neighbor #5',
+ noerr => 'del',
},
'protocols bgp var neighbor var address-family' => {
set => undef,
@@ -495,8 +496,28 @@ my %qcom = (
del => 'router bgp #3 ; no neighbor #5 remote-as #7',
},
'protocols bgp var neighbor var interface' => {
- set => 'router bgp #3 ; neighbor #5 interface #7',
- del => 'router bgp #3 ; no neighbor #5 interface #7',
+ set => undef,
+ del => undef,
+ },
+ 'protocols bgp var neighbor var interface peer-group' => {
+ set => 'router bgp #3 ; neighbor #5 interface peer-group #8',
+ del => 'router bgp #3 ; no neighbor #5 interface peer-group #8',
+ },
+ 'protocols bgp var neighbor var interface remote-as' => {
+ set => 'router bgp #3 ; neighbor #5 interface remote-as #8',
+ del => 'router bgp #3 ; no neighbor #5 interface remote-as #8',
+ },
+ 'protocols bgp var neighbor var interface v6only' => {
+ set => undef,
+ del => undef,
+ },
+ 'protocols bgp var neighbor var interface v6only peer-group' => {
+ set => 'router bgp #3 ; neighbor #5 interface v6only peer-group #9',
+ del => 'router bgp #3 ; no neighbor #5 interface v6only peer-group #9',
+ },
+ 'protocols bgp var neighbor var interface v6only remote-as' => {
+ set => 'router bgp #3 ; neighbor #5 interface v6only remote-as #9',
+ del => 'router bgp #3 ; no neighbor #5 interface v6only remote-as #9',
},
'protocols bgp var neighbor var disable-capability-negotiation' => {
set => 'router bgp #3 ; neighbor #5 dont-capability-negotiate',
@@ -1122,7 +1143,7 @@ if ( ! -e "/usr/sbin/zebra" ) {
}
my ( $pg, $as, $neighbor );
-my ( $main, $peername, $isneighbor, $checkpeergroups, $checkpeergroups6, $checksource,
+my ( $main, $peername, $isneighbor, $checkpeergroups, $checkpeergroups6, $checksource,
$isiBGPpeer, $wasiBGPpeer, $confedibgpasn, $listpeergroups, $checkremoteas);
GetOptions(
@@ -1170,6 +1191,10 @@ sub list_peer_groups {
sub check_neighbor_ip {
my $neighbor = shift;
+ if ($neighbor =~ /^(\w+)$/) {
+ exit 0;
+ }
+
die "Can't set neighbor address to local system IP.\n"
if (is_local_address($neighbor));
@@ -1198,17 +1223,18 @@ sub check_remote_as {
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";
+ 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;
+ exit 0;
}
- die "remote-as must be between 1 and 4294967294 or external or internal";
+ 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 {
@@ -1259,6 +1285,10 @@ sub check_for_peer_groups {
foreach my $node (@neighbors) {
my $peergroup = $config->returnValue("$node peer-group");
if ((defined $peergroup) && ($peergroup eq $pg)) { push @peers, $node; }
+ $peergroup = $config->returnValue("$node interface peer-group");
+ if ((defined $peergroup) && ($peergroup eq $pg)) { push @peers, $node; }
+ $peergroup = $config->returnValue("$node interface v6only peer-group");
+ if ((defined $peergroup) && ($peergroup eq $pg)) { push @peers, $node; }
}
# if we found peers in the previous statements
@@ -1404,8 +1434,20 @@ sub check_neighbor_parameters
my @neighbors = $config->listNodes("$as neighbor");
foreach my $neighbor (@neighbors) {
my $pgmembership = $config->returnValue("$as neighbor $neighbor peer-group");
+ if ( ! defined $pgmembership ) {
+ my $pgmembership = $config->returnValue("$as neighbor $neighbor іnterface peer-group");
+ }
+ if ( ! defined $pgmembership ) {
+ my $pgmembership = $config->returnValue("$as neighbor $neighbor іnterface v6only peer-group");
+ }
if ( (defined $pgmembership) && ("$pgmembership" eq "$peergroup") ) {
my $remoteas = $config->returnValue("$as neighbor $neighbor remote-as");
+ if ( ! defined $remoteas) {
+ my $remoteas = $config->returnValue("$as neighbor $neighbor іnterface remote-as");
+ }
+ if ( ! defined $remoteas ) {
+ my $remoteas = $config->returnValue("$as neighbor $neighbor іnterface v6only remote-as");
+ }
if (! defined $remoteas) {
die "[ protocols bgp $as peer-group $neighbor ]\n can't delete the remote-as in peer-group without setting remote-as in member neighbors\n"
}
@@ -1423,8 +1465,20 @@ sub check_neighbor_parameters
my @neighbors = $config->listNodes("$as neighbor");
foreach my $neighbor (@neighbors) {
my $pgmembership = $config->returnValue("$as neighbor $neighbor peer-group");
+ if ( ! defined $pgmembership ) {
+ my $pgmembership = $config->returnValue("$as neighbor $neighbor іnterface peer-group");
+ }
+ if ( ! defined $pgmembership ) {
+ my $pgmembership = $config->returnValue("$as neighbor $neighbor іnterface v6only peer-group");
+ }
if ((defined $pgmembership) && ("$pgmembership" eq "$peergroup")) {
my $remoteas = $config->returnValue("$as neighbor $neighbor remote-as");
+ if ( ! defined $remoteas) {
+ my $remoteas = $config->returnValue("$as neighbor $neighbor іnterface remote-as");
+ }
+ if ( ! defined $remoteas ) {
+ my $remoteas = $config->returnValue("$as neighbor $neighbor іnterface v6only remote-as");
+ }
if (defined $remoteas && defined $pgremoteas) {
die "[ protocols bgp $as peer-group $neighbor ]\n must not define remote-as in both neighbor and peer-group\n"
}
@@ -1452,23 +1506,36 @@ sub check_neighbor_parameters
# remote-as checks: Make sure the neighbor has a remote-as defined locally or in the peer-group
my ($remoteas, $peergroup, $peergroupas, $peergroup6, $peergroup6as);
$remoteas = $config->returnValue("$as neighbor $neighbor remote-as");
- if ($config->exists("$as neighbor $neighbor peer-group")) {
- if ($config->exists("$as parameters default no-ipv4-unicast")) {
+ if (! defined($remoteas)) {
+ $remoteas = $config->returnValue("$as neighbor $neighbor interface remote-as");
+ }
+ if (! defined($remoteas)) {
+ $remoteas = $config->returnValue("$as neighbor $neighbor interface v6only remote-as");
+ }
+ if ($config->exists("$as neighbor $neighbor peer-group") ||
+ $config->exists("$as neighbor $neighbor interface peer-group") ||
+ $config->exists("$as neighbor $neighbor interface v6only peer-group")) {
+ if ($config->exists("$as parameters default no-ipv4-unicast") && $config->exists("$as neighbor $neighbor peer-group")) {
die "[ protocols bgp $as neighbor $neighbor ]\n peer-group defined but ipv4-unicast is disabled\n";
}
- $peergroup = $config->returnValue("$as neighbor $neighbor peer-group");
+ $peergroup = $config->returnValue("$as neighbor $neighbor peer-group");
+ if (! defined($peergroup)) {
+ $peergroup = $config->returnValue("$as neighbor $neighbor interface peer-group");
+ }
+ if (! defined($peergroup)) {
+ $peergroup = $config->returnValue("$as neighbor $neighbor interface v6only peer-group");
+ }
if ($config->exists("$as peer-group $peergroup remote-as")) {
- $peergroupas = $config->returnValue("$as peer-group $peergroup remote-as");
+ $peergroupas = $config->returnValue("$as peer-group $peergroup remote-as");
}
}
if ($config->exists("$as neighbor $neighbor address-family ipv6-unicast peer-group")) {
- $peergroup6 = $config->returnValue("$as neighbor $neighbor address-family ipv6-unicast peer-group");
+ $peergroup6 = $config->returnValue("$as neighbor $neighbor address-family ipv6-unicast peer-group");
if ($config->exists("$as peer-group $peergroup6 remote-as")
&& $config->exists("$as peer-group $peergroup6 address-family ipv6-unicast")) {
- $peergroup6as = $config->returnValue("$as peer-group $peergroup6 remote-as");
+ $peergroup6as = $config->returnValue("$as peer-group $peergroup6 remote-as");
}
- }
-
+ }
die "[ protocols bgp $as neighbor $neighbor ]\n must set remote-as or peer-group with remote-as defined\n"
if ((!defined($remoteas) && !defined($peergroupas)) && !$config->exists("$as parameters default no-ipv4-unicast"));
@@ -1520,7 +1587,15 @@ sub confed_iBGP_ASN {
my @neighbors = $config->listOrigNodes('neighbor');
foreach my $neighbor (@neighbors) {
my $remoteas = $config->returnValue("neighbor $neighbor remote-as");
- if ("$testas" eq "$remoteas") {
+ if (("$testas" eq "$remoteas") || ("$testas" eq "internal")) {
+ exit 1;
+ }
+ $remoteas = $config->returnValue("neighbor $neighbor interface remote-as");
+ if (("$testas" eq "$remoteas") || ("$testas" eq "internal")) {
+ exit 1;
+ }
+ $remoteas = $config->returnValue("neighbor $neighbor interface v6only remote-as");
+ if (("$testas" eq "$remoteas") || ("$testas" eq "internal")) {
exit 1;
}
}
@@ -1643,14 +1718,16 @@ sub main
'address-family ipv6-unicast unsuppress-map');
# notice the extra space in the level string. keeps the parent from being deleted.
- $qconfig->deleteConfigTreeRecursive('protocols bgp var neighbor var ', undef, \@ordered) || die "exiting $?\n";
- $qconfig->deleteConfigTreeRecursive('protocols bgp var peer-group var ', undef, \@ordered) || die "exiting $?\n";
+ $qconfig->deleteConfigTreeRecursive('protocols bgp var neighbor var', undef, \@ordered) || die "exiting $?\n";
+ $qconfig->deleteConfigTreeRecursive('protocols bgp var peer-group var', undef, \@ordered) || die "exiting $?\n";
$qconfig->deleteConfigTreeRecursive('protocols bgp') || die "exiting $?\n";
## sets with priority
$qconfig->setConfigTreeRecursive('protocols bgp var parameters') || die "exiting $?\n";
$qconfig->setConfigTreeRecursive('protocols bgp var peer-group', undef, \@ordered) || die "exiting $?\n";
$qconfig->setConfigTreeRecursive('protocols bgp var neighbor var remote-as', undef, \@ordered) || die "exiting $?\n";
+ $qconfig->setConfigTreeRecursive('protocols bgp var neighbor var interface', undef, \@ordered)
+ || die "exiting $?\n";
$qconfig->setConfigTreeRecursive('protocols bgp var neighbor var address-family ipv6-unicast peer-group'
, undef, \@ordered) || die "exiting $?\n";
$qconfig->setConfigTreeRecursive('protocols bgp var neighbor var address-family ipv6-unicast'