"help": "vxlan multicast group",
"validvals": ["<ip6>"],
"example": ["vxlan-mcastgrp ff02::15c"],
- }
+ },
+ "vxlan-mcastgrp-map": {
+ "help": "vxlan multicast group for single-vxlan device",
+ "validvals": ["<number-ipv4-list>"],
+ "example": ["vxlan-mcastgrp-map 1000=239.1.1.100 1001=239.1.1.200"],
+ },
}
}
self.log_error("%s: vxlan creation failed: %s" % (ifname, str(e)), ifaceobj)
return
+ if ifaceobj.link_privflags & ifaceLinkPrivFlags.SINGLE_VXLAN:
+ # check current fdb entries
+ vxlan_fdb_data = utils.exec_command("bridge fdb show dev %s" % ifname)
+ current_fdb = []
+
+ if vxlan_fdb_data:
+ # each entry should look like the following:
+ # 00:00:00:00:00:00 dst 239.1.1.100 src_vni 1000 self permanent
+ for entry in [line for line in vxlan_fdb_data.strip().split("\n") if "src_vni" in line]:
+ mac, _, dst, _, src_vni = entry.split()[0:5]
+ current_fdb.append((mac, src_vni, dst))
+
+ user_config_fdb = self.get_vxlan_fdb_src_vni(ifaceobj.get_attr_value("vxlan-mcastgrp-map"))
+
+ fdb_to_remove = set(current_fdb) - set(user_config_fdb)
+
+ for mac, vni, _ in fdb_to_remove:
+ self.iproute2.bridge_fdb_del_src_vni(ifname, mac, vni)
+
+ for mac, src_vni, dst_ip in user_config_fdb:
+ if (mac, src_vni, dst_ip) not in current_fdb:
+ try:
+ self.iproute2.bridge_fdb_add_src_vni(ifname, src_vni, dst_ip)
+ except Exception as e:
+ ifaceobj.set_status(ifaceStatus.ERROR)
+ self.log_error("%s: vxlan-mcastgrp-map: %s=%s: %s" % (ifname, src_vni, dst_ip, str(e)), raise_error=False)
+
vxlan_purge_remotes = self.__get_vlxan_purge_remotes(ifaceobj)
remoteips = ifaceobj.get_attr_value('vxlan-remoteip')
except Exception:
pass
+ @staticmethod
+ def get_vxlan_fdb_src_vni(vxlan_mcast_grp_map):
+ fdbs = []
+ for entry in vxlan_mcast_grp_map or []:
+ for vni_ip in entry.split():
+ src_vni, dst_ip = vni_ip.split("=")
+ fdbs.append(("00:00:00:00:00:00", src_vni, dst_ip))
+ return fdbs
+
def _down(self, ifaceobj):
try:
self.netlink.link_del(ifaceobj.name)
)
)
+ @staticmethod
+ def bridge_fdb_add_src_vni(dev, src_vni, dst_ip):
+ """
+ bridge fdb add dev $dev 00:00:00:00:00:00 src_vni $src_vni dst $dst_ip
+ """
+ utils.exec_command(
+ "%s fdb add dev %s 00:00:00:00:00:00 src_vni %s dst %s"
+ % (
+ utils.bridge_cmd,
+ dev,
+ src_vni,
+ dst_ip
+ )
+ )
+
@staticmethod
def bridge_fdb_append(dev, address, vlan=None, bridge=True, remote=None):
target = "self" if bridge else ""
)
)
+ @staticmethod
+ def bridge_fdb_del_src_vni(dev, mac, src_vni):
+ utils.exec_command(
+ "%s fdb del %s dev %s src_vni %s"
+ % (
+ utils.bridge_cmd,
+ mac,
+ dev,
+ src_vni
+ )
+ )
+
@staticmethod
def bridge_fdb_del(dev, address, vlan=None, bridge=True, remote=None):
target = "self" if bridge else ""