From 9bc5734e46f55b8134847da2333147f52711f77b Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Thu, 14 Oct 2021 13:46:13 -0700 Subject: [PATCH] [NSX-P] Ensure multicast is disabled for dualstack use cases For some dual-stack use cases it will be mandatory to disable multicast routing on NSX-T segments. Change-Id: I821b6038ec4b0404d54c03c8802bdbbf8d211ed4 --- vmware_nsx/plugins/nsx_p/plugin.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/vmware_nsx/plugins/nsx_p/plugin.py b/vmware_nsx/plugins/nsx_p/plugin.py index a4e45a96a3..56702ea6e2 100644 --- a/vmware_nsx/plugins/nsx_p/plugin.py +++ b/vmware_nsx/plugins/nsx_p/plugin.py @@ -1152,12 +1152,11 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base): return True if dhcp_port else False def _get_segment_subnets_versions(self, context, net_id): - # Find networks DHCP enabled subnets - versions = set() + versions = {4: [], 6: []} with db_api.CONTEXT_READER.using(context): network = self._get_network(context, net_id) for subnet in network.subnets: - versions.add(subnet.ip_version) + versions[subnet.ip_version].append(subnet) return versions def _get_segment_multicast_setting(self, context, net_id): @@ -1165,8 +1164,16 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base): seg_subnets_ip_ver = self._get_segment_subnets_versions( context, net_id) # Multicast cannot be enabled on segments with v6 subnets only - if len(seg_subnets_ip_ver) == 1 and seg_subnets_ip_ver.pop() == 6: + if not seg_subnets_ip_ver[4]: return False + if seg_subnets_ip_ver[6]: + for subnet in seg_subnets_ip_ver[6]: + if subnet.enable_dhcp: + break + else: + # There are no v4 subnets stored in NSX, must + # disable multicast + return False # Ignore value of multicast setting (go with defaults) return core_resources.IGNORE