net/sctp/protocol.c
Source file repositories/reference/linux-study-clean/net/sctp/protocol.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/protocol.c- Extension
.c- Size
- 46618 bytes
- Lines
- 1720
- 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.
- 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/init.hlinux/netdevice.hlinux/inetdevice.hlinux/seq_file.hlinux/memblock.hlinux/highmem.hlinux/slab.hnet/flow.hnet/net_namespace.hnet/protocol.hnet/ip.hnet/ipv6.hnet/route.hnet/sctp/sctp.hnet/addrconf.hnet/inet_common.hnet/inet_ecn.hnet/inet_sock.hnet/udp_tunnel.hnet/inet_dscp.h
Detected Declarations
function sctp_v4_copy_addrlistfunction in_dev_for_each_ifa_rcufunction sctp_get_local_addr_listfunction list_for_eachfunction sctp_free_local_addr_listfunction list_for_each_safefunction sctp_copy_local_addr_listfunction sctp_v4_copy_ip_optionsfunction sctp_v4_ip_options_lenfunction sctp_v4_from_skbfunction sctp_v4_from_skfunction sctp_v4_to_sk_saddrfunction sctp_v4_to_sk_daddrfunction sctp_v4_from_addr_paramfunction sctp_v4_to_addr_paramfunction sctp_v4_dst_saddrfunction sctp_v4_cmp_addrfunction sctp_v4_inaddr_anyfunction sctp_v4_is_anyfunction sctp_v4_addr_validfunction sctp_v4_availablefunction sctp_v4_scopefunction ipv4_is_private_172function sctp_v4_get_dstfunction list_for_each_entry_rcufunction sctp_v4_get_saddrfunction sctp_v4_skb_iiffunction sctp_v4_skb_sdiffunction sctp_v4_is_cefunction sctp_v4_addr_to_userfunction sctp_v4_seq_dump_addrfunction sctp_v4_ecn_capablefunction sctp_addr_wq_timeout_handlerfunction list_for_each_entry_safefunction list_for_each_entryfunction sctp_free_addr_wqfunction list_for_each_entryfunction sctp_addr_wq_mgmtfunction list_emptyfunction notifiersfunction list_for_each_entry_safefunction sctp_ctl_sock_initfunction sctp_udp_rcvfunction sctp_udp_sock_startfunction sctp_udp_sock_stopfunction sctp_register_affunction sctp_inet_msgnamefunction sctp_inet_event_msgname
Annotated Snippet
static const struct proto_ops inet_seqpacket_ops = {
.family = PF_INET,
.owner = THIS_MODULE,
.release = inet_release, /* Needs to be wrapped... */
.bind = inet_bind,
.connect = sctp_inet_connect,
.socketpair = sock_no_socketpair,
.accept = inet_accept,
.getname = inet_getname, /* Semantics are different. */
.poll = sctp_poll,
.ioctl = inet_ioctl,
.gettstamp = sock_gettstamp,
.listen = sctp_inet_listen,
.shutdown = inet_shutdown, /* Looks harmless. */
.setsockopt = sock_common_setsockopt, /* IP_SOL IP_OPTION is a problem */
.getsockopt = sock_common_getsockopt,
.sendmsg = inet_sendmsg,
.recvmsg = inet_recvmsg,
.mmap = sock_no_mmap,
};
/* Registration with AF_INET family. */
static struct inet_protosw sctp_seqpacket_protosw = {
.type = SOCK_SEQPACKET,
.protocol = IPPROTO_SCTP,
.prot = &sctp_prot,
.ops = &inet_seqpacket_ops,
.flags = SCTP_PROTOSW_FLAG
};
static struct inet_protosw sctp_stream_protosw = {
.type = SOCK_STREAM,
.protocol = IPPROTO_SCTP,
.prot = &sctp_prot,
.ops = &inet_seqpacket_ops,
.flags = SCTP_PROTOSW_FLAG
};
static int sctp4_rcv(struct sk_buff *skb)
{
SCTP_INPUT_CB(skb)->encap_port = 0;
return sctp_rcv(skb);
}
/* Register with IP layer. */
static const struct net_protocol sctp_protocol = {
.handler = sctp4_rcv,
.err_handler = sctp_v4_err,
.no_policy = 1,
.icmp_strict_tag_validation = 1,
};
/* IPv4 address related functions. */
static struct sctp_af sctp_af_inet = {
.sa_family = AF_INET,
.sctp_xmit = sctp_v4_xmit,
.setsockopt = ip_setsockopt,
.getsockopt = ip_getsockopt,
.get_dst = sctp_v4_get_dst,
.get_saddr = sctp_v4_get_saddr,
.copy_addrlist = sctp_v4_copy_addrlist,
.from_skb = sctp_v4_from_skb,
.from_sk = sctp_v4_from_sk,
.from_addr_param = sctp_v4_from_addr_param,
.to_addr_param = sctp_v4_to_addr_param,
.cmp_addr = sctp_v4_cmp_addr,
.addr_valid = sctp_v4_addr_valid,
.inaddr_any = sctp_v4_inaddr_any,
.is_any = sctp_v4_is_any,
.available = sctp_v4_available,
.scope = sctp_v4_scope,
.skb_iif = sctp_v4_skb_iif,
.skb_sdif = sctp_v4_skb_sdif,
.is_ce = sctp_v4_is_ce,
.seq_dump_addr = sctp_v4_seq_dump_addr,
.ecn_capable = sctp_v4_ecn_capable,
.net_header_len = sizeof(struct iphdr),
.sockaddr_len = sizeof(struct sockaddr_in),
.ip_options_len = sctp_v4_ip_options_len,
};
struct sctp_pf *sctp_get_pf_specific(sa_family_t family)
{
switch (family) {
case PF_INET:
return sctp_pf_inet_specific;
case PF_INET6:
return sctp_pf_inet6_specific;
default:
return NULL;
}
Annotation
- Immediate include surface: `linux/module.h`, `linux/init.h`, `linux/netdevice.h`, `linux/inetdevice.h`, `linux/seq_file.h`, `linux/memblock.h`, `linux/highmem.h`, `linux/slab.h`.
- Detected declarations: `function sctp_v4_copy_addrlist`, `function in_dev_for_each_ifa_rcu`, `function sctp_get_local_addr_list`, `function list_for_each`, `function sctp_free_local_addr_list`, `function list_for_each_safe`, `function sctp_copy_local_addr_list`, `function sctp_v4_copy_ip_options`, `function sctp_v4_ip_options_len`, `function sctp_v4_from_skb`.
- 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.