[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEf4BzZmkR80AF-gz6NyLH21q=un1Wfpobo=TwpahX+YJ-t3ww@mail.gmail.com>
Date: Fri, 20 Nov 2020 10:25:21 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Martin KaFai Lau <kafai@...com>
Cc: Andrii Nakryiko <andrii@...nel.org>, bpf <bpf@...r.kernel.org>,
Networking <netdev@...r.kernel.org>,
Alexei Starovoitov <ast@...com>,
Daniel Borkmann <daniel@...earbox.net>,
Kernel Team <kernel-team@...com>
Subject: Re: [PATCH bpf-next 2/6] libbpf: add internal helper to load BTF data
by FD
On Fri, Nov 20, 2020 at 10:20 AM Martin KaFai Lau <kafai@...com> wrote:
>
> On Thu, Nov 19, 2020 at 03:22:40PM -0800, Andrii Nakryiko wrote:
> [ ... ]
>
> > +int btf__get_from_id(__u32 id, struct btf **btf)
> > +{
> > + struct btf *res;
> > + int btf_fd;
> > +
> > + *btf = NULL;
> > + btf_fd = bpf_btf_get_fd_by_id(id);
> > + if (btf_fd < 0)
> > + return 0;
> It should return an error.
>
That would break the original behavior with (ret == 0 && btf == NULL),
but I think it's more consistent, so I'll fix this and will add Fixes:
tag.
> > +
> > + res = btf_get_from_fd(btf_fd, NULL);
> > + close(btf_fd);
> > + if (IS_ERR(res))
> > + return PTR_ERR(res);
> > +
> > + *btf = res;
> > + return 0;
> > }
> >
Powered by blists - more mailing lists