net/ipv4/xfrm4_protocol.c
Source file repositories/reference/linux-study-clean/net/ipv4/xfrm4_protocol.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/xfrm4_protocol.c- Extension
.c- Size
- 6716 bytes
- Lines
- 307
- 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/init.hlinux/mutex.hlinux/skbuff.hnet/icmp.hnet/ip.hnet/protocol.hnet/xfrm.h
Detected Declarations
function xfrm4_rcv_cbfunction xfrm4_rcv_encapfunction xfrm4_esp_rcvfunction xfrm4_esp_errfunction xfrm4_ah_rcvfunction xfrm4_ah_errfunction xfrm4_ipcomp_rcvfunction xfrm4_ipcomp_errfunction xfrm4_protocol_registerfunction xfrm4_protocol_deregisterfunction xfrm4_protocol_initexport xfrm4_rcv_encapexport xfrm4_protocol_registerexport xfrm4_protocol_deregister
Annotated Snippet
if (inet_add_protocol(netproto(protocol), protocol)) {
pr_err("%s: can't add protocol\n", __func__);
ret = -EAGAIN;
}
}
return ret;
}
EXPORT_SYMBOL(xfrm4_protocol_register);
int xfrm4_protocol_deregister(struct xfrm4_protocol *handler,
unsigned char protocol)
{
struct xfrm4_protocol __rcu **pprev;
struct xfrm4_protocol *t;
int ret = -ENOENT;
if (!proto_handlers(protocol) || !netproto(protocol))
return -EINVAL;
mutex_lock(&xfrm4_protocol_mutex);
for (pprev = proto_handlers(protocol);
(t = rcu_dereference_protected(*pprev,
lockdep_is_held(&xfrm4_protocol_mutex))) != NULL;
pprev = &t->next) {
if (t == handler) {
*pprev = handler->next;
ret = 0;
break;
}
}
if (!rcu_dereference_protected(*proto_handlers(protocol),
lockdep_is_held(&xfrm4_protocol_mutex))) {
if (inet_del_protocol(netproto(protocol), protocol) < 0) {
pr_err("%s: can't remove protocol\n", __func__);
ret = -EAGAIN;
}
}
mutex_unlock(&xfrm4_protocol_mutex);
synchronize_net();
return ret;
}
EXPORT_SYMBOL(xfrm4_protocol_deregister);
void __init xfrm4_protocol_init(void)
{
xfrm_input_register_afinfo(&xfrm4_input_afinfo);
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/mutex.h`, `linux/skbuff.h`, `net/icmp.h`, `net/ip.h`, `net/protocol.h`, `net/xfrm.h`.
- Detected declarations: `function xfrm4_rcv_cb`, `function xfrm4_rcv_encap`, `function xfrm4_esp_rcv`, `function xfrm4_esp_err`, `function xfrm4_ah_rcv`, `function xfrm4_ah_err`, `function xfrm4_ipcomp_rcv`, `function xfrm4_ipcomp_err`, `function xfrm4_protocol_register`, `function xfrm4_protocol_deregister`.
- 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.