Skip to content

Commit f38edf1

Browse files
kuba-mooqmonnet
authored andcommitted
bpftool: Fix truncated netlink dumps
Netlink requires that the recv buffer used during dumps is at least min(PAGE_SIZE, 8k) (see the man page). Otherwise the messages will get truncated. Make sure bpftool follows this requirement, avoid missing information on systems with large pages. Acked-by: Quentin Monnet <qmo@kernel.org> Fixes: 7084566a236f ("tools/bpftool: Remove libbpf_internal.h usage in bpftool") Signed-off-by: Jakub Kicinski <kuba@kernel.org> Link: https://lore.kernel.org/r/20260217194150.734701-1-kuba@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 42a87a0 commit f38edf1

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/net.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,
156156
bool multipart = true;
157157
struct nlmsgerr *err;
158158
struct nlmsghdr *nh;
159-
char buf[4096];
159+
char buf[8192];
160160
int len, ret;
161161

162162
while (multipart) {
@@ -201,6 +201,9 @@ static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,
201201
return ret;
202202
}
203203
}
204+
205+
if (len)
206+
p_err("Invalid message or trailing data in Netlink response: %d bytes left", len);
204207
}
205208
ret = 0;
206209
done:

0 commit comments

Comments
 (0)