From 458f195c1a57e1eadb0d0eb26310025850a65593 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 30 Sep 2020 20:43:41 +0200 Subject: 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. --- src/conf_mode/interfaces-macsec.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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)): -- cgit v1.2.3