diff --git a/bpf/cilium-map-migrate.c b/bpf/cilium-map-migrate.c index 2efbd5c6a85c..2b050cb7f5d9 100644 --- a/bpf/cilium-map-migrate.c +++ b/bpf/cilium-map-migrate.c @@ -49,7 +49,7 @@ #include "elf/libelf.h" #include "elf/gelf.h" -#include "iproute2/bpf_elf.h" +#include "bpf/api.h" #ifndef EM_BPF # define EM_BPF 247 @@ -513,7 +513,7 @@ static int bpf_check_ancillary(struct bpf_elf_ctx *ctx, bpf_handle_state_t cb, if (ret < 0) continue; if (data.sec_hdr.sh_type == SHT_PROGBITS && - !strcmp(data.sec_name, ELF_SECTION_MAPS)) + !strcmp(data.sec_name, "maps")) ret = bpf_fetch_maps_begin(ctx, i, &data); else if (data.sec_hdr.sh_type == SHT_SYMTAB && !strcmp(data.sec_name, ".symtab")) diff --git a/bpf/include/bpf/api.h b/bpf/include/bpf/api.h index 6a512cd3e9a4..6b7537e9ba6f 100644 --- a/bpf/include/bpf/api.h +++ b/bpf/include/bpf/api.h @@ -1,217 +1,49 @@ -#ifndef __BPF_API__ -#define __BPF_API__ - -/* Note: +/* + * Copyright (C) 2016-2020 Authors of Cilium + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * This file can be included into eBPF kernel programs. It contains - * a couple of useful helper functions, map/section ABI (bpf_elf.h), - * misc macros and some eBPF specific LLVM built-ins. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef __BPF_API__ +#define __BPF_API__ #include #include -#include #include - -#include +#include #include "compiler.h" - -#ifndef TC_ACT_OK -#define TC_ACT_OK 0 -#define TC_ACT_RECLASSIFY 1 -#define TC_ACT_SHOT 2 -#define TC_ACT_PIPE 3 -#define TC_ACT_STOLEN 4 -#define TC_ACT_QUEUED 5 -#define TC_ACT_REPEAT 6 -#define TC_ACT_REDIRECT 7 -#endif - -/** Section helper macros. */ - -#ifndef __section -# define __section(NAME) \ - __attribute__((section(NAME), used)) -#endif - -#ifndef __section_tail -# define __section_tail(ID, KEY) \ - __section(__stringify(ID) "/" __stringify(KEY)) -#endif - -#ifndef __section_cls_entry -# define __section_cls_entry \ - __section(ELF_SECTION_CLASSIFIER) -#endif - -#ifndef __section_act_entry -# define __section_act_entry \ - __section(ELF_SECTION_ACTION) -#endif - -#ifndef __section_license -# define __section_license \ - __section(ELF_SECTION_LICENSE) -#endif - -#ifndef __section_maps -# define __section_maps \ - __section(ELF_SECTION_MAPS) -#endif - -/** Declaration helper macros. */ - -#ifndef BPF_LICENSE -# define BPF_LICENSE(NAME) \ - char ____license[] __section_license = NAME -#endif - -/** Classifier helper */ - -#ifndef BPF_H_DEFAULT -# define BPF_H_DEFAULT -1 -#endif - -/** BPF helper functions for tc. Individual flags are in linux/bpf.h */ - -#ifndef BPF_FUNC -# define BPF_FUNC(NAME, ...) \ - (* NAME)(__VA_ARGS__) __maybe_unused = (void *) BPF_FUNC_##NAME -#endif - -#ifndef BPF_FUNC2 -# define BPF_FUNC2(NAME, ...) \ - (* NAME)(__VA_ARGS__) __maybe_unused -#endif - -/* Map access/manipulation */ -static void *BPF_FUNC(map_lookup_elem, void *map, const void *key); -static int BPF_FUNC(map_update_elem, void *map, const void *key, - const void *value, __u32 flags); -static int BPF_FUNC(map_delete_elem, void *map, const void *key); - -/* Time access */ -static __u64 BPF_FUNC(ktime_get_ns); - -/* Sockets */ -static __u64 BPF_FUNC(get_socket_cookie, void *ctx); - -/* Debugging */ - -__attribute__((__format__(__printf__, 1, 3))) -static void BPF_FUNC(trace_printk, const char *fmt, int fmt_size, ...); - -#ifndef printt -# define printt(fmt, ...) \ - ({ \ - trace_printk(____fmt, ##__VA_ARGS__); \ - }) -#endif - -/* Random numbers */ -static __u32 BPF_FUNC(get_prandom_u32); - -/* Tail calls */ -static void BPF_FUNC(tail_call, struct __sk_buff *skb, void *map, - __u32 index); - -/* System helpers */ -static __u32 BPF_FUNC(get_smp_processor_id); - -/* Packet misc meta data */ -static __u32 BPF_FUNC(get_cgroup_classid, struct __sk_buff *skb); -static __u32 BPF_FUNC(get_route_realm, struct __sk_buff *skb); -static __u32 BPF_FUNC(get_hash_recalc, struct __sk_buff *skb); -static __u32 BPF_FUNC(set_hash_invalid, struct __sk_buff *skb); - -static int BPF_FUNC(skb_under_cgroup, void *map, __u32 index); - -/* Packet redirection */ -static int BPF_FUNC(redirect, int ifindex, __u32 flags); -static int BPF_FUNC(clone_redirect, struct __sk_buff *skb, int ifindex, - __u32 flags); - -/* Packet manipulation */ -static int BPF_FUNC(skb_load_bytes_relative, struct __sk_buff *skb, __u32 off, - void *to, __u32 len, __u32 hdr); -static int BPF_FUNC(skb_load_bytes, struct __sk_buff *skb, __u32 off, - void *to, __u32 len); -static int BPF_FUNC(skb_store_bytes, struct __sk_buff *skb, __u32 off, - const void *from, __u32 len, __u32 flags); -static int BPF_FUNC(skb_adjust_room, struct __sk_buff *skb, __s32 len_diff, - __u32 mode, __u64 flags); - -static int BPF_FUNC(l3_csum_replace, struct __sk_buff *skb, __u32 off, - __u32 from, __u32 to, __u32 flags); -static int BPF_FUNC(l4_csum_replace, struct __sk_buff *skb, __u32 off, - __u32 from, __u32 to, __u32 flags); -static int BPF_FUNC(csum_diff, void *from, __u32 from_size, void *to, - __u32 to_size, __u32 seed); - -static int BPF_FUNC(skb_change_type, struct __sk_buff *skb, __u32 type); -static int BPF_FUNC(skb_change_proto, struct __sk_buff *skb, __u32 proto, - __u32 flags); -static int BPF_FUNC(skb_change_tail, struct __sk_buff *skb, __u32 nlen, - __u32 flags); -static int BPF_FUNC(skb_pull_data, struct __sk_buff *skb, __u32 len); - -/* Packet vlan encap/decap */ -static int BPF_FUNC(skb_vlan_push, struct __sk_buff *skb, __u16 proto, - __u16 vlan_tci); -static int BPF_FUNC(skb_vlan_pop, struct __sk_buff *skb); - -/* Packet tunnel encap/decap */ -static int BPF_FUNC(skb_get_tunnel_key, struct __sk_buff *skb, - struct bpf_tunnel_key *to, __u32 size, __u32 flags); -static int BPF_FUNC(skb_set_tunnel_key, struct __sk_buff *skb, - const struct bpf_tunnel_key *from, __u32 size, - __u32 flags); - -static int BPF_FUNC(skb_get_tunnel_opt, struct __sk_buff *skb, - void *to, __u32 size); -static int BPF_FUNC(skb_set_tunnel_opt, struct __sk_buff *skb, - const void *from, __u32 size); - -/* Events for user space */ -static int BPF_FUNC2(skb_event_output, struct __sk_buff *skb, void *map, __u64 index, - const void *data, __u32 size) = (void *)BPF_FUNC_perf_event_output; -static int BPF_FUNC2(xdp_event_output, struct xdp_md *xdp, void *map, __u64 index, - const void *data, __u32 size) = (void *)BPF_FUNC_perf_event_output; - -/* Sockops and SK_MSG helpers */ -static int BPF_FUNC(sock_map_update, struct bpf_sock_ops *skops, void *map, __u32 key, __u64 flags); -static int BPF_FUNC(sock_hash_update, struct bpf_sock_ops *skops, void *map, void *key, __u64 flags); -static int BPF_FUNC(msg_redirect_hash, struct sk_msg_md *md, void *map, void *key, __u64 flags); - -static int BPF_FUNC(fib_lookup, void *ctx, struct bpf_fib_lookup *params, __u32 plen, __u32 flags); - -/** LLVM built-ins, mem*() routines work for constant size */ - -#ifndef lock_xadd -# define lock_xadd(ptr, val) ((void) __sync_fetch_and_add(ptr, val)) -#endif - -#ifndef memset -# define memset(s, c, n) __builtin_memset((s), (c), (n)) -#endif - -#ifndef memcpy -# define memcpy(d, s, n) __builtin_memcpy((d), (s), (n)) -#endif - -#ifndef memmove -# define memmove(d, s, n) __builtin_memmove((d), (s), (n)) -#endif - -/* FIXME: __builtin_memcmp() is not yet fully useable unless llvm bug - * https://llvm.org/bugs/show_bug.cgi?id=26218 gets resolved. Also - * this one would generate a reloc entry (non-map), otherwise. - */ -#if 0 -#ifndef memcmp -# define memcmp(a, b, n) __builtin_memcmp((a), (b), (n)) -#endif -#endif +#include "section.h" +#include "helpers.h" +#include "builtins.h" + +#define PIN_NONE 0 +#define PIN_OBJECT_NS 1 +#define PIN_GLOBAL_NS 2 + +struct bpf_elf_map { + __u32 type; + __u32 size_key; + __u32 size_value; + __u32 max_elem; + __u32 flags; + __u32 id; + __u32 pinning; +#ifdef SOCKMAP + __u32 inner_id; + __u32 inner_idx; +#endif +}; #endif /* __BPF_API__ */ diff --git a/bpf/include/bpf/builtins.h b/bpf/include/bpf/builtins.h new file mode 100644 index 000000000000..2cb96d4d9048 --- /dev/null +++ b/bpf/include/bpf/builtins.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2016-2020 Authors of Cilium + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __BPF_BUILTINS__ +#define __BPF_BUILTINS__ + +#include "compiler.h" + +#ifndef lock_xadd +# define lock_xadd(P, V) ((void) __sync_fetch_and_add((P), (V))) +#endif + +#ifndef memset +# define memset(S, C, N) __builtin_memset((S), (C), (N)) +#endif + +#ifndef memcpy +# define memcpy(D, S, N) __builtin_memcpy((D), (S), (N)) +#endif + +#ifndef memmove +# define memmove(D, S, N) __builtin_memmove((D), (S), (N)) +#endif + +/* NOTE: https://llvm.org/bugs/show_bug.cgi?id=26218 */ +#ifndef memcmp +# define memcmp(A, B, N) __builtin_memcmp((A), (B), (N)) +#endif + +#endif /* __BPF_BUILTINS__ */ diff --git a/bpf/include/bpf/compiler.h b/bpf/include/bpf/compiler.h index d0ef09b7507a..d1c5d7699d16 100644 --- a/bpf/include/bpf/compiler.h +++ b/bpf/include/bpf/compiler.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2020 Authors of Cilium + * Copyright (C) 2016-2020 Authors of Cilium * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,10 @@ #include #include +#ifndef __section +# define __section(X) __attribute__((section(X), used)) +#endif + #ifndef __maybe_unused # define __maybe_unused __attribute__((__unused__)) #endif @@ -56,6 +60,10 @@ # define build_bug_on(E) ((void)sizeof(char[1 - 2*!!(E)])) #endif +#ifndef __printf +# define __printf(X, Y) __attribute__((__format__(printf, X, Y))) +#endif + static __always_inline void bpf_barrier(void) { /* Workaround to avoid verifier complaint: diff --git a/bpf/include/bpf/ctx/skb.h b/bpf/include/bpf/ctx/skb.h index bd551a0ab61e..ee03381ba8b1 100644 --- a/bpf/include/bpf/ctx/skb.h +++ b/bpf/include/bpf/ctx/skb.h @@ -20,6 +20,18 @@ #include "common.h" +#ifndef TC_ACT_OK +# define TC_ACT_OK 0 +#endif + +#ifndef TC_ACT_SHOT +# define TC_ACT_SHOT 2 +#endif + +#ifndef TC_ACT_REDIRECT +# define TC_ACT_REDIRECT 7 +#endif + #define __ctx_buff __sk_buff #define CTX_ACT_OK TC_ACT_OK diff --git a/bpf/include/bpf/helpers.h b/bpf/include/bpf/helpers.h new file mode 100644 index 000000000000..7947f88d008e --- /dev/null +++ b/bpf/include/bpf/helpers.h @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2016-2020 Authors of Cilium + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __BPF_HELPERS__ +#define __BPF_HELPERS__ + +#include + +#include "compiler.h" + +#ifndef BPF_FUNC +# define BPF_FUNC(NAME, ...) \ + (* NAME)(__VA_ARGS__) __maybe_unused = (void *)BPF_FUNC_##NAME +#endif + +#ifndef BPF_FUNC_REMAP +# define BPF_FUNC_REMAP(NAME, ...) \ + (* NAME)(__VA_ARGS__) __maybe_unused +#endif + +#include "helpers_skb.h" +#include "helpers_xdp.h" + +/* Map access/manipulation */ +static void *BPF_FUNC(map_lookup_elem, void *map, const void *key); +static int BPF_FUNC(map_update_elem, void *map, const void *key, + const void *value, __u32 flags); +static int BPF_FUNC(map_delete_elem, void *map, const void *key); + +/* Time access */ +static __u64 BPF_FUNC(ktime_get_ns); + +/* Sockets */ +static __u64 BPF_FUNC(get_socket_cookie, void *ctx); + +/* Debugging */ +static __printf(1,3) void BPF_FUNC(trace_printk, const char *fmt, int fmt_size, ...); + +#ifndef printt +# define printt(fmt, ...) \ + ({ \ + trace_printk(____fmt, ##__VA_ARGS__); \ + }) +#endif + +/* Random numbers */ +static __u32 BPF_FUNC(get_prandom_u32); + +/* Checksumming */ +static int BPF_FUNC(csum_diff, void *from, __u32 from_size, void *to, + __u32 to_size, __u32 seed); + +/* Tail calls */ +static void BPF_FUNC(tail_call, void *ctx, void *map, __u32 index); + +/* System helpers */ +static __u32 BPF_FUNC(get_smp_processor_id); + +/* Routing helpers */ +static int BPF_FUNC(fib_lookup, void *ctx, struct bpf_fib_lookup *params, + __u32 plen, __u32 flags); + +/* Sockops and SK_MSG helpers */ +static int BPF_FUNC(sock_map_update, struct bpf_sock_ops *skops, void *map, + __u32 key, __u64 flags); +static int BPF_FUNC(sock_hash_update, struct bpf_sock_ops *skops, void *map, + void *key, __u64 flags); +static int BPF_FUNC(msg_redirect_hash, struct sk_msg_md *md, void *map, + void *key, __u64 flags); + +#endif /* __BPF_HELPERS__ */ diff --git a/bpf/include/bpf/helpers_skb.h b/bpf/include/bpf/helpers_skb.h new file mode 100644 index 000000000000..266cb02e01f9 --- /dev/null +++ b/bpf/include/bpf/helpers_skb.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2016-2020 Authors of Cilium + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __BPF_HELPERS_SKB__ +#define __BPF_HELPERS_SKB__ + +#include + +#include "compiler.h" +#include "helpers.h" + +/* Packet misc meta data */ +static __u32 BPF_FUNC(get_cgroup_classid, struct __sk_buff *skb); +static __u32 BPF_FUNC(get_route_realm, struct __sk_buff *skb); +static __u32 BPF_FUNC(get_hash_recalc, struct __sk_buff *skb); +static __u32 BPF_FUNC(set_hash_invalid, struct __sk_buff *skb); + +static int BPF_FUNC(skb_under_cgroup, void *map, __u32 index); + +/* Packet redirection */ +static int BPF_FUNC(redirect, int ifindex, __u32 flags); +static int BPF_FUNC(clone_redirect, struct __sk_buff *skb, int ifindex, + __u32 flags); + +/* Packet manipulation */ +static int BPF_FUNC(skb_load_bytes_relative, struct __sk_buff *skb, __u32 off, + void *to, __u32 len, __u32 hdr); +static int BPF_FUNC(skb_load_bytes, struct __sk_buff *skb, __u32 off, + void *to, __u32 len); +static int BPF_FUNC(skb_store_bytes, struct __sk_buff *skb, __u32 off, + const void *from, __u32 len, __u32 flags); +static int BPF_FUNC(skb_adjust_room, struct __sk_buff *skb, __s32 len_diff, + __u32 mode, __u64 flags); + +static int BPF_FUNC(l3_csum_replace, struct __sk_buff *skb, __u32 off, + __u32 from, __u32 to, __u32 flags); +static int BPF_FUNC(l4_csum_replace, struct __sk_buff *skb, __u32 off, + __u32 from, __u32 to, __u32 flags); + +static int BPF_FUNC(skb_change_type, struct __sk_buff *skb, __u32 type); +static int BPF_FUNC(skb_change_proto, struct __sk_buff *skb, __u32 proto, + __u32 flags); +static int BPF_FUNC(skb_change_tail, struct __sk_buff *skb, __u32 nlen, + __u32 flags); +static int BPF_FUNC(skb_pull_data, struct __sk_buff *skb, __u32 len); + +/* Packet vlan encap/decap */ +static int BPF_FUNC(skb_vlan_push, struct __sk_buff *skb, __u16 proto, + __u16 vlan_tci); +static int BPF_FUNC(skb_vlan_pop, struct __sk_buff *skb); + +/* Packet tunnel encap/decap */ +static int BPF_FUNC(skb_get_tunnel_key, struct __sk_buff *skb, + struct bpf_tunnel_key *to, __u32 size, __u32 flags); +static int BPF_FUNC(skb_set_tunnel_key, struct __sk_buff *skb, + const struct bpf_tunnel_key *from, __u32 size, + __u32 flags); + +static int BPF_FUNC(skb_get_tunnel_opt, struct __sk_buff *skb, + void *to, __u32 size); +static int BPF_FUNC(skb_set_tunnel_opt, struct __sk_buff *skb, + const void *from, __u32 size); + +/* Events for user space */ +static int BPF_FUNC_REMAP(skb_event_output, struct __sk_buff *skb, void *map, + __u64 index, const void *data, __u32 size) = + (void *)BPF_FUNC_perf_event_output; + +#endif /* __BPF_HELPERS_SKB__ */ diff --git a/bpf/include/bpf/helpers_xdp.h b/bpf/include/bpf/helpers_xdp.h new file mode 100644 index 000000000000..a6d5a0a4ff82 --- /dev/null +++ b/bpf/include/bpf/helpers_xdp.h @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2016-2020 Authors of Cilium + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef __BPF_HELPERS_XDP__ +#define __BPF_HELPERS_XDP__ + +#include + +#include "compiler.h" +#include "helpers.h" + +/* Events for user space */ +static int BPF_FUNC_REMAP(xdp_event_output, struct xdp_md *xdp, void *map, + __u64 index, const void *data, __u32 size) = + (void *)BPF_FUNC_perf_event_output; + +#endif /* __BPF_HELPERS_XDP__ */ diff --git a/bpf/include/bpf/section.h b/bpf/include/bpf/section.h new file mode 100644 index 000000000000..2bda65c61a65 --- /dev/null +++ b/bpf/include/bpf/section.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2016-2020 Authors of Cilium + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __BPF_SECTION__ +#define __BPF_SECTION__ + +#include "compiler.h" + +#ifndef __section_tail +# define __section_tail(ID, KEY) __section(__stringify(ID) "/" __stringify(KEY)) +#endif + +#ifndef __section_license +# define __section_license __section("license") +#endif + +#ifndef __section_maps +# define __section_maps __section("maps") +#endif + +#ifndef BPF_LICENSE +# define BPF_LICENSE(NAME) \ + char ____license[] __section_license = NAME +#endif + +#endif /* __BPF_SECTION__ */ diff --git a/bpf/include/iproute2/bpf_elf.h b/bpf/include/iproute2/bpf_elf.h deleted file mode 100644 index 342320bab62a..000000000000 --- a/bpf/include/iproute2/bpf_elf.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef __BPF_ELF__ -#define __BPF_ELF__ - -#include - -/* Note: - * - * Below ELF section names and bpf_elf_map structure definition - * are not (!) kernel ABI. It's rather a "contract" between the - * application and the BPF loader in tc. For compatibility, the - * section names should stay as-is. Introduction of aliases, if - * needed, are a possibility, though. - */ - -/* ELF section names, etc */ -#define ELF_SECTION_LICENSE "license" -#define ELF_SECTION_MAPS "maps" -#define ELF_SECTION_CLASSIFIER "classifier" -#define ELF_SECTION_ACTION "action" - -#define ELF_MAX_MAPS 64 -#define ELF_MAX_LICENSE_LEN 128 - -/* Object pinning settings */ -#define PIN_NONE 0 -#define PIN_OBJECT_NS 1 -#define PIN_GLOBAL_NS 2 - -/* ELF map definition */ -struct bpf_elf_map { - __u32 type; - __u32 size_key; - __u32 size_value; - __u32 max_elem; - __u32 flags; - __u32 id; - __u32 pinning; -#ifdef SOCKMAP - __u32 inner_id; - __u32 inner_idx; -#endif -}; - -#endif /* __BPF_ELF__ */ diff --git a/bpf/probes/raw_main.c b/bpf/probes/raw_main.c index b55336039b1b..9c67b8d6f33d 100644 --- a/bpf/probes/raw_main.c +++ b/bpf/probes/raw_main.c @@ -25,7 +25,7 @@ #include "raw_insn.h" -#include "iproute2/bpf_elf.h" +#include "bpf/api.h" #define BPF_MAX_FIXUPS 64 #define BPF_MAX_INSNS (2 * BPF_MAXINSNS)