[DTrace-devel] [PATCH] Fix type of default key when creating BPF maps

Kris Van Hees kris.van.hees at oracle.com
Thu Dec 9 05:04:21 UTC 2021


The default key (0) used to populate various BPF maps was declared as
uint32_t. but the 'dvars' BPF map uses a uint64_t key.  Since we know
that the vlaue of the key will always be 0, it is safe to just make it
uint64_t for all maps, and have it be interpreted as uint32_t for the
maps that use a smaller key size.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 libdtrace/dt_bpf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libdtrace/dt_bpf.c b/libdtrace/dt_bpf.c
index ccfd7f09..50343057 100644
--- a/libdtrace/dt_bpf.c
+++ b/libdtrace/dt_bpf.c
@@ -227,7 +227,7 @@ dt_bpf_gmap_create(dtrace_hdl_t *dtp)
 	int		stabsz, gvarsz, lvarsz, aggsz, memsz;
 	int		dvarc = 0;
 	int		ci_mapfd, st_mapfd, pr_mapfd;
-	uint32_t	key = 0;
+	uint64_t	key = 0;
 	size_t		strsize = dtp->dt_options[DTRACEOPT_STRSIZE];
 	uint8_t		*buf, *end;
 	char		*strtab;
-- 
2.34.1




More information about the DTrace-devel mailing list