Add TableStorage class for wrapping bpf map tracking
authorBrenden Blanco <bblanco@gmail.com>
Wed, 29 Mar 2017 16:58:31 +0000 (09:58 -0700)
committerBrenden Blanco <bblanco@gmail.com>
Mon, 3 Apr 2017 17:54:03 +0000 (10:54 -0700)
commitfaea8c8469c53ecb1ed82698bc48656462b48dcd
treec74c71ad83ba93d222e27a7cc48cc50daf083f77
parent271056f9366704dc49c9f4d7823041630940fede
Add TableStorage class for wrapping bpf map tracking

Adds a TableStorage class for use by language frontends to store/access
references to loaded bpf maps. Includes support for shared and
namespaced maps, in a directory-like hierarchy.

Add a FileDesc helper class to automatically wrap open file descriptors.
The object prevents implicit copying of the fd (allows only
rvalue/move()), and takes care of the close() call.

Add a reference implementation of a TableStorageImpl that performs the
current default behavior expected by BPF_TABLE_PUBLIC, which is to share
maps between BPFModules in the same-process only. A stub implementation
for bpffs is started.

Update b/clang frontends to use this new class.

Also included is a framework for extracting the type information of maps
in an extensible way. Migrate BMapDeclVisitor to use this as the first
consumer.

Signed-off-by: Brenden Blanco <bblanco@gmail.com>
23 files changed:
.clang-format
src/cc/BPF.cc
src/cc/BPF.h
src/cc/BPFTable.h
src/cc/CMakeLists.txt
src/cc/bpf_module.cc
src/cc/bpf_module.h
src/cc/bpffs_table.cc [new file with mode: 0644]
src/cc/frontends/b/codegen_llvm.cc
src/cc/frontends/b/codegen_llvm.h
src/cc/frontends/b/loader.cc
src/cc/frontends/b/loader.h
src/cc/frontends/clang/b_frontend_action.cc
src/cc/frontends/clang/b_frontend_action.h
src/cc/frontends/clang/loader.cc
src/cc/frontends/clang/loader.h
src/cc/json_map_decl_visitor.cc [new file with mode: 0644]
src/cc/shared_table.cc
src/cc/shared_table.h
src/cc/table_desc.h
src/cc/table_storage.cc [new file with mode: 0644]
src/cc/table_storage.h [new file with mode: 0644]
src/cc/table_storage_impl.h [new file with mode: 0644]