BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/5] bpf: add bpf_memcmp and bpf_strpbrk kfuncs
@ 2026-06-23  3:07 Longjun Tang
  2026-06-23  3:07 ` [PATCH bpf-next 1/5] bpf: add bpf_memcmp kfunc Longjun Tang
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: Longjun Tang @ 2026-06-23  3:07 UTC (permalink / raw)
  To: ast, andrii; +Cc: yonghong.song, jolsa, bpf, tanglongjun, lange_tang

From: Longjun Tang <tanglongjun@kylinos.cn>

This series adds two new BPF kfuncs to kernel/bpf/helpers.c:

- bpf_memcmp(): Binary memory comparison, unlike bpf_strcmp null
  bytes do not terminate the comparison. Returns 0, -1, or 1 with
  standard error codes (-EFAULT, -E2BIG, -ERANGE).

- bpf_strpbrk(): Find the first occurrence of any character from an
  accept set in a string. Complements the existing strspn/strcspn
  kfuncs for string tokenization use cases.

All kfuncs are registered in common_btf_ids, making them available
to all BPF program types. Selftests cover functional correctness
(equality, ordering, edge cases) and negative paths (NULL, user,
and invalid kernel pointers).

Longjun Tang (5):
  bpf: add bpf_memcmp kfunc
  selftests/bpf: rename local bpf_memcmp to avoid conflict
  selftests/bpf: add tests for bpf_memcmp
  bpf: add bpf_strpbrk kfunc
  selftests/bpf: add tests for bpf_strpbrk

 kernel/bpf/helpers.c                          | 105 ++++++++++++++++++
 .../selftests/bpf/progs/dynptr_success.c      |  30 ++---
 .../bpf/progs/string_kfuncs_failure1.c        |  16 +++
 .../bpf/progs/string_kfuncs_success.c         |  25 +++++
 4 files changed, 161 insertions(+), 15 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-06-23  3:54 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-23  3:07 [PATCH bpf-next 0/5] bpf: add bpf_memcmp and bpf_strpbrk kfuncs Longjun Tang
2026-06-23  3:07 ` [PATCH bpf-next 1/5] bpf: add bpf_memcmp kfunc Longjun Tang
2026-06-23  3:22   ` sashiko-bot
2026-06-23  3:54   ` bot+bpf-ci
2026-06-23  3:07 ` [PATCH bpf-next 2/5] selftests/bpf: rename local bpf_memcmp to avoid conflict Longjun Tang
2026-06-23  3:08 ` [PATCH bpf-next 3/5] selftests/bpf: add tests for bpf_memcmp Longjun Tang
2026-06-23  3:26   ` sashiko-bot
2026-06-23  3:08 ` [PATCH bpf-next 4/5] bpf: add bpf_strpbrk kfunc Longjun Tang
2026-06-23  3:20   ` sashiko-bot
2026-06-23  3:08 ` [PATCH bpf-next 5/5] selftests/bpf: add tests for bpf_strpbrk Longjun Tang
2026-06-23  3:19   ` sashiko-bot
2026-06-23  3:19 ` [PATCH bpf-next 0/5] bpf: add bpf_memcmp and bpf_strpbrk kfuncs Alexei Starovoitov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox