eBPF:默认的bpf程序/地图?

By simon at 2018-02-07 • 0人收藏 • 59人看过

我正面临bpf的最新net-next的奇怪行为 核心。启用所有BPF内核选项(包括泸定9

# ./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
#
)和 没有9bpf程序加载,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
#
这是w该计划包含:
# ./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的话 内核,显示出来? 这发生在机器启动之后。该只有区别 这个系统和另一个(运行相同的内核和选项,以及我在哪里 不要用mult看到这个问题iple cgroup
skb程序)的存在 /sys/fs/cgroup/unified cgroup2 FS。我不知道这是否与我的问题有关,但是我 别知道如何禁用/sys/fs/cgroup/unified,不允许卸载。

1 个回复 | 最后更新于 2018-02-07
2018-02-07   #1

正如Qeole怀疑的那样,这是来自systemd,特别是systemd v235引入了IP访问控制eBPF功能两个配置选项 公开的,IPAddressDeny和IPAddressAllow。 (我不知道是否有可能 在编译时禁用它)。

登录后方可回帖

Loading...