From 0a24e423184da7a1702c38a323cf0b4de7e15a9d Mon Sep 17 00:00:00 2001 From: arloor Date: Wed, 23 Oct 2024 15:56:10 +0800 Subject: [PATCH] Refactor CI workflow for building BPF code --- .../workflows/{auto.yml => auto_release.yml} | 0 .github/workflows/test.yml | 18 ++++++--- .vscode/settings.json | 3 +- Cargo.lock | 40 +++++++++---------- Cargo.toml | 2 +- cgroup_traffic/Cargo.toml | 8 ++-- socket_filter/Cargo.toml | 10 ++--- trace_conn/Cargo.toml | 4 +- 8 files changed, 47 insertions(+), 38 deletions(-) rename .github/workflows/{auto.yml => auto_release.yml} (100%) diff --git a/.github/workflows/auto.yml b/.github/workflows/auto_release.yml similarity index 100% rename from .github/workflows/auto.yml rename to .github/workflows/auto_release.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 19a34bd..2991036 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: build bpf + - name: build static if: github.event_name == 'push' && github.ref == 'refs/heads/master' - id: build_bpf + id: build_static uses: arloor/rust_musl_action@latest with: use_musl: false @@ -27,6 +27,14 @@ jobs: apt_mirror: mirrors.mit.edu rust_flags: -C target-feature=+crt-static debug: false - - name: ls dir - run: | - ls ${{ steps.build_bpf.outputs.release_dir }} \ No newline at end of file + - name: build vendored + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + id: build_vendored + uses: arloor/rust_musl_action@latest + with: + use_musl: false + extra_deps: cmake clang pkg-config make + args: -p socket_filter -p cgroup_traffic --features vendored -v + apt_mirror: mirrors.mit.edu + rust_flags: -C target-feature=+crt-static + debug: false \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index cddb8e9..b53e543 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,6 +4,7 @@ "if_ether.h": "c" }, "github-actions.workflows.pinned.workflows": [ - ".github/workflows/auto.yml" + ".github/workflows/auto.yml", + ".github/workflows/test.yml" ] } \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 5db67ec..3706a38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -68,9 +68,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "bitflags" @@ -112,9 +112,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.1.30" +version = "1.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b16803a61b81d9eabb7eae2588776c4c1e584b738ede45fdbb4c972cec1e9945" +checksum = "c2e7962b54006dcfcc61cb72735f4d89bb97061dd6a7ed882ec6b8ee53714c6f" dependencies = [ "shlex", ] @@ -329,9 +329,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.159" +version = "0.2.161" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1" [[package]] name = "linux-raw-sys" @@ -509,9 +509,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3e4daa0dcf6feba26f985457cdf104d4b4256fc5a09547140f3631bb076b19a" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -593,18 +593,18 @@ dependencies = [ [[package]] name = "serde" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "3ea7893ff5e2466df8d720bb615088341b295f849602c6956047f8f80f0e9bc1" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.213" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "7e85ad2009c50b58e87caa8cd6dac16bdf511bbfb7af6c33df902396aa480fa5" dependencies = [ "proc-macro2", "quote", @@ -613,9 +613,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -655,9 +655,9 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.79" +version = "2.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "83540f837a8afc019423a8edb95b52a8effe46957ee402287f4292fae35be021" dependencies = [ "proc-macro2", "quote", @@ -679,18 +679,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "5d11abd9594d9b38965ef50805c5e469ca9cc6f197f883f717e0269a3057b3d5" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "ae71770322cbd277e69d762a16c444af02aa0575ac0d174f0b9562d3b37f8602" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index ad23ca6..ca70689 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ # https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inheriting-a-dependency-from-a-workspace [workspace.dependencies] libbpf-cargo = "0.24" -libbpf-rs = { version = "0.24", default-features = false } # Cargo plugin to build bpf programs +libbpf-rs = "0.24" # Cargo plugin to build bpf programs vmlinux = { version = "0.0", git = "https://github.com/libbpf/vmlinux.h.git", rev = "a9c092aa771310bf8b00b5018f7d40a1fdb6ec82" } log = "0.4" libc = "0.2" diff --git a/cgroup_traffic/Cargo.toml b/cgroup_traffic/Cargo.toml index 1f3d986..caeac4c 100755 --- a/cgroup_traffic/Cargo.toml +++ b/cgroup_traffic/Cargo.toml @@ -20,9 +20,9 @@ path = "examples/ex_cgroup_traffic.rs" [dependencies] -libc.workspace = true # Raw FFI bindings to platform libraries like libc -libbpf-rs = { workspace = true, default-features = false } # libbpf-rs is a safe, idiomatic, and opinionated wrapper around libbpf-sys -plain.workspace = true # A small Rust library that allows users to reinterpret data of certain types safely +libc.workspace = true # Raw FFI bindings to platform libraries like libc +libbpf-rs = { workspace = true } # libbpf-rs is a safe, idiomatic, and opinionated wrapper around libbpf-sys +plain.workspace = true # A small Rust library that allows users to reinterpret data of certain types safely log.workspace = true [dev-dependencies] env_logger = "0.11" @@ -31,6 +31,6 @@ env_logger = "0.11" libbpf-cargo = { workspace = true } # Cargo plugin to build bpf programs [features] -default = ["libbpf-rs/default"] +default = [] vendored = ["libbpf-rs/vendored"] static = ["libbpf-rs/static"] diff --git a/socket_filter/Cargo.toml b/socket_filter/Cargo.toml index a5aca84..b6fc027 100755 --- a/socket_filter/Cargo.toml +++ b/socket_filter/Cargo.toml @@ -19,16 +19,16 @@ name = "example1" path = "examples/example1.rs" [dependencies] -libc.workspace = true # Raw FFI bindings to platform libraries like libc -libbpf-rs = { workspace = true, default-features = false } # libbpf-rs is a safe, idiomatic, and opinionated wrapper around libbpf-sys -plain.workspace = true # A small Rust library that allows users to reinterpret data of certain types safely -pnet = "0.35" # Rust library for low level networking using the pcap library +libc.workspace = true # Raw FFI bindings to platform libraries like libc +libbpf-rs = { workspace = true } # libbpf-rs is a safe, idiomatic, and opinionated wrapper around libbpf-sys +plain.workspace = true # A small Rust library that allows users to reinterpret data of certain types safely +pnet = "0.35" # Rust library for low level networking using the pcap library log.workspace = true [build-dependencies] libbpf-cargo = { workspace = true } # Cargo plugin to build bpf programs [features] -default = ["libbpf-rs/default"] +default = [] vendored = ["libbpf-rs/vendored"] static = ["libbpf-rs/static"] diff --git a/trace_conn/Cargo.toml b/trace_conn/Cargo.toml index ef5661d..da7782e 100644 --- a/trace_conn/Cargo.toml +++ b/trace_conn/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -libbpf-rs = { workspace = true, default-features = false } +libbpf-rs = { workspace = true } plain.workspace = true libc.workspace = true object = "0.36" @@ -17,7 +17,7 @@ vmlinux = { workspace = true, optional = true } [features] -default = ["libbpf-rs/default"] +default = [] vendored = ["libbpf-rs/vendored"] static = ["libbpf-rs/static"] remote-vmlinux = ["vmlinux"]