net/ipv4/af_inet.c
Source file repositories/reference/linux-study-clean/net/ipv4/af_inet.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv4/af_inet.c- Extension
.c- Size
- 51082 bytes
- Lines
- 2057
- 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/err.hlinux/errno.hlinux/types.hlinux/socket.hlinux/in.hlinux/kernel.hlinux/kmod.hlinux/sched.hlinux/timer.hlinux/string.hlinux/sockios.hlinux/net.hlinux/capability.hlinux/fcntl.hlinux/mm.hlinux/interrupt.hlinux/stat.hlinux/init.hlinux/poll.hlinux/netfilter_ipv4.hlinux/random.hlinux/slab.hlinux/uaccess.hlinux/inet.hlinux/igmp.hlinux/inetdevice.hlinux/netdevice.hnet/checksum.hnet/ip.hnet/protocol.hnet/arp.hnet/route.h
Detected Declarations
function inet_sock_destructfunction inet_autobindfunction __inet_listen_skfunction inet_listenfunction inet_createfunction NULLfunction inet_bind_skfunction inet_bindfunction __inet_bindfunction inet_dgram_connectfunction inet_wait_for_connectfunction Connectfunction __inet_stream_connectfunction writefunction inet_stream_connectfunction __inet_acceptfunction inet_acceptfunction inet_getnamefunction inet_send_preparefunction inet_sendmsgfunction inet_splice_eoffunction inet_recvmsgfunction inet_shutdownfunction ioctlfunction inet_compat_routing_ioctlfunction inet_compat_ioctlfunction inet_register_protoswfunction inet_unregister_protoswfunction inet_sk_reselect_saddrfunction inet_sk_rebuild_headerfunction inet_sk_set_statefunction inet_sk_state_storefunction list_for_each_entryfunction inet_current_timestampfunction inet_recv_errorfunction inet_gro_completefunction ipip_gro_completefunction inet_ctl_sock_createfunction snmp_fold_fieldfunction snmp_get_cpu_field64function snmp_fold_field64function for_each_possible_cpufunction ipv4_mib_init_netfunction for_each_possible_cpufunction ipv4_mib_exit_netfunction init_ipv4_mibsfunction inet_init_netfunction init_inet_pernet_ops
Annotated Snippet
const struct proto_ops inet_stream_ops = {
.family = PF_INET,
.owner = THIS_MODULE,
.release = inet_release,
.bind = inet_bind,
.connect = inet_stream_connect,
.socketpair = sock_no_socketpair,
.accept = inet_accept,
.getname = inet_getname,
.poll = tcp_poll,
.ioctl = inet_ioctl,
.gettstamp = sock_gettstamp,
.listen = inet_listen,
.shutdown = inet_shutdown,
.setsockopt = sock_common_setsockopt,
.getsockopt = sock_common_getsockopt,
.sendmsg = inet_sendmsg,
.recvmsg = inet_recvmsg,
#ifdef CONFIG_MMU
.mmap = tcp_mmap,
#endif
.splice_eof = inet_splice_eof,
.splice_read = tcp_splice_read,
.set_peek_off = sk_set_peek_off,
.read_sock = tcp_read_sock,
.read_skb = tcp_read_skb,
.sendmsg_locked = tcp_sendmsg_locked,
.peek_len = tcp_peek_len,
#ifdef CONFIG_COMPAT
.compat_ioctl = inet_compat_ioctl,
#endif
.set_rcvlowat = tcp_set_rcvlowat,
.set_rcvbuf = tcp_set_rcvbuf,
};
EXPORT_SYMBOL(inet_stream_ops);
const struct proto_ops inet_dgram_ops = {
.family = PF_INET,
.owner = THIS_MODULE,
.release = inet_release,
.bind = inet_bind,
.connect = inet_dgram_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = inet_getname,
.poll = udp_poll,
.ioctl = inet_ioctl,
.gettstamp = sock_gettstamp,
.listen = sock_no_listen,
.shutdown = inet_shutdown,
.setsockopt = sock_common_setsockopt,
.getsockopt = sock_common_getsockopt,
.sendmsg = inet_sendmsg,
.read_skb = udp_read_skb,
.recvmsg = inet_recvmsg,
.mmap = sock_no_mmap,
.splice_eof = inet_splice_eof,
.set_peek_off = udp_set_peek_off,
#ifdef CONFIG_COMPAT
.compat_ioctl = inet_compat_ioctl,
#endif
};
EXPORT_SYMBOL(inet_dgram_ops);
/*
* For SOCK_RAW sockets; should be the same as inet_dgram_ops but without
* udp_poll
*/
static const struct proto_ops inet_sockraw_ops = {
.family = PF_INET,
.owner = THIS_MODULE,
.release = inet_release,
.bind = inet_bind,
.connect = inet_dgram_connect,
.socketpair = sock_no_socketpair,
.accept = sock_no_accept,
.getname = inet_getname,
.poll = datagram_poll,
.ioctl = inet_ioctl,
.gettstamp = sock_gettstamp,
.listen = sock_no_listen,
.shutdown = inet_shutdown,
.setsockopt = sock_common_setsockopt,
.getsockopt = sock_common_getsockopt,
.sendmsg = inet_sendmsg,
.recvmsg = inet_recvmsg,
.mmap = sock_no_mmap,
.splice_eof = inet_splice_eof,
#ifdef CONFIG_COMPAT
.compat_ioctl = inet_compat_ioctl,
Annotation
- Immediate include surface: `linux/err.h`, `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/in.h`, `linux/kernel.h`, `linux/kmod.h`, `linux/sched.h`.
- Detected declarations: `function inet_sock_destruct`, `function inet_autobind`, `function __inet_listen_sk`, `function inet_listen`, `function inet_create`, `function NULL`, `function inet_bind_sk`, `function inet_bind`, `function __inet_bind`, `function inet_dgram_connect`.
- 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.