summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-09-30 20:43:41 +0200
committerChristian Poessinger <christian@poessinger.com>2020-09-30 20:45:52 +0200
commit458f195c1a57e1eadb0d0eb26310025850a65593 (patch)
tree20c4ad4ca04b44a0b0645862c52be0f63bb3c5d7
parentd1f6b8a8a9e3298b10fe6a04f4edb531582efc88 (diff)
downloadvyos-1x-458f195c1a57e1eadb0d0eb26310025850a65593.tar.gz
vyos-1x-458f195c1a57e1eadb0d0eb26310025850a65593.zip
macsec: T2023: only remove interface when it exists
If for whatever reason the macsec interface dropped out of the Kernel - only call .remove() when it still exists to avoid any exceptions at all.
-rwxr-xr-xsrc/conf_mode/interfaces-macsec.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/conf_mode/interfaces-macsec.py b/src/conf_mode/interfaces-macsec.py
index 613648adb..706b8edb0 100755
--- a/src/conf_mode/interfaces-macsec.py
+++ b/src/conf_mode/interfaces-macsec.py
@@ -16,6 +16,7 @@
import os
+from netifaces import interfaces
from sys import exit
from vyos.config import Config
@@ -114,7 +115,9 @@ def apply(macsec):
call('systemctl stop wpa_supplicant-macsec@{source_interface}'
.format(**macsec))
- MACsecIf(macsec['ifname']).remove()
+ if macsec['ifname'] in interfaces():
+ tmp = MACsecIf(macsec['ifname'])
+ tmp.remove()
# delete configuration on interface removal
if os.path.isfile(wpa_suppl_conf.format(**macsec)):