net/sctp/socket.c
Source file repositories/reference/linux-study-clean/net/sctp/socket.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/socket.c- Extension
.c- Size
- 271543 bytes
- Lines
- 9732
- 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.
- 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/types.hlinux/kernel.hlinux/wait.hlinux/time.hlinux/sched/signal.hlinux/ip.hlinux/capability.hlinux/fcntl.hlinux/poll.hlinux/init.hlinux/slab.hlinux/file.hlinux/compat.hlinux/rhashtable.hnet/ip.hnet/icmp.hnet/route.hnet/ipv6.hnet/inet_common.hnet/busy_poll.htrace/events/sock.hlinux/socket.hlinux/export.hnet/sock.hnet/sctp/sctp.hnet/sctp/sm.hnet/sctp/stream_sched.hnet/rps.h
Detected Declarations
struct compat_sctp_getaddrs_oldfunction sctp_enter_memory_pressurefunction sctp_wspacefunction sctp_packet_transmitfunction sctp_clear_owner_wfunction sctp_for_each_tx_datachunkfunction sctp_for_each_rx_skbfunction sctp_verify_addrfunction sctp_bindfunction sctp_auto_asconf_initfunction sctp_do_bindfunction sctp_send_asconffunction sctp_do_bindfunction sctp_setsockopt_bindxfunction list_for_each_entryfunction list_for_each_entryfunction sctp_setsockopt_bindxfunction sctp_setsockopt_bindxfunction list_for_each_entryfunction list_for_each_entryfunction list_for_each_entryfunction sctp_asconf_mgmtfunction sctp_bindxfunction sctp_bind_addfunction sctp_connect_new_asocfunction sctp_connect_add_peerfunction connectfunction structurefunction sctp_setsockopt_connectx_oldfunction sctp_setsockopt_connectxfunction sctp_getsockopt_connectx3function closefunction sctp_errorfunction sctp_sendmsg_parsefunction sctp_sendmsg_new_asocfunction sctp_sendmsg_check_sflagsfunction sctp_sendmsg_to_asocfunction list_for_each_entryfunction sctp_sendmsg_update_sinfofunction sctp_sendmsgfunction list_for_each_entry_safefunction sctp_skb_pullfunction skb_walk_fragsfunction sctp_recvmsgfunction recvmsgfunction sctp_setsockopt_disable_fragmentsfunction sctp_setsockopt_eventsfunction sctp_setsockopt_autoclose
Annotated Snippet
struct compat_sctp_getaddrs_old {
sctp_assoc_t assoc_id;
s32 addr_num;
compat_uptr_t addrs; /* struct sockaddr * */
};
#endif
static int sctp_getsockopt_connectx3(struct sock *sk, int len,
char __user *optval,
int __user *optlen)
{
struct sctp_getaddrs_old param;
sctp_assoc_t assoc_id = 0;
struct sockaddr *kaddrs;
int err = 0;
#ifdef CONFIG_COMPAT
if (in_compat_syscall()) {
struct compat_sctp_getaddrs_old param32;
if (len < sizeof(param32))
return -EINVAL;
if (copy_from_user(¶m32, optval, sizeof(param32)))
return -EFAULT;
param.assoc_id = param32.assoc_id;
param.addr_num = param32.addr_num;
param.addrs = compat_ptr(param32.addrs);
} else
#endif
{
if (len < sizeof(param))
return -EINVAL;
if (copy_from_user(¶m, optval, sizeof(param)))
return -EFAULT;
}
kaddrs = memdup_user(param.addrs, param.addr_num);
if (IS_ERR(kaddrs))
return PTR_ERR(kaddrs);
err = __sctp_setsockopt_connectx(sk, kaddrs, param.addr_num, &assoc_id);
kfree(kaddrs);
if (err == 0 || err == -EINPROGRESS) {
if (copy_to_user(optval, &assoc_id, sizeof(assoc_id)))
return -EFAULT;
if (put_user(sizeof(assoc_id), optlen))
return -EFAULT;
}
return err;
}
/* API 3.1.4 close() - UDP Style Syntax
* Applications use close() to perform graceful shutdown (as described in
* Section 10.1 of [SCTP]) on ALL the associations currently represented
* by a UDP-style socket.
*
* The syntax is
*
* ret = close(int sd);
*
* sd - the socket descriptor of the associations to be closed.
*
* To gracefully shutdown a specific association represented by the
* UDP-style socket, an application should use the sendmsg() call,
* passing no user data, but including the appropriate flag in the
* ancillary data (see Section xxxx).
*
* If sd in the close() call is a branched-off socket representing only
* one association, the shutdown is performed on that association only.
*
* 4.1.6 close() - TCP Style Syntax
*
* Applications use close() to gracefully close down an association.
*
* The syntax is:
*
* int close(int sd);
*
* sd - the socket descriptor of the association to be closed.
*
* After an application calls close() on a socket descriptor, no further
* socket operations will succeed on that descriptor.
*
* API 7.1.4 SO_LINGER
*
* An application using the TCP-style socket can use this option to
* perform the SCTP ABORT primitive. The linger option structure is:
*
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/wait.h`, `linux/time.h`, `linux/sched/signal.h`, `linux/ip.h`, `linux/capability.h`, `linux/fcntl.h`.
- Detected declarations: `struct compat_sctp_getaddrs_old`, `function sctp_enter_memory_pressure`, `function sctp_wspace`, `function sctp_packet_transmit`, `function sctp_clear_owner_w`, `function sctp_for_each_tx_datachunk`, `function sctp_for_each_rx_skb`, `function sctp_verify_addr`, `function sctp_bind`, `function sctp_auto_asconf_init`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.