lisp_test.sh revision d746f963
1#!/usr/bin/env bash
2#
3#
4#         +------+                   +-----+
5#         |      | VPP1_INT  TG_INT1 |     |
6#         | VPP1 +-------------------+ TG  |
7#         |      |                   |     |
8#         |      |                   |     |
9#         +--+---+                   +--+--+
10#            | VPP1_INT                 | TG_INT2
11#   ODL_INT  |                          |
12# ODL -------|                          |
13#            | VPP2_INT                 |
14#         +--+---+                      |
15#         |      | VPP2_INT             |
16#         | VPP2 +----------------------+
17#         |      |
18#         |      |
19#         +------+
20
21if [ "$1" == "-h" ] || [ "$1" == "-help" ] ; then
22  echo "lisp_test.sh [ip4] [ip6] [ip4_ip6] [4o6] [6o4] [remote] [remote6]"
23  echo "        ip4 - test ip4 topology"
24  echo "        ip6 - test ip6 topology"
25  echo "        ip4_ip6 - test ip4 and ip6 topology"
26  echo "        4o6 - test ip4 over ip6"
27  echo "        6o4 - test ip6 over ip4"
28  echo "        remote - test statick mapping, whit out ODL"
29  echo "        remote6 - test statick mapping for IPv6, whit out ODL"
30  exit 0
31fi
32
33set -x
34
35USER="csit"
36ODL_USER="admin"
37ODL_PASSWD="admin"
38VPP1_IP="192.168.255.101"
39VPP2_IP="192.168.255.102"
40TG_IP="192.168.255.100"
41ODL_IP="192.168.255.10"
42ODL_PORT="8181"
43TMP_DIR="/tmp/vpp_${RANDOM}_lisp_test"
44TG_INT1="eth2"
45TG_INT2="eth3"
46ODL_M_USER="user"
47ODL_INT="eth2"
48VPP_CONFIG_DIR="../configs/vpp_csit_config/"
49VPP_CONFIG1="vpp1.conf"
50VPP_CONFIG1_6="vpp1_6.conf"
51VPP_CONFIG2="vpp2.conf"
52VPP_CONFIG2_6="vpp2_6.conf"
53VPP_RECONF2="vpp2_reconf.conf"
54VPP_RECONF2_6="vpp2_reconf_6.conf"
55ODL_CONFIG_DIR="../configs/odl/"
56ODL_ADD_CONFIG1="add_ipv4_odl1.txt"
57ODL_ADD_CONFIG1_6="add_ipv6_odl1.txt"
58ODL_ADD_CONFIG2="add_ipv4_odl2.txt"
59ODL_ADD_CONFIG2_6="add_ipv6_odl2.txt"
60ODL_REPLACE_CONFIG2="replace_ipv4_odl2.txt"
61ODL_REPLACE_CONFIG2_6="replace_ipv6_odl2.txt"
62
63if [ "$1" == "remote" ] ; then
64  VPP_CONFIG1="vpp1_remote.conf"
65  VPP_CONFIG2="vpp2_remote.conf"
66  VPP_RECONF1="vpp1_reconf_remote.conf"
67  VPP_RECONF2="vpp2_reconf.conf"
68fi
69
70if [ "$1" == "remote6" ] ; then
71  VPP_CONFIG1="vpp1_6_remote.conf"
72  VPP_CONFIG2="vpp2_6_remote.conf"
73  VPP_RECONF1="vpp1_6_reconf_remote.conf"
74  VPP_RECONF2="vpp2_reconf_6.conf"
75fi
76
77if [ "$1" == "4o6" ] ; then
78  VPP_CONFIG1="vpp1_4o6.conf"
79  VPP_CONFIG2="vpp2_4o6.conf"
80  VPP_RECONF2="vpp2_reconf_4o6.conf"
81  ODL_ADD_CONFIG1="add_ipv4o6_odl1.txt"
82  ODL_ADD_CONFIG2="add_ipv4o6_odl2.txt"
83  ODL_REPLACE_CONFIG2="replace_ipv4o6_odl2.txt"
84fi
85
86if [ "$1" == "6o4" ] ; then
87  VPP_CONFIG1="vpp1_6o4.conf"
88  VPP_CONFIG2="vpp2_6o4.conf"
89  VPP_RECONF2="vpp2_reconf_6o4.conf"
90  ODL_ADD_CONFIG1="add_ipv6o4_odl1.txt"
91  ODL_ADD_CONFIG2="add_ipv6o4_odl2.txt"
92  ODL_REPLACE_CONFIG2="replace_ipv6o4_odl2.txt"
93fi
94
95function ssh_vpp1 {
96    ssh ${USER}@${VPP1_IP} ${@} || exit
97}
98
99function ssh_vpp2 {
100    ssh ${USER}@${VPP2_IP} ${@} || exit
101}
102
103function ssh_tg {
104    ssh ${USER}@${TG_IP} ${@} || exit
105}
106
107function ssh_odl {
108    ssh ${ODL_M_USER}@${ODL_IP} ${@} || exit
109}
110
111function post_curl {
112  curl -X POST http://${ODL_IP}:${ODL_PORT}/restconf/operations/odl-mappingservice:${1} \
113     -H "Content-Type: application/json" --data-binary "@${ODL_CONFIG_DIR}${2}" \
114     -u ${ODL_USER}:${ODL_PASSWD}
115}
116
117if [ "$1" != "remote" ] && [ "$1" != "remote6" ]  ; then
118  curl -X DELETE http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database/ \
119       -u ${ODL_USER}:${ODL_PASSWD}
120fi
121
122ssh_tg "sudo ip netns del net2 &> /dev/null || exit 0"
123ssh_tg "sudo ip addr flush dev ${TG_INT1} &> /dev/null || exit 0"
124ssh_tg "sudo ip route del 6.0.2.0/24 via 6.0.1.1 || exit 0"
125ssh_tg "sudo ip route del 6:0:2::0/64 via 6:0:1::1 || exit 0"
126
127ssh_odl "sudo ip addr flush dev ${ODL_INT} &> /dev/null || exit 0"
128ssh_odl "sudo ip addr add 6.0.3.100/24 dev ${ODL_INT}"
129ssh_odl "sudo ip addr add 6:0:3::100/64 dev ${ODL_INT}"
130
131ssh_odl "sudo ethtool --offload  ${ODL_INT}  rx off tx off"
132
133ssh_vpp1 "sudo stop vpp;  exit 0"
134ssh_vpp2 "sudo stop vpp;  exit 0"
135
136ssh_vpp1 "sudo start vpp;  exit 0"
137ssh_vpp2 "sudo start vpp;  exit 0"
138
139ssh_vpp1 "mkdir ${TMP_DIR}"
140ssh_vpp2 "mkdir ${TMP_DIR}"
141
142ssh_tg "sudo ip netns add net2"
143ssh_tg "sudo ip link set dev ${TG_INT2} netns net2"
144
145if [ "$#" == 0 ] || [ "$1" == "ip4" ] ; then
146  source lisp_ip4.sh
147fi
148
149if [ "$1" == "ip6" ] ; then
150  source lisp_ip6.sh
151fi
152
153if [ "$1" == "4o6" ] ; then
154  source lisp_ip4o6.sh
155fi
156
157if [ "$1" == "6o4" ] ; then
158  source lisp_ip6o4.sh
159fi
160
161if [ "$1" == "ip4_ip6" ] ; then
162  source lisp_ip4.sh
163  source lisp_ip6.sh
164
165  ping_lisp
166  ping_lisp6
167fi
168
169if [ "$1" == "remote" ] ; then
170  source lisp_remote.sh
171fi
172
173if [ "$1" == "remote6" ] ; then
174  source lisp_6_remote.sh
175fi
176
177#clean tmp file
178ssh_vpp1 "sudo rm -r ${TMP_DIR}"
179ssh_vpp2 "sudo rm -r ${TMP_DIR}"
180
181echo "Success"