1a6ba15e2SFilip Tehlarsource config.sh
2a6ba15e2SFilip Tehlarsource odl_utils.sh
3a6ba15e2SFilip Tehlarsource topologies/2_node_topo.sh
4a6ba15e2SFilip Tehlar
5a6ba15e2SFilip TehlarODL_CONFIG_FILE1="vpp1.json"
6a6ba15e2SFilip TehlarODL_CONFIG_FILE2="vpp2.json"
7a6ba15e2SFilip Tehlar
8a6ba15e2SFilip Tehlarif [ "$1" == "clean" ] ; then
9a6ba15e2SFilip Tehlar  2_node_topo_clean
10a6ba15e2SFilip Tehlar  exit 0
11a6ba15e2SFilip Tehlarfi
12a6ba15e2SFilip Tehlar
13a6ba15e2SFilip Tehlarif [[ $(id -u) != 0 ]]; then
14a6ba15e2SFilip Tehlar  echo "Error: run this as root."
15a6ba15e2SFilip Tehlar  exit 1
16a6ba15e2SFilip Tehlarfi
17a6ba15e2SFilip Tehlar
18a6ba15e2SFilip Tehlarfunction test_nsh
19a6ba15e2SFilip Tehlar{
20a6ba15e2SFilip Tehlar  2_node_topo_setup
21a6ba15e2SFilip Tehlar  rc=1
22a6ba15e2SFilip Tehlar
23a6ba15e2SFilip Tehlar  maybe_pause
24a6ba15e2SFilip Tehlar
25a6ba15e2SFilip Tehlar  cat << EOF > scripts/lisp_nsh
26a6ba15e2SFilip Tehlarcreate packet-generator interface pg0
27a6ba15e2SFilip Tehlar
28a6ba15e2SFilip Tehlarpacket-generator new {
29a6ba15e2SFilip Tehlar  name nsh1
30a6ba15e2SFilip Tehlar  limit 1
31a6ba15e2SFilip Tehlar  node lisp-cp-lookup-nsh
32a6ba15e2SFilip Tehlar  size 64-64
33a6ba15e2SFilip Tehlar  no-recycle
34a6ba15e2SFilip Tehlar  worker 0
35a6ba15e2SFilip Tehlar  interface pg0
36a6ba15e2SFilip Tehlar  pcap ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap
37a6ba15e2SFilip Tehlar}
38a6ba15e2SFilip TehlarEOF
39a6ba15e2SFilip Tehlar
40a6ba15e2SFilip Tehlar  echo "trace add af-packet-input 100" | nc 0 5002
41a6ba15e2SFilip Tehlar  echo "trace add af-packet-input 100" | nc 0 5003
42a6ba15e2SFilip Tehlar  echo "exec ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/lisp_nsh" | nc 0 5002
43a6ba15e2SFilip Tehlar
44a6ba15e2SFilip Tehlar  # add dummy node to ETR
45a6ba15e2SFilip Tehlar  echo "test one nsh add-dummy-decap-node" | nc 0 5003
46a6ba15e2SFilip Tehlar
477000eb00SFilip Tehlar  echo "packet-generator enable-stream nsh1" | nc 0 5002
487000eb00SFilip Tehlar
497000eb00SFilip Tehlar  echo "enabling stream"
507000eb00SFilip Tehlar  sleep 1
51a6ba15e2SFilip Tehlar  # inject NSH packet to ITR
52a6ba15e2SFilip Tehlar  echo "test one nsh pcap ${ONE_ROOT}/tests/data_plane/vpp_lite_topo/scripts/nsh.pcap" | nc 0 5002
53a6ba15e2SFilip Tehlar
547000eb00SFilip Tehlar  sleep 1
55a6ba15e2SFilip Tehlar  # check decap stats
56a6ba15e2SFilip Tehlar  decap_stats="`echo "show errors" | nc 0 5003 | grep "lisp gpe dummy nsh decap" | awk '{print $1}'`"
57a6ba15e2SFilip Tehlar
58a6ba15e2SFilip Tehlar  if [ "$decap_stats" == "1" ] ; then
59a6ba15e2SFilip Tehlar    rc=0  # test pass
60a6ba15e2SFilip Tehlar  fi
61a6ba15e2SFilip Tehlar
62a6ba15e2SFilip Tehlar  maybe_pause
63a6ba15e2SFilip Tehlar  2_node_topo_clean
64a6ba15e2SFilip Tehlar  print_status $rc "NSH test failed!"
657000eb00SFilip Tehlar  exit $rc
66a6ba15e2SFilip Tehlar}
67