net/ipv6/udp.c
Source file repositories/reference/linux-study-clean/net/ipv6/udp.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/udp.c- Extension
.c- Size
- 50783 bytes
- Lines
- 1952
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bpf-cgroup.hlinux/errno.hlinux/types.hlinux/socket.hlinux/sockios.hlinux/net.hlinux/in6.hlinux/netdevice.hlinux/if_arp.hlinux/ipv6.hlinux/icmpv6.hlinux/init.hlinux/module.hlinux/skbuff.hlinux/slab.hlinux/uaccess.hlinux/indirect_call_wrapper.htrace/events/udp.hnet/addrconf.hnet/aligned_data.hnet/ndisc.hnet/protocol.hnet/transp_v6.hnet/ip6_route.hnet/raw.hnet/seg6.hnet/tcp_states.hnet/ip6_checksum.hnet/ip6_tunnel.hnet/udp_tunnel.hnet/xfrm.hnet/inet_hashtables.h
Detected Declarations
function udpv6_destruct_sockfunction udpv6_init_sockfunction udp6_ehashfnfunction udp_v6_get_portfunction udp_v6_rehashfunction compute_scorefunction udp6_lib_lookup1function sk_for_each_rcufunction udp6_hash4function udp6_hash4function udp6_skb_lenfunction udpv6_recvmsgfunction udpv6_encap_enablefunction __udp6_lib_err_encap_no_skfunction endpointsfunction udpv6_errfunction __udpv6_queue_rcv_skbfunction udpv6_queue_rcv_one_skbfunction udpv6_queue_rcv_skbfunction __udp_v6_is_mcast_sockfunction udp6_csum_zero_errorfunction __udp6_lib_mcast_deliverfunction sk_for_each_entry_offset_rcufunction udp6_sk_rx_dst_setfunction udp6_unicast_rcv_skbfunction udp6_csum_initfunction udpv6_rcvfunction udp_portaddr_for_each_entry_rcufunction udp_v6_early_demuxfunction udp_v6_flush_pending_framesfunction udpv6_pre_connectfunction udpv6_connectfunction udp6_hwcsum_outgoingfunction udp_v6_send_skbfunction udp_v6_push_pending_framesfunction udpv6_sendmsgfunction udpv6_splice_eoffunction udpv6_destroy_sockfunction udpv6_setsockoptfunction udpv6_getsockoptfunction udp6_seq_showfunction udp6_proc_initfunction udp6_proc_exitfunction udpv6_initfunction udpv6_exitexport __udp6_lib_lookupexport udp6_lib_lookupexport udpv6_encap_enable
Annotated Snippet
if (score > badness) {
result = sk;
badness = score;
}
}
return result;
}
/* called with rcu_read_lock() */
static struct sock *udp6_lib_lookup2(const struct net *net,
const struct in6_addr *saddr, __be16 sport,
const struct in6_addr *daddr, unsigned int hnum,
int dif, int sdif, struct udp_hslot *hslot2,
struct sk_buff *skb)
{
struct sock *sk, *result;
int score, badness;
bool need_rescore;
result = NULL;
badness = -1;
udp_portaddr_for_each_entry_rcu(sk, &hslot2->head) {
need_rescore = false;
rescore:
score = compute_score(need_rescore ? result : sk, net, saddr,
sport, daddr, hnum, dif, sdif);
if (score > badness) {
badness = score;
if (need_rescore)
continue;
if (sk->sk_state == TCP_ESTABLISHED) {
result = sk;
continue;
}
result = inet6_lookup_reuseport(net, sk, skb, sizeof(struct udphdr),
saddr, sport, daddr, hnum, udp6_ehashfn);
if (!result) {
result = sk;
continue;
}
/* Fall back to scoring if group has connections */
if (!reuseport_has_conns(sk))
return result;
/* Reuseport logic returned an error, keep original score. */
if (IS_ERR(result))
continue;
/* compute_score is too long of a function to be
* inlined twice here, and calling it uninlined
* here yields measurable overhead for some
* workloads. Work around it by jumping
* backwards to rescore 'result'.
*/
need_rescore = true;
goto rescore;
}
}
return result;
}
#if IS_ENABLED(CONFIG_BASE_SMALL)
static struct sock *udp6_lib_lookup4(const struct net *net,
const struct in6_addr *saddr, __be16 sport,
const struct in6_addr *daddr,
unsigned int hnum, int dif, int sdif,
struct udp_table *udptable)
{
return NULL;
}
static void udp6_hash4(struct sock *sk)
{
}
#else /* !CONFIG_BASE_SMALL */
static struct sock *udp6_lib_lookup4(const struct net *net,
const struct in6_addr *saddr, __be16 sport,
const struct in6_addr *daddr,
unsigned int hnum, int dif, int sdif,
struct udp_table *udptable)
{
const __portpair ports = INET_COMBINED_PORTS(sport, hnum);
const struct hlist_nulls_node *node;
struct udp_hslot *hslot4;
unsigned int hash4, slot;
Annotation
- Immediate include surface: `linux/bpf-cgroup.h`, `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/sockios.h`, `linux/net.h`, `linux/in6.h`, `linux/netdevice.h`.
- Detected declarations: `function udpv6_destruct_sock`, `function udpv6_init_sock`, `function udp6_ehashfn`, `function udp_v6_get_port`, `function udp_v6_rehash`, `function compute_score`, `function udp6_lib_lookup1`, `function sk_for_each_rcu`, `function udp6_hash4`, `function udp6_hash4`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.