diff options
author | Daniil Baturin <daniil@vyos.io> | 2024-05-02 17:18:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 17:18:09 +0200 |
commit | 94912486be3ce4a0338d9a3e1fffa4a8cfe8f52b (patch) | |
tree | d964cfd4f27e741da6eabe25967c47c9572df31e /src/conf_mode | |
parent | a6cc2b4ccbcbf4b427b68000e4b31b9bd95a1d64 (diff) | |
parent | abc465f8ad894fda29d32b053798676e0294e20f (diff) | |
download | vyos-1x-94912486be3ce4a0338d9a3e1fffa4a8cfe8f52b.tar.gz vyos-1x-94912486be3ce4a0338d9a3e1fffa4a8cfe8f52b.zip |
Merge pull request #3401 from vyos/mergify/bp/sagitta/pr-3400
qos: T6225: Fix QoS random-detect policy (backport #3400)
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/qos.py | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/src/conf_mode/qos.py b/src/conf_mode/qos.py index ccfc8f6b8..8a590cbc6 100755 --- a/src/conf_mode/qos.py +++ b/src/conf_mode/qos.py @@ -39,6 +39,9 @@ from vyos.utils.dict import dict_search_recursive from vyos.utils.process import run from vyos import ConfigError from vyos import airbag +from vyos.xml_ref import relative_defaults + + airbag.enable() map_vyops_tc = { @@ -115,8 +118,18 @@ def get_config(config=None): for rd_name in list(qos['policy'][policy]): # There are eight precedence levels - ensure all are present # to be filled later down with the appropriate default values - default_precedence = {'precedence' : { '0' : {}, '1' : {}, '2' : {}, '3' : {}, - '4' : {}, '5' : {}, '6' : {}, '7' : {} }} + default_p_val = relative_defaults( + ['qos', 'policy', 'random-detect', rd_name, 'precedence'], + {'precedence': {'0': {}}}, + get_first_key=True, recursive=True + )['0'] + default_p_val = {key.replace('-', '_'): value for key, value in default_p_val.items()} + default_precedence = { + 'precedence': {'0': default_p_val, '1': default_p_val, + '2': default_p_val, '3': default_p_val, + '4': default_p_val, '5': default_p_val, + '6': default_p_val, '7': default_p_val}} + qos['policy']['random_detect'][rd_name] = dict_merge( default_precedence, qos['policy']['random_detect'][rd_name]) @@ -124,18 +137,6 @@ def get_config(config=None): for policy in qos.get('policy', []): for p_name, p_config in qos['policy'][policy].items(): - if 'precedence' in p_config: - # precedence settings are a bit more complex as they are - # calculated under specific circumstances: - for precedence in p_config['precedence']: - max_thr = int(qos['policy'][policy][p_name]['precedence'][precedence]['maximum_threshold']) - if 'minimum_threshold' not in qos['policy'][policy][p_name]['precedence'][precedence]: - qos['policy'][policy][p_name]['precedence'][precedence]['minimum_threshold'] = str( - int((9 + int(precedence)) * max_thr) // 18); - - if 'queue_limit' not in qos['policy'][policy][p_name]['precedence'][precedence]: - qos['policy'][policy][p_name]['precedence'][precedence]['queue_limit'] = \ - str(int(4 * max_thr)) # cleanup empty match config if 'class' in p_config: for cls, cls_config in p_config['class'].items(): |