neutron/neutron/cmd/runtime_checks.py
Harald Jensås 38afccc28a Use dhcp-host tag support when supported
In dnsmasq 2.81 there is a regression (see [1] for details).
Prior versions of dnsmasq would select a host record where:
a) no address is present in the host record.
b) an address matching address family of the client request
   is present in the host record.

dnsmasq 2.81 will also use a host record where a only an address
not matching the address family of the client request is present.

The same issue is also backported to the dnsmasq-2.79-11.el8.x86_64
which is e.g. in RHEL 8.2 and Centos 8.

dnsmasq version 2.81 also adds support for using tag's on host
records. When a dhcpv6 request is received, dnsmasq automatically
sets the tag 'dhcpv6'.

This change adds a runtime check, testing for dnsmasq host entry
tag support. And adds 'tag:dhcpv6' to all IPv6 host records when
dnsmasq supports this.

Adding the tag makes dnsmasq prefer the tagged host for dhcpv6
requests, i.e it's a workaround fix for the regression issue.

[1] http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/2020q2/014051.html

Closes-Bug: #1876094
Change-Id: Ie654c84137914226bdc3e31e16219345c2efaac9
(cherry picked from commit f951871430)
2020-05-07 10:11:09 +00:00

49 lines
1.6 KiB
Python

# Copyright (c) 2014 OpenStack Foundation.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from neutron_lib import exceptions
from oslo_log import log as logging
from neutron.agent.linux import utils as agent_utils
LOG = logging.getLogger(__name__)
# NOTE: Runtime checks are strongly discouraged in favor of sanity checks
# which would be run at system setup time. Please consider writing a
# sanity check instead.
def dhcp_release6_supported():
try:
cmd = ['dhcp_release6', '--help']
env = {'LC_ALL': 'C'}
agent_utils.execute(cmd, addl_env=env)
except (OSError, RuntimeError, IndexError, ValueError) as e:
LOG.debug("Exception while checking dhcp_release6. "
"Exception: %s", e)
return False
return True
def dnsmasq_host_tag_support():
cmd = ['dnsmasq', '--test', '--dhcp-host=tag:foo']
env = {'LC_ALL': 'C', 'PATH': '/sbin:/usr/sbin'}
try:
agent_utils.execute(cmd, addl_env=env, log_fail_as_error=False)
except exceptions.ProcessExecutionError:
return False
return True