From e0b585c993aadccd72c320e88b22f86aa4c83f54 Mon Sep 17 00:00:00 2001 From: phansGithub Date: Fri, 17 Nov 2023 10:30:20 +0000 Subject: [PATCH] Adding libxdp to the ci-cd Signed-off-by: phansGithub --- .github/workflows/public-ci.yml | 42 ++++----------------------------- Makefile | 35 +++++++++++++++------------ README.md | 2 +- 3 files changed, 25 insertions(+), 54 deletions(-) diff --git a/.github/workflows/public-ci.yml b/.github/workflows/public-ci.yml index bc6f072..b4d3b0d 100644 --- a/.github/workflows/public-ci.yml +++ b/.github/workflows/public-ci.yml @@ -40,22 +40,11 @@ jobs: - name: Install libbpf and libxdp run: | - sudo apt update - sudo apt install -y wget build-essential golang - sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf1_1.1.0-1_amd64.deb - sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf-dev_1.1.0-1_amd64.deb - sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp1_1.3.0-2ubuntu2_amd64.deb - sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp-dev_1.3.0-2ubuntu2_amd64.deb - sudo apt install -y ./libbpf1_1.1.0-1_amd64.deb - sudo apt install -y ./libbpf-dev_1.1.0-1_amd64.deb - sudo apt install -y ./libxdp1_1.3.0-2ubuntu2_amd64.deb - sudo apt install -y ./libxdp-dev_1.3.0-2ubuntu2_amd64.deb + make install-xdp sudo apt install -y clang sudo apt install -y llvm sudo apt install -y gcc-multilib - - - + - name: Run build run: make build @@ -70,17 +59,7 @@ jobs: go-version: 1.19 - name: Install libbpf and libxdp - run: | - sudo apt update - sudo apt install -y wget build-essential golang - sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf1_1.1.0-1_amd64.deb - sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf-dev_1.1.0-1_amd64.deb - sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp1_1.3.0-2ubuntu2_amd64.deb - sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp-dev_1.3.0-2ubuntu2_amd64.deb - sudo apt install -y ./libbpf1_1.1.0-1_amd64.deb - sudo apt install -y ./libbpf-dev_1.1.0-1_amd64.deb - sudo apt install -y ./libxdp1_1.3.0-2ubuntu2_amd64.deb - sudo apt install -y ./libxdp-dev_1.3.0-2ubuntu2_amd64.deb + run: make install-xdp - name: Install staticcheck run: go install honnef.co/go/tools/cmd/staticcheck@latest @@ -99,20 +78,7 @@ jobs: go-version: 1.19 - name: Install libbpf and libxdp - run: | - sudo apt update - sudo apt install -y wget build-essential golang - sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf1_1.1.0-1_amd64.deb - sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf-dev_1.1.0-1_amd64.deb - sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp1_1.3.0-2ubuntu2_amd64.deb - sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp-dev_1.3.0-2ubuntu2_amd64.deb - sudo apt install -y ./libbpf1_1.1.0-1_amd64.deb - sudo apt install -y ./libbpf-dev_1.1.0-1_amd64.deb - sudo apt install -y ./libxdp1_1.3.0-2ubuntu2_amd64.deb - sudo apt install -y ./libxdp-dev_1.3.0-2ubuntu2_amd64.deb - sudo apt install -y clang - sudo apt install -y llvm - sudo apt install -y gcc-multilib + run: make install-xdp - name: unit-tests run: make test diff --git a/Makefile b/Makefile index 54be45e..a67c873 100644 --- a/Makefile +++ b/Makefile @@ -85,12 +85,12 @@ podman: ## Build podman image @echo image: - # if $(MAKE) podman; then \ - # echo "Podman build succeeded"; \ - # else \ - # echo "Podman build failed, trying docker.."; \ + if $(MAKE) podman; then \ + echo "Podman build succeeded"; \ + else \ + echo "Podman build failed, trying docker.."; \ $(MAKE) docker; \ - # fi + fi undeploy: ## Undeploy the Deamonset @echo "****** Stop Daemonset ******" @@ -138,19 +138,24 @@ install-xdp: @echo "****** Install libxdp ******" @echo sudo apt update && \ - sudo apt install -y wget build-essential golang && \ - sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf1_1.1.0-1_amd64.deb && \ - sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf-dev_1.1.0-1_amd64.deb && \ - sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp1_1.3.0-2ubuntu2_amd64.deb &&\ - sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp-dev_1.3.0-2ubuntu2_amd64.deb && \ - sudo apt install -y ./libbpf1_1.1.0-1_amd64.deb && \ - sudo apt install -y ./libbpf-dev_1.1.0-1_amd64.deb && \ + sudo apt install -y wget build-essential golang; + @if ! apt list | grep libbpf1; then \ + sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf1_1.1.0-1_amd64.deb && \ + sudo wget http://security.ubuntu.com/ubuntu/pool/main/libb/libbpf/libbpf-dev_1.1.0-1_amd64.deb &&\ + sudo apt install -y ./libbpf1_1.1.0-1_amd64.deb && \ + sudo apt install -y ./libbpf-dev_1.1.0-1_amd64.deb &&\ + rm ./libbpf1_1.1.0-1_amd64.deb && \ + rm ./libbpf-dev_1.1.0-1_amd64.deb; \ + else \ + echo "Libbpf already found, installing libxdp..."; \ + fi + sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp1_1.3.0-2ubuntu2_amd64.deb &&\ + sudo wget https://mirrors.edge.kernel.org/ubuntu/pool/main/x/xdp-tools/libxdp-dev_1.3.0-2ubuntu2_amd64.deb &&\ sudo apt install -y ./libxdp1_1.3.0-2ubuntu2_amd64.deb && \ - sudo apt install -y ./libxdp-dev_1.3.0-2ubuntu2_amd64.deb + sudo apt install -y ./libxdp-dev_1.3.0-2ubuntu2_amd64.deb; @echo @echo "****** Cleanup ******" - rm ./libbpf1_1.1.0-1_amd64.deb && \ - rm ./libbpf-dev_1.1.0-1_amd64.deb && \ + rm ./libxdp1_1.3.0-2ubuntu2_amd64.deb && \ rm ./libxdp-dev_1.3.0-2ubuntu2_amd64.deb @echo diff --git a/README.md b/README.md index f94272c..da58c3b 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ The following prerequisites are required to build and deploy the plugins from so - Compiling the bpf progs for Kind. - Install on Ubuntu: `apt install llvm` - **libxdp** - - Same as Libbpf, to load and uload the XDP program onto the network device. + - Same as Libbpf, to load and unload the XDP program onto the network device. - Installation: `make install-xdp` ### Static analysis, linting and formatting