tools/testing/selftests/bpf/progs/bpf_iter_ipv6_route.c
Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/bpf_iter_ipv6_route.c
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/bpf/progs/bpf_iter_ipv6_route.c- Extension
.c- Size
- 1445 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
vmlinux.hbpf_tracing_net.hbpf/bpf_helpers.h
Detected Declarations
function dump_ipv6_route
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/* Copyright (c) 2020 Facebook */
#include <vmlinux.h>
#include "bpf_tracing_net.h"
#include <bpf/bpf_helpers.h>
char _license[] SEC("license") = "GPL";
extern bool CONFIG_IPV6_SUBTREES __kconfig __weak;
SEC("iter/ipv6_route")
int dump_ipv6_route(struct bpf_iter__ipv6_route *ctx)
{
struct seq_file *seq = ctx->meta->seq;
struct fib6_info *rt = ctx->rt;
const struct net_device *dev;
struct fib6_nh *fib6_nh;
unsigned int flags;
struct nexthop *nh;
if (rt == (void *)0)
return 0;
fib6_nh = &rt->fib6_nh[0];
flags = rt->fib6_flags;
/* FIXME: nexthop_is_multipath is not handled here. */
nh = rt->nh;
if (rt->nh)
fib6_nh = &nh->nh_info->fib6_nh;
BPF_SEQ_PRINTF(seq, "%pi6 %02x ", &rt->fib6_dst.addr, rt->fib6_dst.plen);
if (CONFIG_IPV6_SUBTREES)
BPF_SEQ_PRINTF(seq, "%pi6 %02x ", &rt->fib6_src.addr,
rt->fib6_src.plen);
else
BPF_SEQ_PRINTF(seq, "00000000000000000000000000000000 00 ");
if (fib6_nh->fib_nh_gw_family) {
flags |= RTF_GATEWAY;
BPF_SEQ_PRINTF(seq, "%pi6 ", &fib6_nh->fib_nh_gw6);
} else {
BPF_SEQ_PRINTF(seq, "00000000000000000000000000000000 ");
}
dev = fib6_nh->fib_nh_dev;
if (dev)
BPF_SEQ_PRINTF(seq, "%08x %08x %08x %08x %8s\n", rt->fib6_metric,
rt->fib6_ref.refs.counter, 0, flags, dev->name);
else
BPF_SEQ_PRINTF(seq, "%08x %08x %08x %08x\n", rt->fib6_metric,
rt->fib6_ref.refs.counter, 0, flags);
return 0;
}
Annotation
- Immediate include surface: `vmlinux.h`, `bpf_tracing_net.h`, `bpf/bpf_helpers.h`.
- Detected declarations: `function dump_ipv6_route`.
- 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.