diff options
| author | Chris J Arges <[email protected]> | 2022-03-09 21:41:58 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2022-03-10 23:06:11 +0000 |
| commit | 357b3cc3c0467b2f7cd6c4a87f7a18bfd779ce5b (patch) | |
| tree | a2220e3df19d2cfcb614a891ad66203eecacd51c /tools/bpf/bpftool/prog.c | |
| parent | bpf: Use offsetofend() to simplify macro definition (diff) | |
| download | kernel-357b3cc3c0467b2f7cd6c4a87f7a18bfd779ce5b.tar.gz kernel-357b3cc3c0467b2f7cd6c4a87f7a18bfd779ce5b.zip | |
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 <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/bpf/bpftool/prog.c')
| -rw-r--r-- | tools/bpf/bpftool/prog.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 8a52eed19fa2..bc4e05542c2b 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -485,7 +485,7 @@ static void print_prog_json(struct bpf_prog_info *info, int fd) memlock = get_fdinfo(fd, "memlock"); if (memlock) - jsonw_int_field(json_wtr, "bytes_memlock", atoi(memlock)); + jsonw_int_field(json_wtr, "bytes_memlock", atoll(memlock)); free(memlock); if (info->nr_map_ids) |
