VPP编译安装及测试

参考:FD.io VPP环境下运行用户应用程序教程

环境

  1. 操作系统:centos7.4,且需要联网
  2. VPP版本:2009
  3. 网卡:10G

VPP编译

  1. 使用git clone VPP项目指定分支的代码(注意:不要使用VPP的release版本包,否则编译会有问题)
bash 复制代码
git clone -b stables/2009 https://github.com/FDio/vpp.git
  1. 添加yum源:epel、centos-release-scl、centos-release-scl-rh源
bash 复制代码
yum install epel-release
yum install centos-release-scl centos-release-scl-rh
#安装完成后在/etc/yum.repos.d/目录下会有相应的源文件
yum clean all
yum makecache		#重新生成缓存
  1. 编译vpp代码(会自动编译dpdk)
bash 复制代码
cd vpp
make 					#可查看支持的选项和说明
make install-deps		#安装vpp依赖
make install-ext-deps	#安装vpp额外的依赖,像dpdk

#编译的结果在build-root目录下
make build-release		#编译成可执行文件
或
make pkg-rpm			#编译成rpm包,然后使用rpm -i *.rpm安装

运行VPP

  1. 使用dpdk接管网卡
bash 复制代码
modprobe uio_pci_generic		#linux内核加载uio_pci_generic驱动
./dpdk-devbind -s 				#查看网卡使用的驱动
ifconfig p3p2 0 up				#去掉待接管网卡的ip,否则绑定驱动可能会失败
./dpdk-devbind -b uio_pci_generic 0000:5e:00.1		#网卡绑定dpdk兼容的驱动

下图是绑定成功后结果

  1. 修改vpp配置文件starup.conf。vpp配置项说明
bash 复制代码
unix {
        nodaemon
        gid vpp
        cli-listen /run/vpp/cli.sock
        #vpp启动后执行的命令
        startup-config /etc/vpp/interface.txt
}
#去掉seesison会导致vcl异常,报-108不支持的应用配置
session { evt_qs_memfd_seg  }

#与vcl.conf中的socket名字对应
socksvr { socket-name /tmp/vpp-api.sock}

api-trace { on }

#cpu中的workers和调度策略会影响vcl是否会卡死
cpu {
        main-core 1
        workers 3
        scheduler-policy idle
        #scheduler-priority 50
        thread-prefix vpp
}

buffers {
        buffers-per-numa 128000
}

dpdk {
        log-level debug

        dev 0000:5e:00.1 {
                name eth1
        }
        no-multi-seg
        dev default {
                num-rx-queues 1
                num-tx-queues 1
                num-rx-desc 1024
        }
        #uio_pci_generic, igb_uio, vfio-pci,default is auto
        #uio-driver vfio-pci
        
        # socket-mem 2048,2048
        no-tx-checksum-offload
}

plugins {
        ## Adjusting the plugin path depending on where the VPP plugins are
        path /root/install-vpp-native/vpp/lib/vpp_plugins

        ## Disable all plugins by default and then selectively enable specific plugins
         plugin default { disable }
         plugin dpdk_plugin.so { enable }
         plugin acl_plugin.so { enable }

        ## Enable all plugins by default and then selectively disable specific plugins
        # plugin dpdk_plugin.so { disable }
        # plugin acl_plugin.so { disable }
 }
  1. 设置VPP启动后执行的命令,修改/etc/vpp/interface.txt如下:
bash 复制代码
#启动网卡
set interface state eth1 up
#设置网卡ip
set interface ip address eth1 172.20.10.38/24
  1. 启动VPP
bash 复制代码
./vpp -c /etc/vpp/startup.conf
  1. 另起一个终端,进入VPP控制界面
bash 复制代码
./vppctl
#控制界面常用的命令:
show int addr		#显示网卡ip
show int			#显示网卡
ip route add 10.170.7.0/24 via 10.170.7.254		#添加路由

基于VCL测试

说明:VPP网络和内核网络是独立的(不通的),有两套路由和网络

VCL:VPP Communication Library,VCL可以在不修改应用的情况下,使应用访问VPP网络。

测试环境:主机1(172.20.10.37/24) 和 主机2(172.20.10.38/24)各使用VPP接管10G网卡,两网卡通过光纤直连。(注:上述ip是在VPP网络下的)

  1. 修改vcl配置文件/etc/vpp/vcl.conf,内容如下:
bash 复制代码
vcl {
    rx-fifo-size 4000000
    tx-fifo-size 4000000
    app-scope-local
    app-scope-global
    api-socket-name /tmp/vpp-api.sock
    use-mq-eventfd
}
  1. 设置VCL相关的环境变量(设置完毕后,该终端就接入VPP网络了)
bash 复制代码
export VCL_CONFIG=/etc/vpp/vcl.conf
export LD_PRELOAD=/root/install-vpp-native/vpp/lib/libvcl_ldpreload.so
  1. 使用iperf3进行测试(两终端均需接入VPP网络,连接时需要使用VPP网络下的ip)
bash 复制代码
#在主机2执行下述命令启动服务端
iperf3 -s --bind 172.20.10.38

#在主机1执行下述命令启动客户端进行连接
iperf3 -c 172.20.10.38 --bind 172.20.10.37
  1. 测试结果:

客户端:

服务端:

相关推荐
木古古181 小时前
搞一个高效的c/c++开发环境,工具VIm+自研vim插件+Shell脚本
linux·编辑器·vim
茫忙然2 小时前
U 盘搭建免驱 Linux 便携系统教程
linux·服务器
一起逃去看海吧3 小时前
dify-03
java·linux·开发语言
fengyehongWorld3 小时前
Linux 根据端口进行的相关查询
linux
lihao lihao3 小时前
linux匿名管道
linux·运维·服务器
うちは止水3 小时前
weston出图调试
linux·wayland·weston
STDD3 小时前
Farming Simulator 25(模拟农场 25) Linux 专服搭建完全指南
linux·运维·javascript
好好风格3 小时前
宝塔面板 HTTPS 端口证书不生效排查记录
linux·运维·nginx
用户2367829801684 小时前
Linux pgrep 命令详解:按名称查找进程 PID 的高效方法
linux