net/sctp/stream_interleave.c
Source file repositories/reference/linux-study-clean/net/sctp/stream_interleave.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/stream_interleave.c- Extension
.c- Size
- 32104 bytes
- Lines
- 1354
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/busy_poll.hnet/sctp/sctp.hnet/sctp/sm.hnet/sctp/ulpevent.hlinux/sctp.h
Detected Declarations
function addreschedfunction sctp_chunk_assign_midfunction list_for_each_entryfunction sctp_validate_datafunction sctp_validate_idatafunction sctp_intl_store_reasmfunction skb_queue_walkfunction skb_queue_walkfunction sctp_intl_store_orderedfunction MID_ltfunction sctp_intl_retrieve_orderedfunction sctp_skb_for_eachfunction sctp_enqueue_eventfunction sctp_intl_store_reasm_uofunction skb_queue_walkfunction skb_queue_walkfunction skb_queue_walkfunction skb_queue_walkfunction sctp_ulpevent_idatafunction skb_queue_walkfunction sctp_intl_start_pdfunction sctp_renege_eventsfunction sctp_intl_stream_abort_pdfunction sctp_intl_reap_orderedfunction sctp_intl_abort_pdfunction sctp_get_skip_posfunction sctp_generate_iftsnfunction list_for_each_safefunction sctp_validate_iftsnfunction sctp_report_fwdtsnfunction sctp_intl_reasm_flushtsnfunction skb_queue_walk_safefunction skb_queue_walk_safefunction sctp_report_iftsnfunction sctp_handle_fwdtsnfunction sctp_intl_skipfunction sctp_handle_iftsnfunction do_ulpq_tail_eventfunction do_sctp_enqueue_eventfunction sctp_stream_interleave_init
Annotated Snippet
if (lchunk->chunk_hdr->flags & SCTP_DATA_UNORDERED) {
mid = lchunk->chunk_hdr->flags & SCTP_DATA_LAST_FRAG ?
sctp_mid_uo_next(stream, out, sid) :
sctp_mid_uo_peek(stream, out, sid);
} else {
mid = lchunk->chunk_hdr->flags & SCTP_DATA_LAST_FRAG ?
sctp_mid_next(stream, out, sid) :
sctp_mid_peek(stream, out, sid);
}
hdr->mid = htonl(mid);
}
}
static bool sctp_validate_data(struct sctp_chunk *chunk)
{
struct sctp_stream *stream;
__u16 sid, ssn;
if (chunk->chunk_hdr->type != SCTP_CID_DATA)
return false;
if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
return true;
stream = &chunk->asoc->stream;
sid = sctp_chunk_stream_no(chunk);
ssn = ntohs(chunk->subh.data_hdr->ssn);
return !SSN_lt(ssn, sctp_ssn_peek(stream, in, sid));
}
static bool sctp_validate_idata(struct sctp_chunk *chunk)
{
struct sctp_stream *stream;
__u32 mid;
__u16 sid;
if (chunk->chunk_hdr->type != SCTP_CID_I_DATA)
return false;
if (chunk->chunk_hdr->flags & SCTP_DATA_UNORDERED)
return true;
stream = &chunk->asoc->stream;
sid = sctp_chunk_stream_no(chunk);
mid = ntohl(chunk->subh.idata_hdr->mid);
return !MID_lt(mid, sctp_mid_peek(stream, in, sid));
}
static void sctp_intl_store_reasm(struct sctp_ulpq *ulpq,
struct sctp_ulpevent *event)
{
struct sctp_ulpevent *cevent;
struct sk_buff *pos, *loc;
pos = skb_peek_tail(&ulpq->reasm);
if (!pos) {
__skb_queue_tail(&ulpq->reasm, sctp_event2skb(event));
return;
}
cevent = sctp_skb2event(pos);
if (event->stream == cevent->stream &&
event->mid == cevent->mid &&
(cevent->msg_flags & SCTP_DATA_FIRST_FRAG ||
(!(event->msg_flags & SCTP_DATA_FIRST_FRAG) &&
event->fsn > cevent->fsn))) {
__skb_queue_tail(&ulpq->reasm, sctp_event2skb(event));
return;
}
if ((event->stream == cevent->stream &&
MID_lt(cevent->mid, event->mid)) ||
event->stream > cevent->stream) {
__skb_queue_tail(&ulpq->reasm, sctp_event2skb(event));
return;
}
loc = NULL;
skb_queue_walk(&ulpq->reasm, pos) {
cevent = sctp_skb2event(pos);
if (event->stream < cevent->stream ||
(event->stream == cevent->stream &&
MID_lt(event->mid, cevent->mid))) {
loc = pos;
break;
}
Annotation
- Immediate include surface: `net/busy_poll.h`, `net/sctp/sctp.h`, `net/sctp/sm.h`, `net/sctp/ulpevent.h`, `linux/sctp.h`.
- Detected declarations: `function addresched`, `function sctp_chunk_assign_mid`, `function list_for_each_entry`, `function sctp_validate_data`, `function sctp_validate_idata`, `function sctp_intl_store_reasm`, `function skb_queue_walk`, `function skb_queue_walk`, `function sctp_intl_store_ordered`, `function MID_lt`.
- 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.