Introduce an option for testing binary API
[one.git] / tests / data_plane / vpp_lite_topo / topologies / basic_two_odls.sh
1
2 #!/usr/bin/env bash
3
4 function basic_two_odls_clean
5 {
6   echo "Clearing all VPP instances.."
7   pkill vpp --signal 9
8   rm /dev/shm/*
9
10   echo "Cleaning topology.."
11   ip netns exec intervppns ifconfig vppbr down
12   ip netns exec intervppns brctl delbr vppbr
13   ip link del dev veth_vpp1 &> /dev/null
14   ip link del dev veth_vpp2 &> /dev/null
15   ip link del dev veth_intervpp1 &> /dev/null
16   ip link del dev veth_intervpp2 &> /dev/null
17   ip link del dev veth_odl1 &> /dev/null
18   ip link del dev veth_odl2 &> /dev/null
19   ip netns del vppns1 &> /dev/null
20   ip netns del vppns2 &> /dev/null
21   ip netns del intervppns &> /dev/null
22 }
23
24 function basic_two_odls_setup
25 {
26
27   # create vpp to clients and inter-vpp namespaces
28   ip netns add vppns1
29   ip netns add vppns2
30   ip netns add intervppns
31
32   # create vpp and odl interfaces and set them in intervppns
33   ip link add veth_intervpp1 type veth peer name intervpp1
34   ip link add veth_intervpp2 type veth peer name intervpp2
35   ip link add veth_odl1 type veth peer name odl1
36   ip link add veth_odl2 type veth peer name odl2
37   ip link set dev intervpp1 up
38   ip link set dev intervpp2 up
39   ip link set dev odl1 up
40   ip link set dev odl2 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_odl1 up netns intervppns
44   ip link set dev veth_odl2 up netns intervppns
45
46   # create bridge in intervppns and add vpp and odl interfaces
47   ip netns exec intervppns brctl addbr vppbr
48   ip netns exec intervppns brctl addif vppbr veth_intervpp1
49   ip netns exec intervppns brctl addif vppbr veth_intervpp2
50   ip netns exec intervppns brctl addif vppbr veth_odl1
51   ip netns exec intervppns brctl addif vppbr veth_odl2
52   ip netns exec intervppns ifconfig vppbr up
53
54   # create and configure 1st veth client to vpp pair
55   ip link add veth_vpp1 type veth peer name vpp1
56   ip link set dev vpp1 up
57   ip link set dev veth_vpp1 up netns vppns1
58
59   # create and configure 2nd veth client to vpp pair
60   ip link add veth_vpp2 type veth peer name vpp2
61   ip link set dev vpp2 up
62   ip link set dev veth_vpp2 up netns vppns2
63
64   ip netns exec vppns1 \
65   bash -c "
66     ip link set dev lo up
67     ip addr add 6.0.1.2/24 dev veth_vpp1
68     ip route add 6.0.2.0/24 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   "
77
78   # set odl iface ip and disable checksum offloading
79   ip addr add 6.0.3.100/24 dev odl1
80   ethtool --offload  odl1 rx off tx off
81
82   # generate config files
83   ./scripts/generate_config.py ${VPP_LITE_CONF} ${CFG_METHOD}
84
85   start_vpp 5002 vpp1
86   start_vpp 5003 vpp2
87
88   echo "* Selected configuration method: $CFG_METHOD"
89   if [ "$CFG_METHOD" == "cli" ] ; then
90     echo "exec ${VPP_LITE_CONF}/vpp1.cli" | nc 0 5002
91     echo "exec ${VPP_LITE_CONF}/vpp2.cli" | nc 0 5003
92   elif [ "$CFG_METHOD" == "vat" ] ; then
93     sleep 2
94     ${VPP_API_TEST} chroot prefix vpp1 script in ${VPP_LITE_CONF}/vpp1.vat
95     ${VPP_API_TEST} chroot prefix vpp2 script in ${VPP_LITE_CONF}/vpp2.vat
96   else
97     echo "=== WARNING:"
98     echo "=== Invalid configuration method selected!"
99     echo "=== To resolve this set env variable CFG_METHOD to vat or cli."
100     echo "==="
101   fi
102 }