1. ENV
    2. Ubuntu 20.04:
    3. root@bpf1:~# lsb_release -a
    4. No LSB modules are available.
    5. Distributor ID: Ubuntu
    6. Description: Ubuntu 20.04.3 LTS
    7. Release: 20.04
    8. Codename: focal
    9. root@bpf1:~# uname -a
    10. Linux bpf1 5.11.0-051100-generic #202102142330 SMP Sun Feb 14 23:33:21 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
    11. root@bpf1:~#
    12. 使用apt install安装的时候,通常不一定能符合我们的需求,所以需要安装对应的版本,以下内容均是为cilium pwru的项目准备。
    13. https://github.com/cilium/pwru
    14. Go >= 1.16
    15. LLVM/clang >= 1.12
    16. 1.Go安装:
    17. 登录Go官网,选择对应的需要的版本下载,这里以1.17.6为例:
    18. wget https://go.dev/dl/go1.17.6.linux-amd64.tar.gz
    19. tar -xvf go1.17.6.linux-amd64.tar.gz
    20. mv go /usr/local/
    21. vi ~/.profile # add export PATH=$PATH:/usr/local/go/bin
    22. source ~/.profile
    23. root@bpf1:~# go version
    24. go version go1.17.6 linux/amd64
    25. root@bpf1:~#
    26. 2.LLVM clang安装:
    27. https://zhuanlan.zhihu.com/p/102028114
    28. sudo mkdir -p /usr/local
    29. cd /usr/local
    30. sudo wget https://github.com/llvm/llvm-project/releases/download/llvmorg-13.0.0/clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
    31. sudo tar xvf clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04.tar.xz
    32. sudo mv clang+llvm-13.0.0-x86_64-linux-gnu-ubuntu-20.04 llvm
    33. export PATH="$PATH:/usr/local/llvm/bin"
    34. root@bpf1:~/pwru# clang --version
    35. clang version 13.0.0 (https://github.com/llvm/llvm-project/ 24c8eaec9467b2aaf70b0db33a4e4dd415139a50)
    36. Target: x86_64-unknown-linux-gnu
    37. Thread model: posix
    38. InstalledDir: /usr/local/llvm/bin
    39. root@bpf1:~/pwru#

    具体参考https://github.com/cilium/pwru/issues/46。

    然后:再重新build一下pwru。[当前版本:v0.0.3]

    root@bpf1:~/pwru# ./pwru -h Usage of ./pwru: —filter-dst-ip string filter destination IP addr —filter-dst-port uint16 filter destination port —filter-func string filter kernel functions to be probed by name (exact match, supports RE2 regular expression) —filter-mark uint32 filter skb mark —filter-netns uint32 filter netns inode —filter-proto string filter L4 protocol (tcp, udp, icmp, icmp6) —filter-src-ip string filter source IP addr —filter-src-port uint16 filter source port —output-limit-lines uint exit the program after the number of events has been received/printed —output-meta print skb metadata —output-relative-timestamp print relative timestamp per skb —output-skb print skb —output-stack print stack —output-tuple print L4 tuple —version show pwru version and exit pflag: help requested root@bpf1:~/pwru# ``` 20221012-LLVM clang Go ENV Prepare - 图1