net/netfilter/nft_inner.c
Source file repositories/reference/linux-study-clean/net/netfilter/nft_inner.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/nft_inner.c- Extension
.c- Size
- 10075 bytes
- Lines
- 431
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/if_vlan.hlinux/init.hlinux/module.hlinux/netlink.hlinux/netfilter.hlinux/netfilter/nf_tables.hnet/netfilter/nf_tables_core.hnet/netfilter/nf_tables.hnet/netfilter/nft_meta.hnet/netfilter/nf_tables_offload.hlinux/tcp.hlinux/udp.hnet/gre.hnet/geneve.hnet/ip.hlinux/icmpv6.hlinux/ip.hlinux/ipv6.h
Detected Declarations
struct nft_inner_tun_ctx_lockedstruct __nft_exprstruct nft_innerstruct nft_expr_infofunction nft_inner_parse_l2l3function nft_inner_parse_tunhdrfunction nft_inner_parsefunction nft_inner_restore_tun_ctxfunction nft_inner_save_tun_ctxfunction nft_inner_parse_neededfunction nft_inner_evalfunction nft_inner_initfunction nft_inner_dump
Annotated Snippet
struct nft_inner_tun_ctx_locked {
struct nft_inner_tun_ctx ctx;
local_lock_t bh_lock;
};
static DEFINE_PER_CPU(struct nft_inner_tun_ctx_locked, nft_pcpu_tun_ctx) = {
.bh_lock = INIT_LOCAL_LOCK(bh_lock),
};
/* Same layout as nft_expr but it embeds the private expression data area. */
struct __nft_expr {
const struct nft_expr_ops *ops;
union {
struct nft_payload payload;
struct nft_meta meta;
} __attribute__((aligned(__alignof__(u64))));
};
enum {
NFT_INNER_EXPR_PAYLOAD,
NFT_INNER_EXPR_META,
};
struct nft_inner {
u8 flags;
u8 hdrsize;
u8 type;
u8 expr_type;
struct __nft_expr expr;
};
static int nft_inner_parse_l2l3(const struct nft_inner *priv,
const struct nft_pktinfo *pkt,
struct nft_inner_tun_ctx *ctx, u32 off)
{
__be16 llproto, outer_llproto;
u32 nhoff, thoff;
if (priv->flags & NFT_INNER_LL) {
struct vlan_ethhdr *veth, _veth;
struct ethhdr *eth, _eth;
u32 hdrsize;
eth = skb_header_pointer(pkt->skb, off, sizeof(_eth), &_eth);
if (!eth)
return -1;
switch (eth->h_proto) {
case htons(ETH_P_IP):
case htons(ETH_P_IPV6):
llproto = eth->h_proto;
hdrsize = sizeof(_eth);
break;
case htons(ETH_P_8021Q):
veth = skb_header_pointer(pkt->skb, off, sizeof(_veth), &_veth);
if (!veth)
return -1;
outer_llproto = veth->h_vlan_encapsulated_proto;
llproto = veth->h_vlan_proto;
hdrsize = sizeof(_veth);
break;
default:
return -1;
}
ctx->inner_lloff = off;
ctx->flags |= NFT_PAYLOAD_CTX_INNER_LL;
off += hdrsize;
} else {
struct iphdr *iph;
u32 _version;
iph = skb_header_pointer(pkt->skb, off, sizeof(_version), &_version);
if (!iph)
return -1;
switch (iph->version) {
case 4:
llproto = htons(ETH_P_IP);
break;
case 6:
llproto = htons(ETH_P_IPV6);
break;
default:
return -1;
}
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/if_vlan.h`, `linux/init.h`, `linux/module.h`, `linux/netlink.h`, `linux/netfilter.h`, `linux/netfilter/nf_tables.h`, `net/netfilter/nf_tables_core.h`.
- Detected declarations: `struct nft_inner_tun_ctx_locked`, `struct __nft_expr`, `struct nft_inner`, `struct nft_expr_info`, `function nft_inner_parse_l2l3`, `function nft_inner_parse_tunhdr`, `function nft_inner_parse`, `function nft_inner_restore_tun_ctx`, `function nft_inner_save_tun_ctx`, `function nft_inner_parse_needed`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- 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.