Skip to content

Commit 595b2e5

Browse files
[#119]: replaced old Bpf import with the new Ebpf import from aya
1 parent e806057 commit 595b2e5

1 file changed

Lines changed: 7 additions & 11 deletions

File tree

  • core/src/components/identity/src

core/src/components/identity/src/main.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ mod structs;
1616
mod map_handlers;
1717

1818
use aya::{
19-
Bpf,
20-
maps::{ Map, MapData, perf::{ PerfEventArray, PerfEventArrayBuffer } },
21-
programs::{ KProbe, SchedClassifier, TcAttachType, tc::SchedClassifierLinkId },
22-
util::online_cpus,
19+
Ebpf, maps::{ Map, MapData, perf::{ PerfEventArray, PerfEventArrayBuffer } }, programs::{ KProbe, SchedClassifier, TcAttachType, tc::SchedClassifierLinkId }, util::online_cpus
2320
};
2421

2522
use crate::helpers::{
@@ -59,7 +56,7 @@ async fn main() -> Result<(), anyhow::Error> {
5956
let data = fs::read(Path::new(&bpf_path)).await.context("failed to load file from path")?;
6057

6158
//init bpf data
62-
let bpf = Arc::new(Mutex::new(Bpf::load(&data)?));
59+
let bpf = Arc::new(Mutex::new(Ebpf::load(&data)?));
6360
let bpf_map_save_path = std::env
6461
::var(constants::PIN_MAP_PATH)
6562
.context("PIN_MAP_PATH environment variable required")?;
@@ -69,7 +66,7 @@ async fn main() -> Result<(), anyhow::Error> {
6966
info!("Successfully loaded bpf maps");
7067
let pin_path = std::path::PathBuf::from(&bpf_map_save_path);
7168
info!("About to call map_pinner with path: {:?}", pin_path);
72-
match map_pinner(&bpf_maps, &pin_path).await {
69+
match map_pinner(&bpf_maps, &pin_path) {
7370
std::result::Result::Ok(_) => {
7471
info!("maps pinned successfully");
7572
//load veth_trace program ref veth_trace.rs
@@ -102,7 +99,6 @@ async fn main() -> Result<(), anyhow::Error> {
10299
}
103100
Err(e) => {
104101
error!("Error while pinning bpf_maps: {}", e);
105-
signal::ctrl_c();
106102
}
107103
}
108104
}
@@ -117,7 +113,7 @@ async fn main() -> Result<(), anyhow::Error> {
117113

118114
//attach the tc classifier program to a vector of interfaces
119115
async fn init_tc_classifier(
120-
bpf: Arc<Mutex<Bpf>>,
116+
bpf: Arc<Mutex<Ebpf>>,
121117
ifaces: Vec<String>,
122118
link_ids: Arc<Mutex<HashMap<String, SchedClassifierLinkId>>>
123119
) -> Result<(), anyhow::Error> {
@@ -148,7 +144,7 @@ async fn init_tc_classifier(
148144
Ok(())
149145
}
150146

151-
async fn init_veth_tracer(bpf: Arc<Mutex<Bpf>>) -> Result<(), anyhow::Error> {
147+
async fn init_veth_tracer(bpf: Arc<Mutex<Ebpf>>) -> Result<(), anyhow::Error> {
152148
//this functions init the veth_tracer used to make the InterfacesRegistry
153149

154150
let mut bpf_new = bpf.lock().unwrap();
@@ -180,7 +176,7 @@ async fn init_veth_tracer(bpf: Arc<Mutex<Bpf>>) -> Result<(), anyhow::Error> {
180176
Ok(())
181177
}
182178

183-
async fn init_tcp_registry(bpf: Arc<Mutex<Bpf>>) -> Result<(), anyhow::Error> {
179+
async fn init_tcp_registry(bpf: Arc<Mutex<Ebpf>>) -> Result<(), anyhow::Error> {
184180
let mut bpf_new = bpf.lock().unwrap();
185181

186182
// init tcp registry
@@ -216,7 +212,7 @@ async fn init_tcp_registry(bpf: Arc<Mutex<Bpf>>) -> Result<(), anyhow::Error> {
216212
async fn event_listener(
217213
bpf_maps: (Map, Map, Map, Map),
218214
link_ids: Arc<Mutex<HashMap<String, SchedClassifierLinkId>>>,
219-
bpf: Arc<Mutex<Bpf>>
215+
bpf: Arc<Mutex<Ebpf>>
220216
) -> Result<(), anyhow::Error> {
221217
// this function init the event listener. Listens for veth events (creation/deletion) and network events (pod to pod communications)
222218
/* Doc:

0 commit comments

Comments
 (0)