net/netfilter/ipvs/ip_vs_proto.c
Source file repositories/reference/linux-study-clean/net/netfilter/ipvs/ip_vs_proto.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/ipvs/ip_vs_proto.c- Extension
.c- Size
- 8477 bytes
- Lines
- 382
- 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.
- 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/kernel.hlinux/skbuff.hlinux/gfp.hlinux/in.hlinux/ip.hnet/protocol.hnet/tcp.hnet/udp.hlinux/stat.hlinux/proc_fs.hnet/ip_vs.h
Detected Declarations
function register_ip_vs_protocolfunction register_ip_vs_proto_netnsfunction unregister_ip_vs_protocolfunction unregister_ip_vs_proto_netnsfunction ip_vs_proto_getfunction ip_vs_proto_data_getfunction ip_vs_protocol_timeout_changefunction ip_vs_create_timeout_tablefunction ip_vs_tcpudp_debug_packet_v4function ip_vs_tcpudp_debug_packet_v6function ip_vs_tcpudp_debug_packetfunction ip_vs_protocol_net_initfunction ip_vs_protocol_net_cleanupfunction ip_vs_protocol_initfunction ip_vs_protocol_cleanupexport ip_vs_proto_getexport ip_vs_proto_data_get
Annotated Snippet
if (ret) {
/* unlink an free proto data */
ipvs->proto_data_table[hash] = pd->next;
kfree(pd);
return ret;
}
}
return 0;
}
/*
* unregister an ipvs protocol
*/
static int unregister_ip_vs_protocol(struct ip_vs_protocol *pp)
{
struct ip_vs_protocol **pp_p;
unsigned int hash = IP_VS_PROTO_HASH(pp->protocol);
pp_p = &ip_vs_proto_table[hash];
for (; *pp_p; pp_p = &(*pp_p)->next) {
if (*pp_p == pp) {
*pp_p = pp->next;
if (pp->exit != NULL)
pp->exit(pp);
return 0;
}
}
return -ESRCH;
}
/*
* unregister an ipvs protocols netns data
*/
static int
unregister_ip_vs_proto_netns(struct netns_ipvs *ipvs, struct ip_vs_proto_data *pd)
{
struct ip_vs_proto_data **pd_p;
unsigned int hash = IP_VS_PROTO_HASH(pd->pp->protocol);
pd_p = &ipvs->proto_data_table[hash];
for (; *pd_p; pd_p = &(*pd_p)->next) {
if (*pd_p == pd) {
*pd_p = pd->next;
if (pd->pp->exit_netns != NULL)
pd->pp->exit_netns(ipvs, pd);
kfree(pd);
return 0;
}
}
return -ESRCH;
}
/*
* get ip_vs_protocol object by its proto.
*/
struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto)
{
struct ip_vs_protocol *pp;
unsigned int hash = IP_VS_PROTO_HASH(proto);
for (pp = ip_vs_proto_table[hash]; pp; pp = pp->next) {
if (pp->protocol == proto)
return pp;
}
return NULL;
}
EXPORT_SYMBOL(ip_vs_proto_get);
/*
* get ip_vs_protocol object data by netns and proto
*/
struct ip_vs_proto_data *
ip_vs_proto_data_get(struct netns_ipvs *ipvs, unsigned short proto)
{
struct ip_vs_proto_data *pd;
unsigned int hash = IP_VS_PROTO_HASH(proto);
for (pd = ipvs->proto_data_table[hash]; pd; pd = pd->next) {
if (pd->pp->protocol == proto)
return pd;
}
return NULL;
}
EXPORT_SYMBOL(ip_vs_proto_data_get);
Annotation
- Immediate include surface: `linux/module.h`, `linux/kernel.h`, `linux/skbuff.h`, `linux/gfp.h`, `linux/in.h`, `linux/ip.h`, `net/protocol.h`, `net/tcp.h`.
- Detected declarations: `function register_ip_vs_protocol`, `function register_ip_vs_proto_netns`, `function unregister_ip_vs_protocol`, `function unregister_ip_vs_proto_netns`, `function ip_vs_proto_get`, `function ip_vs_proto_data_get`, `function ip_vs_protocol_timeout_change`, `function ip_vs_create_timeout_table`, `function ip_vs_tcpudp_debug_packet_v4`, `function ip_vs_tcpudp_debug_packet_v6`.
- 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.