summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-10-21 19:56:32 +0200
committerGitHub <noreply@github.com>2021-10-21 19:56:32 +0200
commit479ac2b4cc311a23dbdf2e0867a51cccf99b198a (patch)
tree0698965779203157a123091360c5f3074a055fb2
parent103fca9f77c28e392146f791e0241e119feeadc9 (diff)
parent9c825a3457a88a4eebc6475f92332822e5102889 (diff)
downloadvyos-1x-479ac2b4cc311a23dbdf2e0867a51cccf99b198a.tar.gz
vyos-1x-479ac2b4cc311a23dbdf2e0867a51cccf99b198a.zip
Merge pull request #1035 from sever-sever/T3626
dhcp: T3626: Prevent to disable only one configured network
-rwxr-xr-xsrc/conf_mode/dhcp_server.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py
index 28f2a4ca5..71b71879c 100755
--- a/src/conf_mode/dhcp_server.py
+++ b/src/conf_mode/dhcp_server.py
@@ -151,9 +151,15 @@ def verify(dhcp):
listen_ok = False
subnets = []
failover_ok = False
+ shared_networks = len(dhcp['shared_network_name'])
+ disabled_shared_networks = 0
+
# A shared-network requires a subnet definition
for network, network_config in dhcp['shared_network_name'].items():
+ if 'disable' in network_config:
+ disabled_shared_networks += 1
+
if 'subnet' not in network_config:
raise ConfigError(f'No subnets defined for {network}. At least one\n' \
'lease subnet must be configured.')
@@ -243,6 +249,10 @@ def verify(dhcp):
if net.overlaps(net2):
raise ConfigError('Conflicting subnet ranges: "{net}" overlaps "{net2}"!')
+ # Prevent 'disable' for shared-network if only one network is configured
+ if (shared_networks - disabled_shared_networks) < 1:
+ raise ConfigError(f'At least one shared network must be active!')
+
if 'failover' in dhcp:
if not failover_ok:
raise ConfigError('DHCP failover must be enabled for at least one subnet!')