All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/3] bpf: expose bpf_{g,s}et_retval to more cgroup hooks
@ 2022-08-12 19:02 Stanislav Fomichev
  2022-08-12 19:02 ` [PATCH bpf-next 1/3] bpf: introduce cgroup_{common,current}_func_proto Stanislav Fomichev
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Stanislav Fomichev @ 2022-08-12 19:02 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, martin.lau, song, yhs, john.fastabend,
	kpsingh, sdf, haoluo, jolsa

Apparently, only a small subset of cgroup hooks actually falls
back to cgroup_base_func_proto. This leads to unexpected result
where not all cgroup helpers have bpf_{g,s}et_retval.

It's getting harder and harder to manage which helpers are exported
to which hooks. We now have the following call chains:

- cg_skb_func_proto
  - sk_filter_func_proto
    - bpf_sk_base_func_proto
      - bpf_base_func_proto

So by looking at cg_skb_func_proto it's pretty hard to understand
what's going on.

For cgroup helpers, I'm proposing we do the following instead:

  func_proto = cgroup_common_func_proto();
  if (func_proto) return func_proto;

  /* optional, if hook has 'current' */
  func_proto = cgroup_current_func_proto();
  if (func_proto) return func_proto;

  ...

  switch (func_id) {
  /* hook specific helpers */
  case BPF_FUNC_hook_specific_helper:
    return &xyz;
  default:
    /* always fall back to plain bpf_base_func_proto */
    bpf_base_func_proto(func_id);
  }

If this turns out more workable, we can follow up with converting
the rest to the same pattern.

Stanislav Fomichev (3):
  bpf: introduce cgroup_{common,current}_func_proto
  bpf: use cgroup_{common,current}_func_proto in more hooks
  selftests/bpf: make sure bpf_{g,s}et_retval is exposed everywhere

 include/linux/bpf.h                           | 16 +++
 kernel/bpf/cgroup.c                           | 82 +++++++--------
 kernel/bpf/helpers.c                          | 99 ++++++++++++++++++-
 net/core/filter.c                             | 78 ++++++---------
 tools/testing/selftests/bpf/Makefile          |  1 +
 .../bpf/cgroup_getset_retval_hooks.h          | 25 +++++
 .../bpf/prog_tests/cgroup_getset_retval.c     | 48 +++++++++
 .../bpf/progs/cgroup_getset_retval_hooks.c    | 16 +++
 8 files changed, 270 insertions(+), 95 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/cgroup_getset_retval_hooks.h
 create mode 100644 tools/testing/selftests/bpf/progs/cgroup_getset_retval_hooks.c

-- 
2.37.1.595.g718a3a8f04-goog


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

end of thread, other threads:[~2022-08-16 17:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-12 19:02 [PATCH bpf-next 0/3] bpf: expose bpf_{g,s}et_retval to more cgroup hooks Stanislav Fomichev
2022-08-12 19:02 ` [PATCH bpf-next 1/3] bpf: introduce cgroup_{common,current}_func_proto Stanislav Fomichev
2022-08-15 21:26   ` Martin KaFai Lau
2022-08-16 17:19     ` Stanislav Fomichev
2022-08-12 19:02 ` [PATCH bpf-next 2/3] bpf: use cgroup_{common,current}_func_proto in more hooks Stanislav Fomichev
2022-08-13  6:25   ` kernel test robot
2022-08-13 18:55   ` kernel test robot
2022-08-15 21:57   ` Martin KaFai Lau
2022-08-16 17:19     ` Stanislav Fomichev
2022-08-12 19:02 ` [PATCH bpf-next 3/3] selftests/bpf: make sure bpf_{g,s}et_retval is exposed everywhere Stanislav Fomichev

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.