From 91f54e9f830a36a203168f6f7a90891e872a4fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rom=C3=A9o=20Phang?= Date: Wed, 20 Mar 2024 17:55:20 +0100 Subject: [PATCH] ci: added compile test --- .github/workflows/push.yml | 34 +++++++++++++++++ .github/workflows/release.yml | 51 ++++++++++++++++++++++++++ Makefile | 2 +- src/icmp_pingback/README.md | 4 -- src/icmp_pingback/maps/bpf_helper.h | 12 ------ src/icmp_pingback/minimum/bpf_helper.h | 12 ------ 6 files changed, 86 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/push.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml new file mode 100644 index 0000000..cf586ba --- /dev/null +++ b/.github/workflows/push.yml @@ -0,0 +1,34 @@ +name: create-bin + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y clang llvm libelf-dev gcc-multilib linux-headers-$(uname -r) build-essential + - name: Setting up libbpf + run: | + make -C lib/libbpf/src + sudo make -C lib/libbpf/src install + - name: Compile + run: | + make + - name: Archive production artifacts + uses: actions/upload-artifact@v4 + with: + name: evilbpf-bin-${{ github.sha }} + path: | + dst \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..ea4a56f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,51 @@ +name: Release + +on: + push: + tags: + - 'v*' + +jobs: + build: + permissions: + contents: write + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + submodules: recursive + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y clang llvm libelf-dev gcc-multilib linux-headers-$(uname -r) build-essential + - name: Setting up libbpf + run: | + make -C lib/libbpf/src + sudo make -C lib/libbpf/src install + - name: Compile + run: | + make + - name: Zipping artifacts + run: | + zip -r evilbpf-${{ github.ref_name }}.zip dst + - name: Create release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref_name }} + release_name: Release ${{ github.ref_name }} + draft: false + prerelease: false + - name: Upload release asset + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./evilbpf-${{ github.ref_name }}.zip + asset_name: evilbpf-${{ github.ref_name }}.zip + asset_content_type: application/zip \ No newline at end of file diff --git a/Makefile b/Makefile index 29ff2fe..4b93123 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ all: - find . -mindepth 2 -name libbpf -prune -o -name Makefile -execdir make release \; + find . -mindepth 2 -name libbpf -prune -o -name Makefile -execdir make release \; || exit 1 clean: find . -mindepth 2 -name libbpf -prune -o -name Makefile -execdir make clean \; diff --git a/src/icmp_pingback/README.md b/src/icmp_pingback/README.md index 8d9ca0e..10e9055 100644 --- a/src/icmp_pingback/README.md +++ b/src/icmp_pingback/README.md @@ -12,7 +12,3 @@ All versions kinda based on the same code, but each one adds a way to load or us | ------- | ----------- | | [minimum](minimum) | The bare minimum to get a working XDP program. (no maps, no skel) | | [maps](maps) | Adds a map to the program to enable/disable the pingback service on runtime. | - -> [!NOTE] -> On my dev machine, my `vmlinux.h` file is generated without the `xdp_md` struct. I for now have no idea why this is the case, but I've found a workaround by simply -> redefining the `xdp_md` struct in the application code. This is not ideal, but it works for now. (You may need to remove it if you are not facing this issue) \ No newline at end of file diff --git a/src/icmp_pingback/maps/bpf_helper.h b/src/icmp_pingback/maps/bpf_helper.h index 746f445..40b6f4b 100644 --- a/src/icmp_pingback/maps/bpf_helper.h +++ b/src/icmp_pingback/maps/bpf_helper.h @@ -35,18 +35,6 @@ static inline void csum_replace(uint16_t *sum, uint16_t old, uint16_t new) *sum = ~csum; } -/* From linux/bpf.h */ -struct xdp_md { - __u32 data; - __u32 data_end; - __u32 data_meta; - /* Below access go through struct xdp_rxq_info */ - __u32 ingress_ifindex; /* rxq->dev->ifindex */ - __u32 rx_queue_index; /* rxq->queue_index */ - - __u32 egress_ifindex; /* txq->dev->ifindex */ -}; - void *memcpy(void *dest, const void *src, size_t n); char _license[] SEC("license") = "GPL"; \ No newline at end of file diff --git a/src/icmp_pingback/minimum/bpf_helper.h b/src/icmp_pingback/minimum/bpf_helper.h index 4d7f9bf..2fba501 100644 --- a/src/icmp_pingback/minimum/bpf_helper.h +++ b/src/icmp_pingback/minimum/bpf_helper.h @@ -35,18 +35,6 @@ static inline void csum_replace(uint16_t *sum, uint16_t old, uint16_t new) *sum = ~csum; } -/* From linux/bpf.h */ -struct xdp_md { - __u32 data; - __u32 data_end; - __u32 data_meta; - /* Below access go through struct xdp_rxq_info */ - __u32 ingress_ifindex; /* rxq->dev->ifindex */ - __u32 rx_queue_index; /* rxq->queue_index */ - - __u32 egress_ifindex; /* txq->dev->ifindex */ -}; - void *memcpy(void *dest, const void *src, size_t n); char _license[] SEC("license") = "GPL"; \ No newline at end of file