summaryrefslogtreecommitdiff
path: root/src/conf_mode/dhcp_server.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2021-11-07 11:13:57 +0700
committerGitHub <noreply@github.com>2021-11-07 11:13:57 +0700
commit693638320db4493f7042363bc672e90d441155a7 (patch)
tree2752cc1a10e3c1c23d070d07da1a2a369b8820a7 /src/conf_mode/dhcp_server.py
parent25fea6d05b378792fde1effc757fc8922253251e (diff)
parentf7277650ffe04e863acdae3a52603ec54a4b730b (diff)
downloadvyos-1x-693638320db4493f7042363bc672e90d441155a7.tar.gz
vyos-1x-693638320db4493f7042363bc672e90d441155a7.zip
Merge pull request #1056 from sever-sever/T3626-crux
dhcp: T3626: Prevent to disable only one configured network
Diffstat (limited to 'src/conf_mode/dhcp_server.py')
-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' \