net/ipv6/ipv6_sockglue.c
Source file repositories/reference/linux-study-clean/net/ipv6/ipv6_sockglue.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ipv6_sockglue.c- Extension
.c- Size
- 33548 bytes
- Lines
- 1472
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/module.hlinux/capability.hlinux/errno.hlinux/types.hlinux/socket.hlinux/sockios.hlinux/net.hlinux/in6.hlinux/mroute6.hlinux/netdevice.hlinux/if_arp.hlinux/init.hlinux/sysctl.hlinux/netfilter.hlinux/slab.hnet/sock.hnet/snmp.hnet/ipv6.hnet/ndisc.hnet/protocol.hnet/transp_v6.hnet/ip6_route.hnet/addrconf.hnet/inet_common.hnet/tcp.hnet/udp.hnet/xfrm.hnet/compat.hnet/seg6.hnet/psp.hlinux/uaccess.h
Detected Declarations
function ip6_ra_controlfunction copy_group_source_from_sockptrfunction do_ipv6_mcast_group_sourcefunction ipv6_set_mcast_msfilterfunction compat_ipv6_set_mcast_msfilterfunction ipv6_mcast_join_leavefunction compat_ipv6_mcast_join_leavefunction ipv6_set_opt_hdrfunction do_ipv6_setsockoptfunction ipv6_setsockoptfunction ipv6_getsockopt_stickyfunction ipv6_get_msfilterfunction compat_ipv6_get_msfilterfunction do_ipv6_getsockoptfunction ipv6_getsockoptexport ipv6_setsockoptexport ipv6_getsockopt
Annotated Snippet
if (ra->sk == sk) {
if (sel >= 0) {
write_unlock_bh(&ip6_ra_lock);
kfree(new_ra);
return -EADDRINUSE;
}
*rap = ra->next;
write_unlock_bh(&ip6_ra_lock);
sock_put(sk);
kfree(ra);
return 0;
}
}
if (!new_ra) {
write_unlock_bh(&ip6_ra_lock);
return -ENOBUFS;
}
new_ra->sk = sk;
new_ra->sel = sel;
new_ra->next = ra;
*rap = new_ra;
sock_hold(sk);
write_unlock_bh(&ip6_ra_lock);
return 0;
}
struct ipv6_txoptions *ipv6_update_options(struct sock *sk,
struct ipv6_txoptions *opt)
{
if (inet_test_bit(IS_ICSK, sk)) {
if (opt &&
!((1 << sk->sk_state) & (TCPF_LISTEN | TCPF_CLOSE)) &&
inet_sk(sk)->inet_daddr != LOOPBACK4_IPV6) {
struct inet_connection_sock *icsk = inet_csk(sk);
icsk->icsk_ext_hdr_len =
psp_sk_overhead(sk) +
opt->opt_flen + opt->opt_nflen;
icsk->icsk_sync_mss(sk, icsk->icsk_pmtu_cookie);
}
}
opt = unrcu_pointer(xchg(&inet6_sk(sk)->opt, RCU_INITIALIZER(opt)));
sk_dst_reset(sk);
return opt;
}
static int copy_group_source_from_sockptr(struct group_source_req *greqs,
sockptr_t optval, int optlen)
{
if (in_compat_syscall()) {
struct compat_group_source_req gr32;
if (optlen < sizeof(gr32))
return -EINVAL;
if (copy_from_sockptr(&gr32, optval, sizeof(gr32)))
return -EFAULT;
greqs->gsr_interface = gr32.gsr_interface;
greqs->gsr_group = gr32.gsr_group;
greqs->gsr_source = gr32.gsr_source;
} else {
if (optlen < sizeof(*greqs))
return -EINVAL;
if (copy_from_sockptr(greqs, optval, sizeof(*greqs)))
return -EFAULT;
}
return 0;
}
static int do_ipv6_mcast_group_source(struct sock *sk, int optname,
sockptr_t optval, int optlen)
{
struct group_source_req greqs;
int omode, add;
int ret;
ret = copy_group_source_from_sockptr(&greqs, optval, optlen);
if (ret)
return ret;
if (greqs.gsr_group.ss_family != AF_INET6 ||
greqs.gsr_source.ss_family != AF_INET6)
return -EADDRNOTAVAIL;
if (optname == MCAST_BLOCK_SOURCE) {
omode = MCAST_EXCLUDE;
add = 1;
Annotation
- Immediate include surface: `linux/module.h`, `linux/capability.h`, `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/sockios.h`, `linux/net.h`, `linux/in6.h`.
- Detected declarations: `function ip6_ra_control`, `function copy_group_source_from_sockptr`, `function do_ipv6_mcast_group_source`, `function ipv6_set_mcast_msfilter`, `function compat_ipv6_set_mcast_msfilter`, `function ipv6_mcast_join_leave`, `function compat_ipv6_mcast_join_leave`, `function ipv6_set_opt_hdr`, `function do_ipv6_setsockopt`, `function ipv6_setsockopt`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.