bpf: add bpffs pretty print for cgroup local storage maps
Implement bpffs pretty printing for cgroup local storage maps (both shared and per-cpu). Output example (captured for tools/testing/selftests/bpf/netcnt_prog.c): Shared: $ cat /sys/fs/bpf/map_2 # WARNING!! The output is for debug purpose only # WARNING!! The output format will change {4294968594,1}: {9999,1039896} Per-cpu: $ cat /sys/fs/bpf/map_1 # WARNING!! The output is for debug purpose only # WARNING!! The output format will change {4294968594,1}: { cpu0: {0,0,0,0,0} cpu1: {0,0,0,0,0} cpu2: {1,104,0,0,0} cpu3: {0,0,0,0,0} } Signed-off-by: Roman Gushchin <guro@fb.com> Cc: Alexei Starovoitov <ast@kernel.org> Cc: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:

committato da
Alexei Starovoitov

parent
1b2b234b13
commit
9a1126b631
@@ -514,6 +514,28 @@ static bool btf_type_int_is_regular(const struct btf_type *t)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that given type is a regular int and has the expected size.
|
||||
*/
|
||||
bool btf_type_is_reg_int(const struct btf_type *t, u32 expected_size)
|
||||
{
|
||||
u8 nr_bits, nr_bytes;
|
||||
u32 int_data;
|
||||
|
||||
if (!btf_type_is_int(t))
|
||||
return false;
|
||||
|
||||
int_data = btf_type_int(t);
|
||||
nr_bits = BTF_INT_BITS(int_data);
|
||||
nr_bytes = BITS_ROUNDUP_BYTES(nr_bits);
|
||||
if (BITS_PER_BYTE_MASKED(nr_bits) ||
|
||||
BTF_INT_OFFSET(int_data) ||
|
||||
nr_bytes != expected_size)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
__printf(2, 3) static void __btf_verifier_log(struct bpf_verifier_log *log,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
|
Fai riferimento in un nuovo problema
Block a user