Skip to content

Commit d9a42f9

Browse files
Use FUNC_RET_READ for inet_csk_accept (#201)
* use FUNC_RET_READ for inet_csk_accept * add init for ret value macro * modify probe_fill_relos * formatting
1 parent 97581e4 commit d9a42f9

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

GPL/Events/Helpers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ const volatile int consumer_pid = 0;
113113
ret; \
114114
})
115115

116+
// value is replaced later by `probe_fill_relos()`
116117
#define DECL_FUNC_RET(func) const volatile int ret__##func##__ = 0;
117118
#define FUNC_RET_READ(type, func) \
118119
({ \

GPL/Events/Network/Probe.bpf.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "Network.h"
1919
#include "State.h"
2020

21+
DECL_FUNC_RET(inet_csk_accept);
22+
2123
static int inet_csk_accept__exit(struct sock *sk)
2224
{
2325
if (!sk)
@@ -42,9 +44,9 @@ static int inet_csk_accept__exit(struct sock *sk)
4244
}
4345

4446
SEC("fexit/inet_csk_accept")
45-
int BPF_PROG(
46-
fexit__inet_csk_accept, struct sock *sk, int flags, int *err, bool kern, struct sock *ret)
47+
int BPF_PROG(fexit__inet_csk_accept)
4748
{
49+
struct sock *ret = FUNC_RET_READ(___type(ret), inet_csk_accept);
4850
return inet_csk_accept__exit(ret);
4951
}
5052

non-GPL/Events/Lib/EbpfEvents.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ static int probe_fill_relos(struct btf *btf, struct EventProbe_bpf *obj)
268268
{
269269
int err = 0;
270270

271+
err = err ?: FILL_FUNC_RET_IDX(obj, btf, inet_csk_accept);
272+
271273
err = err ?: FILL_FUNC_ARG_IDX(obj, btf, vfs_unlink, dentry);
272274
err = err ?: FILL_FUNC_RET_IDX(obj, btf, vfs_unlink);
273275

0 commit comments

Comments
 (0)