diff --git a/ifupdown2/addons/addressvirtual.py b/ifupdown2/addons/addressvirtual.py index 9c0cb7d..c5a7c2f 100644 --- a/ifupdown2/addons/addressvirtual.py +++ b/ifupdown2/addons/addressvirtual.py @@ -243,6 +243,13 @@ class addressvirtual(moduleBase): except: self.ipcmd.link_add_macvlan(ifaceobj.name, macvlan_ifacename) link_created = True + else: + if should_configure_ipv6_addrgen: + # When setting addrgenmode it is necessary to flap the macvlan + # device. After flapping the device we also need to re-add all + # the user configuration. The best way to add the user config + # is to flush our internal address cache + self.ipcmd.reset_addr_cache(macvlan_ifacename) # first thing we need to handle vrf enslavement if (ifaceobj.link_privflags & ifaceLinkPrivFlags.VRF_SLAVE): diff --git a/ifupdown2/ifupdownaddons/LinkUtils.py b/ifupdown2/ifupdownaddons/LinkUtils.py index 4c63d0d..6fb42e2 100644 --- a/ifupdown2/ifupdownaddons/LinkUtils.py +++ b/ifupdown2/ifupdownaddons/LinkUtils.py @@ -2638,6 +2638,13 @@ class LinkUtils(utilsBase): except: return [] + def reset_addr_cache(self, ifname): + try: + linkCache.links[ifname]['addrs'] = {} + self.logger.debug('%s: reset address cache' % ifname) + except: + pass + def ipv6_addrgen(self, ifname, addrgen): cmd = 'link set dev %s addrgenmode %s' % (ifname, 'eui64' if addrgen else 'none')