diff options
Diffstat (limited to 'demo')
38 files changed, 0 insertions, 1674 deletions
diff --git a/demo/nginx_proxy/README.md b/demo/nginx_proxy/README.md deleted file mode 100644 index 4085cc9..0000000 --- a/demo/nginx_proxy/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# 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. - -##demo-3 - -This demo NGINX as a reverse proxy server. The server uses kernel tcp/ip as client facing stack and rsocket -stack as upstream server facing stack. diff --git a/demo/nginx_proxy/demo-1/Vagrantfile b/demo/nginx_proxy/demo-1/Vagrantfile deleted file mode 100644 index d3db5e5..0000000 --- a/demo/nginx_proxy/demo-1/Vagrantfile +++ /dev/null @@ -1,98 +0,0 @@ -# -*- 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 deleted file mode 100644 index 282e3bd..0000000 --- a/demo/nginx_proxy/demo-1/adjust_hugepage.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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 deleted file mode 100755 index 84ecc59..0000000 --- a/demo/nginx_proxy/demo-1/apply_patch.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/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 deleted file mode 100644 index f1bc8d3..0000000 --- a/demo/nginx_proxy/demo-1/demo_2stack.patch +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index 5f9424f..0000000 --- a/demo/nginx_proxy/demo-1/module_config.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "default_stack_name": "kernel", - "module_list": [ - { - "stack_name": "kernel", - "libname": "./", - "deploytype": "1", - "stackid": "0", - }, - { - "stack_name": "lwip", - "libname": "liblwip_dpdk.so", - "deploytype": "3", - "stackid": "1", - }, - { - "stack_name": "vpp_hoststack", - "libname": "./libdmm_vcl.so", - "deploytype": "4", - "stackid": "2", - }, - ] -} diff --git a/demo/nginx_proxy/demo-1/proxy_nginx.conf b/demo/nginx_proxy/demo-1/proxy_nginx.conf deleted file mode 100644 index 05d8d2a..0000000 --- a/demo/nginx_proxy/demo-1/proxy_nginx.conf +++ /dev/null @@ -1,81 +0,0 @@ -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 deleted file mode 100644 index 71f8919..0000000 --- a/demo/nginx_proxy/demo-1/rd_config.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "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 deleted file mode 100644 index bd0d030..0000000 --- a/demo/nginx_proxy/demo-1/setup_proxy.sh +++ /dev/null @@ -1,54 +0,0 @@ -######################################################################### -# 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/configure/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 deleted file mode 100644 index 0c2c774..0000000 --- a/demo/nginx_proxy/demo-1/setup_upstream.sh +++ /dev/null @@ -1,45 +0,0 @@ -######################################################################### -# 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 deleted file mode 100644 index 616cd88..0000000 --- a/demo/nginx_proxy/demo-1/startup.conf +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 3904197..0000000 --- a/demo/nginx_proxy/demo-1/upstream_nginx.conf +++ /dev/null @@ -1,80 +0,0 @@ -#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 deleted file mode 100644 index aaeadfb..0000000 --- a/demo/nginx_proxy/demo-1/vpp_config +++ /dev/null @@ -1,6 +0,0 @@ -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 deleted file mode 100644 index 7d6feb1..0000000 --- a/demo/nginx_proxy/demo-2/README.md +++ /dev/null @@ -1,69 +0,0 @@ -#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$ ./udpclient -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. diff --git a/demo/nginx_proxy/demo-2/Vagrantfile b/demo/nginx_proxy/demo-2/Vagrantfile deleted file mode 100644 index dbd703a..0000000 --- a/demo/nginx_proxy/demo-2/Vagrantfile +++ /dev/null @@ -1,116 +0,0 @@ -# -*- 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 deleted file mode 100644 index 282e3bd..0000000 --- a/demo/nginx_proxy/demo-2/adjust_hugepage.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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 deleted file mode 100755 index 05e8c66..0000000 --- a/demo/nginx_proxy/demo-2/apply_patch.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/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 Binary files differdeleted file mode 100644 index ad81372..0000000 --- a/demo/nginx_proxy/demo-2/dem-2-topo.png +++ /dev/null diff --git a/demo/nginx_proxy/demo-2/demo-2.png b/demo/nginx_proxy/demo-2/demo-2.png Binary files differdeleted file mode 100644 index 604c301..0000000 --- a/demo/nginx_proxy/demo-2/demo-2.png +++ /dev/null diff --git a/demo/nginx_proxy/demo-2/demo_2stack.patch b/demo/nginx_proxy/demo-2/demo_2stack.patch deleted file mode 100644 index f1bc8d3..0000000 --- a/demo/nginx_proxy/demo-2/demo_2stack.patch +++ /dev/null @@ -1,29 +0,0 @@ -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 deleted file mode 100644 index 5f9424f..0000000 --- a/demo/nginx_proxy/demo-2/module_config.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "default_stack_name": "kernel", - "module_list": [ - { - "stack_name": "kernel", - "libname": "./", - "deploytype": "1", - "stackid": "0", - }, - { - "stack_name": "lwip", - "libname": "liblwip_dpdk.so", - "deploytype": "3", - "stackid": "1", - }, - { - "stack_name": "vpp_hoststack", - "libname": "./libdmm_vcl.so", - "deploytype": "4", - "stackid": "2", - }, - ] -} diff --git a/demo/nginx_proxy/demo-2/proxy_nginx.conf b/demo/nginx_proxy/demo-2/proxy_nginx.conf deleted file mode 100644 index 925e1a9..0000000 --- a/demo/nginx_proxy/demo-2/proxy_nginx.conf +++ /dev/null @@ -1,33 +0,0 @@ -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 deleted file mode 100644 index 45ad585..0000000 --- a/demo/nginx_proxy/demo-2/rd_config.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "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 deleted file mode 100644 index a0f4363..0000000 --- a/demo/nginx_proxy/demo-2/setup_client.sh +++ /dev/null @@ -1,25 +0,0 @@ -######################################################################### -# 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 deleted file mode 100644 index 8c3d69a..0000000 --- a/demo/nginx_proxy/demo-2/setup_proxy.sh +++ /dev/null @@ -1,54 +0,0 @@ -######################################################################### -# 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/configure/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 deleted file mode 100644 index d684286..0000000 --- a/demo/nginx_proxy/demo-2/setup_udpserver.sh +++ /dev/null @@ -1,25 +0,0 @@ -######################################################################### -# 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 deleted file mode 100644 index ee7dbd4..0000000 --- a/demo/nginx_proxy/demo-2/setup_upstream.sh +++ /dev/null @@ -1,44 +0,0 @@ -######################################################################### -# 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 deleted file mode 100644 index 616cd88..0000000 --- a/demo/nginx_proxy/demo-2/startup.conf +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 76e7b05..0000000 --- a/demo/nginx_proxy/demo-2/udpclient.c +++ /dev/null @@ -1,50 +0,0 @@ -#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 deleted file mode 100644 index 456c7fc..0000000 --- a/demo/nginx_proxy/demo-2/udpserver.c +++ /dev/null @@ -1,55 +0,0 @@ -#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 deleted file mode 100644 index 3904197..0000000 --- a/demo/nginx_proxy/demo-2/upstream_nginx.conf +++ /dev/null @@ -1,80 +0,0 @@ -#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 deleted file mode 100644 index aaeadfb..0000000 --- a/demo/nginx_proxy/demo-2/vpp_config +++ /dev/null @@ -1,6 +0,0 @@ -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-3/NGINX_with_DMM_Demo.md b/demo/nginx_proxy/demo-3/NGINX_with_DMM_Demo.md deleted file mode 100644 index 6deb348..0000000 --- a/demo/nginx_proxy/demo-3/NGINX_with_DMM_Demo.md +++ /dev/null @@ -1,26 +0,0 @@ -# Demo: NGINX working with multi-stack using DMM - -![image](rsocket.png) - - - -In above diagram NGINX box in the middle is working as reverse proxy. -One of the NIC ( client facing) is using kernel tcp/ip stack whereas the -other NIC is connected to upstream server using rsocket tcp/ip stack. - -you can use test.c to compile a server depend on libnStackAPI.so. It bind the -port 8888 by default and you can change it to other port. Then copy the -module_config.json rd_config.json to the folder of server. Then you can start the -server as follow: -./server 162.128.1.16 - -####More Information: -https://wiki.fd.io/view/DMM -https://www.nginx.com/blog/ip-transparency-direct-server-return-nginx-plus-transparent-proxy/ - - - - - - - diff --git a/demo/nginx_proxy/demo-3/proxy_nginx.conf b/demo/nginx_proxy/demo-3/proxy_nginx.conf deleted file mode 100644 index fb085ac..0000000 --- a/demo/nginx_proxy/demo-3/proxy_nginx.conf +++ /dev/null @@ -1,81 +0,0 @@ -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.131.181:80 default_server; - server_name 192.168.131.181; - - location / { - proxy_bind 192.168.21.181; - proxy_pass http://192.168.21.180:8888; - 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-3/rd_config.json b/demo/nginx_proxy/demo-3/rd_config.json deleted file mode 100644 index 51fa4a5..0000000 --- a/demo/nginx_proxy/demo-3/rd_config.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "ip_route": [ - { - "subnet": "192.168.131.1/24", - "stack_name": "kernel", - }, - { - "subnet": "192.168.21.1/24", - "stack_name": "rsocket", - }, - ], - "prot_route": [ - { - "proto_type": "1", - "stack_name": "rsocket", - }, - { - "proto_type": "2", - "stack_name": "kernel", - } - ], -} - diff --git a/demo/nginx_proxy/demo-3/rsocket.png b/demo/nginx_proxy/demo-3/rsocket.png Binary files differdeleted file mode 100644 index 389ae19..0000000 --- a/demo/nginx_proxy/demo-3/rsocket.png +++ /dev/null diff --git a/demo/nginx_proxy/demo-3/server/index.html b/demo/nginx_proxy/demo-3/server/index.html deleted file mode 100644 index 9ab30e1..0000000 --- a/demo/nginx_proxy/demo-3/server/index.html +++ /dev/null @@ -1,31 +0,0 @@ -<!DOCTYPE html> - -<!-- -Copyright 2015 Google Inc. -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. ---> - -<html> - -<head> - <title>Hello, world</title> - <link rel="stylesheet" href="/style.css"> - <script src="/script.js"></script> -</head> - -<body> - <h1>Hello, world</h1> - - <button onclick="fetchMessage()">Fetch Message</button> - <p id="message">Click on the button to fetch the message.</p> -</body> - -</html> diff --git a/demo/nginx_proxy/demo-3/server/test.c b/demo/nginx_proxy/demo-3/server/test.c deleted file mode 100644 index 9ffde09..0000000 --- a/demo/nginx_proxy/demo-3/server/test.c +++ /dev/null @@ -1,320 +0,0 @@ -/* - * httpd.c - * - * Copyright Adin Scannell 2011 - * - * This code is intended for demo purposes only, - * please don't actually use it to do anything. - * - * To compile, use: - * gcc -o httpd httpd.c - * Then, create a file 'index.html' in the directory - * that you are running the server from. Put stuff in - * it. - * Then go to http://localhost:8888 and see the file. - */ - -#include <sys/socket.h> -#include <sys/types.h> -#include <sys/wait.h> -#include <sys/sendfile.h> -#include <sys/stat.h> -#include <arpa/inet.h> -#include <fcntl.h> -#include <unistd.h> -#include <string.h> -#include <stdio.h> -#include <stdlib.h> - -#include <sys/mman.h> - -#define HTTP_BAD_REQUEST "HTTP/1.0 404 Not Found\r\n" -#define HTTP_GOOD_REQUEST "HTTP/1.0 200\r\n" -#define HTTP_CONTENT_TYPE "Content-Type: text/html\r\n" -#define HTTP_CONTENT_LENGTH "Content-Length: %ld\r\n\r\n" -#define MAX_REQUEST_SIZE 4096 -#define DEFAULT_PATH "index.html" - -#define DEBUG -#ifdef DEBUG -#define log(fmt, args...) fprintf(stderr, fmt "\n", ## args) -#else -#define log(fmt, args...) -#endif - -int -send_error (int fd) -{ - write (fd, HTTP_BAD_REQUEST, strlen (HTTP_BAD_REQUEST)); - write (fd, HTTP_CONTENT_TYPE, strlen (HTTP_CONTENT_TYPE)); - return 0; -} - -int -send_file (int fd, char *path) -{ - int iofd = open (path, O_RDONLY); - - int ret = 0; - if (iofd < 0) - { - write (fd, HTTP_BAD_REQUEST, strlen (HTTP_BAD_REQUEST)); - write (fd, HTTP_CONTENT_TYPE, strlen (HTTP_CONTENT_TYPE)); - log ("error opening file"); - } - else - { - char length[MAX_REQUEST_SIZE]; - struct stat statinfo; - if (fstat (iofd, &statinfo) < 0) - { - /* Can't get the length. */ - write (fd, HTTP_BAD_REQUEST, strlen (HTTP_BAD_REQUEST)); - write (fd, HTTP_CONTENT_TYPE, strlen (HTTP_CONTENT_TYPE)); - log ("error fetching size"); - } - else - { - ret = write (fd, HTTP_GOOD_REQUEST, strlen (HTTP_GOOD_REQUEST)); - - log ("write HTTP_GOOD_REQUEST %s ret %d", HTTP_GOOD_REQUEST, ret); - ret = write (fd, HTTP_CONTENT_TYPE, strlen (HTTP_CONTENT_TYPE)); - log ("write HTTP_CONTENT_TYPE %s ret %d", HTTP_CONTENT_TYPE, ret); - snprintf (length, MAX_REQUEST_SIZE, - HTTP_CONTENT_LENGTH, statinfo.st_size); - - ret = write (fd, length, strlen (length)); - log ("write %s ret %d", length, ret); - -#if 1 -#if 1 - //char *source = NULL; - //source = malloc(sizeof(char) * (statinfo.st_size + 1)); - void *file_addr = NULL; - file_addr = - mmap (NULL, statinfo.st_size, PROT_READ, MAP_PRIVATE, iofd, 0); - - if (write (fd, file_addr, statinfo.st_size) < 0) - { - perror ("wyl new"); - } - -#else -// if( write(fd, length, strlen(length)) < 0 || - if (sendfile (fd, iofd, NULL, statinfo.st_size) < 0) - { - /* Error sending the file. Nothing can be done. */ - perror ("error writing file"); - } -#endif - -#endif - close (fd); - } - - close (iofd); - } - - return 0; -} - -int -process (int fd, char *header) -{ - char npath[MAX_REQUEST_SIZE]; - - char *eol = strchr (header, '\r'); - - /* Nuts to thread-safe, this demo uses it's own process :P */ - char *method = strtok (header, " "); - char *path = strtok (NULL, " "); - char *http = strtok (NULL, " "); - - if (eol != NULL) - { - *eol = '\0'; - } - - /* Debug output here, just in case anyone is watching. */ - log (" * method = %s", method); - log (" * path = %s", path); - log (" * http = %s", http); - - /* Ensure that we can process it. */ - if (strcmp (method, "GET") || - (strcmp (http, "HTTP/1.0") && strcmp (http, "HTTP/1.1"))) - { - log ("bad request"); - return send_error (fd); - } - else - { - if (path[0] == '/' && path[1] == '\0') - { - path = DEFAULT_PATH; - } - else if (path[0] == '/') - { - snprintf (npath, MAX_REQUEST_SIZE, ".%s", path); - path = npath; - } - log ("sending %s to %d", path, fd); - return send_file (fd, path); - } -} - -int -service (int fd) -{ - char buffer[MAX_REQUEST_SIZE]; - int readbytes = 0, scanned = 0; - - /* Attempt to read a chunk of bytes, but not process forever. */ - while (readbytes < (MAX_REQUEST_SIZE - 1)) - { - log ("read from %d", fd); - int cur = - read (fd, &(buffer[readbytes]), (MAX_REQUEST_SIZE - 1) - readbytes); - if (cur < 0) - { - perror ("read failed"); - return -1; - } - else - { - buffer[readbytes + cur + 1] = '\0'; - readbytes += cur; - } - - /* Check for the \n\n found at the end of the header. */ - for (; scanned < readbytes - 3; scanned++) - { - if (buffer[scanned] == '\r' && buffer[scanned + 1] == '\n' && - buffer[scanned + 2] == '\r' && buffer[scanned + 3] == '\n') - { - buffer[scanned] = '\0'; - return process (fd, buffer); - } - } - } - - /* Failed to find the end of the header. */ - log ("header too long"); - return -1; -} - -int -main (int argc, char *argv[]) -{ - - struct sockaddr_in servaddr; - int serversock = socket (AF_INET, SOCK_STREAM, 0); - int on = 1; - - if (NULL == argv[1]) - { - log ("please set the ip argument"); - return 1; - } - - /* Create socket. */ - if (serversock < 0) - { - perror ("error creating socket"); - return 1; - } - - /* Tweak it for reuse. Not necessary for fork, just useful * - * when one is killing and running this server a few times. */ - if (setsockopt (serversock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof (on)) < 0) - { - perror ("unable to tweak socket options"); - } - - /* Bind to port 8888. */ - memset (&servaddr, 0, sizeof (servaddr)); - servaddr.sin_family = AF_INET; - //servaddr.sin_addr.s_addr = inet_addr("192.168.21.180"); - servaddr.sin_addr.s_addr = inet_addr (argv[1]); - servaddr.sin_port = htons (8888); - if (bind (serversock, (struct sockaddr *) &servaddr, sizeof (servaddr)) < 0) - { - perror ("couldn't bind to given address"); - return 1; - } - log ("bound to %s:8888", argv[1]); - - /* Start listening, queue size 10. */ - if (listen (serversock, 10) < 0) - { - perror ("listen failed"); - return 1; - } - log ("listening"); - - /* Enter the service loop. */ - while (1) - { - int clientsock, pid, childstatus; - log ("waiting for next request"); - - /* Grab the next request. */ - clientsock = accept (serversock, NULL, NULL); - if (clientsock < 0) - { - perror ("accept failed"); - break; - } - log ("accepted connection %d from %d, forking ", clientsock, - serversock); - - /* Fork off a handler. */ - //pid = fork(); - pid = 0; - if (pid < 0) - { - perror ("fork failed"); - close (clientsock); - continue; - } - else if (pid > 0) - { - close (clientsock); - } - else - { - //close(serversock); - log ("servicing connection (as child) sfd %d cfd %d", serversock, - clientsock); - service (clientsock); - //return 0; - } - - /* Collect any exit statuses (lazy). */ - -#if 0 - while (1) - { - pid = waitpid (-1, &childstatus, WNOHANG); - if (pid < 0) - { - perror ("waitpid error?"); - break; - } - else if (pid == 0) - { - break; - } - else if (WIFEXITED (childstatus)) - { - log ("child %d exited with status %d", pid, - WEXITSTATUS (childstatus)); - } - } -#endif - - } - - /* Should never arrive here. */ - return 254; -} |