net/ipv6/ping.c
Source file repositories/reference/linux-study-clean/net/ipv6/ping.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ping.c- Extension
.c- Size
- 8323 bytes
- Lines
- 305
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
net/addrconf.hnet/ipv6.hnet/ip6_route.hnet/protocol.hnet/udp.hnet/transp_v6.hlinux/proc_fs.hlinux/bpf-cgroup.hnet/ping.h
Detected Declarations
function Kankovskyfunction dummy_ip6_datagram_recv_ctlfunction dummy_ipv6_icmp_errorfunction ping_v6_pre_connectfunction ping_v6_sendmsgfunction ping_v6_seq_showfunction ping_v6_proc_init_netfunction ping_v6_proc_exit_netfunction pingv6_initfunction pingv6_exitexport pingv6_prot
Annotated Snippet
if (u->sin6_family != AF_INET6) {
return -EAFNOSUPPORT;
}
daddr = &(u->sin6_addr);
if (inet6_test_bit(SNDFLOW, sk))
fl6.flowlabel = u->sin6_flowinfo & IPV6_FLOWINFO_MASK;
if (__ipv6_addr_needs_scope_id(ipv6_addr_type(daddr)))
oif = u->sin6_scope_id;
} else {
if (sk->sk_state != TCP_ESTABLISHED)
return -EDESTADDRREQ;
daddr = &sk->sk_v6_daddr;
fl6.flowlabel = np->flow_label;
}
if (!oif)
oif = sk->sk_bound_dev_if;
if (!oif)
oif = np->sticky_pktinfo.ipi6_ifindex;
if (!oif && ipv6_addr_is_multicast(daddr))
oif = READ_ONCE(np->mcast_oif);
else if (!oif)
oif = READ_ONCE(np->ucast_oif);
addr_type = ipv6_addr_type(daddr);
if ((__ipv6_addr_needs_scope_id(addr_type) && !oif) ||
(addr_type & IPV6_ADDR_MAPPED) ||
(oif && sk->sk_bound_dev_if && oif != sk->sk_bound_dev_if &&
l3mdev_master_ifindex_by_index(sock_net(sk), oif) != sk->sk_bound_dev_if))
return -EINVAL;
ipcm6_init_sk(&ipc6, sk);
fl6.flowi6_oif = oif;
if (msg->msg_controllen) {
struct ipv6_txoptions opt = {};
opt.tot_len = sizeof(opt);
ipc6.opt = &opt;
err = ip6_datagram_send_ctl(sock_net(sk), sk, msg, &fl6, &ipc6);
if (err < 0)
return err;
/* Changes to txoptions and flow info are not implemented, yet.
* Drop the options.
*/
ipc6.opt = NULL;
}
fl6.flowi6_proto = IPPROTO_ICMPV6;
fl6.saddr = np->saddr;
fl6.daddr = *daddr;
fl6.flowi6_mark = ipc6.sockc.mark;
fl6.flowi6_uid = sk_uid(sk);
fl6.fl6_icmp_type = user_icmph.icmp6_type;
fl6.fl6_icmp_code = user_icmph.icmp6_code;
security_sk_classify_flow(sk, flowi6_to_flowi_common(&fl6));
fl6.flowlabel = ip6_make_flowinfo(ipc6.tclass, fl6.flowlabel);
dst = ip6_sk_dst_lookup_flow(sk, &fl6, daddr, false);
if (IS_ERR(dst))
return PTR_ERR(dst);
rt = dst_rt6_info(dst);
if (!fl6.flowi6_oif && ipv6_addr_is_multicast(&fl6.daddr))
fl6.flowi6_oif = READ_ONCE(np->mcast_oif);
else if (!fl6.flowi6_oif)
fl6.flowi6_oif = READ_ONCE(np->ucast_oif);
pfh.icmph.type = user_icmph.icmp6_type;
pfh.icmph.code = user_icmph.icmp6_code;
pfh.icmph.checksum = 0;
pfh.icmph.un.echo.id = inet->inet_sport;
pfh.icmph.un.echo.sequence = user_icmph.icmp6_sequence;
pfh.msg = msg;
pfh.wcheck = 0;
pfh.family = AF_INET6;
if (ipc6.hlimit < 0)
ipc6.hlimit = ip6_sk_dst_hoplimit(np, &fl6, dst);
lock_sock(sk);
err = ip6_append_data(sk, ping_getfrag, &pfh, len,
sizeof(struct icmp6hdr), &ipc6, &fl6, rt,
MSG_DONTWAIT);
Annotation
- Immediate include surface: `net/addrconf.h`, `net/ipv6.h`, `net/ip6_route.h`, `net/protocol.h`, `net/udp.h`, `net/transp_v6.h`, `linux/proc_fs.h`, `linux/bpf-cgroup.h`.
- Detected declarations: `function Kankovsky`, `function dummy_ip6_datagram_recv_ctl`, `function dummy_ipv6_icmp_error`, `function ping_v6_pre_connect`, `function ping_v6_sendmsg`, `function ping_v6_seq_show`, `function ping_v6_proc_init_net`, `function ping_v6_proc_exit_net`, `function pingv6_init`, `function pingv6_exit`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
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.