BPF List
 help / color / mirror / Atom feed
* Storing sk_buffs as kptrs in map
@ 2024-11-26 17:05 Maciej Fijalkowski
  2024-11-26 19:56 ` [External] " Amery Hung
  0 siblings, 1 reply; 10+ messages in thread
From: Maciej Fijalkowski @ 2024-11-26 17:05 UTC (permalink / raw)
  To: bpf; +Cc: magnus.karlsson, sreedevi.joshi, amery.hung, ast

Hello eBPFers,

I have a use case where I would like to store sk_buff pointers as kptrs in
eBPF map. To do so, I am borrowing skb kfuncs for acquire/release/destroy
from Amery Hung's bpf qdisc set [0], but they are registered for
BPF_PROG_TYPE_SCHED_CLS programs.

TL;DR - due to following callstack:

do_check()
  check_kfunc_call()
    check_kfunc_args()
      get_kfunc_ptr_arg_type()
          btf_is_prog_ctx_type()
              btf_is_projection_of() -- return true

sk_buff argument is being interpreted as KF_ARG_PTR_TO_CTX, but what we
have there is KF_ARG_PTR_TO_BTF_ID. Verifier is unhappy about it. Should
this be workarounded via some typedef or adding mentioned kfuncs to
special_kfunc_list ? If the latter, then what else needs to be handled?

Commenting out sk_buff part from btf_is_projection_of() makes it work, but
that probably is not a solution:)

Another question is in case bpf qdisc set lands, could we have these
kfuncs not being limited to BPF_PROG_TYPE_STRUCT_OPS ?

I would be thankful for any pointers/stions regarding this issue.
Maciej

[0]: https://lore.kernel.org/bpf/20240714175130.4051012-7-amery.hung@bytedance.com/

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

end of thread, other threads:[~2024-12-09 13:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-26 17:05 Storing sk_buffs as kptrs in map Maciej Fijalkowski
2024-11-26 19:56 ` [External] " Amery Hung
2024-11-26 20:47   ` Martin KaFai Lau
2024-11-27 19:07     ` Maciej Fijalkowski
2024-11-27 20:54       ` Martin KaFai Lau
2024-12-03 20:46         ` Maciej Fijalkowski
2024-12-04 23:24           ` Martin KaFai Lau
2024-12-06 16:24             ` Maciej Fijalkowski
2024-12-07  0:36               ` Martin KaFai Lau
2024-12-09 13:17                 ` Maciej Fijalkowski

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