Add files that support simple overlay setup tutorial
[one.git] / tutorial / setup_lisp_topo.sh
1 # path to vpp executable and configurations folder
2 VPP_LITE_BIN=/vpp/build-root/install-vpp_lite_debug-native/vpp/bin/vpp
3 VPP_LITE_CONF=/etc/vpp/lite/
4
5 # make sure there are no vpp instances running
6 pkill vpp
7
8 # delete previous incarnations if they exist
9 ip netns exec intervppns ifconfig vppbr down
10 ip netns exec intervppns brctl delbr vppbr
11 ip link del dev veth_vpp1 &> /dev/null
12 ip link del dev veth_vpp2 &> /dev/null
13 ip link del dev veth_intervpp1 &> /dev/null
14 ip link del dev veth_intervpp2 &> /dev/null
15 ip link del dev veth_odl &> /dev/null
16 ip netns del vppns1 &> /dev/null
17 ip netns del vppns2 &> /dev/null
18 ip netns del intervppns &> /dev/null
19
20 if [ "$1" == "clean" ] ; then
21   exit 0;
22 fi
23
24 # create vpp to clients and inter-vpp namespaces
25 ip netns add vppns1
26 ip netns add vppns2
27 ip netns add intervppns
28
29 # create vpp and odl interfaces and set them in intervppns
30 ip link add veth_intervpp1 type veth peer name intervpp1
31 ip link add veth_intervpp2 type veth peer name intervpp2
32 ip link add veth_odl type veth peer name odl
33 ip link set dev intervpp1 up
34 ip link set dev intervpp2 up
35 ip link set dev odl up
36 ip link set dev veth_intervpp1 up netns intervppns
37 ip link set dev veth_intervpp2 up netns intervppns
38 ip link set dev veth_odl up netns intervppns
39
40 # create bridge in intervppns and add vpp and odl interfaces
41 ip netns exec intervppns brctl addbr vppbr
42 ip netns exec intervppns brctl addif vppbr veth_intervpp1
43 ip netns exec intervppns brctl addif vppbr veth_intervpp2
44 ip netns exec intervppns brctl addif vppbr veth_odl
45 ip netns exec intervppns ifconfig vppbr up
46
47 # create and configure 1st veth client to vpp pair
48 ip link add veth_vpp1 type veth peer name vpp1
49 ip link set dev vpp1 up
50 ip link set dev veth_vpp1 up netns vppns1
51
52 ip netns exec vppns1 \
53   bash -c "
54     ip link set dev lo up
55     ip addr add 6.0.2.2/24 dev veth_vpp1
56     ip route add 6.0.4.0/24 via 6.0.2.1
57 "
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 vppns2 \
65   bash -c "
66     ip link set dev lo up
67     ip addr add 6.0.4.4/24 dev veth_vpp2
68     ip route add 6.0.2.0/24 via 6.0.4.1
69 "
70
71 # set odl iface ip and disable checksum offloading
72 ifconfig odl 6.0.3.100/24
73 ethtool --offload  odl rx off tx off
74
75 # start vpp1 and vpp2 in separate chroot
76 sudo $VPP_LITE_BIN                              \
77   unix { log /tmp/vpp1.log cli-listen           \
78          localhost:5002 full-coredump           \
79          exec $VPP_LITE_CONF/vpp1.conf }        \
80          api-trace { on } chroot {prefix xtr1}
81
82 sudo $VPP_LITE_BIN                              \
83   unix { log /tmp/vpp2.log cli-listen           \
84          localhost:5003 full-coredump           \
85          exec $VPP_LITE_CONF/vpp2.conf}         \
86          api-trace { on } chroot {prefix xtr2}