VPP 2110版本源码编译安装

原文地址:https://www.cnblogs.com/liqinglucky/p/vpp.html

一 介绍

官方文档:VPP/What is VPP? - fd.io

VPP平台是一个提供了交换机/路由器(switch/router)开箱即用(out-of-the-box)产品功能的可拓展框架。由思科 Vector Packet Processing (VPP)技术开源而来。VPP是一个高性能(high performance)数据包处理栈,可以运行在商用(commodity)CPU上。

使用VPP好处是高性能(high performance),实践检验的成熟技术(proven technology),模块化(modularity)和易于扩展(flexibility),以及丰富的功能集(rich feature set)。

VPP技术经过实践检验,已经用于超过数十亿的思科产品上。产品模块化设计,框架允许通过以插件形式新增图节点(graph nodes)作扩展而不需要去改变VPP的核心(core/kernel)代码。

VPP在裸机/虚拟机/容器中的应用:

flowchart TD subgraph Bare-Metal/VM/Container a1[Data Plane Management Agent] a2[Vector Packet Processing] a3[Network IO] a1<-->a2 a2<-->a3 end

二 编译

编译环境

Ubuntu 20.04.4 LTS

编译VPP

官方文档:VPP/Pulling, Building, Running, Hacking and Pushing VPP Code - fd.io

1 下载源码

建议通过clone方式下载。我通过源码包的方式编译过,容易出问题。

git clone https://gerrit.fd.io/r/vpp

切到VPP 2110版本的分支

vpp# git checkout -b stable/2110 --track origin/stable/2110

vpp# ls
build       build-root  docs     extras     LICENSE      Makefile   RELEASE.md  test
build-data  configure   doxygen  INFO.yaml  MAINTAINERS  README.md  src

编译源码

按照官方给的编译命令编译

# vpp 18.10+ (cmake)
make install-dep
make install-ext-deps
make build        # or `make build-release`

2 安装依赖包

vpp# make install-dep
vpp# make install-ext-deps
Removing deb/debian/vpp-ext-deps.substvars
Removing deb/debian/vpp-ext-deps/
make[2]: Leaving directory '/vpp/build/external'
Selecting previously unselected package vpp-ext-deps.
(Reading database ... 196110 files and directories currently installed.)
Preparing to unpack vpp-ext-deps_21.10-8_amd64.deb ...
Unpacking vpp-ext-deps (21.10-8) ...
Setting up vpp-ext-deps (21.10-8) ...
make[1]: Leaving directory '/vpp/build/external'

这一步需要下载dpdk等包会比较久。也可以事先拷贝已下载好的dpdk包放至build/external/downloads目录。

vpp/build/external/downloads# ls
dpdk-21.08.tar.xz    pyelftools-0.29-py2.py3-none-any.whl  setuptools-67.3.2-py3-none-any.whl  wheel-0.38.4-py3-none-any.whl
meson-0.55.0.tar.gz  quicly_0.1.3-vpp.tar.gz               v0.2.tar.gz
nasm-2.14.02.tar.xz  rdma-core-35.0.tar.gz                 v1.0.tar.gz

3 编译

编译参数可以研究vpp/makefile

vpp# make build
-- Configuration:
VPP version         : 21.10.1-3~g08ff7a985
VPP library version : 21.10.1
GIT toplevel dir    : /vpp
Build type          : debug
C flags             :
Linker flags (apps) :
Linker flags (libs) :
Host processor      : x86_64
Target processor    : x86_64
Prefix path         : /opt/vpp/external/x86_64 /vpp/build-root/install-vpp_debug-native/external
Install prefix      : /vpp/build-root/install-vpp_debug-native/vpp
-- Configuring done
-- Generating done
-- Build files have been written to: /vpp/build-root/build-vpp_debug-native/vpp
@@@@ Building vpp in /vpp/build-root/build-vpp_debug-native/vpp @@@@
[2549/2549] Linking C shared library lib/vat2_plugins/wireguard_test_plugin_wireguard_plugin.so
@@@@ Installing vpp @@@@
[0/1] Install the project...
-- Install configuration: "debug"
make[1]: Leaving directory '/vpp/build-root'

生成的bin文件build-root/install-vpp_debug-native/vpp/bin/vpp

