From f510ce78a4d9606a83640a54e5bd44673373819a Mon Sep 17 00:00:00 2001 From: Junfeng Wang Date: Fri, 20 Mar 2020 18:29:53 +0800 Subject: fix message func miss and build Change-Id: Ifc6a3337c63d69bd4d479cf7a97974c17f809cf4 Signed-off-by: Junfeng Wang --- Makefile | 22 +++++++++++++++++----- README.md | 32 ++++++++++++++++++++++++++------ scripts/checkstyle.sh | 4 ++-- src/dpi_api.c | 11 ++++++++++- src/dpi_plugin_doc.md | 43 ------------------------------------------- 5 files changed, 55 insertions(+), 57 deletions(-) diff --git a/Makefile b/Makefile index 8cae070..dc0bde9 100644 --- a/Makefile +++ b/Makefile @@ -37,15 +37,15 @@ endif ##### #Dependencies to build DEB_DEPENDS = curl build-essential autoconf automake ccache git cmake wget coreutils ragel -DEB_DEPENDS += libboost-dev vpp vpp-dev python*-ply +DEB_DEPENDS += libboost-dev python*-ply ##### #RPM# ##### #Dependencies to build RPM_DEPENDS = curl autoconf automake ccache cmake3 wget gcc gcc-c++ git gtest gtest-devel -RPM_DEPENDS += ragel python-sphinx boost169-devel vpp vpp-devel python*-ply +RPM_DEPENDS += ragel python-sphinx boost169-devel python*-ply devtoolset-7 -.PHONY: help install-dep build build-package build-install-package-hyperscan checkstyle distclean +.PHONY: help install-dep build build-package build-install-package-hyperscan checkstyle distclean fixstyle help: @echo "Make Targets:" @@ -54,6 +54,7 @@ help: @echo " build-install-package-hyperscan - build rpm or deb package for hyperscan" @echo " checkstyle - checkstyle" @echo " distclean - remove all build directory" + @echo " fixstyle - fix coding style" install-dep: ifeq ($(filter ubuntu debian,$(OS_ID)),$(OS_ID)) @@ -61,11 +62,18 @@ ifeq ($(OS_VERSION_ID),14.04) @sudo -E apt-get -y --force-yes install software-properties-common endif @sudo -E apt-get update +ifeq ($(shell dpkg -l|grep vpp-dev),) @curl -s https://packagecloud.io/install/repositories/fdio/2001/script.deb.sh | sudo bash - @sudo -E apt-get $(APT_ARGS) -y --force-yes install $(DEB_DEPENDS) + @sudo -E apt-get -y --force-yes install vpp vpp-dev +endif + @sudo -E apt-get -y --force-yes install $(DEB_DEPENDS) else ifeq ($(OS_ID),centos) + @sudo -E yum install -y epel-release centos-release-scl + @sudo -E yum install -y $(RPM_DEPENDS) +ifeq ($(shell rpm -qa|grep vpp-dev),) @curl -s https://packagecloud.io/install/repositories/fdio/2001/script.rpm.sh | sudo bash - @sudo -E yum install -y $(RPM_DEPENDS) epel-release centos-release-scl devtoolset-7 + @sudo -E yum install -y vpp vpp-devel +endif else $(error "This option currently works only on Ubuntu, Debian, Centos or openSUSE systems") endif @@ -97,5 +105,9 @@ endif checkstyle: @$(BR)/../scripts/checkstyle.sh +fixstyle: + @$(BR)/../scripts/checkstyle.sh --fix + + distclean: @rm -rf $(BR)/build-package* diff --git a/README.md b/README.md index cdf793e..92fbc4a 100644 --- a/README.md +++ b/README.md @@ -21,18 +21,36 @@ Details of the changes leading up to this version of UDPI can be found under ``` From the code tree root +if you have not any sepcical request for udpi compile +you should use the Makefile in the code tree root (suggest to install all the vpp packages first) + +Just run blew command + +$ make install-dep +$ make build-install-package-hyperscan +$ make build-package + +then you can use +$ rpm -i --force build-root/build-packge/udpi*.rpm # you may meet conflict form vpp-devel, but this is not a conflict, force install +or +$ dpkg -i build-root/build-package/udpi*.dep + + +else you should use cmake directly, like blew + + (VPP installed with DEB or RPM pkg) $ cd udpi-plugin $ mkdir -p build $ cd build -$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr #(add "-DCMKAE_INSTALL_LIBDIR=lib" on centos and it's releated) +$ cmake .. -DCMAKE_INSTALL_PREFIX=/usr #(add "-DCMKAE_INSTALL_LIBDIR=lib -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin"" and change cmake to cmake3 on centos and it's releated) $ make package (VPP source code -- build type RELEASE) $ cd udpi-plugin $ mkdir -p build $ cd build -$ cmake .. -DVPP_HOME=/build-root/install-vpp-native/vpp -DCMAKE_INSTALL_PREFIX=/build-root/install-vpp-native/vpp #(add "-DCMKAE_INSTALL_LIBDIR=lib" on centos and it's releated) +$ cmake .. -DVPP_HOME=/build-root/install-vpp-native/vpp -DCMAKE_INSTALL_PREFIX=/build-root/install-vpp-native/vpp #(add "-DCMKAE_INSTALL_LIBDIR=lib -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin"" and change cmake to cmake3 on centos and it's releated) $ make $ sudo make install @@ -40,7 +58,7 @@ $ sudo make install $ cd udpi-plugin $ mkdir -p build $ cd build -$ cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DVPP_HOME=/build-root/install-vpp_debug-native/vpp -DCMAKE_INSTALL_PREFIX=/build-root/install-vpp_debug-native/vpp #(add "-DCMKAE_INSTALL_LIBDIR=lib" on centos and it's releated) +$ cmake .. -DCMAKE_BUILD_TYPE=DEBUG -DVPP_HOME=/build-root/install-vpp_debug-native/vpp -DCMAKE_INSTALL_PREFIX=/build-root/install-vpp_debug-native/vpp #(add "-DCMKAE_INSTALL_LIBDIR=lib -DCMAKE_PROGRAM_PATH:PATH="/opt/rh/devtoolset-7/root/bin"" and change cmake to cmake3 on centos and it's releated) $ make $ sudo make install @@ -69,14 +87,14 @@ Build dependencies: - Hyperscan -- VPP 19.08 +- VPP 20.01 - DEB packages (can be found https://packagecloud.io/fdio/release/install): - libvppinfra-dev - vpp-dev Running dependencies: -- VPP 19.08 +- VPP 20.01 - DEB packages (can be found https://packagecloud.io/fdio/release/install): - vpp - vpp-plugin-core @@ -169,7 +187,9 @@ $ sudo vpp -c /etc/vpp/startup.conf ``` ### Configure udpi plugin ### -The udpi plugin can be configured either using the VPP command-line interface (CLI), through a configuration file or through the VPP binary api +The udpi plugin can be configured either using the VPP command-line interface (CLI), through the VPP binary api + +see src/dpi_plugin_doc.md in details. #### udpi plugin CLI #### diff --git a/scripts/checkstyle.sh b/scripts/checkstyle.sh index 7b0ee61..85af5af 100755 --- a/scripts/checkstyle.sh +++ b/scripts/checkstyle.sh @@ -71,7 +71,7 @@ fi cd ${UDPI_DIR} git status for i in ${FILELIST}; do - if [ -f ${i} ] && [ ${i} != "build-root/scripts/checkstyle.sh" ] && [ ${i} != "extras/emacs/fix-coding-style.el" ]; then + if [ -f ${i} ] && [ ${i} != "scripts/checkstyle.sh" ] && [ ${i} != "extras/emacs/fix-coding-style.el" ]; then grep -q "fd.io coding-style-patch-verification: ON" ${i} if [ $? == 0 ]; then EXTENSION=`basename ${i} | sed 's/^\w\+.//'` @@ -144,7 +144,7 @@ else echo "*******************************************************************" echo "* VPP CHECKSTYLE FAILED" echo "* CONSULT FAILURE LOG ABOVE" - echo "* NOTE: Running 'build-root/scripts/checkstyle.sh --fix' *MAY* fix the issue" + echo "* NOTE: Running 'scripts/checkstyle.sh --fix' *MAY* fix the issue" echo "*******************************************************************" fi exit ${EXIT_CODE} diff --git a/src/dpi_api.c b/src/dpi_api.c index cfb5262..f4bbffd 100644 --- a/src/dpi_api.c +++ b/src/dpi_api.c @@ -114,10 +114,19 @@ out: /* *INDENT-ON* */ } +static void +setup_message_id_table (api_main_t * am) +{ +#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); + foreach_vl_msg_name_crc_dpi; +#undef _ +} + static clib_error_t * dpi_api_hookup (vlib_main_t * vm) { dpi_main_t *dm = &dpi_main; + api_main_t *am = vlibapi_get_main (); u8 *name = format (0, "dpi_%08x%c", api_version, 0); dm->msg_id_base = vl_msg_api_get_msg_ids @@ -135,7 +144,7 @@ dpi_api_hookup (vlib_main_t * vm) #undef _ /* Add our API messages to the global name_crc hash table */ - dm->msg_id_base = setup_message_id_table (); + setup_message_id_table (am); return 0; } diff --git a/src/dpi_plugin_doc.md b/src/dpi_plugin_doc.md index fc069c0..d10cae5 100644 --- a/src/dpi_plugin_doc.md +++ b/src/dpi_plugin_doc.md @@ -62,46 +62,3 @@ Below is the brief design: 2). Scan SSL/TLS certificate message through hyperscan, and get application id if matched. 3). If maximum packets for this flow are checked and not found matched application, the detection will end up. - -## Hyperscan Installation - -Hyperscan can be installed from packages directly on below OS: - Ubuntu 16.04.03 - Ubuntu 18.04 and later version - Fedora 27 and later version - openSUSE rolling-release Tumbleweed and later version - -If you cannot install Hyperscan from packages directly, -you can build and install it from the source code. - -Below are steps to build and install Hyperscan on Ubuntu 16.04: -1).Install binary prerequisites -apt-get install cmake ragel -apt-get install libboost-dev -apt-get install python-dev libbz2-dev - -2).Download Hyperscan sources -wget https://github.com/intel/hyperscan/archive/v5.0.0.tar.gz -tar -xf v5.0.0.tar.gz - -3).Download boost headers -wget https://dl.bintray.com/boostorg/release/1.68.0/source/boost_1_68_0.tar.gz -tar -xf boost_1_68_0.tar.gz -cp -r boost_1_68_0/boost hyperscan-5.0.0/include - -4).Build and install Hyperscan shared library. - Just follow the instruction from here. Compilation can take a long time. -cd hyperscan-5.0.0 -mkdir build -cd build -cmake -DBUILD_SHARED_LIBS=true .. -make -make install - -## Multi-Thread Support -Since generated bytecode database is read only, you can run multiple cores -to utilize the byte database to scale. - - - - -- cgit 1.2.3-korg