Skip to content

Commit

Permalink
ci: added compile test
Browse files Browse the repository at this point in the history
  • Loading branch information
rphang committed Mar 20, 2024
1 parent b620597 commit 91f54e9
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 29 deletions.
34 changes: 34 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -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
51 changes: 51 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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 \;
Expand Down
4 changes: 0 additions & 4 deletions src/icmp_pingback/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 0 additions & 12 deletions src/icmp_pingback/maps/bpf_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";
12 changes: 0 additions & 12 deletions src/icmp_pingback/minimum/bpf_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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";

0 comments on commit 91f54e9

Please sign in to comment.