0、环境准备
操作系统:CentOS 7.3.1611
yum -y install rpm-build redhat-rpm-config asciidoc bison hmaccalc patchutils perl-ExtUtils-Embed pesign xmlto audit-libs-devel binutils-devel elfutils-devel elfutils-libelf-devel ncurses-devel newt-devel numactl-devel pciutils-devel python-devel zlib-devel git wget
1、确认内核版本
uname -a
3.10.0-514.26.1.el7.x86_64
2、下载netmap
git clone https://github.com/luigirizzo/netmap.git
3、下载内核源码(以普通用户下载)
useradd wxx passwd wxx su wxx mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS} echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros rpm -i http://vault.centos.org/7.3.1611/updates/Source/SPackages//kernel-3.10.0-514.26.1.el7.src.rpm 2>&1 | grep -v exist cd ~/rpmbuild/SPECS rpmbuild -bp --nodeps --target=$(uname -m) kernel.spec
4、辅助操作
su root mv /home/wxx/rpmbuild/BUILD/kernel-3.10.0-514.26.1.el7/linux-3.10.0-514.26.1.el7.x86_64 /usr/src/kernels/
5、下载缺失的Module.symvers文件
mkdir temp cd temp wget ftp://mirror.switch.ch/pool/4/mirror/scientificlinux/7.0/x86_64/updates/security/kernel-devel-3.10.0-514.26.1.el7.x86_64.rpm rpm2cpio kernel-devel-3.10.0-514.26.1.el7.x86_64.rpm > test.cpio cpio -i --make-directories < test.cpio cp usr/src/kernels/3.10.0-514.26.1.el7.x86_64/Module.symvers /usr/src/kernels/linux-3.10.0-514.26.1.el7.x86_64
6、编译netmap
cd /root/projects/netmap/LINUX ./configure --kernel-sources=/usr/src/kernels/linux-3.10.0-514.26.1.el7.x86_64 --kernel-dir=/usr/src/kernels/linux-3.10.0-514.26.1.el7.x86_64
如果报错,按照提示操作
cd /usr/src/kernels/linux-3.10.0-514.26.1.el7.x86_64 make oldconfig make modules_prepare cd - ./configure --kernel-sources=/usr/src/kernels/linux-3.10.0-514.26.1.el7.x86_64 --kernel-dir=/usr/src/kernels/linux-3.10.0-514.26.1.el7.x86_64编译
make
7、替换原来的网卡驱动
rmmod e1000 insmod netmap.ko insmod e1000/e1000.ko lsmod | grep e1000
8、测试
cd /root/projects/netmap/LINUX/build-apps/pkt-gen收包测试(ens33就是网卡的名字,同eth0):
./pkt-gen -i ens33 -f rx发包测试:
./pkt-gen -i ens33 -f tx -l 64原文链接:https://www.f2er.com/centos/375982.html