STA INFORMATION LIFETIME RULES(9)
π
STA information lifetime rules β a sta_info tell-all (section 9, Kernel API Manual)
okay so bestie, this is from the Kernel API Manual, section 9, and it's literally the whole lore of how struct sta_info stays alive (and gets yeeted) inside mac80211. grab a strawberry drink π and let's get into it.
π¦ DESCRIPTION π¦
So. STA info structures (struct sta_info) aren't just vibing alone β they're managed in a hash table for faster lookup and a list for iteration. Two whole homes. Main character energy fr. π
And how are they managed? With RCU, bestie. Like, access to the list and the hash table is protected by RCU. that's the vibe check that keeps everything safe π«
β¨ the allocation era (ownership arc begins)
When you allocate a STA info structure with sta_info_alloc, the caller owns that structure. periodt. it's yours. π«Ά
Then you must insert it into the hash table using either:
sta_info_insertsta_info_insert_rcu
and here's the tea π β only in the latter case will the pointer still be valid after the call. And heads up, sta_info_insert_rcu acquires an RCU read section but must not be called from within one. like, don't do that. π
Also, ngl, the caller may not do much with the STA info before inserting it. In particular:
- it may not start any mesh peer link management
- it may not add encryption keys
π WARNING bestie: when the insertion fails (sta_info_insertreturns non-zero), the structure will have been freed bysta_info_insert! like it's gone. don't touch it. no cap.
πΈ how station entries get added (by mac80211, not you)
Station entries are added by mac80211 when you establish a link with a peer. And because we support different types of interfaces, this means different things depending on the vibe:
- Regular station β we add the AP sta when we receive an association response from the AP. π
- IBSS β this occurs when we get to know about a peer on the same IBSS.
- WDS β we add the sta for the peer immediately upon device open.
- AP mode β we add stations for each respective station upon request from userspace through
nl80211.
π the removal era
In order to remove a STA info structure, various sta_info_destroy_*() calls are available. that's the whole lineup, iconically vague but it's giving options π
π the ownership plot twist
There is no concept of ownership on a STA entry. plot twist!! π each structure is owned by the global hash table/list until it is removed. it belongs to the collective now.
And every single user of the structure needs to be RCU protected, so that the structure won't be freed before they are done using it. that's the rule, bestie, we don't break it. π₯
π SEE ALSO π
- Kernel file
./net/mac80211/sta_info.cβsta_info_free(9) ieee80211_sta_bw_capability(9)ieee80211_sta_usable_bw(9)ieee80211_sta_current_bw(9)
go read those too, iykyk π§
okay that's the page!! π this lil masterpiece lives in ./net/mac80211, dropped October 2026, under the Kernel API Manual banner β mwah, slay, go protect your pointers responsibly πβ¨π
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms