From bc01c8eae6ef0d87b1a0e6ac676605cacbd52014 Mon Sep 17 00:00:00 2001 From: BangLang Huang Date: Sat, 23 Dec 2017 20:32:38 +0800 Subject: [PATCH] libpfring: add new package PF_RING is a high speed packet capture library that turns a commodity PC into an efficient and cheap network measurement box suitable for both packet and active traffic analysis and manipulation. Moreover, PF_RING opens totally new markets as it enables the creation of efficient application such as traffic balancers or packet filters in a matter of lines of codes. github : https://github.com/ntop/pf_ring official : https://www.ntop.org Signed-off-by: BangLang Huang Signed-off-by: Stijn Tintel [rename kmod-pfring to kmod-pf-ring] --- kernel/pfring/Makefile | 63 +++++++++++++++++ libs/libpfring/Makefile | 69 +++++++++++++++++++ .../patches/0001-fix-cross-compiling.patch | 32 +++++++++ .../patches/0002-fix-march-native.patch | 21 ++++++ libs/libpfring/patches/0003-fix-strncpy.patch | 10 +++ 5 files changed, 195 insertions(+) create mode 100644 kernel/pfring/Makefile create mode 100644 libs/libpfring/Makefile create mode 100644 libs/libpfring/patches/0001-fix-cross-compiling.patch create mode 100644 libs/libpfring/patches/0002-fix-march-native.patch create mode 100644 libs/libpfring/patches/0003-fix-strncpy.patch diff --git a/kernel/pfring/Makefile b/kernel/pfring/Makefile new file mode 100644 index 000000000..f175475ed --- /dev/null +++ b/kernel/pfring/Makefile @@ -0,0 +1,63 @@ +# +# Copyright (C) 2017 Banglang Huang +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=pf-ring +PKG_VERSION:=7.2.0 +PKG_RELEASE:=1 +PKG_MAINTAINER:=Banglang Huang + +PKG_LICENSE:=GPL-2.0 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://codeload.github.com/ntop/PF_RING/tar.gz/$(PKG_VERSION)? +PKG_HASH:=5d349ac37a6ece5966bf606a6f131d628b98d88654c2f502d3c4b8bbf6ef9796 + +PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/PF_RING-$(PKG_VERSION) + +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +CONFIGURE_PATH:=kernel +MAKE_PATH:=kernel + +define KernelPackage/pf-ring + SUBMENU:=Network Support + TITLE:=PF_RING Kernel driver + FILES:=$(PKG_BUILD_DIR)/kernel/pf_ring.ko + AUTOLOAD:=$(call AutoLoad,90,pf_ring,1) +endef + +define KernelPackage/pf-ring/description + Kernel module for libpf-ring package +endef + +EXTRA_CFLAGS += \ + -I$(PKG_BUILD_DIR)/kernel + +MAKE_OPTS := \ + ARCH="$(LINUX_KARCH)" \ + CROSS_COMPILE="$(TARGET_CROSS)" \ + SUBDIRS="$(PKG_BUILD_DIR)/kernel" \ + CFLAGS="$(TARGET_CFLAGS)" \ + EXTRA_CFLAGS="$(EXTRA_CFLAGS)" + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/linux + $(CP) $(PKG_INSTALL_DIR)/usr/include/linux/*.h $(1)/usr/include/linux +endef + +define Build/Compile + +$(MAKE) -C "$(LINUX_DIR)" \ + $(MAKE_OPTS) \ + modules +endef + +$(eval $(call KernelPackage,pf-ring)) diff --git a/libs/libpfring/Makefile b/libs/libpfring/Makefile new file mode 100644 index 000000000..3cc05658c --- /dev/null +++ b/libs/libpfring/Makefile @@ -0,0 +1,69 @@ +# +# Copyright (C) 2017 Banglang Huang +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libpfring +PKG_VERSION:=7.2.0 +PKG_RELEASE:=1 +PKG_MAINTAINER:=Banglang Huang + +PKG_LICENSE:=LGPL-2.1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=https://codeload.github.com/ntop/PF_RING/tar.gz/$(PKG_VERSION)? +PKG_HASH:=5d349ac37a6ece5966bf606a6f131d628b98d88654c2f502d3c4b8bbf6ef9796 + +PKG_BUILD_DIR:=$(BUILD_DIR)/PF_RING-$(PKG_VERSION) + +PKG_INSTALL:=1 +PKG_FIXUP:=patch-libtool + +include $(INCLUDE_DIR)/package.mk + +CONFIGURE_PATH:=userland +MAKE_PATH:=userland/lib + +define Package/libpfring + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Library for PR_RING (package process framework) + URL:=https://github.com/ntop/pf_ring + DEPENDS:=+kmod-pfring +libpcap +libpthread +endef + +define Package/libpfring/description + PF_RING is a high speed packet capture library that turns a commodity PC into an efficient and cheap + network measurement box suitable for both packet and active traffic analysis and manipulation. + Moreover, PF_RING opens totally new markets as it enables the creation of efficient application such as + traffic balancers or packet filters in a matter of lines of codes. +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/ + $(CP) \ + $(PKG_INSTALL_DIR)/usr/include/* \ + $(1)/usr/include/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libpfring.so* \ + $(1)/usr/lib/ +endef + +CONFIGURE_VARS += \ + MACHINE="$(ARCH)" + +define Package/libpfring/install + $(INSTALL_DIR) $(1)/usr/lib/ + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libpfring.so* \ + $(1)/usr/lib/ + $(LN) libpfring.so $(1)/usr/lib/libpfring.so.1 +endef + +$(eval $(call BuildPackage,libpfring)) diff --git a/libs/libpfring/patches/0001-fix-cross-compiling.patch b/libs/libpfring/patches/0001-fix-cross-compiling.patch new file mode 100644 index 000000000..5af3fb9d5 --- /dev/null +++ b/libs/libpfring/patches/0001-fix-cross-compiling.patch @@ -0,0 +1,32 @@ +--- a/userland/configure ++++ b/userland/configure +@@ -3745,12 +3745,6 @@ fi + if test "$IS_FREEBSD" != "1"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking if r/w locks are supported" >&5 + $as_echo_n "checking if r/w locks are supported... " >&6; } +- if test "$cross_compiling" = yes; then : +- { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +-as_fn_error $? "cannot run test program while cross compiling +-See \`config.log' for more details" "$LINENO" 5; } +-else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext + /* end confdefs.h. */ + +@@ -3763,7 +3757,7 @@ else + + + _ACEOF +-if ac_fn_c_try_run "$LINENO"; then : ++if ac_fn_c_try_compile "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 + $as_echo "yes" >&6; } + cat >>confdefs.h <<_ACEOF +@@ -3777,7 +3771,6 @@ $as_echo "no" >&6; } + fi + rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +-fi + + fi + diff --git a/libs/libpfring/patches/0002-fix-march-native.patch b/libs/libpfring/patches/0002-fix-march-native.patch new file mode 100644 index 000000000..69bfde713 --- /dev/null +++ b/libs/libpfring/patches/0002-fix-march-native.patch @@ -0,0 +1,21 @@ +--- a/userland/configure ++++ b/userland/configure +@@ -3296,14 +3296,16 @@ fi + done + + +-MACHINE=`uname -m` ++if test -z "$MACHINE"; then ++ MACHINE=`uname -m` ++fi + CFLAGS="" + SYS_LIBS="" + + VER=`cat ../kernel/linux/pf_ring.h | grep RING_VERSION | head -1 | cut -d '"' -f 2` + MAJOR_VER=`cat ../kernel/linux/pf_ring.h | grep RING_VERSION | head -1 | cut -d '"' -f 2 | cut -d '.' -f 1` + +-NATIVE=`$CC -c -Q -march=native --help=target| grep "march" | xargs | cut -d ' ' -f 2` ++NATIVE=`$CC -c -Q --help=target| grep "march" | xargs | cut -d ' ' -f 2` + if test -f "lib/libs/libpfring_zc_x86_64_$NATIVE.a"; then + CFLAGS="-march=native -mtune=native $CFLAGS" + LIBARCH="_$NATIVE" diff --git a/libs/libpfring/patches/0003-fix-strncpy.patch b/libs/libpfring/patches/0003-fix-strncpy.patch new file mode 100644 index 000000000..f42c4e524 --- /dev/null +++ b/libs/libpfring/patches/0003-fix-strncpy.patch @@ -0,0 +1,10 @@ +--- a/userland/lib/pfring_mod.c ++++ b/userland/lib/pfring_mod.c +@@ -24,6 +24,7 @@ + #include + + #ifdef ENABLE_BPF ++#include + #include + #include + #include