summaryrefslogtreecommitdiff
path: root/samples/bpf/test_probe_write_user_kern.c
diff options
context:
space:
mode:
authorDaniel T. Lee <danieltimlee@gmail.com>2020-08-23 11:53:33 +0300
committerAlexei Starovoitov <ast@kernel.org>2020-08-25 06:59:35 +0300
commit3677d0a13171bb1dc8db0af84d48dea14a899962 (patch)
tree3de96b317e44d7e1eb175a4be093101f317e88ff /samples/bpf/test_probe_write_user_kern.c
parent35a8b6dd339f04cbcb0b2d085334263542a12b70 (diff)
downloadlinux-3677d0a13171bb1dc8db0af84d48dea14a899962.tar.xz
samples: bpf: Refactor kprobe tracing programs with libbpf
For the problem of increasing fragmentation of the bpf loader programs, instead of using bpf_loader.o, which is used in samples/bpf, this commit refactors the existing kprobe tracing programs with libbbpf bpf loader. - For kprobe events pointing to system calls, the SYSCALL() macro in trace_common.h was used. - Adding a kprobe event and attaching a bpf program to it was done through bpf_program_attach(). - Instead of using the existing BPF MAP definition, MAP definition has been refactored with the new BTF-defined MAP format. Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20200823085334.9413-3-danieltimlee@gmail.com
Diffstat (limited to 'samples/bpf/test_probe_write_user_kern.c')
-rw-r--r--samples/bpf/test_probe_write_user_kern.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/samples/bpf/test_probe_write_user_kern.c b/samples/bpf/test_probe_write_user_kern.c
index fd651a65281e..220a96438d75 100644
--- a/samples/bpf/test_probe_write_user_kern.c
+++ b/samples/bpf/test_probe_write_user_kern.c
@@ -13,12 +13,12 @@
#include <bpf/bpf_core_read.h>
#include "trace_common.h"
-struct bpf_map_def SEC("maps") dnat_map = {
- .type = BPF_MAP_TYPE_HASH,
- .key_size = sizeof(struct sockaddr_in),
- .value_size = sizeof(struct sockaddr_in),
- .max_entries = 256,
-};
+struct {
+ __uint(type, BPF_MAP_TYPE_HASH);
+ __type(key, struct sockaddr_in);
+ __type(value, struct sockaddr_in);
+ __uint(max_entries, 256);
+} dnat_map SEC(".maps");
/* kprobe is NOT a stable ABI
* kernel functions can be removed, renamed or completely change semantics.