| 1 |
|
| 2 |
|
| 3 |
#include "common.h" |
| 4 |
|
| 5 |
struct bpf_map_def dummy __section("maps") = { |
| 6 |
.type = BPF_MAP_TYPE_HASH, |
| 7 |
.key_size = sizeof(uint32_t), |
| 8 |
.value_size = sizeof(uint64_t), |
| 9 |
.max_entries = 1, |
| 10 |
.map_flags = 0, |
| 11 |
}; |
| 12 |
|
| 13 |
|
| 14 |
static struct bpf_map_def hash_map __section("maps") = { |
| 15 |
.type = BPF_MAP_TYPE_HASH, |
| 16 |
.key_size = sizeof(uint32_t), |
| 17 |
.value_size = sizeof(uint64_t), |
| 18 |
.max_entries = 1, |
| 19 |
.map_flags = 0, |
| 20 |
}; |
| 21 |
|
| 22 |
__section("xdp") int xdp_prog() { |
| 23 |
uint32_t key = 0; |
| 24 |
void *p = bpf_map_lookup_elem(&hash_map, &key); |
| 25 |
return !!p; |
| 26 |
} |