]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
DHCP agent: allow using gateway IPs instead of uniquely allocated
authorNeil Jerram <Neil.Jerram@metaswitch.com>
Mon, 27 Jul 2015 13:41:29 +0000 (14:41 +0100)
committerNeil Jerram <Neil.Jerram@metaswitch.com>
Tue, 1 Sep 2015 22:46:15 +0000 (23:46 +0100)
commitf3f5940201a9e010c188f83aead7d93e7e8c9b6d
tree2d28e44675fa3a911e0d05c8bd5c96c169365be4
parent43d62c62a8525a1f2aa67b0ee201c09409fefa9a
DHCP agent: allow using gateway IPs instead of uniquely allocated

In each place where the DHCP agent runs, and for each subnet for which
DHCP is handing out IP addresses, the DHCP port needs - at the Linux
level - to have an IP address within that subnet.  Generally this
needs to be a unique Neutron-allocated IP address, because the
subnet's underlying L2 domain is bridged across multiple compute hosts
and network nodes, and for HA there may be multiple DHCP agents
running on that same bridged L2 domain.

However, if the DHCP ports - on multiple compute/network nodes but for
the same network - are _not_ bridged to each other, they do not need
each to have a unique IP address.  Instead they can all share the same
address from the relevant subnet.  This works, without creating any
ambiguity, because those ports are not all present on the same L2
domain, and because no data within the network is ever sent to that
address.  (DHCP requests are broadcast, and it is the network's job to
ensure that such a broadcast will reach at least one of the available
DHCP servers.  DHCP responses will be sent _from_ the DHCP port
address.)

Specifically, for some networking backends it makes sense to allow all
DHCP ports to use the subnet's gateway IP address, and thereby to
completely avoid any unique IP address allocation.

This change therefore enhances the DHCP agent code to be able to use
gateway IPs as an alternative to uniquely allocated ones, with the
choice between those being made by a new interface driver property,
'use_gateway_ips'.  The back-compatible default is to use unique IPs.
An interface driver that wants the DHCP agent to use gateway IPs can
achieve that by overriding as follows:

    @property
    def use_gateway_ips(self):
        return True

Partial-Bug: #1486649
Change-Id: I17e1dc9231a5ec35bd6f84c4c7aca6350d76e8ec
neutron/agent/linux/dhcp.py
neutron/agent/linux/interface.py
neutron/tests/unit/agent/dhcp/test_agent.py
neutron/tests/unit/agent/linux/test_dhcp.py