Skip to content

Commit b2cfc10

Browse files
committed
Use bpf_builtins.h
1 parent 43f1001 commit b2cfc10

File tree

4 files changed

+11
-29
lines changed

4 files changed

+11
-29
lines changed

bpf/bpfcore/bpf_builtins.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,8 @@ __bpf_no_builtin_memset(void *d __maybe_unused, __u8 c __maybe_unused, __u64 len
905905
}
906906

907907
/* Redirect any direct use in our code to throw an error. */
908-
#define __builtin_memset __bpf_no_builtin_memset
908+
// TODO: re-enable once all __builtin_memset() are replaced with the optimized version
909+
// #define __builtin_memset __bpf_no_builtin_memset
909910

910911
static __always_inline __maybe_unused __nobuiltin("memset") void bpf_memset(void *d,
911912
int c,
@@ -1795,7 +1796,8 @@ static __always_inline __maybe_unused void *__bpf_no_builtin_memcpy(void *d __ma
17951796
}
17961797

17971798
/* Redirect any direct use in our code to throw an error. */
1798-
#define __builtin_memcpy __bpf_no_builtin_memcpy
1799+
// TODO: re-enable once all __builtin_memcpy() are replaced with the optimized version
1800+
// #define __builtin_memcpy __bpf_no_builtin_memcpy
17991801

18001802
static __always_inline __maybe_unused __nobuiltin("memcpy") void bpf_memcpy(void *d,
18011803
const void *s,
@@ -2692,7 +2694,8 @@ static __always_inline __maybe_unused __u64 __bpf_no_builtin_memcmp(const void *
26922694
}
26932695

26942696
/* Redirect any direct use in our code to throw an error. */
2695-
#define __builtin_memcmp __bpf_no_builtin_memcmp
2697+
// TODO: re-enable once all __builtin_memcmp() are replaced with the optimized version
2698+
// #define __builtin_memcmp __bpf_no_builtin_memcmp
26962699

26972700
/* Modified for our needs in that we only return either zero (x and y
26982701
* are equal) or non-zero (x and y are non-equal).

bpf/common/trace_common.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <maps/server_traces.h>
2424
#include <maps/tp_info_mem.h>
2525
#include <maps/tp_char_buf_mem.h>
26-
#include <maps/zeros.h>
2726

2827
#include <pid/pid_helpers.h>
2928

@@ -33,14 +32,6 @@ enum { k_bpf_traceparent_enabled = 1 };
3332
enum { k_bpf_traceparent_enabled = 0 };
3433
#endif
3534

36-
static __always_inline void cheap_bzero(unsigned char *buf, u16 size) {
37-
void *z = bpf_map_lookup_elem(&zeros, &(u16){0});
38-
if (!z) {
39-
return;
40-
}
41-
bpf_probe_read(buf, size, z);
42-
}
43-
4435
static __always_inline unsigned char *tp_char_buf() {
4536
int zero = 0;
4637
return bpf_map_lookup_elem(&tp_char_buf_mem, &zero);

bpf/generictracer/protocol_http.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include <bpfcore/vmlinux.h>
7+
#include <bpfcore/bpf_builtins.h>
78
#include <bpfcore/bpf_helpers.h>
89

910
#include <common/http_types.h>
@@ -148,7 +149,10 @@ http_get_or_create_trace_info(http_connection_metadata_t *meta,
148149
unsigned char *buf = tp_char_buf();
149150
if (buf) {
150151
const u16 buf_len = bytes_len & (TRACE_BUF_SIZE - 1);
151-
cheap_bzero(buf, TRACE_BUF_SIZE);
152+
_Static_assert(TRACE_BUF_SIZE == 1024, "Please fix the __bpf_memzero statements below this line");
153+
__bpf_memzero(buf, 512);
154+
__bpf_memzero(buf + 512, 512);
155+
152156
bpf_probe_read(buf, buf_len, u_buf);
153157

154158
unsigned char *res = tp_loop_fn(buf, buf_len);

bpf/maps/zeros.h

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)