net/sctp/input.c
Source file repositories/reference/linux-study-clean/net/sctp/input.c
File Facts
- System
- Linux kernel
- Corpus path
net/sctp/input.c- Extension
.c- Size
- 37514 bytes
- Lines
- 1371
- 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/list.hlinux/socket.hlinux/ip.hlinux/time.hlinux/slab.hnet/ip.hnet/icmp.hnet/snmp.hnet/sock.hnet/xfrm.hnet/sctp/sctp.hnet/sctp/sm.hnet/sctp/checksum.hnet/net_namespace.hlinux/rhashtable.hnet/sock_reuseport.h
Detected Declarations
struct sctp_hash_cmp_argfunction sctp_rcv_checksumfunction sctp_rcvfunction sctp_backlog_rcvfunction sctp_add_backlogfunction sctp_icmp_frag_neededfunction sctp_icmp_redirectfunction sctp_icmp_proto_unreachablefunction sctp_err_finishfunction sctp_v4_err_handlefunction sctp_v4_errfunction sctp_udp_v4_errfunction sctp_rcv_ootbfunction __sctp_hash_endpointfunction sctp_for_each_hentryfunction sctp_hash_endpointfunction __sctp_unhash_endpointfunction sctp_unhash_endpointfunction sctp_hashfnfunction sctp_hash_cmpfunction sctp_hash_objfunction sctp_hash_keyfunction sctp_transport_hashtable_initfunction sctp_transport_hashtable_destroyfunction sctp_hash_transportfunction rhl_for_each_entry_rcufunction sctp_unhash_transportfunction sctp_sk_bound_dev_eqfunction rhl_for_each_entry_rcufunction sctp_has_associationfunction packet
Annotated Snippet
struct sctp_hash_cmp_arg {
const union sctp_addr *paddr;
const struct net *net;
__be16 lport;
};
static inline int sctp_hash_cmp(struct rhashtable_compare_arg *arg,
const void *ptr)
{
struct sctp_transport *t = (struct sctp_transport *)ptr;
const struct sctp_hash_cmp_arg *x = arg->key;
int err = 1;
if (!sctp_cmp_addr_exact(&t->ipaddr, x->paddr))
return err;
if (!sctp_transport_hold(t))
return err;
if (!net_eq(t->asoc->base.net, x->net))
goto out;
if (x->lport != htons(t->asoc->base.bind_addr.port))
goto out;
err = 0;
out:
sctp_transport_put(t);
return err;
}
static inline __u32 sctp_hash_obj(const void *data, u32 len, u32 seed)
{
const struct sctp_transport *t = data;
return sctp_hashfn(t->asoc->base.net,
htons(t->asoc->base.bind_addr.port),
&t->ipaddr, seed);
}
static inline __u32 sctp_hash_key(const void *data, u32 len, u32 seed)
{
const struct sctp_hash_cmp_arg *x = data;
return sctp_hashfn(x->net, x->lport, x->paddr, seed);
}
static const struct rhashtable_params sctp_hash_params = {
.head_offset = offsetof(struct sctp_transport, node),
.hashfn = sctp_hash_key,
.obj_hashfn = sctp_hash_obj,
.obj_cmpfn = sctp_hash_cmp,
.automatic_shrinking = true,
};
int sctp_transport_hashtable_init(void)
{
return rhltable_init(&sctp_transport_hashtable, &sctp_hash_params);
}
void sctp_transport_hashtable_destroy(void)
{
rhltable_destroy(&sctp_transport_hashtable);
}
int sctp_hash_transport(struct sctp_transport *t)
{
struct sctp_transport *transport;
struct rhlist_head *tmp, *list;
struct sctp_hash_cmp_arg arg;
int err;
if (t->asoc->temp)
return 0;
arg.net = t->asoc->base.net;
arg.paddr = &t->ipaddr;
arg.lport = htons(t->asoc->base.bind_addr.port);
rcu_read_lock();
list = rhltable_lookup(&sctp_transport_hashtable, &arg,
sctp_hash_params);
rhl_for_each_entry_rcu(transport, tmp, list, node)
if (transport->asoc->ep == t->asoc->ep) {
rcu_read_unlock();
return -EEXIST;
}
rcu_read_unlock();
err = rhltable_insert_key(&sctp_transport_hashtable, &arg,
&t->node, sctp_hash_params);
Annotation
- Immediate include surface: `linux/types.h`, `linux/list.h`, `linux/socket.h`, `linux/ip.h`, `linux/time.h`, `linux/slab.h`, `net/ip.h`, `net/icmp.h`.
- Detected declarations: `struct sctp_hash_cmp_arg`, `function sctp_rcv_checksum`, `function sctp_rcv`, `function sctp_backlog_rcv`, `function sctp_add_backlog`, `function sctp_icmp_frag_needed`, `function sctp_icmp_redirect`, `function sctp_icmp_proto_unreachable`, `function sctp_err_finish`, `function sctp_v4_err_handle`.
- 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.