Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

bpftool: Ensure bytes_memlock json output is correct

If a BPF map is created over 2^32 the memlock value as displayed in JSON
format will be incorrect. Use atoll instead of atoi so that the correct
number is displayed.

```
$ bpftool map create /sys/fs/bpf/test_bpfmap type hash key 4 \
value 1024 entries 4194304 name test_bpfmap
$ bpftool map list
1: hash name test_bpfmap flags 0x0
key 4B value 1024B max_entries 4194304 memlock 4328521728B
$ sudo bpftool map list -j | jq .[].bytes_memlock
33554432
```

Signed-off-by: Chris J Arges <carges@cloudflare.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/b6601087-0b11-33cc-904a-1133d1500a10@cloudflare.com

authored by

Chris J Arges and committed by
Daniel Borkmann
357b3cc3 1b773d00

+2 -2
+1 -1
tools/bpf/bpftool/map.c
··· 504 504 jsonw_uint_field(json_wtr, "max_entries", info->max_entries); 505 505 506 506 if (memlock) 507 - jsonw_int_field(json_wtr, "bytes_memlock", atoi(memlock)); 507 + jsonw_int_field(json_wtr, "bytes_memlock", atoll(memlock)); 508 508 free(memlock); 509 509 510 510 if (info->type == BPF_MAP_TYPE_PROG_ARRAY) {
+1 -1
tools/bpf/bpftool/prog.c
··· 485 485 486 486 memlock = get_fdinfo(fd, "memlock"); 487 487 if (memlock) 488 - jsonw_int_field(json_wtr, "bytes_memlock", atoi(memlock)); 488 + jsonw_int_field(json_wtr, "bytes_memlock", atoll(memlock)); 489 489 free(memlock); 490 490 491 491 if (info->nr_map_ids)