From: Mohsin Bashir <mohsin.bashr@gmail.com>
To: netdev@vger.kernel.org
Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, pabeni@redhat.com,
shuah@kernel.org, alexander.duyck@gmail.com
Subject: [PATCH net-next 14/14] selftests: net: shaper: Cover recursive node cleanup
Date: Tue, 4 Aug 2026 20:09:36 -0700 [thread overview]
Message-ID: <20260805030936.1092907-15-mohsin.bashr@gmail.com> (raw)
In-Reply-To: <20260805030936.1092907-1-mohsin.bashr@gmail.com>
From: Mohsin Bashir <hmohsin@meta.com>
Exercise cleanup of nested nodes after deleting their last queue leaf. The
test builds a two-level node hierarchy and checks that removing the queue
also removes both now-empty node shapers.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Mohsin Bashir <hmohsin@meta.com>
---
tools/testing/selftests/drivers/net/shaper.py | 59 +++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/tools/testing/selftests/drivers/net/shaper.py b/tools/testing/selftests/drivers/net/shaper.py
index 9264aeb74a7a..a53316726f69 100755
--- a/tools/testing/selftests/drivers/net/shaper.py
+++ b/tools/testing/selftests/drivers/net/shaper.py
@@ -374,6 +374,64 @@ def mixed_parent_group_requires_parent(cfg, nl_shaper) -> None:
shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
ksft_eq(len(shapers), 0)
+def recursive_empty_node_cleanup(cfg, nl_shaper) -> None:
+ r"""Deleting the last leaf recursively removes the emptied ancestors.
+
+ netdev netdev
+ | del Q0
+ N1 ------> (N1 and N2 removed too)
+ |
+ N2
+ |
+ Q0
+ """
+ _require_queues(cfg, 1)
+ _require_caps(cfg, nl_shaper, 'node',
+ ['support-bw-max', 'support-metric-bps', 'support-nesting'],
+ "device does not support nested node scope shapers")
+ _require_caps(cfg, nl_shaper, 'queue',
+ ['support-nesting', 'support-weight'],
+ "device does not support nested queue scope shapers with weight")
+
+ n1_handle = nl_shaper.group({
+ 'ifindex': cfg.ifindex,
+ 'leaves':[{'handle': {'scope': 'queue', 'id': 0},
+ 'weight': 1}],
+ 'handle': {'scope':'node'},
+ 'metric': 'bps',
+ 'bw-max': 10000})
+ n1_id = n1_handle['handle']['id']
+ defer(_delete_shaper, cfg, nl_shaper, {'scope': 'queue', 'id': 0})
+
+ n2_handle = nl_shaper.group({
+ 'ifindex': cfg.ifindex,
+ 'leaves':[{'handle': {'scope': 'queue', 'id': 0},
+ 'weight': 1}],
+ 'handle': {'scope':'node'},
+ 'parent': {'scope': 'node', 'id': n1_id},
+ 'metric': 'bps',
+ 'bw-max': 5000})
+ n2_id = n2_handle['handle']['id']
+
+ shaper_q0 = nl_shaper.get({'ifindex': cfg.ifindex,
+ 'handle': {'scope': 'queue', 'id': 0}})
+ ksft_eq(shaper_q0, {'ifindex': cfg.ifindex,
+ 'parent': {'scope': 'node', 'id': n2_id},
+ 'handle': {'scope': 'queue', 'id': 0},
+ 'weight': 1})
+
+ nl_shaper.delete({'ifindex': cfg.ifindex,
+ 'handle': {'scope': 'queue', 'id': 0}})
+
+ for handle in ({'scope': 'queue', 'id': 0},
+ {'scope': 'node', 'id': n2_id},
+ {'scope': 'node', 'id': n1_id}):
+ with ksft_raises(NlError):
+ nl_shaper.get({'ifindex': cfg.ifindex, 'handle': handle})
+
+ shapers = nl_shaper.get({'ifindex': cfg.ifindex}, dump=True)
+ ksft_eq(len(shapers), 0)
+
def _group_under_netdev(cfg, nl_shaper, bw_max=None):
r"""Group queues under a netdev-scope node; caller owns node teardown.
@@ -1293,6 +1351,7 @@ def main() -> None:
set_all_supported_attrs,
invalid_set_preserves_state,
mixed_parent_group_requires_parent,
+ recursive_empty_node_cleanup,
basic_groups,
basic_groups_with_rate,
qgroups,
--
2.53.0-Meta
prev parent reply other threads:[~2026-08-05 3:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 3:09 [PATCH net-next 00/14] selftests: net: shaper: Expand shaper API coverage Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 01/14] selftests: net: shaper: Drop redundant command timeouts Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 02/14] selftests: net: shaper: Prepare helpers for group tests Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 03/14] selftests: net: shaper: Decouple basic_groups from netdev rate limiting Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 04/14] selftests: net: shaper: Add basic_groups_with_rate test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 05/14] selftests: net: shaper: Add node scope .set rate update test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 06/14] selftests: net: shaper: Add .group " Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 07/14] selftests: net: shaper: Add nested depth limit discovery test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 08/14] selftests: net: shaper: Add child node deletion reparent test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 09/14] selftests: net: shaper: Add queue migration between nodes test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 10/14] selftests: net: shaper: Add reparenting rejection test Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 11/14] selftests: net: shaper: Cover scalar attributes Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 12/14] selftests: net: shaper: Reject invalid set requests Mohsin Bashir
2026-08-05 3:09 ` [PATCH net-next 13/14] selftests: net: shaper: Cover mixed-parent grouping Mohsin Bashir
2026-08-05 3:09 ` Mohsin Bashir [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260805030936.1092907-15-mohsin.bashr@gmail.com \
--to=mohsin.bashr@gmail.com \
--cc=alexander.duyck@gmail.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox