mirror of
https://github.com/varun-r-mallya/pylibbpf.git
synced 2026-02-12 16:11:00 +00:00
Add struct_defs_ to BpfObject
This commit is contained in:
@ -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!)
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user