Add INFO.yaml file
[one.git] / tutorial / setup_lisp_topo.sh
1 #!/usr/bin/env bash
2
3 if [ $USER != "root" ] ; then
4     echo "Restarting script with sudo..."
5     sudo $0 ${*}
6     exit
7 fi
8
9
10 SRC=${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
16 VPP_LITE_BIN=$SRC/build-root/install-vpp_lite_debug-native/vpp/bin/vpp
17 VPP_LITE_CONF=/etc/vpp/lite/
18
19 # make sure there are no vpp instances running
20 pkill vpp
21
22 # delete previous incarnations if they exist
23 ip netns exec intervppns ifconfig vppbr down
24 ip netns exec intervppns brctl delbr vppbr
25 ip link del dev veth_vpp1 &> /dev/null
26 ip link del dev veth_vpp2 &> /dev/null
27 ip link del dev veth_intervpp1 &> /dev/null
28 ip link del dev veth_intervpp2 &> /dev/null
29 ip link del dev veth_odl &> /dev/null
30 ip netns del vppns1 &> /dev/null
31 ip netns del vppns2 &> /dev/null
32 ip netns del intervppns &> /dev/null
33
34 if [ "$1" == "clean" ] ; then
35   exit 0;
36 fi
37
38 sleep 1
39
40 # create vpp to clients and inter-vpp namespaces
41 ip netns add vppns1
42 ip netns add vppns2
43 ip netns add intervppns
44
45 # create vpp and odl interfaces and set them in intervppns
46 ip link add veth_intervpp1 type veth peer name intervpp1
47 ip link add veth_intervpp2 type veth peer name intervpp2
48 ip link add veth_odl type veth peer name odl
49 ip link set dev intervpp1 up
50 ip link set dev intervpp2 up
51 ip link set dev odl up
52 ip link set dev veth_intervpp1 up netns intervppns
53 ip link set dev veth_intervpp2 up netns intervppns
54 ip link set dev veth_odl up netns intervppns
55
56 # create bridge in intervppns and add vpp and odl interfaces
57 ip netns exec intervppns brctl addbr vppbr
58 ip netns exec intervppns brctl addif vppbr veth_intervpp1
59 ip netns exec intervppns brctl addif vppbr veth_intervpp2
60 ip netns exec intervppns brctl addif vppbr veth_odl
61 ip netns exec intervppns ifconfig vppbr up
62
63 # create and configure 1st veth client to vpp pair
64 ip link add veth_vpp1 type veth peer name vpp1
65 ip link set dev vpp1 up
66 ip link set dev veth_vpp1 up netns vppns1
67
68 ip 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
76 ip link add veth_vpp2 type veth peer name vpp2
77 ip link set dev vpp2 up
78 ip link set dev veth_vpp2 up netns vppns2
79
80 ip 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
88 ifconfig odl 6.0.3.100/24
89 ethtool --offload  odl rx off tx off
90
91 # start vpp1 and vpp2 in separate chroot
92 sudo $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
98 sudo $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}