4 清除编译文件

vpp# make wipe
make[1]: Entering directory '/vpp/test'
make[1]: Leaving directory '/vpp/test'
make[1]: Entering directory '/vpp/build-root'
@@@@ Wiping build/install external @@@@
@@@@ Wiping build/install vpp @@@@
make[1]: Leaving directory '/vpp/build-root'

遇到的问题

1 依赖包下载失败

下载失败
Downloading https://github.com/vpp-quic/quicly/releases/download/v0.1.3-vpp/quicly_0.1.3-vpp.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:02:00 --:--:--     0
curl: (52) Empty reply from server
make[3]: *** [packages/quicly.mk:47: downloads/quicly_0.1.3-vpp.tar.gz] Error 52
make[3]: Leaving directory '/vpp/build/external'
make[2]: *** [Makefile:160: ebuild-build] Error 2
make[2]: Leaving directory '/vpp/build/external'
make[1]: *** [Makefile:732: external-install] Error 2
make[1]: Leaving directory '/vpp/build-root'
make: *** [Makefile:355: build] Error 2

解决:再次执行make install-ext-deps重新下载或者从其他地方拷贝已经下载好的依赖包到对应目录。

2 dpkg-buildpackage: error: version number does not start with digit

vpp# make install-ext-deps

dpkg-buildpackage: warning:     debian/changelog(l1): version '-0' is invalid: upstream version cannot be empty
LINE: vpp-ext-deps (-0) unstable; urgency=low
dpkg-buildpackage: info: source package vpp-ext-deps
dpkg-buildpackage: info: source version unknown
dpkg-buildpackage: error: version number does not start with digit
make[2]: *** [Makefile:75: vpp-ext-deps_-0_amd64.deb] Error 255
make[2]: Leaving directory '/vpp/build/external'
make[1]: *** [Makefile:82: install-deb] Error 2
make[1]: Leaving directory '/vpp/build/external'
make: *** [Makefile:596: install-ext-deps] Error 2

解决:用源码包解压编译的时候遇到的,改成clone方式下载源码就没出现了。

3 ambiguous argument 'v-rc0..': unknown revision

vpp# make build

//原因是v-rc0的宏定义找不到,可以自己去设置宏但比较麻烦。
fatal: ambiguous argument 'v-rc0..': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: No names found, cannot describe anything.
fatal: ambiguous argument 'v-rc0..': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
fatal: No names found, cannot describe anything.

-- Looking for ccache - found
fatal: No names found, cannot describe anything.
CMake Error at CMakeLists.txt:52 (string):
  string sub-command REPLACE requires at least four arguments.

Prefix path         : /opt/vpp/external/x86_64 /vpp/build-root/install-vpp_debug-native/external
Install prefix      : /vpp/build-root/install-vpp_debug-native/vpp
-- Configuring incomplete, errors occurred!
See also "/vpp/build-root/build-vpp_debug-native/vpp/CMakeFiles/CMakeOutput.log".
See also "/vpp/build-root/build-vpp_debug-native/vpp/CMakeFiles/CMakeError.log".
make[1]: *** [Makefile:644: vpp-configure] Error 1
make[1]: Leaving directory '/vpp/build-root'
make: *** [Makefile:355: build] Error 2

解决:用源码包解压编译的时候遇到的,改成clone方式下载源码就没出现了。

三 运行测试

编译完成后可以运行测试脚本检验

vpp# make test

==============================================================================
DHCPv6 Proxy                                                         14.90 OK
DHCP Client                                                          7.76 OK
DHCP Client w/ VLAN                                                  0.40 OK
DHCPv4 Proxy                                                         23.36 OK

==============================================================================
TEST RESULTS:
                      Scheduled tests: 1482
                       Executed tests: 1482
                         Passed tests: 1288
                        Skipped tests: 141
    Tests skipped due to lack of CPUS: 53

     SOME TESTS WERE SKIPPED BECAUSE THERE ARE NOT ENOUGH CPUS AVAILABLE
==============================================================================

Test run was successful
Killing possible remaining process IDs:  875082 875084
make[1]: Leaving directory '/vpp/test'
posted @ 2023-02-20 16:54  liqinglucky  阅读(1735)  评论(0编辑  收藏  举报