Allow to configure DHCP T1 and T2 timers in dnsmasq
This patch introduces two new options for dnsmasq in neutron-dhcp-agent: * dhcp_renewal_time (T1): This option specifies the time interval from address assignment until the client transitions to the RENEWING state. * dhcp_rebinding_time (T2): This option specifies the time interval from address assignment until the client transitions to the REBINDING state. By allowing to set these timers we can configure both the renewal and rebinding times (options 58 and 59 as per RFC2132) and, for example allow to change some parameters (like MTU) on instances without having to wait or the lease time. The advantage of changing T1 over the lease time is that if the DHCP server becomes unreachable within the lease time, instances won't drop their IP addresses and won't cause a dataplane disruption. Change-Id: I29d417d459e92f36c1077962b92fa4c43dfaa97d Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
This commit is contained in:
parent
d2bf790a44
commit
9b809126a2
@ -403,6 +403,14 @@ class Dnsmasq(DhcpLocalProcess):
|
||||
cmd.append('--dhcp-lease-max=%d' %
|
||||
min(possible_leases, self.conf.dnsmasq_lease_max))
|
||||
|
||||
if self.conf.dhcp_renewal_time > 0:
|
||||
cmd.append('--dhcp-option-force=option:T1,%ds' %
|
||||
self.conf.dhcp_renewal_time)
|
||||
|
||||
if self.conf.dhcp_rebinding_time > 0:
|
||||
cmd.append('--dhcp-option-force=option:T2,%ds' %
|
||||
self.conf.dhcp_rebinding_time)
|
||||
|
||||
cmd.append('--conf-file=%s' % self.conf.dnsmasq_config_file)
|
||||
for server in self.conf.dnsmasq_dns_servers:
|
||||
cmd.append('--server=%s' % server)
|
||||
|
@ -94,6 +94,12 @@ DNSMASQ_OPTS = [
|
||||
help=_('Limit number of leases to prevent a denial-of-service.')),
|
||||
cfg.BoolOpt('dhcp_broadcast_reply', default=False,
|
||||
help=_("Use broadcast in DHCP replies.")),
|
||||
cfg.IntOpt('dhcp_renewal_time', default=0,
|
||||
help=_("DHCP renewal time T1 (in seconds). If set to 0, it "
|
||||
"will default to half of the lease time.")),
|
||||
cfg.IntOpt('dhcp_rebinding_time', default=0,
|
||||
help=_("DHCP rebinding time T2 (in seconds). If set to 0, it "
|
||||
"will default to 7/8 of the lease time.")),
|
||||
]
|
||||
|
||||
|
||||
|
@ -1173,7 +1173,7 @@ class TestDnsmasq(TestBase):
|
||||
def _test_spawn(self, extra_options, network=FakeDualNetwork(),
|
||||
max_leases=16777216, lease_duration=86400,
|
||||
has_static=True, no_resolv='--no-resolv',
|
||||
has_stateless=True):
|
||||
has_stateless=True, dhcp_t1=0, dhcp_t2=0):
|
||||
def mock_get_conf_file_name(kind):
|
||||
return '/dhcp/%s/%s' % (network.id, kind)
|
||||
|
||||
@ -1230,6 +1230,11 @@ class TestDnsmasq(TestBase):
|
||||
|
||||
expected.append('--dhcp-lease-max=%d' % min(
|
||||
possible_leases, max_leases))
|
||||
|
||||
if dhcp_t1:
|
||||
expected.append('--dhcp-option-force=option:T1,%ds' % dhcp_t1)
|
||||
if dhcp_t2:
|
||||
expected.append('--dhcp-option-force=option:T2,%ds' % dhcp_t2)
|
||||
expected.extend(extra_options)
|
||||
|
||||
self.execute.return_value = ('', '')
|
||||
@ -1361,6 +1366,12 @@ class TestDnsmasq(TestBase):
|
||||
self._test_spawn(['--conf-file=', '--domain=openstacklocal'],
|
||||
network)
|
||||
|
||||
def test_spawn_cfg_with_dhcp_timers(self):
|
||||
self.conf.set_override('dhcp_renewal_time', 30)
|
||||
self.conf.set_override('dhcp_rebinding_time', 100)
|
||||
self._test_spawn(['--conf-file=', '--domain=openstacklocal'],
|
||||
dhcp_t1=30, dhcp_t2=100)
|
||||
|
||||
def _test_output_init_lease_file(self, timestamp):
|
||||
expected = [
|
||||
'00:00:80:aa:bb:cc 192.168.0.2 * *',
|
||||
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Allow configuration of DHCP renewal (T1) and rebinding (T2) timers in
|
||||
``neutron-dhcp-agent``. By allowing these timers to be set (options 58
|
||||
and 59 as per RFC2132) in ``dnsmasq`` it allows users to change
|
||||
other parameters, like MTU, on instances without having to wait for
|
||||
the lease time to expire. The advantage of changing T1 over the
|
||||
lease time is that if the DHCP server becomes unreachable within
|
||||
the lease time, instances will not drop their IP addresses and it
|
||||
will not cause a dataplane disruption.
|
Loading…
Reference in New Issue
Block a user