net/netfilter/ipvs/ip_vs_conn.c
Source file repositories/reference/linux-study-clean/net/netfilter/ipvs/ip_vs_conn.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/ipvs/ip_vs_conn.c- Extension
.c- Size
- 54006 bytes
- Lines
- 2057
- 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/interrupt.hlinux/in.hlinux/inet.hlinux/net.hlinux/kernel.hlinux/module.hlinux/proc_fs.hlinux/slab.hlinux/seq_file.hlinux/jhash.hlinux/random.hlinux/rcupdate_wait.hnet/net_namespace.hnet/ip_vs.h
Detected Declarations
struct ip_vs_iter_statefunction connsfunction conn_tab_unlockfunction ip_vs_conn_hashkeyfunction ip_vs_conn_hashkey_paramfunction ip_vs_conn_hashkey_connfunction ip_vs_conn_hashfunction ip_vs_conn_unlinkfunction __ip_vs_conn_in_getfunction ip_vs_rht_for_each_table_rcufunction ip_vs_rht_walk_bucket_rcufunction ip_vs_conn_fill_param_protofunction ip_vs_conn_in_get_protofunction ip_vs_rht_for_each_table_rcufunction ip_vs_rht_walk_bucket_rcufunction ip_vs_rht_for_each_table_rcufunction ip_vs_rht_walk_bucket_rcufunction ip_vs_conn_out_get_protofunction __ip_vs_conn_put_timerfunction ip_vs_conn_putfunction ip_vs_conn_fill_cportfunction ip_vs_conn_default_load_factorfunction ip_vs_conn_desired_sizefunction conn_resize_work_handlerfunction ip_vs_rht_for_each_bucketfunction hlist_bl_for_each_entry_safefunction ip_vs_bind_xmitfunction ip_vs_bind_xmit_v6function ip_vs_dest_totalconnsfunction ip_vs_bind_destfunction ip_vs_try_bind_destfunction ip_vs_unbind_destfunction expire_quiescent_templatefunction ip_vs_check_templatefunction expire_quiescent_templatefunction ip_vs_conn_rcu_freefunction ip_vs_conn_delfunction ip_vs_conn_del_putfunction ip_vs_conn_expirefunction ip_vs_conn_expire_nowfunction ip_vs_conn_newfunction hlist_bl_for_each_entry_rcufunction ip_vs_conn_seq_stopfunction ip_vs_conn_seq_showfunction ip_vs_conn_sync_seq_showfunction todrop_entryfunction ip_vs_conn_ops_modefunction ip_vs_random_dropentry
Annotated Snippet
struct ip_vs_iter_state {
struct seq_net_private p;
struct ip_vs_rht *t;
int gen;
u32 bucket;
unsigned int skip_elems;
};
static void *ip_vs_conn_array(struct seq_file *seq)
{
struct ip_vs_iter_state *iter = seq->private;
struct net *net = seq_file_net(seq);
struct netns_ipvs *ipvs = net_ipvs(net);
struct ip_vs_rht *t = iter->t;
struct ip_vs_conn_hnode *hn;
struct hlist_bl_node *e;
int idx;
if (!t)
return NULL;
for (idx = iter->bucket; idx < t->size; idx++) {
unsigned int skip = 0;
hlist_bl_for_each_entry_rcu(hn, e, &t->buckets[idx], node) {
/* __ip_vs_conn_get() is not needed by
* ip_vs_conn_seq_show and ip_vs_conn_sync_seq_show
*/
if (!ip_vs_rht_same_table(t, READ_ONCE(hn->hash_key)))
break;
if (hn->dir != 0)
continue;
if (skip >= iter->skip_elems) {
iter->bucket = idx;
return hn;
}
++skip;
}
if (!(idx & 31)) {
cond_resched_rcu();
/* New table installed ? */
if (iter->gen != atomic_read(&ipvs->conn_tab_changes))
break;
}
iter->skip_elems = 0;
}
iter->bucket = idx;
return NULL;
}
static void *ip_vs_conn_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
{
struct ip_vs_iter_state *iter = seq->private;
struct net *net = seq_file_net(seq);
struct netns_ipvs *ipvs = net_ipvs(net);
rcu_read_lock();
iter->gen = atomic_read(&ipvs->conn_tab_changes);
smp_rmb(); /* ipvs->conn_tab and conn_tab_changes */
iter->t = rcu_dereference(ipvs->conn_tab);
if (*pos == 0) {
iter->skip_elems = 0;
iter->bucket = 0;
return SEQ_START_TOKEN;
}
return ip_vs_conn_array(seq);
}
static void *ip_vs_conn_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct ip_vs_iter_state *iter = seq->private;
struct ip_vs_conn_hnode *hn = v;
struct hlist_bl_node *e;
struct ip_vs_rht *t;
++*pos;
if (v == SEQ_START_TOKEN)
return ip_vs_conn_array(seq);
t = iter->t;
if (!t)
return NULL;
/* more on same hash chain? */
hlist_bl_for_each_entry_continue_rcu(hn, e, node) {
/* Our cursor was moved to new table ? */
Annotation
- Immediate include surface: `linux/interrupt.h`, `linux/in.h`, `linux/inet.h`, `linux/net.h`, `linux/kernel.h`, `linux/module.h`, `linux/proc_fs.h`, `linux/slab.h`.
- Detected declarations: `struct ip_vs_iter_state`, `function conns`, `function conn_tab_unlock`, `function ip_vs_conn_hashkey`, `function ip_vs_conn_hashkey_param`, `function ip_vs_conn_hashkey_conn`, `function ip_vs_conn_hash`, `function ip_vs_conn_unlink`, `function __ip_vs_conn_in_get`, `function ip_vs_rht_for_each_table_rcu`.
- 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.