summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav <v.gletenko@vyos.io>2022-01-12 15:56:52 +0000
committerViacheslav <v.gletenko@vyos.io>2022-01-12 15:56:52 +0000
commitbd55a85af79d6e16b511f2f07b87582fb5dd3ced (patch)
treeb0b829f2652102560fb4b5fc4da1ffeda88d724e
parent9ffb9f5902d7c30e8f37e782268c3ed57b95f72d (diff)
downloadvyatta-op-vpn-bd55a85af79d6e16b511f2f07b87582fb5dd3ced.tar.gz
vyatta-op-vpn-bd55a85af79d6e16b511f2f07b87582fb5dd3ced.zip
op-vpn: T4168: Add timeout for restart vpn with nhrp
With command "restart vpn" in some cases charon process is not fully loaded when is used DMVPN. It is impossible to load "swanctl -q" configuration while "charon" not loaded Add timeout and wait until charon will be available, after that load swanctl configuration
-rwxr-xr-xscripts/vyatta-vpn-op.pl12
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/vyatta-vpn-op.pl b/scripts/vyatta-vpn-op.pl
index 3be7fd8..b48bbb5 100755
--- a/scripts/vyatta-vpn-op.pl
+++ b/scripts/vyatta-vpn-op.pl
@@ -65,6 +65,18 @@ if ($op eq 'clear-vpn-ipsec-process') {
# Check if nhrp configuration exists, exit code
# As 'restart vpn' doesn't load nhrp configuration T3846
if (system('cli-shell-api existsActive protocols nhrp') == 0) {
+ # Set a small timeout for waiting for charon will be loaded
+ # 0 => process not found, 1 => process found
+ my $timeout = 7;
+ if (system("pgrep charon | wc -l" eq 0)) {
+ while ($timeout >= 1){
+ sleep(1);
+ if (system("pgrep charon | wc -l" eq 1)){
+ last;
+ }
+ $timeout--;
+ }
+ }
system 'sudo swanctl --load-all';
}
} else {