tools/testing/selftests/bpf/progs/map_excl.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/map_excl.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/map_excl.c
Extension
.c
Size
706 bytes
Lines
35
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

// 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;
}

Annotation

Implementation Notes