net/ipv6/tcp_ipv6.c
Source file repositories/reference/linux-study-clean/net/ipv6/tcp_ipv6.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/tcp_ipv6.c- Extension
.c- Size
- 64836 bytes
- Lines
- 2402
- 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.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bottom_half.hlinux/module.hlinux/errno.hlinux/types.hlinux/socket.hlinux/sockios.hlinux/net.hlinux/jiffies.hlinux/in.hlinux/in6.hlinux/netdevice.hlinux/init.hlinux/jhash.hlinux/ipsec.hlinux/times.hlinux/slab.hlinux/uaccess.hlinux/ipv6.hlinux/icmpv6.hlinux/random.hlinux/indirect_call_wrapper.hnet/aligned_data.hnet/tcp.hnet/ndisc.hnet/inet6_hashtables.hnet/inet6_connection_sock.hnet/ipv6.hnet/transp_v6.hnet/addrconf.hnet/ip6_route.hnet/ip6_checksum.hnet/inet_ecn.h
Detected Declarations
function inet6_skfunction tcp_v6_init_seq_and_ts_offfunction tcp_v6_pre_connectfunction tcp_v6_connectfunction connectfunction tcp_v6_mtu_reducedfunction tcp_v6_errfunction tcp_v6_send_synackfunction tcp_v6_reqsk_destructorfunction tcp_v6_parse_md5_keysfunction tcp_v6_md5_hash_headersfunction tcp_v6_md5_hash_hdrfunction tcp_v6_md5_hash_skbfunction tcp_v6_init_reqfunction tcp_v6_send_responsefunction tcp_v6_send_resetfunction tcp_v6_send_ackfunction tcp_v6_timewait_ackfunction tcp_v6_reqsk_send_ackfunction tcp_rsk_used_aofunction tcp_v6_get_syncookiefunction tcp_v6_conn_requestfunction tcp_v6_restore_cbfunction tcp_v6_mapped_child_initfunction voidfunction tcp_v6_do_rcvfunction tcp_v6_fill_cbfunction tcp_v6_rcvfunction tcp6_destruct_sockfunction sk_allocfunction get_openreq6function get_tcp6_sockfunction get_timewait6_sockfunction tcp6_seq_showfunction tcp6_proc_initfunction tcp6_proc_exitfunction tcpv6_net_initfunction tcpv6_net_exitfunction tcpv6_initfunction tcpv6_exitexport tcpv6_prot
Annotated Snippet
if (fl6->flowlabel & IPV6_FLOWLABEL_MASK) {
struct ip6_flowlabel *flowlabel;
flowlabel = fl6_sock_lookup(sk, fl6->flowlabel);
if (IS_ERR(flowlabel))
return -EINVAL;
fl6_sock_release(flowlabel);
}
}
/*
* connect() to INADDR_ANY means loopback (BSD'ism).
*/
if (ipv6_addr_any(&usin->sin6_addr)) {
if (ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr))
ipv6_addr_set_v4mapped(htonl(INADDR_LOOPBACK),
&usin->sin6_addr);
else
usin->sin6_addr = in6addr_loopback;
}
addr_type = ipv6_addr_type(&usin->sin6_addr);
if (addr_type & IPV6_ADDR_MULTICAST)
return -ENETUNREACH;
if (addr_type&IPV6_ADDR_LINKLOCAL) {
if (addr_len >= sizeof(struct sockaddr_in6) &&
usin->sin6_scope_id) {
/* If interface is set while binding, indices
* must coincide.
*/
if (!sk_dev_equal_l3scope(sk, usin->sin6_scope_id))
return -EINVAL;
sk->sk_bound_dev_if = usin->sin6_scope_id;
}
/* Connect to link-local address requires an interface */
if (!sk->sk_bound_dev_if)
return -EINVAL;
}
if (tp->rx_opt.ts_recent_stamp &&
!ipv6_addr_equal(&sk->sk_v6_daddr, &usin->sin6_addr)) {
tp->rx_opt.ts_recent = 0;
tp->rx_opt.ts_recent_stamp = 0;
WRITE_ONCE(tp->write_seq, 0);
}
sk->sk_v6_daddr = usin->sin6_addr;
np->flow_label = fl6->flowlabel;
/*
* TCP over IPv4
*/
if (addr_type & IPV6_ADDR_MAPPED) {
u32 exthdrlen = icsk->icsk_ext_hdr_len;
struct sockaddr_in sin;
if (ipv6_only_sock(sk))
return -ENETUNREACH;
sin.sin_family = AF_INET;
sin.sin_port = usin->sin6_port;
sin.sin_addr.s_addr = usin->sin6_addr.s6_addr32[3];
/* Paired with READ_ONCE() in tcp_(get|set)sockopt() */
WRITE_ONCE(icsk->icsk_af_ops, &ipv6_mapped);
if (sk_is_mptcp(sk))
mptcpv6_handle_mapped(sk, true);
sk->sk_backlog_rcv = tcp_v4_do_rcv;
#if defined(CONFIG_TCP_MD5SIG) || defined(CONFIG_TCP_AO)
tp->af_specific = &tcp_sock_ipv6_mapped_specific;
#endif
err = tcp_v4_connect(sk, (struct sockaddr_unsized *)&sin, sizeof(sin));
if (err) {
icsk->icsk_ext_hdr_len = exthdrlen;
/* Paired with READ_ONCE() in tcp_(get|set)sockopt() */
WRITE_ONCE(icsk->icsk_af_ops, &ipv6_specific);
if (sk_is_mptcp(sk))
mptcpv6_handle_mapped(sk, false);
sk->sk_backlog_rcv = tcp_v6_do_rcv;
#if defined(CONFIG_TCP_MD5SIG) || defined(CONFIG_TCP_AO)
tp->af_specific = &tcp_sock_ipv6_specific;
#endif
goto failure;
Annotation
- Immediate include surface: `linux/bottom_half.h`, `linux/module.h`, `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/sockios.h`, `linux/net.h`, `linux/jiffies.h`.
- Detected declarations: `function inet6_sk`, `function tcp_v6_init_seq_and_ts_off`, `function tcp_v6_pre_connect`, `function tcp_v6_connect`, `function connect`, `function tcp_v6_mtu_reduced`, `function tcp_v6_err`, `function tcp_v6_send_synack`, `function tcp_v6_reqsk_destructor`, `function tcp_v6_parse_md5_keys`.
- 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.