github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/testdata/iproute2_map_compat.c (about)

     1  /* This file excercises the ELF loader. It is not a valid BPF program. */
     2  
     3  #include "common.h"
     4  
     5  #define PIN_GLOBAL_NS 2
     6  
     7  // bpf_elf_map is a custom BPF map definition used by iproute2.
     8  // It contains the id, pinning, inner_id and inner_idx fields
     9  // in addition to the ones in struct bpf_map_def which is commonly
    10  // used in the kernel and libbpf.
    11  struct bpf_elf_map {
    12  	unsigned int type;
    13  	unsigned int size_key;
    14  	unsigned int size_value;
    15  	unsigned int max_elem;
    16  	unsigned int flags;
    17  	unsigned int id;
    18  	unsigned int pinning;
    19  	unsigned int inner_id;
    20  	unsigned int inner_idx;
    21  };
    22  
    23  struct bpf_elf_map hash_map __section("maps") = {
    24  	.type       = BPF_MAP_TYPE_HASH,
    25  	.size_key   = sizeof(uint32_t),
    26  	.size_value = sizeof(uint64_t),
    27  	.max_elem   = 2,
    28  	.pinning    = PIN_GLOBAL_NS,
    29  };