net/ipv6/ndisc.c
Source file repositories/reference/linux-study-clean/net/ipv6/ndisc.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ndisc.c- Extension
.c- Size
- 54017 bytes
- Lines
- 2048
- 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/module.hlinux/errno.hlinux/types.hlinux/socket.hlinux/sockios.hlinux/sched.hlinux/net.hlinux/in6.hlinux/route.hlinux/init.hlinux/rcupdate.hlinux/slab.hlinux/sysctl.hlinux/if_addr.hlinux/if_ether.hlinux/if_arp.hlinux/ipv6.hlinux/icmpv6.hlinux/jhash.hnet/sock.hnet/snmp.hnet/ipv6.hnet/protocol.hnet/ndisc.hnet/ip6_route.hnet/addrconf.hnet/icmp.hnet/netlink.hlinux/rtnetlink.hnet/flow.hnet/ip6_checksum.hnet/inet_common.h
Detected Declarations
function __ndisc_fill_addr_optionfunction ndisc_fill_addr_optionfunction ndisc_fill_redirect_addr_optionfunction ndisc_is_useroptfunction ndisc_mc_mapfunction ndisc_hashfunction ndisc_key_eqfunction ndisc_constructorfunction pndisc_constructorfunction pndisc_destructorfunction ndisc_allow_addfunction ip6_nd_hdrfunction ndisc_send_skbfunction ndisc_send_nafunction ndisc_send_unsol_nafunction ndisc_send_nsfunction ndisc_send_rsfunction ndisc_error_reportfunction ndisc_solicitfunction pndisc_is_routerfunction ndisc_updatefunction ndisc_recv_nsfunction accept_untracked_nafunction ndisc_recv_nafunction ndisc_recv_rsfunction ndisc_ra_useroptfunction ndisc_router_discoveryfunction ipv6_chk_addrfunction ipv6_chk_addrfunction ndisc_redirect_rcvfunction ndisc_fill_redirect_hdr_optionfunction ndisc_send_redirectfunction pndisc_redofunction ndisc_is_multicastfunction ndisc_suppress_frag_ndiscfunction READ_ONCEfunction ndisc_rcvfunction ndisc_netdev_eventfunction ndisc_warn_deprecated_sysctlfunction ndisc_ifinfo_sysctl_changefunction ndisc_net_initfunction ndisc_net_exitfunction ndisc_initfunction ndisc_late_initfunction ndisc_late_cleanupfunction ndisc_cleanupexport nd_tblexport __ndisc_fill_addr_option
Annotated Snippet
switch (nd_opt->nd_opt_type) {
case ND_OPT_SOURCE_LL_ADDR:
case ND_OPT_TARGET_LL_ADDR:
case ND_OPT_MTU:
case ND_OPT_NONCE:
case ND_OPT_REDIRECT_HDR:
if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
net_dbg_ratelimited("%s: duplicated ND6 option found: type=%d\n",
__func__, nd_opt->nd_opt_type);
} else {
ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
}
break;
case ND_OPT_PREFIX_INFO:
ndopts->nd_opts_pi_end = nd_opt;
if (!ndopts->nd_opt_array[nd_opt->nd_opt_type])
ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
break;
#ifdef CONFIG_IPV6_ROUTE_INFO
case ND_OPT_ROUTE_INFO:
ndopts->nd_opts_ri_end = nd_opt;
if (!ndopts->nd_opts_ri)
ndopts->nd_opts_ri = nd_opt;
break;
#endif
default:
unknown = true;
}
if (ndisc_is_useropt(dev, nd_opt)) {
ndopts->nd_useropts_end = nd_opt;
if (!ndopts->nd_useropts)
ndopts->nd_useropts = nd_opt;
} else if (unknown) {
/*
* Unknown options must be silently ignored,
* to accommodate future extension to the
* protocol.
*/
net_dbg_ratelimited("%s: ignored unsupported option; type=%d, len=%d\n",
__func__, nd_opt->nd_opt_type, nd_opt->nd_opt_len);
}
next_opt:
opt_len -= l;
nd_opt = ((void *)nd_opt) + l;
}
return ndopts;
}
int ndisc_mc_map(const struct in6_addr *addr, char *buf, struct net_device *dev, int dir)
{
switch (dev->type) {
case ARPHRD_ETHER:
case ARPHRD_IEEE802: /* Not sure. Check it later. --ANK */
case ARPHRD_FDDI:
ipv6_eth_mc_map(addr, buf);
return 0;
case ARPHRD_ARCNET:
ipv6_arcnet_mc_map(addr, buf);
return 0;
case ARPHRD_INFINIBAND:
ipv6_ib_mc_map(addr, dev->broadcast, buf);
return 0;
case ARPHRD_IPGRE:
return ipv6_ipgre_mc_map(addr, dev->broadcast, buf);
default:
if (dir) {
memcpy(buf, dev->broadcast, dev->addr_len);
return 0;
}
}
return -EINVAL;
}
EXPORT_SYMBOL(ndisc_mc_map);
static u32 ndisc_hash(const void *pkey,
const struct net_device *dev,
__u32 *hash_rnd)
{
return ndisc_hashfn(pkey, dev, hash_rnd);
}
static bool ndisc_key_eq(const struct neighbour *n, const void *pkey)
{
return neigh_key_eq128(n, pkey);
}
static int ndisc_constructor(struct neighbour *neigh)
{
struct in6_addr *addr = (struct in6_addr *)&neigh->primary_key;
struct net_device *dev = neigh->dev;
Annotation
- Immediate include surface: `linux/module.h`, `linux/errno.h`, `linux/types.h`, `linux/socket.h`, `linux/sockios.h`, `linux/sched.h`, `linux/net.h`, `linux/in6.h`.
- Detected declarations: `function __ndisc_fill_addr_option`, `function ndisc_fill_addr_option`, `function ndisc_fill_redirect_addr_option`, `function ndisc_is_useropt`, `function ndisc_mc_map`, `function ndisc_hash`, `function ndisc_key_eq`, `function ndisc_constructor`, `function pndisc_constructor`, `function pndisc_destructor`.
- 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.