tools/testing/selftests/bpf/progs/verifier_sock_addr.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_sock_addr.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/verifier_sock_addr.c- Extension
.c- Size
- 6719 bytes
- Lines
- 332
- 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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bpf.hbpf/bpf_helpers.hbpf_sockopt_helpers.hbpf_misc.h
Detected Declarations
function recvmsg4_good_return_codefunction __msgfunction recvmsg6_good_return_codefunction __msgfunction recvmsg_unix_good_return_codefunction __msgfunction sendmsg4_good_return_code_0function sendmsg4_good_return_code_1function __msgfunction sendmsg6_good_return_code_0function sendmsg6_good_return_code_1function __msgfunction sendmsg_unix_good_return_code_0function sendmsg_unix_good_return_code_1function __msgfunction getpeername4_good_return_codefunction __msgfunction getpeername6_good_return_codefunction __msgfunction getpeername_unix_good_return_codefunction __msgfunction getsockname4_good_return_codefunction __msgfunction getsockname6_good_return_codefunction __msgfunction getsockname_unix_good_return_codefunction __msgfunction bind4_good_return_code_0function bind4_good_return_code_1function bind4_good_return_code_2function bind4_good_return_code_3function __msgfunction bind6_good_return_code_0function bind6_good_return_code_1function bind6_good_return_code_2function bind6_good_return_code_3function __msgfunction connect4_good_return_code_0function connect4_good_return_code_1function __msgfunction connect6_good_return_code_0function connect6_good_return_code_1function __msgfunction connect_unix_good_return_code_0function connect_unix_good_return_code_1function __msg
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2024 Google LLC */
#include <linux/bpf.h>
#include <bpf/bpf_helpers.h>
#include <bpf_sockopt_helpers.h>
#include "bpf_misc.h"
SEC("cgroup/recvmsg4")
__success
int recvmsg4_good_return_code(struct bpf_sock_addr *ctx)
{
return 1;
}
SEC("cgroup/recvmsg4")
__failure __msg("At program exit the register R0 has smin=0 smax=0 should have been in [1, 1]")
int recvmsg4_bad_return_code(struct bpf_sock_addr *ctx)
{
return 0;
}
SEC("cgroup/recvmsg6")
__success
int recvmsg6_good_return_code(struct bpf_sock_addr *ctx)
{
return 1;
}
SEC("cgroup/recvmsg6")
__failure __msg("At program exit the register R0 has smin=0 smax=0 should have been in [1, 1]")
int recvmsg6_bad_return_code(struct bpf_sock_addr *ctx)
{
return 0;
}
SEC("cgroup/recvmsg_unix")
__success
int recvmsg_unix_good_return_code(struct bpf_sock_addr *ctx)
{
return 1;
}
SEC("cgroup/recvmsg_unix")
__failure __msg("At program exit the register R0 has smin=0 smax=0 should have been in [1, 1]")
int recvmsg_unix_bad_return_code(struct bpf_sock_addr *ctx)
{
return 0;
}
SEC("cgroup/sendmsg4")
__success
int sendmsg4_good_return_code_0(struct bpf_sock_addr *ctx)
{
return 0;
}
SEC("cgroup/sendmsg4")
__success
int sendmsg4_good_return_code_1(struct bpf_sock_addr *ctx)
{
return 1;
}
SEC("cgroup/sendmsg4")
__failure __msg("At program exit the register R0 has smin=2 smax=2 should have been in [0, 1]")
int sendmsg4_bad_return_code(struct bpf_sock_addr *ctx)
{
return 2;
}
SEC("cgroup/sendmsg6")
__success
int sendmsg6_good_return_code_0(struct bpf_sock_addr *ctx)
{
return 0;
}
SEC("cgroup/sendmsg6")
__success
int sendmsg6_good_return_code_1(struct bpf_sock_addr *ctx)
{
return 1;
}
SEC("cgroup/sendmsg6")
__failure __msg("At program exit the register R0 has smin=2 smax=2 should have been in [0, 1]")
int sendmsg6_bad_return_code(struct bpf_sock_addr *ctx)
{
return 2;
Annotation
- Immediate include surface: `linux/bpf.h`, `bpf/bpf_helpers.h`, `bpf_sockopt_helpers.h`, `bpf_misc.h`.
- Detected declarations: `function recvmsg4_good_return_code`, `function __msg`, `function recvmsg6_good_return_code`, `function __msg`, `function recvmsg_unix_good_return_code`, `function __msg`, `function sendmsg4_good_return_code_0`, `function sendmsg4_good_return_code_1`, `function __msg`, `function sendmsg6_good_return_code_0`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.