summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2023-07-01 12:38:26 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2023-07-01 12:38:26 +0000
commite3361366038fb0acb8c00d54ac30fb9b95debf52 (patch)
treed7fb6ab3e5612651ef231dd0d7dfd23d1e37a3d7 /python/vyos
parent55d6c5749e85fe6d4b771bcdf09fffdd6d6ecb92 (diff)
downloadvyos-1x-e3361366038fb0acb8c00d54ac30fb9b95debf52.tar.gz
vyos-1x-e3361366038fb0acb8c00d54ac30fb9b95debf52.zip
T5295: QoS fix policy limiter tc filter rate limit
tc filter rate limit should be used only if qostype is 'limiter' and not 'shaper'
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/qos/base.py78
-rw-r--r--python/vyos/qos/limiter.py1
2 files changed, 38 insertions, 41 deletions
diff --git a/python/vyos/qos/base.py b/python/vyos/qos/base.py
index 26ec65535..226773c4f 100644
--- a/python/vyos/qos/base.py
+++ b/python/vyos/qos/base.py
@@ -61,6 +61,7 @@ class QoSBase:
"CS7": 0xE0,
"EF": 0xB8
}
+ qostype = None
def __init__(self, interface):
if os.path.exists('/tmp/vyos.qos.debug'):
@@ -322,44 +323,39 @@ class QoSBase:
filter_cmd += f' flowid {self._parent:x}:{cls:x}'
self._cmd(filter_cmd)
- # T5295: Do not do any tc filter action for 'default'
- # In VyOS 1.4, we have the following configuration:
- # tc filter replace dev eth0 parent 1: prio 255 protocol all basic action police rate 300000000 burst 15k
- # However, this caused unexpected random speeds.
- # In VyOS 1.3, we do not use any 'tc filter' for rate limits,
- # It gets rate from tc class classid 1:1
- #
- # if 'default' in config:
- # if 'class' in config:
- # class_id_max = self._get_class_max_id(config)
- # default_cls_id = int(class_id_max) +1
- # self._build_base_qdisc(config['default'], default_cls_id)
- #
- # filter_cmd = f'tc filter replace dev {self._interface} parent {self._parent:x}: '
- # filter_cmd += 'prio 255 protocol all basic'
- #
- # # The police block allows limiting of the byte or packet rate of
- # # traffic matched by the filter it is attached to.
- # # https://man7.org/linux/man-pages/man8/tc-police.8.html
- # if any(tmp in ['exceed', 'bandwidth', 'burst'] for tmp in config['default']):
- # filter_cmd += f' action police'
- #
- # if 'exceed' in config['default']:
- # action = config['default']['exceed']
- # filter_cmd += f' conform-exceed {action}'
- # if 'not_exceed' in config['default']:
- # action = config['default']['not_exceed']
- # filter_cmd += f'/{action}'
- #
- # if 'bandwidth' in config['default']:
- # rate = self._rate_convert(config['default']['bandwidth'])
- # filter_cmd += f' rate {rate}'
- #
- # if 'burst' in config['default']:
- # burst = config['default']['burst']
- # filter_cmd += f' burst {burst}'
- #
- # if 'class' in config:
- # filter_cmd += f' flowid {self._parent:x}:{default_cls_id:x}'
- #
- # self._cmd(filter_cmd)
+ if self.qostype == 'limiter':
+ if 'default' in config:
+ if 'class' in config:
+ class_id_max = self._get_class_max_id(config)
+ default_cls_id = int(class_id_max) + 1
+ self._build_base_qdisc(config['default'], default_cls_id)
+
+ filter_cmd = f'tc filter replace dev {self._interface} parent {self._parent:x}: '
+ filter_cmd += 'prio 255 protocol all basic'
+
+ # The police block allows limiting of the byte or packet rate of
+ # traffic matched by the filter it is attached to.
+ # https://man7.org/linux/man-pages/man8/tc-police.8.html
+ if any(tmp in ['exceed', 'bandwidth', 'burst'] for tmp in
+ config['default']):
+ filter_cmd += f' action police'
+
+ if 'exceed' in config['default']:
+ action = config['default']['exceed']
+ filter_cmd += f' conform-exceed {action}'
+ if 'not_exceed' in config['default']:
+ action = config['default']['not_exceed']
+ filter_cmd += f'/{action}'
+
+ if 'bandwidth' in config['default']:
+ rate = self._rate_convert(config['default']['bandwidth'])
+ filter_cmd += f' rate {rate}'
+
+ if 'burst' in config['default']:
+ burst = config['default']['burst']
+ filter_cmd += f' burst {burst}'
+
+ if 'class' in config:
+ filter_cmd += f' flowid {self._parent:x}:{default_cls_id:x}'
+
+ self._cmd(filter_cmd)
diff --git a/python/vyos/qos/limiter.py b/python/vyos/qos/limiter.py
index ace0c0b6c..3f5c11112 100644
--- a/python/vyos/qos/limiter.py
+++ b/python/vyos/qos/limiter.py
@@ -17,6 +17,7 @@ from vyos.qos.base import QoSBase
class Limiter(QoSBase):
_direction = ['ingress']
+ qostype = 'limiter'
def update(self, config, direction):
tmp = f'tc qdisc add dev {self._interface} handle {self._parent:x}: {direction}'