ml2: gre, vxlan type driver can leak segment_id
When multiple region of segment_id is specified, segment_id can leak (will be never reused) on deletion of network. Change-Id: Ia27b7e2c0ff4ab58be304e54123a679a5e35ab00 Closes-Bug: #1260262
This commit is contained in:
parent
dbd6d45457
commit
4808f91eb2
@ -174,3 +174,34 @@ class GreTypeTest(base.BaseTestCase):
|
||||
for endpoint in endpoints:
|
||||
self.assertIn(endpoint['ip_address'],
|
||||
[TUNNEL_IP_ONE, TUNNEL_IP_TWO])
|
||||
|
||||
|
||||
class GreTypeMultiRangeTest(base.BaseTestCase):
|
||||
|
||||
TUN_MIN0 = 100
|
||||
TUN_MAX0 = 101
|
||||
TUN_MIN1 = 200
|
||||
TUN_MAX1 = 201
|
||||
TUNNEL_MULTI_RANGES = [(TUN_MIN0, TUN_MAX0), (TUN_MIN1, TUN_MAX1)]
|
||||
|
||||
def setUp(self):
|
||||
super(GreTypeMultiRangeTest, self).setUp()
|
||||
ml2_db.initialize()
|
||||
self.driver = type_gre.GreTypeDriver()
|
||||
self.driver.gre_id_ranges = self.TUNNEL_MULTI_RANGES
|
||||
self.driver._sync_gre_allocations()
|
||||
self.session = db.get_session()
|
||||
self.addCleanup(db.clear_db)
|
||||
|
||||
def test_release_segment(self):
|
||||
segments = [self.driver.allocate_tenant_segment(self.session)
|
||||
for i in range(4)]
|
||||
|
||||
# Release them in random order. No special meaning.
|
||||
for i in (0, 2, 1, 3):
|
||||
self.driver.release_segment(self.session, segments[i])
|
||||
|
||||
for key in (self.TUN_MIN0, self.TUN_MAX0,
|
||||
self.TUN_MIN1, self.TUN_MAX1):
|
||||
alloc = self.driver.get_gre_allocation(self.session, key)
|
||||
self.assertFalse(alloc.allocated)
|
||||
|
@ -194,3 +194,35 @@ class VxlanTypeTest(base.BaseTestCase):
|
||||
self.assertEqual(VXLAN_UDP_PORT_ONE, endpoint['udp_port'])
|
||||
elif endpoint['ip_address'] == TUNNEL_IP_TWO:
|
||||
self.assertEqual(VXLAN_UDP_PORT_TWO, endpoint['udp_port'])
|
||||
|
||||
|
||||
class VxlanTypeMultiRangeTest(base.BaseTestCase):
|
||||
|
||||
TUN_MIN0 = 100
|
||||
TUN_MAX0 = 101
|
||||
TUN_MIN1 = 200
|
||||
TUN_MAX1 = 201
|
||||
TUNNEL_MULTI_RANGES = [(TUN_MIN0, TUN_MAX0), (TUN_MIN1, TUN_MAX1)]
|
||||
|
||||
def setUp(self):
|
||||
super(VxlanTypeMultiRangeTest, self).setUp()
|
||||
ml2_db.initialize()
|
||||
self.driver = type_vxlan.VxlanTypeDriver()
|
||||
self.driver.vxlan_vni_ranges = self.TUNNEL_MULTI_RANGES
|
||||
self.driver._sync_vxlan_allocations()
|
||||
self.session = db.get_session()
|
||||
self.addCleanup(cfg.CONF.reset)
|
||||
self.addCleanup(db.clear_db)
|
||||
|
||||
def test_release_segment(self):
|
||||
segments = [self.driver.allocate_tenant_segment(self.session)
|
||||
for i in range(4)]
|
||||
|
||||
# Release them in random order. No special meaning.
|
||||
for i in (0, 2, 1, 3):
|
||||
self.driver.release_segment(self.session, segments[i])
|
||||
|
||||
for key in (self.TUN_MIN0, self.TUN_MAX0,
|
||||
self.TUN_MIN1, self.TUN_MAX1):
|
||||
alloc = self.driver.get_vxlan_allocation(self.session, key)
|
||||
self.assertFalse(alloc.allocated)
|
||||
|
Loading…
Reference in New Issue
Block a user