aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app_example/CMakeLists.txt2
-rw-r--r--app_example/func-test/CMakeLists.txt18
-rw-r--r--app_example/func-test/fork/CMakeLists.txt27
-rw-r--r--app_example/func-test/fork/tcpclient.c173
-rw-r--r--app_example/func-test/fork/tcpserver.c161
-rw-r--r--pkg/deb/control2
-rw-r--r--pkg/rpm/dmm.spec4
-rwxr-xr-xscripts/build.sh256
-rwxr-xr-xscripts/build_dmm_dep.sh35
-rwxr-xr-xscripts/build_dpdk.sh63
-rwxr-xr-xscripts/build_dpdk1802.sh15
-rwxr-xr-xscripts/build_dpdk1805.sh8
-rwxr-xr-xscripts/build_rsocket.sh34
-rwxr-xr-xscripts/check_hugepage.sh41
-rw-r--r--scripts/compile_dmm.sh41
-rwxr-xr-xscripts/generate_dmm_rpm.sh2
-rwxr-xr-x[-rw-r--r--]scripts/install_prereq.sh (renamed from stacks/lwip_stack/vagrant/install_prereq.sh)0
-rwxr-xr-xscripts/prep_app_test.sh80
-rwxr-xr-xscripts/print_os_info.sh17
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/adapt/nstack_dmm_adpt.c2
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c24
-rw-r--r--src/framework/ipc/mgr_com/mgr_com.c23
-rw-r--r--src/framework/ipc/ps/nsfw_fd_timer.c1
-rw-r--r--src/framework/ipc/ps/nsfw_ps_module.c40
-rw-r--r--src/framework/ipc/ps/nsfw_recycle_module.c3
-rw-r--r--src/framework/ipc/ps/nsfw_soft_param.c1
-rw-r--r--src/framework/log/nsfw_set_log.c1
-rw-r--r--src/nSocket/include/nstack_dmm_api.h1
-rw-r--r--src/nSocket/include/nstack_select.h2
-rw-r--r--src/nSocket/kernel/linux_kernel_module.c1
-rw-r--r--src/nSocket/nstack/event/select/nstack_select.c22
-rw-r--r--src/nSocket/nstack/nstack.c4
-rw-r--r--src/nSocket/nstack/nstack_module.c20
-rw-r--r--src/nSocket/nstack/nstack_module.h1
-rw-r--r--src/nSocket/nstack/nstack_socket.c2
-rw-r--r--src/nSocket/nstack_rd/nstack_rd.c2
-rw-r--r--stacks/lwip_stack/CMakeLists.txt4
-rw-r--r--stacks/lwip_stack/doc/README.md120
-rw-r--r--stacks/lwip_stack/doc/dmm_lwip.pngbin0 -> 52940 bytes
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_api_msg.c105
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_spl_share.h12
-rw-r--r--stacks/lwip_stack/lwip_src/core/spl_pbuf.c14
-rw-r--r--stacks/lwip_stack/lwip_src/core/spl_timers.c1
-rw-r--r--stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h3
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c6
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c28
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h3
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c19
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c33
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h1
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_tcp.c2
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_udp.c2
-rw-r--r--stacks/lwip_stack/release/script/nstack_var.sh2
-rw-r--r--stacks/lwip_stack/release/start_nstack.sh11
-rw-r--r--stacks/lwip_stack/release/stop_nstack.sh6
-rw-r--r--stacks/lwip_stack/run_stackx.txt140
-rw-r--r--stacks/lwip_stack/src/alarm/alarm.c4
-rw-r--r--stacks/lwip_stack/src/maintain/fw_mt_config.c38
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_protocol_api.h4
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_res_mgr.h31
-rw-r--r--stacks/lwip_stack/src/sbr/sbr_socket.c43
-rw-r--r--stacks/lwip_stack/vagrant/Vagrantfile6
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/vagrant/build.sh237
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/vagrant/env.sh0
-rwxr-xr-xstacks/lwip_stack/vagrant/start_nstackMain.sh117
-rw-r--r--stacks/vpp/adapt/dmm_vcl_adpt.c1
-rw-r--r--stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch62
68 files changed, 1427 insertions, 759 deletions
diff --git a/app_example/CMakeLists.txt b/app_example/CMakeLists.txt
index 0c88a4f..a82c752 100644
--- a/app_example/CMakeLists.txt
+++ b/app_example/CMakeLists.txt
@@ -15,4 +15,4 @@
#########################################################################
ADD_SUBDIRECTORY(perf-test)
-
+ADD_SUBDIRECTORY(func-test)
diff --git a/app_example/func-test/CMakeLists.txt b/app_example/func-test/CMakeLists.txt
new file mode 100644
index 0000000..e6357b8
--- /dev/null
+++ b/app_example/func-test/CMakeLists.txt
@@ -0,0 +1,18 @@
+#########################################################################
+#
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#########################################################################
+
+ADD_SUBDIRECTORY(fork)
+
diff --git a/app_example/func-test/fork/CMakeLists.txt b/app_example/func-test/fork/CMakeLists.txt
new file mode 100644
index 0000000..266dd9f
--- /dev/null
+++ b/app_example/func-test/fork/CMakeLists.txt
@@ -0,0 +1,27 @@
+#########################################################################
+#
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#########################################################################
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2 -g -fPIC -m64 -mssse3 -std=gnu89")
+
+LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
+
+ADD_EXECUTABLE(tcp_fork_server tcpserver.c)
+ADD_DEPENDENCIES(tcp_fork_server nStackAPI)
+TARGET_LINK_LIBRARIES(tcp_fork_server libnStackAPI.so -lpthread -lrt)
+
+ADD_EXECUTABLE(tcp_client tcpclient.c)
+ADD_DEPENDENCIES(tcp_client nStackAPI)
+TARGET_LINK_LIBRARIES(tcp_client libnStackAPI.so -lpthread -lrt)
+
diff --git a/app_example/func-test/fork/tcpclient.c b/app_example/func-test/fork/tcpclient.c
new file mode 100644
index 0000000..274dcbb
--- /dev/null
+++ b/app_example/func-test/fork/tcpclient.c
@@ -0,0 +1,173 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#define DEBUG
+
+#ifdef DEBUG
+#define DBG(fmt, arg...) do { \
+ printf(fmt, ##arg); \
+} while(0)
+#else
+#define DBG(fmt, arg...) ((void)0)
+#endif
+
+static struct sockaddr_in g_dest;
+static struct sockaddr_in g_src;
+int srcPort = 0;
+int destPort = 0;
+int times = 0;
+
+void
+random_str (char *str, const int len)
+{
+ static const char alphaNum[] =
+ "abcdefghijklmnopqrstuvwxyz" "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "0123456789";
+ int i = 0;
+
+ for (i = 0; i < len; i++)
+ {
+ str[i] = alphaNum[rand () % (sizeof (alphaNum) - 1)];
+ }
+
+ str[len] = 0;
+}
+
+static void
+setArgsDefault ()
+{
+
+ memset (&g_dest, 0, sizeof (g_dest));
+ g_dest.sin_family = AF_INET;
+ g_dest.sin_addr.s_addr = inet_addr ("127.0.0.1");
+ g_dest.sin_port = htons (12345);
+ bzero (&(g_dest.sin_zero), 8);
+
+ memset (&g_src, 0, sizeof (g_src));
+ g_src.sin_family = AF_INET;
+ g_src.sin_addr.s_addr = inet_addr ("0.0.0.0");
+ g_src.sin_port = htons (7895);
+ bzero (&(g_src.sin_zero), 8);
+
+ times = 1;
+}
+
+static int
+process_arg (int argc, char *argv[])
+{
+ int opt = 0;
+ int error = 0;
+ const char *optstring = "p:d:s:a:t:";
+
+ if (argc < 5)
+ {
+ DBG
+ ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -t times; \n");
+ return -1;
+ }
+ setArgsDefault ();
+ while ((opt = getopt (argc, argv, optstring)) != -1)
+ {
+ switch (opt)
+ {
+ case 'p':
+ g_dest.sin_port = htons (atoi (optarg));
+ break;
+ case 'd':
+ g_dest.sin_addr.s_addr = inet_addr (optarg);
+ break;
+ case 's':
+ g_src.sin_addr.s_addr = inet_addr (optarg);
+ break;
+ case 'a':
+ g_src.sin_port = htons (atoi (optarg));
+ break;
+ case 't':
+ times = atoi (optarg);
+ break;
+ }
+ }
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+
+ int clientSocket, ret, i;
+ char sndbuffer[1024];
+ char rcvbuffer[1024];
+ int result = 0;
+
+ /*
+ * check command line arguments
+ */
+ if (0 != process_arg (argc, argv))
+ {
+ DBG ("Error in argument.%d\n", argc);
+ exit (1);
+ }
+
+ clientSocket = socket (AF_INET, SOCK_STREAM, 0);
+ if (clientSocket < 0)
+ {
+ DBG ("Error in connection.\n");
+ exit (1);
+ }
+ DBG ("[INFO]Client Socket is created.\n");
+
+ ret = bind (clientSocket, (struct sockaddr *) &g_src, sizeof (g_src));
+ if (ret < 0)
+ {
+ DBG ("Error in binding.\n");
+ exit (1);
+ }
+
+ DBG ("[INFO]Bind to client aaddress port 0\n");
+
+ ret = connect (clientSocket, (struct sockaddr *) &g_dest, sizeof (g_dest));
+ if (ret < 0)
+ {
+ DBG ("Error in connection.\n");
+ exit (1);
+ }
+ DBG ("[INFO]Connected to Server.\n");
+
+ memset (sndbuffer, '\0', 1024 * sizeof (char));
+ memset (rcvbuffer, '\0', 1024 * sizeof (char));
+
+ for (i = 1; i <= times; i++)
+ {
+ DBG ("Client: \t");
+ random_str (sndbuffer, 50);
+ send (clientSocket, sndbuffer, strlen (sndbuffer), 0);
+
+ if (recv (clientSocket, rcvbuffer, 1024, 0) < 0)
+ {
+ DBG ("Error in receiving data.\n");
+ }
+ else
+ {
+ DBG ("Server: \t%s\n", rcvbuffer);
+ }
+ if (0 != strcmp (sndbuffer, rcvbuffer))
+ {
+ result = -1;
+ break;
+ }
+ }
+
+ /* Send exit message to server */
+ strcpy (sndbuffer, "#exit");
+ send (clientSocket, sndbuffer, strlen (sndbuffer), 0);
+
+ DBG ("Result = %s\n", (result == 0) ? "Success" : "Fail");
+ close (clientSocket);
+ DBG ("Disconnecting from server.\n");
+ return 0;
+}
diff --git a/app_example/func-test/fork/tcpserver.c b/app_example/func-test/fork/tcpserver.c
new file mode 100644
index 0000000..5474c35
--- /dev/null
+++ b/app_example/func-test/fork/tcpserver.c
@@ -0,0 +1,161 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/socket.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <sys/wait.h>
+
+static struct sockaddr_in g_src;
+int srcPort = 0;
+int destPort = 0;
+int times = 0;
+
+#ifdef DEBUG
+#define DBG(fmt, arg...) do { \
+ DBG(fmt, ##arg); \
+} while(0)
+#else
+#define DBG(fmt, arg...) ((void)0)
+#endif
+
+static void
+setArgsDefault ()
+{
+ memset (&g_src, 0, sizeof (g_src));
+ g_src.sin_family = AF_INET;
+ g_src.sin_addr.s_addr = inet_addr ("0.0.0.0");
+ g_src.sin_port = htons (7895);
+ bzero (&(g_src.sin_zero), 8);
+
+ times = 1;
+}
+
+static int
+process_arg (int argc, char *argv[])
+{
+ int opt = 0;
+ int error = 0;
+ const char *optstring = "s:a:t:";
+
+ if (argc < 5)
+ {
+ DBG
+ ("Param info :-p dest_portid; -d dest_serverIP; -a src_portid; -s src_clientIP; -t times; \n");
+ return -1;
+ }
+ setArgsDefault ();
+ while ((opt = getopt (argc, argv, optstring)) != -1)
+ {
+ switch (opt)
+ {
+ case 's':
+ g_src.sin_addr.s_addr = inet_addr (optarg);
+ break;
+ case 'a':
+ g_src.sin_port = htons (atoi (optarg));
+ break;
+ case 't':
+ times = atoi (optarg);
+ break;
+ }
+ }
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+
+ int sockfd, ret;
+ int newSocket;
+ socklen_t addr_size;
+ static struct sockaddr_in accept_addr;
+ char buffer[1024];
+ pid_t childpid;
+
+ /*
+ * check command line arguments
+ */
+ if (0 != process_arg (argc, argv))
+ {
+ DBG ("Error in argument.%d\n", argc);
+ exit (1);
+ }
+
+ sockfd = socket (AF_INET, SOCK_STREAM, 0);
+ if (sockfd < 0)
+ {
+ DBG ("Error in connection.\n");
+ exit (1);
+ }
+ DBG ("Server Socket is created. %d\n", sockfd);
+
+ ret = bind (sockfd, (struct sockaddr *) &g_src, sizeof (g_src));
+ if (ret < 0)
+ {
+ DBG ("Error in binding.\n");
+ exit (1);
+ }
+
+ DBG ("Bind sucess port %d\n", g_src.sin_port);
+
+ if (listen (sockfd, 10) == 0)
+ {
+ DBG ("Listening on %s....\n", inet_ntoa (g_src.sin_addr));
+ }
+ else
+ {
+ DBG ("Error in binding.\n");
+ }
+
+ while (1)
+ {
+ newSocket =
+ accept (sockfd, (struct sockaddr *) &accept_addr, &addr_size);
+ if (newSocket < 0)
+ {
+ DBG ("Error: Exiting here pid %d", getpid ());
+ exit (1);
+ }
+
+ DBG ("Connection accepted from %s:%d fd %d\n",
+ inet_ntoa (accept_addr.sin_addr),
+ ntohs (accept_addr.sin_port), newSocket);
+ if ((childpid = fork ()) == 0)
+ {
+ DBG ("[ PID %d] Child process Created. Pid %d \r\n", getpid (),
+ getpid ());
+ DBG ("[ PID %d] Closing fd %d\n", getpid (), sockfd);
+ close (sockfd);
+
+ while (1)
+ {
+ memset (buffer, '\0', 1024 * sizeof (char));
+ recv (newSocket, buffer, 1024, 0);
+ if (strcmp (buffer, "#exit") == 0)
+ {
+ DBG ("Disconnected from %s:%d\n",
+ inet_ntoa (newAddr.sin_addr),
+ ntohs (newAddr.sin_port));
+ break;
+ }
+ else
+ {
+ DBG ("[PID %d]Client: %s\n", getpid (), buffer);
+ send (newSocket, buffer, strlen (buffer), 0);
+ bzero (buffer, sizeof (buffer));
+ }
+ }
+
+ DBG ("[PID %d]Closing socket %d\r\n", getpid (), newSocket);
+ close (newSocket);
+ }
+
+ }
+
+ DBG ("[PID %d]Process exiting... %d\r\n", getpid (), getpid ());
+ return 0;
+}
diff --git a/pkg/deb/control b/pkg/deb/control
index c220c72..a373fef 100644
--- a/pkg/deb/control
+++ b/pkg/deb/control
@@ -1,5 +1,5 @@
Package: dmm
-Version: 18.04
+Version: 18.07
Section: tuils
Priority: optional
Depends: libc6, libstdc++6, libgcc1
diff --git a/pkg/rpm/dmm.spec b/pkg/rpm/dmm.spec
index 1545d25..79dfb05 100644
--- a/pkg/rpm/dmm.spec
+++ b/pkg/rpm/dmm.spec
@@ -1,5 +1,5 @@
Name: dmm
-Version: 18.04
+Version: 18.07
Release: 1%{?dist}
Summary: DMM Project
@@ -38,7 +38,7 @@ install -c ../BUILD/%{name}-%{version}/release/bin/vs_select %{name}-%{version}-
install -c ../BUILD/%{name}-%{version}/release/bin/ks_common %{name}-%{version}-%{release}.x86_64/usr/bin
install -c ../BUILD/%{name}-%{version}/release/bin/vs_common %{name}-%{version}-%{release}.x86_64/usr/bin
-install -c ../BUILD/%{name}-%{version}/release/lib64/libdmm_api.a %{name}-%{version}-%{release}.x86_64/usr/lib64
+install -c ../BUILD/%{name}-%{version}/release/lib64/libdmm_api.so %{name}-%{version}-%{release}.x86_64/usr/lib64
install -c ../BUILD/%{name}-%{version}/release/lib64/libnStackAPI.so %{name}-%{version}-%{release}.x86_64/usr/lib64
%files
diff --git a/scripts/build.sh b/scripts/build.sh
index 7726f94..eaa0f0e 100755
--- a/scripts/build.sh
+++ b/scripts/build.sh
@@ -22,7 +22,11 @@ exec 1> >(tee -a "$log_file") 2>&1
# Get Command Line arguements if present
DMM_DIR=$1
-if [ "x$1" != "x" ]; then
+if [ "$1" == "all" ]; then
+ BUILD_ALL="YES"
+fi
+
+if [ "x$1" != "x" ] && [ "$1" != "all" ]; then
DMM_DIR=$1
else
DMM_DIR=`dirname $(readlink -f $0)`/../
@@ -34,253 +38,29 @@ echo 2:$2
echo DMM_DIR: $DMM_DIR
BUILD_DIR=${DMM_DIR}/build
-LIB_PATH=${DMM_DIR}/release/lib64
-
-OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-KERNEL_OS=`uname -o`
-KERNEL_MACHINE=`uname -m`
-KERNEL_RELEASE=`uname -r`
-KERNEL_VERSION=`uname -v`
-
-echo KERNEL_OS: $KERNEL_OS
-echo KERNEL_MACHINE: $KERNEL_MACHINE
-echo KERNEL_RELEASE: $KERNEL_RELEASE
-echo KERNEL_VERSION: $KERNEL_VERSION
-echo OS_ID: $OS_ID
-echo OS_VERSION_ID: $OS_VERSION_ID
+#print os information
+bash -x $DMM_DIR/scripts/print_os_info.sh
# add inherited proxy for sudo user
LINE='Defaults env_keep += "ftp_proxy http_proxy https_proxy no_proxy"'
FILE=/etc/sudoers
grep -qF -- "$LINE" "$FILE" || sudo echo "$LINE" >> "$FILE"
-#DPDK download path
-DPDK_DOWNLOAD_PATH=/tmp/dpdk
-
-#dpdk installation path
-DPDK_INSTALL_PATH=/usr
-
#set and check the environment for Linux
-if [ "$OS_ID" == "ubuntu" ]; then
- export DEBIAN_FRONTEND=noninteractive
- export DEBCONF_NONINTERACTIVE_SEEN=true
-
- APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
- sudo apt-get update ${APT_OPTS}
- sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim pkg-config tcl libnl-route-3-200 flex graphviz tk debhelper dpatch gfortran ethtool libgfortran3 bison dkms quilt chrpath swig python-libxml2
-elif [ "$OS_ID" == "debian" ]; then
- echo "not tested for debian and exit"
- exit 1
- export DEBIAN_FRONTEND=noninteractive
- export DEBCONF_NONINTERACTIVE_SEEN=true
-
- APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
- sudo apt-get update ${APT_OPTS}
- sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim
-elif [ "$OS_ID" == "centos" ]; then
- sudo yum install -y deltarpm git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel libiverbs tk tcl tcsh redhat-lsb-core
-elif [ "$OS_ID" == "opensuse" ]; then
- echo "not tested for opensuse and exit"
- exit 1
- sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel
-fi
-
-
-#DPDK will be having dependancy on linux headers
-if [ "$OS_ID" == "ubuntu" ]; then
- sudo apt-get -y install git build-essential linux-headers-`uname -r`
- sudo apt-get -y install libnuma-dev
-elif [ "$OS_ID" == "debian" ]; then
- sudo apt-get -y install git build-essential linux-headers-`uname -r`
-elif [ "$OS_ID" == "centos" ]; then
- sudo yum groupinstall -y "Development Tools"
- sudo yum install -y kernel-headers
- sudo yum install -y numactl-devel
-elif [ "$OS_ID" == "opensuse" ]; then
- sudo yum groupinstall -y "Development Tools"
- sudo yum install -y kernel-headers
-fi
-
+bash -x $DMM_DIR/scripts/build_dmm_dep.sh || exit 1
#===========build DPDK================
-
-if [ "$OS_ID" == "centos" ]; then
- bash -x $DMM_DIR/scripts/build_dpdk1802.sh || exit 1
-else
-
- if [ ! -d /usr/include/dpdk ] || [ ! -d /usr/share/dpdk ] || [ ! -d /usr/lib/modules/4.4.0-31-generic/extra/dpdk ]; then
- mkdir -p $DPDK_DOWNLOAD_PATH
-
- DPDK_FOLDER=$DPDK_DOWNLOAD_PATH/dpdk-18.02-$TIMESTAMP
- cd $DPDK_DOWNLOAD_PATH
- mkdir $DPDK_FOLDER
- wget -N https://fast.dpdk.org/rel/dpdk-18.02.tar.xz --no-check-certificate
- tar xvf dpdk-18.02.tar.xz -C $DPDK_FOLDER
- cd $DPDK_FOLDER/dpdk-18.02
-
- sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base
- sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base
- sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base
- sed -i 's!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1' config/common_base
-
- sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -j 4
-
- mkdir -p /tmp/dpdk/drivers/
- cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/
- fi
-fi
+bash -x $DMM_DIR/scripts/build_dpdk.sh || exit 1
#===========build DMM=================
-echo "DMM build started....."
-
-cd $BUILD_DIR
-rm -rf *
-cmake ..
-make -j 8
-
-if [ $? -eq 0 ]; then
- echo "DMM build is SUCCESS"
-else
- echo "DMM build has FAILED"
- exit 1
-fi
-
-if [ "$OS_ID" == "centos" ]; then
- make pkg-rpm
-elif [ "$OS_ID" == "ubuntu" ]; then
- make pkg-deb
-fi
-
-#===========check running env =================
-hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
-if [ "$hugepagesize" == "2048" ]; then
- pages=1536
-elif [ "$hugepagesize" == "1048576" ]; then
- pages=3
-fi
-sudo sysctl -w vm.nr_hugepages=$pages
-HUGEPAGES=`sysctl -n vm.nr_hugepages`
-if [ $HUGEPAGES != $pages ]; then
- echo "ERROR: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
- exit
-fi
-
-hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0")
-if [ $hugepageTotal -ne 0 ]; then
- echo "HugePages_Total is zero"
- exit
-fi
-
-hugepageFree=$(cat /proc/meminfo | grep -c "HugePages_Free: 0")
-if [ $hugepageFree -ne 0 ]; then
- echo "HugePages_Free is zero"
- exit
-fi
-
-hugepageSize=$(cat /proc/meminfo | grep -c "Hugepagesize: 0 kB")
-if [ $hugepageSize -ne 0 ]; then
- echo "Hugepagesize is zero"
- exit
-fi
-
-sudo mkdir /mnt/nstackhuge -p
-if [ "$hugepagesize" == "2048" ]; then
- sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/
-elif [ "$hugepagesize" == "1048576" ]; then
- sudo mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/
-fi
-#sudo mkdir -p /var/run/ip_module/
-
-#disable ASLR, othewise it may have some problems when mapping memory for secondary process
-echo 0 > /proc/sys/kernel/randomize_va_space
-
-export LD_LIBRARY_PATH=$LIB_PATH
-export NSTACK_LOG_ON=DBG
-
-############### Preapre APP test directory
-echo -e "\e[41m Preapring APP test directory.....\e[0m"
-
-mkdir -p $DMM_DIR/config/app_test
-cd $DMM_DIR/config/app_test
-
-if [ "$OS_ID" == "ubuntu" ]; then
- ifaddress1=$(ifconfig enp0s8 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
- echo $ifaddress1
- ifaddress2=$(ifconfig enp0s9 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
- echo $ifaddress2
-elif [ "$OS_ID" == "centos" ]; then
- ifaddress1=$(ifconfig enp0s8 | grep 'inet' | cut -d: -f2 | awk '{print $2}')
- echo $ifaddress1
- ifaddress2=$(ifconfig enp0s9 | grep 'inet' | cut -d: -f2 | awk '{print $2}')
- echo $ifaddress2
-fi
-
-echo '{
- "default_stack_name": "kernel",
- "module_list": [
- {
- "stack_name": "kernel",
- "function_name": "kernel_stack_register",
- "libname": "./",
- "loadtype": "static",
- "deploytype": "1",
- "maxfd": "1024",
- "minfd": "0",
- "priorty": "1",
- "stackid": "0",
- },
- ]
-}' | tee module_config.json
-
-echo '{
- "ip_route": [
- {
- "subnet": "'$ifaddress1'/24",
- "type": "nstack-kernel",
- },
- {
- "subnet": "'$ifaddress2'/24",
- "type": "nstack-kernel",
- },
- ],
- "prot_route": [
- {
- "proto_type": "1",
- "type": "nstack-kernel",
- },
- {
- "proto_type": "2",
- "type": "nstack-kernel",
- }
- ],
-}' | tee rd_config.json
-
-echo "DMM build finished....."
-
-############### build rsocket
-echo "rsocket build start"
-cd $DMM_DIR/stacks/rsocket
-if [ "$OS_ID" == "ubuntu" ]; then
- wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz
- tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz
- cd MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64
-elif [ "$OS_ID" == "centos" ]; then
- CENT_VERSION=`grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release`
- wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz
- tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz
- cd MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64
-fi
-
-./mlnxofedinstall --force || exit 1
-
-cd $BUILD_DIR
-make dmm_rsocket
-if [ $? -eq 0 ]; then
- echo "rsocket build has SUCCESS"
-else
- echo "rsocket build has FAILED"
- exit 1
+bash -x $DMM_DIR/scripts/compile_dmm.sh || exit 1
+
+if [ "${BUILD_ALL}" == "YES" ]; then
+ #===========build LWIP================
+ bash -x $DMM_DIR/stacks/lwip_stack/vagrant/build.sh "from-base-build" || exit 1
+ #============build rsocket============================
+ bash -x $DMM_DIR/scripts/build_rsocket.sh || exit 1
+ #=======other new stacks build can be called from here
+ echo "SUCCESSFULLY built all the stacks"
fi
-echo "rsocket build finished"
diff --git a/scripts/build_dmm_dep.sh b/scripts/build_dmm_dep.sh
new file mode 100755
index 0000000..ecbb686
--- /dev/null
+++ b/scripts/build_dmm_dep.sh
@@ -0,0 +1,35 @@
+#!/bin/bash -x
+
+set -x
+
+# add inherited proxy for sudo user
+LINE='Defaults env_keep += "ftp_proxy http_proxy https_proxy no_proxy"'
+FILE=/etc/sudoers
+grep -qF -- "$LINE" "$FILE" || sudo echo "$LINE" >> "$FILE"
+
+OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
+
+#set and check the environment for Linux
+if [ "$OS_ID" == "ubuntu" ]; then
+ export DEBIAN_FRONTEND=noninteractive
+ export DEBCONF_NONINTERACTIVE_SEEN=true
+
+ APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
+ sudo apt-get update ${APT_OPTS}
+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim pkg-config tcl libnl-route-3-200 flex graphviz tk debhelper dpatch gfortran ethtool libgfortran3 bison dkms quilt chrpath swig python-libxml2 unzip
+elif [ "$OS_ID" == "debian" ]; then
+ echo "not tested for debian and exit"
+ exit 1
+ export DEBIAN_FRONTEND=noninteractive
+ export DEBCONF_NONINTERACTIVE_SEEN=true
+
+ APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
+ sudo apt-get update ${APT_OPTS}
+ sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim
+elif [ "$OS_ID" == "centos" ]; then
+ sudo yum install -y deltarpm git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel libiverbs tk tcl tcsh redhat-lsb-core
+elif [ "$OS_ID" == "opensuse" ]; then
+ echo "not tested for opensuse and exit"
+ exit 1
+ sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel
+fi
diff --git a/scripts/build_dpdk.sh b/scripts/build_dpdk.sh
new file mode 100755
index 0000000..f631b27
--- /dev/null
+++ b/scripts/build_dpdk.sh
@@ -0,0 +1,63 @@
+#!/bin/bash -x
+
+set -x
+
+SCRIPT_DIR=`dirname $(readlink -f $0)`
+
+#DPDK download path
+#if any change kindly update DPDK_DOWNLOAD_PATH in DMM/stacks/lwip_stack/vagrant/start_nStackMain.sh
+DPDK_DOWNLOAD_PATH=/tmp/dpdk
+
+#dpdk installation path
+DPDK_INSTALL_PATH=/usr
+
+OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
+echo OS_ID: $OS_ID
+
+#DPDK will be having dependancy on linux headers
+if [ "$OS_ID" == "ubuntu" ]; then
+ sudo apt-get -y install git build-essential linux-headers-`uname -r`
+ sudo apt-get -y install libnuma-dev
+elif [ "$OS_ID" == "debian" ]; then
+ sudo apt-get -y install git build-essential linux-headers-`uname -r`
+elif [ "$OS_ID" == "centos" ]; then
+ sudo yum groupinstall -y "Development Tools"
+ sudo yum install -y kernel-headers
+ sudo yum install -y numactl-devel
+elif [ "$OS_ID" == "opensuse" ]; then
+ sudo yum groupinstall -y "Development Tools"
+ sudo yum install -y kernel-headers
+fi
+
+#===========build DPDK================
+
+if [ "$OS_ID" == "centos" ]; then
+ bash -x $SCRIPT_DIR/build_dpdk1802.sh || exit 1
+else
+
+ if [ ! -d /usr/include/dpdk ] || [ ! -d /usr/share/dpdk ] || [ ! -d /usr/lib/modules/4.4.0-31-generic/extra/dpdk ]; then
+ mkdir -p $DPDK_DOWNLOAD_PATH
+
+ cd $DPDK_DOWNLOAD_PATH
+ wget -N https://fast.dpdk.org/rel/dpdk-18.02.tar.xz --no-check-certificate
+ tar xvf dpdk-18.02.tar.xz
+ cd dpdk-18.02
+
+ sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base
+ sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base
+ sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base
+ sed -i 's!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1' config/common_base
+
+ sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -j 4
+
+ if [ $? -eq 0 ]; then
+ echo "DPDK build is SUCCESS"
+ else
+ echo "DPDK build has FAILED"
+ exit 1
+ fi
+
+ mkdir -p /tmp/dpdk/drivers/
+ cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/
+ fi
+fi
diff --git a/scripts/build_dpdk1802.sh b/scripts/build_dpdk1802.sh
index 1ed84bb..74d4860 100755
--- a/scripts/build_dpdk1802.sh
+++ b/scripts/build_dpdk1802.sh
@@ -62,18 +62,24 @@ sed -i '94a sed -ri '\''s!CONFIG_RTE_LIBRARY_PMD_KNI=.*!CONFIG_RTE_LIBRARY_PMD_K
sed -i '95a sed -ri '\''s!CONFIG_RTE_KNI_KMOD=.*!CONFIG_RTE_KNI_KMOD=n!1'\'' %{target}/.config' dpdk.spec
sed -i '96a sed -ri '\''s!CONFIG_RTE_KNI_PREEMPT_DEFAULT=.*!CONFIG_RTE_KNI_PREEMPT_DEFAULT=n!1'\'' %{target}/.config' dpdk.spec
+#Add debug info
+sed -i '98s!$! EXTRA_CFLAGS="-O0 -g" !' dpdk.spec
+
+#Not strip the debug info when generate the rpm
+sed -i '43 i%global __os_install_post %{nil}\n%define debug_package %{nil}' dpdk.spec
+
echo "build the dependence"
#sudo yum-builddep -y dpdk.spec
-sudo yum install -y libpcap-devel python-sphinx inkscape
+sudo yum install -y libpcap-devel python-sphinx inkscape kernel-devel-`uname -r` doxygen libnuma-devel kernel-`uname -r`
echo "generate the rpm package"
rpmbuild -ba dpdk.spec --define "_sourcedir ${PWD}"
if [ $? -eq 0 ]; then
- echo "rpm build success"
+ echo "dpdk rpm build success"
else
- echo "rpm build error"
- exit
+ echo "dpdk rpm build error"
+ exit 1
fi
echo "install the rpm"
@@ -83,5 +89,6 @@ sudo rpm -ivh dpdk-devel-18.02-1.x86_64.rpm || exit 1
mkdir -p /tmp/dpdk/drivers/
cp -f /usr/lib64/librte_mempool_ring.so /tmp/dpdk/drivers/
+cp -f /usr/share/dpdk/usertools/dpdk-devbind.py /usr/sbin/
cd ${cur_directory}
diff --git a/scripts/build_dpdk1805.sh b/scripts/build_dpdk1805.sh
index 805153b..2727877 100755
--- a/scripts/build_dpdk1805.sh
+++ b/scripts/build_dpdk1805.sh
@@ -59,16 +59,16 @@ sed -i '58a sed -i '\''s!CONFIG_RTE_LIBRTE_DPAA2_USE_PHYS_IOVA=.*!CONFIG_RTE_LIB
echo "build the dependence"
#sudo yum-builddep -y dpdk.spec
-sudo yum install -y libpcap-devel python-sphinx inkscape
+sudo yum install -y libpcap-devel python-sphinx inkscape kernel-devel-`uname -r` doxygen libnuma-devel kernel-`uname -r`
echo "generate the rpm package"
rpmbuild -ba dpdk.spec --define "_sourcedir ${PWD}"
if [ $? -eq 0 ]; then
- echo "rpm build success"
+ echo "dpdk rpm build success"
else
- echo "rpm build error"
- exit
+ echo "dpdk rpm build error"
+ exit 1
fi
echo "install the rpm"
diff --git a/scripts/build_rsocket.sh b/scripts/build_rsocket.sh
new file mode 100755
index 0000000..ef31c88
--- /dev/null
+++ b/scripts/build_rsocket.sh
@@ -0,0 +1,34 @@
+#!/bin/bash -x
+
+set -x
+
+OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
+
+DMM_DIR=`dirname $(readlink -f $0)`/../
+BUILD_DIR=${DMM_DIR}/build
+
+############### build rsocket
+echo "rsocket build start"
+cd $DMM_DIR/stacks/rsocket
+if [ "$OS_ID" == "ubuntu" ]; then
+ wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz
+ tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz
+ cd MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64
+elif [ "$OS_ID" == "centos" ]; then
+ CENT_VERSION=`grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release`
+ wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz
+ tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz
+ cd MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64
+fi
+
+sudo ./mlnxofedinstall --force || exit 1
+
+cd $BUILD_DIR
+make dmm_rsocket
+if [ $? -eq 0 ]; then
+ echo "rsocket build has SUCCESS"
+else
+ echo "rsocket build has FAILED"
+ exit 1
+fi
+echo "rsocket build finished" \ No newline at end of file
diff --git a/scripts/check_hugepage.sh b/scripts/check_hugepage.sh
new file mode 100755
index 0000000..bde11a9
--- /dev/null
+++ b/scripts/check_hugepage.sh
@@ -0,0 +1,41 @@
+#!/bin/bash -x
+
+set -x
+
+hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
+if [ "$hugepagesize" == "2048" ]; then
+ pages=1536
+elif [ "$hugepagesize" == "1048576" ]; then
+ pages=3
+fi
+sudo sysctl -w vm.nr_hugepages=$pages
+HUGEPAGES=`sysctl -n vm.nr_hugepages`
+if [ $HUGEPAGES != $pages ]; then
+ echo "ERROR: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
+ exit 1
+fi
+
+hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0")
+if [ $hugepageTotal -ne 0 ]; then
+ echo "HugePages_Total is zero"
+ exit 1
+fi
+
+hugepageFree=$(cat /proc/meminfo | grep -c "HugePages_Free: 0")
+if [ $hugepageFree -ne 0 ]; then
+ echo "HugePages_Free is zero"
+ exit 1
+fi
+
+hugepageSize=$(cat /proc/meminfo | grep -c "Hugepagesize: 0 kB")
+if [ $hugepageSize -ne 0 ]; then
+ echo "Hugepagesize is zero"
+ exit 1
+fi
+
+sudo mkdir /mnt/nstackhuge -p
+if [ "$hugepagesize" == "2048" ]; then
+ sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/
+elif [ "$hugepagesize" == "1048576" ]; then
+ sudo mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/
+fi
diff --git a/scripts/compile_dmm.sh b/scripts/compile_dmm.sh
new file mode 100644
index 0000000..c378bae
--- /dev/null
+++ b/scripts/compile_dmm.sh
@@ -0,0 +1,41 @@
+#!/bin/bash -x
+
+set -x
+
+BUILD_DIR=`dirname $(readlink -f $0)`/../build
+
+OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
+
+echo "DMM build started....."
+
+cd $BUILD_DIR
+rm -rf *
+cmake ..
+make -j 8
+
+if [ $? -eq 0 ]; then
+ echo "DMM build is SUCCESS"
+else
+ echo "DMM build has FAILED"
+ exit 1
+fi
+
+if [ "$OS_ID" == "centos" ]; then
+ make pkg-rpm
+ if [ $? -eq 0 ]; then
+ echo "DMM rpm build is SUCCESS"
+ else
+ echo "DMM rpm build has FAILED"
+ exit 1
+ fi
+elif [ "$OS_ID" == "ubuntu" ]; then
+ make pkg-deb
+ if [ $? -eq 0 ]; then
+ echo "DMM deb build is SUCCESS"
+ else
+ echo "DMM deb build has FAILED"
+ exit 1
+ fi
+fi
+
+echo "DMM build has FINISHED"
diff --git a/scripts/generate_dmm_rpm.sh b/scripts/generate_dmm_rpm.sh
index 792c2a3..76d65a1 100755
--- a/scripts/generate_dmm_rpm.sh
+++ b/scripts/generate_dmm_rpm.sh
@@ -17,7 +17,7 @@
cur_directory=${PWD}
name="dmm"
-version="18.04"
+version="18.07"
mkdir -p ~/rpmbuild/SOURCES
diff --git a/stacks/lwip_stack/vagrant/install_prereq.sh b/scripts/install_prereq.sh
index ae8d442..ae8d442 100644..100755
--- a/stacks/lwip_stack/vagrant/install_prereq.sh
+++ b/scripts/install_prereq.sh
diff --git a/scripts/prep_app_test.sh b/scripts/prep_app_test.sh
new file mode 100755
index 0000000..23bfa8b
--- /dev/null
+++ b/scripts/prep_app_test.sh
@@ -0,0 +1,80 @@
+#!/bin/bash
+
+set -x
+DMM_DIR=`dirname $(readlink -f $0)`/..
+LIB_PATH=$DMM_DIR/release/lib64/
+
+mkdir -p $DMM_DIR/config/app_test
+cd $DMM_DIR/config/app_test
+
+#===========check hugepages=================
+source $DMM_DIR/scripts/check_hugepage.sh
+
+echo -e "\e[41m Preapring APP test directory.....\e[0m"
+
+OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
+if [ "$OS_ID" == "ubuntu" ]; then
+ ifaddress1=$(ifconfig enp0s8 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
+ echo $ifaddress1
+ ifaddress2=$(ifconfig enp0s9 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')
+ echo $ifaddress2
+elif [ "$OS_ID" == "centos" ]; then
+ ifaddress1=$(ifconfig enp0s8 | grep 'inet' | cut -d: -f2 | awk '{print $2}')
+ echo $ifaddress1
+ ifaddress2=$(ifconfig enp0s9 | grep 'inet' | cut -d: -f2 | awk '{print $2}')
+ echo $ifaddress2
+fi
+
+echo '{
+ "default_stack_name": "kernel",
+ "module_list": [
+ {
+ "stack_name": "kernel",
+ "function_name": "kernel_stack_register",
+ "libname": "./",
+ "loadtype": "static",
+ "deploytype": "1",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "0",
+ },
+ ]
+}' | tee module_config.json
+
+echo '{
+ "ip_route": [
+ {
+ "subnet": "'$ifaddress1'/24",
+ "type": "nstack-kernel",
+ },
+ {
+ "subnet": "'$ifaddress2'/24",
+ "type": "nstack-kernel",
+ },
+ ],
+ "prot_route": [
+ {
+ "proto_type": "1",
+ "type": "nstack-kernel",
+ },
+ {
+ "proto_type": "2",
+ "type": "nstack-kernel",
+ }
+ ],
+}' | tee rd_config.json
+
+cp -r ${DMM_DIR}/release/lib64/* .
+cp -r ${DMM_DIR}/release/configure/* .
+cp -r ${DMM_DIR}/release/bin/* .
+chmod 775 *
+
+#disable ASLR, othewise it may have some problems when mapping memory for secondary process
+echo 0 > /proc/sys/kernel/randomize_va_space
+
+sudo mkdir -p /var/run/ip_module/
+sudo mkdir -p /var/log/nStack/ip_module/
+
+export LD_LIBRARY_PATH=$LIB_PATH
+export NSTACK_LOG_ON=DBG \ No newline at end of file
diff --git a/scripts/print_os_info.sh b/scripts/print_os_info.sh
new file mode 100755
index 0000000..4d61c7b
--- /dev/null
+++ b/scripts/print_os_info.sh
@@ -0,0 +1,17 @@
+#!/bin/bash -x
+
+set -x
+
+OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
+OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
+KERNEL_OS=`uname -o`
+KERNEL_MACHINE=`uname -m`
+KERNEL_RELEASE=`uname -r`
+KERNEL_VERSION=`uname -v`
+
+echo KERNEL_OS: $KERNEL_OS
+echo KERNEL_MACHINE: $KERNEL_MACHINE
+echo KERNEL_RELEASE: $KERNEL_RELEASE
+echo KERNEL_VERSION: $KERNEL_VERSION
+echo OS_ID: $OS_ID
+echo OS_VERSION_ID: $OS_VERSION_ID
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c71659c..1069e7f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -42,7 +42,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-z,noexecstack -mcmodel=medium")
SET(COMPLE_CONFIG ${PROJECT_SOURCE_DIR}/src/framework/common/include/compile_config.h)
ADD_DEFINITIONS(-include ${COMM_CONFIG})
ADD_DEFINITIONS(-include ${COMPLE_CONFIG})
-ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.04")
+ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.07")
#LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
if(WITH_SECUREC_LIB)
diff --git a/src/adapt/nstack_dmm_adpt.c b/src/adapt/nstack_dmm_adpt.c
index 652d0e2..d497b80 100644
--- a/src/adapt/nstack_dmm_adpt.c
+++ b/src/adapt/nstack_dmm_adpt.c
@@ -98,7 +98,7 @@ nstack_event_callback (void *pdata, int events)
ep_hlist_add_tail (&ep->rdlist, &epi->rdllink);
sem_post (&ep->waitSem);
}
- epi->revents |= events;
+ epi->revents |= (epi->event.events & events);
out_unlock:
sys_sem_s_signal (&ep->lock);
}
diff --git a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c
index 08ad4cd..ba38c32 100644
--- a/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c
+++ b/src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c
@@ -73,11 +73,7 @@ nsfw_shmem_init (nsfw_mem_para * para)
NSCOMM_LOGINF ("nsfw shmem init begin");
- if (NSFW_PROC_MASTER == para->enflag)
- {
- iret = common_mem_pal_init (para->iargsnum, para->pargs);
- }
- else if (NSFW_PROC_MAIN == para->enflag)
+ if (NSFW_PROC_MAIN == para->enflag)
{
iret = common_pal_module_init (NULL, app_mode);
}
@@ -189,11 +185,7 @@ nsfw_shmem_createv (nsfw_mem_zone * pmeminfo, i32 inum,
{
NSFW_INIT_CHK_RET ();
- if (NSFW_PROC_MASTER == NSFW_SHMEM_FLAG)
- {
- return NSFW_MEM_ERR;
- }
- else if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
+ if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
{
return nsfw_memzone_remote_reserv_v (pmeminfo, paddr_array, iarray_num,
0);
@@ -321,11 +313,7 @@ nsfw_shmem_mbfmpcreatev (nsfw_mem_mbfpool * pmbfname, i32 inum,
{
NSFW_INIT_CHK_RET ();
- if (NSFW_PROC_MASTER == NSFW_SHMEM_FLAG)
- {
- return NSFW_MEM_ERR;
- }
- else if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
+ if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
{
return nsfw_remote_shmem_mbf_createv (pmbfname, phandle_array,
iarray_num, 0);
@@ -431,11 +419,7 @@ nsfw_shmem_spcreatev (nsfw_mem_sppool * pmpinfo, i32 inum,
{
NSFW_INIT_CHK_RET ();
- if (NSFW_PROC_MASTER == NSFW_SHMEM_FLAG)
- {
- return NSFW_MEM_ERR;
- }
- else if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
+ if (NSFW_PROC_MAIN == NSFW_SHMEM_FLAG)
{
return nsfw_remote_shmem_mpcreatev (pmpinfo, pringhandle_array, inum,
0);
diff --git a/src/framework/ipc/mgr_com/mgr_com.c b/src/framework/ipc/mgr_com/mgr_com.c
index bc2aca2..2fb9789 100644
--- a/src/framework/ipc/mgr_com/mgr_com.c
+++ b/src/framework/ipc/mgr_com/mgr_com.c
@@ -423,9 +423,6 @@ nsfw_mgr_get_connect_socket (u8 proc_type, u32 host_pid)
case NSFW_PROC_MAIN:
name = NSFW_MAIN_FILE;
break;
- case NSFW_PROC_MASTER:
- name = NSFW_MASTER_FILE;
- break;
case NSFW_PROC_ALARM:
directory = "/tmp";
name = NSFW_ALARM_FILE;
@@ -1930,27 +1927,7 @@ nsfw_mgr_com_module_init (void *param)
}
break;
- case NSFW_PROC_MASTER:
- /* modify destMax, remove "-1" */
- if (EOK !=
- STRCPY_S (mgr_cfg->domain_path, NSFW_MGRCOM_PATH_LEN, directory))
- {
- NSFW_LOGERR ("module mgr init STRCPY_S failed!");
- lint_unlock_1 ();
- return -1;
- }
- NSFW_LOGINF ("module mgr init]NSFW_PROC_MASTER domain_path=%s",
- mgr_cfg->domain_path);
-
- if (TRUE != nsfw_mgr_com_start ())
- {
- NSFW_LOGERR ("module mgr nsfw_mgr_com_start failed!");
- lint_unlock_1 ();
- return -1;
- }
-
- break;
case NSFW_PROC_TOOLS:
break;
case NSFW_PROC_CTRL:
diff --git a/src/framework/ipc/ps/nsfw_fd_timer.c b/src/framework/ipc/ps/nsfw_fd_timer.c
index 55d35cb..cea2486 100644
--- a/src/framework/ipc/ps/nsfw_fd_timer.c
+++ b/src/framework/ipc/ps/nsfw_fd_timer.c
@@ -322,7 +322,6 @@ nsfw_timer_module_init (void *param)
NSFW_LOGINF ("ps module init]type=%u", proc_type);
switch (proc_type)
{
- case NSFW_PROC_MASTER:
case NSFW_PROC_MAIN:
(void) NSFW_REG_SOFT_INT (NSFW_DBG_MODE_PARAM, g_hbt_switch, 0, 1);
break;
diff --git a/src/framework/ipc/ps/nsfw_ps_module.c b/src/framework/ipc/ps/nsfw_ps_module.c
index e600bf7..6e03e11 100644
--- a/src/framework/ipc/ps/nsfw_ps_module.c
+++ b/src/framework/ipc/ps/nsfw_ps_module.c
@@ -468,7 +468,7 @@ u8
nsfw_ps_exit_end_notify (u32 pid)
{
nsfw_mgr_msg *rsp_msg =
- nsfw_mgr_msg_alloc (MGR_MSG_APP_EXIT_RSP, NSFW_PROC_MASTER);
+ nsfw_mgr_msg_alloc (MGR_MSG_APP_EXIT_RSP, NSFW_PROC_MAIN);
if (NULL == rsp_msg)
{
NSFW_LOGERR ("alloc rsp msg failed]pid=%u", pid);
@@ -1590,42 +1590,6 @@ nsfw_ps_module_init (void *param)
switch (proc_type)
{
- case NSFW_PROC_MASTER:
- {
- (void) nsfw_mgr_reg_msg_fun (MGR_MSG_CHK_HBT_RSP,
- nsfw_ps_recv_hbt_rsp);
- (void) NSFW_REG_SOFT_INT (NSFW_HBT_TIMER, NSFW_CHK_HBT_TVLAUE, 1,
- 0xFFFF);
- (void) NSFW_REG_SOFT_INT (NSFW_HBT_COUNT_PARAM,
- NSFW_SOFT_HBT_CHK_COUNT, 1, 0xFFFF);
- (void) NSFW_REG_SOFT_INT (NSFW_APP_EXIT_TIMER, NSFW_PS_WEXIT_TVLAUE,
- 1, 0xFFFF);
-
- pid_info = nsfw_mem_zone_lookup (&pzoneinfo.stname);
- if (NULL == pid_info)
- {
- pid_info = nsfw_mem_zone_create (&pzoneinfo);
- if (NULL == pid_info)
- {
- NSFW_LOGERR ("alloc rec nul!");
- return -1;
- }
-
- retval =
- MEMSET_S (pid_info, (sizeof (nsfw_pid_item) * NSFW_MAX_PID),
- 0, (sizeof (nsfw_pid_item) * NSFW_MAX_PID));
- if (EOK != retval)
- {
- NSFW_LOGERR ("MEMSET_S failed]retval=%d.\n", retval);
- return -1;
- }
- }
-
- MEM_STAT (NSFW_PS_MODULE, pzoneinfo.stname.aname, NSFW_SHMEM,
- pzoneinfo.length);
- g_ps_info = pid_info;
- break;
- }
case NSFW_PROC_MAIN:
{
pid_info = malloc (sizeof (nsfw_pid_item) * NSFW_MAX_PID);
@@ -1693,7 +1657,7 @@ nsfw_ps_module_init (void *param)
MEM_STAT (NSFW_PS_MODULE, pmpinfo.stname.aname, NSFW_NSHMEM,
nsfw_mem_get_len (ps_cfg->ps_info_pool, NSFW_MEM_SPOOL));
- if (NSFW_PROC_MASTER != proc_type)
+ if (NSFW_PROC_MAIN != proc_type)
{
return 0;
}
diff --git a/src/framework/ipc/ps/nsfw_recycle_module.c b/src/framework/ipc/ps/nsfw_recycle_module.c
index 541581f..01e16fb 100644
--- a/src/framework/ipc/ps/nsfw_recycle_module.c
+++ b/src/framework/ipc/ps/nsfw_recycle_module.c
@@ -607,8 +607,6 @@ nsfw_recycle_module_init (void *param)
g_rec_cfg.rec_waite_end_tvalue = NSFW_REC_WEND_TVLAUE_DEF;
switch (proc_type)
{
- case NSFW_PROC_MASTER:
- return 0;
case NSFW_PROC_MAIN:
(void) nsfw_mgr_reg_msg_fun (MGR_MSG_APP_EXIT_REQ, mem_app_exit_proc);
(void) nsfw_mgr_reg_msg_fun (MGR_MSG_RCC_END_REQ,
@@ -644,7 +642,6 @@ nsfw_recycle_fork_init ()
{
/* reconnect to master after fork in child proc */
nsfw_mgr_close_dst_proc (NSFW_PROC_MAIN, 0);
- nsfw_mgr_close_dst_proc (NSFW_PROC_MASTER, 0);
if (0 == nsfw_recycle_module_init ((void *) ((long long) NSFW_PROC_APP)))
{
return TRUE;
diff --git a/src/framework/ipc/ps/nsfw_soft_param.c b/src/framework/ipc/ps/nsfw_soft_param.c
index 91d7598..743276f 100644
--- a/src/framework/ipc/ps/nsfw_soft_param.c
+++ b/src/framework/ipc/ps/nsfw_soft_param.c
@@ -270,7 +270,6 @@ nsfw_softparam_module_init (void *param)
switch (proc_type)
{
case NSFW_PROC_MAIN:
- case NSFW_PROC_MASTER:
(void) nsfw_mgr_reg_msg_fun (MGR_MSG_SOF_PAR_REQ,
nsfw_softparam_msg_proc);
return 0;
diff --git a/src/framework/log/nsfw_set_log.c b/src/framework/log/nsfw_set_log.c
index 7ef6f37..31241b5 100644
--- a/src/framework/log/nsfw_set_log.c
+++ b/src/framework/log/nsfw_set_log.c
@@ -199,7 +199,6 @@ nsfw_cfg_module_init (void *param)
switch (proc_type)
{
case NSFW_PROC_MAIN:
- case NSFW_PROC_MASTER:
(void) nsfw_mgr_reg_msg_fun (MGR_MSG_SET_LOG_REQ,
nsfw_set_log_msg_proc);
g_log_cfg.proc_type = proc_type;
diff --git a/src/nSocket/include/nstack_dmm_api.h b/src/nSocket/include/nstack_dmm_api.h
index dff69f3..ab06650 100644
--- a/src/nSocket/include/nstack_dmm_api.h
+++ b/src/nSocket/include/nstack_dmm_api.h
@@ -57,6 +57,7 @@ typedef enum
typedef struct __nstack_extern_ops
{
int (*module_init) (void); /*stack module init */
+ int (*module_init_child) (void); /*stack module init for child process */
int (*fork_init_child) (pid_t p, pid_t c); /*after fork, stack child process init again if needed. */
void (*fork_parent_fd) (int s, pid_t p); /*after fork, stack parent process proc again if needed. */
void (*fork_child_fd) (int s, pid_t p, pid_t c); /*after fork, child record pid for recycle if needed. */
diff --git a/src/nSocket/include/nstack_select.h b/src/nSocket/include/nstack_select.h
index 5c84846..659c477 100644
--- a/src/nSocket/include/nstack_select.h
+++ b/src/nSocket/include/nstack_select.h
@@ -141,6 +141,8 @@ extern i32 select_add_cb (struct select_entry *entry);
extern i32 select_rm_cb (struct select_entry *entry);
extern i32 select_entry_reset (struct select_entry *entry);
extern i32 select_module_init ();
+extern i32 select_module_init_child ();
+
extern struct select_module_info *get_select_module (void);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/nSocket/kernel/linux_kernel_module.c b/src/nSocket/kernel/linux_kernel_module.c
index 6a262d0..eb3dd8d 100644
--- a/src/nSocket/kernel/linux_kernel_module.c
+++ b/src/nSocket/kernel/linux_kernel_module.c
@@ -324,6 +324,7 @@ kernel_stack_register (nstack_proc_cb * ops, nstack_event_cb * val)
ops->extern_ops.ep_ctl = kernel_ep_fd_add;
ops->extern_ops.ep_prewait_proc = kernel_prewait_proc;
ops->extern_ops.module_init = kernel_module_init;
+ ops->extern_ops.module_init_child = kernel_module_init;
ops->extern_ops.stack_alloc_fd = kernel_fd_alloc;
/* don't close file descriptor */
diff --git a/src/nSocket/nstack/event/select/nstack_select.c b/src/nSocket/nstack/event/select/nstack_select.c
index ba64cff..930f1db 100644
--- a/src/nSocket/nstack/event/select/nstack_select.c
+++ b/src/nSocket/nstack/event/select/nstack_select.c
@@ -753,4 +753,26 @@ nssct_set_index (i32 fd, i32 inx)
select_set_index (fd, inx);
}
+i32
+select_module_init_child ()
+{
+ pthread_t select_thread_id;
+ i32 retval;
+
+ if (pthread_create (&select_thread_id, NULL, nstack_select_thread, NULL))
+ {
+ goto ERR_RET;
+ }
+
+ retval = pthread_setname_np (select_thread_id, "nstack_select_child");
+ if (retval)
+ {
+ /*set thread name failed */
+ }
+ return TRUE;
+
+ERR_RET:
+ return FALSE;
+}
+
#endif /* NSTACK_SELECT_MODULE */
diff --git a/src/nSocket/nstack/nstack.c b/src/nSocket/nstack/nstack.c
index 707cb49..4198266 100644
--- a/src/nSocket/nstack/nstack.c
+++ b/src/nSocket/nstack/nstack.c
@@ -29,6 +29,7 @@
#include "nstack_share_res.h"
#include "nsfw_mgr_com_api.h"
#include "nsfw_ps_mem_api.h"
+#include "nsfw_fd_timer_api.h"
#include "nsfw_ps_api.h"
#include "nsfw_recycle_api.h"
#include "nstack_fd_mng.h"
@@ -587,7 +588,7 @@ nstack_for_epoll_init ()
NSSOC_LOGINF ("fork]g_nStackInfo.pid=%u,getpid=%d", g_nStackInfo.pid,
getpid ());
- nstack_stack_module_init();
+ nstack_stack_module_init_child();
}
return 0;
}
@@ -788,6 +789,7 @@ nstack_fw_init ()
stinfo.enflag = (fw_poc_type)proc_type;
nstack_framework_setModuleParam(NSFW_MEM_MGR_MODULE, (void*)&stinfo);
nstack_framework_setModuleParam(NSFW_MGR_COM_MODULE, (void*) ((long long)proc_type));
+ nstack_framework_setModuleParam(NSFW_TIMER_MODULE, (void*) ((long long)proc_type));
nstack_framework_setModuleParam(NSFW_PS_MODULE, (void*) ((long long)proc_type));
nstack_framework_setModuleParam(NSFW_PS_MEM_MODULE, (void*) ((long long)proc_type));
nstack_framework_setModuleParam(NSFW_RECYCLE_MODULE, (void*) ((long long)proc_type));
diff --git a/src/nSocket/nstack/nstack_module.c b/src/nSocket/nstack/nstack_module.c
index bef91e5..9566ab8 100644
--- a/src/nSocket/nstack/nstack_module.c
+++ b/src/nSocket/nstack/nstack_module.c
@@ -265,3 +265,23 @@ nstack_stack_module_init ()
}
return 0;
}
+
+int
+nstack_stack_module_init_child ()
+{
+ ns_uint32 idx;
+ for (idx = 0; idx < g_module_num; idx++)
+ {
+ if (g_nstack_modules.modules[idx].mops.extern_ops.module_init_child)
+ {
+ if (0 !=
+ g_nstack_modules.modules[idx].mops.
+ extern_ops.module_init_child ())
+ {
+ NSSOC_LOGERR ("nstack[%s] modx:%d init child fail",
+ g_nstack_modules.modules[idx].modulename, idx);
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/nSocket/nstack/nstack_module.h b/src/nSocket/nstack/nstack_module.h
index e0105af..ec81ac1 100644
--- a/src/nSocket/nstack/nstack_module.h
+++ b/src/nSocket/nstack/nstack_module.h
@@ -135,6 +135,7 @@ extern nstack_module_keys g_nstack_module_desc[];
for ((modInx) = 0; ((modInx) < nstack_get_modNum() && (pMod = nstack_get_module((modInx)))); (modInx)++)
int nstack_stack_module_init ();
+int nstack_stack_module_init_child ();
int nstack_get_deploy_type ();
diff --git a/src/nSocket/nstack/nstack_socket.c b/src/nSocket/nstack/nstack_socket.c
index e3da248..cd1557b 100644
--- a/src/nSocket/nstack/nstack_socket.c
+++ b/src/nSocket/nstack/nstack_socket.c
@@ -2775,6 +2775,8 @@ nstack_fork (void)
dmm_spinlock_lock_with_pid (nstack_get_fork_share_lock (),
get_sys_pid ());
nsep_fork_child_proc (parent_pid);
+
+ (void) select_module_init_child ();
common_mem_spinlock_unlock (nstack_get_fork_share_lock ());
}
else if (pid > 0)
diff --git a/src/nSocket/nstack_rd/nstack_rd.c b/src/nSocket/nstack_rd/nstack_rd.c
index eb38bca..cdcb92d 100644
--- a/src/nSocket/nstack_rd/nstack_rd.c
+++ b/src/nSocket/nstack_rd/nstack_rd.c
@@ -189,7 +189,7 @@ nstack_rd_sys_default ()
/*get the protocol default route */
(void) MEMSET_S (&item, sizeof (item), 0, sizeof (item));
for (icnt = 0;
- icnt < sizeof (g_default_protcol) / sizeof (rd_data_defaut_ip); icnt++)
+ icnt < sizeof (g_default_protcol) / sizeof (rd_data_defaut_protocol); icnt++)
{
pprotodata = &g_default_protcol[icnt];
for (iindex = 0; iindex < g_rd_map_num; iindex++)
diff --git a/stacks/lwip_stack/CMakeLists.txt b/stacks/lwip_stack/CMakeLists.txt
index 9f64af9..297d2d9 100644
--- a/stacks/lwip_stack/CMakeLists.txt
+++ b/stacks/lwip_stack/CMakeLists.txt
@@ -61,15 +61,13 @@ execute_process(
COMMAND cp -rf ${CMAKE_CURRENT_LIST_DIR}/../../release/include ${CMAKE_CURRENT_LIST_DIR}/src/
COMMAND cp ${CMAKE_CURRENT_LIST_DIR}/../../release/lib64/libnStackAPI.so ${CMAKE_CURRENT_LIST_DIR}/release/lib64/
COMMAND cp ${CMAKE_CURRENT_LIST_DIR}/../../release/lib64/libdmm_api.so ${CMAKE_CURRENT_LIST_DIR}/release/lib64/
- COMMAND cp ${CMAKE_CURRENT_LIST_DIR}/../../build/libnStackMaintain.a ${CMAKE_CURRENT_LIST_DIR}/release/lib64/
- COMMAND cp ${CMAKE_CURRENT_LIST_DIR}/../../build/libsocket.a ${CMAKE_CURRENT_LIST_DIR}/build/
COMMAND echo "stacklwip prepare ok"
)
execute_process(
COMMAND sh ${CMAKE_CURRENT_LIST_DIR}/release/lwip_helper_files/download_lwip.sh
)
-ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.04")
+ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.07")
SET(JSON_C_SRC ${CMAKE_CURRENT_LIST_DIR}/../../thirdparty/json/json-c-0.12.1)
INCLUDE(ExternalProject)
diff --git a/stacks/lwip_stack/doc/README.md b/stacks/lwip_stack/doc/README.md
new file mode 100644
index 0000000..e9bb31e
--- /dev/null
+++ b/stacks/lwip_stack/doc/README.md
@@ -0,0 +1,120 @@
+# 1. What is lwIP
+lwIP is a light-weight implementation of the TCP/IP protocol suite.
+lwIP is freely available (under a BSD-style license) in C source
+code format and can be downloaded from the development homepage.
+The focus of the lwIP TCP/IP implementation is to reduce the RAM
+usage while still having a full scale TCP.
+
+# 2. How to use lwIP
+
+## How to integrate lwIP into DMM
+The file CMakeList.txt defined the compiling process, including downloading
+the lwip 2.7.0 code and pushing the helper files into it, or modify
+lwip files.
+
+Currently lwip will not be build as separate lib, instead it'll be part
+of the excutable namely "nStackMain".
+lwip Stack will run in pipeline mode. Application will run in one process
+and lwip will run as "nStackMain" process. Below picture depicts
+a birds eye view of lwip in DMM pipeline mode.
+![Lwip in DMM framework](dmm_lwip.png)
+
+## Compile
+```sh
+ #cd dmm/build && cmake ..
+ #make
+ #cd ../stacks/lwip_stack/build && cmake ..
+ #make
+```
+
+## Test
+- Steps 1: update some environment variables
+```sh
+ #export LD_LIBRARY_PATH=${dmm}/stacks/lwip_stack/release/lib64/
+ #export LD_PRELOAD=${dmm}/release/lib64/libnStackAPI.so
+ #export NSTACK_MOD_CFG_FILE=${dmm}/stacks/lwip_stack/app_conf/module_config.json
+ #export NSTACK_MOD_CFG_RD=${dmm}/stacks/lwip_stack/app_conf/rd_config.json
+ #export NSTACK_LOG_ON=DBG (optional enable debug)
+```
+- Steps 2: Modify rd_config.json(located at dmm/stacks/lwip_stack/app_config/)
+```sh
+ #vim rd_config.json
+ Eg. set "subnet": "192.168.21.1/24"
+```
+Note:
+ Means dmm chose lwip_stack if subnet matches 192.168.21.*
+
+- Steps 3: Run nStackMain(lwip stack))
+```sh
+ #cp ${dmm}/stacks/lwip_stack/release/configure/ip_data.json ${dmm}/stacks/lwip_stack/release/bin/
+ #cp ${dmm}/stacks/lwip_stack/release/configure/network_data_tonStack.json ${dmm}/stacks/lwip_stack/release/bin/
+
+```
+Modify ip_data.json
+```
+Change ref_nic => to interface name which you want to use
+Change ip_cidr => ip address you want to use.
+```
+Modify network network_data_tonStack.json
+```
+Change ref_nic => to interface name which you want to use
+Change subnet => Subnet (ip_cidr belongs to this subnet)
+Change gateway, range-start, range-end, dst, gw accordingly. This information will be used by DMM to configure network.
+```
+Run the process:
+```
+ #cd ${dmm}/stacks/lwip_stack/release
+ #./start_nstack.sh
+```
+
+- Steps 4: Communication test between machine A(as server) with machine B
+ (as client)
+
+##### Run in machine A
+```sh
+ #./dmm/release/bin/vs_epoll -p 20000 -d 192.168.21.180 -a 10000 -s 192.168.21.181 -l 1000 -t 500000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 50000 -e 10 -x 1
+```
+Note:
+ Means the current machine would be server, and it's
+destination address is 192.168.21.180 (client address),
+source address is 192.168.21.181(server address)
+
+##### Run in machine B
+```
+ #./dmm/release/bin/vc_common -p 20000 -d 192.168.21.181 -a 10000 -s 192.168.21.180 -l 1000 -t 500000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 50000 -e 10 -x 1
+```
+Note:
+ Means the current machine would be client, and it's
+destination address is 192.168.21.181 (server address),
+source address is 192.168.21.180(client address)
+
+# 3. Document description
+
+(dmm/stacks/lwip_stack/doc)
+
+## CMakeLists.txt
+Control file for Cmake compiling.
+
+## config folder
+##### module_config.json
+- module_config.json is for configuring dmm protocol stack module.
+
+##### rd_config.json
+- rd_config.json is to choose which module is better to go through, if subnet matches, It will go through lwip protocol stack when RD type is nstack-dpdk
+
+## lwip helper files.
+lwip helper files is implmentation and modification of some supportive functions to run lwip with dmm.
+
+## lwip_stack/src folder
+
+- Implmetation of nStackMain process which provides the framework to hold lwip stack.
+
+## lwip_stack/lwip_src
+- Downloaded opensource lwip 2.7.0. code.
+
+# 4. More Information
+https://wiki.fd.io/view/DMM
+https://savannah.nongnu.org/projects/lwip/
+http://lwip.wikia.com/wiki/LwIP_Wiki
+[DMM_DeveloperManual.md](../../doc/DMM_DeveloperManual.md)
+
diff --git a/stacks/lwip_stack/doc/dmm_lwip.png b/stacks/lwip_stack/doc/dmm_lwip.png
new file mode 100644
index 0000000..403eed3
--- /dev/null
+++ b/stacks/lwip_stack/doc/dmm_lwip.png
Binary files differ
diff --git a/stacks/lwip_stack/lwip_src/api/spl_api_msg.c b/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
index 9ba1e92..1c9bf92 100644
--- a/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
+++ b/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
@@ -414,7 +414,7 @@ spl_recv_udp (void *arg, struct udp_pcb *pcb, struct pbuf *p,
{
struct spl_netbuf *buf;
spl_netconn_t *conn = (spl_netconn_t *) arg;
- struct spl_pbuf *spb = NULL; //??
+ struct spl_pbuf *spl_pb = NULL; //??
if (NULL == pcb)
{
@@ -432,12 +432,28 @@ spl_recv_udp (void *arg, struct udp_pcb *pcb, struct pbuf *p,
/* //@TODO: malloc and Copy splbuf */
struct common_pcb *cpcb = (struct common_pcb *) (conn->comm_pcb_data);
- buf = (struct spl_netbuf *) ((char *) p + sizeof (struct spl_pbuf));
- buf->p = spb;
+ u16_t proc_id = spl_get_lcore_id ();
+
+ spl_pb = spl_pbuf_alloc_hugepage (SPL_PBUF_TRANSPORT,
+ p->tot_len +
+ g_offSetArry[SPL_PBUF_TRANSPORT],
+ SPL_PBUF_HUGE, proc_id, conn);
+
+ if (!spl_pb)
+ {
+ NSPOL_LOGINF (TCP_DEBUG, "spl_pbuf_alloc_hugepage Failed!!!");
+ return;
+ }
+
+ pbuf_to_splpbuf_copy (spl_pb, p);
+ pbuf_free (p);
+
+ buf = (struct spl_netbuf *) ((char *) spl_pb + sizeof (struct spl_pbuf));
+ buf->p = spl_pb;
spl_ip_addr_set (&buf->addr, ipaddr);
buf->port = port;
- err_t ret = sp_enqueue (cpcb, (void *) p);
+ err_t ret = sp_enqueue (cpcb, (void *) spl_pb);
if (ret != ERR_OK)
{
NSPOL_LOGDBG (UDP_DEBUG, "mbox post failed");
@@ -1808,6 +1824,56 @@ do_listen (struct common_pcb *cpcb, msg_listen * lmsg)
}
/**
+ * Send some data on UDP pcb contained in a netconn
+ * Called from do_send
+ *
+ * @param msg the api_msg_msg pointing to the connection
+ */
+void
+spl_udp_send (struct common_pcb *cpcb, msg_send_buf * smsg)
+{
+ struct spl_pbuf *p_from = smsg->p;
+ spl_netconn_t *conn = cpcb->conn;
+ struct udp_pcb *upcb = (struct udp_pcb *) (cpcb->conn->private_data);
+ data_com_msg *m = MSG_ENTRY (smsg, data_com_msg, buffer);
+ struct pbuf *p_to = NULL;
+ err_t err = ERR_OK;
+
+ //allocate pbuf and copy spl_pbuf, send , free pbuf and spl_pbuf
+ do
+ {
+ p_to = pbuf_alloc (PBUF_TRANSPORT, p_from->len, PBUF_RAM);
+ if (NULL == p_to)
+ {
+ NSPOL_LOGERR ("pbuf is NULL]conn=%p,pcb=%p", conn, upcb);
+ return;
+ }
+
+ err = splpbuf_to_pbuf_transport_copy (p_to, p_from);
+ if (err != ERR_OK)
+ {
+ SET_MSG_ERR (m, conn->last_err);
+ return;
+ }
+
+ if (ip_addr_isany (&smsg->addr))
+ {
+ SET_MSG_ERR (m, udp_send (upcb, p_to));
+ }
+ else
+ {
+ SET_MSG_ERR (m,
+ udp_sendto (upcb, p_to, (ip_addr_t *) & smsg->addr,
+ smsg->port));
+ }
+
+ p_from = (struct spl_pbuf *) ADDR_SHTOL (p_from->next_a);
+ }
+ while (p_from != NULL);
+
+}
+
+/**
* Send some data on a RAW or UDP pcb contained in a netconn
* Called from netconn_send
*
@@ -1825,8 +1891,8 @@ do_send (struct common_pcb *cpcb, msg_send_buf * smsg)
if (SPL_ERR_IS_FATAL (conn->last_err))
{
SET_MSG_ERR (m, conn->last_err);
- spl_pbuf_free (p);
- return;
+ NSPOL_LOGERR ("Invalid param]msg->conn=%p", conn);
+ goto err_return;
}
switch (SPL_NETCONNTYPE_GROUP (cpcb->type))
@@ -1840,20 +1906,8 @@ do_send (struct common_pcb *cpcb, msg_send_buf * smsg)
ss_set_local_ip (conn, smsg->local_ip.addr);
}
- //spl_ip_addr_t *destIP = &smsg->addr;
+ spl_udp_send (cpcb, smsg);
- //@TODO udp send need to update like TCP. copy pbuf here. Once testing done for TCP we'll update it here.
- if (ip_addr_isany (&smsg->addr))
- {
- //SET_MSG_ERR(m, udp_send(upcb, p));
- /* destIP.addr == IPADDR_ANY means it is from stackx_send
- and the destination is stored in remote_ip and remote port */
- //destIP = &upcb->remote_ip;
- }
- else
- {
- //SET_MSG_ERR(m, udp_sendto(upcb, p, &smsg->addr, smsg->port));
- }
break;
}
@@ -1862,6 +1916,10 @@ do_send (struct common_pcb *cpcb, msg_send_buf * smsg)
break;
}
+err_return:
+ pbuf_free_safe (smsg->p);
+ ASYNC_MSG_FREE (m);
+
return;
}
@@ -3186,9 +3244,12 @@ update_tcp_state (spl_netconn_t * conn, enum tcp_state state)
spl_state = SPL_CLOSED;
break;
}
- conn->tcp_state = spl_state;
- NSTCP_LOGINF ("conn=%p,private_data=%p,state=%d", conn,
- conn->private_data, spl_state);
+ if (conn->tcp_state != spl_state)
+ {
+ conn->tcp_state = spl_state;
+ NSTCP_LOGINF ("conn=%p,private_data=%p,state=%d", conn,
+ conn->private_data, spl_state);
+ }
}
}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_spl_share.h b/stacks/lwip_stack/lwip_src/common/stackx_spl_share.h
index 3b0c9f9..2d35dd0 100644
--- a/stacks/lwip_stack/lwip_src/common/stackx_spl_share.h
+++ b/stacks/lwip_stack/lwip_src/common/stackx_spl_share.h
@@ -431,11 +431,23 @@ ss_set_is_listen_conn (spl_netconn_t * sh, i8 is_listen_conn)
}
static inline i32
+ss_inc_fork_ref (spl_netconn_t * sh)
+{
+ return __sync_add_and_fetch (&sh->recycle.fork_ref, 1);
+}
+
+static inline i32
ss_dec_fork_ref (spl_netconn_t * sh)
{
return __sync_sub_and_fetch (&sh->recycle.fork_ref, 1);
}
+static inline i32
+ss_get_fork_ref (spl_netconn_t * sh)
+{
+ return sh->recycle.fork_ref;
+}
+
static inline int
ss_add_pid (spl_netconn_t * sh, pid_t pid)
{
diff --git a/stacks/lwip_stack/lwip_src/core/spl_pbuf.c b/stacks/lwip_stack/lwip_src/core/spl_pbuf.c
index 03e30ed..54589e8 100644
--- a/stacks/lwip_stack/lwip_src/core/spl_pbuf.c
+++ b/stacks/lwip_stack/lwip_src/core/spl_pbuf.c
@@ -369,6 +369,20 @@ spl_pbuf_copy (struct spl_pbuf * p_to, struct spl_pbuf * p_from)
}
err_t
+splpbuf_to_pbuf_transport_copy (struct pbuf * p_to, struct spl_pbuf * p_from)
+{
+ if (EOK != MEMMOVE_S ((u8_t *) p_to->payload,
+ p_to->len, (u8_t *) ADDR_SHTOL (p_from->payload_a),
+ p_from->len))
+ {
+ NSPOL_LOGERR ("MEMMOVE_S failed");
+ return ERR_MEM;
+ }
+
+ return ERR_OK;
+}
+
+err_t
splpbuf_to_pbuf_copy (struct pbuf * p_to, struct spl_pbuf * p_from)
{
u32_t offset_to = 0;
diff --git a/stacks/lwip_stack/lwip_src/core/spl_timers.c b/stacks/lwip_stack/lwip_src/core/spl_timers.c
index 50582fc..cfa130b 100644
--- a/stacks/lwip_stack/lwip_src/core/spl_timers.c
+++ b/stacks/lwip_stack/lwip_src/core/spl_timers.c
@@ -283,7 +283,6 @@ deal_timeout_sig (void)
int retval;
if (ptimer.first == NULL)
{
- NSPOL_LOGERR ("ptimer.first=NULL!!");
return;
}
tmo = rb_entry (ptimer.first, struct ptimer_node, node);
diff --git a/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h b/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h
index 01fe242..79deace 100644
--- a/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h
+++ b/stacks/lwip_stack/lwip_src/include/stackx/spl_pbuf.h
@@ -48,6 +48,9 @@ struct spl_pbuf *spl_pbuf_alloc_hugepage (spl_pbuf_layer l, u16_t length,
spl_pbuf_type type,
u16_t thread_index, void *net_conn);
struct pbuf *spl_convert_spl_pbuf_to_pbuf (struct spl_pbuf *p_from);
+err_t
+splpbuf_to_pbuf_transport_copy (struct pbuf *p_to, struct spl_pbuf *p_from);
+
err_t pbuf_to_splpbuf_copy (struct spl_pbuf *p_to, struct pbuf *p_from);
err_t splpbuf_to_pbuf_copy (struct pbuf *p_to, struct spl_pbuf *p_from);
spl_pbuf_layer get_pbuf_layer_from_pbuf_payload (struct pbuf *buf);
diff --git a/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c b/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c
index d5b228b..03b5998 100644
--- a/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c
+++ b/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c
@@ -823,13 +823,7 @@ read_fn (i32 fd)
return;
}
- const char *old_hbt_cnt = "6";
- const char *new_hbt_cnt = "60";
- nsfw_set_soft_para (NSFW_PROC_MASTER, NSFW_HBT_COUNT_PARAM,
- (void *) new_hbt_cnt, sizeof (u16));
(void) read_configuration (); // if it returns -1, the err desc info will be wrote to g_config_data, so no need to check return value.
- nsfw_set_soft_para (NSFW_PROC_MASTER, NSFW_HBT_COUNT_PARAM,
- (void *) old_hbt_cnt, sizeof (u16));
offset = 0;
left = MAX_IP_MODULE_BUFF_SIZE;
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c
index 6af2a77..292c17a 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.c
@@ -522,6 +522,34 @@ sbr_com_lock_common (sbr_socket_t * sk)
}
+void
+sbr_com_fork_parent (sbr_socket_t * sk, pid_t p)
+{
+ i32 ref = ss_inc_fork_ref (sbr_get_conn (sk));
+ NSSBR_LOGINF ("inc fork ref] fd=%d, p=%d, ref=%d, conn=%p, private_data=%p",
+ sk->fd, p, ref, sbr_get_conn (sk),
+ sbr_get_conn (sk)->private_data);
+}
+
+void
+sbr_com_fork_child (sbr_socket_t * sk, pid_t p, pid_t c)
+{
+ if (ss_add_pid (sbr_get_conn (sk), c) != 0)
+ {
+ NSSBR_LOGERR
+ ("add pid failed] fd=%d, p=%d, c=%d, ref=%d, conn=%p, private_data=%p",
+ sk->fd, p, c, ss_get_fork_ref (sbr_get_conn (sk)), sbr_get_conn (sk),
+ sbr_get_conn (sk)->private_data);
+ }
+ else
+ {
+ NSSBR_LOGINF
+ ("add pid ok] fd=%d, p=%d, c=%d, ref=%d, conn=%p, private_data=%p",
+ sk->fd, p, c, ss_get_fork_ref (sbr_get_conn (sk)), sbr_get_conn (sk),
+ sbr_get_conn (sk)->private_data);
+ }
+}
+
/*****************************************************************************
* Prototype : sbr_com_unlock_common
* Description : unlock common
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h
index 054393b..1be44cb 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_prot_com.h
@@ -150,6 +150,9 @@ int sbr_get_sockaddr_and_len (u16 port, spl_ip_addr_t * ip_addr,
struct sockaddr *addr, socklen_t * addrlen);
void sbr_com_set_app_info (sbr_socket_t * sk, void *appinfo);
+void sbr_com_fork_parent (sbr_socket_t * sk, pid_t p);
+void sbr_com_fork_child (sbr_socket_t * sk, pid_t p, pid_t c);
+
#ifdef __cplusplus
/* *INDENT-OFF* */
}
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c b/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c
index 94ef483..920d73d 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_protocol_api.c
@@ -44,6 +44,25 @@ sbr_init_protocol ()
}
/*****************************************************************************
+* Prototype : sbr_fork_protocol
+* Description : init protocol
+* Input : None
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+int
+sbr_fork_protocol ()
+{
+ pid_t pid = updata_sys_pid ();
+
+ NSSBR_LOGINF ("update pid in child]pid=%d", pid);
+ return sbr_fork_stackx ();
+}
+
+/*****************************************************************************
* Prototype : sbr_get_fdopt
* Description : get fdopt by domain type protocol
* Input : int domain
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c
index 331eee1..f3cb5b5 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.c
@@ -172,6 +172,39 @@ sbr_init_stackx ()
}
/*****************************************************************************
+* Prototype : sbr_fork_stackx
+* Description : init stackx res
+* Input : None
+* Output : None
+* Return Value : int
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+int
+sbr_fork_stackx ()
+{
+
+ if (sbr_attach_group_array () != 0)
+ {
+ NSSBR_LOGERR ("sbr_attach_group_array failed");
+ return -1;
+ }
+
+ NSSBR_LOGDBG ("sbr_attach_group_array ok");
+
+ if (sbr_init_tx_pool () != 0)
+ {
+ NSSBR_LOGERR ("init tx pool failed");
+ return -1;
+ }
+
+ NSSBR_LOGDBG ("init tx pool ok");
+ NSSBR_LOGDBG ("sbr_fork_stackx ok");
+ return 0;
+}
+
+/*****************************************************************************
* Prototype : sbr_malloc_conn_for_sk
* Description : malloc netconn for sk,need add pid
* Input : sbr_socket_t* sk
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h
index e139644..73cec7f 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_res_mgr.h
@@ -56,6 +56,7 @@ sbr_get_spl_msg_box (sbr_socket_t * sk, u8 tos)
}
int sbr_init_stackx ();
+int sbr_fork_stackx ();
int sbr_malloc_conn_for_sk (sbr_socket_t * sk, spl_netconn_type_t type);
int sbr_init_conn_for_accept (sbr_socket_t * sk, spl_netconn_t * conn);
void sbr_free_conn_from_sk (sbr_socket_t * sk);
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c b/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
index c64dc7b..3225c2f 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
@@ -1690,6 +1690,8 @@ sbr_fdopt tcp_fdopt = {
.peak = sbr_com_peak,
.lock_common = sbr_com_lock_common,
.unlock_common = sbr_com_unlock_common,
+ .fork_parent = sbr_com_fork_parent,
+ .fork_child = sbr_com_fork_child,
.ep_getevt = stackx_eventpoll_getEvt,
.ep_ctl = stackx_eventpoll_triggle,
.set_close_stat = NULL,
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_udp.c b/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
index cf08731..69b822b 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_udp.c
@@ -1163,6 +1163,8 @@ sbr_fdopt udp_fdopt = {
.peak = sbr_com_peak,
.lock_common = sbr_com_lock_common,
.unlock_common = sbr_com_unlock_common,
+ .fork_parent = sbr_com_fork_parent,
+ .fork_child = sbr_com_fork_child,
.ep_getevt = stackx_eventpoll_getEvt,
.ep_ctl = stackx_eventpoll_triggle,
.set_close_stat = NULL,
diff --git a/stacks/lwip_stack/release/script/nstack_var.sh b/stacks/lwip_stack/release/script/nstack_var.sh
index 15ef2f0..4c5c6f6 100644
--- a/stacks/lwip_stack/release/script/nstack_var.sh
+++ b/stacks/lwip_stack/release/script/nstack_var.sh
@@ -26,7 +26,7 @@ DPDK_FILE_NAME=nstack_dpdk.log
export VM_ID=agent-node-x
-export DPDK_INSTALL_PATH="/root/dpdk/dpdk-18.02"
+export DPDK_INSTALL_PATH="/tmp/dpdk/dpdk-18.02/"
export DPDK_LIB_PATH=${DPDK_INSTALL_PATH}/x86_64-native-linuxapp-gcc/lib
export DPDK_TOOL_DIR=${DPDK_INSTALL_PATH}/usertools
export DPDK_MOD_PATH=${DPDK_INSTALL_PATH}/x86_64-native-linuxapp-gcc/kmod
diff --git a/stacks/lwip_stack/release/start_nstack.sh b/stacks/lwip_stack/release/start_nstack.sh
index c005f25..db0c084 100644
--- a/stacks/lwip_stack/release/start_nstack.sh
+++ b/stacks/lwip_stack/release/start_nstack.sh
@@ -1,9 +1,11 @@
#!/bin/bash
-. ./script/nstack_var.sh
-. ./script/nstack_fun.sh
script_path=$(cd "$(dirname "$0")"; pwd)
+
+. ${script_path}/script/nstack_var.sh
+. ${script_path}/script/nstack_fun.sh
+
config_name=${script_path}/script/nstack_var.sh
if [ ! -e $config_name ]; then
log $LINENO "nstack_var.sh not exit, plz check!"
@@ -59,7 +61,7 @@ if [ -f "lockfile" ]; then
rm lockfile
fi
-. ./script/nstack_var.sh
+. ${script_path}/script/nstack_var.sh
########################################################
@@ -115,8 +117,7 @@ install_config
core_mask=1
START_TYPE="primary"
log $LINENO "./script/run_nstack_main.sh ${core_mask} $HUGE_DIR $MEM_SIZE $START_TYPE"
-cd script
-./run_nstack_main.sh $HUGE_DIR $MEM_SIZE
+${script_path}/script/run_nstack_main.sh $HUGE_DIR $MEM_SIZE
print_pid=$(ps -ux | grep nStackMain | awk '{print $2}' | awk 'NR == 2')
echo "nStackMain PID:$print_pid"
diff --git a/stacks/lwip_stack/release/stop_nstack.sh b/stacks/lwip_stack/release/stop_nstack.sh
index 9b9fe94..48d1af7 100644
--- a/stacks/lwip_stack/release/stop_nstack.sh
+++ b/stacks/lwip_stack/release/stop_nstack.sh
@@ -1,9 +1,11 @@
#!/bin/bash
-. ./script/nstack_var.sh
-. ./script/nstack_fun.sh
script_path=$(cd "$(dirname "$0")"; pwd)
+
+. ${script_path}/script/nstack_var.sh
+. ${script_path}/script/nstack_fun.sh
+
config_name=${script_path}/script/nstack_var.sh
if [ ! -e $config_name ]; then
log $LINENO "$config_name not exit, plz pay attention and add back!,or it has resourcce leak."
diff --git a/stacks/lwip_stack/run_stackx.txt b/stacks/lwip_stack/run_stackx.txt
index 7322635..71cdd20 100644
--- a/stacks/lwip_stack/run_stackx.txt
+++ b/stacks/lwip_stack/run_stackx.txt
@@ -14,118 +14,36 @@
# limitations under the License.
#########################################################################
-#build DPDK
-#Note: build path /root/dpdk/ , install path /root/dpdk_install/tmp
-===================================================================
-if [ -d /root/dpdk_install/tmp ]; then
- rm -rf /root/dpdk_install/tmp
-fi
-
-mkdir -p /root/dpdk
-
-cd /root/dpdk
-rm -rf dpdk-16.04/
-wget https://fast.dpdk.org/rel/dpdk-16.04.tar.xz
-tar xvf dpdk-16.04.tar.xz
-cd dpdk-16.04/
-
-sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base
-sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base
-sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base
-
-make install T=x86_64-native-linuxapp-gcc DESTDIR=/root/dpdk_install/tmp
-cd x86_64-native-linuxapp-gcc
-make
-
-cp -r /root/dpdk/dpdk-16.04/tools/dpdk_nic_bind.py /root/dpdk/dpdk-16.04/tools/dpdk-devbind.py
-
-mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/
-mkdir /var/run/ip_module
-
-#verify hugepages 8GB free hugepages are required
-=================================================
-cat /proc/meminfo
-
-#build DMM
-============
-#got to DMM/
-
-cd thirdparty/glog/glog-0.3.4/
-sudo autoreconf -ivf
-
-cd -
-cd build/
-
-cmake ..
-make -j 8
-
-#build stackx
-================
-cd ../thirdparty/glog/glog-0.3.4/
-sudo autoreconf -ivf
-
-cd -
-cd ../stacks/lwip_stack/build/
-
-cmake ..
-make -j 8
-
-#run app
+#build DPDK, DMM, lwip stack by calling build script:
+====================================================
+ cd dmm/stacks/lwip_stack/vagrant
+ build.sh
+
+#update interface name if required(default enp0s8) in dmm/stacks/lwip_stack/vagrant/start_nstackMain.sh
+#Start nStackMain:
+=================
+ 1.for the first time (to configure json files and start nStackMain)
+ cd dmm/stacks/lwip_stack/vagrant
+ ./start_nstackMain.sh
+
+ 2.from secod time:
+ cd dmm/stacks/lwip_stack/release
+ ./start_nstack.sh
+
+#get configured client/server ip from dmm/stacks/lwip_stack/release/bin/ip_data.json
+#can get the log path details from dmm/stacks/lwip_stack/release/bin/nStackConfig.json
+
+#run app:
========
-cd ../
-chmod +x release_tar.sh
-./release_tar.sh
-
-tar -zxf nStackServer.tar.gz
-
-cd nStackServer/
-cp configure/*.json bin/
-
-##make json file changes
-#I have copied the working configs in the path /home/sharath/working_config/
-
-#server
-cp -r /home/sharath/working_config/server/ip_data.json bin/
-cp -r /home/sharath/working_config/server/network_data_tonStack.json bin/
-cp -r /home/sharath/working_config/server/nStackConfig.json bin/
-
-#client
-cp -r /home/sharath/working_config/client/ip_data.json bin/
-cp -r /home/sharath/working_config/client/network_data_tonStack.json bin/
-cp -r /home/sharath/working_config/client/nStackConfig.json bin/
-
-#dpdk download path : /root/dpdk/dpdk-16.04/
-sed -i 's!export DPDK_INSTALL_PATH.*!export DPDK_INSTALL_PATH="/root/dpdk/dpdk-16.04"!1' ../release/script/nstack_var.sh
+ cd dmm/stacks/lwip_stack/app_test
-cd ../../../release/bin/
-cp ../configure/*.json .
+ #server
+ ./vs_epoll -p 20000 -d {client_ip} -a 10000 -s {ser_ip} -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-#server
-cp -r /home/sharath/working_config/server/module_config.json .
-cp -r /home/sharath/working_config/server/nStackConfig.json .
-cp -r /home/sharath/working_config/server/rd_config.json .
+ #client
+ ./vc_epoll -p 20000 -d {ser_ip} -a 10000 -s {client_ip} -l 200 -t 50000 -i 1000 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-#client
-cp -r /home/sharath/working_config/client/module_config.json .
-cp -r /home/sharath/working_config/client/nStackConfig.json .
-cp -r /home/sharath/working_config/client/rd_config.json .
-
-cd -
-./stop_nstack.sh
-./start_nstack.sh
-
-#verify process up
-ps aux | grep nS
-
-cd bin
-./nStackCtrl -a add -p ./network_data_tonStack.json -t network
-./nStackCtrl -a add -p ./ip_data.json -t ip
-
-cd ../../../../release/bin/
-cp ../../stacks/lwip_stack/release/lib64/libnstack.so .
-
-#server
-./vs_epoll -p 20000 -d 192.168.1.207 -a 10000 -s 192.168.1.206 -l 200 -t 5000000 -i 0 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
-
-#client
-./vc_epoll -p 20000 -d 192.168.1.206 -a 10000 -s 192.168.1.207 -l 200 -t 50000 -i 1000 -f 1 -r 20000 -n 1 -w 10 -u 10000 -e 10 -x 1
+#stop nStackMain:
+================
+ cd dmm/stacks/lwip_stack/release
+ ./stop_nstack.sh
diff --git a/stacks/lwip_stack/src/alarm/alarm.c b/stacks/lwip_stack/src/alarm/alarm.c
index 5f89cdd..c158144 100644
--- a/stacks/lwip_stack/src/alarm/alarm.c
+++ b/stacks/lwip_stack/src/alarm/alarm.c
@@ -158,11 +158,9 @@ ns_alarm_module_init (void *param)
switch (proc_type)
{
case NSFW_PROC_MAIN:
-
- case NSFW_PROC_MASTER:
case NSFW_PROC_CTRL:
- /* [S138713][p00329905][20171219]modify ip address to vm id */
+ /* modify ip address to vm id */
pst_vm_id = getenv ("VM_ID");
if (INVALID_STR_LEN (pst_vm_id, MIN_VM_ID_LEN, MAX_VM_ID_LEN))
diff --git a/stacks/lwip_stack/src/maintain/fw_mt_config.c b/stacks/lwip_stack/src/maintain/fw_mt_config.c
index 400eaa0..403a46e 100644
--- a/stacks/lwip_stack/src/maintain/fw_mt_config.c
+++ b/stacks/lwip_stack/src/maintain/fw_mt_config.c
@@ -558,8 +558,7 @@ init_base_config (cfg_module_param * param)
{
/* initial default config */
/* omc_ctrl single log file should be 10M */
- if (param->proc_type == NSFW_PROC_MASTER
- || param->proc_type == NSFW_PROC_CTRL)
+ if (param->proc_type == NSFW_PROC_CTRL)
{
init_master_def_config_items ();
}
@@ -684,26 +683,6 @@ init_main_log_cfg_para ()
set_log_init_para (&log_para);
}
-NSTACK_STATIC void
-init_master_log_cfg_para ()
-{
- struct log_init_para log_para;
- log_para.mon_log_size = g_cfg_item_info[CFG_SEG_LOG][0].value;
- log_para.mon_log_count = g_cfg_item_info[CFG_SEG_LOG][1].value;
-
- /* log path valid check */
- if (0 == access (g_cfg_item_info[CFG_SEG_PATH][0].pvalue, W_OK))
- {
- log_para.mon_log_path = g_cfg_item_info[CFG_SEG_PATH][0].pvalue;
- }
- else
- {
- log_para.mon_log_path = g_cfg_item_info[CFG_SEG_PATH][0].default_str;
- }
-
- set_log_init_para (&log_para);
-}
-
/* nStackCtrl is the diff process with main, cannot use main process info,
need get the configure info respectively */
/* omc_ctrl single log file should be 10M */
@@ -739,17 +718,6 @@ init_module_cfg_nstackmain ()
init_main_log_cfg_para ();
}
-/*===========config init for nstack master=============*/
-
-NSTACK_STATIC void
-init_module_cfg_nstackmaster ()
-{
- /* init config data */
- init_module_cfg_default ();
-
- init_master_log_cfg_para ();
-}
-
/*===========config init for nstack ctrl=============*/
/* nStackCtrl is the diff process with main,
@@ -776,10 +744,6 @@ config_module_init (cfg_module_param * param)
init_module_cfg_nstackmain ();
break;
- case NSFW_PROC_MASTER:
- init_module_cfg_nstackmaster ();
- break;
-
case NSFW_PROC_CTRL:
init_module_cfg_nstackctrl ();
break;
diff --git a/stacks/lwip_stack/src/sbr/sbr_protocol_api.h b/stacks/lwip_stack/src/sbr/sbr_protocol_api.h
index f4e5070..95ca565 100644
--- a/stacks/lwip_stack/src/sbr/sbr_protocol_api.h
+++ b/stacks/lwip_stack/src/sbr/sbr_protocol_api.h
@@ -70,6 +70,8 @@ typedef struct
int (*peak) (sbr_socket_t *);
void (*lock_common) (sbr_socket_t *);
void (*unlock_common) (sbr_socket_t *);
+ void (*fork_parent) (sbr_socket_t *, pid_t);
+ void (*fork_child) (sbr_socket_t *, pid_t, pid_t);
unsigned int (*ep_ctl) (sbr_socket_t *, int triggle_ops,
struct epoll_event * event, void *pdata);
unsigned int (*ep_getevt) (sbr_socket_t *, unsigned int events);
@@ -86,7 +88,7 @@ struct sbr_socket_s
};
int sbr_init_protocol ();
-
+int sbr_fork_protocol ();
sbr_fdopt *sbr_get_fdopt (int domain, int type, int protocol);
void sbr_app_touch_in (void); /*app send its version info to nStackMain */
int lwip_try_select (int fdsize, fd_set * fdread, fd_set * fdwrite,
diff --git a/stacks/lwip_stack/src/sbr/sbr_res_mgr.h b/stacks/lwip_stack/src/sbr/sbr_res_mgr.h
index 54729d4..e731314 100644
--- a/stacks/lwip_stack/src/sbr/sbr_res_mgr.h
+++ b/stacks/lwip_stack/src/sbr/sbr_res_mgr.h
@@ -117,6 +117,37 @@ sbr_lookup_sk (int fd)
return sk;
}
+/*****************************************************************************
+* Prototype : sbr_free_sk
+* Description : free sock
+* Input : sbr_socket_t * sk
+* Output : None
+* Return Value : static inline void
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+static inline void
+sbr_free_fd (int fd)
+{
+ if ((fd < 1) || (fd > SBR_MAX_FD_NUM))
+ {
+ NSSBR_LOGERR ("fd is not ok]fd=%d", fd);
+ sbr_set_errno (EBADF);
+ return;
+ }
+
+ sbr_socket_t *sk = &g_res_group.sk[fd];
+ if (!sk->fdopt && !sk->sk_obj && !sk->stack_obj)
+ {
+ NSSBR_LOGERR
+ ("can't free empty fd] fd=%d, fdopt=%p, sk_obj=%p, stack_obj=%p", fd,
+ sk->fdopt, sk->sk_obj, sk->stack_obj);
+ return;
+ }
+ sbr_free_sk (sk);
+}
+
int sbr_init_res ();
#ifdef __cplusplus
diff --git a/stacks/lwip_stack/src/sbr/sbr_socket.c b/stacks/lwip_stack/src/sbr/sbr_socket.c
index e335d6c..6f867ab 100644
--- a/stacks/lwip_stack/src/sbr/sbr_socket.c
+++ b/stacks/lwip_stack/src/sbr/sbr_socket.c
@@ -1197,6 +1197,45 @@ SBR_INTERCEPT (int, fd_alloc, ())
return sbr_socket (AF_INET, SOCK_STREAM, 0);
}
+SBR_INTERCEPT (int, fork_init_child, (pid_t p, pid_t c))
+{
+ NSSBR_LOGDBG ("fork_init_child() is called]");
+ return sbr_fork_protocol ();
+}
+
+SBR_INTERCEPT (void, fork_parent_fd, (int s, pid_t p))
+{
+ NSSBR_LOGDBG ("fork_parent_fd() is called]");
+ sbr_socket_t *sk = sbr_lookup_sk (s);
+
+ if (!sk)
+ {
+ return;
+ }
+
+ sk->fdopt->fork_parent (sk, p);
+}
+
+SBR_INTERCEPT (void, fork_child_fd, (int s, pid_t p, pid_t c))
+{
+ NSSBR_LOGDBG ("fork_child_fd() is called]");
+ sbr_socket_t *sk = sbr_lookup_sk (s);
+
+ if (!sk)
+ {
+ return;
+ }
+
+ sk->fdopt->fork_child (sk, p, c);
+
+}
+
+SBR_INTERCEPT (void, fork_free_fd, (int s, pid_t p, pid_t c))
+{
+ NSSBR_LOGDBG ("fork_free_fd() is called]");
+ sbr_free_fd (s);
+}
+
/*****************************************************************************
* Prototype : nstack_stack_register
* Description : reg api to nsocket
@@ -1227,5 +1266,9 @@ nstack_stack_register (nstack_proc_cb * ops, nstack_event_cb * val)
(ops->extern_ops).ep_ctl = GET_SBR_INTERCEPT (ep_ctl);
(ops->extern_ops).peak = GET_SBR_INTERCEPT (peak);
(ops->extern_ops).stack_alloc_fd = GET_SBR_INTERCEPT (fd_alloc); /*alloc a fd id for epoll */
+ (ops->extern_ops).fork_init_child = GET_SBR_INTERCEPT (fork_init_child);
+ (ops->extern_ops).fork_parent_fd = GET_SBR_INTERCEPT (fork_parent_fd);
+ (ops->extern_ops).fork_child_fd = GET_SBR_INTERCEPT (fork_child_fd);
+ (ops->extern_ops).fork_free_fd = GET_SBR_INTERCEPT (fork_free_fd);
return 0;
}
diff --git a/stacks/lwip_stack/vagrant/Vagrantfile b/stacks/lwip_stack/vagrant/Vagrantfile
index cd59dbf..b3a31c1 100644
--- a/stacks/lwip_stack/vagrant/Vagrantfile
+++ b/stacks/lwip_stack/vagrant/Vagrantfile
@@ -14,12 +14,14 @@ Vagrant.configure(2) do |config|
# Create DMM client and server VM's
config.vm.define "dmm-stackx-server" do |server|
- server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install_prereq.sh")
+ server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/DMM vagrant"
+ server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"start_nstackMain.sh"), :args => "/DMM vagrant"
end
config.vm.define "dmm-stackx-client" do |client|
- client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install_prereq.sh")
+ client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/DMM vagrant"
+ client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"start_nstackMain.sh"), :args => "/DMM vagrant"
end
diff --git a/stacks/lwip_stack/vagrant/build.sh b/stacks/lwip_stack/vagrant/build.sh
index 8b1cb37..a934eef 100644..100755
--- a/stacks/lwip_stack/vagrant/build.sh
+++ b/stacks/lwip_stack/vagrant/build.sh
@@ -21,16 +21,17 @@ log_file="/tmp/build_log.txt-$TIMESTAMP"
exec 1> >(tee -a "$log_file") 2>&1
# Get Command Line arguements if present
-TEMP_DIR=$1
-if [ "x$1" != "x" ]; then
+if [ "$1" == "from-base-build" ]; then
+ WAS_DMM_BUILT="YES"
+fi
+
+if [ "x$1" != "x" ] && [ "$1" != "from-base-build" ]; then
TEMP_DIR=$1
- DMM_BUILD_DIR=${TEMP_DIR}/build
- DPDK_BUILD_SCRIPT_DIR=${DMM_BUILD_DIR}/../scripts
+ DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/scripts
LWIP_BUILD_DIR=${TEMP_DIR}/stacks/lwip_stack/build/
else
TEMP_DIR=`dirname $(readlink -f $0)`/..
- DMM_BUILD_DIR=${TEMP_DIR}/../../build
- DPDK_BUILD_SCRIPT_DIR=${DMM_BUILD_DIR}/../scripts
+ DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/../../scripts
LWIP_BUILD_DIR=${TEMP_DIR}/build/
fi
@@ -38,231 +39,21 @@ echo 0:$0
echo 1:$1
echo 2:$2
echo TEMP_DIR: $TEMP_DIR
-echo DMM_BUILD_DIR: $DMM_BUILD_DIR
-echo DPDK_BUILD_SCRIPT_DIR: $DPDK_BUILD_SCRIPT_DIR
+echo DMM_BUILD_SCRIPT_DIR: $DMM_BUILD_SCRIPT_DIR
echo LWIP_BUILD_DIR: $LWIP_BUILD_DIR
-OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
-KERNEL_OS=`uname -o`
-KERNEL_MACHINE=`uname -m`
-KERNEL_RELEASE=`uname -r`
-KERNEL_VERSION=`uname -v`
-
-echo KERNEL_OS: $KERNEL_OS
-echo KERNEL_MACHINE: $KERNEL_MACHINE
-echo KERNEL_RELEASE: $KERNEL_RELEASE
-echo KERNEL_VERSION: $KERNEL_VERSION
-echo OS_ID: $OS_ID
-echo OS_VERSION_ID: $OS_ID
-
-#DPDK download path
-DPDK_DOWNLOAD_PATH=/tmp/dpdk
-
-#dpdk installation path
-DPDK_INSTALL_PATH=/usr
-
-#set and check the environment for Linux
-if [ "$OS_ID" == "ubuntu" ]; then
- export DEBIAN_FRONTEND=noninteractive
- export DEBCONF_NONINTERACTIVE_SEEN=true
-
- APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
- sudo apt-get update ${APT_OPTS}
- sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim ethtool unzip
-elif [ "$OS_ID" == "debian" ]; then
- echo "not tested for debian and exit"
- exit 1
- export DEBIAN_FRONTEND=noninteractive
- export DEBCONF_NONINTERACTIVE_SEEN=true
-
- APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
- sudo apt-get update ${APT_OPTS}
- sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim
-elif [ "$OS_ID" == "centos" ]; then
- sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel
-elif [ "$OS_ID" == "opensuse" ]; then
- echo "not tested for opensuse and exit"
- exit 1
- sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel
-fi
-
-#DPDK will be having dependancy on linux headers
-if [ "$OS_ID" == "ubuntu" ]; then
- sudo apt-get -y install git build-essential linux-headers-`uname -r`
- sudo apt-get -y install libnuma-dev
-elif [ "$OS_ID" == "debian" ]; then
- sudo apt-get -y install git build-essential linux-headers-`uname -r`
-elif [ "$OS_ID" == "centos" ]; then
- sudo yum groupinstall -y "Development Tools"
- sudo yum install -y kernel-headers
- sudo yum install -y numactl-devel
-elif [ "$OS_ID" == "opensuse" ]; then
- sudo yum groupinstall -y "Development Tools"
- sudo yum install -y kernel-headers
+if [ 'x$WAS_DMM_BUILT' != "xYES" ]; then
+ bash -x $DMM_BUILD_SCRIPT_DIR/build.sh
fi
-#===========build DPDK================
-
-if [ ! -d /usr/include/dpdk ] || [ ! -d /usr/share/dpdk ] || [ ! -d /usr/lib/modules/4.4.0-31-generic/extra/dpdk ]; then
- mkdir -p $DPDK_DOWNLOAD_PATH
-
- cd $DPDK_DOWNLOAD_PATH
- wget -N https://fast.dpdk.org/rel/dpdk-18.02.tar.xz --no-check-certificate
- tar xvf dpdk-18.02.tar.xz
- cd dpdk-18.02/
-
- sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base
- sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base
- sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base
- sed -i 's!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1' config/common_base
-
- sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -j 4
-
- mkdir -p /tmp/dpdk/drivers/
- cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/
-fi
-#===========build DMM=================
-echo "DMM build started....."
-
-cd $DMM_BUILD_DIR
-ldconfig
-rm -rf *
-cmake ..
-make -j 8
-if [ $? -eq 0 ]; then
- echo "DMM build is SUCCESS"
-else
- echo "DMM build has FAILED"
- exit 1
-fi
-echo "DMM build finished....."
-
-#===========build Stackpool===========
-echo "Stackpool build started....."
+#===========build LWIP===========
+echo "LWIP build started....."
cd $LWIP_BUILD_DIR
cmake ..
make -j 8
if [ $? -eq 0 ]; then
- echo "Stackpool build is SUCCESS"
+ echo "LWIP build is SUCCESS"
else
- echo "Stackpool build has FAILED"
- exit 1
-fi
-echo "Stackpool build finished....."
-
-#===========check running env =================
-hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
-if [ "$hugepagesize" == "2048" ]; then
- pages=1536
-elif [ "$hugepagesize" == "1048576" ]; then
- pages=3
-fi
-sudo sysctl -w vm.nr_hugepages=$pages
-HUGEPAGES=`sysctl -n vm.nr_hugepages`
-if [ $HUGEPAGES != $pages ]; then
- echo "ERROR: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
- exit
-fi
-
-
-hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0")
-if [ $hugepageTotal -ne 0 ]; then
- echo "HugePages_Total is zero"
- exit
-fi
-
-hugepageFree=$(cat /proc/meminfo | grep -c "HugePages_Free: 0")
-if [ $hugepageFree -ne 0 ]; then
- echo "HugePages_Free is zero"
- exit
-fi
-
-hugepageSize=$(cat /proc/meminfo | grep -c "Hugepagesize: 0 kB")
-if [ $hugepageSize -ne 0 ]; then
- echo "Hugepagesize is zero"
- exit
-fi
-
-
-sudo mkdir /mnt/nstackhuge -p
-if [ "$hugepagesize" == "2048" ]; then
-sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/
-elif [ "$hugepagesize" == "1048576" ]; then
- sudo mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/
-fi
-sudo mkdir -p /var/run/ip_module/
-sudo mkdir -p /var/log/nStack/ip_module/
-
-export LD_LIBRARY_PATH=$LIB_PATH
-export NSTACK_LOG_ON=DBG
-
-
-
-#===========set environment===========
-if [ "$OS_ID" == "centos" ]; then
- ifaddress1=$(ifconfig enp0s8 | grep 'inet' | cut -d: -f2 | awk '{print $2}')
- echo $ifaddress1
- ifaddresscut=$(ifconfig enp0s8 | grep 'inet' | head -n 1 | awk -F " " '{print $2}' | awk -F "." '{print $1"."$2"."$3}')
- echo $ifaddresscut
- ifmac=$(ifconfig enp0s8 | grep 'ether' | awk -F " " '{print $2}')
- echo $ifmac
-elif [ "$OS_ID" == "ubuntu" ]; then
- ifaddress1=$(ifconfig enp0s8 | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}')
- echo $ifaddress1
- ifaddresscut=$(ifconfig enp0s8 | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}' | awk -F "." '{print $1"."$2"."$3}')
- echo $ifaddresscut
- ifmac=$(ifconfig enp0s8 | grep 'HWaddr' | awk -F " " '{print $5}')
- echo $ifmac
-fi
-
-cd $LWIP_BUILD_DIR/../
-bash ./release_tar.sh
-cd nStackServer/script
-sed -i 's!/root/dpdk/dpdk-18.02!'$DPDK_DOWNLOAD_PATH'/dpdk-18.02!1' nstack_var.sh
-
-cd ../
-cp ./configure/*.json bin/
-cd bin
-
-if [ "$OS_ID" == "centos" ]; then
- sed -i 's!eth7!enp0s8!1' ip_data.json
-elif [ "$OS_ID" == "ubuntu" ]; then
- sed -i 's!eth7!enp0s8!1' ip_data.json
-fi
-
-sed -i 's!00:54:32:19:3d:19!'$ifmac'!1' ip_data.json
-sed -i 's!192.168.1.207!'$ifaddress1'!1' ip_data.json
-
-sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' network_data_tonStack.json
-sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json
-sed -i 's!192.168.1.098!'$ifaddresscut'.5!1' network_data_tonStack.json
-sed -i 's!192.168.1.209!'$ifaddresscut'.254!1' network_data_tonStack.json
-sed -i 's!192.168.1.0!'$ifaddresscut'.0!1' network_data_tonStack.json
-sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json
-
-if [ "$OS_ID" == "centos" ]; then
- sed -i 's!eth7!enp0s8!1' network_data_tonStack.json
-elif [ "$OS_ID" == "ubuntu" ]; then
- sed -i 's!eth7!enp0s8!1' network_data_tonStack.json
-fi
-sed -i 's!eth7!enp0s8!1' network_data_tonStack.json
-
-cd $DMM_BUILD_DIR/../release/bin
-cp -r . ../../stacks/lwip_stack/app_test
-cd $DMM_BUILD_DIR/../stacks/lwip_stack/app_test
-cp -r ../app_conf/*.json .
-
-sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' rd_config.json
-
-cd $LWIP_BUILD_DIR/../nStackServer
-bash -x ./stop_nstack.sh
-bash -x ./start_nstack.sh
-check_result=$(pgrep nStackMain)
-if [ -z "$check_result" ]; then
- echo "nStackMain execute failed"
+ echo "LWIP build has FAILED"
exit 1
-else
- echo "nStackMain execute successful"
- exit 0
fi
diff --git a/stacks/lwip_stack/vagrant/env.sh b/stacks/lwip_stack/vagrant/env.sh
index 96ad346..96ad346 100644..100755
--- a/stacks/lwip_stack/vagrant/env.sh
+++ b/stacks/lwip_stack/vagrant/env.sh
diff --git a/stacks/lwip_stack/vagrant/start_nstackMain.sh b/stacks/lwip_stack/vagrant/start_nstackMain.sh
new file mode 100755
index 0000000..00d4370
--- /dev/null
+++ b/stacks/lwip_stack/vagrant/start_nstackMain.sh
@@ -0,0 +1,117 @@
+#########################################################################
+# Copyright (c) 2018 Huawei Technologies Co.,Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#########################################################################
+#!/bin/bash -x
+
+set -x
+
+DPDK_DOWNLOAD_PATH=/tmp/dpdk
+ifname=enp0s8
+
+if [ "x$1" != "x" ] && [ "$1" != "from-base-build" ]; then
+ TEMP_DIR=$1
+ DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/scripts
+ LWIP_BUILD_DIR=${TEMP_DIR}/stacks/lwip_stack/build/
+else
+ TEMP_DIR=`dirname $(readlink -f $0)`/..
+ DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/../../scripts
+ LWIP_BUILD_DIR=${TEMP_DIR}/build/
+fi
+
+LIB_PATH=$LWIP_BUILD_DIR/../release/lib64/
+
+echo 0:$0
+echo 1:$1
+echo 2:$2
+echo TEMP_DIR: $TEMP_DIR
+echo DMM_BUILD_SCRIPT_DIR: $DMM_BUILD_SCRIPT_DIR
+echo LWIP_BUILD_DIR: $LWIP_BUILD_DIR
+echo LIB_PATH: $LIB_PATH
+
+#===========check hugepages=================
+source $DMM_BUILD_SCRIPT_DIR/check_hugepage.sh
+
+OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g')
+if [ "$OS_ID" == "centos" ]; then
+ ifaddress1=$(ifconfig $ifname | grep 'inet' | cut -d: -f2 | awk '{print $2}')
+ echo $ifaddress1
+ ifaddresscut=$(ifconfig $ifname | grep 'inet' | head -n 1 | awk -F " " '{print $2}' | awk -F "." '{print $1"."$2"."$3}')
+ echo $ifaddresscut
+ ifmac=$(ifconfig $ifname | grep 'ether' | awk -F " " '{print $2}')
+ echo $ifmac
+elif [ "$OS_ID" == "ubuntu" ]; then
+ ifaddress1=$(ifconfig $ifname | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}')
+ echo $ifaddress1
+ ifaddresscut=$(ifconfig $ifname | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}' | awk -F "." '{print $1"."$2"."$3}')
+ echo $ifaddresscut
+ ifmac=$(ifconfig $ifname | grep 'HWaddr' | awk -F " " '{print $5}')
+ echo $ifmac
+fi
+
+cd $LWIP_BUILD_DIR/../
+cd release/script
+sed -i 's!DPDK_INSTALL_PATH=.*!DPDK_INSTALL_PATH='$DPDK_DOWNLOAD_PATH'/dpdk-18.02!1' nstack_var.sh
+
+cd ../
+chmod 775 *
+cp ./configure/*.json bin/
+cd bin
+
+if [ "$OS_ID" == "centos" ]; then
+ sed -i 's!eth7!'$ifname'!1' ip_data.json
+elif [ "$OS_ID" == "ubuntu" ]; then
+ sed -i 's!eth7!'$ifname'!1' ip_data.json
+fi
+
+sed -i 's!00:54:32:19:3d:19!'$ifmac'!1' ip_data.json
+sed -i 's!192.168.1.207!'$ifaddress1'!1' ip_data.json
+
+sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' network_data_tonStack.json
+sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json
+sed -i 's!192.168.1.098!'$ifaddresscut'.5!1' network_data_tonStack.json
+sed -i 's!192.168.1.209!'$ifaddresscut'.254!1' network_data_tonStack.json
+sed -i 's!192.168.1.0!'$ifaddresscut'.0!1' network_data_tonStack.json
+sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json
+
+if [ "$OS_ID" == "centos" ]; then
+ sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json
+elif [ "$OS_ID" == "ubuntu" ]; then
+ sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json
+fi
+sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json
+
+cd $DMM_BUILD_SCRIPT_DIR/../release/bin
+cp -r . ../../stacks/lwip_stack/app_test
+cd $DMM_BUILD_SCRIPT_DIR/../stacks/lwip_stack/app_test
+cp -r ../app_conf/*.json .
+
+sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' rd_config.json
+
+sudo mkdir -p /var/run/ip_module/
+sudo mkdir -p /var/log/nStack/ip_module/
+
+export LD_LIBRARY_PATH=$LIB_PATH
+export NSTACK_LOG_ON=DBG
+
+cd $LWIP_BUILD_DIR/../release
+bash -x ./stop_nstack.sh
+bash -x ./start_nstack.sh
+check_result=$(pgrep nStackMain)
+if [ -z "$check_result" ]; then
+ echo "nStackMain execute failed"
+ exit 1
+else
+ echo "nStackMain execute successful"
+ exit 0
+fi
diff --git a/stacks/vpp/adapt/dmm_vcl_adpt.c b/stacks/vpp/adapt/dmm_vcl_adpt.c
index 1b2b9a9..d4974e2 100644
--- a/stacks/vpp/adapt/dmm_vcl_adpt.c
+++ b/stacks/vpp/adapt/dmm_vcl_adpt.c
@@ -35,6 +35,7 @@ vpphs_ep_ctl_ops (int epFD, int proFD, int ctl_ops,
tmpEvt.data.ptr = pdata;
tmpEvt.events = events->events;
+ tmpEvt.events |= (EPOLLIN | EPOLLOUT);
if (DMM_VCL_ADPT_DEBUG > 0)
clib_warning ("DMM VCL ADPT<%d>: epfd=%d,fd=%d,ops=%d, events=%u",
diff --git a/stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch b/stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch
new file mode 100644
index 0000000..7975e27
--- /dev/null
+++ b/stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch
@@ -0,0 +1,62 @@
+From bdb9568fe64c6bdfde17f61dac57a7f54214912c Mon Sep 17 00:00:00 2001
+From: Jiang Wenjiang <jiangwenjiang@huawei.com>
+Date: Mon, 10 Sep 2018 03:01:41 +0800
+Subject: [PATCH] Fix: fix epoll problem
+
+The same fd can add to different epoll.
+---
+ src/vcl/vppcom.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
+index cab2f60..9cb52cb 100644
+--- a/src/vcl/vppcom.c
++++ b/src/vcl/vppcom.c
+@@ -162,6 +162,7 @@ typedef struct
+ u64 options[16];
+ elog_track_t elog_track;
+ vce_event_handler_reg_t *poll_reg;
++ u32 ep_count; //the count that add to epoll
+ } session_t;
+
+ typedef struct vppcom_cfg_t_
+@@ -3430,6 +3431,7 @@ vppcom_session_write_ready (session_t * session, u32 session_index)
+
+ if (PREDICT_FALSE (session->state & STATE_LISTEN))
+ {
++ return 0;
+ clib_warning ("VCL<%d>: ERROR: vpp handle 0x%llx, sid %u: "
+ "cannot write to a listen session!",
+ getpid (), session->vpp_handle, session_index);
+@@ -3802,6 +3804,7 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index,
+ session_t *vep_session;
+ session_t *session;
+ int rv;
++ int ep_cnt = 0;
+
+ if (vep_idx == session_index)
+ {
+@@ -3846,6 +3849,9 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index,
+ switch (op)
+ {
+ case EPOLL_CTL_ADD:
++ ep_cnt = __sync_add_and_fetch (&(session->ep_count), 1);
++ if (ep_cnt != 1)
++ break;
+ if (PREDICT_FALSE (!event))
+ {
+ clib_warning ("VCL<%d>: ERROR: EPOLL_CTL_ADD: NULL pointer to "
+@@ -3950,6 +3956,10 @@ vppcom_epoll_ctl (uint32_t vep_idx, int op, uint32_t session_index,
+ break;
+
+ case EPOLL_CTL_DEL:
++ ep_cnt = __sync_sub_and_fetch (&(session->ep_count), 1);
++ if (ep_cnt != 0)
++ break;
++
+ if (PREDICT_FALSE (!session->is_vep_session))
+ {
+ clib_warning ("VCL<%d>: ERROR: sid %u EPOLL_CTL_DEL: "
+--
+1.8.3.1
+