net/netfilter/ipvs/ip_vs_ctl.c
Source file repositories/reference/linux-study-clean/net/netfilter/ipvs/ip_vs_ctl.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/ipvs/ip_vs_ctl.c- Extension
.c- Size
- 137701 bytes
- Lines
- 5324
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/init.hlinux/types.hlinux/capability.hlinux/fs.hlinux/sysctl.hlinux/proc_fs.hlinux/workqueue.hlinux/seq_file.hlinux/slab.hlinux/netfilter.hlinux/netfilter_ipv4.hlinux/mutex.hlinux/rcupdate_wait.hnet/net_namespace.hlinux/nsproxy.hnet/ip.hnet/ipv6.hnet/ip6_route.hnet/netfilter/ipv6/nf_defrag_ipv6.hnet/route.hnet/sock.hnet/genetlink.hlinux/uaccess.hnet/ip_vs.h
Detected Declarations
struct ip_vs_iterstruct ip_vs_svcdest_userfunction ip_vs_get_debug_levelfunction __ip_vs_addr_is_local_v6function update_defense_levelfunction expire_nodest_conn_handlerfunction defense_work_handlerfunction est_reload_work_handlerfunction get_conn_tab_sizefunction ip_vs_use_count_incfunction ip_vs_use_count_decfunction tablesfunction ip_vs_svc_fwm_hashvalfunction ip_vs_svc_hashfunction ip_vs_svc_unhashfunction __ip_vs_service_findfunction ip_vs_rht_for_each_table_rcufunction ip_vs_rht_walk_bucket_rcufunction __ip_vs_svc_fwm_findfunction ip_vs_rht_for_each_table_rcufunction ip_vs_rht_walk_bucket_rcufunction ip_vs_service_findfunction ip_vs_get_num_servicesfunction ip_vs_svc_default_load_factorfunction ip_vs_svc_desired_sizefunction svc_resize_work_handlerfunction ip_vs_rht_for_each_bucketfunction hlist_bl_for_each_entry_safefunction __ip_vs_bind_svcfunction ip_vs_service_freefunction ip_vs_service_rcu_freefunction __ip_vs_svc_putfunction ip_vs_rs_hashkeyfunction ip_vs_rs_hashfunction ip_vs_rs_unhashfunction ip_vs_has_real_servicefunction hlist_for_each_entry_rcufunction hlist_for_each_entry_rcufunction hlist_for_each_entry_rcufunction ip_vs_lookup_destfunction ip_vs_process_messagefunction ip_vs_dest_dst_rcu_freefunction __ip_vs_dst_cache_resetfunction downfunction ip_vs_trash_put_destfunction ip_vs_dest_rcu_freefunction ip_vs_dest_freefunction ip_vs_control_cleanup
Annotated Snippet
struct ip_vs_iter {
struct seq_net_private p; /* Do not move this, netns depends upon it*/
struct ip_vs_rht *t;
u32 bucket;
};
/*
* Write the contents of the VS rule table to a PROCfs file.
* (It is kept just for backward compatibility)
*/
static inline const char *ip_vs_fwd_name(unsigned int flags)
{
switch (flags & IP_VS_CONN_F_FWD_MASK) {
case IP_VS_CONN_F_LOCALNODE:
return "Local";
case IP_VS_CONN_F_TUNNEL:
return "Tunnel";
case IP_VS_CONN_F_DROUTE:
return "Route";
default:
return "Masq";
}
}
/* Do not expect consistent view during add, del and move(table resize).
* We may miss entries and even show duplicates.
*/
static struct ip_vs_service *ip_vs_info_array(struct seq_file *seq, loff_t pos)
{
struct ip_vs_iter *iter = seq->private;
struct ip_vs_rht *t = iter->t;
struct ip_vs_service *svc;
struct hlist_bl_node *e;
int idx;
if (!t)
return NULL;
for (idx = 0; idx < t->size; idx++) {
hlist_bl_for_each_entry_rcu(svc, e, &t->buckets[idx], s_list) {
if (!ip_vs_rht_same_table(t, READ_ONCE(svc->hash_key)))
break;
if (pos-- == 0) {
iter->bucket = idx;
return svc;
}
}
}
return NULL;
}
static void *ip_vs_info_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
{
struct ip_vs_iter *iter = seq->private;
struct net *net = seq_file_net(seq);
struct netns_ipvs *ipvs = net_ipvs(net);
rcu_read_lock();
iter->t = rcu_dereference(ipvs->svc_table);
return *pos ? ip_vs_info_array(seq, *pos - 1) : SEQ_START_TOKEN;
}
static void *ip_vs_info_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct ip_vs_service *svc;
struct ip_vs_iter *iter;
struct hlist_bl_node *e;
struct ip_vs_rht *t;
++*pos;
if (v == SEQ_START_TOKEN)
return ip_vs_info_array(seq,0);
svc = v;
iter = seq->private;
t = iter->t;
if (!t)
return NULL;
hlist_bl_for_each_entry_continue_rcu(svc, e, s_list) {
/* Our cursor was moved to new table ? */
if (!ip_vs_rht_same_table(t, READ_ONCE(svc->hash_key)))
break;
return svc;
}
while (++iter->bucket < t->size) {
hlist_bl_for_each_entry_rcu(svc, e, &t->buckets[iter->bucket],
s_list) {
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/types.h`, `linux/capability.h`, `linux/fs.h`, `linux/sysctl.h`, `linux/proc_fs.h`, `linux/workqueue.h`.
- Detected declarations: `struct ip_vs_iter`, `struct ip_vs_svcdest_user`, `function ip_vs_get_debug_level`, `function __ip_vs_addr_is_local_v6`, `function update_defense_level`, `function expire_nodest_conn_handler`, `function defense_work_handler`, `function est_reload_work_handler`, `function get_conn_tab_size`, `function ip_vs_use_count_inc`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.