netlink: cope with growing requests

If a request ends up growing beyong the initially allocated space the
netlink functions (such as snl_add_msg_attr_u32()) will allocate a
new buffer. This invalidates the header pointer we can have received
from snl_create_msg_request(). Always use the hdr returned by
snl_finalize_msg().

Reviewed by:	melifaro
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D42223
This commit is contained in:
Kristof Provost
2023-10-16 11:48:57 +02:00
parent fad5734995
commit 4f8f43b06e
9 changed files with 28 additions and 28 deletions
+1 -1
View File
@@ -86,7 +86,7 @@ ATF_TC_BODY(test_snl_get_genl_family_groups, tc)
snl_init_writer(&ss, &nw);
hdr = snl_create_genl_msg_request(&nw, GENL_ID_CTRL, CTRL_CMD_GETFAMILY);
snl_add_msg_attr_string(&nw, CTRL_ATTR_FAMILY_NAME, "nlctrl");
snl_finalize_msg(&nw);
hdr = snl_finalize_msg(&nw);
snl_send_message(&ss, hdr);
hdr = snl_read_reply(&ss, hdr->nlmsg_seq);