net/ipv6/ila/ila_xlat.c
Source file repositories/reference/linux-study-clean/net/ipv6/ila/ila_xlat.c
File Facts
- System
- Linux kernel
- Corpus path
net/ipv6/ila/ila_xlat.c- Extension
.c- Size
- 14154 bytes
- Lines
- 666
- 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/jhash.hlinux/netfilter.hlinux/rcupdate.hlinux/rhashtable.hlinux/vmalloc.hnet/genetlink.hnet/netns/generic.huapi/linux/genetlink.hila.h
Detected Declarations
struct ila_xlat_paramsstruct ila_mapstruct ila_dump_iterfunction alloc_ila_locksfunction __ila_hash_secret_initfunction ila_locator_hashfunction ila_cmp_wildcardsfunction ila_cmp_paramsfunction ila_cmpfnfunction ila_orderfunction parse_nl_configfunction ila_releasefunction ila_free_nodefunction ila_free_cbfunction ila_nf_inputfunction ila_add_mappingfunction ila_del_mappingfunction ila_xlat_nl_cmd_add_mappingfunction ila_xlat_nl_cmd_del_mappingfunction ila_xlat_nl_cmd_flushfunction ila_fill_infofunction ila_dump_infofunction ila_xlat_nl_cmd_get_mappingfunction ila_xlat_nl_dump_startfunction ila_xlat_nl_dump_donefunction ila_xlat_nl_dumpfunction ila_xlat_init_netfunction ila_xlat_pre_exit_netfunction ila_xlat_exit_netfunction ila_xlat_addr
Annotated Snippet
struct ila_xlat_params {
struct ila_params ip;
int ifindex;
};
struct ila_map {
struct ila_xlat_params xp;
struct rhash_head node;
struct ila_map __rcu *next;
struct rcu_head rcu;
};
#define MAX_LOCKS 1024
#define LOCKS_PER_CPU 10
static int alloc_ila_locks(struct ila_net *ilan)
{
return alloc_bucket_spinlocks(&ilan->xlat.locks, &ilan->xlat.locks_mask,
MAX_LOCKS, LOCKS_PER_CPU,
GFP_KERNEL);
}
static u32 hashrnd __read_mostly;
static __always_inline void __ila_hash_secret_init(void)
{
net_get_random_once(&hashrnd, sizeof(hashrnd));
}
static inline u32 ila_locator_hash(struct ila_locator loc)
{
u32 *v = (u32 *)loc.v32;
__ila_hash_secret_init();
return jhash_2words(v[0], v[1], hashrnd);
}
static inline spinlock_t *ila_get_lock(struct ila_net *ilan,
struct ila_locator loc)
{
return &ilan->xlat.locks[ila_locator_hash(loc) & ilan->xlat.locks_mask];
}
static inline int ila_cmp_wildcards(struct ila_map *ila,
struct ila_addr *iaddr, int ifindex)
{
return (ila->xp.ifindex && ila->xp.ifindex != ifindex);
}
static inline int ila_cmp_params(struct ila_map *ila,
struct ila_xlat_params *xp)
{
return (ila->xp.ifindex != xp->ifindex);
}
static int ila_cmpfn(struct rhashtable_compare_arg *arg,
const void *obj)
{
const struct ila_map *ila = obj;
return (ila->xp.ip.locator_match.v64 != *(__be64 *)arg->key);
}
static inline int ila_order(struct ila_map *ila)
{
int score = 0;
if (ila->xp.ifindex)
score += 1 << 1;
return score;
}
static const struct rhashtable_params rht_params = {
.nelem_hint = 1024,
.head_offset = offsetof(struct ila_map, node),
.key_offset = offsetof(struct ila_map, xp.ip.locator_match),
.key_len = sizeof(u64), /* identifier */
.max_size = 1048576,
.min_size = 256,
.automatic_shrinking = true,
.obj_cmpfn = ila_cmpfn,
};
static int parse_nl_config(struct genl_info *info,
struct ila_xlat_params *xp)
{
memset(xp, 0, sizeof(*xp));
if (info->attrs[ILA_ATTR_LOCATOR])
xp->ip.locator.v64 = (__force __be64)nla_get_u64(
Annotation
- Immediate include surface: `linux/jhash.h`, `linux/netfilter.h`, `linux/rcupdate.h`, `linux/rhashtable.h`, `linux/vmalloc.h`, `net/genetlink.h`, `net/netns/generic.h`, `uapi/linux/genetlink.h`.
- Detected declarations: `struct ila_xlat_params`, `struct ila_map`, `struct ila_dump_iter`, `function alloc_ila_locks`, `function __ila_hash_secret_init`, `function ila_locator_hash`, `function ila_cmp_wildcards`, `function ila_cmp_params`, `function ila_cmpfn`, `function ila_order`.
- 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.