47f9b68b98ce379fcb32475d7bd7bfe6064cd138
[one.git] / tests / data_plane / vpp_lite_topo / test_driver / nsh.sh
1 source config.sh
2 source odl_utils.sh
3 source topologies/2_node_topo.sh
4
5 ODL_CONFIG_FILE1="vpp1.json"
6 ODL_CONFIG_FILE2="vpp2.json"
7
8 if [ "$1" == "clean" ] ; then
9   2_node_topo_clean
10   exit 0
11 fi
12
13 if [[ $(id -u) != 0 ]]; then
14   echo "Error: run this as root."
15   exit 1
16 fi
17
18 function send_nsh_packet_from_namespace
19 {
20   ns=$1
21   dst=$2
22   spi=$3
23   si=$4
24   itr_mac=$5
25   src_mac=$6
26
27   ip netns exec $ns python scripts/send_nsh_packet.py $dst $itr_mac $spi $si $src_mac
28 }
29
30 function test_nsh
31 {
32   dst=$1
33   spi=$2
34   si=$3
35
36   2_node_topo_setup
37   rc=1
38
39   src_mac=`ip netns exec vppns1 ip a show dev veth_vpp1  | grep "link/ether" | awk '{print $2}'`
40   itr_mac=`echo "sh hard host-vpp1" | nc 0 5002 | grep 'Ethernet address' | awk '{print $3}'`
41
42   maybe_pause
43
44   cat << EOF > scripts/lisp_nsh
45 create packet-generator interface pg0
46
47 packet-generator new {
48   name nsh1
49   limit 1
50   node lisp-cp-lookup-nsh
51   size 64-64
52   no-recycle
53   worker 0
54   interface pg0
55   pcap ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap
56 }
57
58 EOF
59
60   echo "trace add af-packet-input 100" | nc 0 5002
61   echo "trace add af-packet-input 100" | nc 0 5003
62   echo "exec ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/lisp_nsh" | nc 0 5002
63   echo "packet-generator enable-stream nsh1" | nc 0 5002
64
65   # add dummy node to ETR
66   echo "test one nsh add-dummy-decap-node" | nc 0 5003
67
68   # inject NSH packet to ITR
69   echo "test one nsh pcap ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap" | nc 0 5002
70
71   # check decap stats
72   decap_stats="`echo "show errors" | nc 0 5003 | grep "lisp gpe dummy nsh decap" | awk '{print $1}'`"
73
74   if [ "$decap_stats" == "1" ] ; then
75     rc=0  # test pass
76   fi
77
78   maybe_pause
79   2_node_topo_clean
80   print_status $rc "NSH test failed!"
81   exit $test_result
82 }