NSXv: evaluate NAT rules correctly

Change-Id: Ic558a08cd629e3b2b02190bb5fff9d4b5ad05396
This commit is contained in:
Kobi Samoray 2019-12-10 11:33:09 +02:00
parent 59dbb0dc0c
commit 6966160da6

View File

@ -3890,7 +3890,6 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
context.elevated(), router['id']) context.elevated(), router['id'])
gw_address_scope = self._get_network_address_scope( gw_address_scope = self._get_network_address_scope(
context.elevated(), gw_port['network_id']) context.elevated(), gw_port['network_id'])
if gw_address_scope:
for subnet in subnets: for subnet in subnets:
# Do not build NAT rules for v6 # Do not build NAT rules for v6
if subnet.get('ip_version') == 6: if subnet.get('ip_version') == 6:
@ -3899,7 +3898,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
# no need for SNAT # no need for SNAT
subnet_address_scope = self._get_subnetpool_address_scope( subnet_address_scope = self._get_subnetpool_address_scope(
context.elevated(), subnet['subnetpool_id']) context.elevated(), subnet['subnetpool_id'])
if gw_address_scope == subnet_address_scope: if (gw_address_scope and
gw_address_scope == subnet_address_scope):
LOG.info("No need for SNAT rule for router %(router)s " LOG.info("No need for SNAT rule for router %(router)s "
"and subnet %(subnet)s because they use the " "and subnet %(subnet)s because they use the "
"same address scope %(addr_scope)s.", "same address scope %(addr_scope)s.",
@ -3907,7 +3907,6 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin,
'subnet': subnet['id'], 'subnet': subnet['id'],
'addr_scope': gw_address_scope}) 'addr_scope': gw_address_scope})
continue continue
snat.append(self._get_default_nat_rule( snat.append(self._get_default_nat_rule(
context, router['id'], subnet, snat_ip)) context, router['id'], subnet, snat_ip))
return (snat, dnat) return (snat, dnat)