Skip to content

KFunc bpf_strnstr

v6.17

Find the first sub-string in a length-limited string

Definition

Parameters

s1__ign: The string to be searched

s2__ign: The string to search for

len: the maximum number of characters to search

Returns

  • >=0 - Index of the first character of the first occurrence of s2__ign within the first len characters of s1__ign
  • -ENOENT - s2__ign not found in the first len characters of s1__ign
  • -EFAULT - Cannot read one of the strings
  • -E2BIG - One of the strings is too large
  • -ERANGE - One of the strings is outside of kernel address space

Signature

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

Usage

Docs could be improved

This part of the docs is incomplete, contributions are very welcome

Program types

The following program types can make use of this kfunc:

Example

Docs could be improved

This part of the docs is incomplete, contributions are very welcome