net/ipv6/addrconf.c
Source file repositories/reference/linux-study-clean/net/ipv6/addrconf.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/addrconf.c- Extension
.c- Size
- 193481 bytes
- Lines
- 7650
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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
crypto/sha1.hlinux/errno.hlinux/types.hlinux/kernel.hlinux/sched/signal.hlinux/socket.hlinux/sockios.hlinux/net.hlinux/inet.hlinux/in6.hlinux/netdevice.hlinux/if_addr.hlinux/if_arp.hlinux/if_arcnet.hlinux/if_infiniband.hlinux/route.hlinux/inetdevice.hlinux/init.hlinux/slab.hlinux/sysctl.hlinux/capability.hlinux/delay.hlinux/notifier.hlinux/string.hlinux/hash.hnet/ip_tunnels.hnet/net_namespace.hnet/sock.hnet/snmp.hnet/6lowpan.hnet/firewire.hnet/ipv6.h
Detected Declarations
struct ipv6_saddr_scorestruct ipv6_saddr_dststruct if6_iter_stateenum cleanup_prefix_rt_tfunction cstamp_deltafunction rfc3315_s14_backoff_initfunction rfc3315_s14_backoff_updatefunction addrconf_sysctl_registerfunction addrconf_sysctl_unregisterfunction addrconf_link_readyfunction addrconf_del_rs_timerfunction addrconf_del_dad_workfunction addrconf_mod_rs_timerfunction addrconf_mod_dad_workfunction snmp6_alloc_devfunction for_each_possible_cpufunction inet6_netconf_msgsize_devconffunction inet6_netconf_fill_devconffunction inet6_netconf_notify_devconffunction inet6_netconf_valid_get_reqfunction inet6_netconf_get_devconffunction inet6_base_seqfunction inet6_netconf_dump_devconffunction dev_forward_changefunction addrconf_forward_changefunction for_each_netdevfunction addrconf_fixup_forwardingfunction addrconf_linkdown_changefunction for_each_netdevfunction addrconf_fixup_linkdownfunction inet6_ifa_finish_destroyfunction ipv6_link_dev_addrfunction inet6_addr_hashfunction ipv6_chk_same_addrfunction hlist_for_each_entryfunction ipv6_add_addr_hashfunction ipv6_add_addrfunction check_cleanup_prefix_routefunction list_for_each_entryfunction cleanup_prefix_routefunction ipv6_del_addrfunction ipv6_get_regen_advancefunction ipv6_create_tempaddrfunction ipv6_saddr_preferredfunction ipv6_use_optimistic_addrfunction ipv6_allow_optimistic_dadfunction ipv6_get_saddr_evalfunction __ipv6_dev_get_saddr
Annotated Snippet
struct ipv6_saddr_score {
int rule;
int addr_type;
struct inet6_ifaddr *ifa;
DECLARE_BITMAP(scorebits, IPV6_SADDR_RULE_MAX);
int scopedist;
int matchlen;
};
struct ipv6_saddr_dst {
const struct in6_addr *addr;
int ifindex;
int scope;
int label;
unsigned int prefs;
};
static inline int ipv6_saddr_preferred(int type)
{
if (type & (IPV6_ADDR_MAPPED|IPV6_ADDR_COMPATv4|IPV6_ADDR_LOOPBACK))
return 1;
return 0;
}
static bool ipv6_use_optimistic_addr(const struct net *net,
const struct inet6_dev *idev)
{
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
if (!idev)
return false;
if (!READ_ONCE(net->ipv6.devconf_all->optimistic_dad) &&
!READ_ONCE(idev->cnf.optimistic_dad))
return false;
if (!READ_ONCE(net->ipv6.devconf_all->use_optimistic) &&
!READ_ONCE(idev->cnf.use_optimistic))
return false;
return true;
#else
return false;
#endif
}
static bool ipv6_allow_optimistic_dad(const struct net *net,
const struct inet6_dev *idev)
{
#ifdef CONFIG_IPV6_OPTIMISTIC_DAD
if (!idev)
return false;
if (!READ_ONCE(net->ipv6.devconf_all->optimistic_dad) &&
!READ_ONCE(idev->cnf.optimistic_dad))
return false;
return true;
#else
return false;
#endif
}
static int ipv6_get_saddr_eval(struct net *net,
struct ipv6_saddr_score *score,
struct ipv6_saddr_dst *dst,
int i)
{
int ret;
if (i <= score->rule) {
switch (i) {
case IPV6_SADDR_RULE_SCOPE:
ret = score->scopedist;
break;
case IPV6_SADDR_RULE_PREFIX:
ret = score->matchlen;
break;
default:
ret = !!test_bit(i, score->scorebits);
}
goto out;
}
switch (i) {
case IPV6_SADDR_RULE_INIT:
/* Rule 0: remember if hiscore is not ready yet */
ret = !!score->ifa;
break;
case IPV6_SADDR_RULE_LOCAL:
/* Rule 1: Prefer same address */
ret = ipv6_addr_equal(&score->ifa->addr, dst->addr);
break;
case IPV6_SADDR_RULE_SCOPE:
Annotation
- Immediate include surface: `crypto/sha1.h`, `linux/errno.h`, `linux/types.h`, `linux/kernel.h`, `linux/sched/signal.h`, `linux/socket.h`, `linux/sockios.h`, `linux/net.h`.
- Detected declarations: `struct ipv6_saddr_score`, `struct ipv6_saddr_dst`, `struct if6_iter_state`, `enum cleanup_prefix_rt_t`, `function cstamp_delta`, `function rfc3315_s14_backoff_init`, `function rfc3315_s14_backoff_update`, `function addrconf_sysctl_register`, `function addrconf_sysctl_unregister`, `function addrconf_link_ready`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.