net/netfilter/ipvs/ip_vs_proto_udp.c
Source file repositories/reference/linux-study-clean/net/netfilter/ipvs/ip_vs_proto_udp.c
File Facts
- System
- Linux kernel
- Corpus path
net/netfilter/ipvs/ip_vs_proto_udp.c- Extension
.c- Size
- 12223 bytes
- Lines
- 497
- 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/in.hlinux/ip.hlinux/kernel.hlinux/netfilter.hlinux/netfilter_ipv4.hlinux/udp.hlinux/indirect_call_wrapper.hnet/ip_vs.hnet/ip.hnet/ip6_checksum.h
Detected Declarations
function udp_conn_schedulefunction udp_fast_csum_updatefunction udp_partial_csum_updatefunction udp_snat_handlerfunction udp_dnat_handlerfunction udp_csum_checkfunction udp_app_hashkeyfunction udp_register_appfunction list_for_each_entryfunction udp_unregister_appfunction udp_app_conn_bindfunction list_for_each_entry_rcufunction udp_state_namefunction udp_state_transitionfunction __udp_initfunction __udp_exit
Annotated Snippet
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 inline void
udp_fast_csum_update(int af, struct udphdr *uhdr,
const union nf_inet_addr *oldip,
const union nf_inet_addr *newip,
__be16 oldport, __be16 newport)
{
#ifdef CONFIG_IP_VS_IPV6
if (af == AF_INET6)
uhdr->check =
csum_fold(ip_vs_check_diff16(oldip->ip6, newip->ip6,
ip_vs_check_diff2(oldport, newport,
~csum_unfold(uhdr->check))));
else
#endif
uhdr->check =
csum_fold(ip_vs_check_diff4(oldip->ip, newip->ip,
ip_vs_check_diff2(oldport, newport,
~csum_unfold(uhdr->check))));
if (!uhdr->check)
uhdr->check = CSUM_MANGLED_0;
}
static inline void
udp_partial_csum_update(int af, struct udphdr *uhdr,
const union nf_inet_addr *oldip,
const union nf_inet_addr *newip,
__be16 oldlen, __be16 newlen)
{
#ifdef CONFIG_IP_VS_IPV6
if (af == AF_INET6)
uhdr->check =
~csum_fold(ip_vs_check_diff16(oldip->ip6, newip->ip6,
ip_vs_check_diff2(oldlen, newlen,
csum_unfold(uhdr->check))));
else
#endif
uhdr->check =
~csum_fold(ip_vs_check_diff4(oldip->ip, newip->ip,
ip_vs_check_diff2(oldlen, newlen,
csum_unfold(uhdr->check))));
}
INDIRECT_CALLABLE_SCOPE int
udp_snat_handler(struct sk_buff *skb, struct ip_vs_protocol *pp,
struct ip_vs_conn *cp, struct ip_vs_iphdr *iph)
{
struct udphdr *udph;
unsigned int udphoff = iph->len;
bool payload_csum = false;
int oldlen;
#ifdef CONFIG_IP_VS_IPV6
if (cp->af == AF_INET6 && iph->fragoffs)
return 1;
#endif
oldlen = skb->len - udphoff;
/* csum_check requires unshared skb */
if (skb_ensure_writable(skb, udphoff + sizeof(*udph)))
return 0;
if (unlikely(cp->app != NULL)) {
Annotation
- Immediate include surface: `linux/in.h`, `linux/ip.h`, `linux/kernel.h`, `linux/netfilter.h`, `linux/netfilter_ipv4.h`, `linux/udp.h`, `linux/indirect_call_wrapper.h`, `net/ip_vs.h`.
- Detected declarations: `function udp_conn_schedule`, `function udp_fast_csum_update`, `function udp_partial_csum_update`, `function udp_snat_handler`, `function udp_dnat_handler`, `function udp_csum_check`, `function udp_app_hashkey`, `function udp_register_app`, `function list_for_each_entry`, `function udp_unregister_app`.
- 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.