net/sctp/endpointola.c
Source file repositories/reference/linux-study-clean/net/sctp/endpointola.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/endpointola.c- Extension
.c- Size
- 10848 bytes
- Lines
- 424
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- 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/slab.hlinux/in.hlinux/random.hnet/sock.hnet/ipv6.hnet/sctp/sctp.hnet/sctp/sm.h
Detected Declarations
function gen_cookie_auth_keyfunction sctp_endpoint_add_asocfunction sctp_endpoint_freefunction sctp_endpoint_destroy_rcufunction sctp_endpoint_destroyfunction sctp_endpoint_holdfunction sctp_endpoint_putfunction sctp_endpoint_is_peeled_offfunction sctp_endpoint_bh_rcvfunction later
Annotated Snippet
if (ep->asconf_enable) {
sctp_auth_ep_add_chunkid(ep, SCTP_CID_ASCONF);
sctp_auth_ep_add_chunkid(ep, SCTP_CID_ASCONF_ACK);
}
}
/* Initialize the base structure. */
/* What type of endpoint are we? */
ep->base.type = SCTP_EP_TYPE_SOCKET;
/* Initialize the basic object fields. */
refcount_set(&ep->base.refcnt, 1);
ep->base.dead = false;
/* Create an input queue. */
sctp_inq_init(&ep->base.inqueue);
/* Set its top-half handler */
sctp_inq_set_th_handler(&ep->base.inqueue, sctp_endpoint_bh_rcv);
/* Initialize the bind addr area */
sctp_bind_addr_init(&ep->base.bind_addr, 0);
/* Create the lists of associations. */
INIT_LIST_HEAD(&ep->asocs);
/* Use SCTP specific send buffer space queues. */
ep->sndbuf_policy = net->sctp.sndbuf_policy;
sk->sk_data_ready = sctp_data_ready;
sk->sk_write_space = sctp_write_space;
sock_set_flag(sk, SOCK_USE_WRITE_QUEUE);
/* Get the receive buffer policy for this endpoint */
ep->rcvbuf_policy = net->sctp.rcvbuf_policy;
/* Generate the cookie authentication key. */
gen_cookie_auth_key(&ep->cookie_auth_key);
/* SCTP-AUTH extensions*/
INIT_LIST_HEAD(&ep->endpoint_shared_keys);
null_key = sctp_auth_shkey_create(0, gfp);
if (!null_key)
goto nomem_shkey;
list_add(&null_key->key_list, &ep->endpoint_shared_keys);
/* Add the null key to the endpoint shared keys list and
* set the hmcas and chunks pointers.
*/
ep->prsctp_enable = net->sctp.prsctp_enable;
ep->reconf_enable = net->sctp.reconf_enable;
ep->ecn_enable = net->sctp.ecn_enable;
/* Remember who we are attached to. */
ep->base.sk = sk;
ep->base.net = sock_net(sk);
sock_hold(ep->base.sk);
return ep;
nomem_shkey:
sctp_auth_free(ep);
nomem:
return NULL;
}
/* Create a sctp_endpoint with all that boring stuff initialized.
* Returns NULL if there isn't enough memory.
*/
struct sctp_endpoint *sctp_endpoint_new(struct sock *sk, gfp_t gfp)
{
struct sctp_endpoint *ep;
/* Build a local endpoint. */
ep = kzalloc_obj(*ep, gfp);
if (!ep)
goto fail;
if (!sctp_endpoint_init(ep, sk, gfp))
goto fail_init;
SCTP_DBG_OBJCNT_INC(ep);
return ep;
fail_init:
kfree(ep);
fail:
return NULL;
Annotation
- Immediate include surface: `linux/types.h`, `linux/slab.h`, `linux/in.h`, `linux/random.h`, `net/sock.h`, `net/ipv6.h`, `net/sctp/sctp.h`, `net/sctp/sm.h`.
- Detected declarations: `function gen_cookie_auth_key`, `function sctp_endpoint_add_asoc`, `function sctp_endpoint_free`, `function sctp_endpoint_destroy_rcu`, `function sctp_endpoint_destroy`, `function sctp_endpoint_hold`, `function sctp_endpoint_put`, `function sctp_endpoint_is_peeled_off`, `function sctp_endpoint_bh_rcv`, `function later`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.