From a3cecbc37572679807fdb4aa7acb0c606cb5b178 Mon Sep 17 00:00:00 2001 From: jim-p Date: Wed, 25 Mar 2015 10:40:00 -0400 Subject: [PATCH] Eliminate the "this_device" test from the resync check in rc.openvpn. It is not necessary to check, as the only times a gateway event should trigger the VPN to restart are when the current and new devices differ. This also allows us to simplify the code a bit and eliminate some single-use variables. See the discussion at https://github.com/pfsense/pfsense/commit/4aefcf915112b38784b06abc8dd9a26d9a4960b3 --- etc/rc.openvpn | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/etc/rc.openvpn b/etc/rc.openvpn index e3af78538e..ce5ea9669b 100755 --- a/etc/rc.openvpn +++ b/etc/rc.openvpn @@ -49,15 +49,10 @@ function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) { $mode_id = $mode . $ovpn_settings['vpnid']; $fpath = "{$g['varetc_path']}/openvpn/{$mode_id}.interface"; if (file_exists($fpath)) { - $current_device = file_get_contents($fpath); - $current_device = trim($current_device, " \t\n"); - $new_device = get_failover_interface($ovpn_settings['interface']); - if (isset($config['interfaces'][$interface])) { - $this_device = $config['interfaces'][$interface]['if']; - /* If the "current", "new", and "this" device are ALL the same, no resync should be necessary. */ - if (($current_device == $new_device) && ($current_device == $this_device)) - $resync_needed = false; - } + /* Compare the interface currently used by the VPN with the interface that should be used. + If the VPN should stay on the same interface, do not resync */ + if (trim(file_get_contents($fpath), " \t\n") == get_failover_interface($ovpn_settings['interface'])) { + $resync_needed = false; } } }