mbox series

[bpf-next,v4,0/3] bpf: implement link_query for bpf iterators

Message ID 20200821184418.574065-1-yhs@fb.com
Headers show
Series bpf: implement link_query for bpf iterators | expand

Message

Yonghong Song Aug. 21, 2020, 6:44 p.m. UTC
"link" has been an important concept for bpf ecosystem to connect
bpf program with other properties. Currently, the information related
information can be queried from userspace through bpf command
BPF_LINK_GET_NEXT_ID, BPF_LINK_GET_FD_BY_ID and BPF_OBJ_GET_INFO_BY_FD.
The information is also available by "cating" /proc/<pid>/fdinfo/<link_fd>.
Raw_tracepoint, tracing, cgroup, netns and xdp links are already
supported in the kernel and bpftool.

This patch added support for bpf iterator. Patch #1 added generic support
for link querying interface. Patch #2 implemented callback functions
for map element bpf iterators. Patch #3 added bpftool support.

Changelogs:
  v3 -> v4:
    . return target specific link_info even if target_name buffer
      is empty. (Andrii)
  v2 -> v3:
    . remove extra '\t' when fdinfo prints map_id to make parsing
      consistent. (Andrii)
  v1 -> v2:
    . fix checkpatch.pl warnings. (Jakub)

Yonghong Song (3):
  bpf: implement link_query for bpf iterators
  bpf: implement link_query callbacks in map element iterators
  bpftool: implement link_query for bpf iterators

 include/linux/bpf.h            | 10 ++++++
 include/uapi/linux/bpf.h       |  7 ++++
 kernel/bpf/bpf_iter.c          | 58 ++++++++++++++++++++++++++++++++++
 kernel/bpf/map_iter.c          | 15 +++++++++
 net/core/bpf_sk_storage.c      |  2 ++
 tools/bpf/bpftool/link.c       | 44 ++++++++++++++++++++++++--
 tools/include/uapi/linux/bpf.h |  7 ++++
 7 files changed, 140 insertions(+), 3 deletions(-)

Comments

Andrii Nakryiko Aug. 21, 2020, 7:04 p.m. UTC | #1
On Fri, Aug 21, 2020 at 11:44 AM Yonghong Song <yhs@fb.com> wrote:
>
> "link" has been an important concept for bpf ecosystem to connect
> bpf program with other properties. Currently, the information related
> information can be queried from userspace through bpf command
> BPF_LINK_GET_NEXT_ID, BPF_LINK_GET_FD_BY_ID and BPF_OBJ_GET_INFO_BY_FD.
> The information is also available by "cating" /proc/<pid>/fdinfo/<link_fd>.
> Raw_tracepoint, tracing, cgroup, netns and xdp links are already
> supported in the kernel and bpftool.
>
> This patch added support for bpf iterator. Patch #1 added generic support
> for link querying interface. Patch #2 implemented callback functions
> for map element bpf iterators. Patch #3 added bpftool support.
>
> Changelogs:
>   v3 -> v4:
>     . return target specific link_info even if target_name buffer
>       is empty. (Andrii)
>   v2 -> v3:
>     . remove extra '\t' when fdinfo prints map_id to make parsing
>       consistent. (Andrii)
>   v1 -> v2:
>     . fix checkpatch.pl warnings. (Jakub)
>
> Yonghong Song (3):
>   bpf: implement link_query for bpf iterators
>   bpf: implement link_query callbacks in map element iterators
>   bpftool: implement link_query for bpf iterators
>
>  include/linux/bpf.h            | 10 ++++++
>  include/uapi/linux/bpf.h       |  7 ++++
>  kernel/bpf/bpf_iter.c          | 58 ++++++++++++++++++++++++++++++++++
>  kernel/bpf/map_iter.c          | 15 +++++++++
>  net/core/bpf_sk_storage.c      |  2 ++
>  tools/bpf/bpftool/link.c       | 44 ++++++++++++++++++++++++--
>  tools/include/uapi/linux/bpf.h |  7 ++++
>  7 files changed, 140 insertions(+), 3 deletions(-)
>
> --
> 2.24.1
>

LGTM, thanks.

Acked-by: Andrii Nakryiko <andriin@fb.com>
Alexei Starovoitov Aug. 21, 2020, 9:17 p.m. UTC | #2
On Fri, Aug 21, 2020 at 12:04 PM Andrii Nakryiko
<andrii.nakryiko@gmail.com> wrote:
>
> On Fri, Aug 21, 2020 at 11:44 AM Yonghong Song <yhs@fb.com> wrote:
> >
> > "link" has been an important concept for bpf ecosystem to connect
> > bpf program with other properties. Currently, the information related
> > information can be queried from userspace through bpf command
> > BPF_LINK_GET_NEXT_ID, BPF_LINK_GET_FD_BY_ID and BPF_OBJ_GET_INFO_BY_FD.
> > The information is also available by "cating" /proc/<pid>/fdinfo/<link_fd>.
> > Raw_tracepoint, tracing, cgroup, netns and xdp links are already
> > supported in the kernel and bpftool.
> >
> > This patch added support for bpf iterator. Patch #1 added generic support
> > for link querying interface. Patch #2 implemented callback functions
> > for map element bpf iterators. Patch #3 added bpftool support.
> >
> > Changelogs:
> >   v3 -> v4:
> >     . return target specific link_info even if target_name buffer
> >       is empty. (Andrii)
> >   v2 -> v3:
> >     . remove extra '\t' when fdinfo prints map_id to make parsing
> >       consistent. (Andrii)
> >   v1 -> v2:
> >     . fix checkpatch.pl warnings. (Jakub)
> >
> > Yonghong Song (3):
> >   bpf: implement link_query for bpf iterators
> >   bpf: implement link_query callbacks in map element iterators
> >   bpftool: implement link_query for bpf iterators
> >
> >  include/linux/bpf.h            | 10 ++++++
> >  include/uapi/linux/bpf.h       |  7 ++++
> >  kernel/bpf/bpf_iter.c          | 58 ++++++++++++++++++++++++++++++++++
> >  kernel/bpf/map_iter.c          | 15 +++++++++
> >  net/core/bpf_sk_storage.c      |  2 ++
> >  tools/bpf/bpftool/link.c       | 44 ++++++++++++++++++++++++--
> >  tools/include/uapi/linux/bpf.h |  7 ++++
> >  7 files changed, 140 insertions(+), 3 deletions(-)
> >
> > --
> > 2.24.1
> >
>
> LGTM, thanks.
>
> Acked-by: Andrii Nakryiko <andriin@fb.com>

Applied. Thanks