Skip to content

Commit

Permalink
T6790: QoS: Improve CAKE Policy
Browse files Browse the repository at this point in the history
- Fixed handling of flow isolation parameters.
- Corrected support for `nat` and `nonat` in flow isolation.
- Extended RTT values to cover the full range supported by `tc`.
  • Loading branch information
HollyGurza committed Nov 11, 2024
1 parent ff82bd5 commit f92e4c4
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 12 deletions.
6 changes: 3 additions & 3 deletions python/vyos/qos/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ def _build_base_qdisc(self, config : dict, cls_id : int):
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),
avg_pkt=dict_search('average_packet', config) or 1024,
max_thr=dict_search('maximum_threshold', config) or 18,
limit=dict_search('queue_limit', config),
min_thr=dict_search('minimum_threshold', config),
mark_probability=dict_search('mark_probability', config)
mark_probability=dict_search('mark_probability', config) or 10
)

default_tc += f' limit {qparams["limit"]} avpkt {qparams["avg_pkt"]}'
Expand Down
19 changes: 10 additions & 9 deletions python/vyos/qos/priority.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ class Priority(QoSBase):

# https://man7.org/linux/man-pages/man8/tc-prio.8.html
def update(self, config, direction):
if 'class' in config:
class_id_max = self._get_class_max_id(config)
bands = int(class_id_max) +1
class_id_max = self._get_class_max_id(config)
class_id_max = class_id_max if class_id_max else 1
bands = int(class_id_max) + 1

tmp = f'tc qdisc add dev {self._interface} root handle {self._parent:x}: prio bands {bands} priomap ' \
f'{class_id_max} {class_id_max} {class_id_max} {class_id_max} ' \
f'{class_id_max} {class_id_max} {class_id_max} {class_id_max} ' \
f'{class_id_max} {class_id_max} {class_id_max} {class_id_max} ' \
f'{class_id_max} {class_id_max} {class_id_max} {class_id_max} '
self._cmd(tmp)
tmp = f'tc qdisc add dev {self._interface} root handle {self._parent:x}: prio bands {bands} priomap ' \
f'{class_id_max} {class_id_max} {class_id_max} {class_id_max} ' \
f'{class_id_max} {class_id_max} {class_id_max} {class_id_max} ' \
f'{class_id_max} {class_id_max} {class_id_max} {class_id_max} ' \
f'{class_id_max} {class_id_max} {class_id_max} {class_id_max} '
self._cmd(tmp)

if 'class' in config:
for cls in config['class']:
cls = int(cls)
tmp = f'tc qdisc add dev {self._interface} parent {self._parent:x}:{cls:x} pfifo'
Expand Down
76 changes: 76 additions & 0 deletions smoketest/scripts/cli/test_qos.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

base_path = ['qos']


def get_tc_qdisc_json(interface, all=False) -> dict:
tmp = cmd(f'tc -detail -json qdisc show dev {interface}')
tmp = loads(tmp)
Expand Down Expand Up @@ -871,6 +872,81 @@ def test_16_wrong_traffic_match_group(self):
self.cli_set(['qos', 'traffic-match-group', '3', 'match-group', 'unexpected'])
self.cli_commit()

def test_18_priority_queue_default(self):
interface = self._interfaces[0]
policy_name = f'qos-policy-{interface}'

self.cli_set(base_path + ['interface', interface, 'egress', policy_name])
self.cli_set(
base_path
+ ['policy', 'priority-queue', policy_name, 'description', 'default policy']
)

self.cli_commit()

tmp = get_tc_qdisc_json(interface, all=True)

self.assertEqual(2, len(tmp))
self.assertEqual('prio', tmp[0]['kind'])
self.assertDictEqual(
{
'bands': 2,
'priomap': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
'multiqueue': False,
},
tmp[0]['options'],
)
self.assertEqual('pfifo', tmp[1]['kind'])
self.assertDictEqual({'limit': 1000}, tmp[1]['options'])

def test_19_priority_queue_default_random_detect(self):
interface = self._interfaces[0]
policy_name = f'qos-policy-{interface}'

self.cli_set(base_path + ['interface', interface, 'egress', policy_name])
self.cli_set(
base_path
+ [
'policy',
'priority-queue',
policy_name,
'default',
'queue-type',
'random-detect',
]
)

self.cli_commit()

tmp = get_tc_qdisc_json(interface, all=True)

self.assertEqual(2, len(tmp))
self.assertEqual('prio', tmp[0]['kind'])
self.assertDictEqual(
{
'bands': 2,
'priomap': [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
'multiqueue': False,
},
tmp[0]['options'],
)
self.assertEqual('red', tmp[1]['kind'])
self.assertDictEqual(
{
'limit': 73728,
'min': 9216,
'max': 18432,
'ecn': False,
'harddrop': False,
'adaptive': False,
'nodrop': False,
'ewma': 3,
'probability': 0.1,
'Scell_log': 13,
},
tmp[1]['options'],
)

def test_20_round_robin_policy_default(self):
interface = self._interfaces[0]
policy_name = f'qos-policy-{interface}'
Expand Down

0 comments on commit f92e4c4

Please sign in to comment.