net/netfilter/nf_conntrack_expect.c
Source file repositories/reference/linux-study-clean/net/netfilter/nf_conntrack_expect.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/nf_conntrack_expect.c- Extension
.c- Size
- 20896 bytes
- Lines
- 775
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/types.hlinux/netfilter.hlinux/skbuff.hlinux/proc_fs.hlinux/seq_file.hlinux/stddef.hlinux/slab.hlinux/err.hlinux/percpu.hlinux/kernel.hlinux/siphash.hlinux/moduleparam.hlinux/export.hnet/net_namespace.hnet/netns/hash.hnet/netfilter/nf_conntrack.hnet/netfilter/nf_conntrack_core.hnet/netfilter/nf_conntrack_ecache.hnet/netfilter/nf_conntrack_expect.hnet/netfilter/nf_conntrack_helper.hnet/netfilter/nf_conntrack_l4proto.hnet/netfilter/nf_conntrack_tuple.hnet/netfilter/nf_conntrack_zones.h
Detected Declarations
struct ct_expect_iter_statefunction nf_ct_unlink_expect_reportfunction nf_ct_expectation_timed_outfunction nf_ct_expect_dst_hashfunction nf_ct_exp_equalfunction nf_ct_remove_expectfunction __nf_ct_expect_findfunction nf_ct_expect_find_getfunction nf_ct_find_expectationfunction nf_ct_remove_expectationsfunction expect_clashfunction expect_matchesfunction master_matchesfunction nf_ct_unexpect_relatedfunction nf_ct_expect_initfunction nf_ct_expect_free_rcufunction nf_ct_expect_putfunction nf_ct_expect_insertfunction evict_oldest_expectfunction hlist_for_each_entryfunction __nf_ct_expect_checkfunction nf_ct_expect_related_reportfunction nf_ct_expect_iterate_destroyfunction hlist_for_each_entry_safefunction nf_ct_expect_iterate_netfunction hlist_for_each_entry_safefunction exp_seq_stopfunction exp_seq_showfunction exp_proc_initfunction exp_proc_removefunction nf_conntrack_expect_pernet_initfunction nf_conntrack_expect_pernet_finifunction nf_conntrack_expect_initfunction nf_conntrack_expect_finiexport nf_ct_expect_hsizeexport nf_ct_expect_hashexport nf_ct_unlink_expect_reportexport nf_ct_remove_expectexport __nf_ct_expect_findexport nf_ct_expect_find_getexport nf_ct_remove_expectationsexport nf_ct_unexpect_relatedexport nf_ct_expect_allocexport nf_ct_expect_initexport nf_ct_expect_putexport nf_ct_expect_related_reportexport nf_ct_expect_iterate_destroyexport nf_ct_expect_iterate_net
Annotated Snippet
struct ct_expect_iter_state {
struct seq_net_private p;
unsigned int bucket;
};
static struct hlist_node *ct_expect_get_first(struct seq_file *seq)
{
struct ct_expect_iter_state *st = seq->private;
struct hlist_node *n;
for (st->bucket = 0; st->bucket < nf_ct_expect_hsize; st->bucket++) {
n = rcu_dereference(hlist_first_rcu(&nf_ct_expect_hash[st->bucket]));
if (n)
return n;
}
return NULL;
}
static struct hlist_node *ct_expect_get_next(struct seq_file *seq,
struct hlist_node *head)
{
struct ct_expect_iter_state *st = seq->private;
head = rcu_dereference(hlist_next_rcu(head));
while (head == NULL) {
if (++st->bucket >= nf_ct_expect_hsize)
return NULL;
head = rcu_dereference(hlist_first_rcu(&nf_ct_expect_hash[st->bucket]));
}
return head;
}
static struct hlist_node *ct_expect_get_idx(struct seq_file *seq, loff_t pos)
{
struct hlist_node *head = ct_expect_get_first(seq);
if (head)
while (pos && (head = ct_expect_get_next(seq, head)))
pos--;
return pos ? NULL : head;
}
static void *exp_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
{
rcu_read_lock();
return ct_expect_get_idx(seq, *pos);
}
static void *exp_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
(*pos)++;
return ct_expect_get_next(seq, v);
}
static void exp_seq_stop(struct seq_file *seq, void *v)
__releases(RCU)
{
rcu_read_unlock();
}
static int exp_seq_show(struct seq_file *s, void *v)
{
struct nf_conntrack_expect *expect;
struct nf_conntrack_helper *helper;
struct net *net = seq_file_net(s);
struct hlist_node *n = v;
char *delim = "";
expect = hlist_entry(n, struct nf_conntrack_expect, hnode);
if (!net_eq(nf_ct_exp_net(expect), net))
return 0;
if (expect->timeout.function)
seq_printf(s, "%ld ", timer_pending(&expect->timeout)
? (long)(expect->timeout.expires - jiffies)/HZ : 0);
else
seq_puts(s, "- ");
seq_printf(s, "l3proto = %u proto=%u ",
expect->tuple.src.l3num,
expect->tuple.dst.protonum);
print_tuple(s, &expect->tuple,
nf_ct_l4proto_find(expect->tuple.dst.protonum));
if (expect->flags & NF_CT_EXPECT_PERMANENT) {
seq_puts(s, "PERMANENT");
delim = ",";
}
if (expect->flags & NF_CT_EXPECT_INACTIVE) {
Annotation
- Immediate include surface: `linux/types.h`, `linux/netfilter.h`, `linux/skbuff.h`, `linux/proc_fs.h`, `linux/seq_file.h`, `linux/stddef.h`, `linux/slab.h`, `linux/err.h`.
- Detected declarations: `struct ct_expect_iter_state`, `function nf_ct_unlink_expect_report`, `function nf_ct_expectation_timed_out`, `function nf_ct_expect_dst_hash`, `function nf_ct_exp_equal`, `function nf_ct_remove_expect`, `function __nf_ct_expect_find`, `function nf_ct_expect_find_get`, `function nf_ct_find_expectation`, `function nf_ct_remove_expectations`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.