mirror of
https://github.com/varun-r-mallya/pylibbpf.git
synced 2026-02-12 16:11:00 +00:00
add map support
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
#include <filesystem>
|
||||
#include <utility>
|
||||
|
||||
BpfProgram::BpfProgram(std::string object_path, std::string program_name)
|
||||
BpfProgram::BpfProgram(std::string object_path, std::string program_name)
|
||||
: obj_(nullptr), prog_(nullptr), link_(nullptr),
|
||||
object_path_(std::move(object_path)), program_name_(std::move(program_name)) {
|
||||
}
|
||||
@ -15,6 +15,10 @@ BpfProgram::~BpfProgram() {
|
||||
}
|
||||
}
|
||||
|
||||
struct bpf_object * BpfProgram::get_obj() const {
|
||||
return obj_;
|
||||
}
|
||||
|
||||
bool BpfProgram::load() {
|
||||
// Open the eBPF object file
|
||||
obj_ = bpf_object__open_file(object_path_.c_str(), nullptr);
|
||||
@ -48,8 +52,7 @@ bool BpfProgram::load() {
|
||||
}
|
||||
|
||||
bool BpfProgram::attach() {
|
||||
for (auto [prog, link] : programs)
|
||||
{
|
||||
for (auto [prog, link]: programs) {
|
||||
if (!prog) {
|
||||
throw BpfException("Program not loaded");
|
||||
}
|
||||
@ -66,7 +69,7 @@ bool BpfProgram::attach() {
|
||||
|
||||
bool BpfProgram::destroy() {
|
||||
bool success = true;
|
||||
for (auto [prog, link] : programs) {
|
||||
for (auto [prog, link]: programs) {
|
||||
if (!prog) {
|
||||
throw BpfException("Program not loaded");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user