diff options
Diffstat (limited to 'python')
| -rw-r--r-- | python/vyos/ifconfig/ethernet.py | 5 | ||||
| -rw-r--r-- | python/vyos/qos/base.py | 50 | ||||
| -rw-r--r-- | python/vyos/utils/network.py | 2 | 
3 files changed, 38 insertions, 19 deletions
diff --git a/python/vyos/ifconfig/ethernet.py b/python/vyos/ifconfig/ethernet.py index aaf903acd..dde87149d 100644 --- a/python/vyos/ifconfig/ethernet.py +++ b/python/vyos/ifconfig/ethernet.py @@ -19,6 +19,7 @@ from glob import glob  from vyos.base import Warning  from vyos.ethtool import Ethtool +from vyos.ifconfig import Section  from vyos.ifconfig.interface import Interface  from vyos.utils.dict import dict_search  from vyos.utils.file import read_file @@ -128,6 +129,10 @@ class EthernetIf(Interface):              # will remain visible for the operating system.              self.set_admin_state('down') +        # Remove all VLAN subinterfaces - filter with the VLAN dot +        for vlan in [x for x in Section.interfaces(self.iftype) if x.startswith(f'{self.ifname}.')]: +            Interface(vlan).remove() +          super().remove()      def set_flow_control(self, enable): diff --git a/python/vyos/qos/base.py b/python/vyos/qos/base.py index d8bbfe970..a22039e52 100644 --- a/python/vyos/qos/base.py +++ b/python/vyos/qos/base.py @@ -1,4 +1,4 @@ -# Copyright 2022-2023 VyOS maintainers and contributors <maintainers@vyos.io> +# Copyright 2022-2024 VyOS maintainers and contributors <maintainers@vyos.io>  #  # This library is free software; you can redistribute it and/or  # modify it under the terms of the GNU Lesser General Public @@ -14,6 +14,7 @@  # License along with this library.  If not, see <http://www.gnu.org/licenses/>.  import os +import jmespath  from vyos.base import Warning  from vyos.utils.process import cmd @@ -166,14 +167,17 @@ class QoSBase:          }          if rate == 'auto' or rate.endswith('%'): -            speed = 10 +            speed = 1000 +            default_speed = speed              # 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)') +                    Warning('Interface speed cannot be determined (assuming 1000 Mbit/s)') +                if int(speed) < 1: +                    speed = default_speed                  if rate.endswith('%'):                      percent = rate.rstrip('%')                      speed = int(speed) * int(percent) // 100 @@ -223,6 +227,9 @@ class QoSBase:                          if 'mark' in match_config:                              mark = match_config['mark']                              filter_cmd += f' handle {mark} fw' +                        if 'vif' in match_config: +                            vif = match_config['vif'] +                            filter_cmd += f' basic match "meta(vlan mask 0xfff eq {vif})"'                          for af in ['ip', 'ipv6']:                              tc_af = af @@ -298,23 +305,28 @@ class QoSBase:                                  filter_cmd += f' flowid {self._parent:x}:{cls:x}'                                  self._cmd(filter_cmd) +                    vlan_expression = "match.*.vif" +                    match_vlan = jmespath.search(vlan_expression, cls_config) +                      if any(tmp in ['exceed', 'bandwidth', 'burst'] for tmp in cls_config): -                        filter_cmd += f' action police' - -                        if 'exceed' in cls_config: -                            action = cls_config['exceed'] -                            filter_cmd += f' conform-exceed {action}' -                        if 'not_exceed' in cls_config: -                            action = cls_config['not_exceed'] -                            filter_cmd += f'/{action}' - -                        if 'bandwidth' in cls_config: -                            rate = self._rate_convert(cls_config['bandwidth']) -                            filter_cmd += f' rate {rate}' - -                        if 'burst' in cls_config: -                            burst = cls_config['burst'] -                            filter_cmd += f' burst {burst}' +                        # For "vif" "basic match" is used instead of "action police" T5961 +                        if not match_vlan: +                            filter_cmd += f' action police' + +                            if 'exceed' in cls_config: +                                action = cls_config['exceed'] +                                filter_cmd += f' conform-exceed {action}' +                            if 'not_exceed' in cls_config: +                                action = cls_config['not_exceed'] +                                filter_cmd += f'/{action}' + +                            if 'bandwidth' in cls_config: +                                rate = self._rate_convert(cls_config['bandwidth']) +                                filter_cmd += f' rate {rate}' + +                            if 'burst' in cls_config: +                                burst = cls_config['burst'] +                                filter_cmd += f' burst {burst}'                          cls = int(cls)                          filter_cmd += f' flowid {self._parent:x}:{cls:x}'                          self._cmd(filter_cmd) diff --git a/python/vyos/utils/network.py b/python/vyos/utils/network.py index b782e0bd8..cac59475d 100644 --- a/python/vyos/utils/network.py +++ b/python/vyos/utils/network.py @@ -159,7 +159,9 @@ def is_wwan_connected(interface):      """ Determine if a given WWAN interface, e.g. wwan0 is connected to the      carrier network or not """      import json +    from vyos.utils.dict import dict_search      from vyos.utils.process import cmd +    from vyos.utils.process import is_systemd_service_active      if not interface.startswith('wwan'):          raise ValueError(f'Specified interface "{interface}" is not a WWAN interface')  | 
