Use VAT in tests
[one.git] / tests / data_plane / vpp_lite_topo / topologies / multihoming_topo.sh
1 #!/usr/bin/env bash
2
3 function multihoming_topo_clean
4 {
5   echo "Clearing all VPP instances.."
6   pkill vpp --signal 9
7   rm /dev/shm/*
8
9   echo "Cleaning topology.."
10   ip netns exec intervppns1 ifconfig vppbr down
11   ip netns exec intervppns1 brctl delbr vppbr
12   ip link del dev veth_vpp1 &> /dev/null
13   ip link del dev veth_vpp2 &> /dev/null
14   ip link del dev veth_intervpp11 &> /dev/null
15   ip link del dev veth_intervpp12 &> /dev/null
16   ip link del dev veth_odl &> /dev/null
17   ip netns del vppns1 &> /dev/null
18   ip netns del vppns2 &> /dev/null
19   ip netns del intervppns1 &> /dev/null
20
21   ip netns exec intervppns2 ifconfig vppbr down
22   ip netns exec intervppns2 brctl delbr vppbr
23   ip link del dev veth_intervpp21 &> /dev/null
24   ip link del dev veth_intervpp22 &> /dev/null
25   ip netns del intervppns2 &> /dev/null
26
27   if [ "$1" != "no_odl" ] ; then
28     odl_clear_all
29   fi
30 }
31
32 function multihoming_topo_setup
33 {
34
35   # create vpp to clients and inter-vpp namespaces
36   ip netns add vppns1
37   ip netns add vppns2
38   ip netns add intervppns1
39   ip netns add intervppns2
40
41   # create vpp and odl interfaces and set them in intervppns1
42   ip link add veth_intervpp11 type veth peer name intervpp11
43   ip link add veth_intervpp12 type veth peer name intervpp12
44   ip link add veth_odl type veth peer name odl
45   ip link set dev intervpp11 up
46   ip link set dev intervpp12 up
47   ip link set dev odl up
48   ip link set dev veth_intervpp11 up netns intervppns1
49   ip link set dev veth_intervpp12 up netns intervppns1
50   ip link set dev veth_odl up netns intervppns1
51
52   ip link add veth_intervpp21 type veth peer name intervpp21
53   ip link add veth_intervpp22 type veth peer name intervpp22
54   ip link set dev intervpp21 up
55   ip link set dev intervpp22 up
56   ip link set dev veth_intervpp21 up netns intervppns2
57   ip link set dev veth_intervpp22 up netns intervppns2
58
59   # create bridge in intervppns1 and add vpp and odl interfaces
60   ip netns exec intervppns1 brctl addbr vppbr
61   ip netns exec intervppns1 brctl addif vppbr veth_intervpp11
62   ip netns exec intervppns1 brctl addif vppbr veth_intervpp12
63   ip netns exec intervppns1 brctl addif vppbr veth_odl
64   ip netns exec intervppns1 ifconfig vppbr up
65
66   # create bridge in intervppns2 and add vpp and odl interfaces
67   ip netns exec intervppns2 brctl addbr vppbr
68   ip netns exec intervppns2 brctl addif vppbr veth_intervpp21
69   ip netns exec intervppns2 brctl addif vppbr veth_intervpp22
70   ip netns exec intervppns2 brctl addif vppbr veth_odl
71   ip netns exec intervppns2 ifconfig vppbr up
72
73   # create and configure 1st veth client to vpp pair
74   ip link add veth_vpp1 type veth peer name vpp1
75   ip link set dev vpp1 up
76   ip link set dev veth_vpp1 up netns vppns1
77
78   # create and configure 2nd veth client to vpp pair
79   ip link add veth_vpp2 type veth peer name vpp2
80   ip link set dev vpp2 up
81   ip link set dev veth_vpp2 up netns vppns2
82
83   ip netns exec vppns1 \
84   bash -c "
85     ip link set dev lo up
86     ip addr add 6.0.1.2/24 dev veth_vpp1
87     ip route add 6.0.2.0/24 via 6.0.1.1
88     ip addr add 6:0:1::2/64 dev veth_vpp1
89     ip route add 6:0:2::0/64 via 6:0:1::1
90   "
91
92   ip netns exec vppns2 \
93   bash -c "
94     ip link set dev lo up
95     ip addr add 6.0.2.2/24 dev veth_vpp2
96     ip route add 6.0.1.0/24 via 6.0.2.1
97     ip addr add 6:0:2::2/64 dev veth_vpp2
98     ip route add 6:0:1::0/64 via 6:0:2::1
99   "
100
101   # set odl iface ip and disable checksum offloading
102   ip addr add 6.0.3.100/24 dev odl
103   ip addr add 6:0:3::100/64 dev odl
104   ethtool --offload  odl rx off tx off
105
106   # start vpp1 and vpp2 in separate chroot
107   ${VPP_LITE_BIN}                                 \
108     unix { log /tmp/vpp1.log cli-listen           \
109            localhost:5002 full-coredump           \
110            exec ${VPP_LITE_CONF}/vpp1.config }    \
111            api-trace { on } api-segment {prefix xtr1}
112
113   ${VPP_LITE_BIN}                                 \
114     unix { log /tmp/vpp2.log cli-listen           \
115            localhost:5003 full-coredump           \
116            exec ${VPP_LITE_CONF}/vpp2.config }    \
117            api-trace { on } api-segment {prefix xtr2}
118
119   sleep 2
120   ${VPP_API_TEST} chroot prefix xtr1 script in ${VPP_LITE_CONF}/vpp1.vat
121   ${VPP_API_TEST} chroot prefix xtr2 script in ${VPP_LITE_CONF}/vpp2.vat
122
123   if [ "$1" != "no_odl" ] ; then
124     post_curl "add-mapping" ${ODL_CONFIG_FILE1}
125     post_curl "add-mapping" ${ODL_CONFIG_FILE2}
126   fi
127 }
128