0296ec3af2fb30fd3a8d67517f459cf66a7eafb4
[csit.git] / tests / func / gre / gre_encapsulation.robot
1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Resource | resources/libraries/robot/default.robot
16 | Resource | resources/libraries/robot/testing_path.robot
17 | Resource | resources/libraries/robot/ipv4.robot
18 | Resource | resources/libraries/robot/gre.robot
19 | Resource | resources/libraries/robot/traffic.robot
20 | Library  | resources.libraries.python.IPUtil
21 | Library  | resources.libraries.python.Trace
22 | Force Tags | VM_ENV | HW_ENV
23 | Test Setup | Run Keywords
24 | ... | Setup all DUTs before test | AND
25 | ... | Setup all TGs before traffic script
26 | Test Teardown | Run Keywords
27 | ... | Show Packet Trace on All DUTs | ${nodes} | AND
28 | ... | Show vpp trace dump on all DUTs
29 | Documentation | *GREoIPv4 test cases*
30 | ...
31 | ... | *[Top] Network Topologies:* TG=DUT1 2-node topology with two links
32 | ... | between nodes; TG-DUT1-DUT2-TG 3-node circular topology with single
33 | ... | links between nodes.
34 | ... | *[Enc] Packet Encapsulations:* Eth-IPv4-GRE-IPv4-ICMPv4 on DUT1-DUT2,
35 | ... | Eth-IPv4-ICMPv4 on TG-DUTn for routing over GRE tunnel; Eth-IPv4-ICMPv4
36 | ... | on TG_if1-DUT, Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT for GREoIPv4
37 | ... | encapsulation and decapsulation verification.
38 | ... | *[Cfg] DUT configuration:* DUT1 and DUT2 are configured with IPv4 routing
39 | ... | and static routes. GREoIPv4 tunnel is configured between DUT1 and DUT2.
40 | ... | *[Ver] TG verification:* Test ICMPv4 (or ICMPv6) Echo Request packets are
41 | ... | sent in both directions by TG on links to DUT1 and DUT2; GREoIPv4
42 | ... | encapsulation and decapsulation are verified separately by TG; on
43 | ... | receive TG verifies packets for correctness and their IPv4 (IPv6)
44 | ... | src-addr, dst-addr and MAC addresses.
45 | ... | *[Ref] Applicable standard specifications:* RFC2784.
46
47 *** Variables ***
48 | ${net1_address}= | 192.168.0.0
49 | ${net1_host_address}= | 192.168.0.100
50 | ${net1_gw_address}= | 192.168.0.1
51 | ${net2_address}= | 192.168.2.0
52 | ${net2_host_address}= | 192.168.2.100
53 | ${net3_address}= | 192.168.3.0
54 | ${net3_host_address}= | 192.168.3.100
55 | ${net2_gw_address}= | 192.168.2.1
56 | ${dut1_ip_address}= | 192.168.1.1
57 | ${dut2_ip_address}= | 192.168.1.2
58 | ${dut1_gre_ip}= | 172.16.0.1
59 | ${dut2_gre_ip}= | 172.16.0.2
60 | ${dut_tun0_ip1}= | 172.16.0.1
61 | ${dut_tun0_ip2}= | 172.16.0.2
62 | ${dut_tun1_ip1}= | 172.16.1.1
63 | ${dut_tun1_ip2}= | 172.16.1.2
64 | ${dut1_lo_address}= | 10.0.0.1
65 | ${tun0_dst}= | 10.0.0.2
66 | ${tun1_dst}= | 10.0.0.3
67 | ${prefix}= | 24
68
69 *** Test Cases ***
70 | TC01: DUT1 and DUT2 route over GREoIPv4 tunnel between two TG links
71 | | [Documentation]
72 | | ... | [Top] TG-DUT1-DUT2-TG. [Enc] Eth-IPv4-GRE-IPv4-ICMPv4 on \
73 | | ... | DUT1-DUT2, Eth-IPv4-ICMPv4 on TG-DUTn. [Cfg] On DUT1 and DUT2
74 | | ... | configure GREoIPv4 tunnel with IPv4 routes towards each other.
75 | | ... | [Ver] Make TG send ICMPv4 Echo Req between its interfaces across
76 | | ... | both DUTs and GRE tunnel between them; verify IPv4 headers on
77 | | ... | received packets are correct. [Ref] RFC2784.
78 | | [Tags] | 3_NODE_SINGLE_LINK_TOPO | 3_NODE_DOUBLE_LINK_TOPO
79 | | Given Path for 3-node testing is set | ${nodes['TG']} | ${nodes['DUT1']}
80 | | ... | ${nodes['DUT2']} | ${nodes['TG']}
81 | | And Interfaces in 3-node path are up
82 | | And IP addresses are set on interfaces
83 | | ... | ${dut1_node} | ${dut1_to_dut2} | ${dut1_ip_address} | ${prefix}
84 | | ... | ${dut1_node} | ${dut1_to_tg}   | ${net1_gw_address} | ${prefix}
85 | | ... | ${dut2_node} | ${dut2_to_dut1} | ${dut2_ip_address} | ${prefix}
86 | | ... | ${dut2_node} | ${dut2_to_tg}   | ${net2_gw_address} | ${prefix}
87 | | And VPP IP Probe | ${dut1_node} | ${dut1_to_dut2} | ${dut2_ip_address}
88 | | And VPP IP Probe | ${dut2_node} | ${dut2_to_dut1} | ${dut1_ip_address}
89 | | And Add Arp On Dut | ${dut2_node} | ${dut2_to_tg} | ${net2_host_address}
90 | | ... | ${tg_to_dut2_mac}
91 | | ${dut1_gre_interface} | ${dut1_gre_index}=
92 | | ... | When GRE tunnel interface is created and up
93 | | ... | ${dut1_node} | ${dut1_ip_address} | ${dut2_ip_address}
94 | | ${dut2_gre_interface} | ${dut2_gre_index}=
95 | | ... | And  GRE tunnel interface is created and up
96 | | ... | ${dut2_node} | ${dut2_ip_address} | ${dut1_ip_address}
97 | | And IP addresses are set on interfaces
98 | | ... | ${dut1_node} | ${dut1_gre_index} | ${dut1_gre_ip} | ${prefix}
99 | | ... | ${dut2_node} | ${dut2_gre_index} | ${dut2_gre_ip} | ${prefix}
100 | | And Vpp Route Add | ${dut1_node} | ${net2_address} | ${prefix}
101 | | ... | ${dut2_gre_ip} | ${dut1_gre_index}
102 | | Then Send Packet And Check Headers | ${tg_node}
103 | | ... | ${net1_host_address} | ${net2_host_address}
104 | | ... | ${tg_to_dut1} | ${tg_to_dut1_mac} | ${dut1_to_tg_mac}
105 | | ... | ${tg_to_dut2} | ${dut2_to_tg_mac} | ${tg_to_dut2_mac}
106
107 | TC02: DUT encapsulates IPv4 into GREoIPv4 tunnel - GRE header verification
108 | | [Documentation]
109 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
110 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure
111 | | ... | GREoIPv4 tunnel with IPv4 route towards TG. [Ver] Make TG send
112 | | ... | non-encapsulated ICMPv4 Echo Req to DUT; verify TG received
113 | | ... | GREoIPv4 encapsulated packet is correct. [Ref] RFC2784.
114 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
115 | | Given Path for 2-node testing is set
116 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
117 | | And Interfaces in 2-node path are up
118 | | And IP addresses are set on interfaces
119 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
120 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
121 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if2} | ${dut2_ip_address}
122 | | ... | ${tg_to_dut_if2_mac}
123 | | ${dut1_gre_interface} | ${dut1_gre_index}=
124 | | ... | When GRE tunnel interface is created and up
125 | | ... | ${dut_node} | ${dut1_ip_address} | ${dut2_ip_address}
126 | | And IP addresses are set on interfaces
127 | | ... | ${dut_node} | ${dut1_gre_index} | ${dut1_gre_ip} | ${prefix}
128 | | And Vpp Route Add | ${dut_node} | ${net2_address} | ${prefix}
129 | | ... | ${dut2_gre_ip} | ${dut1_gre_index}
130 | | Then Send ICMPv4 and check received GRE header
131 | | ... | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2}
132 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if2_mac}
133 | | ... | ${net1_host_address} | ${net2_host_address}
134 | | ... | ${dut1_ip_address} | ${dut2_ip_address}
135
136 | TC03: DUT decapsulates IPv4 from GREoIPv4 tunnel - IPv4 header verification
137 | | [Documentation]
138 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
139 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure
140 | | ... | GREoIPv4 tunnel towards TG. [Ver] Make TG send ICMPv4 Echo Req
141 | | ... | encapsulated into GREoIPv4 towards VPP; verify TG received IPv4
142 | | ... | de-encapsulated packet is correct. [Ref] RFC2784.
143 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
144 | | Given Path for 2-node testing is set
145 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
146 | | And Interfaces in 2-node path are up
147 | | And IP addresses are set on interfaces
148 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
149 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
150 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1} | ${net1_host_address}
151 | | ... | ${tg_to_dut_if1_mac}
152 | | ${dut1_gre_interface} | ${dut1_gre_index}=
153 | | ... | When GRE tunnel interface is created and up
154 | | ... | ${dut_node} | ${dut1_ip_address} | ${dut2_ip_address}
155 | | And IP addresses are set on interfaces
156 | | ... | ${dut_node} | ${dut1_gre_index} | ${dut1_gre_ip} | ${prefix}
157 | | Then Send GRE and check received ICMPv4 header
158 | | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if1}
159 | | ... | ${dut_to_tg_if2_mac} | ${tg_to_dut_if1_mac}
160 | | ... | ${net2_host_address} | ${net1_host_address}
161 | | ... | ${dut2_ip_address} | ${dut1_ip_address}
162
163 | TC04: DUT encapsulates IPv4 into GREoIPv4 different tunnels - GRE header verification
164 | | [Documentation]
165 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
166 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure two
167 | | ... | GRE tunnels with loopback's source address. Destination address of
168 | | ... | tunnels are routed via next hop address of DUT's to TG if2, where
169 | | ... | should be only GRE encapsulated packets. Each tunnel has IPv4 address
170 | | ... | and configured prefix routed through the tunnel. [Ver] Make TG send
171 | | ... | non-encapsulated ICMPv4 Echo Req to DUT; verify TG received GREoIPv4
172 | | ... | encapsulated packet is correct for each tunnel. [Ref] RFC2784.
173 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
174 | | Given Path for 2-node testing is set
175 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
176 | | And Interfaces in 2-node path are up
177 | | ${dut1_lo_index}= | And VPP Create loopback | ${dut_node}
178 | | And Set Interface State |  ${dut_node} | ${dut1_lo_index} | up
179 | | And IP addresses are set on interfaces
180 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
181 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
182 | | ... | ${dut_node} | ${dut1_lo_index} | ${dut1_lo_address} | ${32}
183 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if2} | ${dut2_ip_address}
184 | | ... | ${tg_to_dut_if2_mac}
185 | | And Vpp Route Add | ${dut_node} | ${tun0_dst} | ${32}
186 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
187 | | And Vpp Route Add | ${dut_node} | ${tun1_dst} | ${32}
188 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
189 | | ${dut1_gre0_interface} | ${dut1_gre0_index}=
190 | | ... | When GRE tunnel interface is created and up
191 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun0_dst}
192 | | ${dut1_gre1_interface} | ${dut1_gre1_index}=
193 | | ... | And GRE tunnel interface is created and up
194 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun1_dst}
195 | | And IP addresses are set on interfaces
196 | | ... | ${dut_node} | ${dut1_gre0_index} | ${dut_tun0_ip1} | ${prefix}
197 | | ... | ${dut_node} | ${dut1_gre1_index} | ${dut_tun1_ip1} | ${prefix}
198 | | And Vpp Route Add | ${dut_node} | ${net2_address} | ${prefix}
199 | |  ... | ${dut_tun0_ip2} | ${dut1_gre0_index}
200 | | And Vpp Route Add | ${dut_node} | ${net3_address} | ${prefix}
201 | | ... | ${dut_tun1_ip2} | ${dut1_gre1_index}
202 | | Then Send ICMPv4 and check received GRE header
203 | | ... | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2}
204 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if2_mac}
205 | | ... | ${net1_host_address} | ${net2_host_address}
206 | | ... | ${dut1_lo_address} | ${tun0_dst}
207 | | And Send ICMPv4 and check received GRE header
208 | | ... | ${tg_node} | ${tg_to_dut_if1} | ${tg_to_dut_if2}
209 | | ... | ${dut_to_tg_if1_mac} | ${tg_to_dut_if2_mac}
210 | | ... | ${net1_host_address} | ${net3_host_address}
211 | | ... | ${dut1_lo_address} | ${tun1_dst}
212
213 | TC05: DUT re-encapsulates IPv4 GRE into other GRE tunnel - GRE header verification
214 | | [Documentation]
215 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
216 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure two
217 | | ... | GRE tunnels with loopback's source address. Destination address of
218 | | ... | tunnels are routed via next hop address of DUT's to TG if2, where
219 | | ... | should be only GRE encapsulated packets. Each tunnel has IPv4 address
220 | | ... | and configured prefix routed through the tunnel. [Ver] Make TG send
221 | | ... | encapsulated IPv4 UDP to DUT; Encapsulated IP source is behind
222 | | ... | configured tunnel same as destination; verify TG received GREoIPv4
223 | | ... | encapsulated packet is correct. [Ref] RFC2784.
224 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
225 | | Given Path for 2-node testing is set
226 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
227 | | And Interfaces in 2-node path are up
228 | | ${dut1_lo_index}= | And VPP Create loopback | ${dut_node}
229 | | And Set Interface State |  ${dut_node} | ${dut1_lo_index} | up
230 | | And IP addresses are set on interfaces
231 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
232 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
233 | | ... | ${dut_node} | ${dut1_lo_index} | ${dut1_lo_address} | ${32}
234 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if2} | ${dut2_ip_address}
235 | | ... | ${tg_to_dut_if2_mac}
236 | | And Vpp Route Add | ${dut_node} | ${tun0_dst} | ${32}
237 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
238 | | And Vpp Route Add | ${dut_node} | ${tun1_dst} | ${32}
239 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
240 | | ${dut1_gre0_interface} | ${dut1_gre0_index}=
241 | | ... | When GRE tunnel interface is created and up
242 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun0_dst}
243 | | ${dut1_gre1_interface} | ${dut1_gre1_index}=
244 | | ... | And GRE tunnel interface is created and up
245 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun1_dst}
246 | | And IP addresses are set on interfaces
247 | | ... | ${dut_node} | ${dut1_gre0_index} | ${dut_tun0_ip1} | ${prefix}
248 | | ... | ${dut_node} | ${dut1_gre1_index} | ${dut_tun1_ip1} | ${prefix}
249 | | And Vpp Route Add | ${dut_node} | ${net2_address} | ${prefix}
250 | |  ... | ${dut_tun0_ip2} | ${dut1_gre0_index}
251 | | And Vpp Route Add | ${dut_node} | ${net3_address} | ${prefix}
252 | | ... | ${dut_tun1_ip2} | ${dut1_gre1_index}
253 | | Then Send GRE and check received GRE header
254 | | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if2}
255 | | ... | ${dut_to_tg_if2_mac} | ${tg_to_dut_if2_mac}
256 | | ... | ${dut1_lo_address} | ${tun0_dst}
257 | | ... | ${net3_host_address} | ${net2_host_address}
258 | | ... | ${tg_to_dut_if2_mac} | ${dut_to_tg_if2_mac}
259 | | ... | ${tun1_dst} | ${dut1_lo_address}
260
261 | TC06: DUT do not process GRE with wrong tunnel destination IP
262 | | [Documentation]
263 | | ... | [Top] TG=DUT1. [Enc] Eth-IPv4-ICMPv4 on TG_if1-DUT, \
264 | | ... | Eth-IPv4-GRE-IPv4-ICMPv4 on TG_if2_DUT. [Cfg] On DUT1 configure two
265 | | ... | GRE tunnels with loopback's source address. Destination address of
266 | | ... | tunnels are routed via next hop address of DUT's to TG if2, where
267 | | ... | should be only GRE encapsulated packets. On DUT's to TG if1 interface
268 | | ... | is configured test destination host MAC address. [Ver] Make TG send
269 | | ... | GRE encapsulated ICMPv4 Echo Req to DUT; verify TG received
270 | | ... | de-capsulated packet is correct, then send packet with wrong tunnel
271 | | ... | destination address. [Ref] RFC2784.
272 | | ... |
273 | | [Tags] | 3_NODE_DOUBLE_LINK_TOPO
274 | | Given Path for 2-node testing is set
275 | | ... | ${nodes['TG']} | ${nodes['DUT1']} | ${nodes['TG']}
276 | | And Interfaces in 2-node path are up
277 | | ${dut1_lo_index}= | And VPP Create loopback | ${dut_node}
278 | | And Set Interface State |  ${dut_node} | ${dut1_lo_index} | up
279 | | And IP addresses are set on interfaces
280 | | ... | ${dut_node} | ${dut_to_tg_if2} | ${dut1_ip_address} | ${prefix}
281 | | ... | ${dut_node} | ${dut_to_tg_if1} | ${net1_gw_address} | ${prefix}
282 | | ... | ${dut_node} | ${dut1_lo_index} | ${dut1_lo_address} | ${32}
283 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if1} | ${net1_host_address}
284 | | ... | ${tg_to_dut_if1_mac}
285 | | And Add Arp On Dut | ${dut_node} | ${dut_to_tg_if2} | ${dut2_ip_address}
286 | | ... | ${tg_to_dut_if2_mac}
287 | | And Vpp Route Add | ${dut_node} | ${tun0_dst} | ${32}
288 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
289 | | And Vpp Route Add | ${dut_node} | ${tun1_dst} | ${32}
290 | | ... | ${dut2_ip_address} | ${dut_to_tg_if2}
291 | | ${dut1_gre0_interface} | ${dut1_gre0_index}=
292 | | ... | When GRE tunnel interface is created and up
293 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun0_dst}
294 | | ${dut1_gre1_interface} | ${dut1_gre1_index}=
295 | | ... | And GRE tunnel interface is created and up
296 | | ... | ${dut_node} | ${dut1_lo_address} | ${tun1_dst}
297 | | And IP addresses are set on interfaces
298 | | ... | ${dut_node} | ${dut1_gre0_index} | ${dut_tun0_ip1} | ${prefix}
299 | | ... | ${dut_node} | ${dut1_gre1_index} | ${dut_tun1_ip1} | ${prefix}
300 | | Then Send GRE and check received ICMPv4 header
301 | | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if1}
302 | | ... | ${dut_to_tg_if2_mac} | ${tg_to_dut_if1_mac}
303 | | ... | ${net2_host_address} | ${net1_host_address}
304 | | ... | ${tun0_dst} | ${dut1_lo_address}
305 | | And Run Keyword And Expect Error | ICMP echo Rx timeout
306 | | ... | Send GRE and check received ICMPv4 header |
307 | | ... | ${tg_node} | ${tg_to_dut_if2} | ${tg_to_dut_if1}
308 | | ... | ${dut_to_tg_if2_mac} | ${tg_to_dut_if1_mac}
309 | | ... | ${net2_host_address} | ${net1_host_address}
310 | | ... | ${tun0_dst} | ${dut1_ip_address}