Skip to content

Commit fc987b8

Browse files
author
Tomasz Jonak
committed
Dev: enable inclusion of ebpfguard as a regular cargo dependency
Requires checking in compiled eBPF object.
1 parent 1a1f672 commit fc987b8

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ members = [
55
"xtask",
66
"examples/*",
77
]
8+
exclude = ["ebpfguard-ebpf"]
89

910
[patch.crates-io]
1011
aya = { git = "https://github.com/deepfence/aya-rs", branch = "btf-fixes" }

ebpfguard-common/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ default = []
88
user = ["aya"]
99

1010
[dependencies]
11-
aya = { version = ">=0.11", optional = true }
11+
aya = { git = "https://github.com/deepfence/aya-rs", branch = "btf-fixes", optional=true }
1212

1313
[lib]
1414
path = "src/lib.rs"

ebpfguard-ebpf/ebpfguard.debug.obj

8.47 MB
Binary file not shown.

ebpfguard/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ pub struct PolicyManager {
230230

231231
impl PolicyManager {
232232
/// Default path for storage of eBPFGuard maps
233-
const DEFAULT_BPFFS_MAPS_PATH: &str = "/sys/fs/bpf/ebpfguard_default";
233+
pub const DEFAULT_BPFFS_MAPS_PATH: &str = "/sys/fs/bpf/ebpfguard_default";
234234

235235
/// Creates a new policy manager with default maps path.
236236
///
@@ -242,6 +242,7 @@ impl PolicyManager {
242242
/// let mut policy_manager = PolicyManager::with_default_path().unwrap();
243243
/// ```
244244
pub fn with_default_path() -> Result<Self, EbpfguardError> {
245+
std::fs::create_dir_all(Self::DEFAULT_BPFFS_MAPS_PATH)?;
245246
Self::new(Self::DEFAULT_BPFFS_MAPS_PATH)
246247
}
247248

@@ -260,13 +261,13 @@ impl PolicyManager {
260261
let bpf = BpfLoader::new()
261262
.map_pin_path(&bpf_path)
262263
.load(include_bytes_aligned!(
263-
"../../target/bpfel-unknown-none/debug/ebpfguard"
264+
"../../ebpfguard-ebpf/ebpfguard.debug.obj"
264265
))?;
265266
#[cfg(not(debug_assertions))]
266267
let bpf = BpfLoader::new()
267268
.map_pin_path(&bpf_path)
268269
.load(include_bytes_aligned!(
269-
"../../target/bpfel-unknown-none/release/ebpfguard"
270+
"../../ebpfguard-ebpf/ebpfguard.release.obj"
270271
))?;
271272

272273
Ok(Self { bpf })

0 commit comments

Comments
 (0)