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 7char _license[] SEC("license") = "GPL"; 8 9struct { 10 __uint(type, BPF_MAP_TYPE_HASH); 11 __uint(max_entries, 1); 12 __uint(key_size, sizeof(__u32)); 13 __uint(value_size, sizeof(__u32)); 14} htab SEC(".maps"); 15 16int pid = 0; 17int update_err = 0; 18 19SEC("?fentry/lookup_elem_raw") 20int lookup_elem_raw(void *ctx) 21{ 22 __u32 key = 0, value = 1; 23 24 if ((bpf_get_current_pid_tgid() >> 32) != pid) 25 return 0; 26 27 update_err = bpf_map_update_elem(&htab, &key, &value, 0); 28 return 0; 29} 30