tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/cg_storage_multi.c- Extension
.c- Size
- 13691 bytes
- Lines
- 394
- 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.hcgroup_helpers.hnetwork_helpers.hprogs/cg_storage_multi.hcg_storage_multi_egress_only.skel.hcg_storage_multi_isolated.skel.hcg_storage_multi_shared.skel.h
Detected Declarations
function assert_storagefunction assert_storage_noexistfunction connect_sendfunction test_egress_onlyfunction test_isolatedfunction test_sharedfunction serial_test_cg_storage_multi
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright 2020 Google LLC.
*/
#include <test_progs.h>
#include <cgroup_helpers.h>
#include <network_helpers.h>
#include "progs/cg_storage_multi.h"
#include "cg_storage_multi_egress_only.skel.h"
#include "cg_storage_multi_isolated.skel.h"
#include "cg_storage_multi_shared.skel.h"
#define PARENT_CGROUP "/cgroup_storage"
#define CHILD_CGROUP "/cgroup_storage/child"
static int duration;
static bool assert_storage(struct bpf_map *map, const void *key,
struct cgroup_value *expected)
{
struct cgroup_value value;
int map_fd;
map_fd = bpf_map__fd(map);
if (CHECK(bpf_map_lookup_elem(map_fd, key, &value) < 0,
"map-lookup", "errno %d", errno))
return true;
if (CHECK(memcmp(&value, expected, sizeof(struct cgroup_value)),
"assert-storage", "storages differ"))
return true;
return false;
}
static bool assert_storage_noexist(struct bpf_map *map, const void *key)
{
struct cgroup_value value;
int map_fd;
map_fd = bpf_map__fd(map);
if (CHECK(bpf_map_lookup_elem(map_fd, key, &value) == 0,
"map-lookup", "succeeded, expected ENOENT"))
return true;
if (CHECK(errno != ENOENT,
"map-lookup", "errno %d, expected ENOENT", errno))
return true;
return false;
}
static bool connect_send(const char *cgroup_path)
{
int server_fd = -1, client_fd = -1;
char message[] = "message";
bool res = true;
if (join_cgroup(cgroup_path))
goto out_clean;
server_fd = start_server(AF_INET, SOCK_DGRAM, NULL, 0, 0);
if (server_fd < 0)
goto out_clean;
client_fd = connect_to_fd(server_fd, 0);
if (client_fd < 0)
goto out_clean;
if (send(client_fd, &message, sizeof(message), 0) < 0)
goto out_clean;
if (read(server_fd, &message, sizeof(message)) < 0)
goto out_clean;
res = false;
out_clean:
close(client_fd);
close(server_fd);
return res;
}
static void test_egress_only(int parent_cgroup_fd, int child_cgroup_fd)
{
struct cg_storage_multi_egress_only *obj;
Annotation
- Immediate include surface: `test_progs.h`, `cgroup_helpers.h`, `network_helpers.h`, `progs/cg_storage_multi.h`, `cg_storage_multi_egress_only.skel.h`, `cg_storage_multi_isolated.skel.h`, `cg_storage_multi_shared.skel.h`.
- Detected declarations: `function assert_storage`, `function assert_storage_noexist`, `function connect_send`, `function test_egress_only`, `function test_isolated`, `function test_shared`, `function serial_test_cg_storage_multi`.
- 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.