diff options
author | khramshinr <khramshinr@gmail.com> | 2024-05-02 17:45:57 +0600 |
---|---|---|
committer | Mergify <37929162+mergify[bot]@users.noreply.github.com> | 2024-05-02 15:05:57 +0000 |
commit | abc465f8ad894fda29d32b053798676e0294e20f (patch) | |
tree | 26b454e089b55712223e0f7ea403a2ab17fe208a /python | |
parent | 44008b19c5e8547521908b0df04f75215fb3fb79 (diff) | |
download | vyos-1x-abc465f8ad894fda29d32b053798676e0294e20f.tar.gz vyos-1x-abc465f8ad894fda29d32b053798676e0294e20f.zip |
qos: T6225: Fix qos random-detect policy
Fix default values for random-detect
Remove dsmakr qdisc from gred cofig because dsmark was deleted from kernel
(cherry picked from commit 0b54c1bc411a21833ec573031cf5ad98fe709a2f)
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/qos/base.py | 5 | ||||
-rw-r--r-- | python/vyos/qos/randomdetect.py | 34 |
2 files changed, 16 insertions, 23 deletions
diff --git a/python/vyos/qos/base.py b/python/vyos/qos/base.py index 4173a1a43..87927ba9d 100644 --- a/python/vyos/qos/base.py +++ b/python/vyos/qos/base.py @@ -90,13 +90,14 @@ class QoSBase: else: return value - def _calc_random_detect_queue_params(self, avg_pkt, max_thr, limit=None, min_thr=None, mark_probability=None): + def _calc_random_detect_queue_params(self, avg_pkt, max_thr, limit=None, min_thr=None, + mark_probability=None, precedence=0): 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 + min_thr = int(min_thr) if min_thr else ((9 + precedence) * max_thr) // 18 params['avg_pkt'] = avg_pkt params['limit'] = limit * avg_pkt diff --git a/python/vyos/qos/randomdetect.py b/python/vyos/qos/randomdetect.py index d7d84260f..a3a39da36 100644 --- a/python/vyos/qos/randomdetect.py +++ b/python/vyos/qos/randomdetect.py @@ -21,33 +21,25 @@ class RandomDetect(QoSBase): # https://man7.org/linux/man-pages/man8/tc.8.html def update(self, config, direction): - tmp = f'tc qdisc add dev {self._interface} root handle {self._parent}:0 dsmark indices 8 set_tc_index' + # # Generalized Random Early Detection + handle = self._parent + tmp = f'tc qdisc add dev {self._interface} root handle {self._parent}:0 gred setup DPs 8 default 0 grio' self._cmd(tmp) - - tmp = f'tc filter add dev {self._interface} parent {self._parent}:0 protocol ip prio 1 tcindex mask 0xe0 shift 5' - self._cmd(tmp) - - # Generalized Random Early Detection - handle = self._parent +1 - tmp = f'tc qdisc add dev {self._interface} parent {self._parent}:0 handle {handle}:0 gred setup DPs 8 default 0 grio' - self._cmd(tmp) - bandwidth = self._rate_convert(config['bandwidth']) # set VQ (virtual queue) parameters for precedence, precedence_config in config['precedence'].items(): precedence = int(precedence) - avg_pkt = int(precedence_config['average_packet']) - limit = int(precedence_config['queue_limit']) * avg_pkt - min_val = int(precedence_config['minimum_threshold']) * avg_pkt - max_val = int(precedence_config['maximum_threshold']) * avg_pkt - - tmp = f'tc qdisc change dev {self._interface} handle {handle}:0 gred limit {limit} min {min_val} max {max_val} avpkt {avg_pkt} ' - - burst = (2 * int(precedence_config['minimum_threshold']) + int(precedence_config['maximum_threshold'])) // 3 - probability = 1 / int(precedence_config['mark_probability']) - tmp += f'burst {burst} bandwidth {bandwidth} probability {probability} DP {precedence} prio {8 - precedence:x}' - + qparams = self._calc_random_detect_queue_params( + avg_pkt=precedence_config.get('average_packet'), + max_thr=precedence_config.get('maximum_threshold'), + limit=precedence_config.get('queue_limit'), + min_thr=precedence_config.get('minimum_threshold'), + mark_probability=precedence_config.get('mark_probability'), + precedence=precedence + ) + tmp = f'tc qdisc change dev {self._interface} handle {handle}:0 gred limit {qparams["limit"]} min {qparams["min_val"]} max {qparams["max_val"]} avpkt {qparams["avg_pkt"]} ' + tmp += f'burst {qparams["burst"]} bandwidth {bandwidth} probability {qparams["probability"]} DP {precedence} prio {8 - precedence:x}' self._cmd(tmp) # call base class |