test_lookup_and_delete.c (547B)
1// SPDX-License-Identifier: GPL-2.0 2 3#include "vmlinux.h" 4#include <bpf/bpf_helpers.h> 5 6__u32 set_pid = 0; 7__u64 set_key = 0; 8__u64 set_value = 0; 9 10struct { 11 __uint(type, BPF_MAP_TYPE_HASH); 12 __uint(max_entries, 2); 13 __type(key, __u64); 14 __type(value, __u64); 15} hash_map SEC(".maps"); 16 17SEC("tp/syscalls/sys_enter_getpgid") 18int bpf_lookup_and_delete_test(const void *ctx) 19{ 20 if (set_pid == bpf_get_current_pid_tgid() >> 32) 21 bpf_map_update_elem(&hash_map, &set_key, &set_value, BPF_NOEXIST); 22 23 return 0; 24} 25 26char _license[] SEC("license") = "GPL";