netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/4] libbpf: Add support for 32-bit static data
@ 2019-02-12  0:47 Joe Stringer
  2019-02-12  0:47 ` [PATCH bpf-next 1/4] libbpf: Refactor relocations Joe Stringer
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Joe Stringer @ 2019-02-12  0:47 UTC (permalink / raw)
  To: bpf; +Cc: netdev, daniel, ast

This series adds support to libbpf for relocating references to 32-bit
static data inside ELF files, both for .data and .bss, similar to one of
the approaches proposed in LPC 2018[0]. This improves a common workflow
for BPF users, where the BPF program may be customised each time it is
loaded, for example to tailor IP addresses for each instance of the
loaded program. Current approaches require full recompilation of the
programs for each load, however with templatized BPF programs, one ELF
template program may be generated, then the static data can be easily
substituted prior to loading into the kernel without invoking the
compiler again.

The approach here is useful for templating limited static data for ELF
programs, and will work regardless of kernel support for static data
sections. Its main limitation is that static data must be defined as
32-bit values in the BPF C input code (or defined using macros that use
32-bit values as the underlying store). The alternative approach
proposed at LPC would be more general and is being actively explored,
however it requires kernel extension and so will not solve this problem
for any existing kernels that are in use today.

There are similar patches floating around for iproute2 which I would
like to upstream as well[1].

[0] https://linuxplumbersconf.org/event/2/contributions/115/
[1] https://github.com/joestringer/iproute2/tree/bss

Joe Stringer (4):
  libbpf: Refactor relocations
  libbpf: Support 32-bit static data loads
  libbpf: Support relocations for bss.
  selftests/bpf: Test static data relocation

 tools/lib/bpf/libbpf.c                        | 108 ++++++++++++------
 tools/testing/selftests/bpf/Makefile          |   2 +-
 tools/testing/selftests/bpf/test_progs.c      |  44 +++++++
 .../selftests/bpf/test_static_data_kern.c     |  47 ++++++++
 4 files changed, 168 insertions(+), 33 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/test_static_data_kern.c

-- 
2.19.1


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

end of thread, other threads:[~2019-02-27 22:43 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12  0:47 [PATCH bpf-next 0/4] libbpf: Add support for 32-bit static data Joe Stringer
2019-02-12  0:47 ` [PATCH bpf-next 1/4] libbpf: Refactor relocations Joe Stringer
2019-02-12  0:47 ` [PATCH bpf-next 2/4] libbpf: Support 32-bit static data loads Joe Stringer
2019-02-15  5:38   ` Y Song
2019-02-15  7:16     ` Joe Stringer
2019-02-15 20:18       ` Y Song
2019-02-27 22:42         ` Y Song
2019-02-15 16:17     ` Alexei Starovoitov
2019-02-12  0:47 ` [PATCH bpf-next 3/4] libbpf: Support relocations for bss Joe Stringer
2019-02-12  0:47 ` [PATCH bpf-next 4/4] selftests/bpf: Test static data relocation Joe Stringer
2019-02-12  5:01   ` Alexei Starovoitov
2019-02-12 20:43     ` Joe Stringer
2019-02-14  0:35       ` Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).