1.安装依赖环境
yum install gcc make python-devel openssl-devel graphviz autoconf automake rpm-build redhat-rpm-config libtool
2.下载 kernel 源码:
yum install "kernel-devel-uname-r == $(uname -r)"
3.创建rpmbuild目录结构
mkdir rpmbuild/{BUILD,SOURCES,SPECS,RPMS,BUILDROOT} -pv
4.下载源码,解压,编译
cp openvswitch-2.9.2.tar.gz rpmbuild/SOURCES/
tar -xvf openvswitch-2.9.2.tar.gz
cp openvswitch-2.9.2/rhel/openvswitch.spec rpmbuild/SPECS/
cp openvswitch-2.9.2/rhel/openvswitch-kmod-rhel6.spec rpmbuild/SPECS/
5.编译Open vSwitch 2.9.2 用户态模块
rpmbuild -bb rpmbuild/SPECS/openvswitch.spec --nocheck
6.编译Open vSwitch 2.9.2 内核态模块
rpmbuild -bb rpmbuild/SPECS/openvswitch-kmod-rhel6.spec
DPDK编译:
cd dpdk-18.02 && make install T=x86_64-native-linuxapp-gcc DESTDIR=.
openvswitch.spec 配置更改:
# 增加dpdk的选项
%build
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=%{_localstatedir} \
--libdir=%{_libdir} --enable-ssl --with-dpdk=/root/dpdk-18.02
# 修改libdir文件安装
%{_libdir}/lib*.so.*
%{_libdir}/lib*.so
这两行改成:
%{_libdir}/*
# ovs 初始化
ovs-vsctl --no-wait init
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-init=true
ovs-vsctl --no-wait set Open_vSwitch . other_config:dpdk-socket-mem="1024,0"
ovs-vsctl --no-wait set Open_vSwitch . other_config:pmd-cpu-mask=0xf
ovs-vsctl add-br br-int -- set bridge br-int datapath_type=netdev
ovs-vsctl add-port br-int vhostuser0 -- set Interface vhostuser0 type=dpdkvhostuserclient options:vhost-server-path="/var/run/openvswitch/vhostuser0"
ovs-vsctl add-port br-int vhostuser1 -- set Interface vhostuser1 type=dpdkvhostuserclient options:vhost-server-path="/var/run/openvswitch/vhostuser1"