net/netfilter/ipvs/ip_vs_proto_sctp.c
Source file repositories/reference/linux-study-clean/net/netfilter/ipvs/ip_vs_proto_sctp.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/ipvs/ip_vs_proto_sctp.c- Extension
.c- Size
- 18296 bytes
- Lines
- 592
- 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/kernel.hlinux/ip.hlinux/sctp.hnet/ip.hnet/ip6_checksum.hlinux/netfilter.hlinux/netfilter_ipv4.hnet/sctp/checksum.hnet/ip_vs.h
Detected Declarations
enum ipvs_sctp_event_tfunction sctp_conn_schedulefunction sctp_nat_csumfunction sctp_snat_handlerfunction sctp_dnat_handlerfunction sctp_csum_checkfunction set_sctp_statefunction chunksfunction sctp_state_transitionfunction sctp_app_hashkeyfunction sctp_register_appfunction list_for_each_entryfunction sctp_unregister_appfunction sctp_app_conn_bindfunction list_for_each_entry_rcufunction __ip_vs_sctp_initfunction __ip_vs_sctp_exit
Annotated Snippet
if (sh) {
sch = skb_header_pointer(skb, iph->len + sizeof(_sctph),
sizeof(_schunkh), &_schunkh);
if (sch) {
if (sch->type == SCTP_CID_ABORT ||
!(sysctl_sloppy_sctp(ipvs) ||
sch->type == SCTP_CID_INIT))
return 1;
ports = &sh->source;
}
}
} else {
ports = skb_header_pointer(
skb, iph->len, sizeof(_ports), &_ports);
}
if (!ports) {
*verdict = NF_DROP;
return 0;
}
if (likely(!ip_vs_iph_inverse(iph)))
svc = ip_vs_service_find(ipvs, af, skb->mark, iph->protocol,
&iph->daddr, ports[1]);
else
svc = ip_vs_service_find(ipvs, af, skb->mark, iph->protocol,
&iph->saddr, ports[0]);
if (svc) {
int ignored;
if (ip_vs_todrop(ipvs)) {
/*
* It seems that we are very loaded.
* We have to drop this packet :(
*/
*verdict = NF_DROP;
return 0;
}
/*
* Let the virtual server select a real server for the
* incoming connection, and create a connection entry.
*/
*cpp = ip_vs_schedule(svc, skb, pd, &ignored, iph);
if (!*cpp && ignored <= 0) {
if (!ignored)
*verdict = ip_vs_leave(svc, skb, pd, iph);
else
*verdict = NF_DROP;
return 0;
}
}
/* NF_ACCEPT */
return 1;
}
static void sctp_nat_csum(struct sk_buff *skb, struct sctphdr *sctph,
unsigned int sctphoff)
{
sctph->checksum = sctp_compute_cksum(skb, sctphoff);
skb->ip_summed = CHECKSUM_UNNECESSARY;
}
static int
sctp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
struct ip_vs_conn *cp, struct ip_vs_iphdr *iph)
{
struct sctphdr *sctph;
unsigned int sctphoff = iph->len;
bool payload_csum = false;
#ifdef CONFIG_IP_VS_IPV6
if (cp->af == AF_INET6 && iph->fragoffs)
return 1;
#endif
/* csum_check requires unshared skb */
if (skb_ensure_writable(skb, sctphoff + sizeof(*sctph)))
return 0;
if (unlikely(cp->app != NULL)) {
int ret;
/* Some checks before mangling */
if (!sctp_csum_check(cp->af, skb, pp, sctphoff))
return 0;
/* Call application helper if needed */
ret = ip_vs_app_pkt_out(cp, skb, iph);
if (ret == 0)
return 0;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/ip.h`, `linux/sctp.h`, `net/ip.h`, `net/ip6_checksum.h`, `linux/netfilter.h`, `linux/netfilter_ipv4.h`, `net/sctp/checksum.h`.
- Detected declarations: `enum ipvs_sctp_event_t`, `function sctp_conn_schedule`, `function sctp_nat_csum`, `function sctp_snat_handler`, `function sctp_dnat_handler`, `function sctp_csum_check`, `function set_sctp_state`, `function chunks`, `function sctp_state_transition`, `function sctp_app_hashkey`.
- 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.