net/sctp/stream.c
Source file repositories/reference/linux-study-clean/net/sctp/stream.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/stream.c- Extension
.c- Size
- 27388 bytes
- Lines
- 1092
- 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.
- 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/list.hnet/sctp/sctp.hnet/sctp/sm.hnet/sctp/stream_sched.h
Detected Declarations
function Copyrightfunction list_for_each_entry_safefunction sctp_stream_free_extfunction sctp_stream_outq_migratefunction sctp_stream_alloc_outfunction sctp_stream_alloc_infunction sctp_stream_initfunction sctp_stream_init_extfunction sctp_stream_freefunction sctp_stream_clearfunction sctp_stream_updatefunction sctp_send_reconffunction sctp_stream_outq_is_emptyfunction sctp_send_reset_streamsfunction sctp_send_reset_assocfunction sctp_send_add_streamsfunction sctp_update_strreset_resultfunction TSN_ltfunction TSN_ltfunction TSN_ltfunction TSN_lt
Annotated Snippet
if (out) {
for (i = 0; i < str_nums; i++)
if (str_list[i] >= stream->outcnt)
goto out;
param_len = str_nums * sizeof(__u16) +
sizeof(struct sctp_strreset_outreq);
}
if (in) {
for (i = 0; i < str_nums; i++)
if (str_list[i] >= stream->incnt)
goto out;
param_len += str_nums * sizeof(__u16) +
sizeof(struct sctp_strreset_inreq);
}
if (param_len > SCTP_MAX_CHUNK_LEN -
sizeof(struct sctp_reconf_chunk))
goto out;
}
nstr_list = kcalloc(str_nums, sizeof(__be16), GFP_KERNEL);
if (!nstr_list) {
retval = -ENOMEM;
goto out;
}
for (i = 0; i < str_nums; i++)
nstr_list[i] = htons(str_list[i]);
if (out && !sctp_stream_outq_is_empty(stream, str_nums, nstr_list)) {
kfree(nstr_list);
retval = -EAGAIN;
goto out;
}
chunk = sctp_make_strreset_req(asoc, str_nums, nstr_list, out, in);
kfree(nstr_list);
if (!chunk) {
retval = -ENOMEM;
goto out;
}
if (out) {
if (str_nums)
for (i = 0; i < str_nums; i++)
SCTP_SO(stream, str_list[i])->state =
SCTP_STREAM_CLOSED;
else
for (i = 0; i < stream->outcnt; i++)
SCTP_SO(stream, i)->state = SCTP_STREAM_CLOSED;
}
asoc->strreset_chunk = chunk;
sctp_chunk_hold(asoc->strreset_chunk);
retval = sctp_send_reconf(asoc, chunk);
if (retval) {
sctp_chunk_put(asoc->strreset_chunk);
asoc->strreset_chunk = NULL;
if (!out)
goto out;
if (str_nums)
for (i = 0; i < str_nums; i++)
SCTP_SO(stream, str_list[i])->state =
SCTP_STREAM_OPEN;
else
for (i = 0; i < stream->outcnt; i++)
SCTP_SO(stream, i)->state = SCTP_STREAM_OPEN;
goto out;
}
asoc->strreset_outstanding = out + in;
out:
return retval;
}
int sctp_send_reset_assoc(struct sctp_association *asoc)
{
struct sctp_stream *stream = &asoc->stream;
struct sctp_chunk *chunk = NULL;
int retval;
__u16 i;
Annotation
- Immediate include surface: `linux/list.h`, `net/sctp/sctp.h`, `net/sctp/sm.h`, `net/sctp/stream_sched.h`.
- Detected declarations: `function Copyright`, `function list_for_each_entry_safe`, `function sctp_stream_free_ext`, `function sctp_stream_outq_migrate`, `function sctp_stream_alloc_out`, `function sctp_stream_alloc_in`, `function sctp_stream_init`, `function sctp_stream_init_ext`, `function sctp_stream_free`, `function sctp_stream_clear`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
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.