DPDK pktgen package issuing tool used
git clone git://dpdk.org/apps/pktgen-dpdk
cd pktgen-dpdk
make
Compile the method
DPDK compilation and example compilation Application compilation
[root@localhost pktgen-dpdk]# make
>>> Use 'make help' for more commands\n
./tools/pktgen-build.sh build
>>> lua_enabled : '-Denable_lua=false'
>>> gui_enabled : '-Denable_gui=false'
>>> SDK Directory : '/tmp/pktgen-dpdk'
>>> Build Directory : '/tmp/pktgen-dpdk/Builddir'
>>> Target Directory : '/tmp/pktgen-dpdk/usr'
>>> Ninja build in '/tmp/pktgen-dpdk/Builddir' buildtype='release'
meson -Dbuildtype=release -Denable_lua=false -Denable_gui=false Builddir
./tools/pktgen-build.sh: line 43: meson: command not found
./tools/pktgen-build.sh: line 53: ninja: command not found
Prompt error, install meson and ninja
[root@localhost pktgen-dpdk]# make
>>> Use 'make help' for more commands\n
./tools/pktgen-build.sh build
>>> lua_enabled : '-Denable_lua=false'
>>> gui_enabled : '-Denable_gui=false'
>>> SDK Directory : '/tmp/pktgen-dpdk'
>>> Build Directory : '/tmp/pktgen-dpdk/Builddir'
>>> Target Directory : '/tmp/pktgen-dpdk/usr'
>>> Ninja build in '/tmp/pktgen-dpdk/Builddir' buildtype='release'
meson -Dbuildtype=release -Denable_lua=false -Denable_gui=false Builddir
The Meson build system
Version: 0.55.1
Source dir: /tmp/pktgen-dpdk
Build dir: /tmp/pktgen-dpdk/Builddir
Build type: native build
Program cat found: YES
Project name: pktgen
Project version: 21.11.0
C compiler for the host machine: cc (gcc 4.8.5 "cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)")
C linker for the host machine: cc ld.bfd 2.27-44
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -mavx: YES
Compiler for C supports arguments -mavx2: YES
Compiler for C supports arguments -Wno-pedantic -Wpedantic: YES
Compiler for C supports arguments -Wno-format-truncation -Wformat-truncation: NO
Found pkg-config: /usr/bin/pkg-config (0.27.1)
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency libdpdk found: NO (tried pkgconfig)
meson.build:62:0: ERROR: Dependency "libdpdk" not found, tried pkgconfig
A full log can be found at /tmp/pktgen-dpdk/Builddir/meson-logs/meson-log.txt
ninja: Entering directory `/tmp/pktgen-dpdk/Builddir'
ninja: error: loading 'build.ninja': No such file or directory
make: *** [build] Error 1
After installing cmake
[root@localhost pktgen-dpdk]# make
>>> Use 'make help' for more commands\n
./tools/pktgen-build.sh build
>>> lua_enabled : '-Denable_lua=false'
>>> gui_enabled : '-Denable_gui=false'
>>> SDK Directory : '/tmp/pktgen-dpdk'
>>> Build Directory : '/tmp/pktgen-dpdk/Builddir'
>>> Target Directory : '/tmp/pktgen-dpdk/usr'
>>> Ninja build in '/tmp/pktgen-dpdk/Builddir' buildtype='release'
meson -Dbuildtype=release -Denable_lua=false -Denable_gui=false Builddir
The Meson build system
Version: 0.55.1
Source dir: /tmp/pktgen-dpdk
Build dir: /tmp/pktgen-dpdk/Builddir
Build type: native build
Program cat found: YES
Project name: pktgen
Project version: 21.11.0
C compiler for the host machine: cc (gcc 4.8.5 "cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)")
C linker for the host machine: cc ld.bfd 2.27-44
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -mavx: YES
Compiler for C supports arguments -mavx2: YES
Compiler for C supports arguments -Wno-pedantic -Wpedantic: YES
Compiler for C supports arguments -Wno-format-truncation -Wformat-truncation: NO
Found pkg-config: /usr/bin/pkg-config (0.27.1)
Found CMake: /usr/bin/cmake (2.8.12.2)
WARNING: The version of CMake /usr/bin/cmake is 2.8.12.2 but version >=3.4 is required
Run-time dependency libdpdk found: NO (tried pkgconfig)
meson.build:62:0: ERROR: Dependency "libdpdk" not found, tried pkgconfig
A full log can be found at /tmp/pktgen-dpdk/Builddir/meson-logs/meson-log.txt
ninja: Entering directory `/tmp/pktgen-dpdk/Builddir'
Hint libdpdk found: NO (tried pkgconfig) not found
This version corresponds to the latest DPDK version, re-download the old version
在地址下载pktgen:http://git.dpdk.org/apps/pktgen-dpdk/refs/ 用此地址下载
一般情况选取最新版本,对应dpdk的最新版本
Download the compilation
[root@localhost tmp]# wget http://git.dpdk.org/apps/pktgen-dpdk/snapshot/pktgen-dpdk-pktgen-3.7.2.tar.gz
--2022-01-15 17:08:34-- http://git.dpdk.org/apps/pktgen-dpdk/snapshot/pktgen-dpdk-pktgen-3.7.2.tar.gz
make
== lua
"Lua pkg-config file was not found"
"Get lua-5.3 from lua.org and build it on your system"
"Also install lua 5.3 into /usr/local/include and /usr/local/lib"
"Make sure the library in /usr/local/lib is called liblua.a"
"Lua pkg-config file was not found"
Compilation tips If you have lua, install the lua library
yum install lua-devel
Prompt again
[root@localhost pktgen-dpdk-pktgen-3.7.2]# make
== lib
== common
cat: /tmp/pktgen-dpdk-pktgen-3.7.2/lib/common/ABI_VERSION: No such file or directory
== plugin
cat: /tmp/pktgen-dpdk-pktgen-3.7.2/lib/plugin/ABI_VERSION: No such file or directory
== utils
cat: /tmp/pktgen-dpdk-pktgen-3.7.2/lib/utils/ABI_VERSION: No such file or directory
== vec
cat: /tmp/pktgen-dpdk-pktgen-3.7.2/lib/vec/ABI_VERSION: No such file or directory
== lua
cat: /tmp/pktgen-dpdk-pktgen-3.7.2/lib/lua/ABI_VERSION: No such file or directory
CC lua_config.o
In file included from /usr/include/lua.h:16:0,
from /tmp/pktgen-dpdk-pktgen-3.7.2/lib/lua/lua_config.h:25,
from /tmp/pktgen-dpdk-pktgen-3.7.2/lib/lua/lua_config.c:28:
/usr/include/luaconf.h:285:31: fatal error: readline/readline.h: No such file or directory
#include <readline/readline.h>
^
compilation terminated.
make[3]: *** [lua_config.o] Error 1
make[2]: *** [all] Error 2
make[1]: *** [lua] Error 2
make: *** [lib] Error 2
Install readline-devel
yum install -y readline-devel
The version of lua is too low to compile
Re-download
wget http://git.dpdk.org/apps/pktgen-dpdk/snapshot/pktgen-dpdk-pktgen-19.12.0.tar.gz
Download lua version 5.3, you can't uninstall it with rpm -e lua, download the source code compilation
[root@localhost ~]# ls
anaconda-ks.cfg lua-5.3.5 lua-5.3.5.tar.gz
[root@localhost ~]#
[root@localhost ~]# wget http://www.lua.org/ftp/lua-5.3.5.tar.gz
An error is still prompted at compile time
[root@localhost pktgen-dpdk-pktgen-19.12.0]#
[root@localhost pktgen-dpdk-pktgen-19.12.0]# make
== lib
== common
cat: /tmp/pktgen-dpdk-pktgen-19.12.0/lib/common/ABI_VERSION: No such file or directory
== plugin
cat: /tmp/pktgen-dpdk-pktgen-19.12.0/lib/plugin/ABI_VERSION: No such file or directory
== utils
cat: /tmp/pktgen-dpdk-pktgen-19.12.0/lib/utils/ABI_VERSION: No such file or directory
== vec
cat: /tmp/pktgen-dpdk-pktgen-19.12.0/lib/vec/ABI_VERSION: No such file or directory
== lua
cat: /tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/ABI_VERSION: No such file or directory
== cli
cat: /tmp/pktgen-dpdk-pktgen-19.12.0/lib/cli/ABI_VERSION: No such file or directory
== app
LD pktgen
cli-functions.o: In function `script_cmd':
/tmp/pktgen-dpdk-pktgen-19.12.0/app/cli-functions.c:1351: undefined reference to `luaL_loadfilex'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/cli-functions.c:1351: undefined reference to `lua_pcallk'
cli-functions.o: In function `exec_lua_cmd':
/tmp/pktgen-dpdk-pktgen-19.12.0/app/cli-functions.c:1399: undefined reference to `lua_pcallk'
lpktgenlib.o: In function `getf_integer':
/tmp/pktgen-dpdk-pktgen-19.12.0/app/lpktgenlib.c:183: undefined reference to `lua_isinteger'
lpktgenlib.o: In function `luaopen_pktgen':
/tmp/pktgen-dpdk-pktgen-19.12.0/app/lpktgenlib.c:3765: undefined reference to `luaL_checkversion_'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/lpktgenlib.c:3765: undefined reference to `luaL_setfuncs'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/lpktgenlib.c:3813: undefined reference to `luaL_setfuncs'
lpktgenlib.o: In function `pktgen_lua_openlib':
/tmp/pktgen-dpdk-pktgen-19.12.0/app/lpktgenlib.c:3837: undefined reference to `luaL_requiref'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_config.o): In function `msghandler':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_config.c:283: undefined reference to `luaL_traceback'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_config.o): In function `lua_docall':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_config.c:305: undefined reference to `lua_rotate'
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_config.c:307: undefined reference to `lua_pcallk'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_config.o): In function `lua_dofile':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_config.c:317: undefined reference to `luaL_loadfilex'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_config.o): In function `lua_dostring':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_config.c:332: undefined reference to `luaL_loadbufferx'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_config.o): In function `lua_dolibrary':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_config.c:345: undefined reference to `lua_getglobal'
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_config.c:350: undefined reference to `lua_setglobal'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_config.o): In function `lua_execute_string':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_config.c:367: undefined reference to `lua_pcallk'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_stdio.o): In function `newprefile':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_stdio.c:123: undefined reference to `luaL_setmetatable'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_socket.o): In function `addreturn':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_socket.c:154: undefined reference to `luaL_loadbufferx'
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_socket.c:157: undefined reference to `lua_rotate'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_socket.o): In function `multiline':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_socket.c:175: undefined reference to `luaL_loadbufferx'
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_socket.c:181: undefined reference to `lua_rotate'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_socket.o): In function `loadline':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_socket.c:207: undefined reference to `lua_rotate'
/tmp/pktgen-dpdk-pktgen-19.12.0/app/../lib/lua/x86_64-native-linuxapp-gcc/lib/libpktgen_lua.a(lua_socket.o): In function `l_print':
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_socket.c:226: undefined reference to `lua_getglobal'
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_socket.c:227: undefined reference to `lua_rotate'
/tmp/pktgen-dpdk-pktgen-19.12.0/lib/lua/lua_socket.c:228: undefined reference to `lua_pcallk'
collect2: error: ld returned 1 exit status
make[2]: *** [pktgen] Error 1
Need to replace the original Lua 5.1 dynamic library
[root@localhost ~]# wget http://www.lua.org/ftp/lua-5.3.5.tar.gz
[root@localhost ~]# cd lua-5.3.5
[root@localhost lua-5.3.5]# ls
doc Makefile README src
[root@localhost lua-5.3.5]#
[root@localhost lua-5.3.5]# cd src/
[root@localhost src]#
[root@localhost src]# vim Makefile
找到这行代码
CFLAGS= -O2 -Wall -DLUA_COMPAT_ALL $(SYSCFLAGS) $(MYCFLAGS)
修改为
CFLAGS= -O2 -Wall -DLUA_COMPAT_ALL $(SYSCFLAGS) $(MYCFLAGS) -fPIC #后面加的-fPIC表示要编译位置无关代码
找到
LUA_A = liblua.a
下面添加一行
LUA_SO = liblua.so #表示新建一个目标,要编译出lua动态库,编译出来的 动态库文件名字为liblua.so
找到
ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
改为
ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO) 表示添加上刚才的目标
找到
$(LUA_A): $(BASE_O)
$(AR) $@ $?
$(RANLIB) $@
在下面添加一行
$(LUA_SO): $(CORE_O) $(LIB_O)
$(CC) -o $@ -shared $? -ldl -lm 注意:本行前面的空格其实是一个tab
然后 make
Replace the original
cp liblua.so /usr/lib64/
Remake is ready to spawn
Original link: https://zhuanlan.zhihu.com/p/457628487