Message ID | 20241009220638.333429-2-wudevelops@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [bpf,v1,1/2] bpf: fix unpopulated path_size when uprobe_multi fields unset | expand |
On Wed, Oct 9, 2024 at 3:07 PM Tyrone Wu <wudevelops@gmail.com> wrote: > > Add assertions in `bpf_link_info.uprobe_multi` test to verify that > `count` and `path_size` fields are correctly populated when the fields > are unset. > > This tests a previous bug where the `path_size` field was not populated > when `path` and `path_size` were unset. > > Signed-off-by: Tyrone Wu <wudevelops@gmail.com> > --- > tools/testing/selftests/bpf/prog_tests/fill_link_info.c | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/tools/testing/selftests/bpf/prog_tests/fill_link_info.c b/tools/testing/selftests/bpf/prog_tests/fill_link_info.c > index f3932941bbaa..a38cf2a999fe 100644 > --- a/tools/testing/selftests/bpf/prog_tests/fill_link_info.c > +++ b/tools/testing/selftests/bpf/prog_tests/fill_link_info.c > @@ -417,6 +417,13 @@ verify_umulti_link_info(int fd, bool retprobe, __u64 *offsets, > if (!ASSERT_NEQ(err, -1, "readlink")) > return -1; > > + memset(&info, 0, sizeof(info)); > + err = bpf_link_get_info_by_fd(fd, &info, &len); if (!ASSERT_OK(err, "link_get_info")) return -1; ? Other than this, LGTM. pw-bot: cr > + > + ASSERT_EQ(info.uprobe_multi.count, 3, "info.uprobe_multi.count"); > + ASSERT_EQ(info.uprobe_multi.path_size, strlen(path) + 1, > + "info.uprobe_multi.path_size"); > + > for (bit = 0; bit < 8; bit++) { > memset(&info, 0, sizeof(info)); > info.uprobe_multi.path = ptr_to_u64(path_buf); > -- > 2.43.0 >
diff --git a/tools/testing/selftests/bpf/prog_tests/fill_link_info.c b/tools/testing/selftests/bpf/prog_tests/fill_link_info.c index f3932941bbaa..a38cf2a999fe 100644 --- a/tools/testing/selftests/bpf/prog_tests/fill_link_info.c +++ b/tools/testing/selftests/bpf/prog_tests/fill_link_info.c @@ -417,6 +417,13 @@ verify_umulti_link_info(int fd, bool retprobe, __u64 *offsets, if (!ASSERT_NEQ(err, -1, "readlink")) return -1; + memset(&info, 0, sizeof(info)); + err = bpf_link_get_info_by_fd(fd, &info, &len); + + ASSERT_EQ(info.uprobe_multi.count, 3, "info.uprobe_multi.count"); + ASSERT_EQ(info.uprobe_multi.path_size, strlen(path) + 1, + "info.uprobe_multi.path_size"); + for (bit = 0; bit < 8; bit++) { memset(&info, 0, sizeof(info)); info.uprobe_multi.path = ptr_to_u64(path_buf);
Add assertions in `bpf_link_info.uprobe_multi` test to verify that `count` and `path_size` fields are correctly populated when the fields are unset. This tests a previous bug where the `path_size` field was not populated when `path` and `path_size` were unset. Signed-off-by: Tyrone Wu <wudevelops@gmail.com> --- tools/testing/selftests/bpf/prog_tests/fill_link_info.c | 7 +++++++ 1 file changed, 7 insertions(+)