net/mac802154/llsec.c
Source file repositories/reference/linux-study-clean/net/mac802154/llsec.c
File Facts
- System
- Linux kernel
- Corpus path
net/mac802154/llsec.c- Extension
.c- Size
- 25744 bytes
- Lines
- 1062
- 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/err.hlinux/bug.hlinux/completion.hlinux/ieee802154.hlinux/rculist.hcrypto/aead.hcrypto/skcipher.hieee802154_i.hllsec.h
Detected Declarations
function mac802154_llsec_initfunction mac802154_llsec_destroyfunction list_for_each_entry_safefunction list_for_each_entry_safefunction list_for_each_entry_safefunction mac802154_llsec_get_paramsfunction mac802154_llsec_set_paramsfunction llsec_key_allocfunction llsec_key_releasefunction llsec_key_getfunction llsec_key_putfunction llsec_key_id_equalfunction mac802154_llsec_key_addfunction list_for_each_entryfunction mac802154_llsec_key_del_rcufunction mac802154_llsec_key_delfunction list_for_each_entryfunction llsec_dev_use_shortaddrfunction llsec_dev_hash_shortfunction llsec_dev_hash_longfunction llsec_dev_find_shortfunction hash_for_each_possible_rcufunction llsec_dev_find_longfunction hash_for_each_possible_rcufunction llsec_dev_freefunction list_for_each_entry_safefunction mac802154_llsec_dev_addfunction llsec_dev_free_rcufunction mac802154_llsec_dev_delfunction llsec_devkey_findfunction list_for_each_entry_rcufunction mac802154_llsec_devkey_addfunction mac802154_llsec_devkey_delfunction llsec_find_seclevelfunction list_for_each_entryfunction mac802154_llsec_seclevel_addfunction mac802154_llsec_seclevel_delfunction llsec_recover_addrfunction llsec_lookup_keyfunction list_for_each_entry_rcufunction llsec_genivfunction llsec_do_encrypt_unauthfunction llsec_tfm_by_lenfunction llsec_do_encrypt_authfunction llsec_do_encryptfunction mac802154_llsec_encryptfunction llsec_lookup_devfunction hash_for_each_possible_rcu
Annotated Snippet
if (llsec_key_id_equal(&pos->id, key)) {
list_del_rcu(&pos->list);
call_rcu(&pos->rcu, mac802154_llsec_key_del_rcu);
return 0;
}
}
return -ENOENT;
}
static bool llsec_dev_use_shortaddr(__le16 short_addr)
{
return short_addr != cpu_to_le16(IEEE802154_ADDR_UNDEF) &&
short_addr != cpu_to_le16(0xffff);
}
static u32 llsec_dev_hash_short(__le16 short_addr, __le16 pan_id)
{
return ((__force u16)short_addr) << 16 | (__force u16)pan_id;
}
static u64 llsec_dev_hash_long(__le64 hwaddr)
{
return (__force u64)hwaddr;
}
static struct mac802154_llsec_device*
llsec_dev_find_short(struct mac802154_llsec *sec, __le16 short_addr,
__le16 pan_id)
{
struct mac802154_llsec_device *dev;
u32 key = llsec_dev_hash_short(short_addr, pan_id);
hash_for_each_possible_rcu(sec->devices_short, dev, bucket_s, key) {
if (dev->dev.short_addr == short_addr &&
dev->dev.pan_id == pan_id)
return dev;
}
return NULL;
}
static struct mac802154_llsec_device*
llsec_dev_find_long(struct mac802154_llsec *sec, __le64 hwaddr)
{
struct mac802154_llsec_device *dev;
u64 key = llsec_dev_hash_long(hwaddr);
hash_for_each_possible_rcu(sec->devices_hw, dev, bucket_hw, key) {
if (dev->dev.hwaddr == hwaddr)
return dev;
}
return NULL;
}
static void llsec_dev_free(struct mac802154_llsec_device *dev)
{
struct ieee802154_llsec_device_key *pos, *pn;
struct mac802154_llsec_device_key *devkey;
list_for_each_entry_safe(pos, pn, &dev->dev.keys, list) {
devkey = container_of(pos, struct mac802154_llsec_device_key,
devkey);
list_del(&pos->list);
kfree_sensitive(devkey);
}
kfree_sensitive(dev);
}
int mac802154_llsec_dev_add(struct mac802154_llsec *sec,
const struct ieee802154_llsec_device *dev)
{
struct mac802154_llsec_device *entry;
u32 skey = llsec_dev_hash_short(dev->short_addr, dev->pan_id);
u64 hwkey = llsec_dev_hash_long(dev->hwaddr);
BUILD_BUG_ON(sizeof(hwkey) != IEEE802154_ADDR_LEN);
if ((llsec_dev_use_shortaddr(dev->short_addr) &&
llsec_dev_find_short(sec, dev->short_addr, dev->pan_id)) ||
llsec_dev_find_long(sec, dev->hwaddr))
return -EEXIST;
entry = kmalloc_obj(*entry);
if (!entry)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/err.h`, `linux/bug.h`, `linux/completion.h`, `linux/ieee802154.h`, `linux/rculist.h`, `crypto/aead.h`, `crypto/skcipher.h`, `ieee802154_i.h`.
- Detected declarations: `function mac802154_llsec_init`, `function mac802154_llsec_destroy`, `function list_for_each_entry_safe`, `function list_for_each_entry_safe`, `function list_for_each_entry_safe`, `function mac802154_llsec_get_params`, `function mac802154_llsec_set_params`, `function llsec_key_alloc`, `function llsec_key_release`, `function llsec_key_get`.
- 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.