diff --git a/Cargo.lock b/Cargo.lock index cb37684..d6dfcb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,18 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "ahash" -version = "0.8.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" -dependencies = [ - "cfg-if", - "once_cell", - "version_check", - "zerocopy", -] - [[package]] name = "aho-corasick" version = "1.1.3" @@ -209,27 +197,27 @@ dependencies = [ [[package]] name = "aya" -version = "0.12.0" +version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90eea657cc8028447cbda5068f4e10c4fadba0131624f4f7dd1a9c46ffc8d81f" +checksum = "7127cbe933572dfabb7a87d2c740f5b720c3e19b4d2b8c99a262ffa35c8761ff" dependencies = [ "assert_matches", "aya-obj", "bitflags 2.5.0", "bytes", - "lazy_static", "libc", "log", - "object", + "object 0.36.5", + "once_cell", "thiserror", "tokio", ] [[package]] name = "aya-log" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f11a92f305b983e9f53433457dede617a4ad0aa22e4702220092f39e844c1a2" +checksum = "b600d806c1d07d3b81ab5f4a2a95fd80f479a0d3f1d68f29064d660865f85f02" dependencies = [ "aya", "aya-log-common", @@ -241,24 +229,24 @@ dependencies = [ [[package]] name = "aya-log-common" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6d38a351ee2d5dc24e04cac6184b1b39408642d9a8b585892c99146f8dd4edb" +checksum = "befef9fe882e63164a2ba0161874e954648a72b0e1c4b361f532d590638c4eec" dependencies = [ "num_enum", ] [[package]] name = "aya-obj" -version = "0.1.0" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c02024a307161cf3d1f052161958fd13b1a33e3e038083e58082c0700fdab85" +checksum = "56e133d505de14d5948a312060b8b12752c22a965632cc57da12f5db653de4c0" dependencies = [ "bytes", "core-error", - "hashbrown 0.14.3", + "hashbrown 0.15.0", "log", - "object", + "object 0.36.5", "thiserror", ] @@ -273,7 +261,7 @@ dependencies = [ "cfg-if", "libc", "miniz_oxide", - "object", + "object 0.32.2", "rustc-demangle", ] @@ -387,6 +375,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "crc32fast" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" +dependencies = [ + "cfg-if", +] + [[package]] name = "either" version = "1.11.0" @@ -446,6 +443,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f81ec6369c545a7d40e4589b5597581fa1c441fe1cce96dd1de43159910a36a2" + [[package]] name = "futures-channel" version = "0.3.30" @@ -532,9 +535,16 @@ name = "hashbrown" version = "0.14.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604" + +[[package]] +name = "hashbrown" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" dependencies = [ - "ahash", "allocator-api2", + "equivalent", + "foldhash", ] [[package]] @@ -654,12 +664,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.159" @@ -826,11 +830,23 @@ dependencies = [ "memchr", ] +[[package]] +name = "object" +version = "0.36.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" +dependencies = [ + "crc32fast", + "hashbrown 0.15.0", + "indexmap 2.2.6", + "memchr", +] + [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "parking_lot" @@ -1661,26 +1677,6 @@ dependencies = [ "tonic-build", ] -[[package]] -name = "zerocopy" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74d4d3961e53fa4c9a25a8637fc2bfaf2595b3d3ae34875568a5cf64787716be" -dependencies = [ - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.7.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "zeroize" version = "1.7.0" diff --git a/Cargo.toml b/Cargo.toml index 5ca399a..fbacb8c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,9 +18,9 @@ version = "0.3.0" [workspace.dependencies] anyhow = { version = "1", default-features = true } api-server = { version = "0.3.0", path = "./dataplane/api-server" } -aya = { version = "0.12.0", default-features = false } +aya = { version = "0.13.0", default-features = false } aya-ebpf = { git = "https://github.com/aya-rs/aya", default-features = false } -aya-log = { version = "0.2.0", default-features = false } +aya-log = { version = "0.2.1", default-features = false } aya-log-ebpf = { git = "https://github.com/aya-rs/aya", default-features = false } clap = { version = "4.5", default-features = true } common = { version = "0.3.0", path = "./dataplane/common" } diff --git a/dataplane/loader/src/main.rs b/dataplane/loader/src/main.rs index 2ec5ffe..ae33d14 100644 --- a/dataplane/loader/src/main.rs +++ b/dataplane/loader/src/main.rs @@ -10,8 +10,8 @@ use anyhow::Context; use api_server::start as start_api_server; use aya::maps::HashMap; use aya::programs::{tc, SchedClassifier, TcAttachType}; -use aya::{include_bytes_aligned, Bpf}; -use aya_log::BpfLogger; +use aya::{include_bytes_aligned, Ebpf}; +use aya_log::EbpfLogger; use clap::Parser; use common::{BackendKey, BackendList, ClientKey, LoadBalancerMapping}; use log::{info, warn}; @@ -28,59 +28,64 @@ async fn main() -> Result<(), anyhow::Error> { env_logger::init(); - info!("loading ebpf programs"); - - #[cfg(debug_assertions)] - let mut bpf = Bpf::load(include_bytes_aligned!( - "../../target/bpfel-unknown-none/debug/loader" - ))?; - #[cfg(not(debug_assertions))] - let mut bpf = Bpf::load(include_bytes_aligned!( - "../../target/bpfel-unknown-none/release/loader" - ))?; - if let Err(e) = BpfLogger::init(&mut bpf) { - warn!("failed to initialize eBPF logger: {}", e); - } - - info!("attaching tc_ingress program to {}", &opt.iface); - - let _ = tc::qdisc_add_clsact(&opt.iface); - let ingress_program: &mut SchedClassifier = - bpf.program_mut("tc_ingress").unwrap().try_into()?; - ingress_program.load()?; - ingress_program - .attach(&opt.iface, TcAttachType::Ingress) - .context("failed to attach the ingress TC program")?; - - info!("attaching tc_egress program to {}", &opt.iface); - - let egress_program: &mut SchedClassifier = - bpf.program_mut("tc_egress").unwrap().try_into()?; - egress_program.load()?; - egress_program - .attach(&opt.iface, TcAttachType::Egress) - .context("failed to attach the egress TC program")?; - - info!("starting api server"); - let backends: HashMap<_, BackendKey, BackendList> = - HashMap::try_from(bpf.take_map("BACKENDS").expect("no maps named BACKENDS"))?; - let gateway_indexes: HashMap<_, BackendKey, u16> = HashMap::try_from( - bpf.take_map("GATEWAY_INDEXES") - .expect("no maps named GATEWAY_INDEXES"), - )?; - let tcp_conns: HashMap<_, ClientKey, LoadBalancerMapping> = HashMap::try_from( - bpf.take_map("LB_CONNECTIONS") - .expect("no maps named LB_CONNECTIONS"), - )?; - - start_api_server( - Ipv4Addr::new(0, 0, 0, 0), - 9874, - backends, - gateway_indexes, - tcp_conns, - ) - .await?; + info!("loading ebpf programs"); + + #[cfg(debug_assertions)] + let mut bpf_program = Ebpf::load(include_bytes_aligned!( + "../../target/bpfel-unknown-none/debug/loader" + ))?; + #[cfg(not(debug_assertions))] + let mut bpf = Ebpf::load(include_bytes_aligned!( + "../../target/bpfel-unknown-none/release/loader" + ))?; + if let Err(e) = EbpfLogger::init(&mut bpf_program) { + warn!("failed to initialize eBPF logger: {}", e); + } + + info!("attaching tc_ingress program to {}", &opt.iface); + + let _ = tc::qdisc_add_clsact(&opt.iface); + let ingress_program: &mut SchedClassifier = + bpf_program.program_mut("tc_ingress").unwrap().try_into()?; + ingress_program.load()?; + ingress_program + .attach(&opt.iface, TcAttachType::Ingress) + .context("failed to attach the ingress TC program")?; + + info!("attaching tc_egress program to {}", &opt.iface); + + let egress_program: &mut SchedClassifier = + bpf_program.program_mut("tc_egress").unwrap().try_into()?; + egress_program.load()?; + egress_program + .attach(&opt.iface, TcAttachType::Egress) + .context("failed to attach the egress TC program")?; + + info!("starting api server"); + let backends: HashMap<_, BackendKey, BackendList> = HashMap::try_from( + bpf_program + .take_map("BACKENDS") + .expect("no maps named BACKENDS"), + )?; + let gateway_indexes: HashMap<_, BackendKey, u16> = HashMap::try_from( + bpf_program + .take_map("GATEWAY_INDEXES") + .expect("no maps named GATEWAY_INDEXES"), + )?; + let tcp_conns: HashMap<_, ClientKey, LoadBalancerMapping> = HashMap::try_from( + bpf_program + .take_map("LB_CONNECTIONS") + .expect("no maps named LB_CONNECTIONS"), + )?; + + start_api_server( + Ipv4Addr::new(0, 0, 0, 0), + 9874, + backends, + gateway_indexes, + tcp_conns, + ) + .await?; info!("Exiting...");