bpf_strnstr(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… bpf_strnstr(9)

ok so this is a page from the Kernel API Manual (section 9, the kernel-funcs girlies ✨), and it's all about bpf_strnstr β€” the function that finds the first substring in a length-limited string. like strnstr but make it BPF πŸŽ€


✨ NAME ✨

bpf_strnstr β€” find the first substring in a length-limited string πŸ”


🌸 SYNOPSIS 🌸

__bpf_kfunc int bpf_strnstr (const char *s1__ign , const char *s2__ign ,
       size_t len );

πŸ¦‹ ARGUMENTS πŸ¦‹

  • s1__ign β€” the string you're searching in, i.e. the one getting snooped through πŸ•΅οΈβ€β™€οΈ
  • s2__ign β€” the string you're searching for, the one you're hoping to find 🎯
  • len β€” the maximum number of characters to search, so bestie you're only looking at the first len chars and nothing past that, periodt βœ‹

πŸ’– RETURN πŸ’–

  • >=0 β€” the index of the first character of the first occurrence of s2__ign within the first len characters of s1__ign πŸ₯³ found it!!
  • -ENOENT β€” s2__ign was not found in the first len characters of s1__ign 😭 it's not there, bestie
  • -EFAULT β€” cannot read one of the strings πŸ’€ something's unreachable
  • -E2BIG β€” one of the strings is too large, like it's giving too much 🫠
  • -ERANGE β€” one of the strings is outside of kernel address space 🚫 not our territory

πŸ‘‘ SEE ALSO πŸ‘‘

Kernel file ./kernel/bpf/helpers.c β€” and honestly the whole friend group is here, so let's give them all their moment πŸ’…


ok that's the whole page bestie, no skips, no gatekeeping 🫢

and that's a wrap!! this one lives in ./kernel/bpf and the version date on it is October 2026 β€” so yeah, bookmark it, screenshot it, send it to the group chat πŸŒˆπŸ’œ mwah πŸ’‹

πŸ“¦ where this page comes from