]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: vxlan: ifquery-check: mcastgrp-map: use bridge vni show
authorJulien Fortin <jfortin@nvidia.com>
Wed, 23 Jun 2021 12:00:00 +0000 (14:00 +0200)
committerJulien Fortin <jfortin@nvidia.com>
Thu, 1 Jul 2021 17:54:09 +0000 (19:54 +0200)
Signed-off-by: Julien Fortin <jfortin@nvidia.com>
ifupdown2/addons/vxlan.py

index 102c3fe3ca8eec19695d608c3d5426b33c81b001..6797fe318504c6bddb3bc2cb5238c2c8edd61a54 100644 (file)
@@ -1477,21 +1477,30 @@ class vxlan(Vxlan, moduleBase):
         user_mcastgrp_map = self.__get_vxlan_mcastgrp_map(ifaceobj)
         user_remote_ip_map = self.__get_vxlan_remote_ip_map(ifaceobj)
 
-        if not user_mcastgrp_map or not user_remote_ip_map:
+        if not user_mcastgrp_map and not user_remote_ip_map:
             return
 
         fdb_mcast = {}
         fdb_remote = {}
 
-        for _, src_vni, dst in self.get_svd_running_fdb(ifname):
-            ip = ipnetwork.IPv4Address(dst)
+        if user_remote_ip_map:
+            for _, src_vni, dst in self.get_svd_running_fdb(ifname):
+                ip = ipnetwork.IPv4Address(dst)
 
-            if ip.is_multicast:
-                # we need to reconvert back to ipaddress.IPv4Address because
-                # the existing code uses this type of obj (namely: __get_vxlan_mcastgrp_map)
-                fdb_mcast[int(src_vni)] = IPv4Address(ip.ip)
-            else:
-                fdb_remote.setdefault(int(src_vni), []).append(ip)
+                if not ip.is_multicast:
+                    fdb_remote.setdefault(int(src_vni), []).append(ip)
+
+        if user_mcastgrp_map:
+            for obj in json.loads(utils.exec_command("bridge -j -p vni show dev %s" % ifname) or "[]"):
+                for vni in obj.get("vnis", []):
+                    group = vni.get("group")
+
+                    if not group:
+                        continue
+
+                    # we need to reconvert back to ipaddress.IPv4Address because
+                    # the existing code uses this type of obj (namely: __get_vxlan_mcastgrp_map)
+                    fdb_mcast[vni.get("vni")] = IPv4Address(group)
 
         #
         # vxlan-mcastgrp-map