summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/map_excl.c
blob: d461684728e4e725ed83bbe1eff80f7746a08891 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: GPL-2.0
/* Copyright (C) 2025 Google LLC. */
#include <linux/bpf.h>
#include <time.h>
#include <bpf/bpf_helpers.h>

#include "bpf_misc.h"

struct {
	__uint(type, BPF_MAP_TYPE_ARRAY);
	__type(key, __u32);
	__type(value, __u32);
	__uint(max_entries, 1);
} excl_map SEC(".maps");

char _license[] SEC("license") = "GPL";

SEC("?fentry.s/" SYS_PREFIX "sys_getpgid")
int should_have_access(void *ctx)
{
	int key = 0, value = 0xdeadbeef;

	bpf_map_update_elem(&excl_map, &key, &value, 0);
	return 0;
}

SEC("?fentry.s/" SYS_PREFIX "sys_getpgid")
int should_not_have_access(void *ctx)
{
	int key = 0, value = 0xdeadbeef;

	bpf_map_update_elem(&excl_map, &key, &value, 0);
	return 0;
}