我正面临着bpf
最新net-next
内核的奇怪行为。在启用所有 BPF 内核选项(包括CONFIG_BPF_JIT_ALWAYS_ON
)且未加载任何 bpf
程序的情况下,bpftool
报告以下内容:
# ./bpftool prog show
2: cgroup_skb tag 7be49e3934a125ba
loaded_at Feb 05/10:17 uid 0
xlated 296B jited 229B memlock 4096B map_ids 2,3
3: cgroup_skb tag 2a142ef67aaad174
loaded_at Feb 05/10:17 uid 0
xlated 296B jited 229B memlock 4096B map_ids 2,3
4: cgroup_skb tag 7be49e3934a125ba
loaded_at Feb 05/10:17 uid 0
xlated 296B jited 229B memlock 4096B map_ids 4,5
5: cgroup_skb tag 2a142ef67aaad174
loaded_at Feb 05/10:17 uid 0
xlated 296B jited 229B memlock 4096B map_ids 4,5
6: cgroup_skb tag 7be49e3934a125ba
loaded_at Feb 05/10:17 uid 0
xlated 296B jited 229B memlock 4096B map_ids 6,7
7: cgroup_skb tag 2a142ef67aaad174
loaded_at Feb 05/10:17 uid 0
xlated 296B jited 229B memlock 4096B map_ids 6,7
#
# ./bpftool map show
2: lpm_trie flags 0x1
key 8B value 8B max_entries 1 memlock 4096B
3: lpm_trie flags 0x1
key 20B value 8B max_entries 1 memlock 4096B
4: lpm_trie flags 0x1
key 8B value 8B max_entries 1 memlock 4096B
5: lpm_trie flags 0x1
key 20B value 8B max_entries 1 memlock 4096B
6: lpm_trie flags 0x1
key 8B value 8B max_entries 1 memlock 4096B
7: lpm_trie flags 0x1
key 20B value 8B max_entries 1 memlock 4096B
#
这是程序包含的内容:
# ./bpftool prog dump xlated id 2
0: (bf) r6 = r1
1: (69) r7 = *(u16 *)(r6 +192)
2: (b4) (u32) r8 = (u32) 0
3: (55) if r7 != 0x8 goto pc+14
4: (bf) r1 = r6
5: (b4) (u32) r2 = (u32) 16
6: (bf) r3 = r10
7: (07) r3 += -4
8: (b4) (u32) r4 = (u32) 4
9: (85) call bpf_skb_load_bytes#6169312
10: (18) r1 = map[id:2]
12: (bf) r2 = r10
13: (07) r2 += -8
14: (62) *(u32 *)(r2 +0) = 32
15: (85) call bpf_map_lookup_elem#73712
16: (15) if r0 == 0x0 goto pc+1
17: (44) (u32) r8 |= (u32) 2
18: (55) if r7 != 0xdd86 goto pc+14
19: (bf) r1 = r6
20: (b4) (u32) r2 = (u32) 24
21: (bf) r3 = r10
22: (07) r3 += -16
23: (b4) (u32) r4 = (u32) 16
24: (85) call bpf_skb_load_bytes#6169312
25: (18) r1 = map[id:3]
27: (bf) r2 = r10
28: (07) r2 += -20
29: (62) *(u32 *)(r2 +0) = 128
30: (85) call bpf_map_lookup_elem#73712
31: (15) if r0 == 0x0 goto pc+1
32: (44) (u32) r8 |= (u32) 2
33: (b7) r0 = 1
34: (55) if r8 != 0x2 goto pc+1
35: (b7) r0 = 0
36: (95) exit
#
有趣的是我没有eBPF
明确加载任何程序。我想知道内核中现在是否有一个默认的eBPF
blob 显示出来?
这发生在机器启动后。这个系统和另一个系统之间的唯一区别(运行相同的内核和选项,我没有看到多个 cgroup_skb 程序的这个问题)是/sys/fs/cgroup/unified
cgroup2 FS 的存在。我不知道这是否与我的问题有关,但我不知道如何禁用/sys/fs/cgroup/unified
,不允许卸载。