summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/templates/accel-ppp/ipoe.config.j211
-rw-r--r--python/vyos/qos/base.py21
-rw-r--r--python/vyos/template.py14
3 files changed, 32 insertions, 14 deletions
diff --git a/data/templates/accel-ppp/ipoe.config.j2 b/data/templates/accel-ppp/ipoe.config.j2
index 99227ea33..2a2367b69 100644
--- a/data/templates/accel-ppp/ipoe.config.j2
+++ b/data/templates/accel-ppp/ipoe.config.j2
@@ -25,7 +25,7 @@ verbose=1
{% for iface, iface_config in interface.items() %}
{% set tmp = 'interface=' %}
{% if iface_config.vlan is vyos_defined %}
-{% set tmp = tmp ~ 're:' ~ iface ~ '\.\d+' %}
+{% set tmp = tmp ~ 're:^' ~ iface ~ '\.' ~ iface_config.vlan | range_to_regex ~ '$' %}
{% else %}
{% set tmp = tmp ~ iface %}
{% endif %}
@@ -36,6 +36,9 @@ verbose=1
{% set shared = 'shared=0,' %}
{% endif %}
{{ tmp }},{{ shared }}mode={{ iface_config.mode | upper }},ifcfg=1,range={{ iface_config.client_subnet }},start=dhcpv4,ipv6=1
+{% if iface_config.vlan is vyos_defined %}
+vlan-mon={{ iface }},{{ iface_config.vlan | join(',') }}
+{% endif %}
{% endfor %}
{% endif %}
{% if authentication.mode is vyos_defined('noauth') %}
@@ -54,12 +57,6 @@ password=csid
{% endif %}
proxy-arp=1
-{% for interface in interfaces %}
-{% if (interface.shared == '0') and (interface.vlan_mon) %}
-vlan-mon={{ interface.name }},{{ interface.vlan_mon | join(',') }}
-{% endif %}
-{% endfor %}
-
{% if client_ip_pool.name is vyos_defined %}
[ip-pool]
{% for pool, pool_options in client_ip_pool.name.items() %}
diff --git a/python/vyos/qos/base.py b/python/vyos/qos/base.py
index 378e11acf..33bb8ae28 100644
--- a/python/vyos/qos/base.py
+++ b/python/vyos/qos/base.py
@@ -121,13 +121,20 @@ class QoSBase:
}
if rate == 'auto' or rate.endswith('%'):
- speed = read_file(f'/sys/class/net/{self._interface}/speed')
- if not speed.isnumeric():
- Warning('Interface speed cannot be determined (assuming 10 Mbit/s)')
- speed = 10
- if rate.endswith('%'):
- percent = rate.rstrip('%')
- speed = int(speed) * int(percent) // 100
+ speed = 10
+ # Not all interfaces have valid entries in the speed file. PPPoE
+ # interfaces have the appropriate speed file, but you can not read it:
+ # cat: /sys/class/net/pppoe7/speed: Invalid argument
+ try:
+ speed = read_file(f'/sys/class/net/{self._interface}/speed')
+ if not speed.isnumeric():
+ Warning('Interface speed cannot be determined (assuming 10 Mbit/s)')
+ if rate.endswith('%'):
+ percent = rate.rstrip('%')
+ speed = int(speed) * int(percent) // 100
+ except:
+ pass
+
return int(speed) *1000000 # convert to MBit/s
rate_numeric = int(''.join([n for n in rate if n.isdigit()]))
diff --git a/python/vyos/template.py b/python/vyos/template.py
index 6367f51e5..7f417992e 100644
--- a/python/vyos/template.py
+++ b/python/vyos/template.py
@@ -663,7 +663,21 @@ def nat_static_rule(rule_conf, rule_id, nat_type):
@register_filter('range_to_regex')
def range_to_regex(num_range):
+ """Convert range of numbers or list of ranges
+ to regex
+
+ % range_to_regex('11-12')
+ '(1[1-2])'
+ % range_to_regex(['11-12', '14-15'])
+ '(1[1-2]|1[4-5])'
+ """
from vyos.range_regex import range_to_regex
+ if isinstance(num_range, list):
+ data = []
+ for entry in num_range:
+ data.append(range_to_regex(entry))
+ return f'({"|".join(data)})'
+
if '-' not in num_range:
return num_range