summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorSimon <965089+sarthurdev@users.noreply.github.com>2024-01-11 06:46:33 +0100
committerGitHub <noreply@github.com>2024-01-11 06:46:33 +0100
commitee494c3a1dbfca3457bcaffe89d45971348e4848 (patch)
tree4e29926fae96e8837e6b903fc46478a92e6890da /src/conf_mode
parent7c6cb9829356d07c3cfa865eff7f60c24d982d6e (diff)
downloadvyos-1x-ee494c3a1dbfca3457bcaffe89d45971348e4848.tar.gz
vyos-1x-ee494c3a1dbfca3457bcaffe89d45971348e4848.zip
dhcp: dhcpv6: T3316: Add `subnet-id` so leases remain mapped to entries in the lease file (#2796)
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/service_dhcp-server.py9
-rwxr-xr-xsrc/conf_mode/service_dhcpv6-server.py9
2 files changed, 18 insertions, 0 deletions
diff --git a/src/conf_mode/service_dhcp-server.py b/src/conf_mode/service_dhcp-server.py
index ceaba019e..2418c8faa 100755
--- a/src/conf_mode/service_dhcp-server.py
+++ b/src/conf_mode/service_dhcp-server.py
@@ -165,6 +165,7 @@ def verify(dhcp):
shared_networks = len(dhcp['shared_network_name'])
disabled_shared_networks = 0
+ subnet_ids = []
# A shared-network requires a subnet definition
for network, network_config in dhcp['shared_network_name'].items():
@@ -176,6 +177,14 @@ def verify(dhcp):
'lease subnet must be configured.')
for subnet, subnet_config in network_config['subnet'].items():
+ if 'subnet_id' not in subnet_config:
+ raise ConfigError(f'Unique subnet ID not specified for subnet "{subnet}"')
+
+ if subnet_config['subnet_id'] in subnet_ids:
+ raise ConfigError(f'Subnet ID for subnet "{subnet}" is not unique')
+
+ subnet_ids.append(subnet_config['subnet_id'])
+
# All delivered static routes require a next-hop to be set
if 'static_route' in subnet_config:
for route, route_option in subnet_config['static_route'].items():
diff --git a/src/conf_mode/service_dhcpv6-server.py b/src/conf_mode/service_dhcpv6-server.py
index 9cc57dbcf..7cd801cdd 100755
--- a/src/conf_mode/service_dhcpv6-server.py
+++ b/src/conf_mode/service_dhcpv6-server.py
@@ -63,6 +63,7 @@ def verify(dhcpv6):
# Inspect shared-network/subnet
subnets = []
+ subnet_ids = []
listen_ok = False
for network, network_config in dhcpv6['shared_network_name'].items():
# A shared-network requires a subnet definition
@@ -72,6 +73,14 @@ def verify(dhcpv6):
'each shared network!')
for subnet, subnet_config in network_config['subnet'].items():
+ if 'subnet_id' not in subnet_config:
+ raise ConfigError(f'Unique subnet ID not specified for subnet "{subnet}"')
+
+ if subnet_config['subnet_id'] in subnet_ids:
+ raise ConfigError(f'Subnet ID for subnet "{subnet}" is not unique')
+
+ subnet_ids.append(subnet_config['subnet_id'])
+
if 'address_range' in subnet_config:
if 'start' in subnet_config['address_range']:
range6_start = []