4
0

variables_reloc.bpf.c 461 B

123456789101112131415161718192021
  1. // clang-format off
  2. #include <vmlinux.h>
  3. #include <bpf/bpf_helpers.h>
  4. // clang-format on
  5. volatile unsigned int key1 = 0; // .bss
  6. volatile unsigned int key2 = 1; // .data
  7. volatile const unsigned int key3 = 2; // .rodata
  8. SEC("xdp")
  9. int variables_reloc(struct xdp_md *ctx) {
  10. if (key1 == 0 && key2 != 1 && key3 != 2) {
  11. key1 += 1;
  12. key2 += 1;
  13. return XDP_DROP;
  14. } else {
  15. return XDP_PASS;
  16. }
  17. }
  18. char _license[] SEC("license") = "GPL";