summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-26 21:40:57 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-26 21:40:57 +0200
commit214af997817f1856c8297a33b0b6ac3f7fb628b3 (patch)
tree8c4875ad79f7e2f1379cdb59b627d18f72b6f926
parent6956bfe0620638adbad36f8cdf6d312884ba82ff (diff)
downloadvyos-1x-214af997817f1856c8297a33b0b6ac3f7fb628b3.tar.gz
vyos-1x-214af997817f1856c8297a33b0b6ac3f7fb628b3.zip
openvpn: T1691: add artifical abort when waiting on interface
-rwxr-xr-xsrc/conf_mode/interface-openvpn.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/conf_mode/interface-openvpn.py b/src/conf_mode/interface-openvpn.py
index 57d565749..c91bc3900 100755
--- a/src/conf_mode/interface-openvpn.py
+++ b/src/conf_mode/interface-openvpn.py
@@ -903,8 +903,19 @@ def apply(openvpn):
# better late then sorry ... but we can only set interface alias after
# OpenVPN has been launched and created the interface
+ cnt = 0
while openvpn['intf'] not in interfaces():
- sleep(0.250) # 250ms
+ # If VPN tunnel can't be established because the peer/server isn't
+ # (temporarily) available, the vtun interface never becomes registered
+ # with the kernel, and the commit would hang if there is no bail out
+ # condition
+ cnt += 1
+ if cnt == 50:
+ break
+
+ # sleep 250ms
+ sleep(0.250)
+
Interface(openvpn['intf']).set_alias(openvpn['description'])
return None