Commit b8af171f authored by Mauricio Vasquez B's avatar Mauricio Vasquez B

cc: add support for prog table

Signed-off-by: default avatarMauricio Vasquez B <mauricio.vasquez@polito.it>
parent 0f3787f7
...@@ -482,6 +482,13 @@ std::string BPF::get_kprobe_event(const std::string& kernel_func, ...@@ -482,6 +482,13 @@ std::string BPF::get_kprobe_event(const std::string& kernel_func,
return res; return res;
} }
BPFProgTable BPF::get_prog_table(const std::string& name) {
TableStorage::iterator it;
if (bpf_module_->table_storage().Find(Path({bpf_module_->id(), name}), it))
return BPFProgTable(it->second);
return BPFProgTable({});
}
std::string BPF::get_uprobe_event(const std::string& binary_path, std::string BPF::get_uprobe_event(const std::string& binary_path,
uint64_t offset, bpf_probe_attach_type type) { uint64_t offset, bpf_probe_attach_type type) {
std::string res = attach_type_prefix(type) + "_"; std::string res = attach_type_prefix(type) + "_";
......
...@@ -106,6 +106,8 @@ public: ...@@ -106,6 +106,8 @@ public:
return BPFHashTable<KeyType, ValueType>({}); return BPFHashTable<KeyType, ValueType>({});
} }
BPFProgTable get_prog_table(const std::string& name);
BPFStackTable get_stack_table(const std::string& name) { BPFStackTable get_stack_table(const std::string& name) {
TableStorage::iterator it; TableStorage::iterator it;
if (bpf_module_->table_storage().Find(Path({bpf_module_->id(), name}), it)) if (bpf_module_->table_storage().Find(Path({bpf_module_->id(), name}), it))
......
...@@ -202,4 +202,20 @@ class BPFPerfBuffer : protected BPFTableBase<int, int> { ...@@ -202,4 +202,20 @@ class BPFPerfBuffer : protected BPFTableBase<int, int> {
std::unique_ptr<epoll_event[]> ep_events_; std::unique_ptr<epoll_event[]> ep_events_;
}; };
class BPFProgTable : protected BPFTableBase<int, int> {
public:
BPFProgTable(const TableDesc& desc)
: BPFTableBase<int, int>(desc) {
if (desc.type != BPF_MAP_TYPE_PROG_ARRAY)
throw std::invalid_argument("Table '" + desc.name + "' is not a prog table");
}
// updates an element
StatusTuple update_value(const int& index, const int& value) {
if (!this->update(const_cast<int*>(&index), const_cast<int*>(&value)))
return StatusTuple(-1, "Error updating value: %s", std::strerror(errno));
return StatusTuple(0);
}
};
} // namespace ebpf } // namespace ebpf
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment