net/ipv6/af_inet6.c
Source file repositories/reference/linux-study-clean/net/ipv6/af_inet6.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/af_inet6.c- Extension
.c- Size
- 29724 bytes
- Lines
- 1225
- 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.
- 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/capability.hlinux/errno.hlinux/types.hlinux/socket.hlinux/in.hlinux/kernel.hlinux/timer.hlinux/string.hlinux/sockios.hlinux/net.hlinux/fcntl.hlinux/mm.hlinux/interrupt.hlinux/proc_fs.hlinux/stat.hlinux/init.hlinux/slab.hlinux/inet.hlinux/netdevice.hlinux/icmpv6.hnet/ip.hnet/ipv6.hnet/udp.hnet/tcp.hnet/ping.hnet/protocol.hnet/inet_common.hnet/route.hnet/transp_v6.hnet/ip6_route.hnet/addrconf.h
Detected Declarations
struct compat_in6_rtmsgfunction inet6_sock_destructfunction inet6_createfunction __inet6_bindfunction inet6_bind_skfunction inet6_bindfunction inet6_releasefunction inet6_cleanup_sockfunction inet6_getnamefunction inet6_ioctlfunction inet6_compat_routing_ioctlfunction inet6_compat_ioctlfunction inet6_sendmsgfunction inet6_recvmsgfunction inet6_register_protoswfunction inet6_unregister_protoswfunction inet6_sk_rebuild_headerfunction ipv6_opt_acceptedfunction ipv6_packet_initfunction ipv6_packet_cleanupfunction ipv6_init_mibsfunction for_each_possible_cpufunction ipv6_cleanup_mibsfunction inet6_net_initfunction inet6_net_exitfunction inet6_initmodule init inet6_initexport inet6_sock_destructexport inet6_bindexport inet6_releaseexport inet6_getnameexport inet6_ioctlexport inet6_compat_ioctlexport inet6_stream_opsexport inet6_register_protoswexport inet6_unregister_protosw
Annotated Snippet
const struct proto_ops inet6_stream_ops = {
.family = PF_INET6,
.owner = THIS_MODULE,
.release = inet6_release,
.bind = inet6_bind,
.connect = inet_stream_connect, /* ok */
.socketpair = sock_no_socketpair, /* a do nothing */
.accept = inet_accept, /* ok */
.getname = inet6_getname,
.poll = tcp_poll, /* ok */
.ioctl = inet6_ioctl, /* must change */
.gettstamp = sock_gettstamp,
.listen = inet_listen, /* ok */
.shutdown = inet_shutdown, /* ok */
.setsockopt = sock_common_setsockopt, /* ok */
.getsockopt = sock_common_getsockopt, /* ok */
.sendmsg = inet6_sendmsg, /* retpoline's sake */
.recvmsg = inet6_recvmsg, /* retpoline's sake */
#ifdef CONFIG_MMU
.mmap = tcp_mmap,
#endif
.splice_eof = inet_splice_eof,
.sendmsg_locked = tcp_sendmsg_locked,
.splice_read = tcp_splice_read,
.set_peek_off = sk_set_peek_off,
.read_sock = tcp_read_sock,
.read_skb = tcp_read_skb,
.peek_len = tcp_peek_len,
#ifdef CONFIG_COMPAT
.compat_ioctl = inet6_compat_ioctl,
#endif
.set_rcvlowat = tcp_set_rcvlowat,
.set_rcvbuf = tcp_set_rcvbuf,
};
EXPORT_SYMBOL_GPL(inet6_stream_ops);
const struct proto_ops inet6_dgram_ops = {
.family = PF_INET6,
.owner = THIS_MODULE,
.release = inet6_release,
.bind = inet6_bind,
.connect = inet_dgram_connect, /* ok */
.socketpair = sock_no_socketpair, /* a do nothing */
.accept = sock_no_accept, /* a do nothing */
.getname = inet6_getname,
.poll = udp_poll, /* ok */
.ioctl = inet6_ioctl, /* must change */
.gettstamp = sock_gettstamp,
.listen = sock_no_listen, /* ok */
.shutdown = inet_shutdown, /* ok */
.setsockopt = sock_common_setsockopt, /* ok */
.getsockopt = sock_common_getsockopt, /* ok */
.sendmsg = inet6_sendmsg, /* retpoline's sake */
.recvmsg = inet6_recvmsg, /* retpoline's sake */
.read_skb = udp_read_skb,
.mmap = sock_no_mmap,
.set_peek_off = udp_set_peek_off,
#ifdef CONFIG_COMPAT
.compat_ioctl = inet6_compat_ioctl,
#endif
};
static const struct net_proto_family inet6_family_ops = {
.family = PF_INET6,
.create = inet6_create,
.owner = THIS_MODULE,
};
int inet6_register_protosw(struct inet_protosw *p)
{
struct list_head *lh;
struct inet_protosw *answer;
struct list_head *last_perm;
int protocol = p->protocol;
int ret;
spin_lock_bh(&inetsw6_lock);
ret = -EINVAL;
if (p->type >= SOCK_MAX)
goto out_illegal;
/* If we are trying to override a permanent protocol, bail. */
answer = NULL;
ret = -EPERM;
last_perm = &inetsw6[p->type];
list_for_each(lh, &inetsw6[p->type]) {
answer = list_entry(lh, struct inet_protosw, list);
/* Check only the non-wild match. */
Annotation
- Immediate include surface: `linux/module.h`, `linux/capability.h`, `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/in.h`, `linux/kernel.h`, `linux/timer.h`.
- Detected declarations: `struct compat_in6_rtmsg`, `function inet6_sock_destruct`, `function inet6_create`, `function __inet6_bind`, `function inet6_bind_sk`, `function inet6_bind`, `function inet6_release`, `function inet6_cleanup_sock`, `function inet6_getname`, `function inet6_ioctl`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.