Skip to content

Commit bec3d62

Browse files
authored
Merge pull request #170 from oracle/optional-errs
libbpftune: only show errors on optional prog reload
2 parents e89daf0 + e0a3a97 commit bec3d62

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

include/bpftune/libbpftune.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ void bpftuner_cgroup_detach(struct bpftuner *tuner, const char *prog_name,
131131

132132

133133
struct bpftuner *bpftuner_init(const char *path);
134-
int __bpftuner_bpf_load(struct bpftuner *tuner, const char **optionals);
134+
int __bpftuner_bpf_load(struct bpftuner *tuner, const char **optionals, bool quiet);
135135
int __bpftuner_bpf_attach(struct bpftuner *tuner);
136136

137137
int bpftuner_tunables_init(struct bpftuner *tuner, unsigned int num_descs,
@@ -251,12 +251,12 @@ void bpftuner_tunables_fini(struct bpftuner *tuner);
251251
#define bpftuner_bpf_load(tuner_name, tuner, optionals) ({ \
252252
int __err; \
253253
\
254-
__err = __bpftuner_bpf_load(tuner, NULL); \
254+
__err = __bpftuner_bpf_load(tuner, NULL, optionals != NULL); \
255255
if (__err && optionals != NULL) { \
256256
bpftuner_bpf_fini(tuner); \
257257
__err = bpftuner_bpf_open(tuner_name, tuner); \
258258
if (!__err) \
259-
__err = __bpftuner_bpf_load(tuner, optionals); \
259+
__err = __bpftuner_bpf_load(tuner, optionals, false);\
260260
} \
261261
if (__err) \
262262
bpftuner_bpf_destroy(tuner_name, tuner); \

src/libbpftune.c

+5-3
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ static void bpftuner_map_init(struct bpftuner *tuner, const char *name,
575575
}
576576
}
577577

578-
int __bpftuner_bpf_load(struct bpftuner *tuner, const char **optionals)
578+
int __bpftuner_bpf_load(struct bpftuner *tuner, const char **optionals, bool quiet)
579579
{
580580
int err = 0;
581581

@@ -590,7 +590,6 @@ int __bpftuner_bpf_load(struct bpftuner *tuner, const char **optionals)
590590
netns_map_fd, &tuner->netns_map_fd) ||
591591
bpftuner_map_reuse("corr_map", tuner->corr_map,
592592
corr_map_fd, &tuner->corr_map_fd)) {
593-
bpftune_log(LOG_DEBUG, "got here!!\n");
594593
err = -1;
595594
goto out;
596595
}
@@ -613,7 +612,10 @@ int __bpftuner_bpf_load(struct bpftuner *tuner, const char **optionals)
613612
}
614613
}
615614
err = bpf_object__load_skeleton(tuner->skeleton);
616-
if (err) {
615+
/* only show errors when not in quiet mode (load with no optionals
616+
* or retry when loading without optionals failed.
617+
*/
618+
if (err && !quiet) {
617619
switch (err) {
618620
case -ESRCH:
619621
bpftune_log(LOG_ERR, "tuner '%s' failed to load, tracing target was not found; this can occur for unstable tracing targets like kernel functions.\n",

0 commit comments

Comments
 (0)