Re: [PATCH v3 bpf-next 16/18] libbpf: Add support for attaching BPF programs to other BPF programs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On Nov 7, 2019, at 10:40 PM, Alexei Starovoitov <ast@xxxxxxxxxx> wrote:
> 
> Extend libbpf api to pass attach_prog_fd into bpf_object__open.
> 
> Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
> ---

[...]

> +static int libbpf_find_prog_btf_id(const char *name, __u32 attach_prog_fd)
> +{
> +	struct bpf_prog_info_linear *info_linear;
> +	struct bpf_prog_info *info;
> +	struct btf *btf = NULL;
> +	int err = -EINVAL;
> +
> +	info_linear = bpf_program__get_prog_info_linear(attach_prog_fd, 0);
> +	if (IS_ERR_OR_NULL(info_linear)) {
> +		pr_warn("failed get_prog_info_linear for FD %d\n",
> +			attach_prog_fd);
> +		return -EINVAL;
> +	}
> +	info = &info_linear->info;
> +	if (!info->btf_id) {
> +		pr_warn("The target program doesn't have BTF\n");
> +		goto out;
> +	}
> +	if (btf__get_from_id(info->btf_id, &btf)) {
> +		pr_warn("Failed to get BTF of the program\n");
> +		goto out;
> +	}
> +	err = btf__find_by_name_kind(btf, name, BTF_KIND_FUNC);
> +	btf__free(btf);
> +	if (err <= 0) {
> +		pr_warn("%s is not found in prog's BTF\n", name);
> +		goto out;
		^^^ This goto doesn't really do much. 
> +	}
> +out:
> +	free(info_linear);
> +	return err;
> +}

Otherwise

Acked-by: Song Liu <songliubraving@xxxxxx>





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux