This patch allows eBPF programs that use sock_ops to send perf-based event notifications using bpf_perf_event_output()
Signed-off-by: Sowmini Varadhan <sowmini.varad...@oracle.com> --- net/core/filter.c | 19 +++++++++++++++++++ 1 files changed, 19 insertions(+), 0 deletions(-) diff --git a/net/core/filter.c b/net/core/filter.c index e521c5e..23464a3 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -4048,6 +4048,23 @@ static unsigned long bpf_xdp_copy(void *dst_buff, const void *src_buff, return ret; } +BPF_CALL_5(bpf_sock_opts_event_output, struct bpf_sock_ops *, skops, + struct bpf_map *, map, u64, flags, void *, data, u64, size) +{ + return bpf_event_output(map, flags, data, size, NULL, 0, NULL); +} + +static const struct bpf_func_proto bpf_sock_ops_event_output_proto = { + .func = bpf_sock_opts_event_output, + .gpl_only = true, + .ret_type = RET_INTEGER, + .arg1_type = ARG_PTR_TO_CTX, + .arg2_type = ARG_CONST_MAP_PTR, + .arg3_type = ARG_ANYTHING, + .arg4_type = ARG_PTR_TO_MEM, + .arg5_type = ARG_CONST_SIZE_OR_ZERO, +}; + static const struct bpf_func_proto bpf_setsockopt_proto = { .func = bpf_setsockopt, .gpl_only = false, @@ -5226,6 +5243,8 @@ bool bpf_helper_changes_pkt_data(void *func) sock_ops_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) { switch (func_id) { + case BPF_FUNC_perf_event_output: + return &bpf_sock_ops_event_output_proto; case BPF_FUNC_setsockopt: return &bpf_setsockopt_proto; case BPF_FUNC_getsockopt: -- 1.7.1