diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-04-13 13:10:15 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-13 13:10:15 +0200 |
commit | a6ccf358c7148781be438c4a2f89468ebfe5d48f (patch) | |
tree | 5b72368e3267106b23fc98a4f87e3c0fad382fe5 /python | |
parent | a49772fabb0e6f405ca19c7f9f76927ef96c4f79 (diff) | |
parent | 31cd75aec6d035b36537046ae0d034c03009a3fc (diff) | |
download | vyos-1x-a6ccf358c7148781be438c4a2f89468ebfe5d48f.tar.gz vyos-1x-a6ccf358c7148781be438c4a2f89468ebfe5d48f.zip |
Merge pull request #3297 from HollyGurza/T6035
qos: T6035: QoS policy shaper queue-type random-detect requires limit avpkt
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/qos/base.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/python/vyos/qos/base.py b/python/vyos/qos/base.py index c8e881ee2..f9366c6b1 100644 --- a/python/vyos/qos/base.py +++ b/python/vyos/qos/base.py @@ -90,6 +90,23 @@ class QoSBase: else: return value + def _calc_random_detect_queue_params(self, avg_pkt, max_thr, limit=None, min_thr=None, mark_probability=None): + params = dict() + avg_pkt = int(avg_pkt) + max_thr = int(max_thr) + mark_probability = int(mark_probability) + limit = int(limit) if limit else 4 * max_thr + min_thr = int(min_thr) if min_thr else (9 * max_thr) // 18 + + params['avg_pkt'] = avg_pkt + params['limit'] = limit * avg_pkt + params['min_val'] = min_thr * avg_pkt + params['max_val'] = max_thr * avg_pkt + params['burst'] = (2 * min_thr + max_thr) // 3 + params['probability'] = 1 / mark_probability + + return params + def _build_base_qdisc(self, config : dict, cls_id : int): """ Add/replace qdisc for every class (also default is a class). This is @@ -144,6 +161,18 @@ class QoSBase: elif queue_type == 'random-detect': default_tc += f' red' + qparams = self._calc_random_detect_queue_params( + avg_pkt=dict_search('average_packet', config), + max_thr=dict_search('maximum_threshold', config), + limit=dict_search('queue_limit', config), + min_thr=dict_search('minimum_threshold', config), + mark_probability=dict_search('mark_probability', config) + ) + + default_tc += f' limit {qparams["limit"]} avpkt {qparams["avg_pkt"]}' + default_tc += f' max {qparams["max_val"]} min {qparams["min_val"]}' + default_tc += f' burst {qparams["burst"]} probability {qparams["probability"]}' + self._cmd(default_tc) elif queue_type == 'drop-tail': |