From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A69793C98A2 for ; Wed, 5 Aug 2026 03:10:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785899422; cv=none; b=VR0EGwLR6xdU4xyMQTyKgTJXLShXi2HiMI2J37Zgps0ym0gWmb0aaxlX9krlHxI6dTIS+aLX8gvz1uxbr5wE6avuoNSvB0/qvj0MWa42QPjMU0uW8JzfSIhTRClY2Y7P2HruPQW2BM39wFpg9abVmWN3wFNb7RAgr8rUESdtJDA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785899422; c=relaxed/simple; bh=Ew9kqnx7gNLh63gLTyVSPNRcNPey74+hcBLknh/TAH0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VIAa0JsHyoyb0c4rd/xk9IFLdSfR7m62DTY9Xje2Lrtg77auBLKfoXNab8ZtjSDhXnakj2kDMV3CwXjEihn8N0w66uXoT58E7vVYKmbYGG+v86ju3hFBGn2164wLyq37fom6KbZqWKU0lxgmKqpeB3c0xRpGern/7/mD3hIAr04= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fffVNSwF; arc=none smtp.client-ip=209.85.161.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fffVNSwF" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-6acabd2c8bdso368497eaf.2 for ; Tue, 04 Aug 2026 20:10:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785899419; x=1786504219; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lcsQyfByd70EchMKWRKdanf3VR0eB6+yq95Jw1CGYPw=; b=fffVNSwF35pnScmiJy0Gp4fzCbMgu5G1uZpHPxqqfBMgi6BoUoCLdsXE6xAPkCf2XG EP/RIs1SOuKK/HoGfZkTK03EAtzHBcIncvj3uamJoLrAGOKJF9Sq2qrCJz98CpZw9uj2 0p5Xaw1yjrdKMG68bG7IYHKySFHtPIZlO5oNpsFT15xMXA6Ces2p1e90+Dx78CLjua9m KfiQijfAR+6jzxTbxYaZFBsM94xVyQs80yWStyg+32wpjzWYhN4tZEngokyoBFnTraRX x3mUQkIa20ex0jSqsrc8ZXZ4zgkBP16dAxqybfRjuRZVMIPynxxePap1O+Ze3vLg5nLw bCBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785899419; x=1786504219; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=lcsQyfByd70EchMKWRKdanf3VR0eB6+yq95Jw1CGYPw=; b=LBnBdrVxoQ0L78pw2L4sgu1U2jAQGWmXhxWA2IMolGZj8oqQ7+K0oxFTodQCBo0d96 U9MxqSYyX7fPq0sjVoehiR5IiW4j3slLcoWKKlFb6H58WfyQpxJ/JrjJyufyREnMl9cZ nWBZxHQm3RkH0HW1LXMhfOv8rHQHV/XUOoGZNxhmr1iGQk1pSdjPb4fR1bQh3TbOMejD hYOlSFBRRR/kDpA20A4I9bqnyaONc+WK2qNRAxqhMMQWMCLa7N2thA8ym0tJFxrRnbzu g0Ke+oSWK2/OavrCimWs5Y/vpK424nZHWCqRoeJPPgeAv/DfjA0w1r91e70IXEuD/CVl jnrg== X-Forwarded-Encrypted: i=1; AHgh+RpOUFtINzER8b/7uNRZBIb6wpei6alUctw/uYuUCtQksuDAC6q/jJUpxohj9xnWI95kSenezCdEzvHW/q4=@vger.kernel.org X-Gm-Message-State: AOJu0Yw/VopeHO7b0YjwegxdnIt3JYTyB1jehApZhKmFwH4DOv/5NomO 9C8VZLTCo33Cqd82Wp71IGHQoDFmMoeI7xnqbjE/y6mgRSxdH+ipZDAg X-Gm-Gg: AR+sD115cmQBS2sj2MR2qXE3HOQTkxWUNlxeE5FD6RyzEC0E7+oP6wcgTlsOQpSHkNT w0GvSi9kvAz/SIM40sguxZRXgRhJQSWui9mxmzj317QXDuRXXoD7b2Jd3OyfPUta9b1e/abVXF+ FCRTL1zYEfrn8bCK6OXUSKGGna75YE/8JEVqow+VRU5fqE7kIB0x4mwzuyjYk+P/c5+ZJwWSmri mG5x0hPSa4YDReFjPNMja3gRHzApoaP/oETU6qTT6Adxig/3wAsXpuIECZshCfuyb8Fl43NiZq9 WCnRq1+8f1xdjwu2o95dswE7v06g+rmFHVkbiO68bVlRQ4KGN7MWzmYbPq5kL1p2gScJG9xHMtV TRWZ1ova9VLLJPTCRhhd+Z47e2YtZCv/ul0QXK8HWdORsQfR/wPWSyqjRjfcOb08+sudZ640Fc5 +wl17b9KZO/Qh3CLRzJUOx+Nft3ub/0cWFNIGTFLZPNNojKtvm9RMJ8reNWkg= X-Received: by 2002:a05:6820:1990:b0:69d:e4c8:86f6 with SMTP id 006d021491bc7-6ae96e3b5afmr1985507eaf.15.1785899419557; Tue, 04 Aug 2026 20:10:19 -0700 (PDT) Received: from localhost ([2a03:2880:31ff:3a::]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6ae93cbf7a9sm1632805eaf.2.2026.08.04.20.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Aug 2026 20:10:18 -0700 (PDT) From: Mohsin Bashir 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 Message-ID: <20260805030936.1092907-15-mohsin.bashr@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260805030936.1092907-1-mohsin.bashr@gmail.com> References: <20260805030936.1092907-1-mohsin.bashr@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Mohsin Bashir 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 Signed-off-by: Mohsin Bashir --- 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