libbpfgo-beginners
libbpfgo-beginners copied to clipboard
config: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found
Hi
I was trying to create a EBPF home lab in a Docker image: my problem is reproducible from the repository https://github.com/elmazzun/ibipief
What I did
I updated the FROM in Dockerfile to ubuntu:22.04
as suggested in https://github.com/lizrice/libbpfgo-beginners/issues/4.
I build the ebpf lab with the following Dockerfile which is the same from this repository besides the base image version:
FROM ubuntu:22.04
# Define variables.
ARG GOVERSION=1.15.15
ARG ARCH=amd64
# Download development environment.
RUN apt update && \
apt install -y \
libbpf-dev \
make \
clang \
llvm \
libelf-dev
# Install Go specific version.
RUN apt install -y wget && \
wget https://golang.org/dl/go${GOVERSION}.linux-${ARCH}.tar.gz && \
tar -xf go${GOVERSION}.linux-${ARCH}.tar.gz && \
mv go/ /usr/local/ && \
ln -s /usr/local/go/bin/go /usr/local/bin/ && \
rm -rf go${GOVERSION}.linux-${ARCH}.tar.gz
# Setup working directory.
RUN mkdir -p /app
WORKDIR /app
# Execute build command.
ENTRYPOINT ["/usr/bin/make", "all"]
This image builds a binary from the following Makefile:
ARCH=$(shell uname -m)
TARGET := ibipief
TARGET_BPF := $(TARGET).bpf.o
GO_SRC := *.go
BPF_SRC := *.bpf.c
LIBBPF_HEADERS := /usr/include/bpf
LIBBPF_OBJ := /usr/lib/$(ARCH)-linux-gnu/libbpf.a
.PHONY: all
all: $(TARGET) $(TARGET_BPF)
go_env := CC=clang CGO_CFLAGS="-I $(LIBBPF_HEADERS)" CGO_LDFLAGS="$(LIBBPF_OBJ)"
$(TARGET): $(GO_SRC)
$(go_env) go build -o $(TARGET)
$(TARGET_BPF): $(BPF_SRC)
clang \
-I /usr/include/$(ARCH)-linux-gnu \
-O2 -c -target bpf \
-o $@ $<
.PHONY: clean
clean:
go clean
The issue
Yet when I run the target binary from Makefile (ibipief
) I get:
➜ ibipief git:(main) ✗ sudo ./ibipief
./ibipief: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./ibipief)
./ibipief: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./ibipief)
Also the go source returns:
➜ ibipief git:(main) ✗ go run ibipief.go
# github.com/aquasecurity/libbpfgo
../../../go/pkg/mod/github.com/aquasecurity/[email protected]/libbpfgo.go:6:10: fatal error: bpf/bpf.h: No such file or directory
6 | #include <bpf/bpf.h>
| ^~~~~~~~~~~
compilation terminated.
My system
My OS:
No LSB modules are available.
Distributor ID: Linuxmint
Description: Linux Mint 20.3
Release: 20.3
Codename: una
5.15.0-67-generic #74~20.04.1-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
My Docker:
Client: Docker Engine - Community
Version: 24.0.2
API version: 1.43
Go version: go1.20.4
Git commit: cb74dfc
Built: Thu May 25 21:52:22 2023
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 24.0.2
API version: 1.43 (minimum version 1.12)
Go version: go1.20.4
Git commit: 659604f
Built: Thu May 25 21:52:22 2023
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: 1.1.7
GitCommit: v1.1.7-0-g860f061
docker-init:
Version: 0.19.0
GitCommit: de40ad0
My Go:
go version go1.19.1 linux/amd64
My target binary:
➜ ibipief git:(main) ✗ go version -m ibipief
ibipief: go1.15.15
path github.com/elmazzun/ibipief
mod github.com/elmazzun/ibipief (devel)
dep github.com/aquasecurity/libbpfgo v0.1.0 h1:14V7ISF45XVqwBre+7NCDByy77OuwFgzDjVR+0JltZ8=
dep golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 h1:hZR0X1kPW+nwyJ9xRxqZk1vx5RUObAPBdKVvXPDUH/E=