summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViacheslav <v.gletenko@vyos.io>2021-10-30 07:32:38 +0000
committerViacheslav <v.gletenko@vyos.io>2021-10-30 07:32:38 +0000
commitf7277650ffe04e863acdae3a52603ec54a4b730b (patch)
tree2752cc1a10e3c1c23d070d07da1a2a369b8820a7
parent25fea6d05b378792fde1effc757fc8922253251e (diff)
downloadvyos-1x-f7277650ffe04e863acdae3a52603ec54a4b730b.tar.gz
vyos-1x-f7277650ffe04e863acdae3a52603ec54a4b730b.zip
dhcp: T3626: Prevent to disable only one configured network
-rwxr-xr-xsrc/conf_mode/dhcp_server.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/conf_mode/dhcp_server.py b/src/conf_mode/dhcp_server.py
index 485b25e4c..fc8855f9f 100755
--- a/src/conf_mode/dhcp_server.py
+++ b/src/conf_mode/dhcp_server.py
@@ -664,9 +664,14 @@ def verify(dhcp):
failover_names = []
listen_ok = False
subnets = []
+ shared_networks = len(dhcp['shared_network'])
+ disabled_shared_networks = 0
# A shared-network requires a subnet definition
for network in dhcp['shared_network']:
+ if network['disabled']:
+ disabled_shared_networks += 1
+
if len(network['subnet']) == 0:
raise ConfigError('No DHCP lease subnets configured for {0}. At least one\n' \
'lease subnet must be configured for each shared network.'.format(network['name']))
@@ -793,6 +798,10 @@ def verify(dhcp):
if net.overlaps(net2):
raise ConfigError('DHCP conflicting subnet ranges: {0} overlaps {1}'.format(net, net2))
+ # Prevent 'disable' for shared-network if only one network is configured
+ if (shared_networks - disabled_shared_networks) < 1:
+ raise ConfigError('At least one shared network must be active!')
+
if not listen_ok:
raise ConfigError('DHCP server configuration error!\n' \
'None of configured DHCP subnets does not have appropriate\n' \