diff --git a/backends/ebpf/runtime/ebpf_kernel.h b/backends/ebpf/runtime/ebpf_kernel.h index 6813c0affc..f63a17db24 100644 --- a/backends/ebpf/runtime/ebpf_kernel.h +++ b/backends/ebpf/runtime/ebpf_kernel.h @@ -23,6 +23,7 @@ limitations under the License. #include "ebpf_common.h" +#include // Exports BPF_ANNOTATE_KV_PAIR in newer versions. #include // definitions for bpf_ntohs etc... #undef htonl @@ -79,6 +80,9 @@ struct bpf_elf_map { /// Simple descriptor which replaces the kernel sk_buff structure. #define SK_BUFF struct __sk_buff + +#define REGISTER_START() +#ifndef BPF_ANNOTATE_KV_PAIR /// From iproute2, annotate table with BTF which allows to read types at runtime. #define BPF_ANNOTATE_KV_PAIR(name, type_key, type_val) \ struct ____btf_map_##name { \ @@ -89,8 +93,6 @@ struct bpf_elf_map { __attribute__ ((section(".maps." #name), used)) \ ____btf_map_##name = {}; -#define REGISTER_START() -#ifndef BTF /// Note: pinning exports the table name globally, do not remove. #define REGISTER_TABLE(NAME, TYPE, KEY_TYPE, VALUE_TYPE, MAX_ENTRIES) \ struct bpf_elf_map SEC("maps") NAME = { \ diff --git a/testdata/extern_modules/extern-conntrack-ebpf.c b/testdata/extern_modules/extern-conntrack-ebpf.c index 2b90d0a3b7..f5046fd6b8 100644 --- a/testdata/extern_modules/extern-conntrack-ebpf.c +++ b/testdata/extern_modules/extern-conntrack-ebpf.c @@ -29,7 +29,7 @@ struct connInfo { }; REGISTER_START() -REGISTER_TABLE(tcp_reg, BPF_MAP_TYPE_HASH, sizeof(u32), sizeof(struct connInfo), MAX_ENTRIES) +REGISTER_TABLE(tcp_reg, BPF_MAP_TYPE_HASH, u32, struct connInfo, MAX_ENTRIES) REGISTER_END() static inline u8 tcp_conntrack(struct Headers_t hdrs)