]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Prevent an iteration through ports on IPv6 slaac
authorKevin Benton <blak111@gmail.com>
Tue, 18 Nov 2014 16:34:56 +0000 (08:34 -0800)
committerKevin Benton <blak111@gmail.com>
Tue, 18 Nov 2014 16:39:30 +0000 (08:39 -0800)
A recent change[1] allowed subnets to be deleted even if they
had active IPv6 SLAAC allocations on them. The updated check
was inefficient because it would check every port in the subnet
even if the subnet was a SLAAC subnet. This patch just shortcuts
out that check.

1. I281f5a1553248e09174dc49d0a42aef4b5c44bee

Change-Id: I2c35495b3642c644e4758f28ccddcc076139ec3b

neutron/plugins/ml2/plugin.py

index 09c6e95239b76675205696ecd055043e36964b2b..7572c4a43aaf1a3c3d48a49239525fd940ff4f33 100644 (file)
@@ -728,11 +728,9 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
                              filter_by(network_id=subnet['network_id']).
                              with_lockmode('update').all())
                 LOG.debug(_("Ports to auto-deallocate: %s"), allocated)
-                only_auto_del = all(not a.port_id or
-                                    a.ports.device_owner in db_base_plugin_v2.
-                                    AUTO_DELETE_PORT_OWNERS or
-                                    ipv6_utils.is_slaac_subnet(subnet)
-                                    for a in allocated)
+                only_auto_del = ipv6_utils.is_slaac_subnet(subnet) or all(
+                    not a.port_id or a.ports.device_owner in db_base_plugin_v2.
+                    AUTO_DELETE_PORT_OWNERS for a in allocated)
                 if not only_auto_del:
                     LOG.debug(_("Tenant-owned ports exist"))
                     raise exc.SubnetInUse(subnet_id=id)