From f7277650ffe04e863acdae3a52603ec54a4b730b Mon Sep 17 00:00:00 2001 From: Viacheslav Date: Sat, 30 Oct 2021 07:32:38 +0000 Subject: dhcp: T3626: Prevent to disable only one configured network --- src/conf_mode/dhcp_server.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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' \ -- cgit v1.2.3