samples: bpf: avoid name collision with kernel enum values
Kumar Kartikeya Dwivedi
maintainerPATCH 1/1 samples: bpf: avoid name collision with kernel enum values
In xdp_redirect_map_multi.bpf.c, on newer kernels samples compilation fails when vmlinux.h is generated from a kernel supporting broadcast for devmap. Hence, avoid naming collisions to prevent build failure.
--- samples/bpf/xdp_redirect_map_multi.bpf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
samples/bpf/xdp_redirect_map_multi.bpf.c +4 -3
@@ -6,8 +6,8 @@#include "xdp_sample_shared.h" enum { -BPF_F_BROADCAST = (1ULL <<3 ), -BPF_F_EXCLUDE_INGRESS = (1ULL <<4 ), + __BPF_F_BROADCAST = (1ULL <<3 ), + __BPF_F_EXCLUDE_INGRESS = (1ULL <<4 ), };struct {
@@ -43,7 +43,8 @@ static int xdp_redirect_map(struct xdp_md *ctx, void *forward_map)NO_TEAR_INC (rec->processed);return bpf_redirect_map (forward_map,0 , -BPF_F_BROADCAST |BPF_F_EXCLUDE_INGRESS ); + __BPF_F_BROADCAST | + __BPF_F_EXCLUDE_INGRESS); }SEC ("xdp" )
--
2.33.0
Quoted 3 lines · Kumar Kartikeya Dwivedi
In
xdp_redirect_map_multi.bpf.c, on newer kernels samples compilation fails whenvmlinux.his generated from a kernel supporting broadcast for devmap. Hence, avoid naming collisions to prevent build failure.
Hmm, shouldn't the sample just be getting the value from the kernel in the first place instead of re-defining it?
-Toke
Kumar Kartikeya Dwivedi
maintainerQuoted 9 lines · Toke Høiland-Jørgensen
Quoted 3 lines · Kumar Kartikeya Dwivedi
In
xdp_redirect_map_multi.bpf.c, on newer kernels samples compilation fails whenvmlinux.his generated from a kernel supporting broadcast for devmap. Hence, avoid naming collisions to prevent build failure.Hmm, shouldn't the sample just be getting the value from the kernel in the first place instead of re-defining it?
True, but in general my assumption was that it could be built with a older kernel's vmlinux.h, but be ran on a newer one. If that's not strictly needed, I can just drop it.
This can also be the case if you haven't built the kernel in the tree (just did a make headers_install), it then falls back to generating the vmlinux.h from the running kernel.
Quoted 2 lines
-Toke
--
Kartikeya
Quoted 7 lines · Kumar Kartikeya Dwivedi
Quoted 6 lines · Toke Høiland-Jørgensen
Quoted 3 lines · Kumar Kartikeya Dwivedi
In
xdp_redirect_map_multi.bpf.c, on newer kernels samples compilation fails whenvmlinux.his generated from a kernel supporting broadcast for devmap. Hence, avoid naming collisions to prevent build failure.
Quoted 7 lines
Quoted 3 lines
Hmm, shouldn't the sample just be getting the value from the kernel in the first place instead of re-defining it?
True, but in general my assumption was that it could be built with a older kernel's
vmlinux.h, but be ran on a newer one. If that's not strictly needed, I can just drop it.
But the code is still making assumptions about the contents of vmlinux.h, isn't it? Like the size (and existence) of struct bpf_devmap_val.
Quoted 3 lines
This can also be the case if you haven't built the kernel in the tree (just did a make
headers_install), it then falls back to generating thevmlinux.hfrom the running kernel.
This seems a bit brittle. Given that the samples are distributed with the kernel sources, I would expect them to always correspond to the kernel version in the source tree they're in and not randomly break if the running kernel is different...
-Toke