include/net/netfilter/nf_tables_ipv4.h
Source file repositories/reference/linux-study-clean/include/net/netfilter/nf_tables_ipv4.h
File Facts
- System
- Linux kernel
- Corpus path
include/net/netfilter/nf_tables_ipv4.h- Extension
.h- Size
- 2253 bytes
- Lines
- 100
- 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
net/netfilter/nf_tables.hnet/ip.h
Detected Declarations
function nft_set_pktinfo_ipv4function __nft_set_pktinfo_ipv4_validatefunction nft_set_pktinfo_ipv4_validatefunction nft_set_pktinfo_ipv4_ingress
Annotated Snippet
#ifndef _NF_TABLES_IPV4_H_
#define _NF_TABLES_IPV4_H_
#include <net/netfilter/nf_tables.h>
#include <net/ip.h>
static inline void nft_set_pktinfo_ipv4(struct nft_pktinfo *pkt)
{
struct iphdr *ip;
ip = ip_hdr(pkt->skb);
pkt->flags = NFT_PKTINFO_L4PROTO;
pkt->tprot = ip->protocol;
pkt->ethertype = pkt->skb->protocol;
pkt->nhoff = 0;
pkt->thoff = ip_hdrlen(pkt->skb);
pkt->fragoff = ntohs(ip->frag_off) & IP_OFFSET;
}
static inline int __nft_set_pktinfo_ipv4_validate(struct nft_pktinfo *pkt,
int nhoff)
{
struct iphdr *iph, _iph;
u32 len, thoff, skb_len;
iph = skb_header_pointer(pkt->skb, skb_network_offset(pkt->skb) + nhoff,
sizeof(*iph), &_iph);
if (!iph)
return -1;
if (iph->ihl < 5 || iph->version != 4)
return -1;
len = iph_totlen(pkt->skb, iph);
thoff = iph->ihl * 4;
skb_len = pkt->skb->len - skb_network_offset(pkt->skb) - nhoff;
if (skb_len < len)
return -1;
else if (len < thoff)
return -1;
else if (thoff < sizeof(*iph))
return -1;
pkt->flags = NFT_PKTINFO_L4PROTO;
pkt->tprot = iph->protocol;
pkt->ethertype = pkt->skb->protocol;
pkt->nhoff = nhoff;
pkt->thoff = skb_network_offset(pkt->skb) + nhoff + thoff;
pkt->fragoff = ntohs(iph->frag_off) & IP_OFFSET;
return 0;
}
static inline void nft_set_pktinfo_ipv4_validate(struct nft_pktinfo *pkt)
{
if (__nft_set_pktinfo_ipv4_validate(pkt, 0) < 0)
nft_set_pktinfo_unspec(pkt);
}
static inline int nft_set_pktinfo_ipv4_ingress(struct nft_pktinfo *pkt)
{
struct iphdr *iph;
u32 len, thoff;
if (!pskb_may_pull(pkt->skb, sizeof(*iph)))
return -1;
iph = ip_hdr(pkt->skb);
if (iph->ihl < 5 || iph->version != 4)
goto inhdr_error;
len = iph_totlen(pkt->skb, iph);
thoff = iph->ihl * 4;
if (pkt->skb->len < len) {
__IP_INC_STATS(nft_net(pkt), IPSTATS_MIB_INTRUNCATEDPKTS);
return -1;
} else if (len < thoff) {
goto inhdr_error;
} else if (thoff < sizeof(*iph)) {
return -1;
}
pkt->flags = NFT_PKTINFO_L4PROTO;
pkt->ethertype = pkt->skb->protocol;
pkt->nhoff = 0;
pkt->tprot = iph->protocol;
pkt->thoff = thoff;
pkt->fragoff = ntohs(iph->frag_off) & IP_OFFSET;
Annotation
- Immediate include surface: `net/netfilter/nf_tables.h`, `net/ip.h`.
- Detected declarations: `function nft_set_pktinfo_ipv4`, `function __nft_set_pktinfo_ipv4_validate`, `function nft_set_pktinfo_ipv4_validate`, `function nft_set_pktinfo_ipv4_ingress`.
- 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.