net/ipv6/icmp.c
Source file repositories/reference/linux-study-clean/net/ipv6/icmp.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/icmp.c- Extension
.c- Size
- 35936 bytes
- Lines
- 1458
- 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/module.hlinux/errno.hlinux/types.hlinux/socket.hlinux/in.hlinux/kernel.hlinux/sockios.hlinux/net.hlinux/skbuff.hlinux/init.hlinux/netfilter.hlinux/slab.hlinux/sysctl.hlinux/inet.hlinux/netdevice.hlinux/icmpv6.hnet/ip.hnet/sock.hnet/ipv6.hnet/ip6_checksum.hnet/ping.hnet/protocol.hnet/raw.hnet/rawv6.hnet/seg6.hnet/transp_v6.hnet/ip6_route.hnet/addrconf.hnet/icmp.hnet/xfrm.hnet/inet_common.hnet/dsfield.h
Detected Declarations
struct icmpv6_msgstruct icmp6_ext_iio_addr6_subobjfunction icmpv6_errfunction icmpv6_xmit_unlockfunction is_ineligiblefunction icmpv6_mask_allowfunction icmpv6_global_allowfunction icmpv6_xrlim_allowfunction icmpv6_rt_has_prefsrcfunction opt_unrecfunction icmpv6_push_pending_framesfunction skb_queue_walkfunction icmpv6_getfragfunction mip6_addr_swapfunction mip6_addr_swapfunction ipv6_anycast_destinationfunction icmp6_iiffunction icmp6_ext_iio_lenfunction icmp6_ext_max_lenfunction icmp6_ext_iio_iif_appendfunction icmp6_ext_objs_appendfunction icmp6_ext_appendfunction icmp6_sendfunction nodefunction icmpv6_param_prob_reasonfunction ip6_err_gen_icmpv6_unreachfunction icmpv6_echo_replyfunction icmpv6_notifyfunction icmpv6_rcvfunction icmpv6_flow_initfunction icmpv6_initfunction for_each_possible_cpufunction icmpv6_cleanupfunction icmpv6_err_convertfunction ipv6_icmp_sysctl_initfunction ipv6_icmp_sysctl_table_sizeexport icmp6_sendexport ip6_err_gen_icmpv6_unreachexport icmpv6_err_convert
Annotated Snippet
struct icmpv6_msg {
struct sk_buff *skb;
int offset;
uint8_t type;
};
static int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb)
{
struct icmpv6_msg *msg = (struct icmpv6_msg *) from;
struct sk_buff *org_skb = msg->skb;
__wsum csum;
csum = skb_copy_and_csum_bits(org_skb, msg->offset + offset,
to, len);
skb->csum = csum_block_add(skb->csum, csum, odd);
if (!(msg->type & ICMPV6_INFOMSG_MASK))
nf_ct_attach(skb, org_skb);
return 0;
}
#if IS_ENABLED(CONFIG_IPV6_MIP6)
static void mip6_addr_swap(struct sk_buff *skb, const struct inet6_skb_parm *opt)
{
struct ipv6hdr *iph = ipv6_hdr(skb);
struct ipv6_destopt_hao *hao;
int off;
if (opt->dsthao) {
off = ipv6_find_tlv(skb, opt->dsthao, IPV6_TLV_HAO);
if (likely(off >= 0)) {
hao = (struct ipv6_destopt_hao *)
(skb_network_header(skb) + off);
swap(iph->saddr, hao->addr);
}
}
}
#else
static inline void mip6_addr_swap(struct sk_buff *skb, const struct inet6_skb_parm *opt) {}
#endif
static struct dst_entry *icmpv6_route_lookup(struct net *net,
struct sk_buff *skb,
struct sock *sk,
struct flowi6 *fl6)
{
struct dst_entry *dst, *dst2;
struct flowi6 fl2;
int err;
err = ip6_dst_lookup(net, sk, &dst, fl6);
if (err)
return ERR_PTR(err);
/*
* We won't send icmp if the destination is known
* anycast unless we need to treat anycast as unicast.
*/
if (!READ_ONCE(net->ipv6.sysctl.icmpv6_error_anycast_as_unicast) &&
ipv6_anycast_destination(dst, &fl6->daddr)) {
net_dbg_ratelimited("icmp6_send: acast source\n");
dst_release(dst);
return ERR_PTR(-EINVAL);
}
/* No need to clone since we're just using its address. */
dst2 = dst;
dst = xfrm_lookup(net, dst, flowi6_to_flowi(fl6), sk, 0);
if (!IS_ERR(dst)) {
if (dst != dst2)
return dst;
} else {
if (PTR_ERR(dst) == -EPERM)
dst = NULL;
else
return dst;
}
err = xfrm_decode_session_reverse(net, skb, flowi6_to_flowi(&fl2), AF_INET6);
if (err)
goto relookup_failed;
err = ip6_dst_lookup(net, sk, &dst2, &fl2);
if (err)
goto relookup_failed;
dst2 = xfrm_lookup(net, dst2, flowi6_to_flowi(&fl2), sk, XFRM_LOOKUP_ICMP);
if (!IS_ERR(dst2)) {
dst_release(dst);
dst = dst2;
Annotation
- Immediate include surface: `linux/module.h`, `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/in.h`, `linux/kernel.h`, `linux/sockios.h`, `linux/net.h`.
- Detected declarations: `struct icmpv6_msg`, `struct icmp6_ext_iio_addr6_subobj`, `function icmpv6_err`, `function icmpv6_xmit_unlock`, `function is_ineligible`, `function icmpv6_mask_allow`, `function icmpv6_global_allow`, `function icmpv6_xrlim_allow`, `function icmpv6_rt_has_prefsrc`, `function opt_unrec`.
- 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.