Prune Step 7: Remove VXLAN tunnels that either aren't in the config, or have a mismatched src/dst/vni

This commit is contained in:
Pim van Pelt
2022-03-24 23:42:46 +00:00
parent c381c7cbaa
commit 33aedd585f

View File

@ -75,6 +75,9 @@ class Reconciler():
if not self.prune_bondethernets(): if not self.prune_bondethernets():
self.logger.warning("Could not prune BondEthernets from VPP that are not in the config") self.logger.warning("Could not prune BondEthernets from VPP that are not in the config")
ret = False ret = False
if not self.prune_vxlan_tunnels():
self.logger.warning("Could not prune VXLAN Tunnels from VPP that are not in the config")
ret = False
return ret return ret
def prune_loopbacks(self): def prune_loopbacks(self):
@ -173,6 +176,25 @@ class Reconciler():
self.logger.debug("BondEthernet OK: %s" % (vpp_ifname)) self.logger.debug("BondEthernet OK: %s" % (vpp_ifname))
return True return True
def prune_vxlan_tunnels(self):
for idx, vpp_vxlan in self.vpp.config['vxlan_tunnels'].items():
vpp_ifname = self.vpp.config['interfaces'][idx].interface_name
config_ifname, config_iface = vxlan_tunnel.get_by_name(self.cfg, vpp_ifname)
if not config_iface:
self.logger.info("1> create vxlan tunnel instance %d src %s dst %s vni %d del" % (vpp_vxlan.instance,
vpp_vxlan.src_address, vpp_vxlan.dst_address, vpp_vxlan.vni))
continue
if config_iface['local'] != str(vpp_vxlan.src_address) or config_iface['remote'] != str(vpp_vxlan.dst_address) or config_iface['vni'] != vpp_vxlan.vni:
self.logger.info("2> create vxlan tunnel instance %d src %s dst %s vni %d del" % (vpp_vxlan.instance,
vpp_vxlan.src_address, vpp_vxlan.dst_address, vpp_vxlan.vni))
continue
addresses = []
if 'addresses' in config_iface:
addresses = config_iface['addresses']
self.prune_addresses(vpp_ifname, addresses)
self.logger.debug("VXLAN Tunnel OK: %s" % (vpp_ifname))
return True
def __parent_iface_by_encap(self, sup_sw_if_index, outer, dot1ad=True): def __parent_iface_by_encap(self, sup_sw_if_index, outer, dot1ad=True):
""" Returns the idx of an interface on a given super_sw_if_index with given dot1q/dot1ad outer and inner-dot1q=0 """ """ Returns the idx of an interface on a given super_sw_if_index with given dot1q/dot1ad outer and inner-dot1q=0 """
for idx, iface in self.vpp.config['interfaces'].items(): for idx, iface in self.vpp.config['interfaces'].items():