setup_lisp_topo.sh revision 40841eaf
1#!/usr/bin/env bash
2
3if [ $USER != "root" ] ; then
4    echo "Restarting script with sudo..."
5    sudo $0 ${*}
6    exit
7fi
8
9
10SRC=${1:-/vpp}
11[ $# -eq 0 ] && { echo "(using default vpp src $SRC. This can be passed as parameter to script)"; }
12
13# path to vpp executable and configurations folder
14[ -f $SRC/build-root/install-vpp_lite_debug-native/vpp/bin/vpp ] || { echo "VPP lite not found, build it by 'cd $SRC; PLATFORM=vpp_lite make build'"; exit 1; }
15
16VPP_LITE_BIN=$SRC/build-root/install-vpp_lite_debug-native/vpp/bin/vpp
17VPP_LITE_CONF=/etc/vpp/lite/
18
19# make sure there are no vpp instances running
20pkill vpp
21
22# delete previous incarnations if they exist
23ip netns exec intervppns ifconfig vppbr down
24ip netns exec intervppns brctl delbr vppbr
25ip link del dev veth_vpp1 &> /dev/null
26ip link del dev veth_vpp2 &> /dev/null
27ip link del dev veth_intervpp1 &> /dev/null
28ip link del dev veth_intervpp2 &> /dev/null
29ip link del dev veth_odl &> /dev/null
30ip netns del vppns1 &> /dev/null
31ip netns del vppns2 &> /dev/null
32ip netns del intervppns &> /dev/null
33
34if [ "$1" == "clean" ] ; then
35  exit 0;
36fi
37
38sleep 1
39
40# create vpp to clients and inter-vpp namespaces
41ip netns add vppns1
42ip netns add vppns2
43ip netns add intervppns
44
45# create vpp and odl interfaces and set them in intervppns
46ip link add veth_intervpp1 type veth peer name intervpp1
47ip link add veth_intervpp2 type veth peer name intervpp2
48ip link add veth_odl type veth peer name odl
49ip link set dev intervpp1 up
50ip link set dev intervpp2 up
51ip link set dev odl up
52ip link set dev veth_intervpp1 up netns intervppns
53ip link set dev veth_intervpp2 up netns intervppns
54ip link set dev veth_odl up netns intervppns
55
56# create bridge in intervppns and add vpp and odl interfaces
57ip netns exec intervppns brctl addbr vppbr
58ip netns exec intervppns brctl addif vppbr veth_intervpp1
59ip netns exec intervppns brctl addif vppbr veth_intervpp2
60ip netns exec intervppns brctl addif vppbr veth_odl
61ip netns exec intervppns ifconfig vppbr up
62
63# create and configure 1st veth client to vpp pair
64ip link add veth_vpp1 type veth peer name vpp1
65ip link set dev vpp1 up
66ip link set dev veth_vpp1 up netns vppns1
67
68ip netns exec vppns1 \
69  bash -c "
70    ip link set dev lo up
71    ip addr add 6.0.2.2/24 dev veth_vpp1
72    ip route add 6.0.4.0/24 via 6.0.2.1
73"
74
75# create and configure 2nd veth client to vpp pair
76ip link add veth_vpp2 type veth peer name vpp2
77ip link set dev vpp2 up
78ip link set dev veth_vpp2 up netns vppns2
79
80ip netns exec vppns2 \
81  bash -c "
82    ip link set dev lo up
83    ip addr add 6.0.4.4/24 dev veth_vpp2
84    ip route add 6.0.2.0/24 via 6.0.4.1
85"
86
87# set odl iface ip and disable checksum offloading
88ifconfig odl 6.0.3.100/24
89ethtool --offload  odl rx off tx off
90
91# start vpp1 and vpp2 in separate chroot
92sudo $VPP_LITE_BIN                                  \
93  unix { log /tmp/vpp1.log cli-listen               \
94         localhost:5002 full-coredump               \
95         exec $VPP_LITE_CONF/vpp1.conf }            \
96         api-trace { on } api-segment {prefix xtr1}
97
98sudo $VPP_LITE_BIN                                  \
99  unix { log /tmp/vpp2.log cli-listen               \
100         localhost:5003 full-coredump               \
101         exec $VPP_LITE_CONF/vpp2.conf}             \
102         api-trace { on } api-segment {prefix xtr2}
103