summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorNataliia Solomko <natalirs1985@gmail.com>2024-04-16 11:15:56 +0300
committerNataliia Solomko <natalirs1985@gmail.com>2024-04-16 11:15:56 +0300
commit82fdbedb79cf1c0a253657dfe7f23dee58c0dd47 (patch)
tree457f430babfa3aab6a2508720ab9bb0177583899 /src/conf_mode
parent0aabfbbbf5619a11c4a9d4a9eb4ed402ce62d51b (diff)
downloadvyos-1x-82fdbedb79cf1c0a253657dfe7f23dee58c0dd47.tar.gz
vyos-1x-82fdbedb79cf1c0a253657dfe7f23dee58c0dd47.zip
pppoe-server: T6141: T5364: PPPoE-server add pado-delay without sessions fails
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/service_pppoe-server.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/conf_mode/service_pppoe-server.py b/src/conf_mode/service_pppoe-server.py
index f6182f8ea..aeb8df7eb 100755
--- a/src/conf_mode/service_pppoe-server.py
+++ b/src/conf_mode/service_pppoe-server.py
@@ -33,6 +33,16 @@ airbag.enable()
pppoe_conf = r'/run/accel-pppd/pppoe.conf'
pppoe_chap_secrets = r'/run/accel-pppd/pppoe.chap-secrets'
+def convert_pado_delay(pado_delay):
+ new_pado_delay = {'delays_without_sessions': [],
+ 'delays_with_sessions': []}
+ for delay, sessions in pado_delay.items():
+ if not sessions:
+ new_pado_delay['delays_without_sessions'].append(delay)
+ else:
+ new_pado_delay['delays_with_sessions'].append((delay, int(sessions['sessions'])))
+ return new_pado_delay
+
def get_config(config=None):
if config:
conf = config
@@ -44,13 +54,30 @@ def get_config(config=None):
# retrieve common dictionary keys
pppoe = get_accel_dict(conf, base, pppoe_chap_secrets)
+
+ if dict_search('pado_delay', pppoe):
+ pado_delay = dict_search('pado_delay', pppoe)
+ pppoe['pado_delay'] = convert_pado_delay(pado_delay)
+
return pppoe
+def verify_pado_delay(pppoe):
+ if 'pado_delay' in pppoe:
+ pado_delay = pppoe['pado_delay']
+
+ delays_without_sessions = pado_delay['delays_without_sessions']
+ if len(delays_without_sessions) > 1:
+ raise ConfigError(
+ f'Cannot add more then ONE pado-delay without sessions, '
+ f'but {len(delays_without_sessions)} were set'
+ )
+
def verify(pppoe):
if not pppoe:
return None
verify_accel_ppp_base_service(pppoe)
+ verify_pado_delay(pppoe)
if 'wins_server' in pppoe and len(pppoe['wins_server']) > 2:
raise ConfigError('Not more then two IPv4 WINS name-servers can be configured')