diff options
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/vti-up-down.sh | 2 | ||||
-rwxr-xr-x | scripts/vyatta-vti-config.pl | 37 |
2 files changed, 37 insertions, 2 deletions
diff --git a/scripts/vti-up-down.sh b/scripts/vti-up-down.sh index efa4118..60fc191 100755 --- a/scripts/vti-up-down.sh +++ b/scripts/vti-up-down.sh @@ -14,4 +14,4 @@ down-client) *) ;; esac - +exit 0 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; +} |