net/ipv6/ip6_input.c
Source file repositories/reference/linux-study-clean/net/ipv6/ip6_input.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ip6_input.c- Extension
.c- Size
- 16053 bytes
- Lines
- 643
- 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/errno.hlinux/types.hlinux/socket.hlinux/sockios.hlinux/net.hlinux/netdevice.hlinux/in6.hlinux/icmpv6.hlinux/mroute6.hlinux/slab.hlinux/indirect_call_wrapper.hlinux/netfilter.hlinux/netfilter_ipv6.hnet/sock.hnet/snmp.hnet/udp.hnet/ipv6.hnet/protocol.hnet/transp_v6.hnet/rawv6.hnet/ndisc.hnet/ip6_route.hnet/addrconf.hnet/xfrm.hnet/inet_ecn.hnet/dst_metadata.hnet/inet6_hashtables.h
Detected Declarations
function tcp_v6_early_demuxfunction ip6_rcv_finish_corefunction ip6_rcv_finishfunction ip6_sublist_rcv_finishfunction list_for_each_entry_safefunction ip6_can_use_hintfunction ip6_list_rcv_finishfunction list_for_each_entry_safefunction READ_ONCEfunction ipv6_rcvfunction ip6_sublist_rcvfunction ipv6_list_rcvfunction list_for_each_entry_safefunction ip6_protocol_deliver_rcufunction ip6_input_finishfunction ip6_inputfunction ip6_mc_inputfunction likelyfunction MLDexport ip6_input
Annotated Snippet
if (sk_fullsock(sk)) {
struct dst_entry *dst = rcu_dereference(sk->sk_rx_dst);
if (dst)
dst = dst_check(dst, sk->sk_rx_dst_cookie);
if (dst &&
sk->sk_rx_dst_ifindex == skb->skb_iif)
skb_dst_set_noref(skb, dst);
}
}
}
static void ip6_rcv_finish_core(struct net *net, struct sock *sk,
struct sk_buff *skb)
{
if (READ_ONCE(net->ipv4.sysctl_ip_early_demux) &&
!skb_dst(skb) && !skb->sk) {
switch (ipv6_hdr(skb)->nexthdr) {
case IPPROTO_TCP:
if (READ_ONCE(net->ipv4.sysctl_tcp_early_demux))
tcp_v6_early_demux(skb);
break;
case IPPROTO_UDP:
if (READ_ONCE(net->ipv4.sysctl_udp_early_demux))
udp_v6_early_demux(skb);
break;
}
}
if (!skb_valid_dst(skb))
ip6_route_input(skb);
}
int ip6_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
{
/* if ingress device is enslaved to an L3 master device pass the
* skb to its handler for processing
*/
skb = l3mdev_ip6_rcv(skb);
if (!skb)
return NET_RX_SUCCESS;
ip6_rcv_finish_core(net, sk, skb);
return dst_input(skb);
}
static void ip6_sublist_rcv_finish(struct list_head *head)
{
struct sk_buff *skb, *next;
list_for_each_entry_safe(skb, next, head, list) {
skb_list_del_init(skb);
dst_input(skb);
}
}
static bool ip6_can_use_hint(const struct sk_buff *skb,
const struct sk_buff *hint)
{
return hint && !skb_dst(skb) &&
ipv6_addr_equal(&ipv6_hdr(hint)->daddr, &ipv6_hdr(skb)->daddr);
}
static struct sk_buff *ip6_extract_route_hint(const struct net *net,
struct sk_buff *skb)
{
if (fib6_routes_require_src(net) || fib6_has_custom_rules(net) ||
IP6CB(skb)->flags & IP6SKB_MULTIPATH)
return NULL;
return skb;
}
static void ip6_list_rcv_finish(struct net *net, struct sock *sk,
struct list_head *head)
{
struct sk_buff *skb, *next, *hint = NULL;
struct dst_entry *curr_dst = NULL;
LIST_HEAD(sublist);
list_for_each_entry_safe(skb, next, head, list) {
struct dst_entry *dst;
skb_list_del_init(skb);
/* if ingress device is enslaved to an L3 master device pass the
* skb to its handler for processing
*/
skb = l3mdev_ip6_rcv(skb);
if (!skb)
continue;
Annotation
- Immediate include surface: `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/sockios.h`, `linux/net.h`, `linux/netdevice.h`, `linux/in6.h`, `linux/icmpv6.h`.
- Detected declarations: `function tcp_v6_early_demux`, `function ip6_rcv_finish_core`, `function ip6_rcv_finish`, `function ip6_sublist_rcv_finish`, `function list_for_each_entry_safe`, `function ip6_can_use_hint`, `function ip6_list_rcv_finish`, `function list_for_each_entry_safe`, `function READ_ONCE`, `function ipv6_rcv`.
- 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.