Add struct_defs_ to BpfObject

This commit is contained in:
Pragyansh Chaturvedi
2025-10-19 21:26:20 +05:30
parent 874d567825
commit b4d0a49883
2 changed files with 5 additions and 3 deletions

View File

@ -4,8 +4,9 @@
#include "bpf_program.h" #include "bpf_program.h"
#include <cerrno> #include <cerrno>
BpfObject::BpfObject(std::string object_path) BpfObject::BpfObject(std::string object_path, py::dict structs)
: obj_(nullptr), object_path_(std::move(object_path)), loaded_(false) {} : obj_(nullptr), object_path_(std::move(object_path)), loaded_(false),
struct_defs_(structs) {}
BpfObject::~BpfObject() { BpfObject::~BpfObject() {
// Clear caches first (order matters!) // Clear caches first (order matters!)

View File

@ -28,12 +28,13 @@ private:
mutable std::unordered_map<std::string, std::shared_ptr<BpfMap>> maps_cache_; mutable std::unordered_map<std::string, std::shared_ptr<BpfMap>> maps_cache_;
mutable std::unordered_map<std::string, std::shared_ptr<BpfProgram>> mutable std::unordered_map<std::string, std::shared_ptr<BpfProgram>>
prog_cache_; prog_cache_;
py::dict struct_defs_;
std::shared_ptr<BpfProgram> _get_or_create_program(struct bpf_program *prog); std::shared_ptr<BpfProgram> _get_or_create_program(struct bpf_program *prog);
std::shared_ptr<BpfMap> _get_or_create_map(struct bpf_map *map); std::shared_ptr<BpfMap> _get_or_create_map(struct bpf_map *map);
public: public:
explicit BpfObject(std::string object_path); explicit BpfObject(std::string object_path, py::dict structs = py::dict());
~BpfObject(); ~BpfObject();
// Disable copy, allow move // Disable copy, allow move