tld_create_key(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– tld_create_key(9) β€” a Kernel API Manual moment πŸ’–

okay bestie, gather round, because this one is from the Kernel API Manual and it's lowkey iconic. it's tld_create_key(9) and it's literally about making a TLD and getting a key back that's associated with it. slay. let's get into it ✨


✨ NAME ✨

tld_create_key β€” create a TLD and return a key associated with the TLD. that's it, that's the vibe πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

tld_key_t tld_create_key (const char *name , size_t size );

look at her. so clean. so main character. πŸ’…


🌸 ARGUMENTS 🌸

  • name β€” the name the TLD 🏷️ (yes, that's exactly what the manpage says, don't come for me)
  • size β€” the size of the TLD πŸ“

πŸ’œ DESCRIPTION πŸ’œ

so what does she actually do? she returns an opaque object key. that's the whole thing. iconic behaviour, no notes.

now, please don't just rawdog it and assume it worked β€” use tld_key_is_err or tld_key_err_or_zero to check if the key creation actually succeeded. vibe check your return value, fr fr 😭

once you've got your key, pass it to tld_get_data to get a pointer so you can locate the TLD. and plot twist β€” bpf programs can also fetch the same key by name. iykyk 🫢

⚠️ important bestie moment: only use tld_create_key when a TLD genuinely needs to be created dynamically β€” like when the name is not known statically, or a TLD needs to be created conditionally. don't be out here creating things dynamically for no reason, that's not the move πŸ™ˆ

and here's the memory tea β˜•: an additional TLD_DYN_DATA_SIZE bytes are allocated per-thread to accommodate TLDs created dynamically with tld_create_key. since only a user page is pinned to the kernel, when TLDs created with TLD_DEFINE_KEY uses more than TLD_PAGE_SIZE - TLD_DYN_DATA_SIZE, the buffer size will be limited to the rest of the page. so like, space is finite, the math is mathing, plan accordingly πŸ’€


πŸŽ€ SEE ALSO πŸŽ€

go read those too, bestie, knowledge is free and it's giving study session 🌈


and that's the page!! brought to you by the fine folks over at ./tools/testing/selftests/bpf/... β€” the source/version line situation β€” dated October 2026. periodt. πŸ’…βœ¨πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from