From 51a6eaa324775049ee666503ca0a63571750ac25 Mon Sep 17 00:00:00 2001 From: Lucas Christian Date: Sun, 4 Oct 2020 17:50:53 -0500 Subject: dhcpv6: T2961: support stateless dhcpv6 clients This commit adds support for configuring the DHCPv6 server to serve "stateless" DHCPv6 clients (those that send an information-request message and do not request an address). The change introduces a `common-options` node at the `shared-network-name` level, which allows specifying options applicable to clients regardless of subnet assigned (or in the case of stateless clients, when no subnet is assigned). Parameters specified at the subnet level take precedence over those set at the shared-network level. Presently, only parameters that are meaningful to stateless clients have been exposed under `common-options`, as there is no precedent of exposing parameters at multiple levels under the current DHCPv4 or DHCPv6 configuration syntax. If desired, additional parameters could certainly be added with relative ease. --- data/templates/dhcpv6-server/dhcpdv6.conf.tmpl | 9 ++++++ interface-definitions/dhcpv6-server.xml.in | 42 ++++++++++++++++++++++++++ src/conf_mode/dhcpv6_server.py | 26 ++++++++++++++++ 3 files changed, 77 insertions(+) diff --git a/data/templates/dhcpv6-server/dhcpdv6.conf.tmpl b/data/templates/dhcpv6-server/dhcpdv6.conf.tmpl index ff7822b0d..bdeea71da 100644 --- a/data/templates/dhcpv6-server/dhcpdv6.conf.tmpl +++ b/data/templates/dhcpv6-server/dhcpdv6.conf.tmpl @@ -12,6 +12,15 @@ option dhcp6.preference {{ preference }}; {% for network in shared_network %} {%- if not network.disabled -%} shared-network {{ network.name }} { + {%- if network.common.info_refresh_time %} + option dhcp6.info-refresh-time {{ network.common.info_refresh_time }}; + {%- endif %} + {%- if network.common.domain_search %} + option dhcp6.domain-search "{{ network.common.domain_search | join('", "') }}"; + {%- endif %} + {%- if network.common.dns_server %} + option dhcp6.name-servers {{ network.common.dns_server | join(', ') }}; + {%- endif %} {%- for subnet in network.subnet %} subnet6 {{ subnet.network }} { {%- for range in subnet.range6_prefix %} diff --git a/interface-definitions/dhcpv6-server.xml.in b/interface-definitions/dhcpv6-server.xml.in index 4073b46b2..acc33d40f 100644 --- a/interface-definitions/dhcpv6-server.xml.in +++ b/interface-definitions/dhcpv6-server.xml.in @@ -43,6 +43,48 @@ + + + Common options to distribute to all clients, including stateless clients + + + + + Time (in seconds) that stateless clients should wait between refreshing the information they were given + + 1-4294967295 + DHCPv6 information refresh time + + + + + + + + + Domain name for client to search + + [-_a-zA-Z0-9.]+ + + Invalid domain name. May only contain letters, numbers and .-_ + + + + + + IPv6 address of a Recursive DNS Server + + ipv6 + IPv6 address of DNS name server + + + + + + + + + IPv6 DHCP subnet for this shared network [REQUIRED] diff --git a/src/conf_mode/dhcpv6_server.py b/src/conf_mode/dhcpv6_server.py index 4ce4cada1..1777d4db7 100755 --- a/src/conf_mode/dhcpv6_server.py +++ b/src/conf_mode/dhcpv6_server.py @@ -65,6 +65,7 @@ def get_config(config=None): config = { 'name': network, 'disabled': False, + 'common': {}, 'subnet': [] } @@ -72,6 +73,31 @@ def get_config(config=None): if conf.exists(['disable']): config['disabled'] = True + # Common options shared among subnets. These can be overridden if + # the same option is specified on a per-subnet or per-host + # basis. These are the only options that can be handed out to + # stateless clients via an information-request message. + if conf.exists(['common-options']): + conf.set_level(base + ['shared-network-name', network, 'common-options']) + + # How often stateless clients should refresh their information. This is + # mostly taken as a hint by clients, and only if they request it. + # (if not specified, the server does not supply this to the client) + if conf.exists(['info-refresh-time']): + config['common']['info_refresh_time'] = conf.return_value(['info-refresh-time']) + + # The domain-search option specifies a 'search list' of Domain Names to be used + # by the client to locate not-fully-qualified domain names. + if conf.exists(['domain-search']): + config['common']['domain_search'] = conf.return_values(['domain-search']) + + # Specifies a list of Domain Name System name servers available to the client. + # Servers should be listed in order of preference. + if conf.exists(['name-server']): + config['common']['dns_server'] = conf.return_values(['name-server']) + + conf.set_level(base + ['shared-network-name', network]) + # check for multiple subnet configurations in a shared network if conf.exists(['subnet']): for net in conf.list_nodes(['subnet']): -- cgit v1.2.3