d349e8d4ce0cacf02bb9224145ba1ee97affcd5f
[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 sleep 1
25
26 # create vpp to clients and inter-vpp namespaces
27 ip netns add vppns1
28 ip netns add vppns2
29 ip netns add intervppns
30
31 # create vpp and odl interfaces and set them in intervppns
32 ip link add veth_intervpp1 type veth peer name intervpp1
33 ip link add veth_intervpp2 type veth peer name intervpp2
34 ip link add veth_odl type veth peer name odl
35 ip link set dev intervpp1 up
36 ip link set dev intervpp2 up
37 ip link set dev odl up
38 ip link set dev veth_intervpp1 up netns intervppns
39 ip link set dev veth_intervpp2 up netns intervppns
40 ip link set dev veth_odl up netns intervppns
41
42 # create bridge in intervppns and add vpp and odl interfaces
43 ip netns exec intervppns brctl addbr vppbr
44 ip netns exec intervppns brctl addif vppbr veth_intervpp1
45 ip netns exec intervppns brctl addif vppbr veth_intervpp2
46 ip netns exec intervppns brctl addif vppbr veth_odl
47 ip netns exec intervppns ifconfig vppbr up
48
49 # create and configure 1st veth client to vpp pair
50 ip link add veth_vpp1 type veth peer name vpp1
51 ip link set dev vpp1 up
52 ip link set dev veth_vpp1 up netns vppns1
53
54 ip netns exec vppns1 \
55   bash -c "
56     ip link set dev lo up
57     ip addr add 6.0.2.2/24 dev veth_vpp1
58     ip route add 6.0.4.0/24 via 6.0.2.1
59 "
60
61 # create and configure 2nd veth client to vpp pair
62 ip link add veth_vpp2 type veth peer name vpp2
63 ip link set dev vpp2 up
64 ip link set dev veth_vpp2 up netns vppns2
65
66 ip netns exec vppns2 \
67   bash -c "
68     ip link set dev lo up
69     ip addr add 6.0.4.4/24 dev veth_vpp2
70     ip route add 6.0.2.0/24 via 6.0.4.1
71 "
72
73 # set odl iface ip and disable checksum offloading
74 ifconfig odl 6.0.3.100/24
75 ethtool --offload  odl rx off tx off
76
77 # start vpp1 and vpp2 in separate chroot
78 sudo $VPP_LITE_BIN                                  \
79   unix { log /tmp/vpp1.log cli-listen               \
80          localhost:5002 full-coredump               \
81          exec $VPP_LITE_CONF/vpp1.conf }            \
82          api-trace { on } api-segment {prefix xtr1}
83
84 sudo $VPP_LITE_BIN                                  \
85   unix { log /tmp/vpp2.log cli-listen               \
86          localhost:5003 full-coredump               \
87          exec $VPP_LITE_CONF/vpp2.conf}             \
88          api-trace { on } api-segment {prefix xtr2}