include/linux/netfilter.h
Source file repositories/reference/linux-study-clean/include/linux/netfilter.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/netfilter.h- Extension
.h- Size
- 14129 bytes
- Lines
- 511
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/init.hlinux/skbuff.hlinux/net.hlinux/if.hlinux/in.hlinux/in6.hlinux/wait.hlinux/list.hlinux/static_key.hlinux/module.hlinux/netfilter_defs.hlinux/netdevice.hlinux/sockptr.hnet/net_namespace.hnet/flow.hlinux/netfilter/nf_conntrack_zones_common.h
Detected Declarations
struct sk_buffstruct nf_hook_opsstruct sockstruct nf_hook_statestruct nf_hook_opsstruct nf_hook_entrystruct nf_hook_entries_rcu_headstruct nf_hook_entriesstruct nf_sockopt_opsstruct flowistruct nf_queue_entrystruct nf_connstruct nlattrstruct nf_nat_hookstruct flowistruct nf_conntrack_tuplestruct nf_conntrack_tuplestruct nf_connstruct nf_ct_hookstruct nlattrstruct nfnl_ct_hookstruct nf_defrag_hookenum nf_hook_ops_typeenum nf_nat_manip_typeenum ip_conntrack_infofunction NF_DROP_GETERRfunction NF_DROP_REASONfunction nf_inet_addr_cmpfunction nf_inet_addr_maskfunction nf_hook_entry_hookfnfunction nf_hook_state_initfunction nf_hookfunction NF_STOLENfunction NF_HOOKfunction NF_HOOK_LISTfunction nf_nat_decode_sessionfunction NF_HOOK_CONDfunction NF_HOOKfunction NF_HOOK_LISTfunction nf_nat_decode_sessionfunction nf_ct_attachfunction nf_ct_get_tuple_skb
Annotated Snippet
struct nf_hook_state {
u8 hook;
u8 pf;
struct net_device *in;
struct net_device *out;
struct sock *sk;
struct net *net;
int (*okfn)(struct net *, struct sock *, struct sk_buff *);
};
typedef unsigned int nf_hookfn(void *priv,
struct sk_buff *skb,
const struct nf_hook_state *state);
enum nf_hook_ops_type {
NF_HOOK_OP_UNDEFINED,
NF_HOOK_OP_NF_TABLES,
NF_HOOK_OP_BPF,
NF_HOOK_OP_NFT_FT,
};
struct nf_hook_ops {
struct list_head list;
struct rcu_head rcu;
/* User fills in from here down. */
nf_hookfn *hook;
struct net_device *dev;
void *priv;
u8 pf;
enum nf_hook_ops_type hook_ops_type:8;
unsigned int hooknum;
/* Hooks are ordered in ascending priority. */
int priority;
};
struct nf_hook_entry {
nf_hookfn *hook;
void *priv;
};
struct nf_hook_entries_rcu_head {
struct rcu_head head;
void *allocation;
};
struct nf_hook_entries {
u16 num_hook_entries;
/* padding */
struct nf_hook_entry hooks[];
/* trailer: pointers to original orig_ops of each hook,
* followed by rcu_head and scratch space used for freeing
* the structure via call_rcu.
*
* This is not part of struct nf_hook_entry since its only
* needed in slow path (hook register/unregister):
* const struct nf_hook_ops *orig_ops[]
*
* For the same reason, we store this at end -- its
* only needed when a hook is deleted, not during
* packet path processing:
* struct nf_hook_entries_rcu_head head
*/
};
#ifdef CONFIG_NETFILTER
static inline struct nf_hook_ops **nf_hook_entries_get_hook_ops(const struct nf_hook_entries *e)
{
unsigned int n = e->num_hook_entries;
const void *hook_end;
hook_end = &e->hooks[n]; /* this is *past* ->hooks[]! */
return (struct nf_hook_ops **)hook_end;
}
static inline int
nf_hook_entry_hookfn(const struct nf_hook_entry *entry, struct sk_buff *skb,
struct nf_hook_state *state)
{
return entry->hook(entry->priv, skb, state);
}
static inline void nf_hook_state_init(struct nf_hook_state *p,
unsigned int hook,
u_int8_t pf,
struct net_device *indev,
struct net_device *outdev,
struct sock *sk,
struct net *net,
Annotation
- Immediate include surface: `linux/init.h`, `linux/skbuff.h`, `linux/net.h`, `linux/if.h`, `linux/in.h`, `linux/in6.h`, `linux/wait.h`, `linux/list.h`.
- Detected declarations: `struct sk_buff`, `struct nf_hook_ops`, `struct sock`, `struct nf_hook_state`, `struct nf_hook_ops`, `struct nf_hook_entry`, `struct nf_hook_entries_rcu_head`, `struct nf_hook_entries`, `struct nf_sockopt_ops`, `struct flowi`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.