tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/net/tcp_ao/lib/ftrace-tcp.c- Extension
.c- Size
- 13245 bytes
- Lines
- 557
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
inttypes.hpthread.haolib.h
Detected Declarations
struct expected_trace_pointstruct trace_pointfunction __trace_event_expectfunction free_expected_eventsfunction lookup_expected_eventfunction check_event_typefunction event_has_flagsfunction tracer_ip_splitfunction tracer_scan_addressfunction tracer_scan_eventfunction aolib_tracer_process_eventfunction dump_trace_eventfunction print_match_statsfunction check_free_eventsfunction setup_tcp_trace_eventsfunction aolib_tracer_destroyfunction aolib_tracer_expecting_morefunction setup_aolib_ftracer
Annotated Snippet
struct expected_trace_point {
/* required */
enum trace_events type;
int family;
union tcp_addr src;
union tcp_addr dst;
/* optional */
int src_port;
int dst_port;
int L3index;
int fin;
int syn;
int rst;
int psh;
int ack;
int keyid;
int rnext;
int maclen;
int sne;
size_t matched;
};
static struct expected_trace_point *exp_tps;
static size_t exp_tps_nr;
static size_t exp_tps_size;
static pthread_mutex_t exp_tps_mutex = PTHREAD_MUTEX_INITIALIZER;
int __trace_event_expect(enum trace_events type, int family,
union tcp_addr src, union tcp_addr dst,
int src_port, int dst_port, int L3index,
int fin, int syn, int rst, int psh, int ack,
int keyid, int rnext, int maclen, int sne)
{
struct expected_trace_point new_tp = {
.type = type,
.family = family,
.src = src,
.dst = dst,
.src_port = src_port,
.dst_port = dst_port,
.L3index = L3index,
.fin = fin,
.syn = syn,
.rst = rst,
.psh = psh,
.ack = ack,
.keyid = keyid,
.rnext = rnext,
.maclen = maclen,
.sne = sne,
.matched = 0,
};
int ret = 0;
if (!kernel_config_has(KCONFIG_FTRACE))
return 0;
pthread_mutex_lock(&exp_tps_mutex);
if (exp_tps_nr == exp_tps_size) {
struct expected_trace_point *tmp;
if (exp_tps_size == 0)
exp_tps_size = 10;
else
exp_tps_size = exp_tps_size * 1.6;
tmp = reallocarray(exp_tps, exp_tps_size, sizeof(exp_tps[0]));
if (!tmp) {
ret = -ENOMEM;
goto out;
}
exp_tps = tmp;
}
exp_tps[exp_tps_nr] = new_tp;
exp_tps_nr++;
out:
pthread_mutex_unlock(&exp_tps_mutex);
return ret;
}
static void free_expected_events(void)
{
/* We're from the process destructor - not taking the mutex */
exp_tps_size = 0;
exp_tps = NULL;
free(exp_tps);
Annotation
- Immediate include surface: `inttypes.h`, `pthread.h`, `aolib.h`.
- Detected declarations: `struct expected_trace_point`, `struct trace_point`, `function __trace_event_expect`, `function free_expected_events`, `function lookup_expected_event`, `function check_event_type`, `function event_has_flags`, `function tracer_ip_split`, `function tracer_scan_address`, `function tracer_scan_event`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.