Skip to content

Commit

Permalink
Added ARP Response NF (#226)
Browse files Browse the repository at this point in the history
Introduces a new example NF that responds to ARP request packets for the ONVM machine's MAC addresses. This allows other machines to discover the ONVM machine based on IP across the network.

The NF takes a list of IPs as a command line argument and assigns them to the corresponding NIC ports.  The NF also takes a destination NF service ID.  Any packets that don't match an ARP request for the given IP will be forwarded to the destination NF.

This can be used in a service chain with other NFs (such as `examples/load_balancer`) which require IP-based connections.


Commit Log:
* Added ARP Response NF

Using the IP passed in at the start, the NF can reply to ARP request
packets directed at the same IP that the machine is set to.

* Modified argument input to allow for comma-separated IP addresses

* Fixes port id bug

* Added onvm_pkt_parse_ip_string() to convert a string IP to decimal

* Added struct for global NF variables and modified IP string processing

* Updated documentation and copyright information

* Revert "Added onvm_pkt_parse_ip_string() to convert a string IP to decimal"

* Modified IP processing to use function from PR #227

* Fixed IP endian check

* Implemented requested changes

* Fixed style change and arg count of strncopy()

* Removed hard-coded string length
  • Loading branch information
pcodes authored and twood02 committed Nov 16, 2017
1 parent 92b77d0 commit 6d828a9
Show file tree
Hide file tree
Showing 5 changed files with 424 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
examples = bridge basic_monitor simple_forward speed_tester flow_table test_flow_dir aes_encrypt aes_decrypt flow_tracker load_balancer arp_response

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

# all source are stored in SRCS-y
SRCS-y := arp_response.c

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

CFLAGS += $(WERROR_FLAGS) -O3 $(USER_FLAGS)

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

include $(RTE_SDK)/mk/rte.extapp.mk
21 changes: 21 additions & 0 deletions examples/arp_response/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARP Response
==
ARP Response is an NF that responds to ARP Requests. The NF allows the user to set the IP address of each NIC port that needs to send ARP replies. The IPs are passed in as a comma separated list, `<IP for first port>,<IP for second port>,etc`, with each port gettting mapped to the corresponding port.

Compilation and Execution
--
```
make
./go.sh CORELIST SERVICE_ID DESTINATION_ID -s SOURCE_IP_LIST [-p enable
print]
OR
sudo ./build/monitor -l CORELIST -n NUM_MEMORY_CHANNELS --proc-type=secondary -- -r SERVICE_ID -- -d DESTINATION_ID -s SOURCE_IP_LIST [-p ENABLE PRINT]
```

App Specific Arguments
--
- `-d <destination_id>`: the NF will send non-ARP packets to the NF at this service ID, e.g. `-d 2` sends packets to service ID 2
- `-s <source_ip_list>`: the NF will map each comma separated IP (no spaces) to the corresponding port. Example: `-s 10.0.0.31,11.0.0.31` maps port 0 to 10.0.0.31, and port 1 to 11.0.0.31. If 0.0.0.0 is inputted, the IP will be 0. If too few IPs are inputted, the remaining ports will be ignored.
- `-p`: Enables printing of log information
Loading

0 comments on commit 6d828a9

Please sign in to comment.