bpf_strcmp(9)
π bpf_strcmp(9) β like, the Kernel API Manual page, bestie π
okay so real talk: this is a page from the Kernel API Manual (the bpf_strcmp(9) one, yes ma'am π) and it's literally just about comparing two strings. That's it. That's the whole vibe. But it's a BPF kfunc, so there are rules, and we're gonna go through every single one of them together. no skipping. periodt. β¨
πΈ NAME πΈ
bpf_strcmp β compare two strings π«Ά
Like, you give it two strings, it tells you who's winning. Iconic behavior honestly.
β¨ SYNOPSIS β¨
__bpf_kfunc int bpf_strcmp (const char *s1__ign , const char *s2__ign );
That's the whole signature, character for character, don't @ me π
. Note the __bpf_kfunc β that's the special sauce that makes this a BPF callable kernel function, and the __ign suffixes are just how these args are named, keep them exactly as-is.
π¦ ARGUMENTS π¦
s1__ignβ one string. just... a string. the first one. πΈs2__ignβ another string. the other one. the rival. the second contender. π
π₯ RETURN π₯
This is the part where it gets juicy β the return value is doing the actual storytelling here, so let's go one by one, no cap:
0β the strings are equal π (they're twins, they're matching, they ate)-1βs1__ignis smaller π1βs2__ignis smaller π-EFAULTβ can't read one of the strings π (like, the string said "no β€οΈ")-E2BIGβ one of the strings is too large π (she's doing too much, respectfully)-ERANGEβ one of the strings is outside of kernel address space π (wrong neighborhood bestie, she does not live there)
fr fr, clock those negative codes β they're not "smaller than" answers, they're errors. don't be out here reading -EFAULT as "string one wins by a lot." that's not the vibe. π«Ά
π SEE ALSO π
Everything below lives in the kernel file ./kernel/bpf/helpers.c β go say hi to the whole friend group:
bpf_obj_new(9),bpf_percpu_obj_new(9),bpf_obj_drop(9),bpf_percpu_obj_drop(9),bpf_refcount_acquire(9)bpf_list_push_front(9),bpf_list_push_back(9),bpf_rbtree_add(9)bpf_task_acquire(9),bpf_task_release(9),bpf_cgroup_acquire(9),bpf_cgroup_release(9),bpf_cgroup_ancestor(9),bpf_cgroup_from_id(9),bpf_task_under_cgroup(9),bpf_task_get_cgroup1(9),bpf_task_from_pid(9),bpf_task_from_vpid(9)bpf_dynptr_slice(9),bpf_dynptr_slice_rdwr(9),bpf_dynptr_copy(9),bpf_dynptr_memset(9)bpf_iter_bits_new(9),bpf_iter_bits_next(9),bpf_iter_bits_destroy(9)bpf_copy_from_user_str(9),bpf_copy_from_user_task_str(9)bpf_strcasecmp(9),bpf_strnchr(9),bpf_strchr(9),bpf_strchrnul(9),bpf_strrchr(9),bpf_strnlen(9),bpf_strlen(9),bpf_strspn(9),bpf_strcspn(9),bpf_strstr(9),bpf_strcasestr(9),bpf_strnstr(9),bpf_strncasestr(9)bpf_lookup_user_key(9),bpf_lookup_system_key(9),bpf_key_put(9),bpf_verify_pkcs7_signature(9)bpf_task_work_schedule_signal(9),bpf_task_work_schedule_resume(9),bpf_timer_cancel_async(9)
that's forty-something friends and every single one of them made the list, we do not cut people from the list π β¨
okay mwah, that's the whole page! π§ This little gem comes from the source path ./kernel/bpf and it's dated October 2026, and yes the page footer says bpf_strcmp(9) because we always come back to her. π go compare some strings bestie, ily, bye! π
π¦ 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