From: Yana Bashlykova <yana2bsh@gmail.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: Yana Bashlykova <yana2bsh@gmail.com>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: [PATCH 6.1 04/15] genetlink: add test case for duplicate genl family registration
Date: Fri, 12 Sep 2025 22:53:27 +0300 [thread overview]
Message-ID: <20250912195339.20635-5-yana2bsh@gmail.com> (raw)
In-Reply-To: <20250912195339.20635-1-yana2bsh@gmail.com>
Add incorrect_genl_family struct with duplicate name to test
error handling when registering families with conflicting names.
Signed-off-by: Yana Bashlykova <yana2bsh@gmail.com>
---
.../net-pf-16-proto-16-family-PARALLEL_GENL.c | 35 +++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c b/drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c
index 17f869ece2d6..1db5d15a6f2c 100644
--- a/drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c
+++ b/drivers/net/genetlink/net-pf-16-proto-16-family-PARALLEL_GENL.c
@@ -1077,6 +1077,18 @@ static struct genl_family my_genl_family_parallel = {
.n_mcgrps = ARRAY_SIZE(genl_many_mcgrps_two),
};
+// genl_family struct with incorrect name
+static struct genl_family incorrect_genl_family = {
+ .hdrsize = 0,
+ .name = MY_GENL_FAMILY_NAME, // such family already exists
+ .version = MY_GENL_VERSION,
+ .maxattr = MY_GENL_ATTR_MAX,
+ .netnsok = true,
+ .ops = my_genl_ops,
+ .n_ops = ARRAY_SIZE(my_genl_ops),
+ .policy = my_genl_policy,
+};
+
static int __init init_netlink(void)
{
int rc;
@@ -1104,6 +1116,25 @@ static int __init init_netlink(void)
return rc;
}
+static int __init incorrect_init_netlink(void)
+{
+ int rc;
+
+ pr_info("%s: My module. Initializing incorrect Netlink\n", __func__);
+
+ rc = genl_register_family(&incorrect_genl_family);
+ if (rc) {
+ pr_err("%s: Failed to register incorrect Generic Netlink family\n", __func__);
+ goto failure;
+ }
+
+ return 0;
+
+failure:
+ pr_info("%s: Error was handled correctly\n", __func__);
+ return -EINVAL;
+}
+
static int __init init_sysfs_third_genl(void)
{
int ret;
@@ -1215,6 +1246,10 @@ static int __init module_netlink_init(void)
goto err_sysfs;
pr_info("%s: New families are registered\n", __func__);
+ ret = incorrect_init_netlink();
+ if (ret)
+ pr_err("%s: Incorrect Generic Netlink family wasn't registered\n", __func__);
+
return 0;
err_sysfs:
--
2.34.1
next prev parent reply other threads:[~2025-09-12 19:53 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-12 19:53 [PATCH 6.1 00/15] genetlink: Test Netlink subsystem of Linux v6.1 Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 01/15] genetlink: add sysfs test module for Generic Netlink Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 02/15] genetlink: add TEST_GENL family for netlink testing Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 03/15] genetlink: add PARALLEL_GENL test family Yana Bashlykova
2025-09-12 19:53 ` Yana Bashlykova [this message]
2025-09-12 19:53 ` [PATCH 6.1 05/15] genetlink: add test case for family with invalid ops Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 06/15] genetlink: add netlink notifier support Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 07/15] genetlink: add THIRD_GENL family Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 08/15] genetlink: verify unregister fails for non-registered family Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 09/15] genetlink: add LARGE_GENL stress test family Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 10/15] selftests: net: genetlink: add packet capture test infrastructure Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 11/15] selftests: net: genetlink: add /proc/net/netlink test Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 12/15] selftests: net: genetlink: add Generic Netlink controller tests Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 13/15] selftests: net: genetlink: add large family ID resolution test Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 14/15] selftests: net: genetlink: add Netlink and Generic Netlink test suite Yana Bashlykova
2025-09-12 19:53 ` [PATCH 6.1 15/15] selftests: net: genetlink: fix expectation for large family resolution Yana Bashlykova
2025-09-12 20:17 ` [PATCH 6.1 00/15] genetlink: Test Netlink subsystem of Linux v6.1 Jakub Kicinski
2025-10-15 14:49 ` Яна Башлыкова
2025-10-15 15:04 ` Jakub Kicinski
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=20250912195339.20635-5-yana2bsh@gmail.com \
--to=yana2bsh@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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
all inboxes | Powered by JetHome®