net/l2tp/l2tp_ip6.c
Source file repositories/reference/linux-study-clean/net/l2tp/l2tp_ip6.c
File Facts
- System
- Linux kernel
- Corpus path
net/l2tp/l2tp_ip6.c- Extension
.c- Size
- 21317 bytes
- Lines
- 869
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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/icmp.hlinux/module.hlinux/skbuff.hlinux/random.hlinux/socket.hlinux/l2tp.hlinux/in.hlinux/in6.hnet/sock.hnet/ip.hnet/icmp.hnet/udp.hnet/inet_common.hnet/tcp_states.hnet/protocol.hnet/xfrm.hnet/net_namespace.hnet/netns/generic.hnet/transp_v6.hnet/addrconf.hnet/ip6_route.hl2tp_core.h
Detected Declarations
struct l2tp_ip6_netstruct l2tp_ip6_sockfunction sk_for_each_boundfunction l2tp_ip6_recvfunction l2tp_ip6_hashfunction l2tp_ip6_unhashfunction l2tp_ip6_openfunction l2tp_ip6_closefunction l2tp_ip6_destroy_sockfunction l2tp_ip6_bindfunction l2tp_ip6_connectfunction l2tp_ip6_disconnectfunction l2tp_ip6_getnamefunction l2tp_ip6_backlog_recvfunction l2tp_ip6_push_pending_framesfunction l2tp_ip6_sendmsgfunction l2tp_ip6_recvmsgfunction l2tp_ip6_init_netfunction l2tp_ip6_exit_netfunction l2tp_ip6_initfunction l2tp_ip6_exitmodule init l2tp_ip6_init
Annotated Snippet
static const struct proto_ops l2tp_ip6_ops = {
.family = PF_INET6,
.owner = THIS_MODULE,
.release = inet6_release,
.bind = inet6_bind,
.connect = inet_dgram_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = l2tp_ip6_getname,
.poll = datagram_poll,
.ioctl = inet6_ioctl,
.gettstamp = sock_gettstamp,
.listen = sock_no_listen,
.shutdown = inet_shutdown,
.setsockopt = sock_common_setsockopt,
.getsockopt = sock_common_getsockopt,
.sendmsg = inet_sendmsg,
.recvmsg = sock_common_recvmsg,
.mmap = sock_no_mmap,
#ifdef CONFIG_COMPAT
.compat_ioctl = inet6_compat_ioctl,
#endif
};
static struct inet_protosw l2tp_ip6_protosw = {
.type = SOCK_DGRAM,
.protocol = IPPROTO_L2TP,
.prot = &l2tp_ip6_prot,
.ops = &l2tp_ip6_ops,
};
static struct inet6_protocol l2tp_ip6_protocol __read_mostly = {
.handler = l2tp_ip6_recv,
};
static __net_init int l2tp_ip6_init_net(struct net *net)
{
struct l2tp_ip6_net *pn = net_generic(net, l2tp_ip6_net_id);
rwlock_init(&pn->l2tp_ip6_lock);
INIT_HLIST_HEAD(&pn->l2tp_ip6_table);
INIT_HLIST_HEAD(&pn->l2tp_ip6_bind_table);
return 0;
}
static __net_exit void l2tp_ip6_exit_net(struct net *net)
{
struct l2tp_ip6_net *pn = l2tp_ip6_pernet(net);
write_lock_bh(&pn->l2tp_ip6_lock);
WARN_ON_ONCE(hlist_count_nodes(&pn->l2tp_ip6_table) != 0);
WARN_ON_ONCE(hlist_count_nodes(&pn->l2tp_ip6_bind_table) != 0);
write_unlock_bh(&pn->l2tp_ip6_lock);
}
static struct pernet_operations l2tp_ip6_net_ops = {
.init = l2tp_ip6_init_net,
.exit = l2tp_ip6_exit_net,
.id = &l2tp_ip6_net_id,
.size = sizeof(struct l2tp_ip6_net),
};
static int __init l2tp_ip6_init(void)
{
int err;
pr_info("L2TP IP encapsulation support for IPv6 (L2TPv3)\n");
err = register_pernet_device(&l2tp_ip6_net_ops);
if (err)
goto out;
err = proto_register(&l2tp_ip6_prot, 1);
if (err != 0)
goto out1;
err = inet6_add_protocol(&l2tp_ip6_protocol, IPPROTO_L2TP);
if (err)
goto out2;
inet6_register_protosw(&l2tp_ip6_protosw);
return 0;
out2:
proto_unregister(&l2tp_ip6_prot);
out1:
unregister_pernet_device(&l2tp_ip6_net_ops);
out:
return err;
}
Annotation
- Immediate include surface: `linux/icmp.h`, `linux/module.h`, `linux/skbuff.h`, `linux/random.h`, `linux/socket.h`, `linux/l2tp.h`, `linux/in.h`, `linux/in6.h`.
- Detected declarations: `struct l2tp_ip6_net`, `struct l2tp_ip6_sock`, `function sk_for_each_bound`, `function l2tp_ip6_recv`, `function l2tp_ip6_hash`, `function l2tp_ip6_unhash`, `function l2tp_ip6_open`, `function l2tp_ip6_close`, `function l2tp_ip6_destroy_sock`, `function l2tp_ip6_bind`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.