From 152fa12099e2abe13cb44d874c9b1594b24bdafe Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Fri, 25 Mar 2022 13:56:04 +0000 Subject: [PATCH] Update to ordering - Prune bridgedomains before pruning BVIs. The reason for this is that prune_bridgedomains() will set the BVI to L3 mode, and if the BVI is removed before the bridge is pruned, this is an error. - When pruning bridge members, use the VPP configuration as the member may not exist in the config, upon which the call to interface.is_sub() will return False even if it is actually a VPP sub-int. Update README.md, also take into account the previous change which calls prune_addresses() before object deletion. --- README.md | 24 +++++++++++++++--------- vpp/reconciler.py | 15 ++++++++------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 945875b..316dd6c 100644 --- a/README.md +++ b/README.md @@ -138,42 +138,46 @@ and finally all objects are synchronized with the configuration (IP addresses, M if `e0.100` exists with dot1q 100, but has moved to dot1ad 1234. * Remove those that do exist in the config but have mismatched VPP/LCP interface names, for example if `e0` was paired with interface Te1/0/0 but has moved to interface Te1/0/1. -1. Retrieve all Loopbacks and BVIs from VPP - * Remove those that do not exist in the config +1. Retrieve all Loopbacks from VPP * Remove all IP addresses that are not in the config + * Remove those that do not exist in the config 1. Retrieve all Bridge Domains from VPP * Remove those that do not exist in the config * Remove all member interfaces (including BVIs) that are not in the config, return them to L3 mode * Remove tag-rewrite options on removed member interfaces if they have encapsulation +1. Retrieve all BVIs from VPP + * Remove all IP addresses that are not in the config + * Remove those that do not exist in the config 1. For L2 Cross Connects from VPP * For interfaces that do not exist in the config (either as source or target): * Return the interface to L3 mode * Remove tag-rewrite options on if it has encapsulation 1. Retrieve all Tunnels from VPP - * Remove those that do not exist in the config * Remove all IP addresses that are not in the config + * Remove those that do not exist in the config 1. Retrieve all sub-interfaces from VPP * Starting with QinQ/QinAD, then Dot1Q/Dot1AD: + * Remove all IP addresses that are not in the config * Remove those that do not exist in the config * Remove those that do exist in the config but have a different encapsulation - * Remove all IP addresses that are not in the config 1. Retrieve all BondEthernets from VPP + * Remove all IP addresses that are not in the config * Remove those that do not exist in the config * Remove all member interfaces that are not in the config - * Remove all IP addresses that are not in the config 1. And finally, for each PHY interface: * Remove all IP addresses that are not in the config * If not in the config, return to default (L3 mode, MTU 9000, admin-state down) ### Creating -1. Loopbacks and BVIs -1. Bridge Domains +1. Loopbacks 1. BondEthernets -1. Tunnels 1. Dot1Q and Dot1AD sub-interfaces 1. Qin1Q and Qin1AD sub-interfaces +1. Tunnels +1. BVIs +1. Bridge Domains 1. LCP pairs for Tunnels (TUN type) 1. LCP pairs for PHYs, BondEthernets, Dot1Q/Dot1AD and finally QinQ/QinAD (TAP type) @@ -194,5 +198,7 @@ and finally all objects are synchronized with the configuration (IP addresses, M * Set tag-rewrite options if any of the interfaces have encapsulation 1. Decrease MTU for QinQ/QinAD, then Dot1Q/Dot1AD, then (BondEthernets, Tunnels, PHYs) 1. Raise MTU for (PHYs, Tunnels, BondEthernets), then Dot1Q/Dot1AD, then QinQ/QinAD + * Take special care for PHYs which need a max-frame-size change (some interfaces + must be temporarily set admin-down to change that!) 1. Add IPv4/IPv6 addresses -1. Set admin state up +1. Set admin state for all interfaces diff --git a/vpp/reconciler.py b/vpp/reconciler.py index 841a1c1..9152c2b 100644 --- a/vpp/reconciler.py +++ b/vpp/reconciler.py @@ -57,12 +57,12 @@ class Reconciler(): if not self.prune_loopbacks(): self.logger.warning("Could not prune loopbacks from VPP") ret = False - if not self.prune_bvis(): - self.logger.warning("Could not prune BVIs from VPP") - ret = False if not self.prune_bridgedomains(): self.logger.warning("Could not prune BridgeDomains from VPP") ret = False + if not self.prune_bvis(): + self.logger.warning("Could not prune BVIs from VPP") + ret = False if not self.prune_l2xcs(): self.logger.warning("Could not prune L2 Cross Connects from VPP") ret = False @@ -70,13 +70,13 @@ class Reconciler(): self.logger.warning("Could not prune VXLAN Tunnels from VPP") ret = False if not self.prune_sub_interfaces(): - self.logger.warning("Could not prune interfaces from VPP") + self.logger.warning("Could not prune sub-interfaces from VPP") ret = False if not self.prune_bondethernets(): self.logger.warning("Could not prune BondEthernets from VPP") ret = False if not self.prune_phys(): - self.logger.warning("Could not prune interfaces from VPP") + self.logger.warning("Could not prune PHYs from VPP") ret = False return ret @@ -134,8 +134,9 @@ class Reconciler(): members = [] if not config_iface: for member in bridge.sw_if_details: - member_ifname = self.vpp.config['interfaces'][member.sw_if_index].interface_name - if interface.is_sub(self.cfg, member_ifname): + member_iface = self.vpp.config['interfaces'][member.sw_if_index] + member_ifname = member_iface.interface_name + if member_iface.sub_id > 0: self.logger.info("1> set interface l2 tag-rewrite %s disable" % member_ifname) self.logger.info("1> set interface l3 %s" % member_ifname) self.logger.info("1> create bridge-domain %d del" % idx)