Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoinstall #6

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 23 additions & 4 deletions Install.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ This guide helps you build and install Snort.
./configure --enable-sourcefire
```

3. Create Patch of Makefille
3. Create Patch of Makefille. This part is critical for the next steps. The defaults are blank. Please type in the answers manually.
```sh
cd ../
./patching-Makefile.sh
Expand Down Expand Up @@ -121,19 +121,38 @@ This guide helps you build and install Snort.
sudo cp -r snort-2.9.8.3/simple-etc /etc/snort
sudo mkdir /usr/local/lib/snort_dynamicrules
```
2. Add snort to path (change /opt/snort if the install path is different)
```
export PATH=$PATH:/opt/snort/bin"
```
3. Set up huge pages
```export ONVM_NUM_HUGEPAGES=1024
hp_size=$(cat /proc/meminfo | grep Hugepagesize | awk '{print $2}')
hp_count="${ONVM_NUM_HUGEPAGES:-1024}"
sudo mkdir -p /mnt/huge
sudo sh -c "echo \"huge /mnt/huge hugetlbfs defaults 0 0\" >> /etc/fstab"
sudo mount -t hugetlbfs nodev /mnt/huge
```
Further troubleshooting:
```sudo sysctl vm.nr_hugepages=$hp_count```

2. Run openNetVM manager. To install openNetVM, refer to this [guide][onvm-install].
4. Run openNetVM manager. To install openNetVM, refer to this [guide][onvm-install].
```sh
cd openNetVM-dev/onvm
./go.sh 0,1,2,3,4 3 -v 0x7f000000000
```
3. Run Snort.
5. Run Snort.
```sh
sudo snort -A console -Q -c /etc/snort/snort.conf -i dpdk0:dpdk1 -N --alert-before-pass --daq-var netvm_args="-l 5 -n 3 --proc-type=secondary -- -r 1 -- -d 4"
```
If the above does not work then try:
```
which snort
sudo `which snort` -A console -Q -c /etc/snort/snort.conf -i dpdk0:dpdk1 -N --alert-before-pass --daq-var netvm_args="-l 5 -n 3 --proc-type=secondary -- -r 1 -- -d 4"
```
![snort init][snort-init]

3. Run Bridge.
6. Run Bridge.
```sh
cd openNetVM-dev/examples/bridge/
./go.sh 6 4
Expand Down
24 changes: 12 additions & 12 deletions daq-2.0.6/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,19 @@ distuninstallcheck_listfiles = find . -type f -print
am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
| sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
distcleancheck_listfiles = find . -type f -print
ACLOCAL = ${SHELL} /users/graceliu/git/onvm-snort/daq-2.0.6/missing aclocal-1.14
ACLOCAL = ${SHELL} ${HOME}/onvm-snort/daq-2.0.6/missing aclocal-1.14
AMTAR = $${TAR-tar}
AM_DEFAULT_VERBOSITY = 1
AR = ar
AUTOCONF = ${SHELL} /users/graceliu/git/onvm-snort/daq-2.0.6/missing autoconf
AUTOHEADER = ${SHELL} /users/graceliu/git/onvm-snort/daq-2.0.6/missing autoheader
AUTOMAKE = ${SHELL} /users/graceliu/git/onvm-snort/daq-2.0.6/missing automake-1.14
AUTOCONF = ${SHELL} ${HOME}/onvm-snort/daq-2.0.6/missing autoconf
AUTOHEADER = ${SHELL} ${HOME}/onvm-snort/daq-2.0.6/missing autoheader
AUTOMAKE = ${SHELL} ${HOME}/onvm-snort/daq-2.0.6/missing automake-1.14
AWK = mawk
CC = gcc
CCDEPMODE = depmode=gcc3
CFLAGS = -g -O2 -fvisibility=hidden -Wall -Wwrite-strings -Wsign-compare -Wcast-align -Wextra -Wformat -Wformat-security -Wno-unused-parameter -fno-strict-aliasing -fdiagnostics-show-option -pedantic -std=c99 -D_GNU_SOURCE -std=gnu99 -Wno-pedantic -std=gnu99 -Wno-pedantic
CPP = gcc -E
CPPFLAGS = -I/usr/include -I/users/graceliu/dpdk-stable-16.11.1/x86_64-native-linuxapp-gcc/include -I/users/graceliu/openNetVM-dev/onvm/onvm_nflib -I/users/graceliu/openNetVM-dev/onvm/shared
CPPFLAGS = -I/usr/include -I${HOME}/onvm-snort/dpdk-stable-16.11.1/x86_64-native-linuxapp-gcc/include -I${HOME}/onvm-snort/openNetVM-dev/onvm/onvm_nflib -I${HOME}/onvm-snort/openNetVM-dev/onvm/shared
CYGPATH_W = echo
DEFS = -DHAVE_CONFIG_H
DEPDIR = .deps
Expand Down Expand Up @@ -237,7 +237,7 @@ LIPO =
LN_S = ln -s
LTLIBOBJS =
LT_SYS_LIBRARY_PATH =
MAKEINFO = ${SHELL} /users/graceliu/git/onvm-snort/daq-2.0.6/missing makeinfo
MAKEINFO = ${SHELL} ${HOME}/onvm-snort/daq-2.0.6/missing makeinfo
MANIFEST_TOOL = :
MKDIR_P = /bin/mkdir -p
NM = /usr/bin/nm -B
Expand All @@ -258,16 +258,16 @@ RANLIB = ranlib
SED = /bin/sed
SET_MAKE =
SHELL = /bin/bash
STATIC_LIBS = -lsfbpf -lsfbpf -L/users/graceliu/dpdk-stable-16.11.1/x86_64-native-linuxapp-gcc/lib -ldpdk -lpthread -lsfbpf -L/users/graceliu/openNetVM-dev/onvm/onvm_nflib/onvm_nflib/x86_64-native-linuxapp-gcc/ -lonvm -L/users/graceliu/dpdk-stable-16.11.1/x86_64-native-linuxapp-gcc/lib -ldpdk -lpthread -lpcap -lsfbpf -lpcap
STATIC_LIBS = -lsfbpf -lsfbpf -L${HOME}/onvm-snort/dpdk-stable-16.11.1/x86_64-native-linuxapp-gcc/lib -ldpdk -lpthread -lsfbpf -L${HOME}/onvm-snort/openNetVM-dev/onvm/onvm_nflib/onvm_nflib/x86_64-native-linuxapp-gcc/ -lonvm -L${HOME}/onvm-snort/dpdk-stable-16.11.1/x86_64-native-linuxapp-gcc/lib -ldpdk -lpthread -lpcap -lsfbpf -lpcap
STRIP = strip
VERSION = 2.0.6
V_LEX = flex -Psfbpf_
V_YACC = bison -y -p sfbpf_
XCCFLAGS =
abs_builddir = /users/graceliu/git/onvm-snort/daq-2.0.6
abs_srcdir = /users/graceliu/git/onvm-snort/daq-2.0.6
abs_top_builddir = /users/graceliu/git/onvm-snort/daq-2.0.6
abs_top_srcdir = /users/graceliu/git/onvm-snort/daq-2.0.6
abs_builddir = ${HOME}/onvm-snort/daq-2.0.6
abs_srcdir = ${HOME}/onvm-snort/daq-2.0.6
abs_top_builddir = ${HOME}/onvm-snort/daq-2.0.6
abs_top_srcdir = ${HOME}/onvm-snort/daq-2.0.6
ac_ct_AR = ar
ac_ct_CC = gcc
ac_ct_DUMPBIN =
Expand Down Expand Up @@ -296,7 +296,7 @@ host_vendor = unknown
htmldir = ${docdir}
includedir = ${prefix}/include
infodir = ${datarootdir}/info
install_sh = ${SHELL} /users/graceliu/git/onvm-snort/daq-2.0.6/install-sh
install_sh = ${SHELL} ${HOME}/onvm-snort/daq-2.0.6/install-sh
libdir = ${exec_prefix}/lib
libexecdir = ${exec_prefix}/libexec
localedir = ${datarootdir}/locale
Expand Down
15 changes: 14 additions & 1 deletion daq-2.0.6/os-daq-modules/daq_netvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <rte_common.h>
#include <rte_mbuf.h>
#include <rte_ip.h>
#include <rte_cycles.h>

