File: iproute2_map_compat.c

package info (click to toggle)
golang-github-cilium-ebpf 0.17.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,684 kB
  • sloc: ansic: 1,259; makefile: 127; python: 113; awk: 29; sh: 24
file content (29 lines) | stat: -rw-r--r-- 779 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* This file excercises the ELF loader. It is not a valid BPF program. */

#include "common.h"

#define PIN_GLOBAL_NS 2

// bpf_elf_map is a custom BPF map definition used by iproute2.
// It contains the id, pinning, inner_id and inner_idx fields
// in addition to the ones in struct bpf_map_def which is commonly
// used in the kernel and libbpf.
struct bpf_elf_map {
	unsigned int type;
	unsigned int size_key;
	unsigned int size_value;
	unsigned int max_elem;
	unsigned int flags;
	unsigned int id;
	unsigned int pinning;
	unsigned int inner_id;
	unsigned int inner_idx;
};

struct bpf_elf_map hash_map __section("maps") = {
	.type       = BPF_MAP_TYPE_HASH,
	.size_key   = sizeof(uint32_t),
	.size_value = sizeof(uint64_t),
	.max_elem   = 2,
	.pinning    = PIN_GLOBAL_NS,
};