libbpf: Add setter for initial value for internal maps
authorToke Høiland-Jørgensen <toke@redhat.com>
Sun, 29 Mar 2020 13:22:52 +0000 (15:22 +0200)
committerDaniel Borkmann <daniel@iogearbox.net>
Sun, 29 Mar 2020 23:17:05 +0000 (01:17 +0200)
commite2842be53d4f31962a9992eab39391cdf637fa2e
tree9c448a2ad2a0e7dc392015e97a0fbd247dd6a7b6
parent5a95cbb80ef8d8f2db29ab10777cd4742e6fc8ec
libbpf: Add setter for initial value for internal maps

For internal maps (most notably the maps backing global variables), libbpf
uses an internal mmaped area to store the data after opening the object.
This data is subsequently copied into the kernel map when the object is
loaded.

This adds a function to set a new value for that data, which can be used to
before it is loaded into the kernel. This is especially relevant for RODATA
maps, since those are frozen on load.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200329132253.232541-1-toke@redhat.com
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf.h
tools/lib/bpf/libbpf.map