summaryrefslogtreecommitdiff
path: root/scripts/vpn-config.pl
diff options
context:
space:
mode:
authorBob Gilligan <gilligan@vyatta.com>2009-04-06 16:38:48 -0700
committerBob Gilligan <gilligan@vyatta.com>2009-04-06 16:38:48 -0700
commitec8ba320d17653ac619a284dd6dd62e104531270 (patch)
treeeef7960a94624fd17d9fa8d345760430e1e4f150 /scripts/vpn-config.pl
parent0686919dca6c7555db90e99eb12ef509bd2422d5 (diff)
downloadvyatta-cfg-vpn-ec8ba320d17653ac619a284dd6dd62e104531270.tar.gz
vyatta-cfg-vpn-ec8ba320d17653ac619a284dd6dd62e104531270.zip
Bugfix 2387: Don't list interfaces in ipsec config file.
The "interfaces=..." entry in the /etc/ipsec.conf file needs to list the actual interfaces we are using only if the underlying kernel IPsec support is provided by KLIPS. In our case, we are using NETKEY, so we don't need to list our interfaces there. Not listing them makes ipsec startup a bit more robust.
Diffstat (limited to 'scripts/vpn-config.pl')
-rwxr-xr-xscripts/vpn-config.pl45
1 files changed, 29 insertions, 16 deletions
diff --git a/scripts/vpn-config.pl b/scripts/vpn-config.pl
index bff9005..b6cecaa 100755
--- a/scripts/vpn-config.pl
+++ b/scripts/vpn-config.pl
@@ -54,6 +54,10 @@ my $error = 0;
my $genout;
my $genout_secrets;
+# Set $using_klips to 1 if kernel IPsec support is provided by KLIPS.
+# Set it to 0 us using NETKEY.
+my $using_klips = 0;
+
$genout .= "# generated by $0\n\n";
$genout_secrets .= "# generated by $0\n\n";
@@ -224,25 +228,34 @@ if ($vcVPN->exists('ipsec')) {
$error = 1;
print STDERR "VPN configuration error. No IPSEC interfaces specified.\n";
} else {
- $genout .= "\tinterfaces=\"";
- my $counter = 0;
- foreach my $interface (@interfaces) {
- if (!(-d "/sys/class/net/$interface")) {
- next;
- }
- if ($counter > 0) {
- $genout .= ' ';
+ # We need to generate an "interfaces=..." entry in the setup section
+ # only if the underlying IPsec kernel code we are using is KLIPS.
+ # If we are using NETKEY, the "interfaces=..." entry is essentially
+ # not used, though we do need to include the line and the keyword
+ # "%none" to keep the IPsec setup code from defaulting the entry.
+ if ($using_klips) {
+ $genout .= "\tinterfaces=\"";
+ my $counter = 0;
+ foreach my $interface (@interfaces) {
+ if (!(-d "/sys/class/net/$interface")) {
+ next;
+ }
+ if ($counter > 0) {
+ $genout .= ' ';
+ }
+ $genout .= "ipsec$counter=$interface";
+ ++$counter;
}
- $genout .= "ipsec$counter=$interface";
- ++$counter;
- }
- if (hasLocalWildcard($vcVPN, 0)) {
- if ($counter > 0) {
- $genout .= ' ';
+ if (hasLocalWildcard($vcVPN, 0)) {
+ if ($counter > 0) {
+ $genout .= ' ';
+ }
+ $genout .= '%defaultroute';
}
- $genout .= '%defaultroute';
+ $genout .= "\"\n";
+ } else {
+ $genout .= "\tinterfaces=\"%none\"\n";
}
- $genout .= "\"\n";
}
#