Use VAT in tests
[one.git] / tests / data_plane / vpp_lite_topo / topologies / basic_topo.sh
1 #!/usr/bin/env bash
2
3 function basic_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 intervppns ifconfig vppbr down
11   ip netns exec intervppns 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_intervpp1 &> /dev/null
15   ip link del dev veth_intervpp2 &> /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 intervppns &> /dev/null
20
21   if [ "$1" != "no_odl" ] ; then
22     odl_clear_all
23   fi
24 }
25
26 function basic_topo_setup
27 {
28
29   # create vpp to clients and inter-vpp namespaces
30   ip netns add vppns1
31   ip netns add vppns2
32   ip netns add intervppns
33
34   # create vpp and odl interfaces and set them in intervppns
35   ip link add veth_intervpp1 type veth peer name intervpp1
36   ip link add veth_intervpp2 type veth peer name intervpp2
37   ip link add veth_odl type veth peer name odl
38   ip link set dev intervpp1 up
39   ip link set dev intervpp2 up
40   ip link set dev odl up
41   ip link set dev veth_intervpp1 up netns intervppns
42   ip link set dev veth_intervpp2 up netns intervppns
43   ip link set dev veth_odl up netns intervppns
44
45   # create bridge in intervppns and add vpp and odl interfaces
46   ip netns exec intervppns brctl addbr vppbr
47   ip netns exec intervppns brctl addif vppbr veth_intervpp1
48   ip netns exec intervppns brctl addif vppbr veth_intervpp2
49   ip netns exec intervppns brctl addif vppbr veth_odl
50   ip netns exec intervppns ifconfig vppbr up
51
52   # create and configure 1st veth client to vpp pair
53   ip link add veth_vpp1 type veth peer name vpp1
54   ip link set dev vpp1 up
55   ip link set dev veth_vpp1 up netns vppns1
56
57   # create and configure 2nd veth client to vpp pair
58   ip link add veth_vpp2 type veth peer name vpp2
59   ip link set dev vpp2 up
60   ip link set dev veth_vpp2 up netns vppns2
61
62   ip netns exec vppns1 \
63   bash -c "
64     ip link set dev lo up
65     ip addr add 6.0.1.2/24 dev veth_vpp1
66     ip route add 6.0.2.0/24 via 6.0.1.1
67     ip addr add 6:0:1::2/64 dev veth_vpp1
68     ip route add 6:0:2::0/64 via 6:0:1::1
69   "
70
71   ip netns exec vppns2 \
72   bash -c "
73     ip link set dev lo up
74     ip addr add 6.0.2.2/24 dev veth_vpp2
75     ip route add 6.0.1.0/24 via 6.0.2.1
76     ip addr add 6:0:2::2/64 dev veth_vpp2
77     ip route add 6:0:1::0/64 via 6:0:2::1
78   "
79
80   # set odl iface ip and disable checksum offloading
81   ip addr add 6.0.3.100/24 dev odl
82   ip addr add 6:0:3::100/64 dev odl
83   ethtool --offload  odl rx off tx off
84
85   # start vpp1 and vpp2 in separate chroot
86   ${VPP_LITE_BIN}                                 \
87     unix { log /tmp/vpp1.log cli-listen           \
88            localhost:5002 full-coredump           \
89            exec ${VPP_LITE_CONF}/vpp1.config }    \
90            api-trace { on } api-segment {prefix xtr1}
91
92   ${VPP_LITE_BIN}                                 \
93     unix { log /tmp/vpp2.log cli-listen           \
94            localhost:5003 full-coredump           \
95            exec ${VPP_LITE_CONF}/vpp2.config }    \
96            api-trace { on } api-segment {prefix xtr2}
97
98   sleep 2
99   ${VPP_API_TEST} chroot prefix xtr1 script in ${VPP_LITE_CONF}/vpp1.vat
100   ${VPP_API_TEST} chroot prefix xtr2 script in ${VPP_LITE_CONF}/vpp2.vat
101
102   if [ "$1" != "no_odl" ] ; then
103     post_curl "add-mapping" ${ODL_CONFIG_FILE1}
104     post_curl "add-mapping" ${ODL_CONFIG_FILE2}
105   fi
106 }
107