0001
0002
0003
0004 #include "vmlinux.h"
0005 #include <bpf/bpf_helpers.h>
0006 #include <bpf/bpf_tracing.h>
0007
0008 char _license[] SEC("license") = "GPL";
0009
0010 struct {
0011 __uint(type, BPF_MAP_TYPE_HASH);
0012 __uint(max_entries, 1);
0013 __type(key, int);
0014 __type(value, long);
0015 } hash1 SEC(".maps");
0016
0017 struct {
0018 __uint(type, BPF_MAP_TYPE_HASH);
0019 __uint(max_entries, 1);
0020 __type(key, int);
0021 __type(value, long);
0022 } hash2 SEC(".maps");
0023
0024 int pass1 = 0;
0025 int pass2 = 0;
0026
0027 SEC("fentry/htab_map_delete_elem")
0028 int BPF_PROG(on_delete, struct bpf_map *map)
0029 {
0030 int key = 0;
0031
0032 if (map == (void *)&hash1) {
0033 pass1++;
0034 return 0;
0035 }
0036 if (map == (void *)&hash2) {
0037 pass2++;
0038 bpf_map_delete_elem(&hash2, &key);
0039 return 0;
0040 }
0041
0042 return 0;
0043 }