Skip to content

Commit

Permalink
Revert "Bumps" (#433)
Browse files Browse the repository at this point in the history
* Revert "chore: code format as clang-format-14"

This reverts commit daeb5d0.

* Revert "chore: bump ubuntu images, go, clang, actions..."

This reverts commit 197df3b.

* Revert "chore: add libzstd-dev to preparation"

This reverts commit 8b68742.

* Revert "fix(build): set required ldflags"

This reverts commit c991672.

* Revert "chore: bump go.mod files"

This reverts commit adfd54f.
  • Loading branch information
geyslan authored May 28, 2024
1 parent daeb5d0 commit 450de10
Show file tree
Hide file tree
Showing 57 changed files with 161 additions and 376 deletions.
11 changes: 6 additions & 5 deletions .github/actions/build-dependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ description: |
inputs:
go-version:
description: go version
default: "1.22.3"
default: "1.21"
runs:
using: composite
steps:
- name: Setup Go
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
uses: actions/setup-go@v5
with:
go-version: "${{ inputs.go-version }}"
- name: Install Compilers & Formatters
Expand All @@ -18,11 +18,12 @@ runs:
sudo apt-get install --yes bsdutils
sudo apt-get install --yes build-essential
sudo apt-get install --yes pkgconf
sudo apt-get install --yes llvm-14 clang-14 clang-format-14
sudo apt-get install --yes llvm-12 clang-12
sudo apt-get install --yes clang-format-12
sudo apt-get install --yes zlib1g-dev libelf-dev
for tool in "clang" "clang-format" "llc" "llvm-strip"
for tool in "clang" "llc" "llvm-strip" "clang-format"
do
sudo rm -f /usr/bin/$tool
sudo ln -s /usr/bin/$tool-14 /usr/bin/$tool
sudo ln -s /usr/bin/$tool-12 /usr/bin/$tool
done
shell: bash
22 changes: 11 additions & 11 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ on:
jobs:
analyze-code:
name: Analyze Code
runs-on: ubuntu-24.04
runs-on: ubuntu-22.04
steps:
- name: Checkout Code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@v4
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
- name: Lint
Expand Down Expand Up @@ -54,13 +54,13 @@ jobs:
shell: bash
libbpfgo-unit-tests:
name: libbpfgo Unit Tests
runs-on: ubuntu-24.04
runs-on: ubuntu-22.04
strategy:
matrix:
go-version: [ '1.21', '1.22', 'stable' ]
go-version: [ 1.18, 1.19, '1.20', '1.21', 'stable' ]
steps:
- name: Checkout Code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@v4
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
Expand All @@ -70,13 +70,13 @@ jobs:
make libbpfgo-static-test
helpers-unit-tests:
name: Helpers Unit Tests
runs-on: ubuntu-24.04
runs-on: ubuntu-22.04
strategy:
matrix:
go-version: [ '1.21', '1.22', 'stable' ]
go-version: [ 1.18, 1.19, '1.20', '1.21', 'stable' ]
steps:
- name: Checkout Code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@v4
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
Expand All @@ -86,13 +86,13 @@ jobs:
make helpers-test-static-run
self-tests:
name: Selftests
runs-on: ubuntu-24.04
runs-on: ubuntu-22.04
strategy:
matrix:
go-version: [ '1.21', '1.22', 'stable' ]
go-version: [ 1.18, 1.19, '1.20', '1.21', 'stable' ]
steps:
- name: Checkout Code
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
uses: actions/checkout@v4
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
Expand Down
10 changes: 4 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ CLANG := clang
CC := $(CLANG)
GO := go
VAGRANT := vagrant
CLANG_FMT := clang-format-14
CLANG_FMT := clang-format-12
GIT := $(shell which git || /bin/false)
REVIVE := revive
PKGCONFIG := pkg-config

HOSTOS = $(shell uname)
ARCH ?= $(shell uname -m | sed 's/x86_64/amd64/g; s/aarch64/arm64/g')
Expand All @@ -34,11 +33,11 @@ LDFLAGS =
# golang

CGO_CFLAGS_STATIC = "-I$(abspath $(OUTPUT))"
CGO_LDFLAGS_STATIC = "$(shell PKG_CONFIG_PATH=$(LIBBPF_OBJDIR) $(PKGCONFIG) --static --libs libbpf)"
CGO_LDFLAGS_STATIC = "-lelf -lz $(LIBBPF_OBJ)"
CGO_EXTLDFLAGS_STATIC = '-w -extldflags "-static"'

CGO_CFLAGS_DYN = "-I. -I/usr/include/"
CGO_LDFLAGS_DYN = "$(shell $(PKGCONFIG) --shared --libs libbpf)"
CGO_LDFLAGS_DYN = "-lelf -lz -lbpf"

# default == shared lib from OS package

Expand Down Expand Up @@ -111,9 +110,8 @@ $(LIBBPF_OBJ): $(LIBBPF_SRC) $(wildcard $(LIBBPF_SRC)/*.[ch]) | $(OUTPUT)/libbpf
$(MAKE) -C $(LIBBPF_SRC) \
BUILD_STATIC_ONLY=1 \
OBJDIR=$(LIBBPF_OBJDIR) \
LIBDIR=$(LIBBPF_OBJDIR) \
DESTDIR=$(LIBBPF_DESTDIR) \
INCLUDEDIR= UAPIDIR= install
INCLUDEDIR= LIBDIR= UAPIDIR= install

$(LIBBPF_SRC):
ifeq ($(wildcard $@), )
Expand Down
4 changes: 2 additions & 2 deletions builder/Vagrantfile-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ VM_SOURCE = "/vagrant"
Vagrant.configure("2") do |config|
case ARCH
when "amd64"
config.vm.box = "bento/ubuntu-24.04"
config.vm.box = "ubuntu/jammy64"
when "arm64"
config.vm.box = "bento/ubuntu-24.04"
config.vm.box = "bento/ubuntu-22.04-arm64"
end

case HOSTOS
Expand Down
22 changes: 5 additions & 17 deletions builder/prepare-ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,9 @@

# variables

[ -z "${GO_VERSION}" ] && GO_VERSION="1.22"
[ -z "${CLANG_VERSION}" ] && CLANG_VERSION="14"
[ -z "${ARCH}" ] && ARCH=$(uname -m)

case "${ARCH}" in
x86_64|amd64)
ARCH="amd64"
;;
aarch64|arm64)
ARCH="arm64"
;;
*)
die "unsupported architecture ${ARCH}"
;;
esac
[ -z "${GO_VERSION}" ] && GO_VERSION="1.21"
[ -z "${CLANG_VERSION}" ] && CLANG_VERSION="12"
[ -z "${ARCH}" ] && ARCH="amd64"


# functions
Expand Down Expand Up @@ -71,7 +59,7 @@ setup_go() {
setup_clang() {
info "Setting Clang ${CLANG_VERSION} as default"

local tools="clang clang-format llc llvm-strip"
local tools="clang llc llvm-strip clang-format"
for tool in ${tools}
do
sudo -E update-alternatives --install "/usr/bin/${tool}" "${tool}" "/usr/bin/${tool}-${CLANG_VERSION}" 100
Expand All @@ -94,7 +82,7 @@ install_pkgs \
llvm-"${CLANG_VERSION}" clang-"${CLANG_VERSION}" clang-format-"${CLANG_VERSION}" \
linux-headers-generic \
linux-tools-generic linux-tools-"$(uname -r)" \
libbpf-dev libelf-dev libzstd-dev zlib1g-dev
zlib1g-dev libelf-dev libbpf-dev

setup_go
setup_clang
Expand Down
9 changes: 5 additions & 4 deletions docs/Vagrantfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

## Boxes

Currently there is one box available in [Vagrantfile-ubuntu](./../builder/Vagrantfile-ubuntu):
Currently there are two boxes available in [Vagrantfile-ubuntu](./../builder/Vagrantfile-ubuntu):

| Box | Providers |
|--------------------------------------------------------------------------|--------------------------|
| [bento/ubuntu-24.04](https://app.vagrantup.com/bento/boxes/ubuntu-24.04) | virtualbox (amd64), parallels (arm64,amd64), ...|
| Box | Providers |
|----------------------------------------------------------------------------------------------|--------------------------|
| [generic/ubuntu2204](https://app.vagrantup.com/generic/boxes/ubuntu2204) (amd64) | virtualbox, parallels |
| [jharoian3/ubuntu-22.04-arm64](https://app.vagrantup.com/jharoian3/boxes/ubuntu-22.04-arm64) | parallels |

It is recommended to use them through the respective [Makefile rules](../Readme.md#contributing) as they are or overriding the `ARCH` environment variable if your architecture and provider allow such virtualization. E.g.: `make vagrant-up ARCH=amd64`.

Expand Down
4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/aquasecurity/libbpfgo

go 1.22.0

toolchain go1.22.3
go 1.21

require github.com/stretchr/testify v1.9.0

Expand Down
4 changes: 1 addition & 3 deletions go.work
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
go 1.22.0

toolchain go1.22.3
go 1.21

use (
.
Expand Down
4 changes: 1 addition & 3 deletions helpers/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module github.com/aquasecurity/libbpfgo/helpers

go 1.22.0

toolchain go1.22.3
go 1.21

require (
github.com/stretchr/testify v1.9.0
Expand Down
14 changes: 4 additions & 10 deletions selftest/attachgenericfd/go.mod
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
module github.com/aquasecurity/libbpfgo/selftest/attachgenericfd

go 1.22.0
go 1.21

toolchain go1.22.3
require github.com/aquasecurity/libbpfgo v0.0.0

require (
github.com/aquasecurity/libbpfgo v0.0.0
golang.org/x/sys v0.20.0
)
require golang.org/x/sys v0.9.0

replace (
github.com/aquasecurity/libbpfgo => ../../
github.com/aquasecurity/libbpfgo/helpers => ../../helpers
)
replace github.com/aquasecurity/libbpfgo => ../../
4 changes: 2 additions & 2 deletions selftest/attachgenericfd/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
9 changes: 2 additions & 7 deletions selftest/cgroup-legacy/go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
module github.com/aquasecurity/libbpfgo/selftest/perfbuffers

go 1.22.0

toolchain go1.22.3
go 1.21

require github.com/aquasecurity/libbpfgo v0.0.0

replace (
github.com/aquasecurity/libbpfgo => ../../
github.com/aquasecurity/libbpfgo/helpers => ../../helpers
)
replace github.com/aquasecurity/libbpfgo => ../../
9 changes: 2 additions & 7 deletions selftest/cgroup/go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
module github.com/aquasecurity/libbpfgo/selftest/perfbuffers

go 1.22.0

toolchain go1.22.3
go 1.21

require github.com/aquasecurity/libbpfgo v0.0.0

replace (
github.com/aquasecurity/libbpfgo => ../../
github.com/aquasecurity/libbpfgo/helpers => ../../helpers
)
replace github.com/aquasecurity/libbpfgo => ../../
9 changes: 2 additions & 7 deletions selftest/common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,18 @@ LIBBPF_OBJ = $(abspath $(OUTPUT)/libbpf.a)
CLANG = clang
CC = $(CLANG)
GO = go
PKGCONFIG = pkg-config

ARCH := $(shell uname -m | sed 's/x86_64/amd64/g; s/aarch64/arm64/g')

# libbpf

LIBBPF_OBJDIR = $(abspath ./$(OUTPUT)/libbpf)

CFLAGS = -g -O2 -Wall -fpie -I$(abspath ../common)
LDFLAGS =

CGO_CFLAGS_STATIC = "-I$(abspath $(OUTPUT)) -I$(abspath ../common)"
CGO_LDFLAGS_STATIC = "$(shell PKG_CONFIG_PATH=$(LIBBPF_OBJDIR) $(PKGCONFIG) --static --libs libbpf)"
CGO_LDFLAGS_STATIC = "-lelf -lz $(LIBBPF_OBJ)"
CGO_EXTLDFLAGS_STATIC = '-w -extldflags "-static"'

CGO_CFLAGS_DYN = "-I. -I/usr/include/"
CGO_LDFLAGS_DYN = "$(shell $(PKGCONFIG) --shared --libs libbpf)"
CGO_LDFLAGS_DYN = "-lelf -lz -lbpf"

MAIN = main

Expand Down
24 changes: 16 additions & 8 deletions selftest/common/vmlinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,13 @@ struct bpf_raw_tracepoint_args {
__u64 args[0];
};

enum {
enum
{
BPF_F_CURRENT_CPU = 4294967295,
};

enum bpf_map_type {
enum bpf_map_type
{
BPF_MAP_TYPE_UNSPEC = 0,
BPF_MAP_TYPE_HASH = 1,
BPF_MAP_TYPE_ARRAY = 2,
Expand Down Expand Up @@ -180,7 +182,8 @@ struct sock_common {

#define ETH_P_IP 0x0800

enum xdp_action {
enum xdp_action
{
XDP_ABORTED = 0,
XDP_DROP = 1,
XDP_PASS = 2,
Expand All @@ -199,7 +202,8 @@ enum xdp_action {
// or, at least, should be, immutable among different kernel versions.
//

enum {
enum
{
TCP_ESTABLISHED = 1,
TCP_SYN_SENT = 2,
TCP_SYN_RECV = 3,
Expand All @@ -215,7 +219,8 @@ enum {
TCP_MAX_STATES = 13,
};

enum sock_type {
enum sock_type
{
SOCK_STREAM = 1,
SOCK_DGRAM = 2,
SOCK_RAW = 3,
Expand All @@ -225,7 +230,8 @@ enum sock_type {
SOCK_PACKET = 10,
};

enum {
enum
{
IPPROTO_IP = 0,
IPPROTO_ICMP = 1,
IPPROTO_IGMP = 2,
Expand Down Expand Up @@ -256,7 +262,8 @@ enum {
IPPROTO_MAX = 263,
};

enum {
enum
{
TCPF_ESTABLISHED = 2,
TCPF_SYN_SENT = 4,
TCPF_FIN_WAIT1 = 16,
Expand Down Expand Up @@ -309,7 +316,8 @@ struct __sk_buff {
__u32 gso_size;
};

enum bpf_hdr_start_off {
enum bpf_hdr_start_off
{
BPF_HDR_START_MAC = 0,
BPF_HDR_START_NET = 1,
};
Expand Down
Loading

0 comments on commit 450de10

Please sign in to comment.