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