tld_create_key(9)
π 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 usetld_create_keywhen a TLD genuinely needs to be created dynamically β like when thenameis 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 π
- kernel file
./tools/testing/selftests/bpf/prog_tests/task_local_data.hπ TLD_DEFINE_KEY(9)tld_get_data(9)tld_free(9)
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
- 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