On Wed, Aug 03, 2022 at 09:32:23AM -0700, Stanislav Fomichev wrote: > +static void test_fentry_to_cgroup_bpf(void) > +{ > + struct bind4_prog *skel = NULL; > + struct bpf_prog_info info = {}; > + __u32 info_len = sizeof(info); > + int cgroup_fd = -1; > + int fentry_fd = -1; > + int btf_id; > + > + cgroup_fd = test__join_cgroup("/fentry_to_cgroup_bpf"); > + if (!ASSERT_GE(cgroup_fd, 0, "cgroup_fd")) > + return; > + > + skel = bind4_prog__open_and_load(); > + if (!ASSERT_OK_PTR(skel, "skel")) > + goto cleanup; > + > + skel->links.bind_v4_prog = bpf_program__attach_cgroup(skel->progs.bind_v4_prog, cgroup_fd); > + if (!ASSERT_OK_PTR(skel->links.bind_v4_prog, "bpf_program__attach_cgroup")) > + goto cleanup; > + > + btf_id = find_prog_btf_id("bind_v4_prog", bpf_program__fd(skel->progs.bind_v4_prog)); > + if (!ASSERT_GE(btf_id, 0, "find_prog_btf_id")) > + goto cleanup; > + > + fentry_fd = load_fentry(bpf_program__fd(skel->progs.bind_v4_prog), btf_id); > + if (!ASSERT_GE(fentry_fd, 0, "load_fentry")) > + goto cleanup; > + > + /* Make sure bpf_obj_get_info_by_fd works correctly when attaching > + * to another BPF program. > + */ > + > + ASSERT_OK(bpf_obj_get_info_by_fd(fentry_fd, &info, &info_len), > + "bpf_obj_get_info_by_fd"); > + > + ASSERT_EQ(info.btf_id, 0, "info.btf_id"); > + ASSERT_GT(info.attach_btf_id, 0, "info.attach_btf_id"); > + ASSERT_GT(info.attach_btf_obj_id, 0, "info.attach_btf_obj_id"); nit. This can check against btf_id. Overall lgtm. Thanks. Acked-by: Martin KaFai Lau <kafai@xxxxxx>