Ubuntu 23.04 已在 4 月 20 日发布,可以到官网下载镜像安装到虚拟机,用来学习 eBPF。

使用的内核版本是 6.2.0-20-generic

Ubuntu 23.04 的相关信息如下:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 23.04
Release:    23.04
Codename:   lunar
# uname -a
Linux xxx 6.2.0-20-generic #20-Ubuntu SMP PREEMPT_DYNAMIC Thu Apr  6 07:48:48 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
# cat /boot/config-6.2.0-20-generic|grep BPF
CONFIG_BPF=y
CONFIG_HAVE_EBPF_JIT=y
CONFIG_ARCH_WANT_DEFAULT_BPF_JIT=y
# BPF subsystem
CONFIG_BPF_SYSCALL=y
CONFIG_BPF_JIT=y
CONFIG_BPF_JIT_ALWAYS_ON=y
CONFIG_BPF_JIT_DEFAULT_ON=y
CONFIG_BPF_UNPRIV_DEFAULT_OFF=y
# CONFIG_BPF_PRELOAD is not set
CONFIG_BPF_LSM=y
# end of BPF subsystem
CONFIG_CGROUP_BPF=y
CONFIG_IPV6_SEG6_BPF=y
CONFIG_NETFILTER_XT_MATCH_BPF=m
CONFIG_BPFILTER=y
CONFIG_BPFILTER_UMH=m
CONFIG_NET_CLS_BPF=m
CONFIG_NET_ACT_BPF=m
CONFIG_BPF_STREAM_PARSER=y
CONFIG_LWTUNNEL_BPF=y
CONFIG_BPF_EVENTS=y
CONFIG_BPF_KPROBE_OVERRIDE=y
CONFIG_TEST_BPF=m
# cat /boot/config-6.2.0-20-generic|grep BTF
CONFIG_VIDEO_SONY_BTF_MPX=m
CONFIG_DEBUG_INFO_BTF=y
CONFIG_PAHOLE_HAS_SPLIT_BTF=y
CONFIG_DEBUG_INFO_BTF_MODULES=y
# CONFIG_MODULE_ALLOW_BTF_MISMATCH is not set

安装虚拟机后,需要安装一些必要的软件:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
apt install -y \
    git \
    wget \
    inetutils-ping \
    gcc \
    make \
    perl \
    bzip2 \
    tar \
    zsh \
    locales \
    autojump \
    bpftrace \
    llvm-15 \
    clang-15

GOVERSION="1.20.5"
wget https://go.dev/dl/go${GOVERSION}.linux-amd64.tar.gz && \
    tar -xzf go${GOVERSION}.linux-amd64.tar.gz -C /usr/local && \
    ln -s /usr/local/go/bin/go /usr/local/bin/go && \
    go version

export PATH="/usr/lib/llvm-15/bin:$PATH"
# echo "export PATH=\"/usr/lib/llvm-15/bin:\$PATH\"" >> ~/.zshrc
# echo "export PATH=\"/usr/lib/llvm-15/bin:\$PATH\"" >> ~/.bashrc

localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8

# disable unattended-upgrades
dpkg-reconfigure unattended-upgrades
apt remove -y unattended-upgrades