1 // SPDX-License-Identifier: GPL-2.0 2 /* Copyright (C) 2022. Huawei Technologies Co., Ltd */ 3 #include <linux/bpf.h> 4 #include <bpf/bpf_helpers.h> 5 #include <bpf/bpf_tracing.h> 6 7 char _license[] SEC("license") = "GPL"; 8 9 /* Map value type: has BTF-managed field (bpf_timer) */ 10 struct val { 11 struct bpf_timer t; 12 __u64 payload; 13 }; 14 15 struct { 16 __uint(type, BPF_MAP_TYPE_HASH); 17 __uint(max_entries, 1); 18 __type(key, __u32); 19 __type(value, struct val); 20 } htab SEC(".maps"); 21 22 int pid = 0; 23 int update_err = 0; 24 25 SEC("?fentry/bpf_obj_free_fields") 26 int bpf_obj_free_fields(void *ctx) 27 { 28 __u32 key = 0; 29 struct val value = { .payload = 1 }; 30 31 if ((bpf_get_current_pid_tgid() >> 32) != pid) 32 return 0; 33 34 update_err = bpf_map_update_elem(&htab, &key, &value, BPF_ANY); 35 return 0; 36 } 37