Skip to content

Commit

Permalink
Merge pull request #131 from aya-rs/names-bye
Browse files Browse the repository at this point in the history
Fix CI
  • Loading branch information
tamird authored Aug 1, 2023
2 parents ac7ee1f + bc0da20 commit 44b1024
Show file tree
Hide file tree
Showing 31 changed files with 51 additions and 55 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ on:
- main
- staging

schedule:
- cron: 00 4 * * *

env:
CARGO_TERM_COLOR: always

Expand Down Expand Up @@ -44,8 +47,9 @@ jobs:
examples/xdp-hello
examples/xdp-log
- name: Install bpf-linker
run: cargo install bpf-linker
- uses: taiki-e/install-action@v2
with:
tool: bpf-linker

- name: Set up Python
uses: actions/setup-python@v4
Expand All @@ -63,7 +67,7 @@ jobs:
for dir in ./examples/*/ ; do
pushd "${dir}"
echo "Example: ${dir}."
cargo xtask build-ebpf
cargo build
cargo xtask build-ebpf --release
cargo build --release
popd
done
2 changes: 1 addition & 1 deletion examples/aya-tool/myapp-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default = []
user = ["aya"]

[dependencies]
aya = { version = "0.11", optional = true }
aya = { git = "https://github.com/aya-rs/aya", optional = true }

[lib]
path = "src/lib.rs"
2 changes: 1 addition & 1 deletion examples/aya-tool/myapp-ebpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use vmlinux::task_struct;
#[map]
static PROCESSES: HashMap<i32, i32> = HashMap::with_max_entries(32768, 0);

#[lsm(name = "task_alloc")]
#[lsm(hook = "task_alloc")]
pub fn task_alloc(ctx: LsmContext) -> i32 {
match unsafe { try_task_alloc(ctx) } {
Ok(ret) => ret,
Expand Down
4 changes: 2 additions & 2 deletions examples/aya-tool/myapp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2021"
publish = false

[dependencies]
aya = "0.11"
aya-log = "0.1"
aya = { git = "https://github.com/aya-rs/aya" }
aya-log = { git = "https://github.com/aya-rs/aya" }
myapp-common = { path = "../myapp-common", features = ["user"] }
anyhow = "1"
ctrlc = "3.2"
Expand Down
1 change: 0 additions & 1 deletion examples/aya-tool/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let target = format!("--target={}", opts.target);
let mut args = vec![
"build",
"--verbose",
target.as_str(),
"-Z",
"build-std=core",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default = []
user = [ "aya" ]

[dependencies]
aya = { version = ">=0.11", optional=true }
aya = { git = "https://github.com/aya-rs/aya", optional=true }

[lib]
path = "src/lib.rs"
6 changes: 3 additions & 3 deletions examples/cgroup-skb-egress/cgroup-skb-egress-ebpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ use cgroup_skb_egress_common::PacketLog;
mod bindings;
use bindings::iphdr;

#[map(name = "EVENTS")]
#[map]
static EVENTS: PerfEventArray<PacketLog> =
PerfEventArray::with_max_entries(1024, 0);

#[map(name = "BLOCKLIST")] // (1)
#[map] // (1)
static BLOCKLIST: HashMap<u32, u32> = HashMap::with_max_entries(1024, 0);

#[cgroup_skb(name = "cgroup_skb_egress")]
#[cgroup_skb]
pub fn cgroup_skb_egress(ctx: SkBuffContext) -> i32 {
match { try_cgroup_skb_egress(ctx) } {
Ok(ret) => ret,
Expand Down
4 changes: 2 additions & 2 deletions examples/cgroup-skb-egress/cgroup-skb-egress/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2021"
publish = false

[dependencies]
aya = { version = ">=0.11", features = ["async_tokio"] }
aya-log = "0.1"
aya = { git = "https://github.com/aya-rs/aya", features = ["async_tokio"] }
aya-log = { git = "https://github.com/aya-rs/aya" }
cgroup-skb-egress-common = { path = "../cgroup-skb-egress-common", features = [
"user",
] }
Expand Down
5 changes: 3 additions & 2 deletions examples/cgroup-skb-egress/cgroup-skb-egress/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ async fn main() -> Result<(), anyhow::Error> {
program.attach(cgroup, CgroupSkbAttachType::Egress)?;

let mut blocklist: HashMap<_, u32, u32> =
HashMap::try_from(bpf.map_mut("BLOCKLIST")?)?;
HashMap::try_from(bpf.map_mut("BLOCKLIST").unwrap())?;

let block_addr: u32 = Ipv4Addr::new(1, 1, 1, 1).try_into()?;

// (3)
blocklist.insert(block_addr, 0, 0)?;

let mut perf_array = AsyncPerfEventArray::try_from(bpf.map_mut("EVENTS")?)?;
let mut perf_array =
AsyncPerfEventArray::try_from(bpf.take_map("EVENTS").unwrap())?;

for cpu_id in online_cpus()? {
let mut buf = perf_array.open(cpu_id, None)?;
Expand Down
1 change: 0 additions & 1 deletion examples/cgroup-skb-egress/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let target = format!("--target={}", opts.target);
let mut args = vec![
"build",
"--verbose",
target.as_str(),
"-Z",
"build-std=core",
Expand Down
2 changes: 1 addition & 1 deletion examples/kprobetcp/kprobetcp-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default = []
user = ["aya"]

[dependencies]
aya = { version = ">=0.11", optional = true }
aya = { git = "https://github.com/aya-rs/aya", optional = true }

[lib]
path = "src/lib.rs"
2 changes: 1 addition & 1 deletion examples/kprobetcp/kprobetcp-ebpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use aya_log_ebpf::info;
const AF_INET: u16 = 2;
const AF_INET6: u16 = 10;

#[kprobe(name = "kprobetcp")]
#[kprobe]
pub fn kprobetcp(ctx: ProbeContext) -> u32 {
match try_kprobetcp(ctx) {
Ok(ret) => ret,
Expand Down
1 change: 0 additions & 1 deletion examples/kprobetcp/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let target = format!("--target={}", opts.target);
let mut args = vec![
"build",
"--verbose",
target.as_str(),
"-Z",
"build-std=core",
Expand Down
2 changes: 1 addition & 1 deletion examples/lsm-nice/lsm-nice-ebpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use vmlinux::task_struct;
#[no_mangle]
static PID: i32 = 0;

#[lsm(name = "task_setnice")]
#[lsm(hook = "task_setnice")]
pub fn task_setnice(ctx: LsmContext) -> i32 {
match unsafe { try_task_setnice(ctx) } {
Ok(ret) => ret,
Expand Down
20 changes: 10 additions & 10 deletions examples/lsm-nice/lsm-nice/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ async fn main() -> Result<(), anyhow::Error> {
// like to specify the eBPF program at runtime rather than at compile-time, you can
// reach for `Bpf::load_file` instead.
#[cfg(debug_assertions)]
let mut bpf = BpfLoader::new()
.set_global("PID", &pid, true)
.load(include_bytes_aligned!(
"../../target/bpfel-unknown-none/debug/lsm-nice"
))?;
let mut bpf = BpfLoader::new().set_global("PID", &pid, true).load(
include_bytes_aligned!(
"../../target/bpfel-unknown-none/debug/lsm-nice"
),
)?;

#[cfg(not(debug_assertions))]
let mut bpf = BpfLoader::new()
.set_global("PID", &pid, true)
.load(include_bytes_aligned!(
"../../target/bpfel-unknown-none/release/lsm-nice"
))?;
let mut bpf = BpfLoader::new().set_global("PID", &pid, true).load(
include_bytes_aligned!(
"../../target/bpfel-unknown-none/release/lsm-nice"
),
)?;
if let Err(e) = BpfLogger::init(&mut bpf) {
// This can happen if you remove all log statements from your eBPF program.
warn!("failed to initialize eBPF logger: {}", e);
Expand Down
1 change: 0 additions & 1 deletion examples/lsm-nice/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let target = format!("--target={}", opts.target);
let mut args = vec![
"build",
"--verbose",
target.as_str(),
"-Z",
"build-std=core",
Expand Down
2 changes: 1 addition & 1 deletion examples/tc-egress/tc-egress-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default = []
user = ["aya"]

[dependencies]
aya = { version = ">=0.11", optional = true }
aya = { git = "https://github.com/aya-rs/aya", optional = true }

[lib]
path = "src/lib.rs"
2 changes: 1 addition & 1 deletion examples/tc-egress/tc-egress-ebpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use network_types::{
#[map]
static BLOCKLIST: HashMap<u32, u32> = HashMap::with_max_entries(1024, 0);

#[classifier(name = "tc_egress")]
#[classifier]
pub fn tc_egress(ctx: TcContext) -> i32 {
match try_tc_egress(ctx) {
Ok(ret) => ret,
Expand Down
4 changes: 2 additions & 2 deletions examples/tc-egress/tc-egress/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ edition = "2021"
publish = false

[dependencies]
aya = { version = ">=0.11", features = ["async_tokio"] }
aya-log = "0.1"
aya = { git = "https://github.com/aya-rs/aya", features = ["async_tokio"] }
aya-log = { git = "https://github.com/aya-rs/aya" }
tc-egress-common = { path = "../tc-egress-common", features = ["user"] }
anyhow = "1"
clap = { version = "4.1", features = ["derive"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/tc-egress/tc-egress/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async fn main() -> Result<(), anyhow::Error> {

// (1)
let mut blocklist: HashMap<_, u32, u32> =
HashMap::try_from(bpf.map_mut("BLOCKLIST")?)?;
HashMap::try_from(bpf.map_mut("BLOCKLIST").unwrap())?;

// (2)
let block_addr: u32 = Ipv4Addr::new(1, 1, 1, 1).try_into()?;
Expand Down
1 change: 0 additions & 1 deletion examples/tc-egress/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let target = format!("--target={}", opts.target);
let mut args = vec![
"build",
"--verbose",
target.as_str(),
"-Z",
"build-std=core",
Expand Down
2 changes: 1 addition & 1 deletion examples/xdp-drop/xdp-drop-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default = []
user = [ "aya" ]

[dependencies]
aya = { version = ">=0.11", optional=true }
aya = { git = "https://github.com/aya-rs/aya", optional=true }

[lib]
path = "src/lib.rs"
2 changes: 1 addition & 1 deletion examples/xdp-drop/xdp-drop-ebpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn panic(_info: &core::panic::PanicInfo) -> ! {
unsafe { core::hint::unreachable_unchecked() }
}

#[map(name = "BLOCKLIST")] // (1)
#[map] // (1)
static BLOCKLIST: HashMap<u32, u32> =
HashMap::<u32, u32>::with_max_entries(1024, 0);

Expand Down
1 change: 0 additions & 1 deletion examples/xdp-drop/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let target = format!("--target={}", opts.target);
let mut args = vec![
"build",
"--verbose",
target.as_str(),
"-Z",
"build-std=core",
Expand Down
2 changes: 1 addition & 1 deletion examples/xdp-hello/xdp-hello-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default = []
user = [ "aya" ]

[dependencies]
aya = { version = ">=0.11", optional=true }
aya = { git = "https://github.com/aya-rs/aya", optional=true }

[lib]
path = "src/lib.rs"
2 changes: 1 addition & 1 deletion examples/xdp-hello/xdp-hello-ebpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use aya_bpf::{bindings::xdp_action, macros::xdp, programs::XdpContext};
use aya_log_ebpf::info;

#[xdp(name = "xdp_hello")] // (4)
#[xdp] // (4)
pub fn xdp_hello(ctx: XdpContext) -> u32 {
// (5)
match unsafe { try_xdp_hello(ctx) } {
Expand Down
1 change: 0 additions & 1 deletion examples/xdp-hello/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let target = format!("--target={}", opts.target);
let mut args = vec![
"build",
"--verbose",
target.as_str(),
"-Z",
"build-std=core",
Expand Down
2 changes: 1 addition & 1 deletion examples/xdp-log/xdp-log-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ default = []
user = [ "aya" ]

[dependencies]
aya = { version = ">=0.11", optional=true }
aya = { git = "https://github.com/aya-rs/aya", optional=true }

[lib]
path = "src/lib.rs"
5 changes: 1 addition & 4 deletions examples/xdp-log/xdp-log-ebpf/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ fn try_xdp_firewall(ctx: XdpContext) -> Result<u32, ()> {
};

// (3)
info!(
&ctx,
"SRC IP: {:i}, SRC PORT: {}", source_addr, source_port
);
info!(&ctx, "SRC IP: {:i}, SRC PORT: {}", source_addr, source_port);

Ok(xdp_action::XDP_PASS)
}
7 changes: 5 additions & 2 deletions examples/xdp-log/xdp-log/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
use aya::{include_bytes_aligned, Bpf};
use anyhow::Context;
use aya::programs::{Xdp, XdpFlags};
use aya::{
include_bytes_aligned,
programs::{Xdp, XdpFlags},
Bpf,
};
use aya_log::BpfLogger;
use clap::Parser;
use log::{info, warn};
Expand Down
4 changes: 1 addition & 3 deletions examples/xdp-log/xtask/src/build_ebpf.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use std::path::PathBuf;
use std::process::Command;
use std::{path::PathBuf, process::Command};

use clap::Parser;

Expand Down Expand Up @@ -45,7 +44,6 @@ pub fn build_ebpf(opts: Options) -> Result<(), anyhow::Error> {
let target = format!("--target={}", opts.target);
let mut args = vec![
"build",
"--verbose",
target.as_str(),
"-Z",
"build-std=core",
Expand Down

0 comments on commit 44b1024

Please sign in to comment.