3_node_star.sh revision 5089c812
1#!/usr/bin/env bash
2
3#                                 +--------+
4#                                 |        |
5#               6.0.10.25         |   MR   |
6#            08:55:55:55:55:55    |        |
7#                    +            +--------+
8#                    |                 |6.0.3.100
9# 6:0:1::2           |vpp8             |6:0:3::100
10# 6.0.1.2     vpp1 +-+------+          |         +--------+
11#        +---------+        |xtr1      |    xtr2 |        |vpp2
12#                  |  VPP1  +----------+---------+  VPP2  +---------+
13#        +---------+        |          |         |        |      6.0.2.2
14# 6.0.5.5     vpp3 +-+------+          |         +-----+--+      6:0:2::2
15# 6:0:5::5           |vpp5             |xtr3           |vpp7
16#                    |             +--------+          |
17#                    +             |        |          + 6.0.10.22
18#                6.0.10.21         |  VPP3  |             08:22:22:22:22:22
19#            08:11:11:11:11:11     |        |
20#                                  +-+----+-+
21#                                vpp6|    |vpp4
22#                                    |    |
23#                                    |    +6.0.2.2
24#                                    +     6:0:2::2
25#                             6.0.10.22
26#                             08:22:22:22:22:22
27#
28
29
30function 3_node_star_topo_clean
31{
32  echo "Clearing all VPP instances.."
33  pkill vpp --signal 9
34
35  rm /dev/shm/*
36
37  echo "Cleaning 3 node star topology..."
38  ip netns exec xtr-ns ifconfig vppbr1 down
39  ip netns exec xtr-ns brctl delbr vppbr1
40  ip link del dev vpp1 &> /dev/null
41  ip link del dev vpp2 &> /dev/null
42  ip link del dev vpp3 &> /dev/null
43  ip link del dev vpp4 &> /dev/null
44  ip link del dev vpp5 &> /dev/null
45  ip link del dev vpp6 &> /dev/null
46  ip link del dev vpp7 &> /dev/null
47  ip link del dev vpp8 &> /dev/null
48  ip link del dev xtr1 &> /dev/null
49  ip link del dev xtr2 &> /dev/null
50  ip link del dev xtr3 &> /dev/null
51  ip link del dev odl &> /dev/null
52
53  ip netns del vpp-ns1 &> /dev/null
54  ip netns del vpp-ns2 &> /dev/null
55  ip netns del vpp-ns3 &> /dev/null
56  ip netns del vpp-ns4 &> /dev/null
57  ip netns del vpp-ns5 &> /dev/null
58  ip netns del vpp-ns6 &> /dev/null
59  ip netns del vpp-ns7 &> /dev/null
60  ip netns del vpp-ns8 &> /dev/null
61  ip netns del xtr-ns &> /dev/null
62
63  odl_clear_all
64}
65
66function set_arp
67{
68  mac1=`ip netns exec vpp-ns5 ip a show dev veth_vpp5  | grep "link/ether" | awk '{print $2}'`
69  ip netns exec vpp-ns6 arp -s 6.0.10.21 $mac1
70
71  mac2=`ip netns exec vpp-ns8 ip a show dev veth_vpp8  | grep "link/ether" | awk '{print $2}'`
72  ip netns exec vpp-ns7 arp -s 6.0.10.25 $mac2
73
74  mac3=`ip netns exec vpp-ns7 ip a show dev veth_vpp7  | grep "link/ether" | awk '{print $2}'`
75  ip netns exec vpp-ns5 arp -s 6.0.10.22 $mac3
76  ip netns exec vpp-ns8 arp -s 6.0.10.22 $mac3
77}
78
79function 3_node_star_topo_setup
80{
81  ip netns add vpp-ns1
82  ip netns add vpp-ns2
83  ip netns add vpp-ns3
84  ip netns add vpp-ns4
85  ip netns add vpp-ns5
86  ip netns add vpp-ns6
87  ip netns add vpp-ns7
88  ip netns add vpp-ns8
89  ip netns add xtr-ns
90
91  ip link add veth_xtr1 type veth peer name xtr1
92  ip link add veth_xtr2 type veth peer name xtr2
93  ip link add veth_xtr3 type veth peer name xtr3
94  ip link add veth_odl type veth peer name odl
95  ip link set dev xtr1 up
96  ip link set dev xtr2 up
97  ip link set dev xtr3 up
98  ip link set dev odl up
99
100  ip link set dev veth_xtr1 up netns xtr-ns
101  ip link set dev veth_xtr2 up netns xtr-ns
102  ip link set dev veth_xtr3 up netns xtr-ns
103  ip link set dev veth_odl up netns xtr-ns
104
105  ip netns exec xtr-ns brctl addbr vppbr1
106  ip netns exec xtr-ns brctl addif vppbr1 veth_xtr1
107  ip netns exec xtr-ns brctl addif vppbr1 veth_xtr2
108  ip netns exec xtr-ns brctl addif vppbr1 veth_xtr3
109  ip netns exec xtr-ns brctl addif vppbr1 veth_odl
110  ip netns exec xtr-ns ifconfig vppbr1 up
111
112  ip link add veth_vpp1 type veth peer name vpp1
113  ip link set dev vpp1 up
114  ip link set dev veth_vpp1 up netns vpp-ns1
115
116  ip netns exec vpp-ns1 \
117    bash -c "
118      ip link set dev lo up
119      ip addr add 6.0.1.2/24 dev veth_vpp1
120      ip addr add 6:0:1::2/64 dev veth_vpp1
121      ip route add 6.0.2.0/24 via 6.0.1.1
122      ip route add 6:0:2::0/64 via 6:0:1::1
123  "
124
125  ip link add veth_vpp2 type veth peer name vpp2
126  ip link set dev vpp2 up
127  ip link set dev veth_vpp2 up netns vpp-ns2
128
129  ip netns exec vpp-ns2 \
130    bash -c "
131      ip link set dev lo up
132      ip addr add 6.0.2.2/24 dev veth_vpp2
133      ip addr add 6:0:2::2/64 dev veth_vpp2
134      ip route add 6.0.1.0/24 via 6.0.2.1
135      ip route add 6:0:1::0/64 via 6:0:2::1
136  "
137
138  ip link add veth_vpp3 type veth peer name vpp3
139  ip link set dev vpp3 up
140  ip link set dev veth_vpp3 up netns vpp-ns3
141
142  ip netns exec vpp-ns3 \
143    bash -c "
144      ip link set dev lo up
145      ip addr add 6.0.5.5/24 dev veth_vpp3
146      ip addr add 6:0:5::5/64 dev veth_vpp3
147      ip route add 6.0.2.0/24 via 6.0.5.1
148      ip route add 6:0:2::0/64 via 6:0:5::1
149  "
150
151  ip link add veth_vpp4 type veth peer name vpp4
152  ip link set dev vpp4 up
153  ip link set dev veth_vpp4 up netns vpp-ns4
154
155  ip netns exec vpp-ns4 \
156    bash -c "
157      ip link set dev lo up
158      ip addr add 6.0.2.2/24 dev veth_vpp4
159      ip addr add 6:0:2::2/64 dev veth_vpp4
160      ip route add 6.0.5.0/24 via 6.0.2.1
161      ip route add 6:0:5::0/64 via 6:0:2::1
162  "
163
164  ip link add veth_vpp5 type veth peer name vpp5
165  ip link set dev vpp5 up
166  ip link set dev veth_vpp5 address 08:11:11:11:11:11
167  ip link set dev veth_vpp5 up netns vpp-ns5
168
169  ip netns exec vpp-ns5 \
170    bash -c "
171      ip link set dev lo up
172      ip addr add 6.0.10.21/24 dev veth_vpp5
173  "
174
175  ip link add veth_vpp6 type veth peer name vpp6
176  ip link set dev vpp6 up
177  ip link set dev veth_vpp6 address 08:22:22:22:22:22
178  ip link set dev veth_vpp6 up netns vpp-ns6
179
180  ip netns exec vpp-ns6 \
181    bash -c "
182      ip link set dev lo up
183      ip addr add 6.0.10.22/24 dev veth_vpp6
184  "
185
186  ip link add veth_vpp7 type veth peer name vpp7
187  ip link set dev vpp7 up
188  ip link set dev veth_vpp7 address 08:22:22:22:22:22
189  ip link set dev veth_vpp7 up netns vpp-ns7
190
191  ip netns exec vpp-ns7 \
192    bash -c "
193      ip link set dev lo up
194      ip addr add 6.0.10.22/24 dev veth_vpp7
195  "
196
197  ip link add veth_vpp8 type veth peer name vpp8
198  ip link set dev vpp8 up
199  ip link set dev veth_vpp8 address 08:55:55:55:55:55
200  ip link set dev veth_vpp8 up netns vpp-ns8
201
202  ip netns exec vpp-ns8 \
203    bash -c "
204      ip link set dev lo up
205      ip addr add 6.0.10.25/24 dev veth_vpp8
206  "
207
208  ip addr add 6.0.3.100/24 dev odl
209  ip addr add 6:0:3::100/64 dev odl
210  ethtool --offload  odl rx off tx off
211maybe_pause
212  # generate config files
213  ./scripts/generate_config.py ${VPP_LITE_CONF} ${CFG_METHOD}
214
215  start_vpp 5002 vpp1
216  start_vpp 5003 vpp2
217  start_vpp 5004 vpp3
218
219  echo "* Selected configuration method: $CFG_METHOD"
220  if [ "$CFG_METHOD" == "cli" ] ; then
221    echo "exec ${VPP_LITE_CONF}/vpp1.cli" | nc 0 5002
222    echo "exec ${VPP_LITE_CONF}/vpp2.cli" | nc 0 5003
223    echo "exec ${VPP_LITE_CONF}/vpp3.cli" | nc 0 5004
224  elif [ "$CFG_METHOD" == "vat" ] ; then
225    sleep 2
226    ${VPP_API_TEST} chroot prefix vpp1 script in ${VPP_LITE_CONF}/vpp1.vat
227    ${VPP_API_TEST} chroot prefix vpp2 script in ${VPP_LITE_CONF}/vpp2.vat
228    ${VPP_API_TEST} chroot prefix vpp3 script in ${VPP_LITE_CONF}/vpp3.vat
229  else
230    echo "=== WARNING:"
231    echo "=== Invalid configuration method selected!"
232    echo "=== To resolve this set env variable CFG_METHOD to vat or cli."
233    echo "==="
234  fi
235
236  post_curl "add-mapping" ${ODL_CONFIG_FILE1}
237  post_curl "add-mapping" ${ODL_CONFIG_FILE2}
238
239  set_arp
240}
241