Skip to contentSkip to conversation

genl-family-get test fails with "Invalid Argument" on kernel 6.8

PATCH In review Divyanshu Rathore 3 participants 3 messages Sep 15, 2025 netfilter

lore
Share & tools
lore
#0 lore raw

Dear Team,

As part of our system testing for the libmnl component version 1.0.5, we are using the genl-family-get.c test file from the upstream repository:

libmnl/tree/examples/genl/genl-family-get.c

In our test setup, we execute this binary without any arguments. We have observed that the test behaves differently depending on the kernel version:

On systems running kernel 5.15, the binary executes successfully.

On systems running kernel 6.8, it consistently fails with the following error: "Invalid Argument"

We added debug logs and got the below output:

Test failing due to:

AssertionError: Regex didn't match: 'name=' not found in '[DBG] main: program start\n[DBG] main: building request: nlmsg_type=16, nlmsg_flags=0x5, nlmsg_seq=1756046191\n[DBG] main: dumping all families\n[DBG] main: opened netlink socket\n[DBG] main: socket bound, portid=9125\n[DBG] main: sent request to kernel\n[DBG] main: received 48 bytes from kernel\n[DBG] main: mnl_cb_run returned -1\n[DBG] main: program finished'

We ensured that the same libmnl version 1.0.5 is used across all systems, and we verified this issue on multiple hardware platforms. We also added debug prints and verified that the failure occurs in the call to mnl_socket_sendto().

From our investigation, We checked in multiple hardwares and added debug prints, from that it is concluded that, the kernel version upgrade is causing the issue Can you please check this issue and provide the fix for it.

Let us know if additional details are needed.

Best Regards,
Divyanshu Rathore

maintainer
#1 lore raw

PATCH 1/1 examples: genl: fix wrong attribute size

This example no longer works on more recent kernels:

genl-family-get
error: Invalid argument

dmesg says:
netlink: 'genl-family-get': attribute type 1 has an invalid length.

Fix this and also zero out the reserved field in the genl header, while not validated yet for dumps this could change.

---
I will push this out later today.

 examples/genl/genl-family-get.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
examples/genl/genl-family-get.c +2 -1
index ba8de122094c..0c2006755e30 100644
@@ -199,8 +199,9 @@ int main(int argc, char *argv[])
 	genl = mnl_nlmsg_put_extra_header(nlh, sizeof(struct genlmsghdr));
 	genl->cmd = CTRL_CMD_GETFAMILY;
 	genl->version = 1;
+	genl->reserved = 0;
 
-	mnl_attr_put_u32(nlh, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL);
+	mnl_attr_put_u16(nlh, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL);
 	if (argc >= 2)
 		mnl_attr_put_strz(nlh, CTRL_ATTR_FAMILY_NAME, argv[1]);
 	else
Signature · 1 line
2.51.0
maintainer Acked-by on v1 1/1
#2 lore raw

Re: [PATCH libmnl] examples: genl: fix wrong attribute size

Quoted 5 lines · Florian Westphal

This example no longer works on more recent kernels:

genl-family-get
error: Invalid argument

Quoted 8 lines

dmesg says:
netlink: 'genl-family-get': attribute type 1 has an invalid length.

Fix this and also zero out the reserved field in the genl header, while not validated yet for dumps this could change.

Quoted 25 lines

---
I will push this out later today.

 examples/genl/genl-family-get.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
examples/genl/genl-family-get.c +2 -1
index ba8de122094c..0c2006755e30 100644
@@ -199,8 +199,9 @@ int main(int argc, char *argv[])
 	genl = mnl_nlmsg_put_extra_header(nlh, sizeof(struct genlmsghdr));
 	genl->cmd = CTRL_CMD_GETFAMILY;
 	genl->version = 1;
+	genl->reserved = 0;
 
-	mnl_attr_put_u32(nlh, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL);
+	mnl_attr_put_u16(nlh, CTRL_ATTR_FAMILY_ID, GENL_ID_CTRL);
 	if (argc >= 2)
 		mnl_attr_put_strz(nlh, CTRL_ATTR_FAMILY_NAME, argv[1]);
 	else
Signature · 1 line
2.51.0