Skip to content

Commit 7ed5254

Browse files
kuba-moogregkh
authored andcommitted
tools: ynl: c: correct reverse decode of empty attrs
[ Upstream commit 964417a ] netlink reports which attribute was incorrect by sending back an attribute offset. Offset points to the address of struct nlattr, but to interpret the type we also need the nesting path. Attribute IDs have different meaning in different nests of the same message. Correct the condition for "is the offset within current attribute". ynl_attr_data_len() does not include the attribute header, so the end offset was off by 4 bytes. This means that we'd always skip over flags and empty nests. The devmem tests, for example, issues an invalid request with empty queue nests, resulting in the following error: YNL failed: Kernel error: missing attribute: .queues.ifindex The message is incorrect, "queues" nest does not have an "ifindex" attribute defined. With this fix we decend correctly into the nest: YNL failed: Kernel error: missing attribute: .queues.id Fixes: 86878f1 ("tools: ynl: user space helpers") Reviewed-by: Donald Hunter <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent a275db4 commit 7ed5254

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/net/ynl/lib/ynl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ynl_err_walk(struct ynl_sock *ys, void *start, void *end, unsigned int off,
9595

9696
ynl_attr_for_each_payload(start, data_len, attr) {
9797
astart_off = (char *)attr - (char *)start;
98-
aend_off = astart_off + ynl_attr_data_len(attr);
98+
aend_off = (char *)ynl_attr_data_end(attr) - (char *)start;
9999
if (aend_off <= off)
100100
continue;
101101

0 commit comments

Comments
 (0)