net/ipv6/ip6_fib.c
Source file repositories/reference/linux-study-clean/net/ipv6/ip6_fib.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ip6_fib.c- Extension
.c- Size
- 67358 bytes
- Lines
- 2839
- 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/bpf.hlinux/errno.hlinux/types.hlinux/net.hlinux/route.hlinux/netdevice.hlinux/in6.hlinux/init.hlinux/list.hlinux/slab.hnet/ip.hnet/ipv6.hnet/ndisc.hnet/addrconf.hnet/lwtunnel.hnet/fib_notifier.hnet/ip_fib.hnet/ip6_fib.hnet/ip6_route.h
Detected Declarations
struct fib6_cleanerstruct fib6_dump_argstruct lookup_argsfunction fib6_walker_linkfunction fib6_walker_unlinkfunction fib6_new_sernumfunction fib6_update_sernumfunction processorfunction fib6_info_destroy_rcufunction node_free_immediatefunction node_freefunction fib6_free_tablefunction fib6_link_tablefunction fib6_tables_initfunction fib6_lookupfunction fib6_tables_initfunction fib6_tables_seq_readfunction call_fib6_entry_notifierfunction call_fib6_multipath_entry_notifierfunction call_fib6_entry_notifiersfunction call_fib6_multipath_entry_notifiersfunction call_fib6_entry_notifiers_replacefunction fib6_rt_dumpfunction fib6_node_dumpfunction fib6_table_dumpfunction fib6_tables_dumpfunction hlist_for_each_entry_rcufunction fib6_dump_nodefunction for_each_fib6_walker_rtfunction fib6_dump_endfunction fib6_dump_donefunction fib6_dump_tablefunction inet6_dump_fibfunction hlist_for_each_entry_rcufunction fib6_metric_setfunction rcu_access_pointerfunction __fib6_drop_pcpu_fromfunction fib6_nh_drop_pcpu_fromfunction fib6_drop_pcpu_fromfunction fib6_purge_rtfunction fib6_add_rt2nodefunction lockdep_is_heldfunction list_for_each_entry_safefunction fib6_add_rt2node_nhfunction fib6_start_gcfunction fib6_force_start_gcfunction __fib6_update_sernum_upto_rootfunction fib6_update_sernum_upto_root
Annotated Snippet
struct fib6_cleaner {
struct fib6_walker w;
struct net *net;
int (*func)(struct fib6_info *, void *arg);
int sernum;
void *arg;
bool skip_notify;
};
#ifdef CONFIG_IPV6_SUBTREES
#define FWS_INIT FWS_S
#else
#define FWS_INIT FWS_L
#endif
static struct fib6_info *fib6_find_prefix(struct net *net,
struct fib6_table *table,
struct fib6_node *fn);
static struct fib6_node *fib6_repair_tree(struct net *net,
struct fib6_table *table,
struct fib6_node *fn);
static int fib6_walk(struct net *net, struct fib6_walker *w);
static int fib6_walk_continue(struct fib6_walker *w);
/*
* A routing update causes an increase of the serial number on the
* affected subtree. This allows for cached routes to be asynchronously
* tested when modifications are made to the destination cache as a
* result of redirects, path MTU changes, etc.
*/
static void fib6_gc_timer_cb(struct timer_list *t);
#define FOR_WALKERS(net, w) \
list_for_each_entry(w, &(net)->ipv6.fib6_walkers, lh)
static void fib6_walker_link(struct net *net, struct fib6_walker *w)
{
write_lock_bh(&net->ipv6.fib6_walker_lock);
list_add(&w->lh, &net->ipv6.fib6_walkers);
write_unlock_bh(&net->ipv6.fib6_walker_lock);
}
static void fib6_walker_unlink(struct net *net, struct fib6_walker *w)
{
write_lock_bh(&net->ipv6.fib6_walker_lock);
list_del(&w->lh);
write_unlock_bh(&net->ipv6.fib6_walker_lock);
}
static int fib6_new_sernum(struct net *net)
{
int new, old = atomic_read(&net->ipv6.fib6_sernum);
do {
new = old < INT_MAX ? old + 1 : 1;
} while (!atomic_try_cmpxchg(&net->ipv6.fib6_sernum, &old, new));
return new;
}
enum {
FIB6_NO_SERNUM_CHANGE = 0,
};
void fib6_update_sernum(struct net *net, struct fib6_info *f6i)
{
struct fib6_node *fn;
fn = rcu_dereference_protected(f6i->fib6_node,
lockdep_is_held(&f6i->fib6_table->tb6_lock));
if (fn)
WRITE_ONCE(fn->fn_sernum, fib6_new_sernum(net));
}
/*
* Auxiliary address test functions for the radix tree.
*
* These assume a 32bit processor (although it will work on
* 64bit processors)
*/
/*
* test bit
*/
#if defined(__LITTLE_ENDIAN)
# define BITOP_BE32_SWIZZLE (0x1F & ~7)
#else
# define BITOP_BE32_SWIZZLE 0
#endif
Annotation
- Immediate include surface: `linux/bpf.h`, `linux/errno.h`, `linux/types.h`, `linux/net.h`, `linux/route.h`, `linux/netdevice.h`, `linux/in6.h`, `linux/init.h`.
- Detected declarations: `struct fib6_cleaner`, `struct fib6_dump_arg`, `struct lookup_args`, `function fib6_walker_link`, `function fib6_walker_unlink`, `function fib6_new_sernum`, `function fib6_update_sernum`, `function processor`, `function fib6_info_destroy_rcu`, `function node_free_immediate`.
- 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.