7f01f5a5cf3c2d4c1ff8d30f5210390560dfeb97
[one.git] / tests / data_plane / vpp_lite_topo / lisp_test.sh
1 #!/usr/bin/env bash
2
3 if [ "$1" == "-h" ] || [ "$1" == "-help" ] ; then
4   echo "lisp_test.sh [ip4] [ip6] [ip4_ip6] [4o6] [6o4] [remote] [remote6]"
5   echo "        ip4 - test ip4 topology"
6   echo "        ip6 - test ip6 topology"
7   echo "        ip4_ip6 - test ip4 and ip6 topology"
8   echo "        4o6 - test ip4 over ip6"
9   echo "        6o4 - test ip6 over ip4"
10   echo "        remote - test statick mapping, whit out ODL"
11   echo "        remote6 - test statick mapping for IPv6, whit out ODL"
12   exit 0
13 fi
14
15 set -x
16
17 # path to vpp executable and configurations folder
18 # VPP_LITE_BIN=/vpp/build-root/install-vpp_lite_debug-native/vpp/bin/vpp
19 VPP_LITE_BIN=/home/csit/lisp_vpp/build-root/install-vpp_lite_debug-native/vpp/bin/vpp
20 VPP_LITE_CONF=`pwd`"/../configs/vpp_lite_config/"
21 VPP1_CONF="vpp1.conf"
22 VPP2_CONF="vpp2.conf"
23 ODL_CONFIG_DIR="../configs/odl/"
24 ODL_ADD_CONFIG1="add_ipv4_odl1.txt"
25 ODL_ADD_CONFIG1_4o6="add_ipv4o6_odl1.txt"
26 ODL_ADD_CONFIG1_6="add_ipv6_odl1.txt"
27 ODL_ADD_CONFIG1_6o4="add_ipv6o4_odl1.txt"
28 ODL_ADD_CONFIG2="add_ipv4_odl2.txt"
29 ODL_ADD_CONFIG2_4o6="add_ipv4o6_odl2.txt"
30 ODL_ADD_CONFIG2_6="add_ipv6_odl2.txt"
31 ODL_ADD_CONFIG2_6o4="add_ipv6o4_odl2.txt"
32 ODL_REPLACE_CONFIG2="replace_ipv4_odl2.txt"
33 ODL_REPLACE_CONFIG2_4o6="replace_ipv4o6_odl2.txt"
34 ODL_REPLACE_CONFIG2_6="replace_ipv6_odl2.txt"
35 ODL_REPLACE_CONFIG2_6o4="replace_ipv6o4_odl2.txt"
36
37 ODL_USER="admin"
38 ODL_PASSWD="admin"
39 ODL_IP="127.0.0.1"
40 ODL_PORT="8181"
41
42 function post_curl {
43   curl -X POST http://${ODL_IP}:${ODL_PORT}/restconf/operations/odl-mappingservice:${1} \
44      -H "Content-Type: application/json" --data-binary "@${ODL_CONFIG_DIR}${2}" \
45      -u ${ODL_USER}:${ODL_PASSWD}
46 }
47
48 # make sure there are no vpp instances running
49 sudo pkill vpp
50
51 # delete previous incarnations if they exist
52 sudo ip netns exec intervppns ifconfig vppbr down
53 sudo ip netns exec intervppns brctl delbr vppbr
54 sudo ip link del dev veth_vpp1 &> /dev/null
55 sudo ip link del dev veth_vpp2 &> /dev/null
56 sudo ip link del dev veth_intervpp1 &> /dev/null
57 sudo ip link del dev veth_intervpp2 &> /dev/null
58 sudo ip link del dev veth_odl &> /dev/null
59 sudo ip netns del vppns1 &> /dev/null
60 sudo ip netns del vppns2 &> /dev/null
61 sudo ip netns del intervppns &> /dev/null
62
63 if [ "$1" != "remote" ] && [ "$1" != "remote6" ]  ; then
64   curl -X DELETE http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database/ \
65        -u ${ODL_USER}:${ODL_PASSWD}
66 fi
67
68 if [ "$1" == "clean" ] ; then
69   exit 0;
70 fi
71
72 # create vpp to clients and inter-vpp namespaces
73 sudo ip netns add vppns1
74 sudo ip netns add vppns2
75 sudo ip netns add intervppns
76
77 # create vpp and odl interfaces and set them in intervppns
78 sudo ip link add veth_intervpp1 type veth peer name intervpp1
79 sudo ip link add veth_intervpp2 type veth peer name intervpp2
80 sudo ip link add veth_odl type veth peer name odl
81 sudo ip link set dev intervpp1 up
82 sudo ip link set dev intervpp2 up
83 sudo ip link set dev odl up
84 sudo ip link set dev veth_intervpp1 up netns intervppns
85 sudo ip link set dev veth_intervpp2 up netns intervppns
86 sudo ip link set dev veth_odl up netns intervppns
87
88 # create bridge in intervppns and add vpp and odl interfaces
89 sudo ip netns exec intervppns brctl addbr vppbr
90 sudo ip netns exec intervppns brctl addif vppbr veth_intervpp1
91 sudo ip netns exec intervppns brctl addif vppbr veth_intervpp2
92 sudo ip netns exec intervppns brctl addif vppbr veth_odl
93 sudo ip netns exec intervppns ifconfig vppbr up
94
95 # create and configure 1st veth client to vpp pair
96 sudo ip link add veth_vpp1 type veth peer name vpp1
97 sudo ip link set dev vpp1 up
98 sudo ip link set dev veth_vpp1 up netns vppns1
99
100 # create and configure 2nd veth client to vpp pair
101 sudo ip link add veth_vpp2 type veth peer name vpp2
102 sudo ip link set dev vpp2 up
103 sudo ip link set dev veth_vpp2 up netns vppns2
104
105 # set odl iface ip and disable checksum offloading
106 sudo ip addr add 6.0.3.100/24 dev odl
107 sudo ip addr add 6:0:3::100/64 dev odl
108 sudo ethtool --offload  odl rx off tx off
109
110 if [ "$1" == "ip6" ] ; then
111   VPP1_CONF="vpp1_6.conf"
112   VPP2_CONF="vpp2_6.conf"
113 fi
114
115 if [ "$1" == "ip4_ip6" ] ; then
116   VPP1_CONF="vpp1_ip4_6.conf"
117   VPP2_CONF="vpp2_ip4_6.conf"
118 fi
119
120 if [ "$1" == "4o6" ] ; then
121   VPP1_CONF="vpp1_4o6.conf"
122   VPP2_CONF="vpp2_4o6.conf"
123 fi
124
125 if [ "$1" == "6o4" ] ; then
126   VPP1_CONF="vpp1_6o4.conf"
127   VPP2_CONF="vpp2_6o4.conf"
128 fi
129
130 if [ "$1" == "remote" ] ; then
131   VPP1_CONF="vpp1_remote.conf"
132   VPP2_CONF="vpp2_remote.conf"
133 fi
134
135 if [ "$1" == "remote6" ] ; then
136   VPP1_CONF="vpp1_6_remote.conf"
137   VPP2_CONF="vpp2_6_remote.conf"
138 fi
139
140 # start vpp1 and vpp2 in separate chroot
141 sudo $VPP_LITE_BIN                              \
142   unix { log /tmp/vpp1.log cli-listen           \
143          localhost:5002 full-coredump           \
144          exec $VPP_LITE_CONF/${VPP1_CONF} }     \
145          api-trace { on } chroot {prefix xtr1}
146
147 sudo $VPP_LITE_BIN                              \
148   unix { log /tmp/vpp2.log cli-listen           \
149          localhost:5003 full-coredump           \
150          exec $VPP_LITE_CONF/${VPP2_CONF}}      \
151          api-trace { on } chroot {prefix xtr2}
152
153
154 if [ "$#" == 0 ] || [ "$1" == "ip4" ] ; then
155   source lisp_ip4.sh
156 fi
157
158 if [ "$1" == "ip6" ] ; then
159   source lisp_ip6.sh
160 fi
161
162 if [ "$1" == "ip4_ip6" ] ; then
163   source lisp_ip4.sh
164   source lisp_ip6.sh
165
166   ping_lisp
167   ping_lisp6
168 fi
169
170 if [ "$1" == "4o6" ] ; then
171   source lisp_ip4o6.sh
172 fi
173
174 if [ "$1" == "6o4" ] ; then
175   source lisp_ip6o4.sh
176 fi
177
178 if [ "$1" == "remote" ] ; then
179   source lisp_remote_mapping.sh
180 fi
181
182 if [ "$1" == "remote6" ] ; then
183   source lisp_6_remote_mapping.sh
184 fi
185
186 echo "Success"