multihoming_topo_l2.sh revision 1df1d674
1#!/usr/bin/env bash
2
3function multihoming_topo_clean
4{
5  echo "Clearing all VPP instances.."
6  pkill vpp --signal 9
7  rm /dev/shm/*
8
9  echo "Cleaning topology.."
10  ip netns exec intervppns1 ifconfig vppbr down
11  ip netns exec intervppns1 brctl delbr vppbr
12  ip link del dev veth_vpp1 &> /dev/null
13  ip link del dev veth_vpp2 &> /dev/null
14  ip link del dev veth_intervpp11 &> /dev/null
15  ip link del dev veth_intervpp12 &> /dev/null
16  ip link del dev veth_odl &> /dev/null
17  ip netns del vppns1 &> /dev/null
18  ip netns del vppns2 &> /dev/null
19  ip netns del intervppns1 &> /dev/null
20
21  ip netns exec intervppns2 ifconfig vppbr down
22  ip netns exec intervppns2 brctl delbr vppbr
23  ip link del dev veth_intervpp21 &> /dev/null
24  ip link del dev veth_intervpp22 &> /dev/null
25  ip netns del intervppns2 &> /dev/null
26
27  if [ "$1" != "no_odl" ] ; then
28    odl_clear_all
29  fi
30}
31
32function set_arp
33{
34  mac1=`ip netns exec vppns1 ip a show dev veth_vpp1  | grep "link/ether" | awk '{print $2}'`
35  ip netns exec vppns2 arp -s 6.0.1.11 $mac1
36
37  mac2=`ip netns exec vppns2 ip a show dev veth_vpp2  | grep "link/ether" | awk '{print $2}'`
38  ip netns exec vppns1 arp -s 6.0.1.12 $mac2
39}
40
41function multihoming_topo_setup
42{
43
44  # create vpp to clients and inter-vpp namespaces
45  ip netns add vppns1
46  ip netns add vppns2
47  ip netns add intervppns1
48  ip netns add intervppns2
49
50  # create vpp and odl interfaces and set them in intervppns1
51  ip link add veth_intervpp11 type veth peer name intervpp11
52  ip link add veth_intervpp12 type veth peer name intervpp12
53  ip link add veth_odl type veth peer name odl
54  ip link set dev intervpp11 up
55  ip link set dev intervpp12 up
56  ip link set dev odl up
57  ip link set dev veth_intervpp11 up netns intervppns1
58  ip link set dev veth_intervpp12 up netns intervppns1
59  ip link set dev veth_odl up netns intervppns1
60
61  ip link add veth_intervpp21 type veth peer name intervpp21
62  ip link add veth_intervpp22 type veth peer name intervpp22
63  ip link set dev intervpp21 up
64  ip link set dev intervpp22 up
65  ip link set dev veth_intervpp21 up netns intervppns2
66  ip link set dev veth_intervpp22 up netns intervppns2
67
68  # create bridge in intervppns1 and add vpp and odl interfaces
69  ip netns exec intervppns1 brctl addbr vppbr
70  ip netns exec intervppns1 brctl addif vppbr veth_intervpp11
71  ip netns exec intervppns1 brctl addif vppbr veth_intervpp12
72  ip netns exec intervppns1 brctl addif vppbr veth_odl
73  ip netns exec intervppns1 ifconfig vppbr up
74
75  # create bridge in intervppns2 and add vpp and odl interfaces
76  ip netns exec intervppns2 brctl addbr vppbr
77  ip netns exec intervppns2 brctl addif vppbr veth_intervpp21
78  ip netns exec intervppns2 brctl addif vppbr veth_intervpp22
79  ip netns exec intervppns2 brctl addif vppbr veth_odl
80  ip netns exec intervppns2 ifconfig vppbr up
81
82  # create and configure 1st veth client to vpp pair
83  ip link add veth_vpp1 type veth peer name vpp1
84  ip link set dev vpp1 up
85  ip link set dev veth_vpp1 address 08:11:11:11:11:11
86  ip link set dev veth_vpp1 up netns vppns1
87
88  # create and configure 2nd veth client to vpp pair
89  ip link add veth_vpp2 type veth peer name vpp2
90  ip link set dev vpp2 up
91  ip link set dev veth_vpp2 address 08:22:22:22:22:22
92  ip link set dev veth_vpp2 up netns vppns2
93
94  ip netns exec vppns1 \
95  bash -c "
96    ip link set dev lo up
97    ip addr add 6.0.1.11/24 dev veth_vpp1
98    ip addr add 6:0:1::11/64 dev veth_vpp1
99  "
100
101  ip netns exec vppns2 \
102  bash -c "
103    ip link set dev lo up
104    ip addr add 6.0.1.12/24 dev veth_vpp2
105    ip addr add 6:0:1::12/64 dev veth_vpp2
106  "
107
108  # set odl iface ip and disable checksum offloading
109  ip addr add 6.0.3.100/24 dev odl
110  ip addr add 6:0:3::100/64 dev odl
111  ethtool --offload  odl rx off tx off
112
113  # start vpp1 and vpp2 in separate chroot
114  ${VPP_LITE_BIN}                                 \
115    unix { log /tmp/vpp1.log cli-listen           \
116           localhost:5002 full-coredump           \
117           exec ${VPP_LITE_CONF}/vpp1.config }    \
118           api-trace { on } api-segment {prefix xtr1}
119
120  ${VPP_LITE_BIN}                                 \
121    unix { log /tmp/vpp2.log cli-listen           \
122           localhost:5003 full-coredump           \
123           exec ${VPP_LITE_CONF}/vpp2.config }    \
124           api-trace { on } api-segment {prefix xtr2}
125
126  sleep 2
127  ${VPP_API_TEST} chroot prefix xtr1 script in ${VPP_LITE_CONF}/vpp1.vat
128  ${VPP_API_TEST} chroot prefix xtr2 script in ${VPP_LITE_CONF}/vpp2.vat
129
130  if [ "$1" != "no_odl" ] ; then
131    post_curl "add-mapping" ${ODL_CONFIG_FILE1}
132    post_curl "add-mapping" ${ODL_CONFIG_FILE2}
133  fi
134
135  set_arp
136}
137
138