//----- NetVM header files and tags ----
#include <onvm_common.h>
Expand Down Expand Up @@ -301,6 +302,9 @@ static int netvm_daq_acquire(void *handle, int cnt, DAQ_Analysis_Func_t callback
uint16_t nb_pkts;
uint16_t i, j;
int tx_batch_size;
uint64_t start;
double cpu_time;
double pps;

//printf("->netvm_daq_acquire(%d - %d)\n", cnt, max_pkts);
//if (once) {
Expand All @@ -318,7 +322,9 @@ static int netvm_daq_acquire(void *handle, int cnt, DAQ_Analysis_Func_t callback
netvmc->break_loop = 0;
return 0;
}


start = rte_get_tsc_cycles();

/* Dequeue all packets in ring up to max possible. */
nb_pkts = rte_ring_dequeue_burst(netvmc->rx_ring, pktsRX, max_pkts);

Expand Down Expand Up @@ -401,6 +407,13 @@ static int netvm_daq_acquire(void *handle, int cnt, DAQ_Analysis_Func_t callback
/* Enqueue on return to NetVM */
pktsTX[tx_batch_size++] = pktsRX[i];
}

cpu_time = (double)(rte_get_tsc_cycles() - start) / rte_get_tsc_hz();
pps = (double) (nb_pkts / cpu_time);

printf("CPU Time: %f\n", cpu_time);
printf("PPS: %f\n", pps);
printf("nb_pkts: %" PRIu16 "\n");

/* Give returned burst of packets back to NetVM manager. */
if (unlikely(tx_batch_size > 0 && rte_ring_enqueue_bulk(netvmc->tx_ring, pktsTX, tx_batch_size) == -ENOBUFS)) {
Expand Down
96 changes: 96 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#! /bin/bash

# openNetVM
# https://sdnfv.github.io
#
# OpenNetVM is distributed under the following BSD LICENSE:
#
# Copyright(c)
# 2015-2016 George Washington University
# 2015-2016 University of California Riverside
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * The name of the author may not be used to endorse or promote
# products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ls | grep setenv.sh
ANS=`echo $?`
if [ $ANS == 1 ]
then
echo please run this script in situ
exit
fi

./setenv.sh
source ~/.bashrc

# Base directory
BASE_DIR=$(pwd)

# update
sudo apt-get update

cd $RTE_SDK
make config T=x86_64-native-linuxapp-gcc O=x86_64-native-linuxapp-gcc
make -j7 T=$RTE_TARGET O=$RTE_TARGET
sudo make install T=x86_64-native-linuxapp-gcc

# Compile DAQ
sudo apt-get install -y libpcap-dev libpcre3-dev libdumbnet-dev zlib1g-dev liblzma-dev libssl-dev autoconf

cd $BASE_DIR/daq*

make clean
aclocal
autoconf
autoheader
automake -a

./configure --with-dpdk-includes=$RTE_SDK/$RTE_TARGET/include --with-dpdk-libraries=$RTE_SDK/$RTE_TARGET/lib --with-netvm-includes=$ONVM_HOME/onvm --with-netvm-libraries=$ONVM_HOME/onvm

make -j7
sudo make install

# Compile snort
cd $BASE_DIR/snort*
./configure --enable-sourcefire

cd snort*/src
make clean
cp ../../Makefile.patched Makefile
make -j7
sudo make install

sudo ldconfig

sudo cp -r snort*/simple-etc /etc/snort
sudo mkdir /usr/local/lib/snort_dynamicrules

cd $ONVM_HOME
scripts/install.sh
cd onvm && make

cd $BASE_DIR
12 changes: 6 additions & 6 deletions openNetVM-dev/scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ fi
start_dir=$(pwd)

# Compile dpdk
cd $RTE_SDK
echo "Compiling and installing dpdk in $RTE_SDK"
sleep 1
make config T=$RTE_TARGET
make T=$RTE_TARGET -j 8
make install T=$RTE_TARGET -j 8
#cd $RTE_SDK
#echo "Compiling and installing dpdk in $RTE_SDK"
#sleep 1
#make config T=$RTE_TARGET
#make T=$RTE_TARGET -j 8
#make install T=$RTE_TARGET -j 8

# Refresh sudo
sudo -v
Expand Down
52 changes: 51 additions & 1 deletion patching-Makefile.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,40 @@
#!/bin/bash
#! /bin/bash

# openNetVM
# https://sdnfv.github.io
#
# OpenNetVM is distributed under the following BSD LICENSE:
#
# Copyright(c)
# 2015-2016 George Washington University
# 2015-2016 University of California Riverside
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * The name of the author may not be used to endorse or promote
# products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

_PATCH_FILE_NAME=Makefile.patched
_MAIN_FILE_TO_PATCH=Makefile.dpdk
Expand All @@ -10,10 +46,24 @@ if [ ! -e $_MAIN_FILE_TO_PATCH ];then
fi
# Insert Directory of Cloned Repo
read -p "onvm-snort cloned at [$(realpath `pwd`/..)] (example: /home/user): " _DIR || exit 10
#if [ -z "_DIR" ]
#then
# _DIR=$HOME
#fi
_DIR=${_DIR:-$(realpath `pwd`/..)}/onvm-snort/

read -p "Snort will install to [/usr/local/] (example: /opt/snort): " _SNORT_INSTALL || exit 10
#if [ -z "$_SNORT_INSTALL" ]
#then
# _SNORT_INSTALL=/opt/snort
#fi
_SNORT_INSTALL=${_SNORT_INSTALL:-/usr/local/}

read -p "DAQ Install PATH [Using System as Default] (example: /opt/daq): " _DAQ_INSTALL || exit 10
#if [ -z "$_DAQ_INSTALL" ]
#then
# _DAQ_INSTALL=/opt/daq
#fi
_DAQ_INSTALL=${_DAQ_INSTALL:- }

# Create patched file
Expand Down
Loading