Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bumps #431

Merged
merged 5 commits into from
May 24, 2024
Merged

Bumps #431

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 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.21"
default: "1.22.3"
runs:
using: composite
steps:
- name: Setup Go
uses: actions/setup-go@v5
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: "${{ inputs.go-version }}"
- name: Install Compilers & Formatters
Expand All @@ -18,12 +18,11 @@ 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-12 clang-12
sudo apt-get install --yes clang-format-12
sudo apt-get install --yes llvm-14 clang-14 clang-format-14
sudo apt-get install --yes zlib1g-dev libelf-dev
for tool in "clang" "llc" "llvm-strip" "clang-format"
for tool in "clang" "clang-format" "llc" "llvm-strip"
do
sudo rm -f /usr/bin/$tool
sudo ln -s /usr/bin/$tool-12 /usr/bin/$tool
sudo ln -s /usr/bin/$tool-14 /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-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- 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-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
go-version: [ 1.18, 1.19, '1.20', '1.21', 'stable' ]
go-version: [ '1.21', '1.22', 'stable' ]
geyslan marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- 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-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
go-version: [ 1.18, 1.19, '1.20', '1.21', 'stable' ]
go-version: [ '1.21', '1.22', 'stable' ]
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- 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-22.04
runs-on: ubuntu-24.04
strategy:
matrix:
go-version: [ 1.18, 1.19, '1.20', '1.21', 'stable' ]
go-version: [ '1.21', '1.22', 'stable' ]
steps:
- name: Checkout Code
uses: actions/checkout@v4
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
- name: Install Dependencies
uses: ./.github/actions/build-dependencies
with:
Expand Down
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ CLANG := clang
CC := $(CLANG)
GO := go
VAGRANT := vagrant
CLANG_FMT := clang-format-12
CLANG_FMT := clang-format-14
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 @@ -33,11 +34,11 @@ LDFLAGS =
# golang

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

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

# default == shared lib from OS package

Expand Down Expand Up @@ -110,8 +111,9 @@ $(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= LIBDIR= UAPIDIR= install
INCLUDEDIR= 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 = "ubuntu/jammy64"
config.vm.box = "bento/ubuntu-24.04"
when "arm64"
config.vm.box = "bento/ubuntu-22.04-arm64"
config.vm.box = "bento/ubuntu-24.04"
end

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

# variables

[ -z "${GO_VERSION}" ] && GO_VERSION="1.21"
[ -z "${CLANG_VERSION}" ] && CLANG_VERSION="12"
[ -z "${ARCH}" ] && ARCH="amd64"
[ -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
geyslan marked this conversation as resolved.
Show resolved Hide resolved


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

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

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

## Boxes

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

| 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 |
| Box | Providers |
|--------------------------------------------------------------------------|--------------------------|
| [bento/ubuntu-24.04](https://app.vagrantup.com/bento/boxes/ubuntu-24.04) | virtualbox (amd64), parallels (arm64,amd64), ...|

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: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/aquasecurity/libbpfgo

go 1.21
go 1.22.0

This comment was marked as resolved.

This comment was marked as outdated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are not supposed to dictate what go version is necessary for the consumers unless it's actually necessary:

No matter how good the latest Go version is, if it's not a requirement, you are not supposed to force it. You set the minimum supported Go version instead. Go supports two major releases at any time and it seems reasonable to do at least the same thing.

People with patched go versions might not have an ability to upgrade to the latest release.

I don't think there's a good reason to set toolchain for a library ever.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're absolutely right. I'm going to revert (soon) this PR by splitting the fix and other chores into their own PRs. 👍🏼

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I appreciate it.


toolchain go1.22.3

require github.com/stretchr/testify v1.9.0

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

toolchain go1.22.3

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

go 1.21
go 1.22.0

toolchain go1.22.3

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

go 1.21
go 1.22.0

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

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

replace github.com/aquasecurity/libbpfgo => ../../
replace (
github.com/aquasecurity/libbpfgo => ../../
github.com/aquasecurity/libbpfgo/helpers => ../../helpers
)
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.9.0 h1:KS/R3tvhPqvJvwcKfnBHJwwthS11LRhmM5D59eEXa0s=
golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
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: 7 additions & 2 deletions selftest/cgroup-legacy/go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
module github.com/aquasecurity/libbpfgo/selftest/perfbuffers

go 1.21
go 1.22.0

toolchain go1.22.3

require github.com/aquasecurity/libbpfgo v0.0.0

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

go 1.21
go 1.22.0

toolchain go1.22.3

require github.com/aquasecurity/libbpfgo v0.0.0

replace github.com/aquasecurity/libbpfgo => ../../
replace (
github.com/aquasecurity/libbpfgo => ../../
github.com/aquasecurity/libbpfgo/helpers => ../../helpers
)
9 changes: 7 additions & 2 deletions selftest/common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ 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 = "-lelf -lz $(LIBBPF_OBJ)"
CGO_LDFLAGS_STATIC = "$(shell PKG_CONFIG_PATH=$(LIBBPF_OBJDIR) $(PKGCONFIG) --static --libs libbpf)"
CGO_EXTLDFLAGS_STATIC = '-w -extldflags "-static"'

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

MAIN = main

Expand Down
24 changes: 8 additions & 16 deletions selftest/common/vmlinux.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,11 @@ 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 @@ -182,8 +180,7 @@ 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 @@ -202,8 +199,7 @@ 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 @@ -219,8 +215,7 @@ enum
TCP_MAX_STATES = 13,
};

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

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

enum
{
enum {
TCPF_ESTABLISHED = 2,
TCPF_SYN_SENT = 4,
TCPF_FIN_WAIT1 = 16,
Expand Down Expand Up @@ -316,8 +309,7 @@ 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