@@ -18,9 +18,9 @@ static void *(*bpf_telemetry_update_patch)(unsigned long, ...) = (void *)PATCH_T
18
18
({ \
19
19
long errno_ret, errno_slot; \
20
20
errno_ret = fn(&map, args); \
21
- if (errno_ret < 0) { \
22
- unsigned long err_telemetry_key; \
23
- LOAD_CONSTANT(MK_KEY(map), err_telemetry_key); \
21
+ unsigned long err_telemetry_key; \
22
+ LOAD_CONSTANT(MK_KEY(map), err_telemetry_key); \
23
+ if (errno_ret < 0 && err_telemetry_key > 0) { \
24
24
map_err_telemetry_t *entry = \
25
25
bpf_map_lookup_elem(&map_err_telemetry_map, &err_telemetry_key); \
26
26
if (entry) { \
@@ -35,7 +35,7 @@ static void *(*bpf_telemetry_update_patch)(unsigned long, ...) = (void *)PATCH_T
35
35
/* Patched instruction for 4.14+: __sync_fetch_and_add(target, 1);
36
36
* This patch point is placed here because the above instruction
37
37
* fails on the 4.4 verifier. On 4.4 this instruction is replaced
38
- * with a nop: r1 = r1 */ \
38
+ * with a nop: r1 = r1 */ \
39
39
bpf_telemetry_update_patch ((unsigned long )target , add ); \
40
40
} \
41
41
} \
@@ -60,9 +60,9 @@ static void *(*bpf_telemetry_update_patch)(unsigned long, ...) = (void *)PATCH_T
60
60
int helper_indx = -1; \
61
61
long errno_slot; \
62
62
long errno_ret = fn(__VA_ARGS__); \
63
- if (errno_ret < 0) { \
64
- unsigned long telemetry_program_id; \
65
- LOAD_CONSTANT("telemetry_program_id_key", telemetry_program_id); \
63
+ unsigned long telemetry_program_id; \
64
+ LOAD_CONSTANT("telemetry_program_id_key", telemetry_program_id); \
65
+ if (errno_ret < 0 && telemetry_program_id > 0) { \
66
66
helper_err_telemetry_t *entry = \
67
67
bpf_map_lookup_elem(&helper_err_telemetry_map, &telemetry_program_id); \
68
68
if (entry) { \
@@ -73,7 +73,7 @@ static void *(*bpf_telemetry_update_patch)(unsigned long, ...) = (void *)PATCH_T
73
73
/* This is duplicated below because on clang 14.0.6 the compiler
74
74
* concludes that this if-check will always force errno_slot in range
75
75
* (0, T_MAX_ERRNO-1], and removes the bounds check, causing the verifier
76
- * to trip. Duplicating this check forces clang not to omit the check */ \
76
+ * to trip. Duplicating this check forces clang not to omit the check */ \
77
77
errno_slot &= (T_MAX_ERRNO - 1 ); \
78
78
} \
79
79
errno_slot &= (T_MAX_ERRNO - 1 ); \
@@ -83,7 +83,7 @@ static void *(*bpf_telemetry_update_patch)(unsigned long, ...) = (void *)PATCH_T
83
83
/* Patched instruction for 4.14+: __sync_fetch_and_add(target, 1);
84
84
* This patch point is placed here because the above instruction
85
85
* fails on the 4.4 verifier. On 4.4 this instruction is replaced
86
- * with a nop: r1 = r1 */ \
86
+ * with a nop: r1 = r1 */ \
87
87
bpf_telemetry_update_patch ((unsigned long )target , add ); \
88
88
} \
89
89
} \
0 commit comments