crit: add BPF map data decoding

This commit enables CRIT to decode the contents of a protobuf image
that stores information related to BPF map

Signed-off-by: Abhishek Vijeev <abhishek.vijeev@gmail.com>
This commit is contained in:
Abhishek Vijeev 2020-07-25 16:17:07 +05:30 committed by Andrei Vagin
parent b924394ccd
commit 4b8186cb6e

View file

@ -353,6 +353,19 @@ class tcp_stream_extra_handler:
f.seek(0, os.SEEK_END)
return pbuff.inq_len + pbuff.outq_len
class bpfmap_data_extra_handler:
def load(self, f, pload):
size = pload.keys_bytes + pload.values_bytes
data = f.read(size)
return base64.encodebytes(data)
def dump(self, extra, f, pload):
data = base64.decodebytes(extra)
f.write(data)
def skip(self, f, pload):
f.seek(pload.bytes, os.SEEK_CUR)
return pload.bytes
class ipc_sem_set_handler:
def load(self, f, pbuff):
@ -526,6 +539,9 @@ handlers = {
'CPUINFO': entry_handler(pb.cpuinfo_entry),
'MEMFD_FILE': entry_handler(pb.memfd_file_entry),
'MEMFD_INODE': entry_handler(pb.memfd_inode_entry),
'BPFMAP_FILE': entry_handler(pb.bpfmap_file_entry),
'BPFMAP_DATA': entry_handler(pb.bpfmap_data_entry,
bpfmap_data_extra_handler()),
}