net/ipv6/anycast.c
Source file repositories/reference/linux-study-clean/net/ipv6/anycast.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/anycast.c- Extension
.c- Size
- 14289 bytes
- Lines
- 657
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source 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.
- 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/capability.hlinux/module.hlinux/errno.hlinux/types.hlinux/random.hlinux/string.hlinux/socket.hlinux/sockios.hlinux/net.hlinux/in6.hlinux/netdevice.hlinux/if_arp.hlinux/route.hlinux/init.hlinux/proc_fs.hlinux/seq_file.hlinux/slab.hnet/net_namespace.hnet/sock.hnet/snmp.hnet/ipv6.hnet/protocol.hnet/if_inet6.hnet/ndisc.hnet/addrconf.hnet/ip6_route.hnet/checksum.h
Detected Declarations
struct ac6_iter_statefunction inet6_acaddr_hashfunction ipv6_sock_ac_joinfunction ipv6_sock_ac_dropfunction __ipv6_sock_ac_closefunction ipv6_sock_ac_closefunction ipv6_add_acaddr_hashfunction ipv6_del_acaddr_hashfunction aca_getfunction aca_free_rcufunction aca_putfunction inet6_ifacaddr_notifyfunction incfunction __ipv6_dev_ac_decfunction ipv6_dev_ac_decfunction ipv6_ac_destroy_devfunction rcu_read_lockfunction interfacefunction hlist_for_each_entry_rcufunction ipv6_chk_acast_addr_srcfunction for_each_netdev_rcufunction ac6_seq_stopfunction ac6_seq_showfunction ac6_proc_initfunction ac6_proc_exitfunction ipv6_anycast_initfunction ipv6_anycast_cleanup
Annotated Snippet
struct ac6_iter_state {
struct seq_net_private p;
struct net_device *dev;
};
#define ac6_seq_private(seq) ((struct ac6_iter_state *)(seq)->private)
static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
{
struct ac6_iter_state *state = ac6_seq_private(seq);
struct net *net = seq_file_net(seq);
struct ifacaddr6 *im = NULL;
for_each_netdev_rcu(net, state->dev) {
struct inet6_dev *idev;
idev = __in6_dev_get(state->dev);
if (!idev)
continue;
im = rcu_dereference(idev->ac_list);
if (im)
break;
}
return im;
}
static struct ifacaddr6 *ac6_get_next(struct seq_file *seq, struct ifacaddr6 *im)
{
struct ac6_iter_state *state = ac6_seq_private(seq);
struct inet6_dev *idev;
im = rcu_dereference(im->aca_next);
while (!im) {
state->dev = next_net_device_rcu(state->dev);
if (!state->dev)
break;
idev = __in6_dev_get(state->dev);
if (!idev)
continue;
im = rcu_dereference(idev->ac_list);
}
return im;
}
static struct ifacaddr6 *ac6_get_idx(struct seq_file *seq, loff_t pos)
{
struct ifacaddr6 *im = ac6_get_first(seq);
if (im)
while (pos && (im = ac6_get_next(seq, im)) != NULL)
--pos;
return pos ? NULL : im;
}
static void *ac6_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(RCU)
{
rcu_read_lock();
return ac6_get_idx(seq, *pos);
}
static void *ac6_seq_next(struct seq_file *seq, void *v, loff_t *pos)
{
struct ifacaddr6 *im = ac6_get_next(seq, v);
++*pos;
return im;
}
static void ac6_seq_stop(struct seq_file *seq, void *v)
__releases(RCU)
{
rcu_read_unlock();
}
static int ac6_seq_show(struct seq_file *seq, void *v)
{
struct ifacaddr6 *im = (struct ifacaddr6 *)v;
struct ac6_iter_state *state = ac6_seq_private(seq);
seq_printf(seq, "%-4d %-15s %pi6 %5d\n",
state->dev->ifindex, state->dev->name,
&im->aca_addr, im->aca_users);
return 0;
}
static const struct seq_operations ac6_seq_ops = {
.start = ac6_seq_start,
.next = ac6_seq_next,
.stop = ac6_seq_stop,
.show = ac6_seq_show,
Annotation
- Immediate include surface: `linux/capability.h`, `linux/module.h`, `linux/errno.h`, `linux/types.h`, `linux/random.h`, `linux/string.h`, `linux/socket.h`, `linux/sockios.h`.
- Detected declarations: `struct ac6_iter_state`, `function inet6_acaddr_hash`, `function ipv6_sock_ac_join`, `function ipv6_sock_ac_drop`, `function __ipv6_sock_ac_close`, `function ipv6_sock_ac_close`, `function ipv6_add_acaddr_hash`, `function ipv6_del_acaddr_hash`, `function aca_get`, `function aca_free_rcu`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source 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.