tools/testing/selftests/bpf/prog_tests/tc_helpers.h
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/tc_helpers.h
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/prog_tests/tc_helpers.h- Extension
.h- Size
- 1160 bytes
- Lines
- 51
- 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.h
Detected Declarations
function ifindex_from_link_fdfunction __assert_mprog_countfunction assert_mprog_countfunction assert_mprog_count_ifindexfunction tc_skel_reset_all_seen
Annotated Snippet
#ifndef TC_HELPERS
#define TC_HELPERS
#include <test_progs.h>
#ifndef loopback
# define loopback 1
#endif
static inline __u32 ifindex_from_link_fd(int fd)
{
struct bpf_link_info link_info = {};
__u32 link_info_len = sizeof(link_info);
int err;
err = bpf_link_get_info_by_fd(fd, &link_info, &link_info_len);
if (!ASSERT_OK(err, "id_from_link_fd"))
return 0;
return link_info.tcx.ifindex;
}
static inline void __assert_mprog_count(int target, int expected, int ifindex)
{
__u32 count = 0, attach_flags = 0;
int err;
err = bpf_prog_query(ifindex, target, 0, &attach_flags,
NULL, &count);
ASSERT_EQ(count, expected, "count");
ASSERT_EQ(err, 0, "prog_query");
}
static inline void assert_mprog_count(int target, int expected)
{
__assert_mprog_count(target, expected, loopback);
}
static inline void assert_mprog_count_ifindex(int ifindex, int target, int expected)
{
__assert_mprog_count(target, expected, ifindex);
}
static inline void tc_skel_reset_all_seen(struct test_tc_link *skel)
{
memset(skel->bss, 0, sizeof(*skel->bss));
}
#endif /* TC_HELPERS */
Annotation
- Immediate include surface: `test_progs.h`.
- Detected declarations: `function ifindex_from_link_fd`, `function __assert_mprog_count`, `function assert_mprog_count`, `function assert_mprog_count_ifindex`, `function tc_skel_reset_all_seen`.
- 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.