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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/bpf_iter_map_elem.c
Extension
.c
Size
427 bytes
Lines
23
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-only

#include "vmlinux.h"
#include <bpf/bpf_tracing.h>
#include <bpf/bpf_helpers.h>

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

__u32 value_sum = 0;

SEC("iter/bpf_map_elem")
int dump_bpf_map_values(struct bpf_iter__bpf_map_elem *ctx)
{
	__u32 value = 0;

	if (ctx->value == (void *)0)
		return 0;

	bpf_probe_read_kernel(&value, sizeof(value), ctx->value);
	value_sum += value;
	return 0;
}

Annotation

Implementation Notes