net/ipv6/mcast_snoop.c
Source file repositories/reference/linux-study-clean/net/ipv6/mcast_snoop.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/mcast_snoop.c- Extension
.c- Size
- 4533 bytes
- Lines
- 191
- 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
linux/skbuff.hnet/ipv6.hnet/mld.hnet/addrconf.hnet/ip6_checksum.h
Detected Declarations
function Copyrightfunction ipv6_mc_check_exthdrsfunction ipv6_mc_check_mld_reportv2function ipv6_mc_check_mld_queryfunction ipv6_mc_check_mld_msgfunction ipv6_mc_validate_checksumfunction ipv6_mc_check_icmpv6function ipv6_mc_check_mldexport ipv6_mc_check_mld
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (C) 2010: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
* Copyright (C) 2015: Linus Lüssing <linus.luessing@c0d3.blue>
*
* Based on the MLD support added to br_multicast.c by YOSHIFUJI Hideaki.
*/
#include <linux/skbuff.h>
#include <net/ipv6.h>
#include <net/mld.h>
#include <net/addrconf.h>
#include <net/ip6_checksum.h>
static int ipv6_mc_check_ip6hdr(struct sk_buff *skb)
{
const struct ipv6hdr *ip6h;
unsigned int len;
unsigned int offset = skb_network_offset(skb) + sizeof(*ip6h);
if (!pskb_may_pull(skb, offset))
return -EINVAL;
ip6h = ipv6_hdr(skb);
if (ip6h->version != 6)
return -EINVAL;
len = offset + ntohs(ip6h->payload_len);
if (skb->len < len || len <= offset)
return -EINVAL;
skb_set_transport_header(skb, offset);
return 0;
}
static int ipv6_mc_check_exthdrs(struct sk_buff *skb)
{
const struct ipv6hdr *ip6h;
int offset;
u8 nexthdr;
__be16 frag_off;
ip6h = ipv6_hdr(skb);
if (ip6h->nexthdr != IPPROTO_HOPOPTS)
return -ENOMSG;
nexthdr = ip6h->nexthdr;
offset = skb_network_offset(skb) + sizeof(*ip6h);
offset = ipv6_skip_exthdr(skb, offset, &nexthdr, &frag_off);
if (offset < 0)
return -EINVAL;
if (nexthdr != IPPROTO_ICMPV6)
return -ENOMSG;
skb_set_transport_header(skb, offset);
return 0;
}
static int ipv6_mc_check_mld_reportv2(struct sk_buff *skb)
{
unsigned int len = skb_transport_offset(skb);
len += sizeof(struct mld2_report);
return ipv6_mc_may_pull(skb, len) ? 0 : -EINVAL;
}
static int ipv6_mc_check_mld_query(struct sk_buff *skb)
{
unsigned int transport_len = ipv6_transport_len(skb);
struct mld_msg *mld;
unsigned int len;
/* RFC2710+RFC3810 (MLDv1+MLDv2) require link-local source addresses */
if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL))
return -EINVAL;
/* MLDv1? */
if (transport_len != sizeof(struct mld_msg)) {
/* or MLDv2? */
if (transport_len < sizeof(struct mld2_query))
return -EINVAL;
len = skb_transport_offset(skb) + sizeof(struct mld2_query);
if (!ipv6_mc_may_pull(skb, len))
Annotation
- Immediate include surface: `linux/skbuff.h`, `net/ipv6.h`, `net/mld.h`, `net/addrconf.h`, `net/ip6_checksum.h`.
- Detected declarations: `function Copyright`, `function ipv6_mc_check_exthdrs`, `function ipv6_mc_check_mld_reportv2`, `function ipv6_mc_check_mld_query`, `function ipv6_mc_check_mld_msg`, `function ipv6_mc_validate_checksum`, `function ipv6_mc_check_icmpv6`, `function ipv6_mc_check_mld`, `export ipv6_mc_check_mld`.
- 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.