]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: bridge: bridge-vlan-vni-map: use vlan and vni ranges within iproute2 cmds
authorJulien Fortin <jfortin@nvidia.com>
Tue, 23 Mar 2021 15:11:28 +0000 (16:11 +0100)
committerJulien Fortin <jfortin@nvidia.com>
Wed, 30 Jun 2021 16:16:07 +0000 (18:16 +0200)
Instead of exploding vlans and vnis ranges we can simply pass those ranges to iproute2
which will reduce the load on ifupdown2 side and scale better

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
ifupdown2/addons/bridge.py
ifupdown2/lib/iproute2.py

index 67e8abc7817ad2b8d1bfb3f99ed36147bb5fb20c..3b0cff1f9eb4e508a461dd392f204dd46a0ad2be 100644 (file)
@@ -2422,15 +2422,9 @@ class bridge(Bridge, moduleBase):
                     except:
                         return self.__warn_bridge_vlan_vni_map_syntax_error(vxlan_name, vlan_vni_map)
 
-                    vlans = self._ranges_to_ints([vlans_str])
-                    vnis = self._ranges_to_ints([vni_str])
-
-                    if len(vlans) != len(vnis):
-                        return self.__warn_bridge_vlan_vni_map_syntax_error(vxlan_name, vlan_vni_map)
-
                     # TODO: query the cache prio to executing those commands
-                    self.iproute2.bridge_vlan_add_vid_list_self(vxlan_name, vlans, False)
-                    self.iproute2.bridge_vlan_add_vlan_tunnel_info(vxlan_name, vlans, vnis)
+                    self.iproute2.bridge_vlan_add_vid_list_self(vxlan_name, [vlans_str], False)
+                    self.iproute2.bridge_vlan_add_vlan_tunnel_info(vxlan_name, vlans_str, vni_str)
 
             self.iproute2.batch_commit()
         except Exception as e:
index 84cb1b843c47947c393b21fb41e5f496cc9ee9a6..6089f642e0ce12bcd08d64713da6ea4b51a65329 100644 (file)
@@ -662,17 +662,16 @@ class IPRoute2(Cache, Requirements):
             )
 
     def bridge_vlan_add_vlan_tunnel_info(self, ifname, vids, vnis):
-        for i in range(0, len(vids)):
-            try:
-                self.__execute_or_batch(
-                    utils.bridge_cmd,
-                    "vlan add dev %s vid %s tunnel_info id %s" % (
-                        ifname, vids[i], vnis[i]
-                    )
+        try:
+            self.__execute_or_batch(
+                utils.bridge_cmd,
+                "vlan add dev %s vid %s tunnel_info id %s" % (
+                    ifname, vids, vnis
                 )
-            except Exception as e:
-                if "exists" not in str(e).lower():
-                    self.logger.error(e)
+            )
+        except Exception as e:
+            if "exists" not in str(e).lower():
+                self.logger.error(e)
 
     @staticmethod
     def bridge_vlan_add_vid_list(ifname, vids):