From: Julien Fortin Date: Fri, 15 Feb 2019 10:29:43 +0000 (+0100) Subject: addons: addressvirtual: delete macvlan when vrrp config is removed (ifreload case) X-Git-Tag: 1.2.8-1~38 X-Git-Url: https://git.proxmox.com/?p=mirror_ifupdown2.git;a=commitdiff_plain;h=709f7942a2886d6b1067f242b023c35809c918d5 addons: addressvirtual: delete macvlan when vrrp config is removed (ifreload case) Add a vrrp config under swp intf - ifup, then remove the vrrp config - ifreload the macvlans are not removed without this patch Signed-off-by: Julien Fortin --- diff --git a/ifupdown2/addons/addressvirtual.py b/ifupdown2/addons/addressvirtual.py index 062c361..9e08e41 100644 --- a/ifupdown2/addons/addressvirtual.py +++ b/ifupdown2/addons/addressvirtual.py @@ -247,15 +247,19 @@ class addressvirtual(moduleBase): return hwaddress = [] self.ipcmd.batch_start() - macvlan_prefix = self._get_macvlan_prefix(ifaceobj) - for macvlan_ifacename in glob.glob("/sys/class/net/%s*" %macvlan_prefix): - macvlan_ifacename = os.path.basename(macvlan_ifacename) - if not self.ipcmd.link_exists(macvlan_ifacename): - continue - hwaddress.append(self.ipcmd.link_get_hwaddress(macvlan_ifacename)) - self.ipcmd.link_delete(os.path.basename(macvlan_ifacename)) - # XXX: Also delete any fdb addresses. This requires, checking mac address - # on individual macvlan interfaces and deleting the vlan from that. + for macvlan_prefix in [ + self._get_macvlan_prefix(ifaceobj), + self.get_vrr_prefix(ifaceobj.name, "4"), + self.get_vrr_prefix(ifaceobj.name, "6") + ]: + for macvlan_ifacename in glob.glob("/sys/class/net/%s*" % macvlan_prefix): + macvlan_ifacename = os.path.basename(macvlan_ifacename) + if not self.ipcmd.link_exists(macvlan_ifacename): + continue + hwaddress.append(self.ipcmd.link_get_hwaddress(macvlan_ifacename)) + self.ipcmd.link_delete(os.path.basename(macvlan_ifacename)) + # XXX: Also delete any fdb addresses. This requires, checking mac address + # on individual macvlan interfaces and deleting the vlan from that. self.ipcmd.batch_commit() if any(hwaddress): self._remove_addresses_from_bridge(ifaceobj, hwaddress)