NSX|V: skip metadata proxy subnets for BGP updates

Ensure that metadata routes and IP's are are not used
when updating BGP

Change-Id: I83b5c57a77f38b95dab14fc9584b9e276438d5a3
This commit is contained in:
Gary Kotton 2017-08-03 00:56:28 -07:00
parent 7bcd7d009f
commit 1f236bb32c
2 changed files with 25 additions and 2 deletions

View File

@ -742,3 +742,6 @@ class NsxVMetadataProxyHandler(object):
except Exception as e:
LOG.error("Failed to delete md_proxy port %(port)s: "
"%(e)s", {'port': ports[0]['id'], 'e': e})
def is_md_subnet(self, subnet_id):
return self.internal_subnet == subnet_id

View File

@ -165,6 +165,16 @@ class NSXvBgpDriver(object):
edge_router_dict[edge_id]['no_snat_routers'].append(router_id)
return edge_router_dict
def _get_md_proxy_for_router(self, context, router_id):
binding = nsxv_db.get_nsxv_router_binding(context.session,
router_id)
md_proxy = None
if binding:
az_name = binding['availability_zone']
md_proxy = self._core_plugin.get_metadata_proxy_handler(
az_name)
return md_proxy
def _query_tenant_subnets(self, context, router_ids):
# Query subnets attached to all of routers attached to same edge
subnets = []
@ -174,8 +184,12 @@ class NSXvBgpDriver(object):
int_ports = self._core_plugin.get_ports(context,
filters=filters,
fields=['fixed_ips'])
# We need to skip metadata subnets
md_proxy = self._get_md_proxy_for_router(context, router_id)
for p in int_ports:
subnet_id = p['fixed_ips'][0]['subnet_id']
if md_proxy and md_proxy.is_md_subnet(subnet_id):
continue
subnet = self._core_plugin.get_subnet(context, subnet_id)
subnets.append({'id': subnet_id,
'cidr': subnet['cidr']})
@ -618,6 +632,9 @@ class NSXvBgpDriver(object):
if not bgp_binding:
return
# Need to ensure that we do not use the metadata IP's
md_proxy = self._get_md_proxy_for_router(context, router_id)
routers_ids = (
self._core_plugin.edge_manager.get_routers_on_same_edge(
context, router_id))
@ -629,8 +646,11 @@ class NSXvBgpDriver(object):
filters = {'device_owner': [n_const.DEVICE_OWNER_ROUTER_GW],
'device_id': routers_ids}
edge_gw_ports = self._core_plugin.get_ports(context, filters=filters)
alt_bgp_identifiers = [p['fixed_ips'][0]['ip_address']
for p in edge_gw_ports]
alt_bgp_identifiers = [
p['fixed_ips'][0]['ip_address'] for p in edge_gw_ports
if (not md_proxy or
not md_proxy.is_md_subnet(
p['fixed_ips'][0]['subnet_id']))]
if alt_bgp_identifiers:
# Shared router, only remove prefixes and redistribution
# rules.