Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): bump aya-log from 0.2.0 to 0.2.1 #294

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 50 additions & 54 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
115 changes: 60 additions & 55 deletions dataplane/loader/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand All @@ -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...");

Expand Down
Loading