1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-22 13:33:56 +03:00

bpf: fix is_allow_list section

The llvm bpf compiler appears to place const volatile variables in
a non-standard section which creates an incompatibility with the gcc
bpf compiler.

To fix this force GCC to also use the rodata section.

Note this does emit an assembler warning:
Generating src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.unstripped.o with a custom command
/tmp/ccM2b7jP.s: Assembler messages:
/tmp/ccM2b7jP.s:87: Warning: setting incorrect section attributes for .rodata

See:
https://github.com/llvm/llvm-project/issues/56468

Fixes:
../src/core/restrict-ifaces.c:45:14: error: ‘struct
restrict_ifaces_bpf’ has no member named ‘rodata’; did you mean
‘data’?
   45 |         obj->rodata->is_allow_list = is_allow_list;
      |              ^~~~~~
      |              data
This commit is contained in:
James Hilliard 2022-08-01 01:11:47 +00:00 committed by Lennart Poettering
parent 00852912ed
commit e8b1e9cf10

View File

@ -6,7 +6,7 @@
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
const volatile __u8 is_allow_list = 0;
const volatile __u8 is_allow_list SEC(".rodata") = 0;
/* Map containing the network interfaces indexes.
* The interpretation of the map depends on the value of is_allow_list.