]> git.baikalelectronics.ru Git - kernel.git/commit
tools/bpf: fix a netlink recv issue
authorYonghong Song <yhs@fb.com>
Tue, 11 Sep 2018 21:09:11 +0000 (14:09 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 11 Sep 2018 21:26:30 +0000 (14:26 -0700)
commit42d63d15f097e03ffd265aae5a19f4ff5057c356
treeb5cca3c959f55bd55798f13f7f55cbbc7e54949c
parent9a66c1cb05002f203ff8b7978700c0ae9f2fb21a
tools/bpf: fix a netlink recv issue

Commit 640ff3c6bfb0 ("tools/bpf: move bpf/lib netlink related
functions into a new file") introduced a while loop for the
netlink recv path. This while loop is needed since the
buffer in recv syscall may not be enough to hold all the
information and in such cases multiple recv calls are needed.

There is a bug introduced by the above commit as
the while loop may block on recv syscall if there is no
more messages are expected. The netlink message header
flag NLM_F_MULTI is used to indicate that more messages
are expected and this patch fixed the bug by doing
further recv syscall only if multipart message is expected.

The patch added another fix regarding to message length of 0.
When netlink recv returns message length of 0, there will be
no more messages for returning data so the while loop
can end.

Fixes: 640ff3c6bfb0 ("tools/bpf: move bpf/lib netlink related functions into a new file")
Reported-by: Björn Töpel <bjorn.topel@intel.com>
Tested-by: Björn Töpel <bjorn.topel@intel.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/netlink.c