From 0ffaac1db23d916c7a73437b13fab56bb9f6b6da Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Mon, 8 Jun 2020 15:29:13 -0400 Subject: [PATCH] Use the correct value for the DHCP client port number Version 2.4.0 of neutron-lib has the DHCP port numbers correct, so start using them. Also updated other code in linux/dhcp.py to use the constants as well, instead of re-defining them. Closes-bug: #1882588 Change-Id: I5dc1d8e7bcc94efd1fab68d980d60e3130d5e5bc --- lower-constraints.txt | 2 +- neutron/agent/linux/dhcp.py | 14 +++++++------- neutron/tests/unit/agent/dhcp/test_agent.py | 2 +- requirements.txt | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lower-constraints.txt b/lower-constraints.txt index 0672190c3f9..7e44c136ec1 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -50,7 +50,7 @@ msgpack-python==0.4.0 munch==2.1.0 netaddr==0.7.18 netifaces==0.10.4 -neutron-lib==2.3.0 +neutron-lib==2.4.0 openstacksdk==0.31.2 os-client-config==1.28.0 os-ken==0.3.0 diff --git a/neutron/agent/linux/dhcp.py b/neutron/agent/linux/dhcp.py index 15d80289a5a..011f7bfedd4 100644 --- a/neutron/agent/linux/dhcp.py +++ b/neutron/agent/linux/dhcp.py @@ -45,11 +45,7 @@ from neutron.ipam import utils as ipam_utils LOG = logging.getLogger(__name__) -UDP = 'udp' -TCP = 'tcp' DNS_PORT = 53 -DHCPV4_PORT = 67 -DHCPV6_PORT = 547 METADATA_DEFAULT_IP = '169.254.169.254' METADATA_SUBNET_CIDR = '169.254.0.0/16' METADATA_PORT = 80 @@ -344,9 +340,13 @@ class Dnsmasq(DhcpLocalProcess): # on the Neutron port used for DHCP. These are provided as a convenience # for users of this class. PORTS = {constants.IP_VERSION_4: - [(UDP, DNS_PORT), (TCP, DNS_PORT), (UDP, DHCPV4_PORT)], + [(constants.PROTO_NAME_UDP, DNS_PORT), + (constants.PROTO_NAME_TCP, DNS_PORT), + (constants.PROTO_NAME_UDP, constants.DHCP_RESPONSE_PORT)], constants.IP_VERSION_6: - [(UDP, DNS_PORT), (TCP, DNS_PORT), (UDP, DHCPV6_PORT)], + [(constants.PROTO_NAME_UDP, DNS_PORT), + (constants.PROTO_NAME_TCP, DNS_PORT), + (constants.PROTO_NAME_UDP, constants.DHCPV6_RESPONSE_PORT)], } _SUBNET_TAG_PREFIX = 'subnet-%s' @@ -1742,7 +1742,7 @@ class DeviceManager(object): nat=False, namespace=namespace) ipv4_rule = ('-p udp -m udp --dport %d -j CHECKSUM --checksum-fill' - % constants.DHCP_RESPONSE_PORT) + % constants.DHCP_CLIENT_PORT) ipv6_rule = ('-p udp -m udp --dport %d -j CHECKSUM --checksum-fill' % constants.DHCPV6_CLIENT_PORT) iptables_mgr.ipv4['mangle'].add_rule('POSTROUTING', ipv4_rule) diff --git a/neutron/tests/unit/agent/dhcp/test_agent.py b/neutron/tests/unit/agent/dhcp/test_agent.py index 6b9b982b3a4..17a94264b58 100644 --- a/neutron/tests/unit/agent/dhcp/test_agent.py +++ b/neutron/tests/unit/agent/dhcp/test_agent.py @@ -1860,7 +1860,7 @@ class TestDeviceManager(base.BaseTestCase): def test_setup_calls_fill_dhcp_udp_checksums_v4(self): self._test_setup_helper(False) rule = ('-p udp -m udp --dport %d -j CHECKSUM --checksum-fill' - % const.DHCP_RESPONSE_PORT) + % const.DHCP_CLIENT_PORT) expected = [mock.call.add_rule('POSTROUTING', rule)] self.mangle_inst_v4.assert_has_calls(expected) diff --git a/requirements.txt b/requirements.txt index 1e53423d35e..2a3f4e9e596 100644 --- a/requirements.txt +++ b/requirements.txt @@ -16,7 +16,7 @@ Jinja2>=2.10 # BSD License (3 clause) keystonemiddleware>=4.17.0 # Apache-2.0 netaddr>=0.7.18 # BSD netifaces>=0.10.4 # MIT -neutron-lib>=2.3.0 # Apache-2.0 +neutron-lib>=2.4.0 # Apache-2.0 python-neutronclient>=6.7.0 # Apache-2.0 tenacity>=4.4.0 # Apache-2.0 SQLAlchemy>=1.2.0 # MIT