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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/test_sockmap_msg_pop_data.c
Extension
.c
Size
534 bytes
Lines
28
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
#include "vmlinux.h"
#include <bpf/bpf_helpers.h>

struct {
	__uint(type, BPF_MAP_TYPE_SOCKMAP);
	__uint(max_entries, 1);
	__type(key, int);
	__type(value, int);
} sock_map SEC(".maps");

#define POP_START 0x48a3
#define POP_LEN   0xfffffffd

long pop_data_ret = 1;

SEC("sk_msg")
int prog_msg_pop_data(struct sk_msg_md *msg)
{
	if (msg->size <= POP_START)
		return SK_PASS;

	pop_data_ret = bpf_msg_pop_data(msg, POP_START, POP_LEN, 0);
	return SK_PASS;
}

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

Annotation

Implementation Notes