1676362e1SAndrej Kozemcak#!/usr/bin/env bash
2676362e1SAndrej Kozemcak#
3676362e1SAndrej Kozemcak#
4676362e1SAndrej Kozemcak#         +------+                   +-----+
5676362e1SAndrej Kozemcak#         |      | VPP1_INT  TG_INT1 |     |
6676362e1SAndrej Kozemcak#         | VPP1 +-------------------+ TG  |
7676362e1SAndrej Kozemcak#         |      |                   |     |
8676362e1SAndrej Kozemcak#         |      |                   |     |
9676362e1SAndrej Kozemcak#         +--+---+                   +--+--+
10676362e1SAndrej Kozemcak#            | VPP1_INT                 | TG_INT2
11676362e1SAndrej Kozemcak#   ODL_INT  |                          |
12676362e1SAndrej Kozemcak# ODL -------|                          |
13676362e1SAndrej Kozemcak#            | VPP2_INT                 |
14676362e1SAndrej Kozemcak#         +--+---+                      |
15676362e1SAndrej Kozemcak#         |      | VPP2_INT             |
16676362e1SAndrej Kozemcak#         | VPP2 +----------------------+
17676362e1SAndrej Kozemcak#         |      |
18676362e1SAndrej Kozemcak#         |      |
19676362e1SAndrej Kozemcak#         +------+
20676362e1SAndrej Kozemcak
2146e4b31aSAndrej Kozemcakif [ "$1" == "-h" ] || [ "$1" == "-help" ] ; then
22d746f963SAndrej Kozemcak  echo "lisp_test.sh [ip4] [ip6] [ip4_ip6] [4o6] [6o4] [remote] [remote6]"
2346e4b31aSAndrej Kozemcak  echo "        ip4 - test ip4 topology"
2446e4b31aSAndrej Kozemcak  echo "        ip6 - test ip6 topology"
2546e4b31aSAndrej Kozemcak  echo "        ip4_ip6 - test ip4 and ip6 topology"
2646e4b31aSAndrej Kozemcak  echo "        4o6 - test ip4 over ip6"
2746e4b31aSAndrej Kozemcak  echo "        6o4 - test ip6 over ip4"
28d746f963SAndrej Kozemcak  echo "        remote - test statick mapping, whit out ODL"
29d746f963SAndrej Kozemcak  echo "        remote6 - test statick mapping for IPv6, whit out ODL"
3046e4b31aSAndrej Kozemcak  exit 0
3146e4b31aSAndrej Kozemcakfi
3246e4b31aSAndrej Kozemcak
33676362e1SAndrej Kozemcakset -x
34676362e1SAndrej Kozemcak
35676362e1SAndrej KozemcakUSER="csit"
36676362e1SAndrej KozemcakODL_USER="admin"
37676362e1SAndrej KozemcakODL_PASSWD="admin"
38676362e1SAndrej KozemcakVPP1_IP="192.168.255.101"
39676362e1SAndrej KozemcakVPP2_IP="192.168.255.102"
40676362e1SAndrej KozemcakTG_IP="192.168.255.100"
41676362e1SAndrej KozemcakODL_IP="192.168.255.10"
42676362e1SAndrej KozemcakODL_PORT="8181"
43676362e1SAndrej KozemcakTMP_DIR="/tmp/vpp_${RANDOM}_lisp_test"
44676362e1SAndrej KozemcakTG_INT1="eth2"
45676362e1SAndrej KozemcakTG_INT2="eth3"
46676362e1SAndrej KozemcakODL_M_USER="user"
47676362e1SAndrej KozemcakODL_INT="eth2"
48676362e1SAndrej KozemcakVPP_CONFIG_DIR="../configs/vpp_csit_config/"
49676362e1SAndrej KozemcakVPP_CONFIG1="vpp1.conf"
50676362e1SAndrej KozemcakVPP_CONFIG1_6="vpp1_6.conf"
51676362e1SAndrej KozemcakVPP_CONFIG2="vpp2.conf"
52676362e1SAndrej KozemcakVPP_CONFIG2_6="vpp2_6.conf"
53676362e1SAndrej KozemcakVPP_RECONF2="vpp2_reconf.conf"
54676362e1SAndrej KozemcakVPP_RECONF2_6="vpp2_reconf_6.conf"
55676362e1SAndrej KozemcakODL_CONFIG_DIR="../configs/odl/"
56676362e1SAndrej KozemcakODL_ADD_CONFIG1="add_ipv4_odl1.txt"
57676362e1SAndrej KozemcakODL_ADD_CONFIG1_6="add_ipv6_odl1.txt"
58676362e1SAndrej KozemcakODL_ADD_CONFIG2="add_ipv4_odl2.txt"
59676362e1SAndrej KozemcakODL_ADD_CONFIG2_6="add_ipv6_odl2.txt"
60676362e1SAndrej KozemcakODL_REPLACE_CONFIG2="replace_ipv4_odl2.txt"
61676362e1SAndrej KozemcakODL_REPLACE_CONFIG2_6="replace_ipv6_odl2.txt"
62d746f963SAndrej Kozemcak
63d746f963SAndrej Kozemcakif [ "$1" == "remote" ] ; then
64d746f963SAndrej Kozemcak  VPP_CONFIG1="vpp1_remote.conf"
65d746f963SAndrej Kozemcak  VPP_CONFIG2="vpp2_remote.conf"
66d746f963SAndrej Kozemcak  VPP_RECONF1="vpp1_reconf_remote.conf"
67d746f963SAndrej Kozemcak  VPP_RECONF2="vpp2_reconf.conf"
68d746f963SAndrej Kozemcakfi
69d746f963SAndrej Kozemcak
70d746f963SAndrej Kozemcakif [ "$1" == "remote6" ] ; then
71d746f963SAndrej Kozemcak  VPP_CONFIG1="vpp1_6_remote.conf"
72d746f963SAndrej Kozemcak  VPP_CONFIG2="vpp2_6_remote.conf"
73d746f963SAndrej Kozemcak  VPP_RECONF1="vpp1_6_reconf_remote.conf"
74d746f963SAndrej Kozemcak  VPP_RECONF2="vpp2_reconf_6.conf"
75d746f963SAndrej Kozemcakfi
76d746f963SAndrej Kozemcak
77d746f963SAndrej Kozemcakif [ "$1" == "4o6" ] ; then
78d746f963SAndrej Kozemcak  VPP_CONFIG1="vpp1_4o6.conf"
79d746f963SAndrej Kozemcak  VPP_CONFIG2="vpp2_4o6.conf"
80d746f963SAndrej Kozemcak  VPP_RECONF2="vpp2_reconf_4o6.conf"
81d746f963SAndrej Kozemcak  ODL_ADD_CONFIG1="add_ipv4o6_odl1.txt"
82d746f963SAndrej Kozemcak  ODL_ADD_CONFIG2="add_ipv4o6_odl2.txt"
83d746f963SAndrej Kozemcak  ODL_REPLACE_CONFIG2="replace_ipv4o6_odl2.txt"
84d746f963SAndrej Kozemcakfi
85d746f963SAndrej Kozemcak
86d746f963SAndrej Kozemcakif [ "$1" == "6o4" ] ; then
87d746f963SAndrej Kozemcak  VPP_CONFIG1="vpp1_6o4.conf"
88d746f963SAndrej Kozemcak  VPP_CONFIG2="vpp2_6o4.conf"
89d746f963SAndrej Kozemcak  VPP_RECONF2="vpp2_reconf_6o4.conf"
90d746f963SAndrej Kozemcak  ODL_ADD_CONFIG1="add_ipv6o4_odl1.txt"
91d746f963SAndrej Kozemcak  ODL_ADD_CONFIG2="add_ipv6o4_odl2.txt"
92d746f963SAndrej Kozemcak  ODL_REPLACE_CONFIG2="replace_ipv6o4_odl2.txt"
93d746f963SAndrej Kozemcakfi
94676362e1SAndrej Kozemcak
95676362e1SAndrej Kozemcakfunction ssh_vpp1 {
96676362e1SAndrej Kozemcak    ssh ${USER}@${VPP1_IP} ${@} || exit
97676362e1SAndrej Kozemcak}
98676362e1SAndrej Kozemcak
99676362e1SAndrej Kozemcakfunction ssh_vpp2 {
100676362e1SAndrej Kozemcak    ssh ${USER}@${VPP2_IP} ${@} || exit
101676362e1SAndrej Kozemcak}
102676362e1SAndrej Kozemcak
103676362e1SAndrej Kozemcakfunction ssh_tg {
104676362e1SAndrej Kozemcak    ssh ${USER}@${TG_IP} ${@} || exit
105676362e1SAndrej Kozemcak}
106676362e1SAndrej Kozemcak
107676362e1SAndrej Kozemcakfunction ssh_odl {
108676362e1SAndrej Kozemcak    ssh ${ODL_M_USER}@${ODL_IP} ${@} || exit
109676362e1SAndrej Kozemcak}
110676362e1SAndrej Kozemcak
11146e4b31aSAndrej Kozemcakfunction post_curl {
11246e4b31aSAndrej Kozemcak  curl -X POST http://${ODL_IP}:${ODL_PORT}/restconf/operations/odl-mappingservice:${1} \
11346e4b31aSAndrej Kozemcak     -H "Content-Type: application/json" --data-binary "@${ODL_CONFIG_DIR}${2}" \
11446e4b31aSAndrej Kozemcak     -u ${ODL_USER}:${ODL_PASSWD}
11546e4b31aSAndrej Kozemcak}
11646e4b31aSAndrej Kozemcak
117d746f963SAndrej Kozemcakif [ "$1" != "remote" ] && [ "$1" != "remote6" ]  ; then
118d746f963SAndrej Kozemcak  curl -X DELETE http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database/ \
119d746f963SAndrej Kozemcak       -u ${ODL_USER}:${ODL_PASSWD}
120d746f963SAndrej Kozemcakfi
121676362e1SAndrej Kozemcak
122676362e1SAndrej Kozemcakssh_tg "sudo ip netns del net2 &> /dev/null || exit 0"
123676362e1SAndrej Kozemcakssh_tg "sudo ip addr flush dev ${TG_INT1} &> /dev/null || exit 0"
124676362e1SAndrej Kozemcakssh_tg "sudo ip route del 6.0.2.0/24 via 6.0.1.1 || exit 0"
125676362e1SAndrej Kozemcakssh_tg "sudo ip route del 6:0:2::0/64 via 6:0:1::1 || exit 0"
126676362e1SAndrej Kozemcak
127676362e1SAndrej Kozemcakssh_odl "sudo ip addr flush dev ${ODL_INT} &> /dev/null || exit 0"
128676362e1SAndrej Kozemcakssh_odl "sudo ip addr add 6.0.3.100/24 dev ${ODL_INT}"
129676362e1SAndrej Kozemcakssh_odl "sudo ip addr add 6:0:3::100/64 dev ${ODL_INT}"
130676362e1SAndrej Kozemcak
131676362e1SAndrej Kozemcakssh_odl "sudo ethtool --offload  ${ODL_INT}  rx off tx off"
132676362e1SAndrej Kozemcak
133676362e1SAndrej Kozemcakssh_vpp1 "sudo stop vpp;  exit 0"
134676362e1SAndrej Kozemcakssh_vpp2 "sudo stop vpp;  exit 0"
135676362e1SAndrej Kozemcak
136676362e1SAndrej Kozemcakssh_vpp1 "sudo start vpp;  exit 0"
137676362e1SAndrej Kozemcakssh_vpp2 "sudo start vpp;  exit 0"
138676362e1SAndrej Kozemcak
139676362e1SAndrej Kozemcakssh_vpp1 "mkdir ${TMP_DIR}"
140676362e1SAndrej Kozemcakssh_vpp2 "mkdir ${TMP_DIR}"
141676362e1SAndrej Kozemcak
142676362e1SAndrej Kozemcakssh_tg "sudo ip netns add net2"
143676362e1SAndrej Kozemcakssh_tg "sudo ip link set dev ${TG_INT2} netns net2"
144676362e1SAndrej Kozemcak
145676362e1SAndrej Kozemcakif [ "$#" == 0 ] || [ "$1" == "ip4" ] ; then
146676362e1SAndrej Kozemcak  source lisp_ip4.sh
147676362e1SAndrej Kozemcakfi
148676362e1SAndrej Kozemcak
149676362e1SAndrej Kozemcakif [ "$1" == "ip6" ] ; then
150676362e1SAndrej Kozemcak  source lisp_ip6.sh
151676362e1SAndrej Kozemcakfi
152676362e1SAndrej Kozemcak
15346e4b31aSAndrej Kozemcakif [ "$1" == "4o6" ] ; then
15446e4b31aSAndrej Kozemcak  source lisp_ip4o6.sh
15546e4b31aSAndrej Kozemcakfi
15646e4b31aSAndrej Kozemcak
15746e4b31aSAndrej Kozemcakif [ "$1" == "6o4" ] ; then
15846e4b31aSAndrej Kozemcak  source lisp_ip6o4.sh
15946e4b31aSAndrej Kozemcakfi
16046e4b31aSAndrej Kozemcak
16146e4b31aSAndrej Kozemcakif [ "$1" == "ip4_ip6" ] ; then
162676362e1SAndrej Kozemcak  source lisp_ip4.sh
163676362e1SAndrej Kozemcak  source lisp_ip6.sh
164676362e1SAndrej Kozemcak
165676362e1SAndrej Kozemcak  ping_lisp
166676362e1SAndrej Kozemcak  ping_lisp6
167676362e1SAndrej Kozemcakfi
168676362e1SAndrej Kozemcak
169d746f963SAndrej Kozemcakif [ "$1" == "remote" ] ; then
170d746f963SAndrej Kozemcak  source lisp_remote.sh
171d746f963SAndrej Kozemcakfi
172d746f963SAndrej Kozemcak
173d746f963SAndrej Kozemcakif [ "$1" == "remote6" ] ; then
174d746f963SAndrej Kozemcak  source lisp_6_remote.sh
175d746f963SAndrej Kozemcakfi
176d746f963SAndrej Kozemcak
177676362e1SAndrej Kozemcak#clean tmp file
178676362e1SAndrej Kozemcakssh_vpp1 "sudo rm -r ${TMP_DIR}"
179676362e1SAndrej Kozemcakssh_vpp2 "sudo rm -r ${TMP_DIR}"
180676362e1SAndrej Kozemcak
181676362e1SAndrej Kozemcakecho "Success"