From 4fa81b6a2da60e7a3ea62282a0fd2812330513aa Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Mon, 1 Aug 2022 01:11:47 +0000 Subject: [PATCH] bpf: fix is_allow_list section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 (cherry picked from commit e8b1e9cf1095f9d6d0f1e2dce2503e25fec2e6c5) (cherry picked from commit cdd3f180b0777e3f94dd1666a7a07a494277beed) --- src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.c b/src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.c index 347a3a8d21..6c960b86f3 100644 --- a/src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.c +++ b/src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.c @@ -6,7 +6,7 @@ #include #include -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.