rtr_two_iface_two_customers.sh revision 1df1d674
1
2#!/usr/bin/env bash
3
4function rtr_two_iface_two_customers_clean {
5  echo "Clearing all VPP instances.."
6  pkill vpp --signal 9
7
8  rm /dev/shm/*
9
10  echo "Cleaning RTR topology.."
11  ip netns exec vpp1-rtr-ns ifconfig vppbr1 down
12  ip netns exec vpp1-rtr-ns brctl delbr vppbr1
13  ip netns exec vpp2-rtr-ns ifconfig vppbr2 down
14  ip netns exec vpp2-rtr-ns brctl delbr vppbr2
15  ip link del dev vpp1 &> /dev/null
16  ip link del dev vpp2 &> /dev/null
17  ip link del dev vpp1_rtr &> /dev/null
18  ip link del dev rtr1_vpp1 &> /dev/null
19  ip link del dev vpp2_rtr &> /dev/null
20  ip link del dev rtr_vpp2 &> /dev/null
21  ip link del dev odl_vpp1 &> /dev/null
22  ip link del dev odl_vpp2 &> /dev/null
23
24  ip netns del vpp1-cus1-ns &> /dev/null
25  ip netns del vpp2-cus1-ns &> /dev/null
26  ip netns del vpp1-cus2-ns &> /dev/null
27  ip netns del vpp2-cus2-ns &> /dev/null
28  ip netns del vpp1-rtr-ns &> /dev/null
29  ip netns del vpp2-rtr-ns &> /dev/null
30
31  odl_clear_all
32}
33
34function rtr_two_iface_two_customers_setup {
35  # create namespaces
36  ip netns add vpp1-cus1-ns
37  ip netns add vpp1-cus2-ns
38  ip netns add vpp2-cus1-ns
39  ip netns add vpp2-cus2-ns
40  ip netns add vpp1-rtr-ns
41  ip netns add vpp2-rtr-ns
42
43  # create pair interfaces between vpp[1|2], rtr and odl
44  ip link add veth_vpp1_rtr type veth peer name vpp1_rtr
45  ip link add veth_rtr_vpp1 type veth peer name rtr_vpp1
46  ip link add veth_vpp2_rtr type veth peer name vpp2_rtr
47  ip link add veth_rtr_vpp2 type veth peer name rtr_vpp2
48  ip link add veth_odl_vpp1 type veth peer name odl_vpp1
49  ip link add veth_odl_vpp2 type veth peer name odl_vpp2
50
51  # enable peer interfaces
52  ip link set dev vpp1_rtr up
53  ip link set dev rtr_vpp1 up
54  ip link set dev vpp2_rtr up
55  ip link set dev rtr_vpp2 up
56  ip link set dev odl_vpp1 up
57  ip link set dev odl_vpp2 up
58
59  # enable veth interfaces and set them in the appropriate ip ns
60  ip link set dev veth_vpp1_rtr up netns vpp1-rtr-ns
61  ip link set dev veth_rtr_vpp1 up netns vpp1-rtr-ns
62  ip link set dev veth_vpp2_rtr up netns vpp2-rtr-ns
63  ip link set dev veth_rtr_vpp2 up netns vpp2-rtr-ns
64  ip link set dev veth_odl_vpp1 up netns vpp1-rtr-ns
65  ip link set dev veth_odl_vpp2 up netns vpp2-rtr-ns
66
67  # vpp1, rtr and odl
68  ip netns exec vpp1-rtr-ns brctl addbr vppbr1
69  ip netns exec vpp1-rtr-ns brctl addif vppbr1 veth_vpp1_rtr
70  ip netns exec vpp1-rtr-ns brctl addif vppbr1 veth_rtr_vpp1
71  ip netns exec vpp1-rtr-ns brctl addif vppbr1 veth_odl_vpp1
72  ip netns exec vpp1-rtr-ns ifconfig vppbr1 up
73
74  # vpp2, rtr and odl
75  ip netns exec vpp2-rtr-ns brctl addbr vppbr2
76  ip netns exec vpp2-rtr-ns brctl addif vppbr2 veth_vpp2_rtr
77  ip netns exec vpp2-rtr-ns brctl addif vppbr2 veth_rtr_vpp2
78  ip netns exec vpp2-rtr-ns brctl addif vppbr2 veth_odl_vpp2
79  ip netns exec vpp2-rtr-ns ifconfig vppbr2 up
80
81  # vpp1 to client1
82  ip link add veth_vpp1_cus1 type veth peer name vpp1_cus1
83  ip link set dev vpp1_cus1 up
84  ip link set dev veth_vpp1_cus1 up netns vpp1-cus1-ns
85
86  ip netns exec vpp1-cus1-ns \
87    bash -c "
88      ip link set dev lo up
89      ip addr add 6.0.2.2/24 dev veth_vpp1_cus1
90      ip addr add 6:0:2::2/64 dev veth_vpp1_cus1
91      ip route add 6.0.4.0/24 via 6.0.2.1
92      ip route add 6:0:4::0/64 via 6:0:2::1
93  "
94  # vpp1 to client2
95  ip link add veth_vpp1_cus2 type veth peer name vpp1_cus2
96  ip link set dev vpp1_cus2 up
97  ip link set dev veth_vpp1_cus2 up netns vpp1-cus2-ns
98
99  ip netns exec vpp1-cus2-ns \
100    bash -c "
101      ip link set dev lo up
102      ip addr add 6.0.2.2/24 dev veth_vpp1_cus2
103      ip addr add 6:0:2::2/64 dev veth_vpp1_cus2
104      ip route add 6.0.4.0/24 via 6.0.2.1
105      ip route add 6:0:4::0/64 via 6:0:2::1
106  "
107
108  # vpp2 to client1
109  ip link add veth_vpp2_cus1 type veth peer name vpp2_cus1
110  ip link set dev vpp2_cus1 up
111  ip link set dev veth_vpp2_cus1 up netns vpp2-cus1-ns
112
113  ip netns exec vpp2-cus1-ns \
114    bash -c "
115      ip link set dev lo up
116      ip addr add 6.0.4.4/24 dev veth_vpp2_cus1
117      ip addr add 6:0:4::4/64 dev veth_vpp2_cus1
118      ip route add 6.0.2.0/24 via 6.0.4.1
119      ip route add 6:0:2::0/64 via 6:0:4::1
120  "
121  # vpp2 to client2
122  ip link add veth_vpp2_cus2 type veth peer name vpp2_cus2
123  ip link set dev vpp2_cus2 up
124  ip link set dev veth_vpp2_cus2 up netns vpp2-cus2-ns
125
126  ip netns exec vpp2-cus2-ns \
127    bash -c "
128      ip link set dev lo up
129      ip addr add 6.0.4.4/24 dev veth_vpp2_cus2
130      ip addr add 6:0:4::4/64 dev veth_vpp2_cus2
131      ip route add 6.0.2.0/24 via 6.0.4.1
132      ip route add 6:0:2::0/64 via 6:0:4::1
133  "
134
135  # vpp1 to odl
136  ip addr add 6.0.3.100/24 dev odl_vpp1
137  ip addr add 6:0:3::100/64 dev odl_vpp1
138  ethtool --offload  odl_vpp1 rx off tx off
139
140  # vpp2 to odl
141  ip addr add 6.0.5.100/24 dev odl_vpp2
142  ip addr add 6:0:5::100/64 dev odl_vpp2
143  ethtool --offload  odl_vpp2 rx off tx off
144
145  ${VPP_LITE_BIN} \
146    unix { log /tmp/vpp1.log cli-listen \
147           localhost:5002 full-coredump \
148           exec ${VPP_LITE_CONF}/vpp1.config } \
149    api-trace { on } api-segment {prefix xtr1}
150
151  ${VPP_LITE_BIN} \
152    unix { log /tmp/vpp2.log cli-listen \
153           localhost:5003 full-coredump \
154           exec ${VPP_LITE_CONF}/vpp2.config } \
155    api-trace { on } api-segment {prefix xtr2}
156
157   ${VPP_LITE_BIN} \
158    unix { log /tmp/rtr.log cli-listen \
159           localhost:5004 full-coredump \
160           exec ${VPP_LITE_CONF}/rtr.config } \
161    api-trace { on } api-segment {prefix rtr}
162
163  sleep 2
164  ${VPP_API_TEST} chroot prefix xtr1 script in ${VPP_LITE_CONF}/vpp1.vat
165  ${VPP_API_TEST} chroot prefix xtr2 script in ${VPP_LITE_CONF}/vpp2.vat
166  ${VPP_API_TEST} chroot prefix rtr script in ${VPP_LITE_CONF}/vpp3.vat
167
168  post_curl "add-mapping" ${ODL_CONFIG_FILE1}
169  post_curl "add-mapping" ${ODL_CONFIG_FILE2}
170  post_curl "add-mapping" ${ODL_CONFIG_FILE3}
171  post_curl "add-mapping" ${ODL_CONFIG_FILE4}
172}
173