All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v2 0/3] samples: bpf: Refactor XDP programs with libbpf
@ 2020-10-10 18:17 Daniel T. Lee
  2020-10-10 18:17 ` [PATCH bpf-next v2 1/3] samples: bpf: Refactor xdp_monitor " Daniel T. Lee
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Daniel T. Lee @ 2020-10-10 18:17 UTC (permalink / raw)
  To: Daniel Borkmann, Alexei Starovoitov, Jesper Dangaard Brouer,
	Andrii Nakryiko, Lorenzo Bianconi
  Cc: bpf, netdev, Xdp

To avoid confusion caused by the increasing fragmentation of the BPF
Loader program, this commit would like to convert the previous bpf_load
loader with the libbpf loader.

Thanks to libbpf's bpf_link interface, managing the tracepoint BPF
program is much easier. bpf_program__attach_tracepoint manages the
enable of tracepoint event and attach of BPF programs to it with a
single interface bpf_link, so there is no need to manage event_fd and
prog_fd separately.

And due to addition of generic bpf_program__attach() to libbpf, it is
now possible to attach BPF programs with __attach() instead of
explicitly calling __attach_<type>().

This patchset refactors xdp_monitor with using this libbpf API, and the
bpf_load is removed and migrated to libbpf. Also, attach_tracepoint()
is replaced with the generic __attach() method in xdp_redirect_cpu.
Moreover, maps in kern program have been converted to BTF-defined map.

---
Changes in v2:
 - added cleanup logic for bpf_link and bpf_object in xdp_monitor
 - program section match with bpf_program__is_<type> instead of strncmp
 - revert BTF key/val type to default of BPF_MAP_TYPE_PERF_EVENT_ARRAY
 - split increment into seperate satement
 - refactor pointer array initialization
 - error code cleanup

Daniel T. Lee (3):
  samples: bpf: Refactor xdp_monitor with libbpf
  samples: bpf: Replace attach_tracepoint() to attach() in
    xdp_redirect_cpu
  samples: bpf: refactor XDP kern program maps with BTF-defined map

 samples/bpf/Makefile                |   4 +-
 samples/bpf/xdp_monitor_kern.c      |  60 +++++------
 samples/bpf/xdp_monitor_user.c      | 159 +++++++++++++++++++++-------
 samples/bpf/xdp_redirect_cpu_user.c | 153 +++++++++++++-------------
 samples/bpf/xdp_sample_pkts_kern.c  |  14 ++-
 samples/bpf/xdp_sample_pkts_user.c  |   1 -
 6 files changed, 230 insertions(+), 161 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread
* [PATCH bpf-next v2 0/3] samples: bpf: Refactor XDP programs with libbpf
@ 2020-10-10 10:44 Daniel T. Lee
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel T. Lee @ 2020-10-10 10:44 UTC (permalink / raw)
  To: Daniel Borkmann, Alexei Starovoitov, Jesper Dangaard Brouer,
	Andrii Nakryiko, Lorenzo Bianconi
  Cc: bpf, netdev, Xdp

To avoid confusion caused by the increasing fragmentation of the BPF
Loader program, this commit would like to convert the previous bpf_load
loader with the libbpf loader.

Thanks to libbpf's bpf_link interface, managing the tracepoint BPF
program is much easier. bpf_program__attach_tracepoint manages the
enable of tracepoint event and attach of BPF programs to it with a
single interface bpf_link, so there is no need to manage event_fd and
prog_fd separately.

And due to addition of generic bpf_program__attach() to libbpf, it is
now possible to attach BPF programs with __attach() instead of
explicitly calling __attach_<type>().

This patchset refactors xdp_monitor with using this libbpf API, and the
bpf_load is removed and migrated to libbpf. Also, attach_tracepoint()
is replaced with the generic __attach() method in xdp_redirect_cpu.
Moreover, maps in kern program have been converted to BTF-defined map.

---
Changes in v2:
 - added cleanup logic for bpf_link and bpf_object in xdp_monitor
 - program section match with bpf_program__is_<type> instead of strncmp
 - revert BTF key/val type to default of BPF_MAP_TYPE_PERF_EVENT_ARRAY
 - split increment into seperate satement
 - refactor pointer array initialization
 - error code cleanup

Daniel T. Lee (3):
  samples: bpf: Refactor xdp_monitor with libbpf
  samples: bpf: Replace attach_tracepoint() to attach() in
    xdp_redirect_cpu
  samples: bpf: refactor XDP kern program maps with BTF-defined map

 samples/bpf/Makefile                |   4 +-
 samples/bpf/xdp_monitor_kern.c      |  60 +++++------
 samples/bpf/xdp_monitor_user.c      | 159 +++++++++++++++++++++-------
 samples/bpf/xdp_redirect_cpu_user.c | 153 +++++++++++++-------------
 samples/bpf/xdp_sample_pkts_kern.c  |  14 ++-
 samples/bpf/xdp_sample_pkts_user.c  |   1 -
 6 files changed, 230 insertions(+), 161 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-10-10 23:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-10 18:17 [PATCH bpf-next v2 0/3] samples: bpf: Refactor XDP programs with libbpf Daniel T. Lee
2020-10-10 18:17 ` [PATCH bpf-next v2 1/3] samples: bpf: Refactor xdp_monitor " Daniel T. Lee
2020-10-10 23:56   ` Andrii Nakryiko
2020-10-10 18:17 ` [PATCH bpf-next v2 2/3] samples: bpf: Replace attach_tracepoint() to attach() in xdp_redirect_cpu Daniel T. Lee
2020-10-10 23:55   ` Andrii Nakryiko
2020-10-10 18:17 ` [PATCH bpf-next v2 3/3] samples: bpf: refactor XDP kern program maps with BTF-defined map Daniel T. Lee
2020-10-10 23:56   ` Andrii Nakryiko
  -- strict thread matches above, loose matches on Subject: below --
2020-10-10 10:44 [PATCH bpf-next v2 0/3] samples: bpf: Refactor XDP programs with libbpf Daniel T. Lee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.