From 8cbea56848852bf97f5d3a017b0513a0487ec9b6 Mon Sep 17 00:00:00 2001 From: JoukoVirtanen Date: Tue, 13 Jun 2023 16:00:40 -0700 Subject: [PATCH 1/3] X-Smart-Branch-Parent: master From 1c884b1bcb67f84e0e8a8a398d6f7f7c5ac39929 Mon Sep 17 00:00:00 2001 From: JoukoVirtanen Date: Tue, 13 Jun 2023 16:01:31 -0700 Subject: [PATCH 2/3] Added probe retries for ebpf --- userspace/libscap/engine/bpf/scap_bpf.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/userspace/libscap/engine/bpf/scap_bpf.c b/userspace/libscap/engine/bpf/scap_bpf.c index 32d45c733..64901966f 100644 --- a/userspace/libscap/engine/bpf/scap_bpf.c +++ b/userspace/libscap/engine/bpf/scap_bpf.c @@ -122,7 +122,15 @@ static const char *g_filler_names[PPM_FILLER_MAX] = { static int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr, unsigned int size) { - return syscall(__NR_bpf, cmd, attr, size); + + int err = syscall(__NR_bpf, cmd, attr, size); + + if (err == EAGAIN) { + return syscall(__NR_bpf, cmd, attr, size); + } + + return err; + } static int sys_perf_event_open(struct perf_event_attr *attr, From fdff512d1c82d0a855151d062875a16ff22e6094 Mon Sep 17 00:00:00 2001 From: JoukoVirtanen Date: Tue, 13 Jun 2023 16:09:51 -0700 Subject: [PATCH 3/3] Trying up to 10 times --- userspace/libscap/engine/bpf/scap_bpf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/userspace/libscap/engine/bpf/scap_bpf.c b/userspace/libscap/engine/bpf/scap_bpf.c index 64901966f..077dd707b 100644 --- a/userspace/libscap/engine/bpf/scap_bpf.c +++ b/userspace/libscap/engine/bpf/scap_bpf.c @@ -123,10 +123,9 @@ static const char *g_filler_names[PPM_FILLER_MAX] = { static int sys_bpf(enum bpf_cmd cmd, union bpf_attr *attr, unsigned int size) { - int err = syscall(__NR_bpf, cmd, attr, size); - - if (err == EAGAIN) { - return syscall(__NR_bpf, cmd, attr, size); + for (int i = 0; i < 10; i++) { + int err = syscall(__NR_bpf, cmd, attr, size); + if (err) break; } return err;