aboutsummaryrefslogtreecommitdiff
path: root/samples/bpf/sampleip_kern.c
diff options
context:
space:
mode:
authorDaniel T. Lee2020-05-16 13:06:08 +0900
committerDaniel Borkmann2020-05-19 17:13:03 +0200
commit59929cd1fec508a48ea2a04d8f2e4fdef907a2cd (patch)
tree2daef9645a717e2ad5ac0dbdfc89e92cd0738adf /samples/bpf/sampleip_kern.c
parent14846dda634e28cc0430f1fbbfa6c758a2e5f873 (diff)
samples, bpf: Refactor kprobe, tail call kern progs map definition
Because the previous two commit replaced the bpf_load implementation of the user program with libbpf, the corresponding kernel program's MAP definition can be replaced with new BTF-defined map syntax. This commit only updates the samples which uses libbpf API for loading bpf program not with bpf_load. Signed-off-by: Daniel T. Lee <danieltimlee@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20200516040608.1377876-6-danieltimlee@gmail.com
Diffstat (limited to 'samples/bpf/sampleip_kern.c')
-rw-r--r--samples/bpf/sampleip_kern.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/samples/bpf/sampleip_kern.c b/samples/bpf/sampleip_kern.c
index e504dc308371..f24806ac24e7 100644
--- a/samples/bpf/sampleip_kern.c
+++ b/samples/bpf/sampleip_kern.c
@@ -13,12 +13,12 @@
#define MAX_IPS 8192
-struct bpf_map_def SEC("maps") ip_map = {
- .type = BPF_MAP_TYPE_HASH,
- .key_size = sizeof(u64),
- .value_size = sizeof(u32),
- .max_entries = MAX_IPS,
-};
+struct {
+ __uint(type, BPF_MAP_TYPE_HASH);
+ __type(key, u64);
+ __type(value, u32);
+ __uint(max_entries, MAX_IPS);
+} ip_map SEC(".maps");
SEC("perf_event")
int do_sample(struct bpf_perf_event_data *ctx)