From 6acbc0520422ab08e87caf7e7ac0f1ebe7683823 Mon Sep 17 00:00:00 2001 From: Salvatore Orlando Date: Mon, 6 May 2013 17:13:15 +0200 Subject: [PATCH] Calculate nicira plugin NAT rules order according to CIDR prefix Bug 1176947 Change-Id: Ibe81b9905cacea51d954416588f5c50d6337bbb0 --- quantum/plugins/nicira/QuantumPlugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/quantum/plugins/nicira/QuantumPlugin.py b/quantum/plugins/nicira/QuantumPlugin.py index 52879c2a2..b451bca6b 100644 --- a/quantum/plugins/nicira/QuantumPlugin.py +++ b/quantum/plugins/nicira/QuantumPlugin.py @@ -68,7 +68,7 @@ from quantum import policy LOG = logging.getLogger("QuantumPlugin") NVP_NOSNAT_RULES_ORDER = 10 -NVP_FLOATINGIP_NAT_RULES_ORDER = 200 +NVP_FLOATINGIP_NAT_RULES_ORDER = 224 NVP_EXTGW_NAT_RULES_ORDER = 255 @@ -524,11 +524,12 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2, lr_port['uuid']) # Set the SNAT rule for each subnet (only first IP) for cidr in self._find_router_subnets_cidrs(context, router_id): + cidr_prefix = int(cidr.split('/')[1]) nvplib.create_lrouter_snat_rule( self.cluster, router_id, ip_addresses[0].split('/')[0], ip_addresses[0].split('/')[0], - order=NVP_EXTGW_NAT_RULES_ORDER, + order=NVP_EXTGW_NAT_RULES_ORDER - cidr_prefix, match_criteria={'source_ip_addresses': cidr}) LOG.debug(_("_nvp_create_ext_gw_port completed on external network " @@ -1591,9 +1592,11 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2, # In that case we will consider only the first one if gw_port.get('fixed_ips'): snat_ip = gw_port['fixed_ips'][0]['ip_address'] + subnet = self._get_subnet(context, subnet_id) + cidr_prefix = int(subnet['cidr'].split('/')[1]) nvplib.create_lrouter_snat_rule( self.cluster, router_id, snat_ip, snat_ip, - order=NVP_EXTGW_NAT_RULES_ORDER, + order=NVP_EXTGW_NAT_RULES_ORDER - cidr_prefix, match_criteria={'source_ip_addresses': subnet['cidr']}) nvplib.create_lrouter_nosnat_rule( self.cluster, router_id, -- 2.45.2