0001
0002 #include <linux/bpf.h>
0003 #include <bpf/bpf_helpers.h>
0004
0005 struct {
0006 __uint(type, BPF_MAP_TYPE_HASH);
0007 __type(key, __u32);
0008 __type(value, long);
0009 __uint(max_entries, 2);
0010 } htab SEC(".maps");
0011
0012 struct {
0013 __uint(type, BPF_MAP_TYPE_ARRAY);
0014 __type(key, __u32);
0015 __type(value, long);
0016 __uint(max_entries, 2);
0017 } array SEC(".maps");
0018
0019
0020 SEC(".text") int func()
0021 {
0022 __u64 key64 = 0;
0023 __u32 key = 0;
0024 long *value;
0025
0026 value = bpf_map_lookup_elem(&htab, &key);
0027 if (!value)
0028 return 1;
0029 value = bpf_map_lookup_elem(&array, &key64);
0030 if (!value)
0031 return 1;
0032
0033 return 0;
0034 }