From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
andrew+netdev@lunn.ch, horms@kernel.org, shuah@kernel.org,
linux-kselftest@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v2 3/4] selftests: net: make sure that Netlink rejects unknown attrs in dump
Date: Tue, 10 Mar 2026 20:28:38 -0700 [thread overview]
Message-ID: <20260311032839.417748-4-kuba@kernel.org> (raw)
In-Reply-To: <20260311032839.417748-1-kuba@kernel.org>
Add a test case for rejecting attrs if policy is not set.
dev_get dump has no input policy (accepts no attrs).
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
CC: shuah@kernel.org
CC: linux-kselftest@vger.kernel.org
---
tools/testing/selftests/net/nl_netdev.py | 32 +++++++++++++++++++-----
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/net/nl_netdev.py b/tools/testing/selftests/net/nl_netdev.py
index 5c66421ab8aa..eff55c64a012 100755
--- a/tools/testing/selftests/net/nl_netdev.py
+++ b/tools/testing/selftests/net/nl_netdev.py
@@ -1,11 +1,15 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
-import time
+"""
+Tests for the netdev netlink family.
+"""
+
+import errno
from os import system
-from lib.py import ksft_run, ksft_exit, ksft_pr
-from lib.py import ksft_eq, ksft_ge, ksft_ne, ksft_busy_wait
-from lib.py import NetdevFamily, NetdevSimDev, ip
+from lib.py import ksft_run, ksft_exit
+from lib.py import ksft_eq, ksft_ge, ksft_ne, ksft_raises, ksft_busy_wait
+from lib.py import NetdevFamily, NetdevSimDev, NlError, ip
def empty_check(nf) -> None:
@@ -19,6 +23,15 @@ from lib.py import NetdevFamily, NetdevSimDev, ip
ksft_eq(len(lo_info['xdp-rx-metadata-features']), 0)
+def dev_dump_reject_attr(nf) -> None:
+ """Test that dev-get dump rejects attributes (no dump request policy)."""
+ with ksft_raises(NlError) as cm:
+ nf.dev_get({'ifindex': 1}, dump=True)
+ ksft_eq(cm.exception.nl_msg.error, -errno.EINVAL)
+ ksft_eq(cm.exception.nl_msg.extack['msg'], 'Unknown attribute type')
+ ksft_eq(cm.exception.nl_msg.extack['bad-attr'], '.ifindex')
+
+
def napi_list_check(nf) -> None:
with NetdevSimDev(queue_count=100) as nsimdev:
nsim = nsimdev.nsims[0]
@@ -243,9 +256,16 @@ from lib.py import NetdevFamily, NetdevSimDev, ip
def main() -> None:
+ """ Ksft boiler plate main """
nf = NetdevFamily()
- ksft_run([empty_check, lo_check, page_pool_check, napi_list_check,
- dev_set_threaded, napi_set_threaded, nsim_rxq_reset_down],
+ ksft_run([empty_check,
+ lo_check,
+ dev_dump_reject_attr,
+ napi_list_check,
+ napi_set_threaded,
+ dev_set_threaded,
+ nsim_rxq_reset_down,
+ page_pool_check],
args=(nf, ))
ksft_exit()
--
2.53.0
next prev parent reply other threads:[~2026-03-11 3:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 3:28 [PATCH net-next v2 0/4] genetlink: apply reject policy for split ops on the dispatch path Jakub Kicinski
2026-03-11 3:28 ` [PATCH net-next v2 1/4] genetlink: use maxattr of 0 for the reject policy Jakub Kicinski
2026-03-11 3:28 ` [PATCH net-next v2 2/4] genetlink: apply reject policy for split ops on the dispatch path Jakub Kicinski
2026-03-11 3:28 ` Jakub Kicinski [this message]
2026-03-11 3:28 ` [PATCH net-next v2 4/4] selftests: net: add test for Netlink policy dumps Jakub Kicinski
2026-03-13 1:20 ` [PATCH net-next v2 0/4] genetlink: apply reject policy for split ops on the dispatch path patchwork-bot+netdevbpf
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=20260311032839.417748-4-kuba@kernel.org \
--to=kuba@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@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