summaryrefslogtreecommitdiff
path: root/scripts/vyatta-vti-config.pl
diff options
context:
space:
mode:
authorSaurabh Mohan <saurabh.mohan@vyatta.com>2012-06-11 17:50:22 -0700
committerSaurabh Mohan <saurabh.mohan@vyatta.com>2012-06-11 17:50:22 -0700
commitbead91b5a008bf8c999db2cc59e34bbe640bcaa0 (patch)
tree25fd304e7bf05907bd37f367f42e0e915bc2cfc5 /scripts/vyatta-vti-config.pl
parentd519a894fcb07ed08577b7be9dfdb3efeafa980c (diff)
downloadvyatta-cfg-vpn-bead91b5a008bf8c999db2cc59e34bbe640bcaa0.tar.gz
vyatta-cfg-vpn-bead91b5a008bf8c999db2cc59e34bbe640bcaa0.zip
VTI: Add support call for checking for vti interface name.
Diffstat (limited to 'scripts/vyatta-vti-config.pl')
-rwxr-xr-xscripts/vyatta-vti-config.pl37
1 files changed, 36 insertions, 1 deletions
diff --git a/scripts/vyatta-vti-config.pl b/scripts/vyatta-vti-config.pl
index aa1efee..57fded4 100755
--- a/scripts/vyatta-vti-config.pl
+++ b/scripts/vyatta-vti-config.pl
@@ -43,11 +43,13 @@ my $result = 0;
my $updown="";
my $intfName="";
my $action="";
+my $checkref="";
GetOptions(
"updown" => \$updown,
"intf=s" => \$intfName,
"action=s" => \$action,
+ "checkref" => \$checkref,
);
@@ -68,6 +70,19 @@ if ($updown ne '') {
}
#
+# --checkref --intf=<intfName>
+# Return 1 if the interface reference exits.
+#
+if ($checkref ne '' ) {
+ if (!(defined $intfName) || $intfName eq '' ) {
+ # invalid
+ exit -1;
+ }
+ my $rval = vti_check_reference($intfName);
+ exit $rval;
+}
+
+#
# Prepare Vyatta::Config object
#
use Vyatta::Config;
@@ -174,8 +189,28 @@ sub vti_handle_updown {
use Vyatta::Config;
my $vcIntf = new Vyatta::Config();
$vcIntf->setLevel('interfaces');
- my $disabled = $vcIntf->exists("vti $intfName disabled");
+ my $disabled = $vcIntf->existsOrig("vti $intfName disabled");
if (!defined($disabled) || ! $disabled) {
system("sudo /sbin/ip link set $intfName $action\n");
}
}
+
+sub vti_check_reference {
+ my ($intfName) = @_;
+ use Vyatta::Config;
+ my $vcVPN = new Vyatta::Config();
+ $vcVPN->setLevel('vpn ipsec site-to-site');
+ my @peers = $vcVPN->listNodes('peer');
+ if (@peers == 0) {
+ return 0;
+ }
+ foreach my $peer (@peers) {
+ if (! $vcVPN->exists("peer $peer vti")) {
+ next;
+ }
+ if ( $vcVPN->exists("peer $peer vti bind $intfName")) {
+ return 1;
+ }
+ }
+ return 0;
+}