Skip to content

Commit 77340a1

Browse files
committed
basic04: Switch back to old-style map definition
While updating libbpf, I also accidentally committed a change to the basic04 lesson that started using the new btf-based map definition syntax. This doesn't work with LLVM versions before v9, so let's revert this change until we decide to require LLVM9 for the whole tutorial. Fixes #85. Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
1 parent c553e5b commit 77340a1

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

basic04-pinning-maps/xdp_prog_kern.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
* - Here an array with XDP_ACTION_MAX (max_)entries are created.
99
* - The idea is to keep stats per (enum) xdp_action
1010
*/
11-
struct {
12-
__uint(type, BPF_MAP_TYPE_PERCPU_ARRAY);
13-
__uint(max_entries, XDP_ACTION_MAX);
14-
__type(key, __u32);
15-
__type(value, struct datarec);
16-
__uint(pinning, 1);
17-
} xdp_stats_map SEC(".maps");
11+
struct bpf_map_def SEC("maps") xdp_stats_map = {
12+
.type = BPF_MAP_TYPE_PERCPU_ARRAY,
13+
.key_size = sizeof(__u32),
14+
.value_size = sizeof(struct datarec),
15+
.max_entries = XDP_ACTION_MAX,
16+
};
1817

1918
/* LLVM maps __sync_fetch_and_add() as a built-in function to the BPF atomic add
2019
* instruction (that is BPF_STX | BPF_XADD | BPF_W for word sizes)

0 commit comments

Comments
 (0)