summaryrefslogtreecommitdiff
path: root/src/conf_mode/wireguard.py
diff options
context:
space:
mode:
authorhagbard <vyosdev@derith.de>2019-01-30 14:57:51 -0800
committerhagbard <vyosdev@derith.de>2019-01-30 14:57:51 -0800
commit2f70340179a64d5936c32cc3c0d6d7f6f04054d0 (patch)
tree4ad7cabd2fd1e533dfca6ef2d0d8690867a39dec /src/conf_mode/wireguard.py
parent31b1b2cb8873f62f8054c87953cd8bd59b59add1 (diff)
downloadvyos-1x-2f70340179a64d5936c32cc3c0d6d7f6f04054d0.tar.gz
vyos-1x-2f70340179a64d5936c32cc3c0d6d7f6f04054d0.zip
Fix: T1217 - cant delete wireguard wg0 interface
Diffstat (limited to 'src/conf_mode/wireguard.py')
-rwxr-xr-xsrc/conf_mode/wireguard.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/conf_mode/wireguard.py b/src/conf_mode/wireguard.py
index c88e9085a..c167366f1 100755
--- a/src/conf_mode/wireguard.py
+++ b/src/conf_mode/wireguard.py
@@ -149,11 +149,12 @@ def apply(c):
if not c:
net_devs = os.listdir('/sys/class/net/')
for dev in net_devs:
- buf = open('/sys/class/net/' + dev + '/uevent', 'r').read()
- if re.search("DEVTYPE=wireguard", buf, re.I|re.M):
- wg_intf = re.sub("INTERFACE=", "", re.search("INTERFACE=.*", buf, re.I|re.M).group(0))
- sl.syslog(sl.LOG_NOTICE, "removing interface " + wg_intf)
- subprocess.call(['ip l d dev ' + wg_intf + ' >/dev/null'], shell=True)
+ if os.path.isdir('/sys/class/net/' + dev):
+ buf = open('/sys/class/net/' + dev + '/uevent', 'r').read()
+ if re.search("DEVTYPE=wireguard", buf, re.I|re.M):
+ wg_intf = re.sub("INTERFACE=", "", re.search("INTERFACE=.*", buf, re.I|re.M).group(0))
+ sl.syslog(sl.LOG_NOTICE, "removing interface " + wg_intf)
+ subprocess.call(['ip l d dev ' + wg_intf + ' >/dev/null'], shell=True)
return None
###