net/ipv6/ioam6_iptunnel.c
Source file repositories/reference/linux-study-clean/net/ipv6/ioam6_iptunnel.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ioam6_iptunnel.c- Extension
.c- Size
- 14994 bytes
- Lines
- 563
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- 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
linux/kernel.hlinux/skbuff.hlinux/net.hlinux/in6.hlinux/ioam6.hlinux/ioam6_iptunnel.hnet/dst.hnet/sock.hnet/lwtunnel.hnet/ioam6.hnet/netlink.hnet/ipv6.hnet/dst_cache.hnet/ip6_route.hnet/addrconf.h
Detected Declarations
struct ioam6_lwt_encapstruct ioam6_lwt_freqstruct ioam6_lwtfunction ioam6_validate_trace_hdrfunction ioam6_build_statefunction ioam6_do_fillfunction ioam6_do_inlinefunction ioam6_do_encapfunction ioam6_outputfunction transformationfunction ioam6_destroy_statefunction ioam6_fill_encap_infofunction ioam6_encap_nlsizefunction ioam6_encap_cmpfunction ioam6_iptunnel_initfunction ioam6_iptunnel_exit
Annotated Snippet
struct ioam6_lwt_encap {
struct ipv6_hopopt_hdr eh;
u8 pad[2]; /* 2-octet padding for 4n-alignment */
struct ioam6_hdr ioamh;
struct ioam6_trace_hdr traceh;
} __packed;
struct ioam6_lwt_freq {
u32 k;
u32 n;
};
struct ioam6_lwt {
struct dst_entry null_dst;
struct dst_cache cache;
struct ioam6_lwt_freq freq;
atomic_t pkt_cnt;
u8 mode;
bool has_tunsrc;
struct in6_addr tunsrc;
struct in6_addr tundst;
struct ioam6_lwt_encap tuninfo;
};
static const struct netlink_range_validation freq_range = {
.min = IOAM6_IPTUNNEL_FREQ_MIN,
.max = IOAM6_IPTUNNEL_FREQ_MAX,
};
static struct ioam6_lwt *ioam6_lwt_state(struct lwtunnel_state *lwt)
{
return (struct ioam6_lwt *)lwt->data;
}
static struct ioam6_lwt_encap *ioam6_lwt_info(struct lwtunnel_state *lwt)
{
return &ioam6_lwt_state(lwt)->tuninfo;
}
static struct ioam6_trace_hdr *ioam6_lwt_trace(struct lwtunnel_state *lwt)
{
return &(ioam6_lwt_state(lwt)->tuninfo.traceh);
}
static const struct nla_policy ioam6_iptunnel_policy[IOAM6_IPTUNNEL_MAX + 1] = {
[IOAM6_IPTUNNEL_FREQ_K] = NLA_POLICY_FULL_RANGE(NLA_U32, &freq_range),
[IOAM6_IPTUNNEL_FREQ_N] = NLA_POLICY_FULL_RANGE(NLA_U32, &freq_range),
[IOAM6_IPTUNNEL_MODE] = NLA_POLICY_RANGE(NLA_U8,
IOAM6_IPTUNNEL_MODE_MIN,
IOAM6_IPTUNNEL_MODE_MAX),
[IOAM6_IPTUNNEL_SRC] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
[IOAM6_IPTUNNEL_DST] = NLA_POLICY_EXACT_LEN(sizeof(struct in6_addr)),
[IOAM6_IPTUNNEL_TRACE] = NLA_POLICY_EXACT_LEN(
sizeof(struct ioam6_trace_hdr)),
};
static bool ioam6_validate_trace_hdr(struct ioam6_trace_hdr *trace)
{
u32 fields;
if (!trace->type_be32 || !trace->remlen ||
trace->remlen > IOAM6_TRACE_DATA_SIZE_MAX / 4 ||
trace->type.bit12 | trace->type.bit13 | trace->type.bit14 |
trace->type.bit15 | trace->type.bit16 | trace->type.bit17 |
trace->type.bit18 | trace->type.bit19 | trace->type.bit20 |
trace->type.bit21 | trace->type.bit23)
return false;
fields = be32_to_cpu(trace->type_be32);
trace->nodelen = ioam6_trace_compute_nodelen(fields);
return true;
}
static int ioam6_build_state(struct net *net, struct nlattr *nla,
unsigned int family, const void *cfg,
struct lwtunnel_state **ts,
struct netlink_ext_ack *extack)
{
struct nlattr *tb[IOAM6_IPTUNNEL_MAX + 1];
struct ioam6_lwt_encap *tuninfo;
struct ioam6_trace_hdr *trace;
struct lwtunnel_state *lwt;
struct ioam6_lwt *ilwt;
int len_aligned, err;
u32 freq_k, freq_n;
u8 mode;
if (family != AF_INET6)
return -EINVAL;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/skbuff.h`, `linux/net.h`, `linux/in6.h`, `linux/ioam6.h`, `linux/ioam6_iptunnel.h`, `net/dst.h`, `net/sock.h`.
- Detected declarations: `struct ioam6_lwt_encap`, `struct ioam6_lwt_freq`, `struct ioam6_lwt`, `function ioam6_validate_trace_hdr`, `function ioam6_build_state`, `function ioam6_do_fill`, `function ioam6_do_inline`, `function ioam6_do_encap`, `function ioam6_output`, `function transformation`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.