我面临着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
,不允许卸载。
答案 0 :(得分:1)
正如Qeole所怀疑的那样,这是来自systemd,特别是systemd v235引入了IP访问控制eBPF功能,其中公开了两个配置选项,IPAddressDeny和IPAddressAllow。 (我不知道是否可以在编译时禁用它。)