]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Calculate nicira plugin NAT rules order according to CIDR prefix
authorSalvatore Orlando <salv.orlando@gmail.com>
Mon, 6 May 2013 15:13:15 +0000 (17:13 +0200)
committerSalvatore Orlando <salv.orlando@gmail.com>
Mon, 6 May 2013 23:11:03 +0000 (01:11 +0200)
Bug 1176947

Change-Id: Ibe81b9905cacea51d954416588f5c50d6337bbb0

quantum/plugins/nicira/QuantumPlugin.py

index 52879c2a21069632096548d88037eb2a96939069..b451bca6b027b4c488f4db490218b8306297f245 100644 (file)
@@ -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,