Skip to content

Commit

Permalink
Use multi XDP attach fix
Browse files Browse the repository at this point in the history
  • Loading branch information
LOU Xun committed Aug 7, 2020
1 parent 19331e1 commit 6f39ae1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 25 deletions.
12 changes: 6 additions & 6 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 block-the-rabbit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ version = "0.1.0"
edition = '2018'

[dependencies]
redbpf-macros = { git = "https://github.com/redsift/redbpf.git" }
redbpf-probes = { git = "https://github.com/redsift/redbpf.git" }
redbpf-macros = { git = "https://github.com/aquarhead/redbpf.git", branch = "xdp-multi-attach" }
redbpf-probes = { git = "https://github.com/aquarhead/redbpf.git", branch = "xdp-multi-attach" }

[features]
default = []
Expand Down
4 changes: 2 additions & 2 deletions ready-the-rabbit/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "ready-the-rabbit"
version = "0.1.0"
version = "0.2.0"
authors = ["LOU Xun <aquarhead@ela.build>"]
edition = "2018"
build = "build.rs"

[dependencies]
redbpf = { git = "https://github.com/redsift/redbpf.git", features = ["load"] }
redbpf = { git = "https://github.com/aquarhead/redbpf.git", branch = "xdp-multi-attach", features = ["load"] }
anyhow = "1.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
Expand Down
25 changes: 10 additions & 15 deletions ready-the-rabbit/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,16 @@ fn main() -> Result<()> {
let mut loader = Loader::load(prog).expect("error loading XDP program");

for prog in loader.module.xdps_mut() {
// Ideally we should not hardcode the interface, but there's a bug in RedBPF currently
//
// let interfaces = std::fs::read_dir("/sys/class/net").expect("failed to list interfaces");
// for interface in interfaces {
// if let Ok(iface) = interface {
// if let Ok(ifa) = iface.file_name().into_string() {
// prog
// .attach_xdp(&ifa, xdp::Flags::default())
// .expect("failed to attach XDP program");
// }
// }
// }
prog
.attach_xdp("eth0", Default::default())
.expect("failed to attach XDP program");
let interfaces = std::fs::read_dir("/sys/class/net").expect("failed to list interfaces");
for interface in interfaces {
if let Ok(iface) = interface {
if let Ok(ifa) = iface.file_name().into_string() {
prog
.attach_xdp(&ifa, Default::default())
.expect("failed to attach XDP program");
}
}
}
}

loop {
Expand Down

0 comments on commit 6f39ae1

Please sign in to comment.