Skip to content

Commit

Permalink
[New NF] L3switch(l3fwd)
Browse files Browse the repository at this point in the history
A l3 forwarding NF based on DPDK's example. There are two modes - longest prefix match table and hash table lookup.
There are a few differences between this version and DPDK's. Use of openNetVM's flow API was broadly used. This allows data to be stored with each rule or flow when added to the table. This is in contrast to DPDK's version where it uses the key value to get an index. The index value is then used to perform a lookup in an array.

Commit log:

* dpdk: Update ONVM to use DPDK v20.05

* onvm: Update onvm to use updated DPDK APIs

* Update the onvm manager, nflib and examples to use the
updated DPDK APIs.

* Update install.sh to enable the igb_uio module build
  (CONFIG_RTE_EAL_IGB_UIO is disabled by default since v20.02)

* switch strncpy to memcpy

strncpy raises (precautionary) werrors during onvm compilation with ubuntu 20 compiler (gcc 9); gnu/gcc recommends use of memcpy to avoid warning

* Layer 3 switch

* Layer 3 switch

* Added Readme.

* Edit makefile

* Edit makefile

* Add symbolic link

* Free tables upon shutdown

* Update free function

* Edit readme.

* rename handler

* update pktgen-dpdk submodule to v20.03

* pktgen submodule updates

* pktgen submodule to 807b4d

* Table pointers to use global variable.

* modify pktgen config args

lua pktgen.set_mac() now takes three args: port, src|dst, mac addr

* remove pktgen blacklist

blacklists outdated as of pktgen v2.7.0

* UPdate dpdk functions to use latest.

* Rename files

* Remove global variables

Co-authored-by: Vivek Jain <jain.vivek.anand@gmail.com>
Co-authored-by: Sreya Nalla <sreyanalla@gwu.edu>
Co-authored-by: Benjamin De Vierno <bdevierno97@gwu.edu>
Co-authored-by: sreyan <sreyan@localhost>
Co-authored-by: Dennis Afanasev <dennis.afa@gmail.com>
  • Loading branch information
6 people authored Oct 25, 2021
1 parent d6483ed commit e101afa
Show file tree
Hide file tree
Showing 8 changed files with 828 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ $(error "Please define RTE_SDK environment variable")
endif

# To add new examples, append the directory name to this variable
examples = bridge basic_monitor simple_forward speed_tester flow_table test_flow_dir aes_encrypt aes_decrypt flow_tracker load_balancer arp_response nf_router scaling_example load_generator payload_scan firewall simple_fwd_tb l2fwd test_messaging
examples = bridge basic_monitor simple_forward speed_tester flow_table test_flow_dir aes_encrypt aes_decrypt flow_tracker load_balancer arp_response nf_router scaling_example load_generator payload_scan firewall simple_fwd_tb l2fwd test_messaging l3fwd

ifeq ($(NDPI_HOME),)
$(warning "Skipping ndpi_stats NF as NDPI_HOME is not set")
Expand Down
62 changes: 62 additions & 0 deletions examples/l3fwd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# openNetVM
# https://github.com/sdnfv/openNetVM
#
# BSD LICENSE
#
# Copyright(c)
# 2015-2020 George Washington University
# 2015-2020 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.

ifeq ($(RTE_SDK),)
$(error "Please define RTE_SDK environment variable")
endif

RTE_TARGET ?= $(RTE_TARGET)

# Default target, can be overriden by command line or environment
include $(RTE_SDK)/mk/rte.vars.mk

# binary name
APP = l3fwd

# all source are stored in SRCS-y
SRCS-y := l3fwd.c l3fwd_lpm.c l3fwd_em.c

# OpenNetVM path
ONVM= $(SRCDIR)/../../onvm

CFLAGS += -O3 $(USER_FLAGS)

CFLAGS += -I$(ONVM)/onvm_nflib
CFLAGS += -I$(ONVM)/lib
LDFLAGS += $(ONVM)/onvm_nflib/$(RTE_TARGET)/libonvm.a
LDFLAGS += $(ONVM)/lib/$(RTE_TARGET)/lib/libonvmhelper.a -lm

include $(RTE_SDK)/mk/rte.extapp.mk
39 changes: 39 additions & 0 deletions examples/l3fwd/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Layer 3 Switch
==
l3switch is based on DPDK's [l3fwd example](https://doc.dpdk.org/guides/sample_app_ug/l3_forward.html) that leverages the openNetVM's flow director API. This NF has two modes, exact match and longest prefix match. In longest prefix match mode, a lookup matches a packet to a destination port. The lookup is based on the destination IP address. In exact match mode, a lookup is is based on the packet 5-tuple i.e. destination and src of the packets port and IP.

Hash entry number refers to the number of flow rules when running in exact match mode.

Compilation and Execution
--
```
cd examples
make
cd l3switch
./go.sh SERVICE_ID [PRINT_DELAY]
OR
./go.sh -F CONFIG_FILE -- -- [-p PRINT_DELAY]
OR
sudo ./build/l3switch -l CORELIST -n 3 --proc-type=secondary -- -r SERVICE_ID -- [-p PRINT_DELAY]
```

App Specific Arguments
--
-p <print_delay>: number of packets between each print, e.g. `-p 1` prints every packets. Default is every 1000000 packets.
-e : Enables exact match mode.
-h <hash entry number> : Sets the hash entry number.

For example: ./go.sh 1 -e -h 7

Will enable exact match mode with hash entry number set to 7. Hash entry number will default to 4 if not manually set or not running in exact match mode.

Config File Support
--
This NF supports the NF generating arguments from a config file. For
additional reading, see [Examples.md](../../docs/Examples.md)

See `../example_config.json` for all possible options that can be set.
1 change: 1 addition & 0 deletions examples/l3fwd/go.sh
Loading

0 comments on commit e101afa

Please sign in to comment.