summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xscripts/bgp/vyatta-bgp.pl20
-rw-r--r--templates/protocols/bgp/node.tag/neighbor/node.tag/update-source/node.def15
2 files changed, 26 insertions, 9 deletions
diff --git a/scripts/bgp/vyatta-bgp.pl b/scripts/bgp/vyatta-bgp.pl
index 610fb571..2f541407 100755
--- a/scripts/bgp/vyatta-bgp.pl
+++ b/scripts/bgp/vyatta-bgp.pl
@@ -4,9 +4,10 @@ use lib "/opt/vyatta/share/perl5/";
use Vyatta::Config;
use Vyatta::Misc;
use Getopt::Long;
+use NetAddr::IP::Lite;
my ( $pg, $as, $neighbor );
-my ( $checkas, $peername, $checkifpeergroup, $checkpeergroups );
+my ( $checkas, $peername, $checkifpeergroup, $checkpeergroups, $checksource );
GetOptions(
"peergroup=s" => \$pg,
@@ -16,12 +17,14 @@ GetOptions(
"check-as" => \$checkas,
"check-peer-groups" => \$checkpeergroups,
"check-if-peer-group" => \$checkifpeergroup,
+ "check-source=s" => \$checksource,
);
check_peer_name($peername) if ($peername);
check_for_peer_groups( $pg, $as ) if ($checkpeergroups);
check_as( $neighbor, $as, $pg ) if ($checkas);
check_if_peer_group($pg) if ($checkifpeergroup);
+check_source($checksource) if ($checksource);
exit 0;
@@ -108,3 +111,18 @@ sub check_as {
die "protocols bgp $as neighbor $neighbor: must define a remote-as in neighbor or peer-group $peergroup\n"
unless $peergroupas;
}
+
+# check that value is either an IPV4 address on system or an interface
+sub check_source {
+ my $src = shift;
+ my $ip = new NetAddr::IP::Lite($src);
+
+ if ($ip) {
+ my $found = grep { my $a = new NetAddr::IP::Lite($_);
+ $a->addr() eq $ip->addr() } Vyatta::Misc::getIP();
+ die "IP address $ip does not exist on this system\n" if ($found == 0);
+ } else {
+ my $found = grep { $_ eq $src } Vyatta::Misc::getInterfaces();
+ die "Interface $src does not exist on the system\n" if ($found == 0);
+ }
+}
diff --git a/templates/protocols/bgp/node.tag/neighbor/node.tag/update-source/node.def b/templates/protocols/bgp/node.tag/neighbor/node.tag/update-source/node.def
index e631951d..9a7b9c09 100644
--- a/templates/protocols/bgp/node.tag/neighbor/node.tag/update-source/node.def
+++ b/templates/protocols/bgp/node.tag/neighbor/node.tag/update-source/node.def
@@ -1,11 +1,9 @@
-type: ipv4
+type: txt
help: Set the source IP of routing updates
-comp_help: \1 <x.x.x.x>\tIP address of route source
-syntax:expression: exec " \
- if [ -z \"`ip addr | grep $VAR(@) `\" ]; then \
- echo $VAR(@) doesn\\'t exist on this system ; \
- exit 1 ; \
- fi ; "
+comp_help:
+ <x.x.x.x> Set IP address of route source
+ <interface> Set interface as route source
+syntax:expression: exec "/opt/vyatta/sbin/vyatta-bgp.pl --check-source $VAR(@)"
commit:expression: exec "/opt/vyatta/sbin/vyatta-bgp.pl --check-as --as $VAR(../../@) --neighbor $VAR(../@)"
update: if [ -n "$VAR(../remote-as/@)" ]; then
peer="remote-as $VAR(../remote-as/@)";
@@ -15,5 +13,6 @@ update: if [ -n "$VAR(../remote-as/@)" ]; then
vyatta-vtysh -c "configure terminal" -c "router bgp $VAR(../../@)" \
-c "neighbor $VAR(../@) $peer" \
-c "neighbor $VAR(../@) update-source $VAR(@)"
-delete: vyatta-vtysh --noerror -c "configure terminal" -c "router bgp $VAR(../../@)" \
+delete: vyatta-vtysh --noerror -c "configure terminal" \
+ -c "router bgp $VAR(../../@)" \
-c "no neighbor $VAR(../@) update-source"