2018-01-17 19:13:31 -08:00
|
|
|
/* SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) */
|
|
|
|
#include <linux/bpf.h>
|
2020-01-20 14:06:45 +01:00
|
|
|
#include <bpf/bpf_helpers.h>
|
2018-01-17 19:13:31 -08:00
|
|
|
|
2022-01-19 22:05:27 -08:00
|
|
|
struct {
|
|
|
|
__uint(type, BPF_MAP_TYPE_HASH);
|
|
|
|
__type(key, __u32);
|
|
|
|
__type(value, long);
|
|
|
|
__uint(max_entries, 2);
|
|
|
|
} htab SEC(".maps");
|
2018-01-17 19:13:31 -08:00
|
|
|
|
2022-01-19 22:05:27 -08:00
|
|
|
struct {
|
|
|
|
__uint(type, BPF_MAP_TYPE_ARRAY);
|
|
|
|
__type(key, __u32);
|
|
|
|
__type(value, long);
|
|
|
|
__uint(max_entries, 2);
|
|
|
|
} array SEC(".maps");
|
2018-01-17 19:13:31 -08:00
|
|
|
|
|
|
|
/* Sample program which should always load for testing control paths. */
|
2024-04-08 20:15:48 -07:00
|
|
|
SEC("xdp") int func()
|
2018-01-17 19:13:31 -08:00
|
|
|
{
|
|
|
|
__u64 key64 = 0;
|
|
|
|
__u32 key = 0;
|
|
|
|
long *value;
|
|
|
|
|
|
|
|
value = bpf_map_lookup_elem(&htab, &key);
|
|
|
|
if (!value)
|
|
|
|
return 1;
|
|
|
|
value = bpf_map_lookup_elem(&array, &key64);
|
|
|
|
if (!value)
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|