1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (c) 2021 Facebook */ 3 4 #include "vmlinux.h" 5 #include <bpf/bpf_helpers.h> 6 #include <bpf/bpf_tracing.h> 7 8 char _license[] SEC("license") = "GPL"; 9 10 struct { 11 __uint(type, BPF_MAP_TYPE_HASH); 12 __uint(max_entries, 1); 13 __type(key, int); 14 __type(value, long); 15 } hash1 SEC(".maps"); 16 17 struct { 18 __uint(type, BPF_MAP_TYPE_HASH); 19 __uint(max_entries, 1); 20 __type(key, int); 21 __type(value, long); 22 } hash2 SEC(".maps"); 23 24 int pass1 = 0; 25 int pass2 = 0; 26 27 SEC("fentry/htab_map_delete_elem") 28 int BPF_PROG(on_delete, struct bpf_map *map) 29 { 30 int key = 0; 31 32 if (map == (void *)&hash1) { 33 pass1++; 34 return 0; 35 } 36 if (map == (void *)&hash2) { 37 pass2++; 38 bpf_map_delete_elem(&hash2, &key); 39 return 0; 40 } 41 42 return 0; 43 } 44