From a6ba15e2cc56e0f91e0d2d9f0b66b62073aac777 Mon Sep 17 00:00:00 2001 From: Filip Tehlar Date: Thu, 15 Jun 2017 13:36:26 +0200 Subject: Add LISP GPE NSH test Change-Id: I4d8b9c8c0bd560a9ba2a8db7ddfacd89b51b433f Signed-off-by: Filip Tehlar --- .gitignore | 1 + tests/data_plane/configs/odl/nsh/vpp1.json | 32 ++++++++ tests/data_plane/configs/odl/nsh/vpp2.json | 32 ++++++++ .../configs/vpp_lite_config/nsh/vpp1.config | 7 ++ .../configs/vpp_lite_config/nsh/vpp2.config | 7 ++ tests/data_plane/vpp_lite_topo/config.sh | 1 + .../vpp_lite_topo/scripts/cmd_mappings.py | 1 + tests/data_plane/vpp_lite_topo/scripts/nsh.pcap | Bin 0 -> 98 bytes tests/data_plane/vpp_lite_topo/test_driver/nsh.sh | 82 +++++++++++++++++++++ tests/data_plane/vpp_lite_topo/tests/test_nsh.sh | 9 +++ 10 files changed, 172 insertions(+) create mode 100644 tests/data_plane/configs/odl/nsh/vpp1.json create mode 100644 tests/data_plane/configs/odl/nsh/vpp2.json create mode 100644 tests/data_plane/configs/vpp_lite_config/nsh/vpp1.config create mode 100644 tests/data_plane/configs/vpp_lite_config/nsh/vpp2.config create mode 100755 tests/data_plane/vpp_lite_topo/scripts/nsh.pcap create mode 100644 tests/data_plane/vpp_lite_topo/test_driver/nsh.sh create mode 100755 tests/data_plane/vpp_lite_topo/tests/test_nsh.sh diff --git a/.gitignore b/.gitignore index 795ab6b..96a8b8c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ # generated files *.vat *.cli +lisp_nsh diff --git a/tests/data_plane/configs/odl/nsh/vpp1.json b/tests/data_plane/configs/odl/nsh/vpp1.json new file mode 100644 index 0000000..b7725e2 --- /dev/null +++ b/tests/data_plane/configs/odl/nsh/vpp1.json @@ -0,0 +1,32 @@ +{ + "input": { + "mapping-record": { + "recordTtl": 1440, + "action": "NoAction", + "authoritative": true, + "eid": { + "address-type": "ietf-lisp-address-types:service-path-lcaf", + "service-path": { + "service-path-id": 10, + "service-index": 200 + } + }, + "LocatorRecord": [ + { + "locator-id": "ISP1", + "priority": 1, + "weight": 1, + "multicastPriority": 255, + "multicastWeight": 0, + "localLocator": true, + "rlocProbed": false, + "routed": true, + "rloc": { + "address-type": "ietf-lisp-address-types:ipv4-afi", + "ipv4": "6.0.3.2" + } + } + ] + } + } +} diff --git a/tests/data_plane/configs/odl/nsh/vpp2.json b/tests/data_plane/configs/odl/nsh/vpp2.json new file mode 100644 index 0000000..b26ce62 --- /dev/null +++ b/tests/data_plane/configs/odl/nsh/vpp2.json @@ -0,0 +1,32 @@ +{ + "input": { + "mapping-record": { + "recordTtl": 1440, + "action": "NoAction", + "authoritative": true, + "eid": { + "address-type": "ietf-lisp-address-types:service-path-lcaf", + "service-path": { + "service-path-id": 11, + "service-index": 4 + } + }, + "LocatorRecord": [ + { + "locator-id": "ISP1", + "priority": 1, + "weight": 1, + "multicastPriority": 255, + "multicastWeight": 0, + "localLocator": true, + "rlocProbed": false, + "routed": true, + "rloc": { + "address-type": "ietf-lisp-address-types:ipv4-afi", + "ipv4": "6.0.3.2" + } + } + ] + } + } +} diff --git a/tests/data_plane/configs/vpp_lite_config/nsh/vpp1.config b/tests/data_plane/configs/vpp_lite_config/nsh/vpp1.config new file mode 100644 index 0000000..808d632 --- /dev/null +++ b/tests/data_plane/configs/vpp_lite_config/nsh/vpp1.config @@ -0,0 +1,7 @@ +create_host_iface vpp1 6.0.1.1/24 +create_host_iface intervpp1 6.0.3.1/24 + +lisp_state enable +lisp_locator_set_with_locator ls1 host-intervpp1 1 1 +lisp_nsh_set_ls ls ls1 +lisp_map_resolver 6.0.3.100 diff --git a/tests/data_plane/configs/vpp_lite_config/nsh/vpp2.config b/tests/data_plane/configs/vpp_lite_config/nsh/vpp2.config new file mode 100644 index 0000000..c17327a --- /dev/null +++ b/tests/data_plane/configs/vpp_lite_config/nsh/vpp2.config @@ -0,0 +1,7 @@ +create_host_iface vpp2 6.0.2.1/24 +create_host_iface intervpp2 6.0.3.2/24 + +lisp_state enable +lisp_locator_set_with_locator ls1 host-intervpp2 1 1 +lisp_nsh_set_ls ls ls1 +lisp_map_resolver 6.0.3.100 diff --git a/tests/data_plane/vpp_lite_topo/config.sh b/tests/data_plane/vpp_lite_topo/config.sh index c615707..94e54b3 100644 --- a/tests/data_plane/vpp_lite_topo/config.sh +++ b/tests/data_plane/vpp_lite_topo/config.sh @@ -7,6 +7,7 @@ ODL_PORT="8181" VPP_LITE_DIR=/vpp/build-root/install-vpp_debug-native/vpp/bin VPP_LITE_BIN=${VPP_LITE_DIR}/vpp VPP_API_TEST=/vpp/build-root/install-vpp_debug-native/vpp-api-test/bin/vpp_api_test +ONE_ROOT=/vpp/one # read user config file if exists if [ -f "${HOME}/.onerc" ] ; then diff --git a/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py b/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py index 4932617..9bf2c15 100644 --- a/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py +++ b/tests/data_plane/vpp_lite_topo/scripts/cmd_mappings.py @@ -63,6 +63,7 @@ SimpleMapping('lisp_rloc_probe_state', 'one rloc-probe', 'one_rloc_probe_enable_ SimpleMapping('lisp_map_register_state', 'one map-register', 'one_map_register_enable_disable') SimpleMapping('lisp_stats', 'one statistics', 'one_stats_enable_disable') SimpleMapping('lisp_l2_arp', 'one l2 arp', 'one_add_del_l2_arp_entry') +SimpleMapping('lisp_nsh_set_ls', 'one nsh-mapping', 'one_nsh_set_locator_set') SimpleMapping('ipsec_sad_add_del_entry', 'TODO', 'ipsec_sad_add_del_entry') SimpleMapping('ipsec_spd_add_del', 'todo', 'ipsec_spd_add_del') diff --git a/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap b/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap new file mode 100755 index 0000000..7e56613 Binary files /dev/null and b/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap differ diff --git a/tests/data_plane/vpp_lite_topo/test_driver/nsh.sh b/tests/data_plane/vpp_lite_topo/test_driver/nsh.sh new file mode 100644 index 0000000..47f9b68 --- /dev/null +++ b/tests/data_plane/vpp_lite_topo/test_driver/nsh.sh @@ -0,0 +1,82 @@ +source config.sh +source odl_utils.sh +source topologies/2_node_topo.sh + +ODL_CONFIG_FILE1="vpp1.json" +ODL_CONFIG_FILE2="vpp2.json" + +if [ "$1" == "clean" ] ; then + 2_node_topo_clean + exit 0 +fi + +if [[ $(id -u) != 0 ]]; then + echo "Error: run this as root." + exit 1 +fi + +function send_nsh_packet_from_namespace +{ + ns=$1 + dst=$2 + spi=$3 + si=$4 + itr_mac=$5 + src_mac=$6 + + ip netns exec $ns python scripts/send_nsh_packet.py $dst $itr_mac $spi $si $src_mac +} + +function test_nsh +{ + dst=$1 + spi=$2 + si=$3 + + 2_node_topo_setup + rc=1 + + src_mac=`ip netns exec vppns1 ip a show dev veth_vpp1 | grep "link/ether" | awk '{print $2}'` + itr_mac=`echo "sh hard host-vpp1" | nc 0 5002 | grep 'Ethernet address' | awk '{print $3}'` + + maybe_pause + + cat << EOF > scripts/lisp_nsh +create packet-generator interface pg0 + +packet-generator new { + name nsh1 + limit 1 + node lisp-cp-lookup-nsh + size 64-64 + no-recycle + worker 0 + interface pg0 + pcap ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap +} + +EOF + + echo "trace add af-packet-input 100" | nc 0 5002 + echo "trace add af-packet-input 100" | nc 0 5003 + echo "exec ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/lisp_nsh" | nc 0 5002 + echo "packet-generator enable-stream nsh1" | nc 0 5002 + + # add dummy node to ETR + echo "test one nsh add-dummy-decap-node" | nc 0 5003 + + # inject NSH packet to ITR + echo "test one nsh pcap ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap" | nc 0 5002 + + # check decap stats + decap_stats="`echo "show errors" | nc 0 5003 | grep "lisp gpe dummy nsh decap" | awk '{print $1}'`" + + if [ "$decap_stats" == "1" ] ; then + rc=0 # test pass + fi + + maybe_pause + 2_node_topo_clean + print_status $rc "NSH test failed!" + exit $test_result +} diff --git a/tests/data_plane/vpp_lite_topo/tests/test_nsh.sh b/tests/data_plane/vpp_lite_topo/tests/test_nsh.sh new file mode 100755 index 0000000..e770f0b --- /dev/null +++ b/tests/data_plane/vpp_lite_topo/tests/test_nsh.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +VPP_LITE_CONF=`pwd`/../configs/vpp_lite_config/nsh +ODL_CONFIG_DIR=`pwd`/../configs/odl/nsh + +source test_driver/nsh.sh + +# args: dest IP, service path ID, service index +test_nsh "6.0.2.2" 10 200 -- cgit 1.2.3-korg