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_dmm_dep.sh5
-rwxr-xr-xscripts/build_dpdk1802.sh9
-rwxr-xr-xscripts/build_dpdk1805.sh2
-rw-r--r--[-rwxr-xr-x]scripts/compile_dmm.sh12
-rwxr-xr-xscripts/generate_dmm_rpm.sh2
-rw-r--r--src/CMakeLists.txt2
-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.txt2
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_api_msg.c9
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_spl_share.h12
-rw-r--r--stacks/lwip_stack/lwip_src/core/spl_timers.c1
-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/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/vpp/adapt/dmm_vcl_adpt.c1
-rw-r--r--stacks/vpp/patch/0002-Fix-fix-epoll-problem.patch62
48 files changed, 719 insertions, 149 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_dmm_dep.sh b/scripts/build_dmm_dep.sh
index 980b3f5..ecbb686 100755
--- a/scripts/build_dmm_dep.sh
+++ b/scripts/build_dmm_dep.sh
@@ -2,6 +2,11 @@
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
diff --git a/scripts/build_dpdk1802.sh b/scripts/build_dpdk1802.sh
index 5686e82..74d4860 100755
--- a/scripts/build_dpdk1802.sh
+++ b/scripts/build_dpdk1802.sh
@@ -62,9 +62,15 @@ 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"
@@ -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 84f3e48..2727877 100755
--- a/scripts/build_dpdk1805.sh
+++ b/scripts/build_dpdk1805.sh
@@ -59,7 +59,7 @@ 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"
diff --git a/scripts/compile_dmm.sh b/scripts/compile_dmm.sh
index b4bc455..c378bae 100755..100644
--- a/scripts/compile_dmm.sh
+++ b/scripts/compile_dmm.sh
@@ -22,8 +22,20 @@ 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/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/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 0498824..297d2d9 100644
--- a/stacks/lwip_stack/CMakeLists.txt
+++ b/stacks/lwip_stack/CMakeLists.txt
@@ -67,7 +67,7 @@ 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/lwip_src/api/spl_api_msg.c b/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
index 9ba1e92..0986ed4 100644
--- a/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
+++ b/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
@@ -3186,9 +3186,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_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/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/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 1c0fb1e..0eac1c4 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 */
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 47aefda..e088224 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/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
+