multimap-btf.bpf.c 934 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // clang-format off
  2. #include <vmlinux.h>
  3. #include <bpf/bpf_helpers.h>
  4. // clang-format on
  5. struct {
  6. __uint(type, BPF_MAP_TYPE_ARRAY);
  7. __type(key, __u32);
  8. __type(value, __u64);
  9. __uint(max_entries, 1);
  10. } map_1 SEC(".maps");
  11. struct {
  12. __uint(type, BPF_MAP_TYPE_ARRAY);
  13. __type(key, __u32);
  14. __type(value, __u64);
  15. __uint(max_entries, 1);
  16. } map_2 SEC(".maps");
  17. struct {
  18. __uint(type, BPF_MAP_TYPE_ARRAY);
  19. __type(key, __u32);
  20. __type(value, __u64);
  21. __uint(max_entries, 1);
  22. __uint(pinning, LIBBPF_PIN_BY_NAME);
  23. } map_pin_by_name SEC(".maps");
  24. SEC("uprobe")
  25. int bpf_prog(void *ctx) {
  26. __u32 key = 0;
  27. __u64 twenty_four = 24;
  28. __u64 forty_two = 42;
  29. __u64 forty_four = 44;
  30. bpf_map_update_elem(&map_1, &key, &twenty_four, BPF_ANY);
  31. bpf_map_update_elem(&map_2, &key, &forty_two, BPF_ANY);
  32. bpf_map_update_elem(&map_pin_by_name, &key, &forty_four, BPF_ANY);
  33. return 0;
  34. }
  35. char _license[] SEC("license") = "GPL";