Add test case for resolving family IDs of large Generic Netlink families
(those with 199+ multicast groups):

1. Tests that standard genl_ctrl_resolve() may fail due to:
   - Response size exceeding single message limit
   - Implementation expecting single response

2. Verifies custom my_genl_ctrl_resolve() works by:
   - Using dump mechanism to collect all responses
   - Properly handling multi-message replies
   - Correctly identifying target family

The test validates that large families can be reliably resolved despite
kernel message size limitations.

Signed-off-by: Yana Bashlykova <yana2...@gmail.com>
---
 tools/testing/selftests/net/genetlink.c | 37 +++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/tools/testing/selftests/net/genetlink.c 
b/tools/testing/selftests/net/genetlink.c
index 0a05402caa20..361840aae918 100644
--- a/tools/testing/selftests/net/genetlink.c
+++ b/tools/testing/selftests/net/genetlink.c
@@ -1142,6 +1142,43 @@ TEST(genl_ctrl_policy)
        nl_socket_free(ctrl_sock);
 }
 
+/**
+ * TEST(resolve_large_family_id) - Tests resolution of family ID for
+ * LARGE_GENL Generic Netlink family
+ *
+ * Validates special handling required for families with many multicast groups 
(199+):
+ * 1. Standard genl_ctrl_resolve() fails due to message size limitations
+ * 2. Custom my_genl_ctrl_resolve() succeeds by using dump mechanism
+ *
+ * Background:
+ * - Kernel successfully registers large families
+ * - Standard resolution fails because:
+ *   * Response doesn't fit in single message
+ *   * genl_ctrl_resolve() expects single response
+ * - Custom solution works by:
+ *   * Using dump request to get all messages
+ *   * Searching for target family in callback
+ *
+ * Verification:
+ * 1. Custom resolver returns valid ID (> 0)
+ * 2. Standard resolver either fails or succeeds (platform-dependent)
+ */
+
+TEST(resolve_large_family_id)
+{
+       int family_id;
+       int no_family_id;
+
+       /* Test custom resolver */
+       family_id = my_genl_ctrl_resolve(LARGE_GENL_FAMILY_NAME);
+       EXPECT_TRUE(family_id > 0);
+
+       /* Test standard resolver (may fail) */
+       no_family_id = genl_ctrl_resolve(socket_alloc_and_conn(),
+                                        LARGE_GENL_FAMILY_NAME);
+       EXPECT_TRUE(no_family_id > 0);
+}
+
 /**
  * TEST(capture_end) - Terminates Netlink traffic monitoring session
  *
-- 
2.34.1


Reply via email to