bpf_strcmp(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… 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__ign is smaller πŸ‘‘
  • 1 β€” s2__ign is 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:

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