summaryrefslogtreecommitdiff
path: root/src/conf_mode
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@vyos.io>2021-12-08 01:55:10 +0700
committerGitHub <noreply@github.com>2021-12-08 01:55:10 +0700
commit7ac6b589e3827ea6ff8e796bb6617c021cf26bca (patch)
tree52a82a471ab87e35625dd139197035bf69e8751e /src/conf_mode
parent7af98b0bb9190f37b5d27da6ffc8343a7138106b (diff)
parent3b6504d4bfc8a7f19613ee32fef5242711ca390a (diff)
downloadvyos-1x-7ac6b589e3827ea6ff8e796bb6617c021cf26bca.tar.gz
vyos-1x-7ac6b589e3827ea6ff8e796bb6617c021cf26bca.zip
Merge pull request #1100 from DmitriyEshenko/sg-1x-03122021-02
pppoe-server: T3006: Add range to regex generator
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-xsrc/conf_mode/service_pppoe-server.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/conf_mode/service_pppoe-server.py b/src/conf_mode/service_pppoe-server.py
index 9fbd531da..1f31d132d 100755
--- a/src/conf_mode/service_pppoe-server.py
+++ b/src/conf_mode/service_pppoe-server.py
@@ -24,8 +24,11 @@ from vyos.configverify import verify_accel_ppp_base_service
from vyos.template import render
from vyos.util import call
from vyos.util import dict_search
+from vyos.util import get_interface_config
from vyos import ConfigError
from vyos import airbag
+from vyos.range_regex import range_to_regex
+
airbag.enable()
pppoe_conf = r'/run/accel-pppd/pppoe.conf'
@@ -56,6 +59,11 @@ def verify(pppoe):
if 'interface' not in pppoe:
raise ConfigError('At least one listen interface must be defined!')
+ # Check is interface exists in the system
+ for iface in pppoe['interface']:
+ if not get_interface_config(iface):
+ raise ConfigError(f'Interface {iface} does not exist!')
+
# local ippool and gateway settings config checks
if not (dict_search('client_ip_pool.subnet', pppoe) or
(dict_search('client_ip_pool.start', pppoe) and
@@ -73,6 +81,13 @@ def generate(pppoe):
if not pppoe:
return None
+ # Generate special regex for dynamic interfaces
+ for iface in pppoe['interface']:
+ if 'vlan_range' in pppoe['interface'][iface]:
+ pppoe['interface'][iface]['regex'] = []
+ for vlan_range in pppoe['interface'][iface]['vlan_range']:
+ pppoe['interface'][iface]['regex'].append(range_to_regex(vlan_range))
+
render(pppoe_conf, 'accel-ppp/pppoe.config.tmpl', pppoe)
if dict_search('authentication.mode', pppoe) == 'local':