Skip to content

Commit

Permalink
Use FUNC_RET_READ for inet_csk_accept (#201)
Browse files Browse the repository at this point in the history
* use FUNC_RET_READ for inet_csk_accept

* add init for ret value macro

* modify probe_fill_relos

* formatting
  • Loading branch information
fearful-symmetry authored Aug 28, 2024
1 parent 97581e4 commit d9a42f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions GPL/Events/Helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const volatile int consumer_pid = 0;
ret; \
})

// value is replaced later by `probe_fill_relos()`
#define DECL_FUNC_RET(func) const volatile int ret__##func##__ = 0;
#define FUNC_RET_READ(type, func) \
({ \
Expand Down
6 changes: 4 additions & 2 deletions GPL/Events/Network/Probe.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "Network.h"
#include "State.h"

DECL_FUNC_RET(inet_csk_accept);

static int inet_csk_accept__exit(struct sock *sk)
{
if (!sk)
Expand All @@ -42,9 +44,9 @@ static int inet_csk_accept__exit(struct sock *sk)
}

SEC("fexit/inet_csk_accept")
int BPF_PROG(
fexit__inet_csk_accept, struct sock *sk, int flags, int *err, bool kern, struct sock *ret)
int BPF_PROG(fexit__inet_csk_accept)
{
struct sock *ret = FUNC_RET_READ(___type(ret), inet_csk_accept);
return inet_csk_accept__exit(ret);
}

Expand Down
2 changes: 2 additions & 0 deletions non-GPL/Events/Lib/EbpfEvents.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ static int probe_fill_relos(struct btf *btf, struct EventProbe_bpf *obj)
{
int err = 0;

err = err ?: FILL_FUNC_RET_IDX(obj, btf, inet_csk_accept);

err = err ?: FILL_FUNC_ARG_IDX(obj, btf, vfs_unlink, dentry);
err = err ?: FILL_FUNC_RET_IDX(obj, btf, vfs_unlink);

Expand Down

0 comments on commit d9a42f9

Please sign in to comment.