lisp_test.sh revision 676362e1
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
21set -x
22
23USER="csit"
24ODL_USER="admin"
25ODL_PASSWD="admin"
26VPP1_IP="192.168.255.101"
27VPP2_IP="192.168.255.102"
28TG_IP="192.168.255.100"
29ODL_IP="192.168.255.10"
30ODL_PORT="8181"
31TMP_DIR="/tmp/vpp_${RANDOM}_lisp_test"
32TG_INT1="eth2"
33TG_INT2="eth3"
34ODL_M_USER="user"
35ODL_INT="eth2"
36VPP_CONFIG_DIR="../configs/vpp_csit_config/"
37VPP_CONFIG1="vpp1.conf"
38VPP_CONFIG1_6="vpp1_6.conf"
39VPP_CONFIG2="vpp2.conf"
40VPP_CONFIG2_6="vpp2_6.conf"
41VPP_RECONF2="vpp2_reconf.conf"
42VPP_RECONF2_6="vpp2_reconf_6.conf"
43ODL_CONFIG_DIR="../configs/odl/"
44ODL_ADD_CONFIG1="add_ipv4_odl1.txt"
45ODL_ADD_CONFIG1_6="add_ipv6_odl1.txt"
46ODL_ADD_CONFIG2="add_ipv4_odl2.txt"
47ODL_ADD_CONFIG2_6="add_ipv6_odl2.txt"
48ODL_REPLACE_CONFIG2="replace_ipv4_odl2.txt"
49ODL_REPLACE_CONFIG2_6="replace_ipv6_odl2.txt"
50
51function ssh_vpp1 {
52    ssh ${USER}@${VPP1_IP} ${@} || exit
53}
54
55function ssh_vpp2 {
56    ssh ${USER}@${VPP2_IP} ${@} || exit
57}
58
59function ssh_tg {
60    ssh ${USER}@${TG_IP} ${@} || exit
61}
62
63function ssh_odl {
64    ssh ${ODL_M_USER}@${ODL_IP} ${@} || exit
65}
66
67curl -X DELETE http://${ODL_IP}:${ODL_PORT}/restconf/config/odl-mappingservice:mapping-database/ -u ${ODL_USER}:${ODL_PASSWD}
68
69ssh_tg "sudo ip netns del net2 &> /dev/null || exit 0"
70ssh_tg "sudo ip addr flush dev ${TG_INT1} &> /dev/null || exit 0"
71ssh_tg "sudo ip route del 6.0.2.0/24 via 6.0.1.1 || exit 0"
72ssh_tg "sudo ip route del 6:0:2::0/64 via 6:0:1::1 || exit 0"
73
74ssh_odl "sudo ip addr flush dev ${ODL_INT} &> /dev/null || exit 0"
75ssh_odl "sudo ip addr add 6.0.3.100/24 dev ${ODL_INT}"
76ssh_odl "sudo ip addr add 6:0:3::100/64 dev ${ODL_INT}"
77
78ssh_odl "sudo ethtool --offload  ${ODL_INT}  rx off tx off"
79
80ssh_vpp1 "sudo stop vpp;  exit 0"
81ssh_vpp2 "sudo stop vpp;  exit 0"
82
83ssh_vpp1 "sudo start vpp;  exit 0"
84ssh_vpp2 "sudo start vpp;  exit 0"
85
86ssh_vpp1 "mkdir ${TMP_DIR}"
87ssh_vpp2 "mkdir ${TMP_DIR}"
88
89ssh_tg "sudo ip netns add net2"
90ssh_tg "sudo ip link set dev ${TG_INT2} netns net2"
91
92if [ "$#" == 0 ] || [ "$1" == "ip4" ] ; then
93  source lisp_ip4.sh
94fi
95
96if [ "$1" == "ip6" ] ; then
97  source lisp_ip6.sh
98fi
99
100if [ "$1" == "all" ] ; then
101  source lisp_ip4.sh
102  source lisp_ip6.sh
103
104  ping_lisp
105  ping_lisp6
106fi
107
108#clean tmp file
109ssh_vpp1 "sudo rm -r ${TMP_DIR}"
110ssh_vpp2 "sudo rm -r ${TMP_DIR}"
111
112echo "Success"