summaryrefslogtreecommitdiffstats
path: root/etc/rc.openvpn
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@world.inf.org>2013-05-07 20:16:13 +0545
committerPhil Davis <phil.davis@world.inf.org>2013-05-07 20:16:13 +0545
commite960b29837062f7b0348abaebfdc9c1cdc423b68 (patch)
tree359846147393888b6d71c297d0fbc14db96864e3 /etc/rc.openvpn
parent982e004f0ae0ae89f627e879be0f355001ae2f5d (diff)
downloadpfsense-e960b29837062f7b0348abaebfdc9c1cdc423b68.zip
pfsense-e960b29837062f7b0348abaebfdc9c1cdc423b68.tar.gz
Optimize which OpenVPN instances are restarted
Diffstat (limited to 'etc/rc.openvpn')
-rwxr-xr-xetc/rc.openvpn25
1 files changed, 23 insertions, 2 deletions
diff --git a/etc/rc.openvpn b/etc/rc.openvpn
index d57594a..531fa40 100755
--- a/etc/rc.openvpn
+++ b/etc/rc.openvpn
@@ -38,6 +38,27 @@ require_once("filter.inc");
require_once("gwlb.inc");
require_once("openvpn.inc");
+function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) {
+ global $g, $config;
+
+ $resync_needed = false;
+ if (empty($interface)) {
+ $resync_needed = true;
+ } else {
+ $mode_id = $mode . $ovpn_settings['vpnid'];
+ $fpath = "{$g['varetc_path']}/openvpn/{$mode_id}.interface";
+ $current_device = file_get_contents($fpath);
+ $new_device = get_failover_interface($ovpn_settings['interface']);
+ $this_device = $config['interfaces'][$interface]['if'];
+ if (($current_device != $new_device) || ($current_device == $this_device) || ($new_device == $this_device))
+ $resync_needed = true;
+ }
+ if ($resync_needed) {
+ log_error("OpenVPN: Resync " . $mode_id . " " . $ovpn_settings['description']);
+ openvpn_resync($mode, $ovpn_settings);
+ }
+}
+
/* make sure to wait until the boot scripts have finished */
if (file_exists("{$g['varrun_path']}/booting"))
return;
@@ -70,14 +91,14 @@ else {
if(is_array($config['openvpn']['openvpn-server'])) {
foreach($config['openvpn']['openvpn-server'] as &$server) {
if ($server['interface'] == $interface || empty($interface) || (!empty($gwgroups) && in_array($server['interface'], $gwgroups)))
- openvpn_resync('server', $server);
+ openvpn_resync_if_needed('server', $server, $interface);
}
}
if (is_array($config['openvpn']['openvpn-client'])) {
foreach($config['openvpn']['openvpn-client'] as &$client) {
if ($client['interface'] == $interface || empty($interface) || (!empty($gwgroups) && in_array($client['interface'], $gwgroups)))
- openvpn_resync('client', $client);
+ openvpn_resync_if_needed('client', $client, $interface);
}
}
OpenPOWER on IntegriCloud