diff options
author | Viacheslav <v.gletenko@vyos.io> | 2022-01-12 15:56:52 +0000 |
---|---|---|
committer | Viacheslav <v.gletenko@vyos.io> | 2022-01-12 15:56:52 +0000 |
commit | bd55a85af79d6e16b511f2f07b87582fb5dd3ced (patch) | |
tree | b0b829f2652102560fb4b5fc4da1ffeda88d724e | |
parent | 9ffb9f5902d7c30e8f37e782268c3ed57b95f72d (diff) | |
download | vyatta-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-x | scripts/vyatta-vpn-op.pl | 12 |
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 { |