From fbabd40240ad3c3b6ab828f2a31fd559d4e5930d Mon Sep 17 00:00:00 2001 From: Daniel Lazkani Feferman Date: Fri, 3 Aug 2018 14:05:13 -0700 Subject: [PATCH] Added table limit fix and small README updates (#64) --- README.md | 38 ++++++---- old_mk/README.md | 83 +++++++++++----------- src/hardware_dep/odp/includes/odp_tables.h | 2 +- 3 files changed, 66 insertions(+), 57 deletions(-) diff --git a/README.md b/README.md index 4974b3c..2ec8b46 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ MACSAD uses ODP for forwarding plane developement. 1. Download ODP v1.19.0.2, compile and install it: - sudo apt-get install -y build-essential autoconf automake pkg-config libssl-dev libconfig-dev + apt-get install -y build-essential autoconf automake pkg-config libssl-dev libconfig-dev libtool wget https://github.com/Linaro/odp/archive/v1.19.0.2.tar.gz - tar xzvf v1.19.0.2.tar.gz + tar xzvf v1.19.0.2.tar.gz; rm v1.19.0.2.tar.gz mv odp-1.19.0.2/ odp/ cd odp ./bootstrap @@ -26,7 +26,7 @@ MACSAD uses ODP for forwarding plane developement. of the ODP build directory before running any of these commands): echo `pwd`/build/lib | sudo tee /etc/ld.so.conf.d/odp.conf - sudo ldconfig + ldconfig export PKG_CONFIG_PATH=`pwd`/build/lib/pkgconfig echo "export PKG_CONFIG_PATH=`pwd`/build/lib/pkgconfig" >> ~/.bashrc cd .. @@ -36,13 +36,14 @@ of the ODP build directory before running any of these commands): 1. Clone the MACSAD project: + apt install -y git git clone --recursive https://github.com/intrig-unicamp/macsad.git - cd mac + cd macsad 2. MACSAD has added `P4-hlir` as a submodule. Download/update and then install it (along with its dependencies): - sudo apt-get install -y python-yaml graphviz python-setuptools + apt-get install -y python-yaml graphviz python-setuptools cd p4-hlir python setup.py install --user @@ -55,15 +56,15 @@ it (along with its dependencies): 4. Install build dependencies, project dependencies and compile MACSAD: - sudo apt-get install -y autoconf libtool build-essential pkg-config autoconf-archive libpcap-dev python-scapy + apt-get install -y autoconf build-essential pkg-config autoconf-archive libpcap-dev python-scapy ./autogen.sh ./configure make 5. Set hugepages number and create interfaces for the test: - sudo sysctl -w vm.nr_hugepages=512 - sudo ./scripts/veth_create.sh + sysctl -w vm.nr_hugepages=512 + ./scripts/veth_create.sh ## Running MACSAD @@ -78,18 +79,25 @@ switch): 2. Run the MACSAD switch: - sudo ./macsad -i veth1,veth2 -c 0 -m 0 --out_mode 0 + ./macsad -i veth1,veth2 -c 0 -m 0 --out_mode 0 -3. Now will use the veth interfaces created in step #5. `veth1` and `veth2` will + NOTE: To allow portability ODP sets a table size limit of 8192, to allow a higher limit: + + sed -i 's/max_queue_size = 8192/max_queue_size = YYY/' /root/odp/config/odp-linux-generic.conf + + Where YYY is the new limit. Then, odp needs to be recompiled. However, this will impact the memory usage and it has a limit of up to 1048576. + +3. Now open a new terminal and we will use the veth interfaces created in step #5. `veth1` and `veth2` will be part of the switch. We will send packet to `veth0` (which is `veth1`'s pair) and monitor at `veth3` (which is `veth2`'s pair) for packets. Similary we will send packet to `veth3` and expect packets to arrive at `veth0`: - sudo python run_test.py + cd /root/macsad + python run_test.py You should see output similar to this: - $ sudo python run_test.py + $ python run_test.py WARNING: No route found for IPv6 destination :: (no default route?) Sending 1 packets to veth3 ... DISTRIBUTION: @@ -110,9 +118,9 @@ veth3 - a2:5e:37:ac:a1:7f veth0 - fa:4f:e8:df:b1:5f - scapy - pkt2 = Ether(dst='a2:5e:37:ac:a1:7f',src='fa:4f:e8:df:b1:5f')/IP(dst='192.168.0.2',src='192.168.0.1') - sendp(pkt2,iface="veth0",count=1); + $ scapy + >>> pkt2 = Ether(dst='a2:5e:37:ac:a1:7f',src='fa:4f:e8:df:b1:5f')/IP(dst='192.168.0.2',src='192.168.0.1') + >>> sendp(pkt2,iface="veth0",count=1); The first packet with an unknown destination mac address will be broadcasted by the switch while the source mac address is learned. Now after the two packets were sent, the switch has already learned the mac addresses of veth0 and veth3. Now if we send those packets again, switch will forward those packets via corresponding ports instead of broadcasting them. diff --git a/old_mk/README.md b/old_mk/README.md index 36de4c6..d66c9d3 100644 --- a/old_mk/README.md +++ b/old_mk/README.md @@ -13,8 +13,8 @@ Note: In this tutorial we are going to install the MACSAD at `/root` folder. To install MACSAD and it dependencies you can run our script (and skip to Part 3): -- `cd /root/` -- `./mac/install.sh` + cd /root/ + ./mac/install.sh Or you can follow the next steps. We strongly suggest to run our `install_pkgs.sh`. @@ -26,21 +26,21 @@ Or you can follow the next steps. We strongly suggest to run our `install_pkgs.s MACSAD uses ODP for forwarding plane developement. Fist of all, we need to create a directory in the same folder where the MACSAD will be cloned: -- `mkdir tools` -- `mkdir tools/odp` + mkdir tools + mkdir tools/odp 1. Download ODP v1.16.0 and compile it: -- `sudo apt-get install -y build-essential autoconf automake pkg-config libssl-dev libtool` -- `git clone -b v1.16.0.0 https://github.com/Linaro/odp` -- `cd odp` -- `./bootstrap` -- `./configure --disable-abi-compat --prefix=/root/tools/odp` -- `make` -- `make install` -- `ln -s /root/odp/helper /root/tools/odp` -- `export ODP_SDK=/root/tools/odp` -- `cd ..` + apt-get install -y build-essential autoconf automake pkg-config libssl-dev libtool git + git clone -b v1.16.0.0 https://github.com/Linaro/odp + cd odp + ./bootstrap + ./configure --disable-abi-compat --prefix=/root/tools/odp + make + make install + ln -s /root/odp/helper /root/tools/odp + export ODP_SDK=/root/tools/odp + cd .. # Part 2 --- @@ -49,30 +49,31 @@ MACSAD uses ODP for forwarding plane developement. Fist of all, we need to creat 1. To run MACSAD we need P4-hlir submodule. Thus, At this step, we will clone MACSAD project and update/install the submodule. -- `sudo apt-get install -y libpcap-dev python-scapy python-yaml graphviz python-setuptools` -- `git clone --recursive https://github.com/intrig-unicamp/mac.git` -- `cd mac` -- `cd p4-hlir` -- `python setup.py install` -- `cd ..` + apt-get install -y libpcap-dev python-scapy python-yaml graphviz python-setuptools + git clone --recursive https://github.com/intrig-unicamp/macsad.git + cd macsad + cd p4-hlir + python setup.py install + cd .. For any issues with p4-hlir, please refer to its `README.md` file. 2. The p4 program needs to be translated for the MACSAD switch project. You can do this as below: -- `python src/transpiler.py examples/p4_src/l2_fwd.p4` + python src/transpiler.py examples/p4_src/l2_fwd.p4 NOTE: This needs to be done everytime the P4 source file is modified or if any of the sugered file inside `src/hardware_indep` is changed. 3. Set environment variables and compile MACSAD: -- `export LD_LIBRARY_PATH=$ODK_SDK:$LD_LIBRARY_PATH` -- `make` + export LD_LIBRARY_PATH=$ODK_SDK:$LD_LIBRARY_PATH + cd old_mk/ + make 4. Set hugepages number and create interfaces for the test: -- `sudo sysctl -w vm.nr_hugepages=512` -- `./scripts/veth_create.sh` + sysctl -w vm.nr_hugepages=512 + ./../scripts/veth_create.sh # Part 3 --- @@ -95,9 +96,7 @@ We need four terminals to perform this test. Build and start the minimalistic controller (required for installing flows in the switch): -- `cd src/hardware_dep/shared/ctrl_plane` -- `make mac_controller` -- `./mac_controller` + ./mac_controller The controller will run in the foreground, so feel free to open another screen or terminal session. @@ -105,24 +104,25 @@ The controller will run in the foreground, so feel free to open another screen o Start the MACSAD switch with veth interfaces 1 and 2 -- `sudo ./macsad -i veth1,veth2 -c 0 -m 0 --out_mode 0` + cd /root/macsad/old_mk + ./macsad -i veth1,veth2 -c 0 -m 0 --out_mode 0 ### TERMINAL 3: Now will use the veth interfaces created in step #5. `veth1` and `veth2` will be part of the switch. We will send packet to `veth0` (which is `veth1`'s pair) and monitor at `veth3` (which is `veth2`'s pair) for packets. Similary we will send packet to `veth3` and expect packets to arrive at `veth0`: -- `sudo python run_test.py` + cd /root/macsad + python run_test.py You should see output similar to this: -- `$ sudo python run_test.py` -- `WARNING: No route found for IPv6 destination :: (no default route?)` -- `Sending 1 packets to veth3 ...` -- `DISTRIBUTION:` -- `port veth0: 1 [ 100.0% ]` -- `port veth3: 1 [ 100.0% ]` -- `sendp(pkt1,iface="veth3",count=1);` + $ python run_test.py + WARNING: No route found for IPv6 destination :: (no default route?) + Sending 1 packets to veth3 ... + DISTRIBUTION: + port veth0: 1 [ 100.0% ] + port veth3: 1 [ 100.0% ] You should be able to catch the packet at veth1 using tcpdump/tshark in terminal 4. You can also verify the RX count using ifconfig. @@ -130,8 +130,9 @@ NOTE: The packet processing logs can be seen at TERMINAL 2 as debug output of th Now send a packet from veth0 to veth3 and verify similarly at terminal 4. -- `pkt2 = Ether(dst='a2:5e:37:ac:a1:7f',src='fa:4f:e8:df:b1:5f')/IP(dst='192.168.0.2',src='192.168.0.1')` -- `sendp(pkt2,iface="veth0",count=1);` + $ scapy + >>> pkt2 = Ether(dst='a2:5e:37:ac:a1:7f',src='fa:4f:e8:df:b1:5f')/IP(dst='192.168.0.2',src='192.168.0.1') + >>> sendp(pkt2,iface="veth0",count=1); The first packet with an unknown destination mac address will be broadcasted by the switch while the source mac address is learned. Now after the two packets were sent, the switch has already learned the mac addresses of veth0 and veth3. Now if we send those packets again, switch will forward those packets via corresponding ports instead of broadcasting them. @@ -139,8 +140,8 @@ Notes: - Update pip, setup tools to latest version - "pip install -U pip setuptools" + "pip install -U pip setuptools" - Pip error:= "locale.Error: unsupported locale setting" - solution := "export LC_ALL=C" + solution := "export LC_ALL=C" diff --git a/src/hardware_dep/odp/includes/odp_tables.h b/src/hardware_dep/odp/includes/odp_tables.h index 20ed677..0f636e3 100644 --- a/src/hardware_dep/odp/includes/odp_tables.h +++ b/src/hardware_dep/odp/includes/odp_tables.h @@ -39,7 +39,7 @@ typedef struct extended_table_s { #define TABLE_MAX 256 -#define TABLE_SIZE 10000 //Number of elements table may store +#define TABLE_SIZE 8192 //Number of elements table may store //define different key and value size for different tables. #define TABLE_KEY_SIZE 4 //key_size fixed size of the 'key' in bytes. #define TABLE_VALUE_SIZE 4 //value_size fixed size of the 'value' in bytes.