Ignore extra subnet IPs in DHCP agent

When the DHCP agent requests a port from a server, it asks
for fixed IPs from specific subnets. However, if the server
is doing auto ipv6 addressing, it may give it an extra IP
it never asked for. The previous logic was not expecting this
so it would fail to correctly setup the DHCP port.

This patch just ignores any IPs on subnets the DHCP agent
isn't servicing.

Closes-Bug: #1618674
Change-Id: I1c26c85520258b751fa98eee326bc2acd2a16860
This commit is contained in:
Kevin Benton 2016-09-01 06:45:52 -07:00
parent 0eec50b12f
commit e5339b4a3d
2 changed files with 8 additions and 1 deletions

View File

@ -1272,7 +1272,10 @@ class DeviceManager(object):
fixed_ips = [dict(subnet_id=fixed_ip.subnet_id,
ip_address=fixed_ip.ip_address,
subnet=dhcp_subnets[fixed_ip.subnet_id])
for fixed_ip in dhcp_port.fixed_ips]
for fixed_ip in dhcp_port.fixed_ips
# we don't care about any ips on subnets irrelevant
# to us (e.g. auto ipv6 addresses)
if fixed_ip.subnet_id in dhcp_subnets]
ips = [DictModel(item) if isinstance(item, dict) else item
for item in fixed_ips]

View File

@ -2142,6 +2142,10 @@ class TestDeviceManager(TestConfBase):
'ip_address': 'unique-IP-address'})
for ip in port.fixed_ips
]
# server rudely gave us an extra address we didn't ask for
port.fixed_ips.append(dhcp.DictModel(
{'subnet_id': 'ffffffff-6666-6666-6666-ffffffffffff',
'ip_address': '2003::f816:3eff:fe45:e893'}))
return port
plugin.create_dhcp_port.side_effect = mock_create