From c26cd1395f68663e5b417b7b64c9c1e35f48fedd Mon Sep 17 00:00:00 2001 From: Abhishek Vijeev Date: Fri, 24 Jul 2020 20:24:57 +0530 Subject: [PATCH] images: protobuf definitions for BPF map meta-data and data This commit adds protobuf definitions needed to checkpoint and restore BPF map files along with the data they contain Source files added: * bpfmap-file.proto - Stores the meta-data about BPF maps * bpfmap-data.proto - Stores the data (key-value pairs) contained in BPF maps Source files modified: * fdinfo.proto - Added BPF map as a new kind of file descriptor. 'message file_entry' can now hold information about BPF map file descriptors * Makefile - Now generates build artifacts for bpfmap-file.proto and bpfmap-data.proto Signed-off-by: Abhishek Vijeev --- images/Makefile | 2 ++ images/bpfmap-data.proto | 8 ++++++++ images/bpfmap-file.proto | 20 ++++++++++++++++++++ images/fdinfo.proto | 3 +++ 4 files changed, 33 insertions(+) create mode 100644 images/bpfmap-data.proto create mode 100644 images/bpfmap-file.proto diff --git a/images/Makefile b/images/Makefile index 9ce7198c0..34bc36792 100644 --- a/images/Makefile +++ b/images/Makefile @@ -68,6 +68,8 @@ proto-obj-y += sit.o proto-obj-y += memfd.o proto-obj-y += timens.o proto-obj-y += img-streamer.o +proto-obj-y += bpfmap-file.o +proto-obj-y += bpfmap-data.o CFLAGS += -iquote $(obj)/ diff --git a/images/bpfmap-data.proto b/images/bpfmap-data.proto new file mode 100644 index 000000000..dc3b0db01 --- /dev/null +++ b/images/bpfmap-data.proto @@ -0,0 +1,8 @@ +syntax = "proto2"; + +message bpfmap_data_entry { + required uint32 map_id = 1; + required uint32 keys_bytes = 2; /* Bytes required to store keys */ + required uint32 values_bytes = 3; /* Bytes required to store values */ + required uint32 count = 4; /* Number of key-value pairs stored */ +} diff --git a/images/bpfmap-file.proto b/images/bpfmap-file.proto new file mode 100644 index 000000000..ae789aa72 --- /dev/null +++ b/images/bpfmap-file.proto @@ -0,0 +1,20 @@ +syntax = "proto2"; + +import "opts.proto"; +import "fown.proto"; + +message bpfmap_file_entry { + required uint32 id = 1; + required uint32 flags = 2 [(criu).flags = "rfile.flags"]; + required uint64 pos = 3; + required fown_entry fown = 4; + required uint32 map_type = 5; + required uint32 key_size = 6; + required uint32 value_size = 7; + required uint32 map_id = 8; + required uint32 max_entries = 9; + required uint32 map_flags = 10; + required uint64 memlock = 11; + required bool frozen = 12; + optional sint32 mnt_id = 13 [default = -1]; +} diff --git a/images/fdinfo.proto b/images/fdinfo.proto index d966d5bc5..f5e18954b 100644 --- a/images/fdinfo.proto +++ b/images/fdinfo.proto @@ -17,6 +17,7 @@ import "fifo.proto"; import "pipe.proto"; import "tty.proto"; import "memfd.proto"; +import "bpfmap-file.proto"; enum fd_types { UND = 0; @@ -38,6 +39,7 @@ enum fd_types { EXT = 16; TIMERFD = 17; MEMFD = 18; + BPFMAP = 19; /* Any number above the real used. Not stored to image */ CTL_TTY = 65534; @@ -73,4 +75,5 @@ message file_entry { optional pipe_entry pipe = 18; optional tty_file_entry tty = 19; optional memfd_file_entry memfd = 20; + optional bpfmap_file_entry bpf = 21; }