net/sctp/output.c
Source file repositories/reference/linux-study-clean/net/sctp/output.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/output.c- Extension
.c- Size
- 24458 bytes
- Lines
- 866
- 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.
- 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/ip.hlinux/ipv6.hlinux/init.hlinux/slab.hnet/inet_ecn.hnet/ip.hnet/icmp.hnet/net_namespace.hlinux/socket.hnet/sock.hnet/sctp/sctp.hnet/sctp/sm.hnet/sctp/checksum.h
Detected Declarations
function sctp_packet_resetfunction sctp_packet_configfunction sctp_packet_initfunction sctp_packet_freefunction list_for_each_entry_safefunction sctp_packet_transmit_chunkfunction sctp_packet_bundle_padfunction sctp_packet_bundle_authfunction sctp_packet_bundle_sackfunction __sctp_packet_append_chunkfunction sctp_packet_append_chunkfunction sctp_packet_gso_appendfunction sctp_packet_packfunction list_for_each_entry_safefunction list_for_each_entry_safefunction sctp_outq_tailfunction sctp_packet_can_append_datafunction sctp_packet_append_datafunction sctp_packet_will_fit
Annotated Snippet
if (!packet->has_cookie_echo) {
int error = 0;
error = sctp_packet_transmit(packet, gfp);
if (error < 0)
chunk->skb->sk->sk_err = -error;
/* If we have an empty packet, then we can NOT ever
* return PMTU_FULL.
*/
if (!one_packet)
retval = sctp_packet_append_chunk(packet,
chunk);
}
break;
case SCTP_XMIT_RWND_FULL:
case SCTP_XMIT_OK:
case SCTP_XMIT_DELAY:
break;
}
return retval;
}
/* Try to bundle a pad chunk into a packet with a heartbeat chunk for PLPMTUTD probe */
static enum sctp_xmit sctp_packet_bundle_pad(struct sctp_packet *pkt, struct sctp_chunk *chunk)
{
struct sctp_transport *t = pkt->transport;
struct sctp_chunk *pad;
int overhead = 0;
if (!chunk->pmtu_probe)
return SCTP_XMIT_OK;
/* calculate the Padding Data size for the pad chunk */
overhead += sizeof(struct sctphdr) + sizeof(struct sctp_chunkhdr);
overhead += sizeof(struct sctp_sender_hb_info) + sizeof(struct sctp_pad_chunk);
pad = sctp_make_pad(t->asoc, t->pl.probe_size - overhead);
if (!pad)
return SCTP_XMIT_DELAY;
list_add_tail(&pad->list, &pkt->chunk_list);
pkt->size += SCTP_PAD4(ntohs(pad->chunk_hdr->length));
chunk->transport = t;
return SCTP_XMIT_OK;
}
/* Try to bundle an auth chunk into the packet. */
static enum sctp_xmit sctp_packet_bundle_auth(struct sctp_packet *pkt,
struct sctp_chunk *chunk)
{
struct sctp_association *asoc = pkt->transport->asoc;
enum sctp_xmit retval = SCTP_XMIT_OK;
struct sctp_chunk *auth;
/* if we don't have an association, we can't do authentication */
if (!asoc)
return retval;
/* See if this is an auth chunk we are bundling or if
* auth is already bundled.
*/
if (chunk->chunk_hdr->type == SCTP_CID_AUTH || pkt->has_auth)
return retval;
/* if the peer did not request this chunk to be authenticated,
* don't do it
*/
if (!chunk->auth)
return retval;
auth = sctp_make_auth(asoc, chunk->shkey->key_id);
if (!auth)
return retval;
auth->shkey = chunk->shkey;
sctp_auth_shkey_hold(auth->shkey);
retval = __sctp_packet_append_chunk(pkt, auth);
if (retval != SCTP_XMIT_OK)
sctp_chunk_free(auth);
return retval;
}
/* Try to bundle a SACK with the packet. */
static enum sctp_xmit sctp_packet_bundle_sack(struct sctp_packet *pkt,
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/wait.h`, `linux/time.h`, `linux/ip.h`, `linux/ipv6.h`, `linux/init.h`, `linux/slab.h`.
- Detected declarations: `function sctp_packet_reset`, `function sctp_packet_config`, `function sctp_packet_init`, `function sctp_packet_free`, `function list_for_each_entry_safe`, `function sctp_packet_transmit_chunk`, `function sctp_packet_bundle_pad`, `function sctp_packet_bundle_auth`, `function sctp_packet_bundle_sack`, `function __sctp_packet_append_chunk`.
- 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.