From e2a1e8c3128b88353a1743612372877f32c4cd76 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 19 Apr 2023 08:55:04 +0200 Subject: [PATCH] VPN: OpenVPN: Clients - When receiving carp events for client mode openvpn instances, treat INIT the same as BACKUP as both modes aren't active. experiment for https://github.com/opnsense/core/issues/6506 --- src/etc/inc/plugins.inc.d/openvpn.inc | 4 ++-- src/etc/rc.syshook.d/carp/20-openvpn | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/etc/inc/plugins.inc.d/openvpn.inc b/src/etc/inc/plugins.inc.d/openvpn.inc index 6a347e510..d588ce91a 100644 --- a/src/etc/inc/plugins.inc.d/openvpn.inc +++ b/src/etc/inc/plugins.inc.d/openvpn.inc @@ -917,9 +917,9 @@ function openvpn_restart($mode, $settings, $carp_event = false) $interface_details = legacy_interface_details(get_real_interface($interface)); if ( !empty($interface_details) && !empty($interface_details['carp'][$vhid]) && - $interface_details['carp'][$vhid]['status'] == 'BACKUP' + in_array($interface_details['carp'][$vhid]['status'], ['BACKUP' ,'INIT']) ) { - /* do not restart a client if we are a CARP backup instance */ + /* do not restart a client if we are a CARP backup instance or unplugged (init)*/ return; } } diff --git a/src/etc/rc.syshook.d/carp/20-openvpn b/src/etc/rc.syshook.d/carp/20-openvpn index ab8973fb8..f0164abb0 100755 --- a/src/etc/rc.syshook.d/carp/20-openvpn +++ b/src/etc/rc.syshook.d/carp/20-openvpn @@ -35,7 +35,7 @@ require_once("plugins.inc.d/openvpn.inc"); $subsystem = !empty($argv[1]) ? $argv[1] : ''; $type = !empty($argv[2]) ? $argv[2] : ''; -if ($type != 'MASTER' && $type != 'BACKUP') { +if (!in_array($type, ['MASTER', 'BACKUP', 'INIT'])) { log_msg("Carp '$type' event unknown from source '{$subsystem}'"); exit(1); }