lisp_test.sh revision 46e4b31a
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]"
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  exit 0
29fi
30
31set -x
32
33USER="csit"
34ODL_USER="admin"
35ODL_PASSWD="admin"
36VPP1_IP="192.168.255.101"
37VPP2_IP="192.168.255.102"
38TG_IP="192.168.255.100"
39ODL_IP="192.168.255.10"
40ODL_PORT="8181"
41TMP_DIR="/tmp/vpp_${RANDOM}_lisp_test"
42TG_INT1="eth2"
43TG_INT2="eth3"
44ODL_M_USER="user"
45ODL_INT="eth2"
46VPP_CONFIG_DIR="../configs/vpp_csit_config/"
47VPP_CONFIG1="vpp1.conf"
48VPP_CONFIG1_4o6="vpp1_4o6.conf"
49VPP_CONFIG1_6="vpp1_6.conf"
50VPP_CONFIG1_6o4="vpp1_6o4.conf"
51VPP_CONFIG2="vpp2.conf"
52VPP_CONFIG2_4o6="vpp2_4o6.conf"
53VPP_CONFIG2_6="vpp2_6.conf"
54VPP_CONFIG2_6o4="vpp2_6o4.conf"
55VPP_RECONF2="vpp2_reconf.conf"
56VPP_RECONF2_6="vpp2_reconf_6.conf"
57VPP_RECONF2_4o6="vpp2_reconf_4o6.conf"
58VPP_RECONF2_6o4="vpp2_reconf_6o4.conf"
59ODL_CONFIG_DIR="../configs/odl/"
60ODL_ADD_CONFIG1="add_ipv4_odl1.txt"
61ODL_ADD_CONFIG1_4o6="add_ipv4o6_odl1.txt"
62ODL_ADD_CONFIG1_6="add_ipv6_odl1.txt"
63ODL_ADD_CONFIG1_6o4="add_ipv6o4_odl1.txt"
64ODL_ADD_CONFIG2="add_ipv4_odl2.txt"
65ODL_ADD_CONFIG2_4o6="add_ipv4o6_odl2.txt"
66ODL_ADD_CONFIG2_6="add_ipv6_odl2.txt"
67ODL_ADD_CONFIG2_6o4="add_ipv6o4_odl2.txt"
68ODL_REPLACE_CONFIG2="replace_ipv4_odl2.txt"
69ODL_REPLACE_CONFIG2_6="replace_ipv6_odl2.txt"
70ODL_REPLACE_CONFIG2_4o6="replace_ipv4o6_odl2.txt"
71ODL_REPLACE_CONFIG2_6o4="replace_ipv6o4_odl2.txt"
72
73function ssh_vpp1 {
74    ssh ${USER}@${VPP1_IP} ${@} || exit
75}
76
77function ssh_vpp2 {
78    ssh ${USER}@${VPP2_IP} ${@} || exit
79}
80
81function ssh_tg {
82    ssh ${USER}@${TG_IP} ${@} || exit
83}
84
85function ssh_odl {
86    ssh ${ODL_M_USER}@${ODL_IP} ${@} || exit
87}
88
89function post_curl {
90  curl -X POST http://${ODL_IP}:${ODL_PORT}/restconf/operations/odl-mappingservice:${1} \
91     -H "Content-Type: application/json" --data-binary "@${ODL_CONFIG_DIR}${2}" \
92     -u ${ODL_USER}:${ODL_PASSWD}
93}
94
95curl -X DELETE http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database/ \
96     -u ${ODL_USER}:${ODL_PASSWD}
97
98ssh_tg "sudo ip netns del net2 &> /dev/null || exit 0"
99ssh_tg "sudo ip addr flush dev ${TG_INT1} &> /dev/null || exit 0"
100ssh_tg "sudo ip route del 6.0.2.0/24 via 6.0.1.1 || exit 0"
101ssh_tg "sudo ip route del 6:0:2::0/64 via 6:0:1::1 || exit 0"
102
103ssh_odl "sudo ip addr flush dev ${ODL_INT} &> /dev/null || exit 0"
104ssh_odl "sudo ip addr add 6.0.3.100/24 dev ${ODL_INT}"
105ssh_odl "sudo ip addr add 6:0:3::100/64 dev ${ODL_INT}"
106
107ssh_odl "sudo ethtool --offload  ${ODL_INT}  rx off tx off"
108
109ssh_vpp1 "sudo stop vpp;  exit 0"
110ssh_vpp2 "sudo stop vpp;  exit 0"
111
112ssh_vpp1 "sudo start vpp;  exit 0"
113ssh_vpp2 "sudo start vpp;  exit 0"
114
115ssh_vpp1 "mkdir ${TMP_DIR}"
116ssh_vpp2 "mkdir ${TMP_DIR}"
117
118ssh_tg "sudo ip netns add net2"
119ssh_tg "sudo ip link set dev ${TG_INT2} netns net2"
120
121if [ "$#" == 0 ] || [ "$1" == "ip4" ] ; then
122  source lisp_ip4.sh
123fi
124
125if [ "$1" == "ip6" ] ; then
126  source lisp_ip6.sh
127fi
128
129if [ "$1" == "4o6" ] ; then
130  source lisp_ip4o6.sh
131fi
132
133if [ "$1" == "6o4" ] ; then
134  source lisp_ip6o4.sh
135fi
136
137if [ "$1" == "ip4_ip6" ] ; then
138  source lisp_ip4.sh
139  source lisp_ip6.sh
140
141  ping_lisp
142  ping_lisp6
143fi
144
145#clean tmp file
146ssh_vpp1 "sudo rm -r ${TMP_DIR}"
147ssh_vpp2 "sudo rm -r ${TMP_DIR}"
148
149echo "Success"