For each hook, have a simple bpf_set_retval(bpf_get_retval) program and make sure it loads for the hooks we want. The exceptions are the hooks which don't propagate the error to the callers: - sockops - recvmsg - getpeername - getsockname - cg_skb ingress and egress Acked-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Stanislav Fomichev <sdf@google.com> Link: https://lore.kernel.org/r/20220823222555.523590-6-sdf@google.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
16 lines
355 B
C
16 lines
355 B
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#include <linux/bpf.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
#define BPF_RETVAL_HOOK(name, section, ctx, expected_err) \
|
|
__attribute__((__section__("?" section))) \
|
|
int name(struct ctx *_ctx) \
|
|
{ \
|
|
bpf_set_retval(bpf_get_retval()); \
|
|
return 1; \
|
|
}
|
|
|
|
#include "cgroup_getset_retval_hooks.h"
|
|
|
|
#undef BPF_RETVAL_HOOK
|