net/xfrm/xfrm_algo.c
Source file repositories/reference/linux-study-clean/net/xfrm/xfrm_algo.c
File Facts
- System
- Linux kernel
- Corpus path
net/xfrm/xfrm_algo.c- Extension
.c- Size
- 14471 bytes
- Lines
- 842
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
crypto/acompress.hcrypto/aead.hcrypto/hash.hcrypto/skcipher.hlinux/module.hlinux/kernel.hlinux/pfkeyv2.hlinux/scatterlist.hnet/xfrm.hnet/esp.h
Detected Declarations
struct xfrm_algo_liststruct xfrm_aead_namefunction aalg_entriesfunction ealg_entriesfunction calg_entriesfunction matchfunction xfrm_alg_id_matchfunction xfrm_alg_name_matchfunction xfrm_aead_name_matchfunction xfrm_probe_algsfunction xfrm_count_pfkey_auth_supportedfunction xfrm_count_pfkey_enc_supportedexport xfrm_aalg_get_byidexport xfrm_ealg_get_byidexport xfrm_calg_get_byidexport xfrm_aalg_get_bynameexport xfrm_ealg_get_bynameexport xfrm_calg_get_bynameexport xfrm_aead_get_bynameexport xfrm_aalg_get_byidxexport xfrm_ealg_get_byidxexport xfrm_probe_algsexport xfrm_count_pfkey_auth_supportedexport xfrm_count_pfkey_enc_supported
Annotated Snippet
struct xfrm_algo_list {
int (*find)(const char *name, u32 type, u32 mask);
struct xfrm_algo_desc *algs;
int entries;
};
static const struct xfrm_algo_list xfrm_aead_list = {
.find = crypto_has_aead,
.algs = aead_list,
.entries = ARRAY_SIZE(aead_list),
};
static const struct xfrm_algo_list xfrm_aalg_list = {
.find = crypto_has_ahash,
.algs = aalg_list,
.entries = ARRAY_SIZE(aalg_list),
};
static const struct xfrm_algo_list xfrm_ealg_list = {
.find = crypto_has_skcipher,
.algs = ealg_list,
.entries = ARRAY_SIZE(ealg_list),
};
static const struct xfrm_algo_list xfrm_calg_list = {
.find = crypto_has_acomp,
.algs = calg_list,
.entries = ARRAY_SIZE(calg_list),
};
static struct xfrm_algo_desc *xfrm_find_algo(
const struct xfrm_algo_list *algo_list,
int match(const struct xfrm_algo_desc *entry, const void *data),
const void *data, int probe)
{
struct xfrm_algo_desc *list = algo_list->algs;
int i, status;
for (i = 0; i < algo_list->entries; i++) {
if (!match(list + i, data))
continue;
if (list[i].available)
return &list[i];
if (!probe)
break;
status = algo_list->find(list[i].name, 0, 0);
if (!status)
break;
list[i].available = status;
return &list[i];
}
return NULL;
}
static int xfrm_alg_id_match(const struct xfrm_algo_desc *entry,
const void *data)
{
return entry->desc.sadb_alg_id == (unsigned long)data;
}
struct xfrm_algo_desc *xfrm_aalg_get_byid(int alg_id)
{
return xfrm_find_algo(&xfrm_aalg_list, xfrm_alg_id_match,
(void *)(unsigned long)alg_id, 1);
}
EXPORT_SYMBOL_GPL(xfrm_aalg_get_byid);
struct xfrm_algo_desc *xfrm_ealg_get_byid(int alg_id)
{
return xfrm_find_algo(&xfrm_ealg_list, xfrm_alg_id_match,
(void *)(unsigned long)alg_id, 1);
}
EXPORT_SYMBOL_GPL(xfrm_ealg_get_byid);
struct xfrm_algo_desc *xfrm_calg_get_byid(int alg_id)
{
return xfrm_find_algo(&xfrm_calg_list, xfrm_alg_id_match,
(void *)(unsigned long)alg_id, 1);
}
EXPORT_SYMBOL_GPL(xfrm_calg_get_byid);
static int xfrm_alg_name_match(const struct xfrm_algo_desc *entry,
const void *data)
{
const char *name = data;
Annotation
- Immediate include surface: `crypto/acompress.h`, `crypto/aead.h`, `crypto/hash.h`, `crypto/skcipher.h`, `linux/module.h`, `linux/kernel.h`, `linux/pfkeyv2.h`, `linux/scatterlist.h`.
- Detected declarations: `struct xfrm_algo_list`, `struct xfrm_aead_name`, `function aalg_entries`, `function ealg_entries`, `function calg_entries`, `function match`, `function xfrm_alg_id_match`, `function xfrm_alg_name_match`, `function xfrm_aead_name_match`, `function xfrm_probe_algs`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration implementation candidate.
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.