Commit 3b39d73c authored by Jakub Kicinski's avatar Jakub Kicinski Committed by Alexei Starovoitov
Browse files

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: default avatarQuentin Monnet <qmo@kernel.org>
Fixes: 7084566a ("tools/bpftool: Remove libbpf_internal.h usage in bpftool")
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
Link: https://lore.kernel.org/r/20260217194150.734701-1-kuba@kernel.org


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 593fffb8
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -156,7 +156,7 @@ static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,
	bool multipart = true;
	struct nlmsgerr *err;
	struct nlmsghdr *nh;
	char buf[4096];
	char buf[8192];
	int len, ret;

	while (multipart) {
@@ -201,6 +201,9 @@ static int netlink_recv(int sock, __u32 nl_pid, __u32 seq,
					return ret;
			}
		}

		if (len)
			p_err("Invalid message or trailing data in Netlink response: %d bytes left", len);
	}
	ret = 0;
done:
+3 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,
	struct nlmsghdr *nh;
	int len, ret;

	ret = alloc_iov(&iov, 4096);
	ret = alloc_iov(&iov, 8192);
	if (ret)
		goto done;

@@ -212,6 +212,8 @@ static int libbpf_netlink_recv(int sock, __u32 nl_pid, int seq,
				}
			}
		}
		if (len)
			pr_warn("Invalid message or trailing data in Netlink response: %d bytes left\n", len);
	}
	ret = 0;
done: