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

Changing the Install.md #5

Open
wants to merge 6 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
14 changes: 13 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,12 @@ 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);

/* 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
55 changes: 55 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
ls | grep setenv.sh
ANS=`echo $?`
if [ $ANS == 1 ]
then
echo please run this script in situ
exit
fi

./setenv.sh

# Base directory
BASE_DIR=$(pwd)

# update
sudo apt-get update

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

cd onvm && make

# 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
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 $BASE_DIR
14 changes: 14 additions & 0 deletions patching-Makefile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,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
86 changes: 86 additions & 0 deletions setenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
ls | grep setenv.sh
ANS=`echo $?`
if [ $ANS == 1 ]
then
echo please run this script in situ
exit
fi

sudo apt-get install realpath

# Base directory
BASE_DIR=$(pwd)

grep RTE_TARGET ~/.bashrc
ANS=`echo $?`
if [ $ANS == 1 ]
then
echo export RTE_TARGET=x86_64-native-linuxapp-gcc >> ~/.bashrc
fi

grep DPDK_TARGET ~/.bashrc
ANS=`echo $?`
if [ $ANS == 1 ]
then
echo export DPDK_TARGET=x86_64-native-linuxapp-gcc >> ~/.bashrc
fi

cd $BASE_DIR/dpdk*
grep RTE_SDK ~/.bashrc
ANS=`echo $?`
if [ $ANS == 1 ]
then
echo export RTE_SDK=$(pwd) >> ~/.bashrc
fi

cd $BASE_DIR/openNetVM*
grep ONVM_HOME ~/.bashrc
ANS=`echo $?`
if [ $ANS == 1 ]
then
echo export ONVM_HOME=$(pwd) >> ~/.bashrc
fi

cd $BASE_DIR
ls | grep Makefile.patched
ANS=`echo $?`
if [ $ANS == 0 ]
then
read -p "Do you want to create the snort Makefile again? (y/N): " ANS
else
ANS='y'
fi

if [ "$ANS" == "y" ]
then
./patching-Makefile.sh
cp ./Makefile.patched $BASE_DIR/snort*/src/
fi

grep "/opt/snort" ~/.bashrc
ANS=`echo $?`
if [ $ANS == 0 ]
then
echo export PATH=$PATH:/opt/snort/bin >> ~/.bashrc
fi

grep ONVM_NUM_HUGEPAGES ~/.bashrc
ANS=`echo $?`
if [ $ANS == 1 ]
then
echo export ONVM_NUM_HUGEPAGES=1024 >> ~/.bashrc
fi

echo using nics 06:00.0 and 06:00.1
grep ONVM_NIC_PCI ~/.bashrc
ANS=`echo $?`
if [ $ANS == 1 ]
then
echo 'export ONVM_NIC_PCI=" 06:00.0 06:00.1 "' >> ~/.bashrc
fi

source ~/.bashrc

sudo sh -c "echo 0 > /proc/sys/kernel/randomize_va_space"

cd $BASE_DIR