diff options
-rwxr-xr-x | scripts/build.sh | 256 | ||||
-rwxr-xr-x | scripts/build_dmm_dep.sh | 30 | ||||
-rwxr-xr-x | scripts/build_dpdk.sh | 63 | ||||
-rwxr-xr-x | scripts/build_rsocket.sh | 34 | ||||
-rwxr-xr-x | scripts/check_hugepage.sh | 41 | ||||
-rwxr-xr-x | scripts/compile_dmm.sh | 29 | ||||
-rwxr-xr-x[-rw-r--r--] | scripts/install_prereq.sh (renamed from stacks/lwip_stack/vagrant/install_prereq.sh) | 0 | ||||
-rwxr-xr-x | scripts/prep_app_test.sh | 80 | ||||
-rwxr-xr-x | scripts/print_os_info.sh | 17 | ||||
-rw-r--r-- | stacks/lwip_stack/vagrant/Vagrantfile | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | stacks/lwip_stack/vagrant/build.sh | 237 | ||||
-rwxr-xr-x[-rw-r--r--] | stacks/lwip_stack/vagrant/env.sh | 0 | ||||
-rwxr-xr-x | stacks/lwip_stack/vagrant/start_nstackMain.sh | 118 |
13 files changed, 448 insertions, 463 deletions
diff --git a/scripts/build.sh b/scripts/build.sh index 7726f94..eaa0f0e 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -22,7 +22,11 @@ exec 1> >(tee -a "$log_file") 2>&1 # Get Command Line arguements if present DMM_DIR=$1 -if [ "x$1" != "x" ]; then +if [ "$1" == "all" ]; then + BUILD_ALL="YES" +fi + +if [ "x$1" != "x" ] && [ "$1" != "all" ]; then DMM_DIR=$1 else DMM_DIR=`dirname $(readlink -f $0)`/../ @@ -34,253 +38,29 @@ echo 2:$2 echo DMM_DIR: $DMM_DIR BUILD_DIR=${DMM_DIR}/build -LIB_PATH=${DMM_DIR}/release/lib64 - -OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') -OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') -KERNEL_OS=`uname -o` -KERNEL_MACHINE=`uname -m` -KERNEL_RELEASE=`uname -r` -KERNEL_VERSION=`uname -v` - -echo KERNEL_OS: $KERNEL_OS -echo KERNEL_MACHINE: $KERNEL_MACHINE -echo KERNEL_RELEASE: $KERNEL_RELEASE -echo KERNEL_VERSION: $KERNEL_VERSION -echo OS_ID: $OS_ID -echo OS_VERSION_ID: $OS_VERSION_ID +#print os information +bash -x $DMM_DIR/scripts/print_os_info.sh # add inherited proxy for sudo user LINE='Defaults env_keep += "ftp_proxy http_proxy https_proxy no_proxy"' FILE=/etc/sudoers grep -qF -- "$LINE" "$FILE" || sudo echo "$LINE" >> "$FILE" -#DPDK download path -DPDK_DOWNLOAD_PATH=/tmp/dpdk - -#dpdk installation path -DPDK_INSTALL_PATH=/usr - #set and check the environment for Linux -if [ "$OS_ID" == "ubuntu" ]; then - export DEBIAN_FRONTEND=noninteractive - export DEBCONF_NONINTERACTIVE_SEEN=true - - APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" - sudo apt-get update ${APT_OPTS} - sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim pkg-config tcl libnl-route-3-200 flex graphviz tk debhelper dpatch gfortran ethtool libgfortran3 bison dkms quilt chrpath swig python-libxml2 -elif [ "$OS_ID" == "debian" ]; then - echo "not tested for debian and exit" - exit 1 - export DEBIAN_FRONTEND=noninteractive - export DEBCONF_NONINTERACTIVE_SEEN=true - - APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" - sudo apt-get update ${APT_OPTS} - sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim -elif [ "$OS_ID" == "centos" ]; then - sudo yum install -y deltarpm git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel libiverbs tk tcl tcsh redhat-lsb-core -elif [ "$OS_ID" == "opensuse" ]; then - echo "not tested for opensuse and exit" - exit 1 - sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel -fi - - -#DPDK will be having dependancy on linux headers -if [ "$OS_ID" == "ubuntu" ]; then - sudo apt-get -y install git build-essential linux-headers-`uname -r` - sudo apt-get -y install libnuma-dev -elif [ "$OS_ID" == "debian" ]; then - sudo apt-get -y install git build-essential linux-headers-`uname -r` -elif [ "$OS_ID" == "centos" ]; then - sudo yum groupinstall -y "Development Tools" - sudo yum install -y kernel-headers - sudo yum install -y numactl-devel -elif [ "$OS_ID" == "opensuse" ]; then - sudo yum groupinstall -y "Development Tools" - sudo yum install -y kernel-headers -fi - +bash -x $DMM_DIR/scripts/build_dmm_dep.sh || exit 1 #===========build DPDK================ - -if [ "$OS_ID" == "centos" ]; then - bash -x $DMM_DIR/scripts/build_dpdk1802.sh || exit 1 -else - - if [ ! -d /usr/include/dpdk ] || [ ! -d /usr/share/dpdk ] || [ ! -d /usr/lib/modules/4.4.0-31-generic/extra/dpdk ]; then - mkdir -p $DPDK_DOWNLOAD_PATH - - DPDK_FOLDER=$DPDK_DOWNLOAD_PATH/dpdk-18.02-$TIMESTAMP - cd $DPDK_DOWNLOAD_PATH - mkdir $DPDK_FOLDER - wget -N https://fast.dpdk.org/rel/dpdk-18.02.tar.xz --no-check-certificate - tar xvf dpdk-18.02.tar.xz -C $DPDK_FOLDER - cd $DPDK_FOLDER/dpdk-18.02 - - sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base - sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base - sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base - sed -i 's!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1' config/common_base - - sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -j 4 - - mkdir -p /tmp/dpdk/drivers/ - cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/ - fi -fi +bash -x $DMM_DIR/scripts/build_dpdk.sh || exit 1 #===========build DMM================= -echo "DMM build started....." - -cd $BUILD_DIR -rm -rf * -cmake .. -make -j 8 - -if [ $? -eq 0 ]; then - echo "DMM build is SUCCESS" -else - echo "DMM build has FAILED" - exit 1 -fi - -if [ "$OS_ID" == "centos" ]; then - make pkg-rpm -elif [ "$OS_ID" == "ubuntu" ]; then - make pkg-deb -fi - -#===========check running env ================= -hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'}) -if [ "$hugepagesize" == "2048" ]; then - pages=1536 -elif [ "$hugepagesize" == "1048576" ]; then - pages=3 -fi -sudo sysctl -w vm.nr_hugepages=$pages -HUGEPAGES=`sysctl -n vm.nr_hugepages` -if [ $HUGEPAGES != $pages ]; then - echo "ERROR: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish." - exit -fi - -hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0") -if [ $hugepageTotal -ne 0 ]; then - echo "HugePages_Total is zero" - exit -fi - -hugepageFree=$(cat /proc/meminfo | grep -c "HugePages_Free: 0") -if [ $hugepageFree -ne 0 ]; then - echo "HugePages_Free is zero" - exit -fi - -hugepageSize=$(cat /proc/meminfo | grep -c "Hugepagesize: 0 kB") -if [ $hugepageSize -ne 0 ]; then - echo "Hugepagesize is zero" - exit -fi - -sudo mkdir /mnt/nstackhuge -p -if [ "$hugepagesize" == "2048" ]; then - sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/ -elif [ "$hugepagesize" == "1048576" ]; then - sudo mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/ -fi -#sudo mkdir -p /var/run/ip_module/ - -#disable ASLR, othewise it may have some problems when mapping memory for secondary process -echo 0 > /proc/sys/kernel/randomize_va_space - -export LD_LIBRARY_PATH=$LIB_PATH -export NSTACK_LOG_ON=DBG - -############### Preapre APP test directory -echo -e "\e[41m Preapring APP test directory.....\e[0m" - -mkdir -p $DMM_DIR/config/app_test -cd $DMM_DIR/config/app_test - -if [ "$OS_ID" == "ubuntu" ]; then - ifaddress1=$(ifconfig enp0s8 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') - echo $ifaddress1 - ifaddress2=$(ifconfig enp0s9 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') - echo $ifaddress2 -elif [ "$OS_ID" == "centos" ]; then - ifaddress1=$(ifconfig enp0s8 | grep 'inet' | cut -d: -f2 | awk '{print $2}') - echo $ifaddress1 - ifaddress2=$(ifconfig enp0s9 | grep 'inet' | cut -d: -f2 | awk '{print $2}') - echo $ifaddress2 -fi - -echo '{ - "default_stack_name": "kernel", - "module_list": [ - { - "stack_name": "kernel", - "function_name": "kernel_stack_register", - "libname": "./", - "loadtype": "static", - "deploytype": "1", - "maxfd": "1024", - "minfd": "0", - "priorty": "1", - "stackid": "0", - }, - ] -}' | tee module_config.json - -echo '{ - "ip_route": [ - { - "subnet": "'$ifaddress1'/24", - "type": "nstack-kernel", - }, - { - "subnet": "'$ifaddress2'/24", - "type": "nstack-kernel", - }, - ], - "prot_route": [ - { - "proto_type": "1", - "type": "nstack-kernel", - }, - { - "proto_type": "2", - "type": "nstack-kernel", - } - ], -}' | tee rd_config.json - -echo "DMM build finished....." - -############### build rsocket -echo "rsocket build start" -cd $DMM_DIR/stacks/rsocket -if [ "$OS_ID" == "ubuntu" ]; then - wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz - tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz - cd MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64 -elif [ "$OS_ID" == "centos" ]; then - CENT_VERSION=`grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release` - wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz - tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz - cd MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64 -fi - -./mlnxofedinstall --force || exit 1 - -cd $BUILD_DIR -make dmm_rsocket -if [ $? -eq 0 ]; then - echo "rsocket build has SUCCESS" -else - echo "rsocket build has FAILED" - exit 1 +bash -x $DMM_DIR/scripts/compile_dmm.sh || exit 1 + +if [ "${BUILD_ALL}" == "YES" ]; then + #===========build LWIP================ + bash -x $DMM_DIR/stacks/lwip_stack/vagrant/build.sh "from-base-build" || exit 1 + #============build rsocket============================ + bash -x $DMM_DIR/scripts/build_rsocket.sh || exit 1 + #=======other new stacks build can be called from here + echo "SUCCESSFULLY built all the stacks" fi -echo "rsocket build finished" diff --git a/scripts/build_dmm_dep.sh b/scripts/build_dmm_dep.sh new file mode 100755 index 0000000..980b3f5 --- /dev/null +++ b/scripts/build_dmm_dep.sh @@ -0,0 +1,30 @@ +#!/bin/bash -x + +set -x + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') + +#set and check the environment for Linux +if [ "$OS_ID" == "ubuntu" ]; then + export DEBIAN_FRONTEND=noninteractive + export DEBCONF_NONINTERACTIVE_SEEN=true + + APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" + sudo apt-get update ${APT_OPTS} + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim pkg-config tcl libnl-route-3-200 flex graphviz tk debhelper dpatch gfortran ethtool libgfortran3 bison dkms quilt chrpath swig python-libxml2 unzip +elif [ "$OS_ID" == "debian" ]; then + echo "not tested for debian and exit" + exit 1 + export DEBIAN_FRONTEND=noninteractive + export DEBCONF_NONINTERACTIVE_SEEN=true + + APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" + sudo apt-get update ${APT_OPTS} + sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim +elif [ "$OS_ID" == "centos" ]; then + sudo yum install -y deltarpm git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel libiverbs tk tcl tcsh redhat-lsb-core +elif [ "$OS_ID" == "opensuse" ]; then + echo "not tested for opensuse and exit" + exit 1 + sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel +fi diff --git a/scripts/build_dpdk.sh b/scripts/build_dpdk.sh new file mode 100755 index 0000000..f631b27 --- /dev/null +++ b/scripts/build_dpdk.sh @@ -0,0 +1,63 @@ +#!/bin/bash -x + +set -x + +SCRIPT_DIR=`dirname $(readlink -f $0)` + +#DPDK download path +#if any change kindly update DPDK_DOWNLOAD_PATH in DMM/stacks/lwip_stack/vagrant/start_nStackMain.sh +DPDK_DOWNLOAD_PATH=/tmp/dpdk + +#dpdk installation path +DPDK_INSTALL_PATH=/usr + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +echo OS_ID: $OS_ID + +#DPDK will be having dependancy on linux headers +if [ "$OS_ID" == "ubuntu" ]; then + sudo apt-get -y install git build-essential linux-headers-`uname -r` + sudo apt-get -y install libnuma-dev +elif [ "$OS_ID" == "debian" ]; then + sudo apt-get -y install git build-essential linux-headers-`uname -r` +elif [ "$OS_ID" == "centos" ]; then + sudo yum groupinstall -y "Development Tools" + sudo yum install -y kernel-headers + sudo yum install -y numactl-devel +elif [ "$OS_ID" == "opensuse" ]; then + sudo yum groupinstall -y "Development Tools" + sudo yum install -y kernel-headers +fi + +#===========build DPDK================ + +if [ "$OS_ID" == "centos" ]; then + bash -x $SCRIPT_DIR/build_dpdk1802.sh || exit 1 +else + + if [ ! -d /usr/include/dpdk ] || [ ! -d /usr/share/dpdk ] || [ ! -d /usr/lib/modules/4.4.0-31-generic/extra/dpdk ]; then + mkdir -p $DPDK_DOWNLOAD_PATH + + cd $DPDK_DOWNLOAD_PATH + wget -N https://fast.dpdk.org/rel/dpdk-18.02.tar.xz --no-check-certificate + tar xvf dpdk-18.02.tar.xz + cd dpdk-18.02 + + sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base + sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base + sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base + sed -i 's!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1' config/common_base + + sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -j 4 + + if [ $? -eq 0 ]; then + echo "DPDK build is SUCCESS" + else + echo "DPDK build has FAILED" + exit 1 + fi + + mkdir -p /tmp/dpdk/drivers/ + cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/ + fi +fi diff --git a/scripts/build_rsocket.sh b/scripts/build_rsocket.sh new file mode 100755 index 0000000..ef31c88 --- /dev/null +++ b/scripts/build_rsocket.sh @@ -0,0 +1,34 @@ +#!/bin/bash -x + +set -x + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') + +DMM_DIR=`dirname $(readlink -f $0)`/../ +BUILD_DIR=${DMM_DIR}/build + +############### build rsocket +echo "rsocket build start" +cd $DMM_DIR/stacks/rsocket +if [ "$OS_ID" == "ubuntu" ]; then + wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz + tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64.tgz + cd MLNX_OFED_LINUX-4.4-1.0.0.0-ubuntu16.04-x86_64 +elif [ "$OS_ID" == "centos" ]; then + CENT_VERSION=`grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release` + wget http://www.mellanox.com/downloads/ofed/MLNX_OFED-4.4-1.0.0.0/MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz + tar -zxvf MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64.tgz + cd MLNX_OFED_LINUX-4.4-1.0.0.0-rhel${CENT_VERSION}-x86_64 +fi + +sudo ./mlnxofedinstall --force || exit 1 + +cd $BUILD_DIR +make dmm_rsocket +if [ $? -eq 0 ]; then + echo "rsocket build has SUCCESS" +else + echo "rsocket build has FAILED" + exit 1 +fi +echo "rsocket build finished"
\ No newline at end of file diff --git a/scripts/check_hugepage.sh b/scripts/check_hugepage.sh new file mode 100755 index 0000000..bde11a9 --- /dev/null +++ b/scripts/check_hugepage.sh @@ -0,0 +1,41 @@ +#!/bin/bash -x + +set -x + +hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'}) +if [ "$hugepagesize" == "2048" ]; then + pages=1536 +elif [ "$hugepagesize" == "1048576" ]; then + pages=3 +fi +sudo sysctl -w vm.nr_hugepages=$pages +HUGEPAGES=`sysctl -n vm.nr_hugepages` +if [ $HUGEPAGES != $pages ]; then + echo "ERROR: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish." + exit 1 +fi + +hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0") +if [ $hugepageTotal -ne 0 ]; then + echo "HugePages_Total is zero" + exit 1 +fi + +hugepageFree=$(cat /proc/meminfo | grep -c "HugePages_Free: 0") +if [ $hugepageFree -ne 0 ]; then + echo "HugePages_Free is zero" + exit 1 +fi + +hugepageSize=$(cat /proc/meminfo | grep -c "Hugepagesize: 0 kB") +if [ $hugepageSize -ne 0 ]; then + echo "Hugepagesize is zero" + exit 1 +fi + +sudo mkdir /mnt/nstackhuge -p +if [ "$hugepagesize" == "2048" ]; then + sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/ +elif [ "$hugepagesize" == "1048576" ]; then + sudo mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/ +fi diff --git a/scripts/compile_dmm.sh b/scripts/compile_dmm.sh new file mode 100755 index 0000000..b4bc455 --- /dev/null +++ b/scripts/compile_dmm.sh @@ -0,0 +1,29 @@ +#!/bin/bash -x + +set -x + +BUILD_DIR=`dirname $(readlink -f $0)`/../build + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') + +echo "DMM build started....." + +cd $BUILD_DIR +rm -rf * +cmake .. +make -j 8 + +if [ $? -eq 0 ]; then + echo "DMM build is SUCCESS" +else + echo "DMM build has FAILED" + exit 1 +fi + +if [ "$OS_ID" == "centos" ]; then + make pkg-rpm +elif [ "$OS_ID" == "ubuntu" ]; then + make pkg-deb +fi + +echo "DMM build has FINISHED" diff --git a/stacks/lwip_stack/vagrant/install_prereq.sh b/scripts/install_prereq.sh index ae8d442..ae8d442 100644..100755 --- a/stacks/lwip_stack/vagrant/install_prereq.sh +++ b/scripts/install_prereq.sh diff --git a/scripts/prep_app_test.sh b/scripts/prep_app_test.sh new file mode 100755 index 0000000..23bfa8b --- /dev/null +++ b/scripts/prep_app_test.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +set -x +DMM_DIR=`dirname $(readlink -f $0)`/.. +LIB_PATH=$DMM_DIR/release/lib64/ + +mkdir -p $DMM_DIR/config/app_test +cd $DMM_DIR/config/app_test + +#===========check hugepages================= +source $DMM_DIR/scripts/check_hugepage.sh + +echo -e "\e[41m Preapring APP test directory.....\e[0m" + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +if [ "$OS_ID" == "ubuntu" ]; then + ifaddress1=$(ifconfig enp0s8 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') + echo $ifaddress1 + ifaddress2=$(ifconfig enp0s9 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}') + echo $ifaddress2 +elif [ "$OS_ID" == "centos" ]; then + ifaddress1=$(ifconfig enp0s8 | grep 'inet' | cut -d: -f2 | awk '{print $2}') + echo $ifaddress1 + ifaddress2=$(ifconfig enp0s9 | grep 'inet' | cut -d: -f2 | awk '{print $2}') + echo $ifaddress2 +fi + +echo '{ + "default_stack_name": "kernel", + "module_list": [ + { + "stack_name": "kernel", + "function_name": "kernel_stack_register", + "libname": "./", + "loadtype": "static", + "deploytype": "1", + "maxfd": "1024", + "minfd": "0", + "priorty": "1", + "stackid": "0", + }, + ] +}' | tee module_config.json + +echo '{ + "ip_route": [ + { + "subnet": "'$ifaddress1'/24", + "type": "nstack-kernel", + }, + { + "subnet": "'$ifaddress2'/24", + "type": "nstack-kernel", + }, + ], + "prot_route": [ + { + "proto_type": "1", + "type": "nstack-kernel", + }, + { + "proto_type": "2", + "type": "nstack-kernel", + } + ], +}' | tee rd_config.json + +cp -r ${DMM_DIR}/release/lib64/* . +cp -r ${DMM_DIR}/release/configure/* . +cp -r ${DMM_DIR}/release/bin/* . +chmod 775 * + +#disable ASLR, othewise it may have some problems when mapping memory for secondary process +echo 0 > /proc/sys/kernel/randomize_va_space + +sudo mkdir -p /var/run/ip_module/ +sudo mkdir -p /var/log/nStack/ip_module/ + +export LD_LIBRARY_PATH=$LIB_PATH +export NSTACK_LOG_ON=DBG
\ No newline at end of file diff --git a/scripts/print_os_info.sh b/scripts/print_os_info.sh new file mode 100755 index 0000000..4d61c7b --- /dev/null +++ b/scripts/print_os_info.sh @@ -0,0 +1,17 @@ +#!/bin/bash -x + +set -x + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +KERNEL_OS=`uname -o` +KERNEL_MACHINE=`uname -m` +KERNEL_RELEASE=`uname -r` +KERNEL_VERSION=`uname -v` + +echo KERNEL_OS: $KERNEL_OS +echo KERNEL_MACHINE: $KERNEL_MACHINE +echo KERNEL_RELEASE: $KERNEL_RELEASE +echo KERNEL_VERSION: $KERNEL_VERSION +echo OS_ID: $OS_ID +echo OS_VERSION_ID: $OS_VERSION_ID diff --git a/stacks/lwip_stack/vagrant/Vagrantfile b/stacks/lwip_stack/vagrant/Vagrantfile index cd59dbf..b3a31c1 100644 --- a/stacks/lwip_stack/vagrant/Vagrantfile +++ b/stacks/lwip_stack/vagrant/Vagrantfile @@ -14,12 +14,14 @@ Vagrant.configure(2) do |config| # Create DMM client and server VM's config.vm.define "dmm-stackx-server" do |server| - server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install_prereq.sh") + server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh") server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/DMM vagrant" + server.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"start_nstackMain.sh"), :args => "/DMM vagrant" end config.vm.define "dmm-stackx-client" do |client| - client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"install_prereq.sh") + client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"../../../scripts/install_prereq.sh") client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh"), :args => "/DMM vagrant" + client.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"start_nstackMain.sh"), :args => "/DMM vagrant" end diff --git a/stacks/lwip_stack/vagrant/build.sh b/stacks/lwip_stack/vagrant/build.sh index 8b1cb37..a934eef 100644..100755 --- a/stacks/lwip_stack/vagrant/build.sh +++ b/stacks/lwip_stack/vagrant/build.sh @@ -21,16 +21,17 @@ log_file="/tmp/build_log.txt-$TIMESTAMP" exec 1> >(tee -a "$log_file") 2>&1 # Get Command Line arguements if present -TEMP_DIR=$1 -if [ "x$1" != "x" ]; then +if [ "$1" == "from-base-build" ]; then + WAS_DMM_BUILT="YES" +fi + +if [ "x$1" != "x" ] && [ "$1" != "from-base-build" ]; then TEMP_DIR=$1 - DMM_BUILD_DIR=${TEMP_DIR}/build - DPDK_BUILD_SCRIPT_DIR=${DMM_BUILD_DIR}/../scripts + DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/scripts LWIP_BUILD_DIR=${TEMP_DIR}/stacks/lwip_stack/build/ else TEMP_DIR=`dirname $(readlink -f $0)`/.. - DMM_BUILD_DIR=${TEMP_DIR}/../../build - DPDK_BUILD_SCRIPT_DIR=${DMM_BUILD_DIR}/../scripts + DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/../../scripts LWIP_BUILD_DIR=${TEMP_DIR}/build/ fi @@ -38,231 +39,21 @@ echo 0:$0 echo 1:$1 echo 2:$2 echo TEMP_DIR: $TEMP_DIR -echo DMM_BUILD_DIR: $DMM_BUILD_DIR -echo DPDK_BUILD_SCRIPT_DIR: $DPDK_BUILD_SCRIPT_DIR +echo DMM_BUILD_SCRIPT_DIR: $DMM_BUILD_SCRIPT_DIR echo LWIP_BUILD_DIR: $LWIP_BUILD_DIR -OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') -OS_VERSION_ID=$(grep '^VERSION_ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') -KERNEL_OS=`uname -o` -KERNEL_MACHINE=`uname -m` -KERNEL_RELEASE=`uname -r` -KERNEL_VERSION=`uname -v` - -echo KERNEL_OS: $KERNEL_OS -echo KERNEL_MACHINE: $KERNEL_MACHINE -echo KERNEL_RELEASE: $KERNEL_RELEASE -echo KERNEL_VERSION: $KERNEL_VERSION -echo OS_ID: $OS_ID -echo OS_VERSION_ID: $OS_ID - -#DPDK download path -DPDK_DOWNLOAD_PATH=/tmp/dpdk - -#dpdk installation path -DPDK_INSTALL_PATH=/usr - -#set and check the environment for Linux -if [ "$OS_ID" == "ubuntu" ]; then - export DEBIAN_FRONTEND=noninteractive - export DEBCONF_NONINTERACTIVE_SEEN=true - - APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" - sudo apt-get update ${APT_OPTS} - sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim ethtool unzip -elif [ "$OS_ID" == "debian" ]; then - echo "not tested for debian and exit" - exit 1 - export DEBIAN_FRONTEND=noninteractive - export DEBCONF_NONINTERACTIVE_SEEN=true - - APT_OPTS="--assume-yes --no-install-suggests --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" - sudo apt-get update ${APT_OPTS} - sudo DEBIAN_FRONTEND=noninteractive apt-get install -yq git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump libpcre3 libpcre3-dev zlibc zlib1g zlib1g-dev vim -elif [ "$OS_ID" == "centos" ]; then - sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel -elif [ "$OS_ID" == "opensuse" ]; then - echo "not tested for opensuse and exit" - exit 1 - sudo yum install -y git cmake gcc g++ automake libtool wget lsof lshw pciutils net-tools tcpdump vim sudo yum-utils pcre-devel zlib-devel -fi - -#DPDK will be having dependancy on linux headers -if [ "$OS_ID" == "ubuntu" ]; then - sudo apt-get -y install git build-essential linux-headers-`uname -r` - sudo apt-get -y install libnuma-dev -elif [ "$OS_ID" == "debian" ]; then - sudo apt-get -y install git build-essential linux-headers-`uname -r` -elif [ "$OS_ID" == "centos" ]; then - sudo yum groupinstall -y "Development Tools" - sudo yum install -y kernel-headers - sudo yum install -y numactl-devel -elif [ "$OS_ID" == "opensuse" ]; then - sudo yum groupinstall -y "Development Tools" - sudo yum install -y kernel-headers +if [ 'x$WAS_DMM_BUILT' != "xYES" ]; then + bash -x $DMM_BUILD_SCRIPT_DIR/build.sh fi -#===========build DPDK================ - -if [ ! -d /usr/include/dpdk ] || [ ! -d /usr/share/dpdk ] || [ ! -d /usr/lib/modules/4.4.0-31-generic/extra/dpdk ]; then - mkdir -p $DPDK_DOWNLOAD_PATH - - cd $DPDK_DOWNLOAD_PATH - wget -N https://fast.dpdk.org/rel/dpdk-18.02.tar.xz --no-check-certificate - tar xvf dpdk-18.02.tar.xz - cd dpdk-18.02/ - - sed -i 's!CONFIG_RTE_EXEC_ENV=.*!CONFIG_RTE_EXEC_ENV=y!1' config/common_base - sed -i 's!CONFIG_RTE_BUILD_SHARED_LIB=.*!CONFIG_RTE_BUILD_SHARED_LIB=y!1' config/common_base - sed -i 's!CONFIG_RTE_LIBRTE_EAL=.*!CONFIG_RTE_LIBRTE_EAL=y!1' config/common_base - sed -i 's!CONFIG_RTE_EAL_PMD_PATH=.*!CONFIG_RTE_EAL_PMD_PATH="/tmp/dpdk/drivers/"!1' config/common_base - - sudo make install T=x86_64-native-linuxapp-gcc DESTDIR=${DPDK_INSTALL_PATH} -j 4 - - mkdir -p /tmp/dpdk/drivers/ - cp -f /usr/lib/librte_mempool_ring.so /tmp/dpdk/drivers/ -fi -#===========build DMM================= -echo "DMM build started....." - -cd $DMM_BUILD_DIR -ldconfig -rm -rf * -cmake .. -make -j 8 -if [ $? -eq 0 ]; then - echo "DMM build is SUCCESS" -else - echo "DMM build has FAILED" - exit 1 -fi -echo "DMM build finished....." - -#===========build Stackpool=========== -echo "Stackpool build started....." +#===========build LWIP=========== +echo "LWIP build started....." cd $LWIP_BUILD_DIR cmake .. make -j 8 if [ $? -eq 0 ]; then - echo "Stackpool build is SUCCESS" + echo "LWIP build is SUCCESS" else - echo "Stackpool build has FAILED" - exit 1 -fi -echo "Stackpool build finished....." - -#===========check running env ================= -hugepagesize=$(cat /proc/meminfo | grep Hugepagesize | awk -F " " {'print$2'}) -if [ "$hugepagesize" == "2048" ]; then - pages=1536 -elif [ "$hugepagesize" == "1048576" ]; then - pages=3 -fi -sudo sysctl -w vm.nr_hugepages=$pages -HUGEPAGES=`sysctl -n vm.nr_hugepages` -if [ $HUGEPAGES != $pages ]; then - echo "ERROR: Unable to get $pages hugepages, only got $HUGEPAGES. Cannot finish." - exit -fi - - -hugepageTotal=$(cat /proc/meminfo | grep -c "HugePages_Total: 0") -if [ $hugepageTotal -ne 0 ]; then - echo "HugePages_Total is zero" - exit -fi - -hugepageFree=$(cat /proc/meminfo | grep -c "HugePages_Free: 0") -if [ $hugepageFree -ne 0 ]; then - echo "HugePages_Free is zero" - exit -fi - -hugepageSize=$(cat /proc/meminfo | grep -c "Hugepagesize: 0 kB") -if [ $hugepageSize -ne 0 ]; then - echo "Hugepagesize is zero" - exit -fi - - -sudo mkdir /mnt/nstackhuge -p -if [ "$hugepagesize" == "2048" ]; then -sudo mount -t hugetlbfs -o pagesize=2M none /mnt/nstackhuge/ -elif [ "$hugepagesize" == "1048576" ]; then - sudo mount -t hugetlbfs -o pagesize=1G none /mnt/nstackhuge/ -fi -sudo mkdir -p /var/run/ip_module/ -sudo mkdir -p /var/log/nStack/ip_module/ - -export LD_LIBRARY_PATH=$LIB_PATH -export NSTACK_LOG_ON=DBG - - - -#===========set environment=========== -if [ "$OS_ID" == "centos" ]; then - ifaddress1=$(ifconfig enp0s8 | grep 'inet' | cut -d: -f2 | awk '{print $2}') - echo $ifaddress1 - ifaddresscut=$(ifconfig enp0s8 | grep 'inet' | head -n 1 | awk -F " " '{print $2}' | awk -F "." '{print $1"."$2"."$3}') - echo $ifaddresscut - ifmac=$(ifconfig enp0s8 | grep 'ether' | awk -F " " '{print $2}') - echo $ifmac -elif [ "$OS_ID" == "ubuntu" ]; then - ifaddress1=$(ifconfig enp0s8 | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}') - echo $ifaddress1 - ifaddresscut=$(ifconfig enp0s8 | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}' | awk -F "." '{print $1"."$2"."$3}') - echo $ifaddresscut - ifmac=$(ifconfig enp0s8 | grep 'HWaddr' | awk -F " " '{print $5}') - echo $ifmac -fi - -cd $LWIP_BUILD_DIR/../ -bash ./release_tar.sh -cd nStackServer/script -sed -i 's!/root/dpdk/dpdk-18.02!'$DPDK_DOWNLOAD_PATH'/dpdk-18.02!1' nstack_var.sh - -cd ../ -cp ./configure/*.json bin/ -cd bin - -if [ "$OS_ID" == "centos" ]; then - sed -i 's!eth7!enp0s8!1' ip_data.json -elif [ "$OS_ID" == "ubuntu" ]; then - sed -i 's!eth7!enp0s8!1' ip_data.json -fi - -sed -i 's!00:54:32:19:3d:19!'$ifmac'!1' ip_data.json -sed -i 's!192.168.1.207!'$ifaddress1'!1' ip_data.json - -sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' network_data_tonStack.json -sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json -sed -i 's!192.168.1.098!'$ifaddresscut'.5!1' network_data_tonStack.json -sed -i 's!192.168.1.209!'$ifaddresscut'.254!1' network_data_tonStack.json -sed -i 's!192.168.1.0!'$ifaddresscut'.0!1' network_data_tonStack.json -sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json - -if [ "$OS_ID" == "centos" ]; then - sed -i 's!eth7!enp0s8!1' network_data_tonStack.json -elif [ "$OS_ID" == "ubuntu" ]; then - sed -i 's!eth7!enp0s8!1' network_data_tonStack.json -fi -sed -i 's!eth7!enp0s8!1' network_data_tonStack.json - -cd $DMM_BUILD_DIR/../release/bin -cp -r . ../../stacks/lwip_stack/app_test -cd $DMM_BUILD_DIR/../stacks/lwip_stack/app_test -cp -r ../app_conf/*.json . - -sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' rd_config.json - -cd $LWIP_BUILD_DIR/../nStackServer -bash -x ./stop_nstack.sh -bash -x ./start_nstack.sh -check_result=$(pgrep nStackMain) -if [ -z "$check_result" ]; then - echo "nStackMain execute failed" + echo "LWIP build has FAILED" exit 1 -else - echo "nStackMain execute successful" - exit 0 fi diff --git a/stacks/lwip_stack/vagrant/env.sh b/stacks/lwip_stack/vagrant/env.sh index 96ad346..96ad346 100644..100755 --- a/stacks/lwip_stack/vagrant/env.sh +++ b/stacks/lwip_stack/vagrant/env.sh diff --git a/stacks/lwip_stack/vagrant/start_nstackMain.sh b/stacks/lwip_stack/vagrant/start_nstackMain.sh new file mode 100755 index 0000000..72d1375 --- /dev/null +++ b/stacks/lwip_stack/vagrant/start_nstackMain.sh @@ -0,0 +1,118 @@ +######################################################################### +# Copyright (c) 2018 Huawei Technologies Co.,Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +######################################################################### +#!/bin/bash -x + +set -x + +DPDK_DOWNLOAD_PATH=/tmp/dpdk +ifname=enp0s8 + +if [ "x$1" != "x" ] && [ "$1" != "from-base-build" ]; then + TEMP_DIR=$1 + DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/scripts + LWIP_BUILD_DIR=${TEMP_DIR}/stacks/lwip_stack/build/ +else + TEMP_DIR=`dirname $(readlink -f $0)`/.. + DMM_BUILD_SCRIPT_DIR=${TEMP_DIR}/../../scripts + LWIP_BUILD_DIR=${TEMP_DIR}/build/ +fi + +LIB_PATH=$LWIP_BUILD_DIR/../release/lib64/ + +echo 0:$0 +echo 1:$1 +echo 2:$2 +echo TEMP_DIR: $TEMP_DIR +echo DMM_BUILD_SCRIPT_DIR: $DMM_BUILD_SCRIPT_DIR +echo LWIP_BUILD_DIR: $LWIP_BUILD_DIR +echo LIB_PATH: $LIB_PATH + +#===========check hugepages================= +source $DMM_BUILD_SCRIPT_DIR/check_hugepage.sh + +OS_ID=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') +if [ "$OS_ID" == "centos" ]; then + ifaddress1=$(ifconfig $ifname | grep 'inet' | cut -d: -f2 | awk '{print $2}') + echo $ifaddress1 + ifaddresscut=$(ifconfig $ifname | grep 'inet' | head -n 1 | awk -F " " '{print $2}' | awk -F "." '{print $1"."$2"."$3}') + echo $ifaddresscut + ifmac=$(ifconfig $ifname | grep 'ether' | awk -F " " '{print $2}') + echo $ifmac +elif [ "$OS_ID" == "ubuntu" ]; then + ifaddress1=$(ifconfig $ifname | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}') + echo $ifaddress1 + ifaddresscut=$(ifconfig $ifname | grep 'inet' | head -n 1 | cut -d: -f2 | awk '{print $1}' | awk -F "." '{print $1"."$2"."$3}') + echo $ifaddresscut + ifmac=$(ifconfig $ifname | grep 'HWaddr' | awk -F " " '{print $5}') + echo $ifmac +fi + +cd $LWIP_BUILD_DIR/../ +bash ./release_tar.sh +cd nStackServer/script +sed -i 's!/root/dpdk/dpdk-18.02!'$DPDK_DOWNLOAD_PATH'/dpdk-18.02!1' nstack_var.sh + +cd ../ +chmod 775 * +cp ./configure/*.json bin/ +cd bin + +if [ "$OS_ID" == "centos" ]; then + sed -i 's!eth7!'$ifname'!1' ip_data.json +elif [ "$OS_ID" == "ubuntu" ]; then + sed -i 's!eth7!'$ifname'!1' ip_data.json +fi + +sed -i 's!00:54:32:19:3d:19!'$ifmac'!1' ip_data.json +sed -i 's!192.168.1.207!'$ifaddress1'!1' ip_data.json + +sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' network_data_tonStack.json +sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json +sed -i 's!192.168.1.098!'$ifaddresscut'.5!1' network_data_tonStack.json +sed -i 's!192.168.1.209!'$ifaddresscut'.254!1' network_data_tonStack.json +sed -i 's!192.168.1.0!'$ifaddresscut'.0!1' network_data_tonStack.json +sed -i 's!192.168.1.254!'$ifaddresscut'.1!1' network_data_tonStack.json + +if [ "$OS_ID" == "centos" ]; then + sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json +elif [ "$OS_ID" == "ubuntu" ]; then + sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json +fi +sed -i 's!eth7!'$ifname'!1' network_data_tonStack.json + +cd $DMM_BUILD_SCRIPT_DIR/../release/bin +cp -r . ../../stacks/lwip_stack/app_test +cd $DMM_BUILD_SCRIPT_DIR/../stacks/lwip_stack/app_test +cp -r ../app_conf/*.json . + +sed -i 's!192.168.1.1!'$ifaddresscut'.0!1' rd_config.json + +sudo mkdir -p /var/run/ip_module/ +sudo mkdir -p /var/log/nStack/ip_module/ + +export LD_LIBRARY_PATH=$LIB_PATH +export NSTACK_LOG_ON=DBG + +cd $LWIP_BUILD_DIR/../nStackServer +bash -x ./stop_nstack.sh +bash -x ./start_nstack.sh +check_result=$(pgrep nStackMain) +if [ -z "$check_result" ]; then + echo "nStackMain execute failed" + exit 1 +else + echo "nStackMain execute successful" + exit 0 +fi |