aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--demo/nginx_proxy/README.md19
-rw-r--r--demo/nginx_proxy/demo-1/Vagrantfile98
-rw-r--r--demo/nginx_proxy/demo-1/adjust_hugepage.sh14
-rwxr-xr-xdemo/nginx_proxy/demo-1/apply_patch.sh9
-rw-r--r--demo/nginx_proxy/demo-1/demo_2stack.patch29
-rw-r--r--demo/nginx_proxy/demo-1/module_config.json38
-rw-r--r--demo/nginx_proxy/demo-1/proxy_nginx.conf81
-rw-r--r--demo/nginx_proxy/demo-1/rd_config.json27
-rw-r--r--demo/nginx_proxy/demo-1/setup_proxy.sh54
-rw-r--r--demo/nginx_proxy/demo-1/setup_upstream.sh45
-rw-r--r--demo/nginx_proxy/demo-1/startup.conf20
-rw-r--r--demo/nginx_proxy/demo-1/upstream_nginx.conf80
-rw-r--r--demo/nginx_proxy/demo-1/vpp_config6
-rw-r--r--demo/nginx_proxy/demo-2/README.md69
-rw-r--r--demo/nginx_proxy/demo-2/Vagrantfile116
-rw-r--r--demo/nginx_proxy/demo-2/adjust_hugepage.sh14
-rwxr-xr-xdemo/nginx_proxy/demo-2/apply_patch.sh9
-rw-r--r--demo/nginx_proxy/demo-2/dem-2-topo.pngbin0 -> 32437 bytes
-rw-r--r--demo/nginx_proxy/demo-2/demo-2.pngbin0 -> 125156 bytes
-rw-r--r--demo/nginx_proxy/demo-2/demo_2stack.patch29
-rw-r--r--demo/nginx_proxy/demo-2/module_config.json38
-rw-r--r--demo/nginx_proxy/demo-2/proxy_nginx.conf33
-rw-r--r--demo/nginx_proxy/demo-2/rd_config.json31
-rw-r--r--demo/nginx_proxy/demo-2/setup_client.sh25
-rw-r--r--demo/nginx_proxy/demo-2/setup_proxy.sh54
-rw-r--r--demo/nginx_proxy/demo-2/setup_udpserver.sh25
-rw-r--r--demo/nginx_proxy/demo-2/setup_upstream.sh44
-rw-r--r--demo/nginx_proxy/demo-2/startup.conf20
-rw-r--r--demo/nginx_proxy/demo-2/udpclient.c50
-rw-r--r--demo/nginx_proxy/demo-2/udpserver.c55
-rw-r--r--demo/nginx_proxy/demo-2/upstream_nginx.conf80
-rw-r--r--demo/nginx_proxy/demo-2/vpp_config6
-rw-r--r--docker/dmm_image/README.md13
-rw-r--r--docker/dmm_image/centos/Dockerfile17
-rw-r--r--pkg/deb/control2
-rw-r--r--pkg/rpm/dmm.spec2
-rwxr-xr-xscripts/build_dpdk1805.sh82
-rwxr-xr-xscripts/build_rsocket.sh37
-rwxr-xr-xscripts/generate_dmm_rpm.sh2
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/framework/common/base/include/common/common_mem_buf.h4
-rw-r--r--src/framework/common/base/liblinuxapi/nsfw_lock_file.c2
-rw-r--r--src/framework/common/mem_mgr/nsfw_shmem/nsfw_shmem_mng.c15
-rw-r--r--src/framework/hal/hal.c4
-rw-r--r--src/framework/hal/hal.h3
-rw-r--r--src/framework/include/hal_api.h3
-rw-r--r--src/framework/include/nsfw_mgr_com_api.h1
-rw-r--r--src/framework/include/nstack_log.h14
-rw-r--r--src/framework/ipc/mgr_com/mgr_com.c1
-rw-r--r--src/framework/lib_common_mem/common_buf.c24
-rw-r--r--src/nSocket/nstack/nstack.c38
-rw-r--r--src/nSocket/nstack/nstack_socket.c95
-rw-r--r--src/nSocket/nstack_rd/nstack_rd_ip.c7
-rw-r--r--stacks/lwip_stack/CMakeLists.txt4
-rw-r--r--stacks/lwip_stack/app_conf/module_config.json2
-rw-r--r--stacks/lwip_stack/doc/README.md5
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_api_msg.c11
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_sbr.c6
-rw-r--r--stacks/lwip_stack/lwip_src/api/spl_tcpip.c6
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_common_opt.h1
-rw-r--r--stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h2
-rw-r--r--stacks/lwip_stack/lwip_src/core/spl_pbuf.c2
-rw-r--r--stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h1
-rw-r--r--stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h1
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c8
-rw-r--r--stacks/lwip_stack/lwip_src/ip_module/network.c43
-rw-r--r--stacks/lwip_stack/lwip_src/netif/spl_hal.c43
-rw-r--r--stacks/lwip_stack/lwip_src/socket/stackx_tcp.c1
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/release/script/nstack_fun.sh4
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/release/script/nstack_var.sh10
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/release/script/run_nstack_main.sh3
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/release/script/run_nstack_master.sh0
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/release/send_alarm.sh0
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/release/start_nstack.sh46
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/release/stop_nstack.sh0
-rwxr-xr-x[-rw-r--r--]stacks/lwip_stack/release/uninstall.sh0
-rw-r--r--stacks/lwip_stack/release/upgrade_nstack.sh452
-rw-r--r--stacks/lwip_stack/release_tar.sh4
-rw-r--r--stacks/lwip_stack/src/io_adpt/dpdk.c169
-rw-r--r--stacks/lwip_stack/src/nStackMain/main.c2
-rw-r--r--stacks/lwip_stack/src/sbr/CMakeLists.txt6
-rw-r--r--stacks/rsocket/CMakeLists.txt2
-rw-r--r--stacks/rsocket/src/rsocket_adpt.c1
-rw-r--r--thirdparty/apps/CMakeLists.txt25
84 files changed, 1739 insertions, 707 deletions
diff --git a/demo/nginx_proxy/README.md b/demo/nginx_proxy/README.md
new file mode 100644
index 0000000..b8a9705
--- /dev/null
+++ b/demo/nginx_proxy/README.md
@@ -0,0 +1,19 @@
+# Introduction
+DMM (Dual Mode, Multi-protocol, Multi-instance) is to implement a transport agnostic framework for network
+applications that can
+1. Work with both user space and kernel space network stacks
+2. Use different network protocol stacks based on their functional and performance requirements (QOS)
+3. Work with multiple instances of a transport protocol stack.
+
+Following demo directory demonstrates some of these features of DMM.
+Procedures and details of how to run this demo is inside each demo directory.
+
+##demo-1
+
+This demo use NGINX as a reverse proxy server. The server uses lwip as client facing stack and kernel tcp/ip
+stack as upstream server facing stack.
+
+##demo-2
+
+This demo NGINX as a reverse proxy server. The server uses lwip as client facing stack and kernel tcp/ip stack
+as upstream server facing stack for UDP, vpp-hoststack for another updtream server facing stack for TCP. \ No newline at end of file
diff --git a/demo/nginx_proxy/demo-1/Vagrantfile b/demo/nginx_proxy/demo-1/Vagrantfile
new file mode 100644
index 0000000..d3db5e5
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/Vagrantfile
@@ -0,0 +1,98 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+boxes = [
+ {
+ :name => "rproxy-client",
+ :hostname => "rproxy-client",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-server",
+ :hostname => "rproxy-server",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-proxy",
+ :hostname => "rproxy-proxy",
+ :mem => "10144",
+ :cpu => "4"
+ }
+]
+
+Vagrant.configure(2) do |config|
+
+ # Pick the right distro and bootstrap, default is ubuntu1604
+ distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu")
+ if distro == 'centos7'
+ config.vm.box = "puppetlabs/centos-7.2-64-nocm"
+ else
+ config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
+ end
+
+ config.vm.box_check_update = false
+ #ddconfig.ssh.password = vagrant
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
+
+ # Define some physical ports for your VMs to be used by DPDK
+ #nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10)
+ #for i in 1..nics
+ # config.vm.network "private_network", type: "dhcp"
+ #end
+
+ if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = ENV['http_proxy']
+ config.proxy.https = ENV['https_proxy']
+ config.proxy.no_proxy = "localhost,127.0.0.1"
+ end
+
+ config.ssh.forward_agent = true
+ config.ssh.forward_x11 = true
+
+ boxes.each do |opts|
+ config.vm.define opts[:name] do |srv|
+ srv.vm.hostname = opts[:hostname]
+ srv.vm.provider "virtualbox" do |vb|
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
+ vb.customize ["modifyvm", :id, "--memory", opts[:mem]]
+ vb.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
+ end
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
+ puts ' '..srv.vm.hostname
+
+ if opts[:name] == "rproxy-proxy"
+ puts 'NGINX Proxy Server, Run nginx in below way '
+ puts 'export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64'
+ puts './DMM/thirdparty/apps/nginx/release/nginx'
+ srv.vm.synced_folder "../../../", "/DMM", type: "rsync"
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"apply_patch.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/build.sh"), :args => "/DMM vagrant"
+ srv.vm.network "private_network", ip: "192.168.50.20"
+ srv.vm.network "private_network", ip: "172.167.50.20"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/start_nstackMain.sh"), :args => "/DMM vagrant"
+ #possibly overwrite by previous script so adjust again
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"setup_proxy.sh"), run: 'always'
+ end
+ if opts[:name] == "rproxy-client"
+ puts 'Client use command: curl http://192.168.50.20'
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.network "private_network", ip: "192.168.50.10"
+ end
+ if opts[:name] == "rproxy-server"
+ puts 'Upstream server '
+
+ srv.vm.synced_folder "./", "/NGINX", type: "rsync"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_upstream.sh"), run: 'always'
+ srv.vm.network "private_network", ip: "172.167.50.30"
+ end
+ end
+ end
+end
diff --git a/demo/nginx_proxy/demo-1/adjust_hugepage.sh b/demo/nginx_proxy/demo-1/adjust_hugepage.sh
new file mode 100644
index 0000000..282e3bd
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/adjust_hugepage.sh
@@ -0,0 +1,14 @@
+#!/bin/bash -x
+hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
+if [ "$hugepagesize" == "2048" ]; then
+ pages=3000
+elif [ "$hugepagesize" == "1048576" ]; then
+ pages=5
+fi
+sudo sysctl -w vm.nr_hugepages=$pages
+HUGEPAGES=`sysctl -n vm.nr_hugepages`
+echo "Configured hugepages: $HUGEPAGE"
+if [ $HUGEPAGES != $pages ]; then
+ echo "Warning: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
+fi
+
diff --git a/demo/nginx_proxy/demo-1/apply_patch.sh b/demo/nginx_proxy/demo-1/apply_patch.sh
new file mode 100755
index 0000000..84ecc59
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/apply_patch.sh
@@ -0,0 +1,9 @@
+#!/bin/bash -x
+sudo apt-get install patch -y
+cd /DMM/src/
+sudo patch -p2 -i /DMM/demo/nginx_proxy/demo-1/demo_2stack.patch
+if [ $? -ne 0 ]; then
+ echo "Patch Apply failed. Downlaod correct commit. Check README for details."
+ exit -1
+fi
+cd -
diff --git a/demo/nginx_proxy/demo-1/demo_2stack.patch b/demo/nginx_proxy/demo-1/demo_2stack.patch
new file mode 100644
index 0000000..f1bc8d3
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/demo_2stack.patch
@@ -0,0 +1,29 @@
+diff --git a/src/adapt/nstack_dmm_adpt.c b/src/adapt/nstack_dmm_adpt.c
+index d497b80..004975c 100644
+--- a/src/adapt/nstack_dmm_adpt.c
++++ b/src/adapt/nstack_dmm_adpt.c
+@@ -76,7 +76,7 @@ nstack_event_callback (void *pdata, int events)
+ /*event should not notice other process */
+ if ((ep->pid != get_sys_pid ()) && g_same_process)
+ {
+- continue;
++ //continue;
+ }
+
+ sys_arch_lock_with_pid (&ep->lock);
+diff --git a/src/nSocket/nstack/nstack_module.c b/src/nSocket/nstack/nstack_module.c
+index 9566ab8..f692225 100644
+--- a/src/nSocket/nstack/nstack_module.c
++++ b/src/nSocket/nstack/nstack_module.c
+@@ -60,6 +60,11 @@ nstack_get_deploy_type ()
+ if (g_nstack_module_desc[icnt].deploytype > type)
+ {
+ type = g_nstack_module_desc[icnt].deploytype;
++ if (NSTACK_MODEL_TYPE3 == type)
++ {
++ break;
++ }
++
+ }
+ }
+ return type;
diff --git a/demo/nginx_proxy/demo-1/module_config.json b/demo/nginx_proxy/demo-1/module_config.json
new file mode 100644
index 0000000..5861153
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/module_config.json
@@ -0,0 +1,38 @@
+{
+ "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",
+ },
+ {
+ "stack_name": "lwip",
+ "function_name": "nstack_stack_register",
+ "libname": "liblwip_dpdk.so",
+ "loadtype": "dynmic",
+ "deploytype": "3",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "1",
+ },
+ {
+ "stack_name": "vpp_hoststack",
+ "function_name": "vpphs_stack_register",
+ "libname": "./libdmm_vcl.so",
+ "loadtype": "dynmic",
+ "deploytype": "4",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "2",
+ },
+ ]
+}
diff --git a/demo/nginx_proxy/demo-1/proxy_nginx.conf b/demo/nginx_proxy/demo-1/proxy_nginx.conf
new file mode 100644
index 0000000..05d8d2a
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/proxy_nginx.conf
@@ -0,0 +1,81 @@
+user root;
+worker_processes 1;
+daemon off;
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+
+ #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ # '$status $body_bytes_sent "$http_referer" '
+ # '"$http_user_agent" "$http_x_forwarded_for"';
+
+ #access_log logs/access.log main;
+
+ sendfile on;
+ #tcp_nopush on;
+
+ #keepalive_timeout 0;
+ keepalive_timeout 65;
+
+ #gzip on;
+
+ server {
+ listen 192.168.50.20:80 default_server;
+ server_name 192.168.50.20;
+
+ location / {
+ proxy_bind 172.167.50.20:2020;
+ proxy_pass http://172.167.50.30:80;
+ proxy_set_header X-Real-IP $remote_addr;
+ sendfile off;
+ proxy_buffering off;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ }
+
+ #error_page 404 /404.html;
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+ #
+ #location ~ \.php$ {
+ # proxy_pass http://127.0.0.1;
+ #}
+
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+ #
+ #location ~ \.php$ {
+ # root html;
+ # fastcgi_pass 127.0.0.1:9000;
+ # fastcgi_index index.php;
+ # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
+ # include fastcgi_params;
+ #}
+
+ # deny access to .htaccess files, if Apache's document root
+ # concurs with nginx's one
+ #
+ #location ~ /\.ht {
+ # deny all;
+ #}
+ }
+
+
+}
diff --git a/demo/nginx_proxy/demo-1/rd_config.json b/demo/nginx_proxy/demo-1/rd_config.json
new file mode 100644
index 0000000..71f8919
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/rd_config.json
@@ -0,0 +1,27 @@
+{
+ "ip_route": [
+ {
+ "subnet": "192.168.50.20/32",
+ "stack_name": "lwip",
+ },
+ {
+ "subnet": "192.168.50.10/32",
+ "stack_name": "kernel",
+ },
+ {
+ "subnet": "172.167.50.20/24",
+ "stack_name": "vpp_hoststack",
+ }
+ ],
+ "prot_route": [
+ {
+ "proto_type": "1",
+ "stack_name": "lwip",
+ },
+ {
+ "proto_type": "2",
+ "stack_name": "kernel",
+ }
+ ],
+}
+
diff --git a/demo/nginx_proxy/demo-1/setup_proxy.sh b/demo/nginx_proxy/demo-1/setup_proxy.sh
new file mode 100644
index 0000000..7dc4fa3
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/setup_proxy.sh
@@ -0,0 +1,54 @@
+#########################################################################
+# 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
+sudo su
+# Clean up build NGINX
+cd /DMM/build/
+
+#Download and compile NGINX
+make NGINX
+#Download and compile vpp-stack
+make vpp-stack
+
+#cp vpp libs
+cp -r /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/vpp_plugins /usr/lib/
+mkdir -p /etc/vpp/
+cp /DMM/demo/nginx_proxy/demo-1/startup.conf /etc/vpp/
+cp /DMM/demo/nginx_proxy/demo-1/vpp_config /etc/vpp/
+cd /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/bin
+#run vpp
+sudo ifconfig enp0s9 down
+./vpp -c /etc/vpp/startup.conf
+
+#cp nginx libs
+cd /DMM/thirdparty/apps/nginx/release
+
+# Move the conf file.
+cp /DMM/demo/nginx_proxy/demo-1/module_config.json /DMM/thirdparty/apps/nginx/release/
+cp /DMM/stacks/lwip_stack/app_conf/nStackConfig.json /DMM/thirdparty/apps/nginx/release/
+cp /DMM/demo/nginx_proxy/demo-1/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/
+cp /DMM/demo/nginx_proxy/demo-1/rd_config.json /DMM/thirdparty/apps/nginx/release/
+mv /DMM/thirdparty/apps/nginx/release/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/nginx.conf
+
+sleep 5
+
+# Run nginx
+cp /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/libdmm_vcl.so /DMM/thirdparty/apps/nginx/release/
+echo "export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64"
+echo "./nginx"
+
+exit 0
diff --git a/demo/nginx_proxy/demo-1/setup_upstream.sh b/demo/nginx_proxy/demo-1/setup_upstream.sh
new file mode 100644
index 0000000..0c2c774
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/setup_upstream.sh
@@ -0,0 +1,45 @@
+#########################################################################
+# 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
+
+# Download nginx
+cd /NGINX
+wget http://nginx.org/download/nginx-1.14.0.tar.gz
+tar -zxf nginx-1.14.0.tar.gz
+
+#install supportive softwares
+apt-get install -yq libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev
+
+# Compile nginx
+cd nginx-1.14.0
+./configure
+make
+make install
+
+# Move the conf file.
+cd /usr/local/nginx/sbin
+cp -r * /usr/local/sbin
+cp /NGINX/upstream_nginx.conf /usr/local/nginx/conf/
+mv /usr/local/nginx/conf/upstream_nginx.conf /usr/local/nginx/conf/nginx.conf
+
+# Run nginx
+
+cd /usr/local/sbin
+./nginx
+echo "hi"
+exit 0
+
diff --git a/demo/nginx_proxy/demo-1/startup.conf b/demo/nginx_proxy/demo-1/startup.conf
new file mode 100644
index 0000000..616cd88
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/startup.conf
@@ -0,0 +1,20 @@
+unix {
+ log /var/log/vpp/vpp.log
+ cli-listen localhost:5002
+ exec /etc/vpp/vpp_config
+}
+
+api-trace {
+ on
+}
+
+cpu {
+ main-core 2
+}
+
+dpdk {
+ socket-mem 1024
+ uio-driver igb_uio
+ dev 0000:00:09.0
+}
+
diff --git a/demo/nginx_proxy/demo-1/upstream_nginx.conf b/demo/nginx_proxy/demo-1/upstream_nginx.conf
new file mode 100644
index 0000000..3904197
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/upstream_nginx.conf
@@ -0,0 +1,80 @@
+#user nobody;
+worker_processes 1;
+#daemon off;
+
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+
+ #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ # '$status $body_bytes_sent "$http_referer" '
+ # '"$http_user_agent" "$http_x_forwarded_for"';
+
+ #access_log logs/access.log main;
+
+ sendfile on;
+ #tcp_nopush on;
+
+ #keepalive_timeout 0;
+ keepalive_timeout 65;
+
+ #gzip on;
+
+ server {
+ listen 80;
+ #server_name localhost;
+
+ #charset koi8-r;
+
+ #access_log logs/host.access.log main;
+
+ location / {
+ return 200 "Hello from upstream $hostname $server_addr:$server_port. Connect from $http_x_real_ip - $remote_user via $remote_addr:$remote_port at [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent\n";
+ }
+
+ #error_page 404 /404.html;
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+ #
+ #location ~ \.php$ {
+ # proxy_pass http://127.0.0.1;
+ #}
+
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+ #
+ #location ~ \.php$ {
+ # root html;
+ # fastcgi_pass 127.0.0.1:9000;
+ # fastcgi_index index.php;
+ # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
+ # include fastcgi_params;
+ #}
+
+ # deny access to .htaccess files, if Apache's document root
+ # concurs with nginx's one
+ #
+ #location ~ /\.ht {
+ # deny all;
+ #}
+ }
+
+}
diff --git a/demo/nginx_proxy/demo-1/vpp_config b/demo/nginx_proxy/demo-1/vpp_config
new file mode 100644
index 0000000..aaeadfb
--- /dev/null
+++ b/demo/nginx_proxy/demo-1/vpp_config
@@ -0,0 +1,6 @@
+set int state GigabitEthernet0/9/0 up
+set int ip addr GigabitEthernet0/9/0 172.167.50.20/24
+show version
+show version verbose
+show cpu
+show int
diff --git a/demo/nginx_proxy/demo-2/README.md b/demo/nginx_proxy/demo-2/README.md
new file mode 100644
index 0000000..173e93b
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/README.md
@@ -0,0 +1,69 @@
+#demo-2
+## Introduction
+This demo NGINX as a reverse proxy server. The server uses "lwip" for client facing socket and "kernel tcp/ip stack "
+as upstream server facing socket for UDP, "vpp-hoststack" for another updtream server facing stack for TCP.
+
+## Topology
+![demo-2.png](demo-2.png)
+![dem-2-topo.png](dem-2-topo.png)
+## Steps
+####1. Create VMs using vagrant.
+Start demo VMs. Go to dmm/demo/nginx_proxy/demo-2 .
+```
+$ vagrant up
+```
+This command will create 4 VMs namely rproxy-client, rproxy-server1, rproxy-server2 and rproxy-proxy. The memory
+requirement for this demo is 13GB (approx).
+
+####2. Log in to VMs
+Open four terminal and login to VMs.
+```
+$ vagrant ssh <vm-name>
+```
+
+####3. Run Udp server Application at rproxy-server2
+```
+$ vagrant ssh rproxy-server2
+Inside VM
+vagrant@rproxy-server2:~$ sudo su
+root@rproxy-server2:/home/vagrant# cd /UDPSERVER/
+root@rproxy-server2:/UDPSERVER# ./udpserver
+```
+
+####4. Run NGINX proxy server at rproxy-proxy
+```
+$ vagrant ssh rproxy-proxy
+Inside VM
+vagrant@rproxy-proxy:~$ sudo su
+root@rproxy-proxy:/home/vagrant# cd /DMM/thirdparty/apps/nginx/release
+root@rproxy-proxy:/DMM/thirdparty/apps/nginx/release# export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64
+root@rproxy-proxy:/DMM/thirdparty/apps/nginx/release# ./nginx
+```
+####5. Test TCP traffic
+```
+$ vagrant ssh rproxy-client
+vagrant@rproxy-client:~$ cd /CLIENT/
+vagrant@rproxy-client:/CLIENT$ curl http://192.168.50.20
+Hello from upstream rproxy-server1 172.167.50.30:80. Connect from - via 172.167.50.20:15140 at [12/Nov/2018:06:17:25 -0800] GET / HTTP/1.1 200 0 curl/7.47.0
+
+```
+
+####6. Test UDP traffic
+```
+$ vagrant ssh rproxy-client
+vagrant@rproxy-client:~$ cd /CLIENT/
+vagrant@rproxy-client:/CLIENT$ curl http://192.168.50.20
+Hello message sent.
+Server : Hello from server
+```
+#### Notes:
+a. If enable debugs i.e. export NSTACK_LOG_ON=DBG before we run nginx in rroxy-proxy we can find below logs which suggest we use diffrent stack for diffrent ip/protoccol.
+```
+...
+nstack_bind<NSSOC>fd addr Select module]fd=18,addr=192.168.50.20,module=lwip
+...
+nstack_bind<NSSOC>fd addr Select module]fd=22,addr=172.167.50.20,module=vpp_hoststack
+...
+nstack_bind<NSSOC>fd addr Select module]fd=22,addr=182.167.50.20,module=kernel
+```
+b. This demo depends on commit of dmm. Please check commit version of your code. \ No newline at end of file
diff --git a/demo/nginx_proxy/demo-2/Vagrantfile b/demo/nginx_proxy/demo-2/Vagrantfile
new file mode 100644
index 0000000..dbd703a
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/Vagrantfile
@@ -0,0 +1,116 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+boxes = [
+ {
+ :name => "rproxy-client",
+ :hostname => "rproxy-client",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-server1",
+ :hostname => "rproxy-server1",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-server2",
+ :hostname => "rproxy-server2",
+ :mem => "1024",
+ :cpu => "1"
+ },
+ {
+ :name => "rproxy-proxy",
+ :hostname => "rproxy-proxy",
+ :mem => "10144",
+ :cpu => "4"
+ }
+]
+
+Vagrant.configure(2) do |config|
+
+ # Pick the right distro and bootstrap, default is ubuntu1604
+ distro = ( ENV['DMM_VAGRANT_DISTRO'] || "ubuntu")
+ if distro == 'centos7'
+ config.vm.box = "puppetlabs/centos-7.2-64-nocm"
+ else
+ config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
+ end
+
+ config.vm.box_check_update = false
+ #ddconfig.ssh.password = vagrant
+ if Vagrant.has_plugin?("vagrant-cachier")
+ config.cache.scope = :box
+ end
+
+ # Define some physical ports for your VMs to be used by DPDK
+ #nics = (ENV['DMM_VAGRANT_NICS'] || "2").to_i(10)
+ #for i in 1..nics
+ # config.vm.network "private_network", type: "dhcp"
+ #end
+
+ if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
+ config.proxy.http = ENV['http_proxy']
+ config.proxy.https = ENV['https_proxy']
+ config.proxy.no_proxy = "localhost,127.0.0.1"
+ end
+
+ config.ssh.forward_agent = true
+ config.ssh.forward_x11 = true
+
+ boxes.each do |opts|
+ config.vm.define opts[:name] do |srv|
+ srv.vm.hostname = opts[:hostname]
+ srv.vm.provider "virtualbox" do |vb|
+ vb.customize ["modifyvm", :id, "--ioapic", "on"]
+ vb.customize ["modifyvm", :id, "--memory", opts[:mem]]
+ vb.customize ["modifyvm", :id, "--cpus", opts[:cpu]]
+ end
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh")
+ puts ' '..srv.vm.hostname
+
+ if opts[:name] == "rproxy-proxy"
+ puts 'NGINX Proxy Server, Run nginx in below way '
+ puts 'export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64'
+ puts './DMM/thirdparty/apps/nginx/release/nginx'
+ srv.vm.synced_folder "../../../", "/DMM", type: "rsync"
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"apply_patch.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/build.sh"), :args => "/DMM vagrant"
+ srv.vm.network "private_network", ip: "192.168.50.20"
+ srv.vm.network "private_network", ip: "172.167.50.20"
+ srv.vm.network "private_network", ip: "182.167.50.20"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../stacks/lwip_stack/vagrant/start_nstackMain.sh"), :args => "/DMM vagrant"
+ #possibly overwrite by previous script so adjust again
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"adjust_hugepage.sh"), run: 'always'
+ srv.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"setup_proxy.sh"), run: 'always'
+ end
+ if opts[:name] == "rproxy-client"
+ puts 'Client use command for TCP: curl http://192.168.50.20'
+ puts 'Client use command for UDP: ./udpclient'
+ srv.vm.synced_folder "./", "/CLIENT", type: "rsync"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.network "private_network", ip: "192.168.50.10"
+ srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_client.sh"), run: 'always'
+ end
+ if opts[:name] == "rproxy-server1"
+ puts 'Upstream server 1'
+
+ srv.vm.synced_folder "./", "/NGINX", type: "rsync"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_upstream.sh"), run: 'always'
+ srv.vm.network "private_network", ip: "172.167.50.30"
+ end
+ if opts[:name] == "rproxy-server2"
+ puts 'Upstream server 2 '
+
+ srv.vm.synced_folder "./", "/UDPSERVER", type: "rsync"
+ srv.vm.network "private_network", type: "dhcp"
+ srv.vm.provision "up", type: "shell", :path => File.join(File.dirname(__FILE__),"setup_udpserver.sh"), run: 'always'
+ srv.vm.network "private_network", ip: "182.167.50.30"
+ end
+ end
+ end
+end
diff --git a/demo/nginx_proxy/demo-2/adjust_hugepage.sh b/demo/nginx_proxy/demo-2/adjust_hugepage.sh
new file mode 100644
index 0000000..282e3bd
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/adjust_hugepage.sh
@@ -0,0 +1,14 @@
+#!/bin/bash -x
+hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'})
+if [ "$hugepagesize" == "2048" ]; then
+ pages=3000
+elif [ "$hugepagesize" == "1048576" ]; then
+ pages=5
+fi
+sudo sysctl -w vm.nr_hugepages=$pages
+HUGEPAGES=`sysctl -n vm.nr_hugepages`
+echo "Configured hugepages: $HUGEPAGE"
+if [ $HUGEPAGES != $pages ]; then
+ echo "Warning: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish."
+fi
+
diff --git a/demo/nginx_proxy/demo-2/apply_patch.sh b/demo/nginx_proxy/demo-2/apply_patch.sh
new file mode 100755
index 0000000..05e8c66
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/apply_patch.sh
@@ -0,0 +1,9 @@
+#!/bin/bash -x
+sudo apt-get install patch -y
+cd /DMM/src/
+sudo patch -p2 -i /DMM/demo/nginx_proxy/demo-2/demo_2stack.patch
+if [ $? -ne 0 ]; then
+ echo "Patch Apply failed. Downlaod correct commit. Check README for details."
+ exit -1
+fi
+cd -
diff --git a/demo/nginx_proxy/demo-2/dem-2-topo.png b/demo/nginx_proxy/demo-2/dem-2-topo.png
new file mode 100644
index 0000000..ad81372
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/dem-2-topo.png
Binary files differ
diff --git a/demo/nginx_proxy/demo-2/demo-2.png b/demo/nginx_proxy/demo-2/demo-2.png
new file mode 100644
index 0000000..604c301
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/demo-2.png
Binary files differ
diff --git a/demo/nginx_proxy/demo-2/demo_2stack.patch b/demo/nginx_proxy/demo-2/demo_2stack.patch
new file mode 100644
index 0000000..f1bc8d3
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/demo_2stack.patch
@@ -0,0 +1,29 @@
+diff --git a/src/adapt/nstack_dmm_adpt.c b/src/adapt/nstack_dmm_adpt.c
+index d497b80..004975c 100644
+--- a/src/adapt/nstack_dmm_adpt.c
++++ b/src/adapt/nstack_dmm_adpt.c
+@@ -76,7 +76,7 @@ nstack_event_callback (void *pdata, int events)
+ /*event should not notice other process */
+ if ((ep->pid != get_sys_pid ()) && g_same_process)
+ {
+- continue;
++ //continue;
+ }
+
+ sys_arch_lock_with_pid (&ep->lock);
+diff --git a/src/nSocket/nstack/nstack_module.c b/src/nSocket/nstack/nstack_module.c
+index 9566ab8..f692225 100644
+--- a/src/nSocket/nstack/nstack_module.c
++++ b/src/nSocket/nstack/nstack_module.c
+@@ -60,6 +60,11 @@ nstack_get_deploy_type ()
+ if (g_nstack_module_desc[icnt].deploytype > type)
+ {
+ type = g_nstack_module_desc[icnt].deploytype;
++ if (NSTACK_MODEL_TYPE3 == type)
++ {
++ break;
++ }
++
+ }
+ }
+ return type;
diff --git a/demo/nginx_proxy/demo-2/module_config.json b/demo/nginx_proxy/demo-2/module_config.json
new file mode 100644
index 0000000..5861153
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/module_config.json
@@ -0,0 +1,38 @@
+{
+ "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",
+ },
+ {
+ "stack_name": "lwip",
+ "function_name": "nstack_stack_register",
+ "libname": "liblwip_dpdk.so",
+ "loadtype": "dynmic",
+ "deploytype": "3",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "1",
+ },
+ {
+ "stack_name": "vpp_hoststack",
+ "function_name": "vpphs_stack_register",
+ "libname": "./libdmm_vcl.so",
+ "loadtype": "dynmic",
+ "deploytype": "4",
+ "maxfd": "1024",
+ "minfd": "0",
+ "priorty": "1",
+ "stackid": "2",
+ },
+ ]
+}
diff --git a/demo/nginx_proxy/demo-2/proxy_nginx.conf b/demo/nginx_proxy/demo-2/proxy_nginx.conf
new file mode 100644
index 0000000..925e1a9
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/proxy_nginx.conf
@@ -0,0 +1,33 @@
+user root;
+worker_processes 1;
+daemon off;
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+stream {
+ upstream stream_tcp {
+ server 172.167.50.30:80;
+ }
+ upstream stream_udp {
+ server 182.167.50.30:53;
+ }
+ server {
+ listen 192.168.50.20:80;
+ proxy_bind 172.167.50.20:2020;
+ proxy_pass stream_tcp;
+ }
+ server {
+ listen 192.168.50.20:53 udp;
+ proxy_bind 182.167.50.20:53;
+ proxy_pass stream_udp;
+ }
+}
+
diff --git a/demo/nginx_proxy/demo-2/rd_config.json b/demo/nginx_proxy/demo-2/rd_config.json
new file mode 100644
index 0000000..45ad585
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/rd_config.json
@@ -0,0 +1,31 @@
+{
+ "ip_route": [
+ {
+ "subnet": "192.168.50.20/32",
+ "stack_name": "lwip",
+ },
+ {
+ "subnet": "192.168.50.10/32",
+ "stack_name": "kernel",
+ },
+ {
+ "subnet": "172.167.50.20/24",
+ "stack_name": "vpp_hoststack",
+ },
+ {
+ "subnet": "182.167.50.20/32",
+ "stack_name": "kernel",
+ }
+ ],
+ "prot_route": [
+ {
+ "proto_type": "1",
+ "stack_name": "lwip",
+ },
+ {
+ "proto_type": "2",
+ "stack_name": "kernel",
+ }
+ ],
+}
+
diff --git a/demo/nginx_proxy/demo-2/setup_client.sh b/demo/nginx_proxy/demo-2/setup_client.sh
new file mode 100644
index 0000000..a0f4363
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/setup_client.sh
@@ -0,0 +1,25 @@
+#########################################################################
+# 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
+
+# Download nginx
+cd /CLIENT
+
+gcc udpclient.c -o udpclient
+
+exit 0
+
diff --git a/demo/nginx_proxy/demo-2/setup_proxy.sh b/demo/nginx_proxy/demo-2/setup_proxy.sh
new file mode 100644
index 0000000..fc2039c
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/setup_proxy.sh
@@ -0,0 +1,54 @@
+#########################################################################
+# 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
+sudo su
+# Clean up build NGINX
+cd /DMM/build/
+
+#Download and compile NGINX
+make NGINX
+#Download and compile vpp-stack
+make vpp-stack
+
+#cp vpp libs
+cp -r /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/vpp_plugins /usr/lib/
+mkdir -p /etc/vpp/
+cp /DMM/demo/nginx_proxy/demo-2/startup.conf /etc/vpp/
+cp /DMM/demo/nginx_proxy/demo-2/vpp_config /etc/vpp/
+cd /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/bin
+#run vpp
+sudo ifconfig enp0s9 down
+./vpp -c /etc/vpp/startup.conf
+
+#cp nginx libs
+cd /DMM/thirdparty/apps/nginx/release
+
+# Move the conf file.
+cp /DMM/demo/nginx_proxy/demo-2/module_config.json /DMM/thirdparty/apps/nginx/release/
+cp /DMM/stacks/lwip_stack/app_conf/nStackConfig.json /DMM/thirdparty/apps/nginx/release/
+cp /DMM/demo/nginx_proxy/demo-2/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/
+cp /DMM/demo/nginx_proxy/demo-2/rd_config.json /DMM/thirdparty/apps/nginx/release/
+mv /DMM/thirdparty/apps/nginx/release/proxy_nginx.conf /DMM/thirdparty/apps/nginx/release/nginx.conf
+
+sleep 5
+
+# Run nginx
+cp /DMM/stacks/vpp/vpp/build-root/install-vpp_debug-native/vpp/lib64/libdmm_vcl.so /DMM/thirdparty/apps/nginx/release/
+echo "export LD_LIBRARY_PATH=/DMM/stacks/lwip_stack/release/lib64"
+echo "./nginx"
+
+exit 0
diff --git a/demo/nginx_proxy/demo-2/setup_udpserver.sh b/demo/nginx_proxy/demo-2/setup_udpserver.sh
new file mode 100644
index 0000000..d684286
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/setup_udpserver.sh
@@ -0,0 +1,25 @@
+#########################################################################
+# 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
+
+# Download nginx
+cd /UDPSERVER
+
+gcc udpserver.c -o udpserver
+
+exit 0
+
diff --git a/demo/nginx_proxy/demo-2/setup_upstream.sh b/demo/nginx_proxy/demo-2/setup_upstream.sh
new file mode 100644
index 0000000..ee7dbd4
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/setup_upstream.sh
@@ -0,0 +1,44 @@
+#########################################################################
+# 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
+
+# Download nginx
+cd /NGINX
+wget http://nginx.org/download/nginx-1.14.0.tar.gz
+tar -zxf nginx-1.14.0.tar.gz
+
+#install supportive softwares
+apt-get install -yq libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev
+
+# Compile nginx
+cd nginx-1.14.0
+./configure
+make
+make install
+
+# Move the conf file.
+cd /usr/local/nginx/sbin
+cp -r * /usr/local/sbin
+cp /NGINX/upstream_nginx.conf /usr/local/nginx/conf/
+mv /usr/local/nginx/conf/upstream_nginx.conf /usr/local/nginx/conf/nginx.conf
+
+# Run nginx
+
+cd /usr/local/sbin
+./nginx
+exit 0
+
diff --git a/demo/nginx_proxy/demo-2/startup.conf b/demo/nginx_proxy/demo-2/startup.conf
new file mode 100644
index 0000000..616cd88
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/startup.conf
@@ -0,0 +1,20 @@
+unix {
+ log /var/log/vpp/vpp.log
+ cli-listen localhost:5002
+ exec /etc/vpp/vpp_config
+}
+
+api-trace {
+ on
+}
+
+cpu {
+ main-core 2
+}
+
+dpdk {
+ socket-mem 1024
+ uio-driver igb_uio
+ dev 0000:00:09.0
+}
+
diff --git a/demo/nginx_proxy/demo-2/udpclient.c b/demo/nginx_proxy/demo-2/udpclient.c
new file mode 100644
index 0000000..76e7b05
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/udpclient.c
@@ -0,0 +1,50 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#define PORT 53
+#define MAXLINE 1024
+
+// Driver code
+int
+main ()
+{
+ int sockfd;
+ char buffer[MAXLINE];
+ char *hello = "Hello from client";
+ struct sockaddr_in servaddr;
+
+ // Creating socket file descriptor
+ if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
+ {
+ perror ("socket creation failed");
+ exit (EXIT_FAILURE);
+ }
+
+ memset (&servaddr, 0, sizeof (servaddr));
+
+ // Filling server information
+ servaddr.sin_family = AF_INET;
+ servaddr.sin_port = htons (PORT);
+ servaddr.sin_addr.s_addr = inet_addr ("192.168.50.20");
+
+ int n, len;
+
+ sendto (sockfd, (const char *) hello, strlen (hello),
+ MSG_CONFIRM, (const struct sockaddr *) &servaddr,
+ sizeof (servaddr));
+ printf ("Hello message sent.\n");
+
+ n = recvfrom (sockfd, (char *) buffer, MAXLINE,
+ MSG_WAITALL, (struct sockaddr *) &servaddr, &len);
+ buffer[n] = '\0';
+ printf ("Server : %s\n", buffer);
+
+ close (sockfd);
+ return 0;
+}
diff --git a/demo/nginx_proxy/demo-2/udpserver.c b/demo/nginx_proxy/demo-2/udpserver.c
new file mode 100644
index 0000000..456c7fc
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/udpserver.c
@@ -0,0 +1,55 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+
+#define PORT 53
+#define MAXLINE 1024
+
+int
+main ()
+{
+ int sockfd;
+ char buffer[MAXLINE];
+ char *hello = "Hello from server";
+
+ struct sockaddr_in servaddr, cliaddr;
+ char name[128] = { 0 };
+
+ // Creating socket file descriptor
+ if ((sockfd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
+ {
+ perror ("socket creation failed");
+ exit (EXIT_FAILURE);
+ }
+
+ memset (&servaddr, 0, sizeof (servaddr));
+ memset (&cliaddr, 0, sizeof (cliaddr));
+
+ // Filling server information
+ servaddr.sin_family = AF_INET; // IPv4
+ servaddr.sin_addr.s_addr = inet_addr ("182.167.50.30");
+ servaddr.sin_port = htons (PORT);
+
+ if (bind (sockfd, (const struct sockaddr *) &servaddr,
+ sizeof (servaddr)) < 0)
+ {
+ perror ("bind failed");
+ exit (EXIT_FAILURE);
+ }
+
+ int len, n;
+ n = recvfrom (sockfd, (char *) buffer, MAXLINE,
+ MSG_WAITALL, (struct sockaddr *) &cliaddr, &len);
+ buffer[n] = '\0';
+ (void) gethostname (name, 127);
+ printf ("Client : %s \n", buffer);
+ sendto (sockfd, (const char *) hello, strlen (hello),
+ MSG_CONFIRM, (const struct sockaddr *) &cliaddr, len);
+ printf ("%s\n", hello);
+ return 0;
+}
diff --git a/demo/nginx_proxy/demo-2/upstream_nginx.conf b/demo/nginx_proxy/demo-2/upstream_nginx.conf
new file mode 100644
index 0000000..3904197
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/upstream_nginx.conf
@@ -0,0 +1,80 @@
+#user nobody;
+worker_processes 1;
+#daemon off;
+
+#error_log logs/error.log;
+#error_log logs/error.log notice;
+#error_log logs/error.log info;
+
+#pid logs/nginx.pid;
+
+
+events {
+ worker_connections 1024;
+}
+
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+
+ #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ # '$status $body_bytes_sent "$http_referer" '
+ # '"$http_user_agent" "$http_x_forwarded_for"';
+
+ #access_log logs/access.log main;
+
+ sendfile on;
+ #tcp_nopush on;
+
+ #keepalive_timeout 0;
+ keepalive_timeout 65;
+
+ #gzip on;
+
+ server {
+ listen 80;
+ #server_name localhost;
+
+ #charset koi8-r;
+
+ #access_log logs/host.access.log main;
+
+ location / {
+ return 200 "Hello from upstream $hostname $server_addr:$server_port. Connect from $http_x_real_ip - $remote_user via $remote_addr:$remote_port at [$time_local] $request $status $body_bytes_sent $http_referer $http_user_agent\n";
+ }
+
+ #error_page 404 /404.html;
+
+ # redirect server error pages to the static page /50x.html
+ #
+ error_page 500 502 503 504 /50x.html;
+ location = /50x.html {
+ root html;
+ }
+
+ # proxy the PHP scripts to Apache listening on 127.0.0.1:80
+ #
+ #location ~ \.php$ {
+ # proxy_pass http://127.0.0.1;
+ #}
+
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+ #
+ #location ~ \.php$ {
+ # root html;
+ # fastcgi_pass 127.0.0.1:9000;
+ # fastcgi_index index.php;
+ # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
+ # include fastcgi_params;
+ #}
+
+ # deny access to .htaccess files, if Apache's document root
+ # concurs with nginx's one
+ #
+ #location ~ /\.ht {
+ # deny all;
+ #}
+ }
+
+}
diff --git a/demo/nginx_proxy/demo-2/vpp_config b/demo/nginx_proxy/demo-2/vpp_config
new file mode 100644
index 0000000..aaeadfb
--- /dev/null
+++ b/demo/nginx_proxy/demo-2/vpp_config
@@ -0,0 +1,6 @@
+set int state GigabitEthernet0/9/0 up
+set int ip addr GigabitEthernet0/9/0 172.167.50.20/24
+show version
+show version verbose
+show cpu
+show int
diff --git a/docker/dmm_image/README.md b/docker/dmm_image/README.md
new file mode 100644
index 0000000..0b674b2
--- /dev/null
+++ b/docker/dmm_image/README.md
@@ -0,0 +1,13 @@
+# How to build the image of dmm
+Note: Make sure your computer can connect to the network
+```sh
+ #cd dmm/docker/dmm_image/centos
+ #docker build -t "dmm:tag" .
+```
+
+# How to use the image of dmm
+```sh
+ #docker run -i -t --network=host -v /sys/bus/pci/devices:/sys/bus/pci/devices -v /sys/devices/system/node:/sys/devices/system/node -v /mnt/nstackhuge:/mnt/nstackhuge -v /dev:/dev --privileged dmm:tag /bin/bash
+```
+
+Then we will enter a container and we can build dmm and run the app.
diff --git a/docker/dmm_image/centos/Dockerfile b/docker/dmm_image/centos/Dockerfile
new file mode 100644
index 0000000..de772fe
--- /dev/null
+++ b/docker/dmm_image/centos/Dockerfile
@@ -0,0 +1,17 @@
+FROM docker.io/centos:latest
+
+RUN yum install -y git vim sudo ethtool
+
+RUN yum install -y kernel-devel-`uname -r`
+RUN yum install -y kernel-`uname -r`
+
+RUN git config --global http.sslVerify false
+RUN git config --global user.email "you@example.com"
+RUN git config --global user.name "Your Name"
+
+RUN git clone https://gerrit.fd.io/r/dmm
+
+RUN mkdir -p /var/run/ip_module/
+RUN mkdir -p /var/log/nStack/ip_module/
+
+RUN cd /dmm/scripts/ && bash -x build.sh && cd /dmm/ && git clean -dfx ./ && git checkout ./
diff --git a/pkg/deb/control b/pkg/deb/control
index a373fef..24302e3 100644
--- a/pkg/deb/control
+++ b/pkg/deb/control
@@ -1,5 +1,5 @@
Package: dmm
-Version: 18.07
+Version: 18.10
Section: tuils
Priority: optional
Depends: libc6, libstdc++6, libgcc1
diff --git a/pkg/rpm/dmm.spec b/pkg/rpm/dmm.spec
index 79dfb05..51ebef1 100644
--- a/pkg/rpm/dmm.spec
+++ b/pkg/rpm/dmm.spec
@@ -1,5 +1,5 @@
Name: dmm
-Version: 18.07
+Version: 18.10
Release: 1%{?dist}
Summary: DMM Project
diff --git a/scripts/build_dpdk1805.sh b/scripts/build_dpdk1805.sh
deleted file mode 100755
index 2727877..0000000
--- a/scripts/build_dpdk1805.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/bin/bash -x
-#########################################################################
-#
-# 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.
-#########################################################################
-
-echo "check whether dpdk installed"
-cur_directory=${PWD}
-check_dpdk=$(rpm -qa | grep dpdk)
-if [ -z "$check_dpdk" ]; then
- echo "system will install the dpdk"
-else
- echo "system has installed the dpdk"
- echo "$check_dpdk"
- exit 0
-fi
-
-cd ~
-mkdir -p rpmbuild/SOURCES
-
-cd ~/rpmbuild/SOURCES
-
-if [ ! -s dpdk-18.05.tar.gz ]; then
-wget http://dpdk.org/browse/dpdk/snapshot/dpdk-18.05.tar.gz
-fi
-
-tar xzvf dpdk-18.05.tar.gz
-cp dpdk-18.05/pkg/dpdk.spec ~/rpmbuild/SOURCES/
-
-echo "modify the spec"
-
-#get rid of the dependence of texlive-collection
-sed -i '/BuildRequires: texlive-collection/s/^/#&/' dpdk.spec
-
-#delete something of generating doc
-sed -i '/%{target} doc/s/^/#&/' dpdk.spec
-sed -i '70d' dpdk.spec
-sed -i '69a datadir=%{_datadir}/dpdk' dpdk.spec
-sed -i '70a # datadir=%{_datadir}/dpdk docdir=%{_docdir}/dpdk' dpdk.spec
-sed -i '/%files doc/s/^/#&/' dpdk.spec
-sed -i '/%doc %{_docdir}/s/^/#&/' dpdk.spec
-
-sed -i '54a sed -i '\''s!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1'\'' config/common_base' dpdk.spec
-sed -i '55a sed -i '\''s!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1'\'' config/common_base' dpdk.spec
-sed -i '56a sed -i '\''s!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1'\'' config/common_base' dpdk.spec
-sed -i '57a sed -i '\''s!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1'\'' config/common_base' dpdk.spec
-sed -i '58a sed -i '\''s!CONFIG_RTE_LIBRTE_DPAA2_USE_PHYS_IOVA=.*!CONFIG_RTE_LIBRTE_DPAA2_USE_PHYS_IOVA=n!1'\'' config/common_base' dpdk.spec
-
-echo "build the dependence"
-#sudo yum-builddep -y dpdk.spec
-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 "dpdk rpm build success"
-else
- echo "dpdk rpm build error"
- exit 1
-fi
-
-echo "install the rpm"
-cd ../RPMS/x86_64/
-sudo rpm -ivh dpdk-18.05-1.x86_64.rpm || exit 1
-sudo rpm -ivh dpdk-devel-18.05-1.x86_64.rpm || exit 1
-
-mkdir -p /tmp/dpdk/drivers/
-cp -f /usr/lib64/librte_mempool_ring.so /tmp/dpdk/drivers/
-
-cd ${cur_directory}
diff --git a/scripts/build_rsocket.sh b/scripts/build_rsocket.sh
index ef31c88..9075e3c 100755
--- a/scripts/build_rsocket.sh
+++ b/scripts/build_rsocket.sh
@@ -7,21 +7,34 @@ 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
+ INSTALLED=`apt list --installed | grep mlnx-ofed`
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
+ INSTALLED=`rpm -qa | grep mlnx-ofed`
fi
-sudo ./mlnxofedinstall --force || exit 1
+############### build rsocket
+echo "rsocket build start"
+cd $DMM_DIR/stacks/rsocket
+
+if [ -z $INSTALLED ]; then
+ 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
+ else
+ echo "NOT SUPPORT $OS_ID"
+ exit 1
+ fi
+
+ sudo ./mlnxofedinstall --force || exit 1
+
+fi
cd $BUILD_DIR
make dmm_rsocket
@@ -31,4 +44,4 @@ else
echo "rsocket build has FAILED"
exit 1
fi
-echo "rsocket build finished" \ No newline at end of file
+echo "rsocket build finished"
diff --git a/scripts/generate_dmm_rpm.sh b/scripts/generate_dmm_rpm.sh
index 76d65a1..f43e8cf 100755
--- a/scripts/generate_dmm_rpm.sh
+++ b/scripts/generate_dmm_rpm.sh
@@ -17,7 +17,7 @@
cur_directory=${PWD}
name="dmm"
-version="18.07"
+version="18.10"
mkdir -p ~/rpmbuild/SOURCES
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1069e7f..0eca7a1 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.07")
+ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.10")
#LINK_DIRECTORIES(${LIB_PATH_SHARED} ${LIB_PATH_STATIC})
if(WITH_SECUREC_LIB)
diff --git a/src/framework/common/base/include/common/common_mem_buf.h b/src/framework/common/base/include/common/common_mem_buf.h
index f9f1593..c9bb9fd 100644
--- a/src/framework/common/base/include/common/common_mem_buf.h
+++ b/src/framework/common/base/include/common/common_mem_buf.h
@@ -20,6 +20,7 @@
#ifdef HAL_LIB
#else
+#include "nsfw_mem_api.h"
#include "common_mem_base_type.h"
#include "types.h"
@@ -64,7 +65,8 @@ typedef struct __common_pal_module_info
* @param name
* The name of the buf pool.
*/
-int nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode);
+int nscomm_pal_module_init (nsfw_mem_para * para,
+ common_mem_pal_module_info * pinfo, u8 app_mode);
void *nscomm_memzone_data_reserve_name (const char *name, size_t len,
int socket_id);
diff --git a/src/framework/common/base/liblinuxapi/nsfw_lock_file.c b/src/framework/common/base/liblinuxapi/nsfw_lock_file.c
index abfbfd1..cef8d95 100644
--- a/src/framework/common/base/liblinuxapi/nsfw_lock_file.c
+++ b/src/framework/common/base/liblinuxapi/nsfw_lock_file.c
@@ -94,6 +94,8 @@ nsfw_proc_start_with_lock (u8 proc_type)
return -1;
}
+ nsfw_mgr_com_mkdir_domainpath (lock_fpath);
+
ret = STRCAT_S (lock_fpath, NSFW_FILE_PATH_LEN, module_name);
if (EOK != ret)
{
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 ba38c32..77ffd19 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,18 +73,11 @@ nsfw_shmem_init (nsfw_mem_para * para)
NSCOMM_LOGINF ("nsfw shmem init begin");
- if (NSFW_PROC_MAIN == para->enflag)
- {
- iret = common_pal_module_init (NULL, app_mode);
- }
- else
- {
- LCORE_MASK_SET (rteinfo.ilcoremask, 1);
- rteinfo.ucproctype = DMM_PROC_T_SECONDARY;
- iret = common_pal_module_init (&rteinfo, app_mode);
- }
+ LCORE_MASK_SET (rteinfo.ilcoremask, 1);
+ rteinfo.ucproctype = DMM_PROC_T_SECONDARY;
+ iret = common_pal_module_init (para, &rteinfo, app_mode);
- if (NSFW_MEM_OK != iret)
+ if (DMM_MBUF_RET_OK != iret)
{
NSCOMM_LOGERR ("rte init fail] ret=0x%x", iret);
return NSFW_MEM_ERR;
diff --git a/src/framework/hal/hal.c b/src/framework/hal/hal.c
index 545c759..49b1fb7 100644
--- a/src/framework/hal/hal.c
+++ b/src/framework/hal/hal.c
@@ -312,7 +312,7 @@ hal_get_invalid_hdl ()
Called By :
*****************************************************************************/
hal_hdl_t
-hal_create (const char *name, hal_netif_config_t * conf)
+hal_create (const char *name, const char *nic_type, hal_netif_config_t * conf)
{
int ret = -1;
uint32_t netif_type;
@@ -336,7 +336,7 @@ hal_create (const char *name, hal_netif_config_t * conf)
/*open */
for (netif_type = 0; NULL != netif_ops_table[netif_type]; ++netif_type)
{
- ret = netif_ops_table[netif_type]->open (inst, name);
+ ret = netif_ops_table[netif_type]->open (inst, name, nic_type);
if (0 == ret)
{
diff --git a/src/framework/hal/hal.h b/src/framework/hal/hal.h
index 36ad79d..5a8f51e 100644
--- a/src/framework/hal/hal.h
+++ b/src/framework/hal/hal.h
@@ -66,6 +66,7 @@ typedef struct dpdk_if
char pci_addr[HAL_MAX_PCI_ADDR_LEN];
char nic_name[HAL_MAX_NIC_NAME_LEN];
+ char nic_type[HAL_MAX_NIC_NAME_LEN];
char driver_name[HAL_MAX_DRIVER_NAME_LEN];
} dpdk_if_t;
@@ -93,7 +94,7 @@ typedef struct netif_ops
const char *name;
int (*init_global) (int argc, char **argv);
int (*init_local) (void);
- int (*open) (netif_inst_t * inst, const char *name);
+ int (*open) (netif_inst_t * inst, const char *name, const char *type);
int (*close) (netif_inst_t * inst);
int (*start) (netif_inst_t * inst);
int (*stop) (netif_inst_t * inst);
diff --git a/src/framework/include/hal_api.h b/src/framework/include/hal_api.h
index 90c3100..a5d7725 100644
--- a/src/framework/include/hal_api.h
+++ b/src/framework/include/hal_api.h
@@ -110,7 +110,8 @@ typedef struct hal_netif_config
int hal_init_global (int argc, char **argv);
int hal_init_local ();
-hal_hdl_t hal_create (const char *name, hal_netif_config_t * conf);
+hal_hdl_t hal_create (const char *name, const char *nic_type,
+ hal_netif_config_t * conf);
hal_hdl_t hal_bond (const char *bond_name, uint8_t slave_num,
hal_hdl_t slave_hdl[]);
diff --git a/src/framework/include/nsfw_mgr_com_api.h b/src/framework/include/nsfw_mgr_com_api.h
index 56ec08f..9bbcaca 100644
--- a/src/framework/include/nsfw_mgr_com_api.h
+++ b/src/framework/include/nsfw_mgr_com_api.h
@@ -186,6 +186,7 @@ extern int nsfw_mgr_run_script (const char *cmd, char *result,
extern int nsfw_mgr_com_chk_hbt (int v_add);
extern i32 nsfw_set_close_on_exec (i32 sock);
extern int nsfw_mgr_comm_fd_init (u32 proc_type);
+extern void nsfw_mgr_com_mkdir_domainpath (char *pathname);
#ifdef __cplusplus
/* *INDENT-OFF* */
diff --git a/src/framework/include/nstack_log.h b/src/framework/include/nstack_log.h
index 4e1ba81..9473aa4 100644
--- a/src/framework/include/nstack_log.h
+++ b/src/framework/include/nstack_log.h
@@ -318,11 +318,11 @@ extern int ctrl_log_switch;
#define NSMON_LOGWAR(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_WAR,fmt,##__VA_ARGS__)
#define NSMON_LOGERR(fmt, ...) NS_LOGPID(MASTER,"NSMON",NSLOG_ERR,fmt,##__VA_ARGS__)
-#define NSPOL_LOGINF(debug,fmt, ...)NS_LOG_STACKX(debug,STACKX,"NSPOL",NSLOG_INF,fmt,##__VA_ARGS__)
-#define NSPOL_LOGDBG(debug,fmt, ...) NS_LOG_STACKX(debug,STACKX,"NSPOL",NSLOG_DBG,fmt,##__VA_ARGS__)
-#define NSPOL_LOGWAR(debug,fmt, ...) NS_LOG_STACKX(debug,STACKX,"NSPOL",NSLOG_WAR,fmt,##__VA_ARGS__)
-#define NSPOL_LOGERR(fmt, ...) NS_LOGPID(STACKX,"NSPOL",NSLOG_ERR,fmt,##__VA_ARGS__)
-#define NSPOL_LOGEMG(fmt, ...) NS_LOGPID(STACKX,"NSPOL",NSLOG_EMG,fmt,##__VA_ARGS__)
+#define NSPOL_LOGINF(debug,fmt, ...)NS_LOG_STACKX(debug,STACKX,"NSLWIP",NSLOG_INF,fmt,##__VA_ARGS__)
+#define NSPOL_LOGDBG(debug,fmt, ...) NS_LOG_STACKX(debug,STACKX,"NSLWIP",NSLOG_DBG,fmt,##__VA_ARGS__)
+#define NSPOL_LOGWAR(debug,fmt, ...) NS_LOG_STACKX(debug,STACKX,"NSLWIP",NSLOG_WAR,fmt,##__VA_ARGS__)
+#define NSPOL_LOGERR(fmt, ...) NS_LOGPID(STACKX,"NSLWIP",NSLOG_ERR,fmt,##__VA_ARGS__)
+#define NSPOL_LOGEMG(fmt, ...) NS_LOGPID(STACKX,"NSLWIP",NSLOG_EMG,fmt,##__VA_ARGS__)
#define NSOPR_LOGINF(fmt, ...) NS_LOGPID(OPERATION,"NSOPR",NSLOG_INF,fmt,##__VA_ARGS__)
#define NSOPR_LOGDBG(fmt, ...) NS_LOGPID(OPERATION,"NSOPR",NSLOG_DBG,fmt,##__VA_ARGS__)
@@ -403,10 +403,10 @@ extern int ctrl_log_switch;
} \
#define INITPOL_LOGINF(init_module_name, function, err_string, err_value, status) \
- INIT_LOG_ASSEM(STACKX,"NSPOL",NSLOG_INF,init_module_name , function, err_string, err_value, status)\
+ INIT_LOG_ASSEM(STACKX,"NSLWIP",NSLOG_INF,init_module_name , function, err_string, err_value, status)\
#define INITPOL_LOGERR(init_module_name, function, err_string, err_value, status) \
- INIT_LOG_ASSEM(STACKX,"NSPOL",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
+ INIT_LOG_ASSEM(STACKX,"NSLWIP",NSLOG_ERR,init_module_name , function, err_string, err_value, status)\
#define INITTCP_LOGINF(init_module_name , function, err_string, err_value, status) \
INIT_LOG_ASSEM(LOGTCP,"NSTCP",NSLOG_INF,init_module_name , function, err_string, err_value, status)\
diff --git a/src/framework/ipc/mgr_com/mgr_com.c b/src/framework/ipc/mgr_com/mgr_com.c
index 2fb9789..a2998fa 100644
--- a/src/framework/ipc/mgr_com/mgr_com.c
+++ b/src/framework/ipc/mgr_com/mgr_com.c
@@ -1828,7 +1828,6 @@ nsfw_mgr_comm_fd_init (u32 proc_type)
* Calls :
* Called By :
*****************************************************************************/
-void nsfw_mgr_com_mkdir_domainpath (char *pathname);
void
nsfw_mgr_com_mkdir_domainpath (char *pathname)
{
diff --git a/src/framework/lib_common_mem/common_buf.c b/src/framework/lib_common_mem/common_buf.c
index 9d9a127..d31ca83 100644
--- a/src/framework/lib_common_mem/common_buf.c
+++ b/src/framework/lib_common_mem/common_buf.c
@@ -88,7 +88,8 @@
int log_level = LOG_INFO;
int
-nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode)
+nscomm_pal_module_init (nsfw_mem_para * para,
+ common_mem_pal_module_info * pinfo, u8 app_mode)
{
char tempargv[PATA_NUM_MAX][PATA_STRLENT];
char *argv[PATA_NUM_MAX];
@@ -100,6 +101,12 @@ nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode)
int retVal;
char name[10] = { '\0' };
+ if (para == NULL)
+ {
+ NSCOMM_LOGERR ("para is null");
+ return DMM_MBUF_RET_ERR;
+ }
+
retVal = MEMSET_S (tempargv, sizeof (tempargv), '\0', sizeof (tempargv));
if (EOK != retVal)
{
@@ -112,8 +119,21 @@ nscomm_pal_module_init (common_mem_pal_module_info * pinfo, u8 app_mode)
NSCOMM_LOGERR ("MEMSET_S failed]ret=%d", retVal);
return DMM_MBUF_RET_ERR;
}
- if (NULL == pinfo)
+ if (NSFW_PROC_MAIN == para->enflag)
{
+ if (para->iargsnum != 0)
+ {
+ if (common_mem_pal_init (para->iargsnum, para->pargs) < 0)
+ {
+ COMMON_LOG_PRINT (LOG_ERR, "Cannot init pal\r\n");
+ return DMM_MBUF_RET_ERR;
+ }
+ else
+ {
+ return DMM_MBUF_RET_OK;
+ }
+ }
+
PARA1_SET (argv, tempargv, agindex, "nStackMain");
PARA2_SET (argv, tempargv, agindex, "-c", "0x1");
PARA2_SET (argv, tempargv, agindex, "-n", "4");
diff --git a/src/nSocket/nstack/nstack.c b/src/nSocket/nstack/nstack.c
index 225c297..9d6a2ba 100644
--- a/src/nSocket/nstack/nstack.c
+++ b/src/nSocket/nstack/nstack.c
@@ -285,44 +285,8 @@ match_version (char *nstack_ver, char *my_ver)
return 0;
}
- char *nstack_ver_head = NULL;
- char *my_ver_head = NULL;
- char nstack_version[NSTACK_VERSION_LEN] = { 0 };
- char my_version[NSTACK_VERSION_LEN] = { 0 };
-
- // !!!STRTOK_S will modify the original string, so use use temp for parameter
- /* use STRCPY_S instead of MEMCPY_S to avoid invalid memory visit */
- if (EOK != STRCPY_S (nstack_version, sizeof (nstack_version), nstack_ver))
- {
- return 0;
- }
-
- nstack_ver_head = get_ver_head (nstack_version);
- if (NULL == nstack_ver_head)
- {
- return 0;
- }
-
- /*use STRCPY_S instead of MEMCPY_S to avoid invalid memory visit */
- if (EOK != STRCPY_S (my_version, sizeof (my_version), my_ver))
- {
- return 0;
- }
-
- my_ver_head = get_ver_head (my_version);
- if (NULL == my_ver_head)
- {
- return 0;
- }
-
- if (strlen (my_ver_head) != strlen (nstack_ver_head))
- {
- return 0;
- }
-
-
- if (0 != strncmp (nstack_ver_head, my_ver_head, strlen (nstack_ver_head)))
+ if (0 != strncmp (nstack_ver, my_ver, 5))
{
return 0;
}
diff --git a/src/nSocket/nstack/nstack_socket.c b/src/nSocket/nstack/nstack_socket.c
index c967d64..210e29d 100644
--- a/src/nSocket/nstack/nstack_socket.c
+++ b/src/nSocket/nstack/nstack_socket.c
@@ -141,12 +141,10 @@ int
nstack_socket (int domain, int itype, int protocol)
{
int ret = -1; //tmp ret of a Single proctol mode.
- int rdret = -1; //the final Return judge vale.
int modInx;
nstack_socket_ops *ops;
int ret_fd = -1;
int protoFD[NSTACK_MAX_MODULE_NUM];
- nstack_rd_key rdkey = { 0 };
int selectmod = -1;
/*check whether module init finish or not */
@@ -183,22 +181,6 @@ nstack_socket (int domain, int itype, int protocol)
nstack_fd_local_lock_info_t *lock_info = get_fd_local_lock_info (ret_fd);
LOCK_FOR_EP (lock_info);
-
- /*check wether select stack create success, if no return fail */
- rdkey.type = RD_DATA_TYPE_PROTO;
- rdkey.proto_type = itype;
- rdret = nstack_rd_get_stackid (&rdkey, &selectmod);
- if ((0 != rdret) || (selectmod < 0) || (selectmod >= nstack_get_modNum ()))
- {
- NSSOC_LOGERR ("protocol:%d select stack fail", protocol);
- selectmod = -1;
- }
- else
- {
- NSSOC_LOGINF ("Create socket of]select modName=%s",
- nstack_get_module_name_by_idx (selectmod));
- }
-
/*create socket by calling select module or all module */
nstack_each_modOps (modInx, ops)
{
@@ -389,6 +371,26 @@ nstack_bind (int fd, const struct sockaddr *addr, socklen_t addrlen)
nstack_get_module_name_by_idx (selectmod));
}
+ if (selectmod == -1)
+ {
+ rdkey.type = RD_DATA_TYPE_PROTO;
+ rdkey.proto_type = fdInf->type;
+ retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod < 0)
+ || (selectmod >= nstack_get_modNum ()))
+ {
+ NSSOC_LOGWAR
+ ("fd Can't select any module for]fd=%d,IP==%s using proto route",
+ fd, inet_ntoa ((iaddr->sin_addr)));
+ selectmod = -1;
+ }
+ else
+ {
+ NSSOC_LOGINF ("Bind socket of]select modName=%s",
+ nstack_get_module_name_by_idx (selectmod));
+ }
+ }
+
retval = -1;
nstack_each_modInx (modIdx)
{
@@ -902,6 +904,25 @@ nstack_connect (int fd, const struct sockaddr *addr, socklen_t addrlen)
rdkey.type = RD_DATA_TYPE_IP;
rdkey.ip_addr = iaddr->sin_addr.s_addr;
retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod == -1))
+ {
+ rdkey.type = RD_DATA_TYPE_PROTO;
+ rdkey.proto_type = fdInf->type;
+ retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod < 0)
+ || (selectmod >= nstack_get_modNum ()))
+ {
+ NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
+ fd, inet_ntoa (iaddr->sin_addr),
+ nstack_get_module_name_by_idx (selectmod));
+ selectmod = -1;
+ }
+ else
+ {
+ NSSOC_LOGINF ("Connect socket of]select modName=%s",
+ nstack_get_module_name_by_idx (selectmod));
+ }
+ }
if (ns_success == retval && selectmod >= 0)
{
NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
@@ -1385,6 +1406,25 @@ nstack_sendto (int fd, const void *buf, size_t len, int flags,
rdkey.type = RD_DATA_TYPE_IP;
rdkey.ip_addr = iaddr->sin_addr.s_addr;
retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod == -1))
+ {
+ rdkey.type = RD_DATA_TYPE_PROTO;
+ rdkey.proto_type = fdInf->type;
+ retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod < 0)
+ || (selectmod >= nstack_get_modNum ()))
+ {
+ NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
+ fd, inet_ntoa (iaddr->sin_addr),
+ nstack_get_module_name_by_idx (selectmod));
+ selectmod = -1;
+ }
+ else
+ {
+ NSSOC_LOGINF ("sendto socket of]select modName=%s",
+ nstack_get_module_name_by_idx (selectmod));
+ }
+ }
if ((ns_success == retval) && (selectmod >= 0))
{
NSSOC_LOGINF ("fd=%d,addr=%s,select_module=%s",
@@ -1472,6 +1512,25 @@ nstack_sendmsg (int fd, const struct msghdr * msg, int flags)
rdkey.type = RD_DATA_TYPE_IP;
rdkey.ip_addr = iaddr->sin_addr.s_addr;
retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod == -1))
+ {
+ rdkey.type = RD_DATA_TYPE_PROTO;
+ rdkey.proto_type = fdInf->type;
+ retval = nstack_rd_get_stackid (&rdkey, &selectmod);
+ if ((0 != retval) || (selectmod < 0)
+ || (selectmod >= nstack_get_modNum ()))
+ {
+ NSSOC_LOGINF ("fd=%d addr=%s Select module=%s",
+ fd, inet_ntoa (iaddr->sin_addr),
+ nstack_get_module_name_by_idx (selectmod));
+ selectmod = -1;
+ }
+ else
+ {
+ NSSOC_LOGINF ("Connect socket of]select modName=%s",
+ nstack_get_module_name_by_idx (selectmod));
+ }
+ }
if (ns_success == retval)
{
NSSOC_LOGINF ("fd=%d,addr=%s,select_module=%s",
diff --git a/src/nSocket/nstack_rd/nstack_rd_ip.c b/src/nSocket/nstack_rd/nstack_rd_ip.c
index c9246c0..82035d1 100644
--- a/src/nSocket/nstack_rd/nstack_rd_ip.c
+++ b/src/nSocket/nstack_rd/nstack_rd_ip.c
@@ -64,12 +64,13 @@ nstack_rd_ip_item_insert (nstack_rd_list * hlist, void *rditem)
nstack_rd_node *tempdata = NULL;
struct hlist_node *tempnode = NULL;
struct hlist_node *tem = NULL;
- unsigned int ip_addr = 0;
- unsigned int ip_masklen = 0;
- unsigned int ip_maskv = MASK_V (ip_addr, ip_masklen);
+
unsigned int tempip_addr = 0;
unsigned int tempip_masklen = 0;
rd_data_item *pitem = (rd_data_item *) rditem;
+ unsigned int ip_addr = pitem->ipdata.addr;
+ unsigned int ip_masklen = pitem->ipdata.masklen;
+ unsigned int ip_maskv = MASK_V (ip_addr, ip_masklen);
ip_masklen = pitem->ipdata.masklen;
NSSOC_LOGDBG ("stackid:%d, ipaddr:%u.%u.%u.%u masklen:0x%x was inserted",
diff --git a/stacks/lwip_stack/CMakeLists.txt b/stacks/lwip_stack/CMakeLists.txt
index 297d2d9..5a5ca94 100644
--- a/stacks/lwip_stack/CMakeLists.txt
+++ b/stacks/lwip_stack/CMakeLists.txt
@@ -48,8 +48,6 @@ FILE(WRITE ${post_compile} "#!/bin/bash\n")
FILE(APPEND ${post_compile}
"
-find ${CMAKE_CURRENT_LIST_DIR}/release/ -name \"*.sh\" -exec chmod +x {} \\;
-find ${CMAKE_CURRENT_LIST_DIR}/release/ -name \"*.py\" -exec chmod +x {} \\;
ln -sfn ./run_nstack_main.sh ${CMAKE_CURRENT_LIST_DIR}/release/script/run_nstack.sh
echo post compile process success.
"
@@ -67,7 +65,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.07")
+ADD_DEFINITIONS(-D_GNU_SOURCE -DNSTACK_GETVER_VERSION="18.10")
SET(JSON_C_SRC ${CMAKE_CURRENT_LIST_DIR}/../../thirdparty/json/json-c-0.12.1)
INCLUDE(ExternalProject)
diff --git a/stacks/lwip_stack/app_conf/module_config.json b/stacks/lwip_stack/app_conf/module_config.json
index f1b3458..6a2f5fb 100644
--- a/stacks/lwip_stack/app_conf/module_config.json
+++ b/stacks/lwip_stack/app_conf/module_config.json
@@ -15,7 +15,7 @@
{
"stack_name": "lwip",
"function_name": "nstack_stack_register",
- "libname": "libnstack.so",
+ "libname": "liblwip_dpdk.so",
"loadtype": "dynmic",
"deploytype": "3",
"maxfd": "1024",
diff --git a/stacks/lwip_stack/doc/README.md b/stacks/lwip_stack/doc/README.md
index e9bb31e..6b533e0 100644
--- a/stacks/lwip_stack/doc/README.md
+++ b/stacks/lwip_stack/doc/README.md
@@ -67,6 +67,11 @@ Run the process:
#./start_nstack.sh
```
+If you want to run it with vhost-user, you can run the start_nstack.sh with parameters as follow.
+```
+ #./start_nstack.sh --vdev virtio_user,mac=fa:16:3e:5f:b3:08,path=/tmp/unix/sock1.sock,queues=8,queue_size=1024 --no-pci
+```
+
- Steps 4: Communication test between machine A(as server) with machine B
(as client)
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 1c9bf92..f437bce 100644
--- a/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
+++ b/stacks/lwip_stack/lwip_src/api/spl_api_msg.c
@@ -22,6 +22,7 @@
//#include "sockets.h"
#include <netinet/in.h>
#include <errno.h>
+#include <netinet/tcp.h>
#include "stackx_prot_com.h"
#include "spl_api.h"
@@ -1572,6 +1573,7 @@ spl_do_connected (void *arg, struct tcp_pcb *pcb, err_t err)
conn->state = SPL_NETCONN_NONE;
SPL_NETCONN_SET_SAFE_ERR (conn, ERR_OK);
+ update_tcp_state (pcb->callback_arg, ESTABLISHED);
SPL_API_EVENT (conn, SPL_NETCONN_EVT_SENDPLUS, 1);
if (was_blocking && m != NULL)
@@ -2523,7 +2525,12 @@ do_get_tcpproto_getsockopt_internal (struct common_pcb *cpcb,
NSPOL_LOGDBG (SOCKETS_DEBUG, "]fd=%d,SPL_TCP_KEEPCNT=%d",
cpcb->socket, *(int *) optval);
break;
-
+ case SPL_TCP_INFO:
+ ((struct tcp_info *) optval)->tcpi_total_retrans = (int) tpcb->nrtx;
+ ((struct tcp_info *) optval)->tcpi_snd_mss = (int) tpcb->mss;
+ ((struct tcp_info *) optval)->tcpi_rtt = (int) tpcb->sa;
+ ((struct tcp_info *) optval)->tcpi_snd_cwnd = (int) tpcb->cwnd;
+ break;
default:
NSPOL_LOGDBG (SOCKETS_DEBUG, "unsupported]optname=%d", optname);
SET_MSG_ERR (m, EOPNOTSUPP);
@@ -3316,5 +3323,7 @@ alloc_common_pcb (enum spl_netconn_type type)
common_pcb_init (cpcb);
cpcb->type = type;
+
+ res_alloc (&cpcb->res_chk);
return cpcb;
}
diff --git a/stacks/lwip_stack/lwip_src/api/spl_sbr.c b/stacks/lwip_stack/lwip_src/api/spl_sbr.c
index 4c510a5..4c1be2f 100644
--- a/stacks/lwip_stack/lwip_src/api/spl_sbr.c
+++ b/stacks/lwip_stack/lwip_src/api/spl_sbr.c
@@ -157,7 +157,7 @@ _do_send (data_com_msg * m)
msg_send_buf *_m = (msg_send_buf *) m->buffer;
if (cpcb == NULL)
{
- NS_LOG_CTRL (LOG_CTRL_SEND, STACKX, "NSPOL", NSLOG_ERR,
+ NS_LOG_CTRL (LOG_CTRL_SEND, STACKX, "NSLWIP", NSLOG_ERR,
"failed to find target pcb, drop the message]"
"module=%u, major=%u, minor=%u",
m->param.module_type,
@@ -192,7 +192,7 @@ _do_write (data_com_msg * m)
msg_write_buf *_m = (msg_write_buf *) m->buffer;
if ((tpcb == NULL) || (cpcb == NULL))
{
- NS_LOG_CTRL (LOG_CTRL_WRITE, STACKX, "NSPOL", NSLOG_ERR,
+ NS_LOG_CTRL (LOG_CTRL_WRITE, STACKX, "NSLWIP", NSLOG_ERR,
"failed to find target pcb, drop the message]"
"module=%u, major=%u, minor=%u",
m->param.module_type,
@@ -225,7 +225,7 @@ _do_recv (data_com_msg * m)
if ((tpcb == NULL) || (cpcb == NULL))
{
- NS_LOG_CTRL (LOG_CTRL_RECV, STACKX, "NSPOL", NSLOG_ERR,
+ NS_LOG_CTRL (LOG_CTRL_RECV, STACKX, "NSLWIP", NSLOG_ERR,
"failed to find target pcb, drop the message]"
"module=%u, major=%u, minor=%u",
m->param.module_type,
diff --git a/stacks/lwip_stack/lwip_src/api/spl_tcpip.c b/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
index b627bcf..b0b588a 100644
--- a/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
+++ b/stacks/lwip_stack/lwip_src/api/spl_tcpip.c
@@ -61,7 +61,7 @@
#include "sys.h"
-#define NSTACK_MAIN_MAX_PARA 19
+#define NSTACK_MAIN_MAX_PARA 32
#define NSTACK_MAIN_MIN_PARA 1
#define DPDK_DEFAULT_EAL_MEM_SIZE (1024)
@@ -951,7 +951,7 @@ spl_tcpip_thread (void *arg)
u16 task_loop;
u16 num_recv_task = 0, num_send_timer_task = 0;
u16 index_task = 0;
- int tcpip_thread_sleep_interval = g_tcpip_thread_sleep_time * 1000;
+ //int tcpip_thread_sleep_interval = g_tcpip_thread_sleep_time * 1000;
void *task_queue[TASK_BURST];
data_com_msg *msg;
@@ -981,7 +981,7 @@ spl_tcpip_thread (void *arg)
if (run_count++ > 20)
{
- sys_sleep_ns (0, tcpip_thread_sleep_interval);
+ //sys_sleep_ns (0, tcpip_thread_sleep_interval);
}
continue;
}
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h b/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h
index d2d01e5..feccc3f 100644
--- a/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h
+++ b/stacks/lwip_stack/lwip_src/common/stackx_common_opt.h
@@ -102,6 +102,7 @@ extern "C" {
#define SPL_TCP_KEEPCNT 0x06
#define SPL_TCP_LINGER2 0x08
#define SPL_TCP_DEFER_ACCEPT 0x09
+#define SPL_TCP_INFO 0x0B
typedef enum spl_netconn_type
{
diff --git a/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h b/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h
index 119c26a..3088150 100644
--- a/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h
+++ b/stacks/lwip_stack/lwip_src/common/stackx_spl_msg.h
@@ -21,6 +21,7 @@
#include "stackx_spl_share.h"
#include "stackx_common_opt.h"
#include <sys/socket.h>
+#include <netinet/tcp.h>
#ifdef __cplusplus
/* *INDENT-OFF* */
@@ -207,6 +208,7 @@ typedef struct
//struct in_addr inaddr_optval;
//struct linger _linger;
struct timeval timeval_optval;
+ struct tcp_info tpinfo;
//ipmreq ipmreq_optval; //Multicast support later
} optval;
diff --git a/stacks/lwip_stack/lwip_src/core/spl_pbuf.c b/stacks/lwip_stack/lwip_src/core/spl_pbuf.c
index 54589e8..e4aa014 100644
--- a/stacks/lwip_stack/lwip_src/core/spl_pbuf.c
+++ b/stacks/lwip_stack/lwip_src/core/spl_pbuf.c
@@ -89,7 +89,7 @@ spl_pbuf_alloc_hugepage (spl_pbuf_layer layer, u16_t length,
{
/* last_log_prt_time and unprint_log_count indeed have multi-thread issue,
* but their values don't have precision requirement. No risk. */
- NS_LOG_CTRL (LOG_CTRL_HUGEPAGE_ALLOC_FAIL, STACKX, "NSPOL", NSLOG_ERR,
+ NS_LOG_CTRL (LOG_CTRL_HUGEPAGE_ALLOC_FAIL, STACKX, "NSLWIP", NSLOG_ERR,
"pbuf_alloc_huge: Could not allocate PBUF for SPL_PBUF_HUGE");
return NULL;
diff --git a/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h b/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
index 488e13e..acf5057 100644
--- a/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
+++ b/stacks/lwip_stack/lwip_src/include/ip_module/ip_module_api.h
@@ -149,6 +149,7 @@ struct network_configuration
struct ip_subnet *ip_subnet;
char network_name[IP_MODULE_MAX_NAME_LEN];
char type_name[IP_MODULE_MAX_NAME_LEN];
+ char nic_type_name[IP_MODULE_MAX_NAME_LEN];
network_buffer *buffer;
};
diff --git a/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h b/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
index 0a92ea0..6230ed8 100644
--- a/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
+++ b/stacks/lwip_stack/lwip_src/include/netif/sharedmemory.h
@@ -101,6 +101,7 @@ enum proc_run_type
struct linux_port_info
{
char if_name[HAL_MAX_NIC_NAME_LEN];
+ char if_type[HAL_MAX_NIC_NAME_LEN];
char ip_addr_linux[18]; //uint32_t ip_addr_linux;
char mask_linux[18]; //uint32_t mask_linux;
char bcast_linux[18]; //uint32_t bcast_linux;
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 03b5998..e2334ea 100644
--- a/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c
+++ b/stacks/lwip_stack/lwip_src/ip_module/configuration_reader.c
@@ -996,13 +996,13 @@ int
init_configuration_reader ()
{
int error_number = 0;
- INITPOL_LOGINF ("RTP", "init_configuration_reader", NULL_STRING,
+ INITPOL_LOGINF ("CONFIGURATION", "init_configuration_reader", NULL_STRING,
LOG_INVALID_VALUE, MODULE_INIT_START);
g_config_data = &g_ip_module_buff;
if (init_ip_module_unix_socket_path () < 0)
{
- INITPOL_LOGERR ("RTP", "init_configuration_reader",
+ INITPOL_LOGERR ("CONFIGURATION", "init_configuration_reader",
"Error when init path", LOG_INVALID_VALUE,
MODULE_INIT_FAIL);
return -1;
@@ -1012,7 +1012,7 @@ init_configuration_reader ()
if (listen_fd < 0)
{
error_number = errno;
- INITPOL_LOGERR ("RTP", "init_configuration_reader",
+ INITPOL_LOGERR ("CONFIGURATION", "init_configuration_reader",
"when listening ip_module_unix_socket", error_number,
MODULE_INIT_FAIL);
return -1;
@@ -1027,7 +1027,7 @@ init_configuration_reader ()
return -1;
}
- INITPOL_LOGINF ("RTP", "init_configuration_reader", NULL_STRING,
+ INITPOL_LOGINF ("CONFIGURATION", "init_configuration_reader", NULL_STRING,
LOG_INVALID_VALUE, MODULE_INIT_SUCCESS);
return 0;
}
diff --git a/stacks/lwip_stack/lwip_src/ip_module/network.c b/stacks/lwip_stack/lwip_src/ip_module/network.c
index ef0d9a7..d7c9630 100644
--- a/stacks/lwip_stack/lwip_src/ip_module/network.c
+++ b/stacks/lwip_stack/lwip_src/ip_module/network.c
@@ -510,7 +510,8 @@ add_network_configuration (struct network_configuration
while (pheader)
{
if (!spl_hal_is_nic_exist (pheader->nic_name)
- && !nic_already_init (pheader->nic_name))
+ && !nic_already_init (pheader->nic_name)
+ && strncmp (tmp->nic_type_name, "vhost", strlen ("vhost")))
{
NSOPR_LOGERR ("Invalid configuration %s not exist Error! ",
pheader->nic_name);
@@ -584,7 +585,7 @@ parse_network_obj (struct json_object *network_obj)
NULL, *type_name_obj = NULL;
struct json_object *ref_nic_list_obj = NULL, *bond_mode_obj =
NULL, *bond_name_obj = NULL, *ipam_obj = NULL;
- struct json_object *subnet_obj = NULL;
+ struct json_object *subnet_obj = NULL, *nic_type_obj = NULL;
if (!network_obj)
{
@@ -687,6 +688,44 @@ parse_network_obj (struct json_object *network_obj)
goto RETURN_ERROR;
}
+ json_object_object_get_ex (phy_obj, "nic_type", &nic_type_obj); /*lint !e534 no need to check return value */
+ if (nic_type_obj)
+ {
+ const char *nic_type_name =
+ json_object_get_string (nic_type_obj);
+ if (strcmp (nic_type_name, "pci") != 0
+ && strcmp (nic_type_name, "vhost") != 0)
+ {
+ NSOPR_LOGERR ("unsupported nic_type]nic_type=%s",
+ nic_type_name);
+ goto RETURN_ERROR;
+ }
+
+ retVal =
+ STRCPY_S (pst_network_configuration->nic_type_name,
+ sizeof (pst_network_configuration->nic_type_name),
+ nic_type_name);
+ if (EOK != retVal)
+ {
+ NSOPR_LOGERR ("strcpy_s failed]ret=%d", retVal);
+ goto RETURN_ERROR;
+ }
+ }
+ else
+ {
+ NSOPR_LOGINF
+ ("nic_type not specified, use default type]defaul nic_type=pci");
+ retVal =
+ STRCPY_S (pst_network_configuration->nic_type_name,
+ sizeof (pst_network_configuration->nic_type_name),
+ "pci");
+ if (EOK != retVal)
+ {
+ NSOPR_LOGERR ("strcpy_s failed]ret=%d", retVal);
+ goto RETURN_ERROR;
+ }
+ }
+
json_object_object_get_ex (phy_obj, "ref_nic", &ref_nic_list_obj);
if (ref_nic_list_obj)
{
diff --git a/stacks/lwip_stack/lwip_src/netif/spl_hal.c b/stacks/lwip_stack/lwip_src/netif/spl_hal.c
index c7cfca1..db843d4 100644
--- a/stacks/lwip_stack/lwip_src/netif/spl_hal.c
+++ b/stacks/lwip_stack/lwip_src/netif/spl_hal.c
@@ -379,7 +379,7 @@ spl_hal_port_zone_init ()
nsfw_mem_zone create_port_zone;
nsfw_mem_zone create_port_info;
struct stackx_port_info *mz_port_info;
- INITPOL_LOGINF ("RTP", "spl_hal_port_zone_init", NULL_STRING,
+ INITPOL_LOGINF ("HAL", "spl_hal_port_zone_init", NULL_STRING,
LOG_INVALID_VALUE, MODULE_INIT_START);
if ((CUR_CFG_HAL_PORT_NUM < 1)
@@ -408,7 +408,7 @@ spl_hal_port_zone_init ()
if (NULL == p_stackx_port_zone)
{
- INITPOL_LOGERR ("RTP", "spl_hal_port_zone_init",
+ INITPOL_LOGERR ("HAL", "spl_hal_port_zone_init",
"Cannot create memory zone for MP_STACKX_PORT_ZONE information",
LOG_INVALID_VALUE, MODULE_INIT_FAIL);
common_exit (EXIT_FAILURE,
@@ -421,7 +421,7 @@ spl_hal_port_zone_init ()
if (EOK != retVal)
{
- INITPOL_LOGERR ("RTP", "spl_hal_port_zone_init", "MEMSET_S return fail",
+ INITPOL_LOGERR ("HAL", "spl_hal_port_zone_init", "MEMSET_S return fail",
retVal, MODULE_INIT_FAIL);
nsfw_mem_zone_release (&create_port_zone.stname);
return -1;
@@ -445,7 +445,7 @@ spl_hal_port_zone_init ()
if (NULL == mz_port_info)
{
- INITPOL_LOGERR ("RTP", "spl_hal_port_zone_init",
+ INITPOL_LOGERR ("HAL", "spl_hal_port_zone_init",
"Cannot create memory zone for MP_STACKX_PORT_INFO information",
LOG_INVALID_VALUE, MODULE_INIT_FAIL);
common_exit (EXIT_FAILURE,
@@ -458,7 +458,7 @@ spl_hal_port_zone_init ()
if (EOK != retVal)
{
- INITPOL_LOGERR ("RTP", "spl_hal_port_zone_init", "MEMSET_S return fail",
+ INITPOL_LOGERR ("HAL", "spl_hal_port_zone_init", "MEMSET_S return fail",
retVal, MODULE_INIT_FAIL);
nsfw_mem_zone_release (&create_port_info.stname);
nsfw_mem_zone_release (&create_port_zone.stname);
@@ -470,7 +470,7 @@ spl_hal_port_zone_init ()
p_stackx_port_zone->stackx_one_port = mz_port_info;
- INITPOL_LOGINF ("RTP", "spl_hal_port_zone_init", NULL_STRING,
+ INITPOL_LOGINF ("HAL", "spl_hal_port_zone_init", NULL_STRING,
LOG_INVALID_VALUE, MODULE_INIT_SUCCESS);
return 0;
@@ -495,7 +495,7 @@ spl_hal_init (int argc, char *argv[])
/* Init DPDK */
argc = uStackArgIndex--;
- INITPOL_LOGINF ("RTP", "hal_init_global", NULL_STRING, LOG_INVALID_VALUE,
+ INITPOL_LOGINF ("HAL", "hal_init_global", NULL_STRING, LOG_INVALID_VALUE,
MODULE_INIT_START);
for (idx_init = 0; idx_init < argc; idx_init++)
@@ -962,6 +962,23 @@ spl_hal_port_config (unsigned int *port_num)
NSPOL_LOGINF (SC_DPDK_INFO, "if_name %s",
p_stackx_port_zone->
stackx_one_port[port_index].linux_ip.if_name);
+
+ retVal =
+ STRCPY_S (p_stackx_port_zone->
+ stackx_one_port[port_index].linux_ip.if_type,
+ sizeof (p_stackx_port_zone->
+ stackx_one_port[port_index].linux_ip.if_type),
+ network->nic_type_name);
+ if (EOK != retVal)
+ {
+ NSPOL_LOGERR ("strcpy_s failed]ret=%d.", retVal);
+ return -1;
+ }
+
+ NSPOL_LOGINF (SC_DPDK_INFO, "if_type %s",
+ p_stackx_port_zone->
+ stackx_one_port[port_index].linux_ip.if_type);
+
retVal =
STRCPY_S (p_stackx_port_zone->
stackx_one_port[port_index].linux_ip.ip_addr_linux,
@@ -1286,7 +1303,9 @@ spl_hal_port_start (uint16_t nic_id, struct stackx_port_info *p_port_info,
conf.tx.ring_size[q] = HAL_TX_RING_SIZE;
}
- hdl = hal_create (p_port_info->linux_ip.if_name, &conf);
+ hdl =
+ hal_create (p_port_info->linux_ip.if_name, p_port_info->linux_ip.if_type,
+ &conf);
if (!hal_is_valid (hdl))
{
@@ -1326,7 +1345,7 @@ spl_hal_port_setup ()
unsigned int i;
struct stackx_port_info *p_port_info = NULL;
- INITPOL_LOGINF ("RTP", "spl_hal_port_setup", NULL_STRING, LOG_INVALID_VALUE,
+ INITPOL_LOGINF ("HAL", "spl_hal_port_setup", NULL_STRING, LOG_INVALID_VALUE,
MODULE_INIT_START);
for (i = num_ports_NIC_start; i < num_ports_NIC; i++)
@@ -1337,7 +1356,7 @@ spl_hal_port_setup ()
{
NSPOL_LOGERR ("Error initialising]nic_id=%u", i);
- INITPOL_LOGERR ("RTP", "spl_hal_port_setup", NULL_STRING,
+ INITPOL_LOGERR ("HAL", "spl_hal_port_setup", NULL_STRING,
LOG_INVALID_VALUE, MODULE_INIT_FAIL);
return -1;
@@ -1353,7 +1372,7 @@ spl_hal_port_setup ()
{
NSPOL_LOGERR ("bond port init failed!");
- INITPOL_LOGERR ("RTP", "spl_hal_port_setup", NULL_STRING,
+ INITPOL_LOGERR ("HAL", "spl_hal_port_setup", NULL_STRING,
LOG_INVALID_VALUE, MODULE_INIT_FAIL);
return -1;
@@ -1361,7 +1380,7 @@ spl_hal_port_setup ()
spl_hal_capa_init ();
- INITPOL_LOGINF ("RTP", "spl_hal_port_setup", NULL_STRING, LOG_INVALID_VALUE,
+ INITPOL_LOGINF ("HAL", "spl_hal_port_setup", NULL_STRING, LOG_INVALID_VALUE,
MODULE_INIT_SUCCESS);
return 0;
diff --git a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c b/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
index 3225c2f..0042e54 100644
--- a/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
+++ b/stacks/lwip_stack/lwip_src/socket/stackx_tcp.c
@@ -498,6 +498,7 @@ sbr_getsockopt_ipproto_tcp (int optname, void *optval, socklen_t optlen)
case SPL_TCP_KEEPIDLE:
case SPL_TCP_KEEPINTVL:
case SPL_TCP_KEEPCNT:
+ case SPL_TCP_INFO:
break;
default:
err = ENOPROTOOPT;
diff --git a/stacks/lwip_stack/release/script/nstack_fun.sh b/stacks/lwip_stack/release/script/nstack_fun.sh
index bb33a6a..fed3588 100644..100755
--- a/stacks/lwip_stack/release/script/nstack_fun.sh
+++ b/stacks/lwip_stack/release/script/nstack_fun.sh
@@ -332,10 +332,10 @@ run_nStackMain()
log $LINENO "$env DPDK_TOOL_DIR=$DPDK_TOOL_DIR"
log $LINENO "$env LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
log $LINENO "$env DPDK_LIB_PATH=$DPDK_LIB_PATH"
- log $LINENO "./bin/nStackMain -c $1 -n 4 --huge-dir=$2 -m $3 stack -c $4 -sleep $5 -bind_cpu $6"
+ log $LINENO "./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 $7 $8 stack -c $4 -sleep $5 -bind_cpu $6"
check_file_size $DPDK_FILE
cd ..; cd bin/
- ./nStackMain -c $1 -n 4 --huge-dir=$2 -m $3 stack -c $4 -sleep $5 -bind_cpu $6 >> $DPDK_FILE &
+ ./nStackMain -c $1 -n 4 --huge-dir=$2 --proc-type=primary --file-prefix nStackMain -m $3 $7 $8 stack -c $4 -sleep $5 -bind_cpu $6 >> $DPDK_FILE &
}
diff --git a/stacks/lwip_stack/release/script/nstack_var.sh b/stacks/lwip_stack/release/script/nstack_var.sh
index 4c5c6f6..a654d34 100644..100755
--- a/stacks/lwip_stack/release/script/nstack_var.sh
+++ b/stacks/lwip_stack/release/script/nstack_var.sh
@@ -26,10 +26,10 @@ DPDK_FILE_NAME=nstack_dpdk.log
export VM_ID=agent-node-x
-export DPDK_INSTALL_PATH="/tmp/dpdk/dpdk-18.02/"
+export DPDK_INSTALL_PATH="/usr/share/dpdk/"
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
+export DPDK_MOD_PATH=/usr/lib/modules/`uname -r`/extra/dpdk
cur_user=`whoami`
if [ "root" != "${cur_user}" ]
@@ -50,9 +50,11 @@ DPDK_NIC_LIST_FILE=$RUNTIME_DIR/.nstack_dpdk_nic_list
MAX_LOG_FILE_SIZE=52428800
HUGE_PAGES=2048
HUGE_DIR=/mnt/nstackhuge
+
SLEEP_INTERVAL=100 # tcpip thread sleep time, unit: us
-BIND_CPU=0
-MEM_SIZE=2048
+BIND_CPU=1
+
+MEM_SIZE=3072
RTP_CORE_MASK=2
MASTER_EXEC_PATH="/product/gpaas/nStackMaster/bin"
diff --git a/stacks/lwip_stack/release/script/run_nstack_main.sh b/stacks/lwip_stack/release/script/run_nstack_main.sh
index 2bd9e0d..9d6049a 100644..100755
--- a/stacks/lwip_stack/release/script/run_nstack_main.sh
+++ b/stacks/lwip_stack/release/script/run_nstack_main.sh
@@ -20,7 +20,8 @@ init_network
CORE_MASK=1
log $LINENO "start run nstackmain"
log $LINENO "COREMASK=$CORE_MASK, HUGE_DIR=$1, MEM_SIZE=$2, RTP_CORE_MASK=$RTP_CORE_MASK, SLEEP_INTERVAL=$SLEEP_INTERVAL, BIND_CPU=$BIND_CPU"
+log $LINENO "VDEV=$VDEV, NO_PCI=$NO_PCI"
-run_nStackMain $CORE_MASK $1 $2 $RTP_CORE_MASK $SLEEP_INTERVAL $BIND_CPU
+run_nStackMain $CORE_MASK $1 $2 $RTP_CORE_MASK $SLEEP_INTERVAL $BIND_CPU $3 $4
exit 0
diff --git a/stacks/lwip_stack/release/script/run_nstack_master.sh b/stacks/lwip_stack/release/script/run_nstack_master.sh
index 8da0d49..8da0d49 100644..100755
--- a/stacks/lwip_stack/release/script/run_nstack_master.sh
+++ b/stacks/lwip_stack/release/script/run_nstack_master.sh
diff --git a/stacks/lwip_stack/release/send_alarm.sh b/stacks/lwip_stack/release/send_alarm.sh
index 46ea413..46ea413 100644..100755
--- a/stacks/lwip_stack/release/send_alarm.sh
+++ b/stacks/lwip_stack/release/send_alarm.sh
diff --git a/stacks/lwip_stack/release/start_nstack.sh b/stacks/lwip_stack/release/start_nstack.sh
index db0c084..35fe9df 100644..100755
--- a/stacks/lwip_stack/release/start_nstack.sh
+++ b/stacks/lwip_stack/release/start_nstack.sh
@@ -16,16 +16,40 @@ fi
##get the log info from the parameter of ./start -l XXX -a XXX ###
nstack_log_path=""
hostinfo_path=""
-while getopts "l:i:a:" arg
+ARGS=`getopt -o "l:i:a:" -l "vdev:,file-prefix:,no-pci" -n "start_nstack.sh" -- "$@"`
+eval set -- "${ARGS}"
+while true
do
- case $arg in
- l)
- nstack_log_path="$OPTARG"
- ;;
- i)
- hostinfo_path="$OPTARG"
- ;;
- esac
+ case "$1" in
+ -l)
+ nstack_log_path="$2"
+ shift 2
+ ;;
+ -i)
+ hostinfo_path="$2"
+ shift 2
+ ;;
+ --vdev)
+ VDEV="--vdev=$2"
+ shift 2
+ ;;
+ --file-prefix)
+ FILE_PREFIX="--file-prefix=$2"
+ shift 2
+ ;;
+ --no-pci)
+ NO_PCI="--no-pci"
+ shift 1
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ echo "Option illegal, please check input!"
+ exit 1
+ ;;
+ esac
done
hostinfo_stat=0
@@ -116,8 +140,8 @@ install_config
########################################################
core_mask=1
START_TYPE="primary"
-log $LINENO "./script/run_nstack_main.sh ${core_mask} $HUGE_DIR $MEM_SIZE $START_TYPE"
-${script_path}/script/run_nstack_main.sh $HUGE_DIR $MEM_SIZE
+log $LINENO "./script/run_nstack_main.sh ${core_mask} $HUGE_DIR $MEM_SIZE $START_TYPE $VDEV $NO_PCI"
+${script_path}/script/run_nstack_main.sh $HUGE_DIR $MEM_SIZE $VDEV $NO_PCI
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 48d1af7..48d1af7 100644..100755
--- a/stacks/lwip_stack/release/stop_nstack.sh
+++ b/stacks/lwip_stack/release/stop_nstack.sh
diff --git a/stacks/lwip_stack/release/uninstall.sh b/stacks/lwip_stack/release/uninstall.sh
index 92ae5fe..92ae5fe 100644..100755
--- a/stacks/lwip_stack/release/uninstall.sh
+++ b/stacks/lwip_stack/release/uninstall.sh
diff --git a/stacks/lwip_stack/release/upgrade_nstack.sh b/stacks/lwip_stack/release/upgrade_nstack.sh
deleted file mode 100644
index 9302da6..0000000
--- a/stacks/lwip_stack/release/upgrade_nstack.sh
+++ /dev/null
@@ -1,452 +0,0 @@
-#!/bin/bash
-
-. ./script/nstack_var.sh
-. ./script/nstack_fun.sh
-
-VERSION_CHK=0
-UPG_MASTER=0
-
-# OLD_VERSION indicates the nStackServer version, in order to support Version upgrade and rollback feature
-# OLD_VERSION=1 B031~newest
-# OLD_VERSION=0 B020~B030
-OLD_VERSION=1
-cur_user=`whoami`
-
-upg_pre_chk()
-{
- ##########check input info###########################
- if [ -z "${DST_VER_PATH}" ]; then
- log $LINENO "dst ${DST_VER_PATH} path error!"
- return 1
- fi
-
- if [ "x${UPG_RBK}" != "x1" -a "x${UPG_RBK}" != "x2" ]; then
- log $LINENO "type error ${UPG_RBK}!"
- return 1
- fi
-
- ##########check src version info######################
- SRC_STOP_FILE=${SRC_VER_PATH}/stop_nstack.sh
- if [ ! -f "$SRC_STOP_FILE" ]; then
- log $LINENO "${SRC_STOP_FILE} path error!"
- return 1
- fi
-
- MASTER_PATH=`get_nstack_bin nStackMaster`
- if [ -z "${MASTER_PATH}" ]; then
- log $LINENO "master not start"
- return 1
- fi
-
- if [ ! -d "${MASTER_PATH}${MASTERBIN}" ]; then
- log $LINENO "${MASTER_PATH} path error!"
- return 1
- fi
-
- SRC_VERSION=`get_version 1`
- if [ -z "${SRC_VERSION}" ]; then
- log $LINENO "get srcVersion error"
- exit 1
- fi
-
- ###########check dst version info######################
- DST_RUN_FILE=${DST_VER_PATH}/script/run_nstack_main.sh
- if [ ! -f "$DST_RUN_FILE" ]; then
- log $LINENO "${DST_RUN_FILE} path error. Try the path of older nstack version then."
- DST_RUN_FILE=${DST_VER_PATH}/bin/run_nstack_main.sh
- OLD_VERSION=0
- if [ ! -f "$DST_RUN_FILE" ]; then
- log $LINENO "${DST_RUN_FILE} older path error!"
- return 1
- fi
- fi
-
- DST_STOP_FILE=${DST_VER_PATH}/stop_nstack.sh
- if [ ! -f "$DST_STOP_FILE" ]; then
- log $LINENO "${DST_STOP_FILE} path error!"
- return 1
- fi
-
- DST_STAT_FILE=${DST_VER_PATH}/start_nstack.sh
- if [ ! -f "$DST_STAT_FILE" ]; then
- log $LINENO "${DST_STAT_FILE} path error!"
- return 1
- fi
-
- if [ ! -x "${DST_VER_PATH}/bin/nStackCtrl" ]; then
- log $LINENO "${DST_VER_PATH} path nStackCtrl exec error!"
- return 1
- fi
-
- DST_VERSION=`get_version 4 ${DST_VER_PATH}/bin/nStackCtrl`
- if [ -z "${DST_VERSION}" ]; then
- log $LINENO "get dstversion error"
- return 1
- fi
-}
-
-restart_upgrade()
-{
- local monipid=`pidof monit`
- local stop_moni=0
- if [ ! -z "${monipid}" ]; then
- for i in `seq 60`
- do
- if [ ${cur_user} = "paas" ]; then
- stop_fin=`/var/ICTS_BASE/Monit/bin/monit summary | grep nstack | grep "Not monitored"`
- else
- stop_fin=`su paas -s /bin/bash -c "/var/ICTS_BASE/Monit/bin/monit summary" | grep nstack | grep "Not monitored"`
- fi
- if [ -n "${stop_fin}" ]; then
- break;
- fi
-
- if [ $stop_moni -eq 0 ]; then
- if [ ${cur_user} = "paas" ]; then
- /var/ICTS_BASE/Monit/bin/monit unmonitor nstack
- else
- su paas -s /bin/bash -c "/var/ICTS_BASE/Monit/bin/monit unmonitor nstack"
- fi
- stop_moni=1
- log $LINENO "stop monit"
- fi
-
- sleep 1
- done
- cd ${SRC_VER_PATH}
- ./stop_nstack.sh
- cd -
- cd ${DST_VER_PATH}
- if [ -n "${LOG_PATH}" ]; then
- ./start_nstack.sh -l $LOG_PATH -i $hostinfo_path
- else
- ./start_nstack.sh -i $hostinfo_path
- fi
- cd -
-
- log $LINENO "with monit restart"
- if [ $stop_moni -eq 1 ]; then
- if [ ${cur_user} = "paas" ]; then
- /var/ICTS_BASE/Monit/bin/monit monitor nstack
- else
- su paas -s /bin/bash -c "/var/ICTS_BASE/Monit/bin/monit monitor nstack"
- fi
- log $LINENO "monit restart"
- fi
- else
- cd ${SRC_VER_PATH}
- ./stop_nstack.sh
- cd -
- cd ${DST_VER_PATH}
- if [ -n "${LOG_PATH}" ]; then
- ./start_nstack.sh -l $LOG_PATH -i $hostinfo_path
- else
- ./start_nstack.sh -i $hostinfo_path
- fi
- cd -
- log $LINENO "none monit restart"
- fi
- return 0
-}
-
-run_upgrade()
-{
-
- if [ -n "${DST_RUN_FILE}" ]; then
- if [ $OLD_VERSION -ge 1 ]; then
- ln -s -f "$DST_RUN_FILE" "${DST_VER_PATH}/script/${RUN_NSTACK_FILE}"
- else
- ln -s -f "$DST_RUN_FILE" "${DST_VER_PATH}/bin/${RUN_NSTACK_FILE}"
- fi
- if [ $? -ne 0 ]; then
- log $LINENO "dst version link failed!"
- return 1
- fi
- fi
-
- # copy old config to avoid config change issue
- copy_config $SRC_VER_PATH $DST_VER_PATH
-
- ./bin/nStackCtrl --module vermgr -t $UPG_RBK -s $SRC_VERSION -d $DST_VERSION
- ret=$?
- if [ $ret -eq 121 ]; then
- restart_upgrade
- WAIT_TIME=50
- RESTART_MASTER=1
- return 0
- fi
-
- if [ $ret -ne 0 ]; then
- log $LINENO "nStackCtrl send vermsg err $ret code"
- return 1
- fi
-
- nStackMain_pid=`pidof nStackMain`
- if [ -n "${DST_RUN_FILE}" ]; then
- ln -s -f "$DST_RUN_FILE" "${MASTER_PATH}${RUN_NSTACK_FILE}"
- if [ $? -ne 0 ]; then
- log $LINENO "link failed!"
- kill -9 $nStackMain_pid
- return 1
- fi
- fi
- kill -9 $nStackMain_pid
- return 0
-}
-
-after_upg_chk()
-{
- for i in `seq $WAIT_TIME`
- do
- NEW_DST_VERSION=`get_version 1`
- if [ -n "${NEW_DST_VERSION}" ]; then
- if [ "$NEW_DST_VERSION" != "$DST_VERSION" ]; then
- log $LINENO "new version:$NEW_DST_VERSION maybe error! expect version is:$DST_VERSION"
- else
- break;
- fi
- fi
- sleep 1
- done
-
- if [ -z "${NEW_DST_VERSION}" ]; then
- log $LINENO "nStackCtrl get dstVersion error"
- return 1
- fi
-
- if [ "$NEW_DST_VERSION" != "$DST_VERSION" -a $VERSION_CHK -eq 1 ]; then
- log $LINENO "new version:$NEW_DST_VERSION maybe error! expect version is:$DST_VERSION"
- return 1
- fi
-
- DST_MAIN_PATH=`get_nstack_bin nStackMain`
- if [ -z "${DST_MAIN_PATH}" ]; then
- log $LINENO "main not start"
- return 1
- fi
-
- if [ "$DST_MAIN_PATH" != "${DST_VER_PATH}/bin/" ]; then
- log $LINENO "main start failed run;$DST_MAIN_PATH expect:${DST_VER_PATH}/script !"
- return 1
- fi
-}
-
-
-run_upgrade_master()
-{
- core_mask=`get_core_mask`
- START_TYPE="secondary"
- ./bin/nStackCtrl --module vermgr -t $UPG_RBK -s $SRC_VERSION -d $DST_VERSION -p 2
- ret=$?
- if [ $ret -ne 0 ]; then
- log $LINENO "nStackMaster nStackCtrl send vermsg err $ret code"
- return 1
- fi
-
- nStackMaster_pid=`pidof nStackMaster`
- kill -9 $nStackMaster_pid
- cd ${DST_VER_PATH}/script/
- ./run_nstack_master.sh ${core_mask} $HUGE_DIR $MEM_SIZE $START_TYPE
- log $LINENO "./script/run_nstack_master.sh ${core_mask} $HUGE_DIR $MEM_SIZE $START_TYPE"
- cd -
- return 0
-}
-
-
-after_upg_master_chk()
-{
- for i in `seq 10`
- do
- NEW_MAS_VERSION=`get_version 2`
- if [ -n "${NEW_MAS_VERSION}" ]; then
- if [ "$NEW_MAS_VERSION" != "$DST_VERSION" ]; then
- log $LINENO "new version:$NEW_MAS_VERSION maybe error! expect version is:$DST_VERSION"
- else
- break;
- fi
- fi
- sleep 1
- done
-
- if [ -z "${NEW_MAS_VERSION}" ]; then
- log $LINENO "nStackCtrl get dstVersion error"
- return 1
- fi
-
- if [ "$NEW_MAS_VERSION" != "$DST_VERSION" -a $VERSION_CHK -eq 1 ]; then
- log $LINENO "new version:$NEW_MAS_VERSION maybe error! expect version is:$DST_VERSION"
- return 1
- fi
-
- DST_MAS_PATH=`get_nstack_bin nStackMaster`
- if [ -z "${DST_MAS_PATH}" ]; then
- log $LINENO "master not start"
- return 1
- fi
-
- if [ "$DST_MAS_PATH" != "${DST_VER_PATH}/script/" ]; then
- log $LINENO "main start failed run;$DST_MAS_PATH expect:${DST_VER_PATH}/script !"
- return 1
- fi
- return 0
-}
-
-opr_suc()
-{
- log $LINENO "operation successful $SRC_VERSION to $NEW_DST_VERSION"
-}
-
-mod_log_path()
-{
- local dst_proc=$1
- local dst_log_path=$2
- ./bin/nStackCtrl --module setlog -n maspath -v ${dst_log_path} -p $dst_proc
- ret=$?
- if [ $ret -ne 0 ]; then
- log $LINENO "mod_log_path error err $ret code"
- return 1
- fi
- return 0
-}
-
-ini_file_path="invalid_path_upgrade"
-
-while getopts 's:d:t:l:i:' opt
-do
- case $opt in
- s)
- SRC_VER_PATH=`get_abs_path $OPTARG`
- ;;
- :)
- echo "-$OPTARG needs an argument"
- exit 1
- ;;
- d)
- DST_VER_PATH=`get_abs_path $OPTARG`
- ;;
- :)
- echo "-$OPTARG needs an argument"
- exit 1
- ;;
- t)
- UPG_RBK=$OPTARG
- ;;
- :)
- echo "-$OPTARG needs an argument"
- exit 1
- ;;
- l)
- LOG_PATH=`get_abs_path $OPTARG`
- ;;
- :)
- echo "-$OPTARG needs an argument"
- exit 1
- ;;
- i)
- ini_file_path=`get_abs_path $OPTARG`
- ;;
- :)
- echo "-$OPTARG needs an argument"
- exit 1
- ;;
- *)
- echo "command not recognized"
- usage
- exit 1
- ;;
- esac
-done
-
-if [ -z $ini_file_path ]; then
- hostinfo_path="invalid_path_upgrade"
- else
- hostinfo_path=$ini_file_path
-fi
-
-(
-flock -e -n 201
-if [ $? -eq 1 ]
-then
- log $LINENO "another upgrade process is running now, exit"
- exit 1
-fi
-
-if [ -n "${LOG_PATH}" ]; then
- modify_nstack_log_path ${LOG_PATH}
-fi
-modify_log_var
-) 201>>./uplockfile
-
-if [ -f "uplockfile" ]; then
- rm uplockfile
-fi
-
-. ./script/nstack_var.sh
-
-RESTART_MASTER=0
-WAIT_TIME=60
-
-log $LINENO "######################upgrade nstack######################"
-log $LINENO "src ver path ${SRC_VER_PATH},dst ver path ${DST_VER_PATH}, type ${UPG_RBK}, log path ${LOG_PATH}"
-
-upg_pre_chk
-ret=$?
-if [ $ret -ne 0 ]; then
- log $LINENO "pre_chk error err $ret code"
- exit 1
-fi
-
-if [ "${DST_VERSION}" = "${SRC_VERSION}" -a $VERSION_CHK -eq 1 ]; then
- log $LINENO "version equal ${DST_VERSION} ${SRC_VERSION}"
- exit 0
-fi
-log $LINENO "prepare ok"
-
-log $LINENO "src ver $SRC_VERSION with master path $MASTER_PATH,dst ver $DST_VERSION,dst run file $DST_RUN_FILE, type ${UPG_RBK}"
-run_upgrade
-ret=$?
-if [ $ret -ne 0 ]; then
- log $LINENO "run_proc error err $ret code"
- exit 1
-fi
-
-log $LINENO "wait new version start"
-sleep 2
-after_upg_chk
-ret=$?
-if [ $ret -ne 0 ]; then
- log $LINENO "after_chk error err $ret code"
- exit 1
-fi
-
-if [ $RESTART_MASTER -ne 0 ]; then
- log $LINENO "master has restart!"
- opr_suc
- exit 0
-fi
-
-if [ $UPG_MASTER -eq 0 ]; then
- if [ -n "${LOG_PATH}" ]; then
- mod_log_path 2 ${LOG_PATH}
- fi
- opr_suc
- exit 0
-fi
-
-run_upgrade_master
-ret=$?
-if [ $ret -ne 0 ]; then
- log $LINENO "run_proc master error err $ret code"
- exit 1
-fi
-
-log $LINENO "wait new version master start"
-sleep 2
-after_upg_master_chk
-ret=$?
-if [ $ret -ne 0 ]; then
- log $LINENO "after_chk master error err $ret code"
- exit 1
-fi
-
-opr_suc
diff --git a/stacks/lwip_stack/release_tar.sh b/stacks/lwip_stack/release_tar.sh
index 6c2928f..d3cfa68 100644
--- a/stacks/lwip_stack/release_tar.sh
+++ b/stacks/lwip_stack/release_tar.sh
@@ -29,7 +29,7 @@ if [ -f "./nStackTools.tar.gz" ]; then
fi
mkdir ./nStackServer/lib64
-cp ./release/lib64/libnstack.so ./release/lib64/libnStackAPI.so ./release/lib64/libnstackcmd.so ./release/lib64/libsecurec.so ./nStackServer/lib64
+cp ./release/lib64/liblwip_dpdk.so ./release/lib64/libnStackAPI.so ./release/lib64/libnstackcmd.so ./release/lib64/libsecurec.so ./nStackServer/lib64
mkdir ./nStackServer/bin
cp ./release/bin/nStackCtrl ./release/bin/nStackMain ./release/bin/nStackMaster ./release/bin/set_permission.sh ./nStackServer/bin
mkdir ./nStackServer/conf
@@ -47,7 +47,7 @@ dos2unix ./nStackServer/*.sh
find ./nStackServer -type f | grep -E "*.sh|*.py" | xargs chmod +x
mkdir ./nStackClient/lib64
-cp ./release/lib64/libnstack.so ./release/lib64/libnStackAPI.so ./release/lib64/libsecurec.so ./nStackClient/lib64
+cp ./release/lib64/liblwip_dpdk.so ./release/lib64/libnStackAPI.so ./release/lib64/libsecurec.so ./nStackClient/lib64
mkdir ./nStackClient/include
cp ./release/include/nstack_custom_api.h ./nStackClient/include
diff --git a/stacks/lwip_stack/src/io_adpt/dpdk.c b/stacks/lwip_stack/src/io_adpt/dpdk.c
index da2cfb6..8518112 100644
--- a/stacks/lwip_stack/src/io_adpt/dpdk.c
+++ b/stacks/lwip_stack/src/io_adpt/dpdk.c
@@ -190,6 +190,89 @@ NSTACK_STATIC struct rte_eth_conf port_conf_default_bond = {
},
};
+NSTACK_STATIC struct rte_eth_conf port_conf_default_vhost = {
+ .rxmode = {
+ .hw_ip_checksum = 0, /* vhost nic doesn't support hw_ip_checksum and hw_vlan_filter */
+ .hw_vlan_filter = 0,
+ }
+};
+
+/*****************************************************************************
+* Prototype : dpdk_mbuf_to_file
+* Description : write the packet data into a file
+* Input : uint16_t pkt_number
+* struct rte_mbuf **pkts
+* Output : None
+* Return Value :
+* Calls :
+* Called By :
+*
+*****************************************************************************/
+NSTACK_STATIC void
+dpdk_mbuf_to_file (uint16_t pkt_number, struct rte_mbuf **pkts)
+{
+ char line[100] = { 0 };
+ FILE *f = NULL;
+ struct rte_mbuf *p = NULL;
+ uint16_t len = 0, offset, i;
+ uint16_t pktlen = 0;
+ uint16_t start = 0;
+ uint16_t number = 0;
+ unsigned char *data = NULL;
+
+ f = fopen ("/var/log/nStack/packet.txt", "a+");
+ if (f == NULL)
+ {
+ NSHAL_LOGERR ("can not open the file:%s", "packet.txt");
+ return;
+ }
+
+ for (i = 0; i < pkt_number; i++)
+ {
+ pktlen = 0;
+ p = pkts[i];
+ while (p)
+ {
+ len = 0;
+ data = rte_pktmbuf_mtod (p, unsigned char *);
+ while (len < p->data_len)
+ {
+ start = pktlen % 16; /* start of the line */
+ if (start == 0)
+ {
+ number = SNPRINTF_S (line, sizeof (line), sizeof (line) - 1,
+ "%08X", len);
+ }
+
+ for (offset = 0;
+ ((offset + start) < 16) && ((len + offset) < p->data_len);
+ offset++)
+ {
+ number +=
+ SNPRINTF_S (line + number, sizeof (line),
+ sizeof (line) - 1, " %02X",
+ data[len + offset]);
+ }
+
+ fprintf (f, "%s", line);
+ if ((offset + start) == 16)
+ fprintf (f, "\n");
+
+ len += offset;
+ pktlen += offset;
+ (void) MEMSET_S (line, sizeof (line), 0, sizeof (line));
+ }
+
+ p = p->next;
+
+ }
+ fprintf (f, "\n");
+ }
+
+ fclose (f);
+ return;
+}
+
/*****************************************************************************
* Prototype : hal_rte_eth_rx_burst
* Description : a copy of rte_eth_rx_burst, because this function invokes
@@ -207,13 +290,13 @@ NSTACK_STATIC struct rte_eth_conf port_conf_default_bond = {
*****************************************************************************/
NSTACK_STATIC inline uint16_t
hal_rte_eth_rx_burst (uint8_t port_id, uint16_t queue_id,
- struct rte_mbuf **rx_pkts, const uint16_t nb_pkts)
+ struct rte_mbuf ** rx_pkts, const uint16_t nb_pkts)
{
#ifdef RTE_ETHDEV_RXTX_CALLBACKS
struct rte_eth_rxtx_callback *cb;
#endif
int16_t nb_rx;
-
+ char *pst_capture_packet = NULL;
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
if (NULL == dev->rx_pkt_burst)
@@ -250,6 +333,11 @@ hal_rte_eth_rx_burst (uint8_t port_id, uint16_t queue_id,
}
#endif
+ //pst_capture_packet = getenv ("NSTACK_CAPTURE_PACKET");
+ if (pst_capture_packet && strcmp (pst_capture_packet, "1") == 0)
+ {
+ dpdk_mbuf_to_file (nb_rx, rx_pkts);
+ }
return (uint16_t) nb_rx;
}
@@ -274,7 +362,8 @@ hal_rte_eth_tx_burst (uint8_t port_id, uint16_t queue_id,
#ifdef RTE_ETHDEV_RXTX_CALLBACKS
struct rte_eth_rxtx_callback *cb;
#endif
-
+ int16_t nb_tx = 0;
+ char *pst_capture_packet = NULL;
struct rte_eth_dev *dev = &rte_eth_devices[port_id];
if (NULL == dev->tx_pkt_burst)
@@ -309,8 +398,16 @@ hal_rte_eth_tx_burst (uint8_t port_id, uint16_t queue_id,
}
#endif
- return (*dev->tx_pkt_burst) (dev->data->tx_queues[queue_id], tx_pkts,
- nb_pkts);
+ nb_tx = (*dev->tx_pkt_burst) (dev->data->tx_queues[queue_id], tx_pkts,
+ nb_pkts);
+
+ //pst_capture_packet = getenv ("NSTACK_CAPTURE_PACKET");
+ if (pst_capture_packet && strcmp (pst_capture_packet, "1") == 0)
+ {
+ dpdk_mbuf_to_file (nb_tx, tx_pkts);
+ }
+
+ return nb_tx;
}
/*****************************************************************************
@@ -610,6 +707,39 @@ dpdk_set_port (netif_inst_t * inst, uint8_t port)
}
/*****************************************************************************
+ Prototype : dpdk_set_nic_type
+ Description : check and save nic type
+ Input : netif_inst_t* inst
+ const char* type
+ Output : None
+ Return Value : NSTACK_STATIC
+ Calls :
+ Called By :
+
+*****************************************************************************/
+NSTACK_STATIC int
+dpdk_set_nic_type (netif_inst_t * inst, const char *type)
+{
+ int ret;
+
+ ret =
+ STRCPY_S (inst->data.dpdk_if.nic_type,
+ sizeof (inst->data.dpdk_if.nic_type), type);
+ if (EOK != ret)
+ {
+ NSHAL_LOGERR ("strcpy_s set nic_type failed]ret=%d", ret);
+ return -1;
+ }
+
+ /*
+ * *nic_type is first checked at read_ipmoduleoperateadd_configuration,
+ * *thus here we dont boring validating it once more and just return.
+ * */
+
+ return 0;
+}
+
+/*****************************************************************************
Prototype : dpdk_set_nic_name
Description : check and save nic name
Input : netif_inst_t* inst
@@ -1343,10 +1473,25 @@ dpdk_probe_pci (netif_inst_t * inst)
*****************************************************************************/
NSTACK_STATIC int
-dpdk_open (netif_inst_t * inst, const char *name)
+dpdk_open (netif_inst_t * inst, const char *name, const char *type)
{
int ret;
+ if ((inst == NULL) || (name == NULL) || (type == NULL))
+ {
+ NSHAL_LOGERR
+ ("invaliad arguments]inst==NULL, nic_type==NULL or type==NULL");
+ return -1;
+ }
+
+ ret = dpdk_set_nic_type (inst, type);
+
+ if (0 != ret)
+ {
+ NSHAL_LOGERR ("dpdk_set_nic_type fail]nic_type=%s, ret=%d", type, ret);
+ return -1;
+ }
+
ret = dpdk_set_nic_name (inst, name);
if (0 != ret)
@@ -1355,6 +1500,13 @@ dpdk_open (netif_inst_t * inst, const char *name)
return -1;
}
+ if (!strncmp (type, "vhost", strlen ("vhost")))
+ {
+ /*for vhost-user device, the remaining steps is unnecessary, y0413485 */
+ NSHAL_LOGERR ("initting vhost device]nic_name=%s type=%s", name, type);
+ return 0;
+ }
+
ret = dpdk_get_driver_name (inst);
if (0 != ret)
@@ -1498,6 +1650,11 @@ dpdk_get_port_conf (netif_inst_t * inst, struct rte_eth_conf **port_conf)
{
*port_conf = &port_conf_default_bond;
}
+ else if (strncmp ("vhost", inst->data.dpdk_if.nic_type, (size_t) 5) == 0)
+ {
+ *port_conf = &port_conf_default_vhost;
+ return;
+ }
else
{
*port_conf = &port_conf_default_normal;
diff --git a/stacks/lwip_stack/src/nStackMain/main.c b/stacks/lwip_stack/src/nStackMain/main.c
index ce05068..ec36b75 100644
--- a/stacks/lwip_stack/src/nStackMain/main.c
+++ b/stacks/lwip_stack/src/nStackMain/main.c
@@ -42,7 +42,7 @@
#define GlOBAL_HELP "--help"
#define GLOBAL_Dpdk_ARG "dpdk"
#define GLOBAL_STACK_PORT "-port"
-#define NSTACK_MAIN_MAX_PARA 19
+#define NSTACK_MAIN_MAX_PARA 32
#define NSTACK_MAIN_MIN_PARA 1
#define MAX_MASTER_OPEN_FD 1024
diff --git a/stacks/lwip_stack/src/sbr/CMakeLists.txt b/stacks/lwip_stack/src/sbr/CMakeLists.txt
index 42ab4a4..f324e5f 100644
--- a/stacks/lwip_stack/src/sbr/CMakeLists.txt
+++ b/stacks/lwip_stack/src/sbr/CMakeLists.txt
@@ -21,9 +21,9 @@ endif()
FILE(GLOB SBR *.c)
-ADD_LIBRARY(nstack SHARED ${SBR})
-TARGET_LINK_LIBRARIES(nstack -Wl,--whole-archive socket -Wl,--no-whole-archive dmm_api nStackMaintain)
-ADD_DEPENDENCIES(nstack socket DPDK)
+ADD_LIBRARY(lwip_dpdk SHARED ${SBR})
+TARGET_LINK_LIBRARIES(lwip_dpdk -Wl,--whole-archive socket -Wl,--no-whole-archive dmm_api nStackMaintain)
+ADD_DEPENDENCIES(lwip_dpdk socket DPDK)
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_LIST_DIR}/../include
${PAL_H_DIRECTORIES}
diff --git a/stacks/rsocket/CMakeLists.txt b/stacks/rsocket/CMakeLists.txt
index c1b2f18..6ba868b 100644
--- a/stacks/rsocket/CMakeLists.txt
+++ b/stacks/rsocket/CMakeLists.txt
@@ -17,7 +17,7 @@
SET(rdmacm_dir librdmacm-1.1.0)
SET(dmm_inc_dir ${DMM_REL_INC_DIR})
-SET(RSOCKET_DEBUG 0)
+SET(RSOCKET_DEBUG 1)
########################
diff --git a/stacks/rsocket/src/rsocket_adpt.c b/stacks/rsocket/src/rsocket_adpt.c
index ea22c76..2839909 100644
--- a/stacks/rsocket/src/rsocket_adpt.c
+++ b/stacks/rsocket/src/rsocket_adpt.c
@@ -235,6 +235,7 @@ rsocket_stack_register (nstack_proc_cb * proc_fun,
proc_fun->extern_ops.module_init = rsocket_init;
proc_fun->extern_ops.ep_ctl = rsocket_ep_ctl;
proc_fun->extern_ops.ep_getevt = NULL;
+ proc_fun->extern_ops.module_init_child = rsocket_init;
g_rr_var.type = event_ops->type;
g_rr_var.event_cb = event_ops->event_cb;
diff --git a/thirdparty/apps/CMakeLists.txt b/thirdparty/apps/CMakeLists.txt
index 2cf5240..0fffccd 100644
--- a/thirdparty/apps/CMakeLists.txt
+++ b/thirdparty/apps/CMakeLists.txt
@@ -28,18 +28,19 @@ endif()
INCLUDE(ExternalProject)
ExternalProject_Add(
- NGINX
- URL ${NGINX_URL}
- DOWNLOAD_DIR ${NGINX_DOWNLOAD_DIR}
- DOWNLOAD_COMMAND ${NGINX_DOWNLOAD_CMD}
- BUILD_IN_SOURCE 1
- SOURCE_DIR ${NGINX_SRC}
- PATCH_COMMAND echo "./configure --with-ld-opt=\"-L${LIB_PATH_SHARED}/ -lnStackAPI -Wl,-rpath=${LIB_PATH_SHARED}\" --sbin-path=${NGINX_RELEASE}/nginx --conf-path=${NGINX_RELEASE}/nginx.conf --pid-path=${NGINX_RELEASE}/nginx.pid " > configure.sh
- COMMAND sed -i -e "48,49 s/^/#/" ${CMAKE_CURRENT_LIST_DIR}/nginx/nginx-1.12.2/auto/os/linux
- CONFIGURE_COMMAND sh configure.sh
- BUILD_COMMAND make
- INSTALL_COMMAND make install
- DEPENDS nStackAPI
+ NGINX
+ URL ${NGINX_URL}
+ DOWNLOAD_DIR ${NGINX_DOWNLOAD_DIR}
+ DOWNLOAD_COMMAND ${NGINX_DOWNLOAD_CMD}
+ BUILD_IN_SOURCE 1
+ SOURCE_DIR ${NGINX_SRC}
+ PATCH_COMMAND echo "./configure --with-stream --with-ld-opt=\"-L${LIB_PATH_SHARED}/ -lnStackAPI -Wl,-rpath=${LIB_PATH_SHARED}\" --sbin-path=${NGINX_RELEASE}/nginx --conf-path=${NGINX_RELEASE}/nginx.conf --pid-path=${NGINX_RELEASE}/nginx.pid " > configure.sh
+ COMMAND sed -i -e "47 s/$/\"/" ${CMAKE_CURRENT_LIST_DIR}/nginx/nginx-1.12.2/auto/os/linux
+ COMMAND sed -i -e "48,49 s/^/#/" ${CMAKE_CURRENT_LIST_DIR}/nginx/nginx-1.12.2/auto/os/linux
+ CONFIGURE_COMMAND sh configure.sh
+ BUILD_COMMAND make
+ INSTALL_COMMAND make install
+ DEPENDS nStackAPI
)
set_target_properties(NGINX PROPERTIES EXCLUDE_FROM_ALL TRUE)