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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/sk_bypass_prot_mem.c
Extension
.c
Size
2459 bytes
Lines
107
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

SEC("cgroup/sock_create")
int sock_create(struct bpf_sock *ctx)
{
	int err, val = 1;

	err = bpf_setsockopt(ctx, SOL_SOCKET, SK_BPF_BYPASS_PROT_MEM,
			     &val, sizeof(val));
	if (err)
		goto err;

	val = 0;

	err = bpf_getsockopt(ctx, SOL_SOCKET, SK_BPF_BYPASS_PROT_MEM,
			     &val, sizeof(val));
	if (err)
		goto err;

	if (val != 1) {
		err = -EINVAL;
		goto err;
	}

	return 1;

err:
	set_if_not_errno_or_zero(err, -EFAULT);
	bpf_set_retval(err);
	return 0;
}

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

Annotation

Implementation Notes