summaryrefslogtreecommitdiff
path: root/scripts/bgp
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-05-21 16:56:09 -0700
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-05-21 16:56:09 -0700
commit562e34a944fa4610931f713ee862d0de3c93161a (patch)
tree4d583a729b4eff2708038f7d0589b5126ae7f0f0 /scripts/bgp
parentbf3b5492e4e36fdccdad9e6651839b33f92ff955 (diff)
downloadvyatta-cfg-quagga-562e34a944fa4610931f713ee862d0de3c93161a.tar.gz
vyatta-cfg-quagga-562e34a944fa4610931f713ee862d0de3c93161a.zip
Allow interface as BGP source
Bug 4391 Quagga allows IP address or interface as update source, so generalize existing template.
Diffstat (limited to 'scripts/bgp')
-rwxr-xr-xscripts/bgp/vyatta-bgp.pl20
1 files changed, 19 insertions, 1 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);
+ }
+}