tools/testing/selftests/bpf/prog_tests/sk_storage_omem_uncharge.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/sk_storage_omem_uncharge.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/sk_storage_omem_uncharge.c- Extension
.c- Size
- 1451 bytes
- Lines
- 57
- 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
test_progs.hbpf/libbpf.hsys/types.hsys/socket.hsk_storage_omem_uncharge.skel.h
Detected Declarations
function test_sk_storage_omem_uncharge
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2023 Facebook */
#include <test_progs.h>
#include <bpf/libbpf.h>
#include <sys/types.h>
#include <sys/socket.h>
#include "sk_storage_omem_uncharge.skel.h"
void test_sk_storage_omem_uncharge(void)
{
struct sk_storage_omem_uncharge *skel;
int sk_fd = -1, map_fd, err, value;
socklen_t optlen;
skel = sk_storage_omem_uncharge__open_and_load();
if (!ASSERT_OK_PTR(skel, "skel open_and_load"))
return;
map_fd = bpf_map__fd(skel->maps.sk_storage);
/* A standalone socket not binding to addr:port,
* so nentns is not needed.
*/
sk_fd = socket(AF_INET6, SOCK_STREAM, 0);
if (!ASSERT_GE(sk_fd, 0, "socket"))
goto done;
optlen = sizeof(skel->bss->cookie);
err = getsockopt(sk_fd, SOL_SOCKET, SO_COOKIE, &skel->bss->cookie, &optlen);
if (!ASSERT_OK(err, "getsockopt(SO_COOKIE)"))
goto done;
value = 0;
err = bpf_map_update_elem(map_fd, &sk_fd, &value, 0);
if (!ASSERT_OK(err, "bpf_map_update_elem(value=0)"))
goto done;
value = 0xdeadbeef;
err = bpf_map_update_elem(map_fd, &sk_fd, &value, 0);
if (!ASSERT_OK(err, "bpf_map_update_elem(value=0xdeadbeef)"))
goto done;
err = sk_storage_omem_uncharge__attach(skel);
if (!ASSERT_OK(err, "attach"))
goto done;
close(sk_fd);
sk_fd = -1;
ASSERT_EQ(skel->bss->cookie_found, 2, "cookie_found");
ASSERT_EQ(skel->bss->omem, 0, "omem");
done:
sk_storage_omem_uncharge__destroy(skel);
if (sk_fd != -1)
close(sk_fd);
}
Annotation
- Immediate include surface: `test_progs.h`, `bpf/libbpf.h`, `sys/types.h`, `sys/socket.h`, `sk_storage_omem_uncharge.skel.h`.
- Detected declarations: `function test_sk_storage_omem_uncharge`.
- 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.