From 9c1176c8499c7f2cdc94667263262bfbb155f76b Mon Sep 17 00:00:00 2001 From: Julien Fortin Date: Sat, 12 Dec 2020 01:20:57 +0100 Subject: [PATCH] addons: vlan: check vlan-id misconfiguration and print warning patch adds the following warning when it detects a vlan-id misconfiguration error: vlan13: cannot change vlan-id to 13: operation not supported. Please delete the device with 'ifdown vlan13' and recreate it to apply the change. Signed-off-by: Julien Fortin Signed-off-by: Julien Fortin --- ifupdown2/addons/vlan.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ifupdown2/addons/vlan.py b/ifupdown2/addons/vlan.py index 8619231..b083b01 100644 --- a/ifupdown2/addons/vlan.py +++ b/ifupdown2/addons/vlan.py @@ -159,6 +159,13 @@ class vlan(Addon, moduleBase): 'apply the change.' % (ifaceobj.name, vlan_protocol, ifaceobj.name)) + cached_vlan_id = cached_vlan_ifla_info_data.get(Link.IFLA_VLAN_ID) + if cached_vlan_id is not None and vlanid != cached_vlan_id: + raise Exception('%s: cannot change vlan-id to %s: operation not supported. ' + 'Please delete the device with \'ifdown %s\' and recreate it to ' + 'apply the change.' + % (ifaceobj.name, vlanid, ifaceobj.name)) + if not ifupdownflags.flags.PERFMODE: vlan_exists = self.cache.link_exists(ifaceobj.name)