brintos

brintos / linux-shallow public Read only

0
0
Text · 633 B · 7481bb3 Raw
30 lines · c
1// SPDX-License-Identifier: GPL-2.02/* 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