mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 03:35:32 -04:00
selftests: net: shaper: Add .group rate update test
Add group_update_rate to test updating an existing node's rate via the .group callback. Creates a node with bw_max=10000, re-groups with bw_max=50000, and verifies the rate changed while leaves remain under the same node. Signed-off-by: Mohsin Bashir <hmohsin@meta.com> Link: https://patch.msgid.link/20260805030936.1092907-7-mohsin.bashr@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
212410dc81
commit
047735744d
@@ -380,6 +380,72 @@ def set_node_shaper(cfg, nl_shaper) -> None:
|
||||
shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
|
||||
ksft_eq(len(shapers), 0)
|
||||
|
||||
def group_update_rate(cfg, nl_shaper) -> None:
|
||||
""" Verify re-grouping a node updates its rate while leaving the leaves untouched. """
|
||||
_require_queues(cfg, 3)
|
||||
_require_caps(cfg, nl_shaper, 'node', ['support-bw-max', 'support-metric-bps'],
|
||||
"device does not support node scope shapers with bw_max and metric bps")
|
||||
_require_caps(cfg, nl_shaper, 'queue', ['support-nesting', 'support-weight'],
|
||||
"device does not support nested queue scope shapers with weight")
|
||||
|
||||
# Create node with Q1, Q2 at bw_max=10000
|
||||
node_handle = nl_shaper.group({
|
||||
'ifindex': cfg.ifindex,
|
||||
'leaves':[{'handle': {'scope': 'queue', 'id': 1},
|
||||
'weight': 1},
|
||||
{'handle': {'scope': 'queue', 'id': 2},
|
||||
'weight': 1}],
|
||||
'handle': {'scope':'node'},
|
||||
'metric': 'bps',
|
||||
'bw-max': 10000})
|
||||
node_id = node_handle['handle']['id']
|
||||
for i in range(1, 3):
|
||||
defer(_delete_shaper, cfg, nl_shaper, {'scope': 'queue', 'id': i})
|
||||
|
||||
# Update rate via .group on the same node
|
||||
nl_shaper.group({
|
||||
'ifindex': cfg.ifindex,
|
||||
'leaves':[{'handle': {'scope': 'queue', 'id': 1},
|
||||
'weight': 1},
|
||||
{'handle': {'scope': 'queue', 'id': 2},
|
||||
'weight': 1}],
|
||||
'handle': {'scope':'node', 'id': node_id},
|
||||
'metric': 'bps',
|
||||
'bw-max': 50000})
|
||||
|
||||
# Verify rate updated
|
||||
shaper = nl_shaper.get({'ifindex': cfg.ifindex,
|
||||
'handle': {'scope': 'node', 'id': node_id}})
|
||||
ksft_eq(shaper, {'ifindex': cfg.ifindex,
|
||||
'handle': {'scope': 'node', 'id': node_id},
|
||||
'parent': {'scope': 'netdev'},
|
||||
'metric': 'bps',
|
||||
'bw-max': 50000})
|
||||
|
||||
# Verify leaves unchanged
|
||||
shaper_q1 = nl_shaper.get({'ifindex': cfg.ifindex,
|
||||
'handle': {'scope': 'queue', 'id': 1}})
|
||||
ksft_eq(shaper_q1, {'ifindex': cfg.ifindex,
|
||||
'parent': {'scope': 'node', 'id': node_id},
|
||||
'handle': {'scope': 'queue', 'id': 1},
|
||||
'weight': 1})
|
||||
shaper_q2 = nl_shaper.get({'ifindex': cfg.ifindex,
|
||||
'handle': {'scope': 'queue', 'id': 2}})
|
||||
ksft_eq(shaper_q2, {'ifindex': cfg.ifindex,
|
||||
'parent': {'scope': 'node', 'id': node_id},
|
||||
'handle': {'scope': 'queue', 'id': 2},
|
||||
'weight': 1})
|
||||
|
||||
# Make sure we only have 3 shapers including 2 queues and the node
|
||||
shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
|
||||
ksft_eq(len(shapers), 3)
|
||||
|
||||
# Cleanup
|
||||
for i in range(1, 3):
|
||||
_delete_shaper(cfg, nl_shaper, {'scope': 'queue', 'id': i})
|
||||
shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
|
||||
ksft_eq(len(shapers), 0)
|
||||
|
||||
def delegation(cfg, nl_shaper) -> None:
|
||||
_require_queues(cfg, 4)
|
||||
_require_caps(cfg, nl_shaper, 'node',
|
||||
@@ -580,6 +646,7 @@ def main() -> None:
|
||||
basic_groups_with_rate,
|
||||
qgroups,
|
||||
set_node_shaper,
|
||||
group_update_rate,
|
||||
delegation,
|
||||
dup_leaves,
|
||||
queue_update],
|
||||
|
||||
Reference in New Issue
Block a user