]>
Commit | Line | Data |
---|---|---|
df94c7e8 KK |
1 | #!/usr/bin/env python |
2 | # | |
3 | # Copyright (c) 2020 by VMware, Inc. ("VMware") | |
4 | # Used Copyright (c) 2018 by Network Device Education Foundation, | |
5 | # Inc. ("NetDEF") in this file. | |
6 | # | |
7 | # Permission to use, copy, modify, and/or distribute this software | |
8 | # for any purpose with or without fee is hereby granted, provided | |
9 | # that the above copyright notice and this permission notice appear | |
10 | # in all copies. | |
11 | # | |
12 | # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES | |
13 | # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
14 | # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR | |
15 | # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY | |
16 | # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, | |
17 | # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS | |
18 | # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE | |
19 | # OF THIS SOFTWARE. | |
20 | # | |
21 | ||
22 | """ | |
23 | Following tests are covered to test PIM BSM processing basic functionality: | |
24 | ||
25 | Test steps | |
26 | - Create topology (setup module) | |
27 | - Bring up topology | |
28 | ||
29 | Tests covered in this suite | |
30 | 1. Verify FRR router select higher IP BSR , when 2 BSR present in the network | |
31 | 2. Verify BSR and RP updated correctly after configuring as black hole address | |
32 | 3.1 Verify when new router added to the topology, FRR node will send | |
33 | unicast BSM to new router | |
34 | 3.2 Verify if no forwarding bit is set , FRR is not forwarding the | |
35 | BSM to other PIM nbrs | |
36 | 3.3 Verify multicast BSM is sent to new router when unicast BSM is disabled | |
37 | 4.1 Verfiy BSM arrived on non bsm capable interface is dropped and | |
38 | not processed | |
39 | 4.2 Verify group to RP info updated correctly in FRR node, after shut and | |
40 | no-shut of BSM enable interfaces | |
41 | 5. Verify static RP is preferred over BSR | |
42 | 6.1 Verify adding/deleting the group to rp mapping and RP priority | |
43 | multiple times | |
44 | 6.2 Verify RP and (*,G) detail after PIM process restart on FRR node | |
45 | 7.1 Verify BSM timeout on FRR1 | |
46 | 7.2 Verify RP state in FRR1 after Bootstrap timer expiry | |
47 | 8.1 Verify upstream interfaces(IIF) and join state are updated properly | |
48 | after BSM received for FRR | |
49 | 8.2 Verify IIF and OIL in "show ip pim state" updated properly after | |
50 | BSM received | |
51 | """ | |
52 | ||
53 | import os | |
54 | import sys | |
55 | import json | |
56 | import time | |
57 | import pytest | |
58 | ||
59 | # Save the Current Working Directory to find configuration files. | |
60 | CWD = os.path.dirname(os.path.realpath(__file__)) | |
61 | sys.path.append(os.path.join(CWD, "../")) | |
62 | sys.path.append(os.path.join(CWD, "../lib/")) | |
63 | ||
64 | # Required to instantiate the topology builder class. | |
65 | ||
66 | # pylint: disable=C0413 | |
67 | # Import topogen and topotest helpers | |
68 | from lib.topogen import Topogen, get_topogen | |
69 | from mininet.topo import Topo | |
70 | ||
71 | from lib.common_config import ( | |
72 | start_topology, | |
73 | write_test_header, | |
74 | write_test_footer, | |
75 | step, | |
76 | addKernelRoute, | |
77 | create_static_routes, | |
78 | iperfSendIGMPJoin, | |
79 | stop_router, | |
80 | start_router, | |
81 | shutdown_bringup_interface, | |
82 | kill_router_daemons, | |
83 | start_router_daemons, | |
84 | reset_config_on_routers, | |
85 | do_countdown, | |
86 | apply_raw_config, | |
87 | kill_iperf, | |
88 | run_frr_cmd, | |
89 | required_linux_kernel_version, | |
90 | topo_daemons, | |
91 | ) | |
92 | ||
93 | from lib.pim import ( | |
94 | create_pim_config, | |
95 | add_rp_interfaces_and_pim_config, | |
96 | reconfig_interfaces, | |
97 | scapy_send_bsr_raw_packet, | |
98 | find_rp_from_bsrp_info, | |
99 | verify_pim_grp_rp_source, | |
100 | verify_pim_bsr, | |
101 | verify_ip_mroutes, | |
102 | verify_join_state_and_timer, | |
103 | verify_pim_state, | |
104 | verify_upstream_iif, | |
105 | verify_igmp_groups, | |
106 | verify_ip_pim_upstream_rpf, | |
107 | enable_disable_pim_unicast_bsm, | |
108 | enable_disable_pim_bsm, | |
109 | clear_ip_mroute, | |
110 | clear_ip_pim_interface_traffic, | |
111 | verify_pim_interface_traffic, | |
112 | ) | |
113 | from lib.topolog import logger | |
114 | from lib.topojson import build_topo_from_json, build_config_from_json | |
115 | ||
116 | # Reading the data from JSON File for topology creation | |
117 | jsonFile = "{}/mcast_pim_bsmp_01.json".format(CWD) | |
118 | try: | |
119 | with open(jsonFile, "r") as topoJson: | |
120 | topo = json.load(topoJson) | |
121 | except IOError: | |
122 | assert False, "Could not read file {}".format(jsonFile) | |
123 | ||
124 | TOPOLOGY = """ | |
125 | ||
126 | b1_____ | |
127 | | | |
128 | | | |
129 | s1-----f1-----i1-----l1----r1 | |
130 | | | |
131 | ______| | |
132 | b2 | |
133 | ||
134 | b1 - BSR 1 | |
135 | b2 - BSR 2 | |
136 | s1 - Source | |
137 | f1 - FHR | |
138 | i1 - Intermediate Router (also RP) | |
139 | r1 - Receiver | |
140 | ||
141 | """ | |
142 | # Global variables | |
143 | NEXT_HOP1 = "70.0.0.1" | |
144 | NEXT_HOP2 = "65.0.0.1" | |
145 | BSR_IP_1 = "1.1.2.7" | |
146 | BSR_IP_2 = "10.2.1.1" | |
147 | BSR1_ADDR = "1.1.2.7/32" | |
148 | BSR2_ADDR = "10.2.1.1/32" | |
149 | ||
150 | ||
151 | class CreateTopo(Topo): | |
152 | """ | |
153 | Test BasicTopo - topology 1 | |
154 | ||
155 | * `Topo`: Topology object | |
156 | """ | |
157 | ||
158 | def build(self, *_args, **_opts): | |
159 | """Build function""" | |
160 | tgen = get_topogen(self) | |
161 | ||
162 | # Building topology from json file | |
163 | build_topo_from_json(tgen, topo) | |
164 | ||
165 | ||
166 | def setup_module(mod): | |
167 | """ | |
168 | Sets up the pytest environment | |
169 | ||
170 | * `mod`: module name | |
171 | """ | |
172 | ||
173 | # Required linux kernel version for this suite to run. | |
174 | result = required_linux_kernel_version("4.15") | |
175 | if result is not True: | |
176 | pytest.skip("Kernel requirements are not met") | |
177 | ||
178 | testsuite_run_time = time.asctime(time.localtime(time.time())) | |
179 | logger.info("Testsuite start time: {}".format(testsuite_run_time)) | |
180 | logger.info("=" * 40) | |
181 | logger.info("Master Topology: \n {}".format(TOPOLOGY)) | |
182 | ||
183 | logger.info("Running setup_module to create topology") | |
184 | ||
185 | # This function initiates the topology build with Topogen... | |
186 | tgen = Topogen(CreateTopo, mod.__name__) | |
187 | # ... and here it calls Mininet initialization functions. | |
188 | ||
189 | # get list of daemons needs to be started for this suite. | |
190 | daemons = topo_daemons(tgen, topo) | |
191 | ||
192 | # Starting topology, create tmp files which are loaded to routers | |
193 | # to start deamons and then start routers | |
194 | start_topology(tgen, daemons) | |
195 | ||
196 | # Don"t run this test if we have any failure. | |
197 | if tgen.routers_have_failure(): | |
198 | pytest.skip(tgen.errors) | |
199 | ||
200 | # Creating configuration from JSON | |
201 | build_config_from_json(tgen, topo) | |
202 | ||
203 | logger.info("Running setup_module() done") | |
204 | ||
205 | ||
206 | def teardown_module(): | |
207 | """Teardown the pytest environment""" | |
208 | ||
209 | logger.info("Running teardown_module to delete topology") | |
210 | ||
211 | tgen = get_topogen() | |
212 | ||
213 | # Stop toplogy and Remove tmp files | |
214 | tgen.stop_topology() | |
215 | ||
216 | logger.info( | |
217 | "Testsuite end time: {}".format(time.asctime(time.localtime(time.time()))) | |
218 | ) | |
219 | logger.info("=" * 40) | |
220 | ||
221 | ||
222 | ##################################################### | |
223 | # | |
224 | # Local APIs | |
225 | # | |
226 | ##################################################### | |
227 | ||
228 | ||
229 | def clear_bsrp_data(tgen, topo): | |
230 | ||
231 | """ | |
232 | clear bsm databas after test" | |
233 | Parameters | |
234 | ---------- | |
235 | * `tgen`: topogen object | |
236 | ||
237 | Usage | |
238 | ----- | |
239 | result = clear_bsrp_data(tgen, topo) | |
240 | Returns | |
241 | ------- | |
242 | errormsg(str) or True | |
243 | """ | |
244 | ||
245 | for dut in tgen.routers(): | |
246 | ||
247 | rnode = tgen.routers()[dut] | |
248 | ||
249 | logger.info("[DUT: %s]: clear_bsrp_data") | |
250 | ||
251 | run_frr_cmd(rnode, "clear ip pim bsr-data") | |
252 | ||
253 | return True | |
254 | ||
255 | ||
256 | def verify_state_incremented(state_before, state_after): | |
257 | """ | |
258 | API to compare interface traffic state incrementing | |
259 | ||
260 | Parameters | |
261 | ---------- | |
262 | * `state_before` : State dictionary for any particular instance | |
263 | * `state_after` : State dictionary for any particular instance | |
264 | """ | |
265 | ||
266 | for router, state_data in state_before.items(): | |
267 | for state, value in state_data.items(): | |
268 | if state_before[router][state] >= state_after[router][state]: | |
269 | errormsg = ( | |
270 | "[DUT: %s]: state %s value has not" | |
271 | " incremented, Initial value: %s, " | |
272 | "Current value: %s [FAILED!!]" | |
273 | % ( | |
274 | router, | |
275 | state, | |
276 | state_before[router][state], | |
277 | state_after[router][state], | |
278 | ) | |
279 | ) | |
280 | return errormsg | |
281 | ||
282 | logger.info( | |
283 | "[DUT: %s]: State %s value is " | |
284 | "incremented, Initial value: %s, Current value: %s" | |
285 | " [PASSED!!]", | |
286 | router, | |
287 | state, | |
288 | state_before[router][state], | |
289 | state_after[router][state], | |
290 | ) | |
291 | ||
292 | return True | |
293 | ||
294 | ||
295 | def pre_config_to_bsm(tgen, topo, tc_name, bsr, sender, receiver, fhr, rp, lhr, packet): | |
296 | """ | |
297 | API to do required configuration to send and receive BSR packet | |
298 | """ | |
299 | ||
300 | # Re-configure interfaces as per BSR packet | |
301 | result = reconfig_interfaces(tgen, topo, bsr, fhr, packet) | |
302 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
303 | ||
304 | # Create static routes | |
305 | if "bsr" in topo["routers"][bsr]["bsm"]["bsr_packets"][packet]: | |
306 | bsr_route = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["bsr"] | |
307 | next_hop = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["src_ip"].split( | |
308 | "/" | |
309 | )[0] | |
310 | next_hop_rp = topo["routers"][fhr]["links"][rp]["ipv4"].split("/")[0] | |
311 | next_hop_lhr = topo["routers"][rp]["links"][lhr]["ipv4"].split("/")[0] | |
312 | ||
313 | # Add static routes | |
314 | input_dict = { | |
315 | fhr: {"static_routes": [{"network": bsr_route, "next_hop": next_hop}]}, | |
316 | rp: {"static_routes": [{"network": bsr_route, "next_hop": next_hop_rp}]}, | |
317 | lhr: {"static_routes": [{"network": bsr_route, "next_hop": next_hop_lhr}]}, | |
318 | } | |
319 | ||
320 | result = create_static_routes(tgen, input_dict) | |
321 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
322 | ||
323 | # Add kernal route for source | |
324 | group = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["pkt_dst"] | |
325 | bsr_interface = topo["routers"][bsr]["links"][fhr]["interface"] | |
326 | result = addKernelRoute(tgen, bsr, bsr_interface, group) | |
327 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
328 | ||
329 | # RP Mapping | |
330 | rp_mapping = topo["routers"][bsr]["bsm"]["bsr_packets"][packet]["rp_mapping"] | |
331 | ||
332 | # Add interfaces in RP for all the RPs | |
333 | result = add_rp_interfaces_and_pim_config(tgen, topo, "lo", rp, rp_mapping) | |
334 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
335 | ||
336 | # Add kernal routes to sender and receiver | |
337 | for group, rp_list in rp_mapping.items(): | |
338 | mask = group.split("/")[1] | |
339 | if int(mask) == 32: | |
340 | group = group.split("/")[0] | |
341 | ||
342 | # Add kernal routes for sender | |
343 | s_interface = topo["routers"][sender]["links"][fhr]["interface"] | |
344 | result = addKernelRoute(tgen, sender, s_interface, group) | |
345 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
346 | ||
347 | # Add kernal routes for receiver | |
348 | r_interface = topo["routers"][receiver]["links"][lhr]["interface"] | |
349 | result = addKernelRoute(tgen, receiver, r_interface, group) | |
350 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
351 | ||
352 | # Add static routes for RPs in FHR and LHR | |
353 | next_hop_fhr = topo["routers"][rp]["links"][fhr]["ipv4"].split("/")[0] | |
354 | next_hop_lhr = topo["routers"][rp]["links"][lhr]["ipv4"].split("/")[0] | |
355 | input_dict = { | |
356 | fhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_fhr}]}, | |
357 | } | |
358 | result = create_static_routes(tgen, input_dict) | |
359 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
360 | ||
361 | input_dict = { | |
362 | lhr: {"static_routes": [{"network": rp_list, "next_hop": next_hop_lhr}]}, | |
363 | } | |
364 | result = create_static_routes(tgen, input_dict) | |
365 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
366 | return True | |
367 | ||
368 | ||
369 | ##################################################### | |
370 | # | |
371 | # Testcases | |
372 | # | |
373 | ##################################################### | |
374 | ||
375 | ||
376 | def test_BSR_higher_prefer_ip_p0(request): | |
377 | """ | |
378 | Verify FRR router select higher IP BSR , when 2 BSR present in the network | |
379 | ||
380 | Topology used: | |
381 | b1_____ | |
382 | | | |
383 | | | |
384 | s1-----f1-----i1-----l1----r1 | |
385 | | | |
386 | ______| | |
387 | b2 | |
388 | ||
389 | b1 - BSR 1 | |
390 | b2 - BSR 2 | |
391 | s1 - Source | |
392 | f1 - FHR | |
393 | i1 - Intermediate Router (also RP) | |
394 | r1 - Receiver | |
395 | """ | |
396 | ||
397 | tgen = get_topogen() | |
398 | tc_name = request.node.name | |
399 | write_test_header(tc_name) | |
400 | ||
401 | kill_iperf(tgen) | |
402 | clear_ip_mroute(tgen) | |
403 | reset_config_on_routers(tgen) | |
404 | clear_ip_pim_interface_traffic(tgen, topo) | |
405 | ||
406 | # Don"t run this test if we have any failure. | |
407 | if tgen.routers_have_failure(): | |
408 | pytest.skip(tgen.errors) | |
409 | ||
410 | reset_config_on_routers(tgen) | |
411 | step("pre-configure BSM packet") | |
412 | step("Configure cisco-1 as BSR1 1.1.2.7") | |
413 | result = pre_config_to_bsm( | |
414 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
415 | ) | |
416 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
417 | step("Configure cisco-1 as BSR1 10.2.1.1") | |
418 | result = pre_config_to_bsm( | |
419 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
420 | ) | |
421 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
422 | step("configuring loopback address of b1 and b2 as BSR") | |
423 | intf_lo_addr_b1 = topo["routers"]["b1"]["links"]["lo"]["ipv4"] | |
424 | intf_lo_addr_b2 = topo["routers"]["b2"]["links"]["lo"]["ipv4"] | |
425 | ||
426 | raw_config = { | |
427 | "b1": { | |
428 | "raw_config": [ | |
429 | "interface lo", | |
430 | "no ip address {}".format(intf_lo_addr_b1), | |
431 | "ip address {}".format(BSR1_ADDR), | |
432 | "ip pim", | |
433 | ] | |
434 | }, | |
435 | "b2": { | |
436 | "raw_config": [ | |
437 | "interface lo", | |
438 | "no ip address {}".format(intf_lo_addr_b2), | |
439 | "ip address {}".format(BSR2_ADDR), | |
440 | "ip pim", | |
441 | ] | |
442 | }, | |
443 | } | |
444 | result = apply_raw_config(tgen, raw_config) | |
445 | assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) | |
446 | ||
447 | GROUP_ADDRESS = "225.200.100.100" | |
448 | step("configuring static routes for both the BSR") | |
449 | ||
450 | next_hop_rp = topo["routers"]["f1"]["links"]["i1"]["ipv4"].split("/")[0] | |
451 | next_hop_lhr = topo["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0] | |
452 | ||
453 | input_dict = { | |
454 | "f1": { | |
455 | "static_routes": [ | |
456 | {"network": BSR1_ADDR, "next_hop": NEXT_HOP1}, | |
457 | {"network": BSR2_ADDR, "next_hop": NEXT_HOP2}, | |
458 | ] | |
459 | }, | |
460 | "i1": { | |
461 | "static_routes": [ | |
462 | {"network": BSR1_ADDR, "next_hop": next_hop_rp}, | |
463 | {"network": BSR2_ADDR, "next_hop": next_hop_rp}, | |
464 | ] | |
465 | }, | |
466 | "l1": { | |
467 | "static_routes": [ | |
468 | {"network": BSR1_ADDR, "next_hop": next_hop_lhr}, | |
469 | {"network": BSR2_ADDR, "next_hop": next_hop_lhr}, | |
470 | ] | |
471 | }, | |
472 | } | |
473 | ||
474 | result = create_static_routes(tgen, input_dict) | |
475 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
476 | ||
477 | # Use scapy to send pre-defined packet from senser to receiver | |
478 | step("Send BSR packet from b1 to FHR") | |
479 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
480 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
481 | ||
482 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
483 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
484 | do_countdown(5) | |
485 | ||
486 | dut = "l1" | |
487 | step("Verify if b1 chosen as BSR in f1") | |
488 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_1) | |
489 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
490 | ||
491 | group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"] | |
492 | step("Find the elected rp from bsrp-info in LHR l1") | |
493 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_1, group) | |
494 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
495 | ||
496 | step("Verify RP in LHR") | |
497 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
498 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
499 | ||
500 | step("Send BSR packet from b2 to FHR") | |
501 | result = scapy_send_bsr_raw_packet(tgen, topo, "b2", "f1", "packet3") | |
502 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
503 | ||
504 | dut = "l1" | |
505 | step("Verify if b2 chosen as BSR in f1") | |
506 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_2) | |
507 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
508 | ||
509 | step("Find the elected rp from bsrp-info in LHR l1") | |
510 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_2, group) | |
511 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
512 | ||
513 | step("Verify RP in LHR") | |
514 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
515 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
516 | ||
517 | step("Shut higher prefer BSR2 link f1 to b2") | |
518 | ||
519 | f1_b2_eth1 = topo["routers"]["f1"]["links"]["b2"]["interface"] | |
520 | shutdown_bringup_interface(tgen, "f1", "f1-b2-eth1", False) | |
521 | ||
522 | step("clearing bsr to timeout old BSR") | |
523 | clear_bsrp_data(tgen, topo) | |
524 | ||
525 | step("Send BSR packet from b1 and b2 to FHR") | |
526 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
527 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
528 | ||
529 | result = scapy_send_bsr_raw_packet(tgen, topo, "b2", "f1", "packet3") | |
530 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
531 | ||
532 | step("sleeping for 3 sec to leran new packet") | |
533 | do_countdown(3) | |
534 | step("verify BSR1 is become prefered RP") | |
535 | dut = "l1" | |
536 | ||
537 | step("Verify if b1 chosen as BSR in f1") | |
538 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_1) | |
539 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
540 | ||
541 | step("Find the elected rp from bsrp-info in LHR l1") | |
542 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_1, group) | |
543 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
544 | ||
545 | step("Verify RP in LHR") | |
546 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
547 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
548 | ||
549 | step("NoShut higher prefer BSR2 link f1 to b2") | |
550 | step("sleeping for 3 min to leran new packet") | |
551 | do_countdown(3) | |
552 | f1_b2_eth1 = topo["routers"]["f1"]["links"]["b2"]["interface"] | |
553 | shutdown_bringup_interface(tgen, "f1", "f1-b2-eth1", True) | |
554 | step("verify BSR2 is become prefered RP") | |
555 | dut = "l1" | |
556 | ||
557 | step("Send BSR packet from b1 and b2 to FHR") | |
558 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
559 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
560 | ||
561 | result = scapy_send_bsr_raw_packet(tgen, topo, "b2", "f1", "packet3") | |
562 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
563 | ||
564 | step("Verify if b2 chosen as BSR in f1") | |
565 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_2) | |
566 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
567 | ||
568 | step("Find the elected rp from bsrp-info in LHR l1") | |
569 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_2, group) | |
570 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
571 | ||
572 | step("Verify RP in LHR") | |
573 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
574 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
575 | ||
576 | step("Clear BSM database before moving to next case") | |
577 | clear_bsrp_data(tgen, topo) | |
578 | ||
579 | write_test_footer(tc_name) | |
580 | ||
581 | ||
582 | def test_BSR_CRP_with_blackhole_address_p1(request): | |
583 | """ | |
584 | Verify BSR and RP updated correctly after configuring as black hole address | |
585 | ||
586 | Topology used: | |
587 | b1_____ | |
588 | | | |
589 | | | |
590 | s1-----f1-----i1-----l1----r1 | |
591 | | | |
592 | ______| | |
593 | b2 | |
594 | ||
595 | b1 - BSR 1 | |
596 | b2 - BSR 2 | |
597 | s1 - Source | |
598 | f1 - FHR | |
599 | i1 - Intermediate Router (also RP) | |
600 | r1 - Receiver | |
601 | """ | |
602 | ||
603 | tgen = get_topogen() | |
604 | tc_name = request.node.name | |
605 | write_test_header(tc_name) | |
606 | ||
607 | kill_iperf(tgen) | |
608 | clear_ip_mroute(tgen) | |
609 | reset_config_on_routers(tgen) | |
610 | clear_ip_pim_interface_traffic(tgen, topo) | |
611 | ||
612 | # Don"t run this test if we have any failure. | |
613 | if tgen.routers_have_failure(): | |
614 | pytest.skip(tgen.errors) | |
615 | ||
616 | reset_config_on_routers(tgen) | |
617 | step("pre-configure BSM packet") | |
618 | step("Configure cisco-1 as BSR1 1.1.2.7") | |
619 | result = pre_config_to_bsm( | |
620 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
621 | ) | |
622 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
623 | ||
624 | step("configuring loopback address of b1 and b2 as BSR") | |
625 | intf_lo_addr_b1 = topo["routers"]["b1"]["links"]["lo"]["ipv4"] | |
626 | ||
627 | raw_config = { | |
628 | "b1": { | |
629 | "raw_config": [ | |
630 | "interface lo", | |
631 | "no ip address {}".format(intf_lo_addr_b1), | |
632 | "ip address {}".format(BSR1_ADDR), | |
633 | "ip pim", | |
634 | ] | |
635 | } | |
636 | } | |
637 | result = apply_raw_config(tgen, raw_config) | |
638 | assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result) | |
639 | ||
640 | GROUP_ADDRESS = "225.200.100.100" | |
641 | step("configuring static routes for both the BSR") | |
642 | ||
643 | next_hop_rp = topo["routers"]["f1"]["links"]["i1"]["ipv4"].split("/")[0] | |
644 | next_hop_lhr = topo["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0] | |
d99438d2 KK |
645 | next_hop_fhr = topo["routers"]["i1"]["links"]["f1"]["ipv4"].split("/")[0] |
646 | CRP = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["candidate_rp"] | |
df94c7e8 KK |
647 | |
648 | input_dict = { | |
df94c7e8 KK |
649 | "i1": {"static_routes": [{"network": BSR1_ADDR, "next_hop": next_hop_rp}]}, |
650 | "l1": {"static_routes": [{"network": BSR1_ADDR, "next_hop": next_hop_lhr}]}, | |
0b25370e DS |
651 | "f1": { |
652 | "static_routes": [ | |
653 | {"network": CRP, "next_hop": next_hop_fhr, "delete": True} | |
654 | ] | |
655 | }, | |
df94c7e8 KK |
656 | } |
657 | ||
658 | result = create_static_routes(tgen, input_dict) | |
659 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
660 | ||
661 | # Use scapy to send pre-defined packet from senser to receiver | |
662 | ||
663 | group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"] | |
df94c7e8 KK |
664 | step("waiting for BSR to timeout before configuring blackhole route") |
665 | clear_bsrp_data(tgen, topo) | |
666 | ||
667 | step("Configure black-hole address for BSR and candidate RP") | |
668 | input_dict = { | |
669 | "f1": { | |
670 | "static_routes": [{"network": [BSR1_ADDR, CRP], "next_hop": "blackhole"}] | |
671 | } | |
672 | } | |
673 | ||
674 | result = create_static_routes(tgen, input_dict) | |
675 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
676 | ||
677 | intf_f1_i1 = topo["routers"]["f1"]["links"]["i1"]["interface"] | |
678 | step("Verify bsm transit count is not increamented" "show ip pim interface traffic") | |
679 | state_dict = {"f1": {intf_f1_i1: ["bsmTx"]}} | |
680 | ||
681 | state_before = verify_pim_interface_traffic(tgen, state_dict) | |
682 | assert isinstance( | |
683 | state_before, dict | |
684 | ), "Testcase{} : Failed \n state_before is not dictionary \n " | |
685 | "Error: {}".format(tc_name, result) | |
686 | ||
687 | step("Sending BSR after Configure black hole address for BSR and candidate RP") | |
688 | step("Send BSR packet from b1 to FHR") | |
689 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
690 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
691 | ||
692 | dut = "l1" | |
693 | step("Find the elected rp from bsrp-info in LHR l1") | |
694 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_1, group) | |
695 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
696 | ||
697 | step("Verify if b1 chosen as BSR in l1") | |
698 | result = verify_pim_bsr(tgen, topo, "l1", BSR_IP_1, expected=False) | |
0b25370e DS |
699 | assert ( |
700 | result is not True | |
701 | ), "Testcase {} : Failed \n " "b1 is not chosen as BSR in l1 \n Error: {}".format( | |
5cbb02eb | 702 | tc_name, result |
0b25370e | 703 | ) |
df94c7e8 KK |
704 | |
705 | state_after = verify_pim_interface_traffic(tgen, state_dict) | |
706 | assert isinstance( | |
707 | state_after, dict | |
708 | ), "Testcase{} : Failed \n state_before is not dictionary \n " | |
709 | "Error: {}".format(tc_name, result) | |
710 | ||
711 | result = verify_state_incremented(state_before, state_after) | |
712 | assert result is not True, "Testcase{} : Failed Error: {}".format(tc_name, result) | |
713 | ||
714 | step("Remove black-hole address for BSR and candidate RP") | |
715 | input_dict = { | |
716 | "f1": { | |
717 | "static_routes": [ | |
5900cf46 | 718 | {"network": [BSR1_ADDR, CRP], "next_hop": "blackhole", "delete": True}, |
5980ad0a | 719 | {"network": BSR1_ADDR, "next_hop": NEXT_HOP1}, |
df94c7e8 KK |
720 | ] |
721 | } | |
722 | } | |
723 | ||
724 | result = create_static_routes(tgen, input_dict) | |
725 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
726 | ||
727 | step("Sending BSR after removing black-hole address for BSR and candidate RP") | |
728 | step("Send BSR packet from b1 to FHR") | |
729 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet9") | |
730 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
731 | ||
732 | step("Verify if b1 chosen as BSR in f1") | |
733 | result = verify_pim_bsr(tgen, topo, "f1", BSR_IP_1) | |
734 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
735 | ||
736 | dut = "l1" | |
737 | group = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"] | |
738 | step("Find the elected rp from bsrp-info in LHR l1") | |
739 | rp = find_rp_from_bsrp_info(tgen, dut, BSR_IP_1, group) | |
740 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
741 | ||
742 | step("Verify RP in LHR l1") | |
743 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
744 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
745 | ||
746 | step("clear BSM database before moving to next case") | |
747 | clear_bsrp_data(tgen, topo) | |
748 | ||
749 | write_test_footer(tc_name) | |
750 | ||
751 | ||
752 | def test_new_router_fwd_p0(request): | |
753 | """ | |
754 | 1. Verify when new router added to the topology, FRR node will send | |
755 | unicast BSM to new router | |
756 | 2. Verify if no forwarding bit is set , FRR is not forwarding the | |
757 | BSM to other PIM nbrs | |
758 | 3. Verify multicast BSM is sent to new router when unicast BSM is disabled | |
759 | ||
760 | Topology used: | |
761 | b1_____ | |
762 | | | |
763 | | | |
764 | s1-----f1-----i1-----l1----r1 | |
765 | | | |
766 | ______| | |
767 | b2 | |
768 | ||
769 | b1 - BSR 1 | |
770 | b2 - BSR 2 | |
771 | s1 - Source | |
772 | f1 - FHR | |
773 | i1 - Intermediate Router (also RP) | |
774 | r1 - Receiver | |
775 | ||
776 | """ | |
777 | ||
778 | tgen = get_topogen() | |
779 | tc_name = request.node.name | |
780 | write_test_header(tc_name) | |
781 | ||
782 | kill_iperf(tgen) | |
783 | clear_ip_mroute(tgen) | |
784 | reset_config_on_routers(tgen) | |
785 | clear_ip_pim_interface_traffic(tgen, topo) | |
786 | ||
787 | # Don"t run this test if we have any failure. | |
788 | if tgen.routers_have_failure(): | |
789 | pytest.skip(tgen.errors) | |
790 | ||
791 | reset_config_on_routers(tgen) | |
792 | ||
793 | result = pre_config_to_bsm( | |
794 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
795 | ) | |
796 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
797 | ||
798 | result = pre_config_to_bsm( | |
799 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
800 | ) | |
801 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
802 | ||
803 | GROUP_ADDRESS = "225.1.1.1" | |
804 | ||
805 | # Use scapy to send pre-defined packet from senser to receiver | |
806 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
807 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
808 | ||
809 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
810 | time.sleep(1) | |
811 | ||
812 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
813 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
814 | ||
815 | # Verify bsr state in FHR | |
816 | step("Verify if b1 chosen as BSR in f1") | |
817 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
818 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
819 | ||
820 | # Verify bsr state in i1 | |
821 | step("Verify if b1 chosen as BSR in i1") | |
822 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
823 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
824 | ||
825 | # Verify ip mroute | |
826 | iif = "l1-i1-eth0" | |
827 | src_addr = "*" | |
828 | oil = "l1-r1-eth1" | |
829 | ||
830 | step("Verify mroute populated on l1") | |
831 | result = verify_ip_mroutes(tgen, "l1", src_addr, GROUP_ADDRESS, iif, oil) | |
832 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
833 | ||
834 | # Reload i1 and l1 | |
835 | step("Reloading i1 and l1. Stop both. bring up l1 and then i1") | |
836 | stop_router(tgen, "i1") | |
837 | start_router(tgen, "i1") | |
838 | stop_router(tgen, "l1") | |
839 | start_router(tgen, "l1") | |
840 | ||
841 | # Verify bsr state in i1 | |
842 | step("Verify BSR in i1 after restart while no new bsm sent from b1") | |
843 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
844 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
845 | ||
846 | # Verify bsr state in l1 | |
847 | step("Verify no BSR in l1 as i1 would not forward the no-forward bsm") | |
848 | result = verify_pim_bsr(tgen, topo, "l1", bsr_ip, expected=False) | |
0b25370e DS |
849 | assert result is not True, ( |
850 | "Testcase {} : Failed \n " | |
5cbb02eb | 851 | "BSR data is present after no-forward bsm also \n Error: {}".format( |
0b25370e DS |
852 | tc_name, result |
853 | ) | |
854 | ) | |
df94c7e8 KK |
855 | |
856 | # unconfigure unicast bsm on f1-i1-eth2 | |
857 | step("unconfigure unicast bsm on f1-i1-eth2, will forward with only mcast") | |
858 | enable_disable_pim_unicast_bsm(tgen, "f1", "f1-i1-eth2", enable=False) | |
859 | ||
860 | # Reboot i1 to check if still bsm received with multicast address | |
861 | step("Reboot i1 to check if still bsm received with multicast address") | |
862 | stop_router(tgen, "i1") | |
863 | start_router(tgen, "i1") | |
864 | ||
865 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
866 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
867 | ||
868 | # Verify again if BSR is installed from bsm forwarded by f1 | |
869 | step("Verify again if BSR is installed from bsm forwarded by f1") | |
870 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
871 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
872 | ||
873 | # Use scapy to send pre-defined packet from senser to receiver | |
874 | step("Send another BSM packet from b1 which will reach l1(LHR)") | |
875 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2") | |
876 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
877 | do_countdown(5) | |
878 | ||
879 | # Verify ip mroute populated again | |
880 | step("Verify mroute again on l1 (lhr)") | |
881 | result = verify_ip_mroutes(tgen, "l1", src_addr, GROUP_ADDRESS, iif, oil) | |
882 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
883 | ||
884 | step("clear BSM database before moving to next case") | |
885 | clear_bsrp_data(tgen, topo) | |
886 | ||
887 | write_test_footer(tc_name) | |
888 | ||
889 | ||
890 | def test_int_bsm_config_p1(request): | |
891 | """ | |
892 | 1. Verfiy BSM arrived on non bsm capable interface is dropped and | |
893 | not processed | |
894 | 2. Verify group to RP info updated correctly in FRR node, after shut and | |
895 | no-shut of BSM enable interfaces | |
896 | ||
897 | Topology used: | |
898 | b1_____ | |
899 | | | |
900 | | | |
901 | s1-----f1-----i1-----l1----r1 | |
902 | | | |
903 | ______| | |
904 | b2 | |
905 | ||
906 | b1 - BSR 1 | |
907 | b2 - BSR 2 | |
908 | s1 - Source | |
909 | f1 - FHR | |
910 | i1 - Intermediate Router (also RP) | |
911 | r1 - Receiver | |
912 | ||
913 | """ | |
914 | ||
915 | tgen = get_topogen() | |
916 | tc_name = request.node.name | |
917 | write_test_header(tc_name) | |
918 | ||
919 | kill_iperf(tgen) | |
920 | clear_ip_mroute(tgen) | |
921 | reset_config_on_routers(tgen) | |
922 | clear_ip_pim_interface_traffic(tgen, topo) | |
923 | ||
924 | # Don"t run this test if we have any failure. | |
925 | if tgen.routers_have_failure(): | |
926 | pytest.skip(tgen.errors) | |
927 | ||
928 | reset_config_on_routers(tgen) | |
929 | ||
930 | result = pre_config_to_bsm( | |
931 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
932 | ) | |
933 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
934 | ||
935 | result = pre_config_to_bsm( | |
936 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
937 | ) | |
938 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
939 | ||
940 | GROUP_ADDRESS = "225.1.1.1" | |
941 | ||
942 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
943 | time.sleep(1) | |
944 | ||
945 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
946 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
947 | ||
948 | # Use scapy to send pre-defined packet from senser to receiver | |
949 | step("Send BSM packet from b1") | |
950 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
951 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
952 | ||
953 | # Verify bsr state in i1 | |
954 | step("Verify if b1 is chosen as BSR in i1") | |
955 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
956 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
957 | ||
958 | # check if mroute installed | |
959 | step("check if mroute installed in i1") | |
960 | iif = "lo" | |
961 | src_addr = "*" | |
962 | oil = "i1-l1-eth1" | |
963 | ||
964 | result = verify_ip_mroutes(tgen, "i1", src_addr, GROUP_ADDRESS, iif, oil) | |
965 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
966 | ||
967 | # wait till bsm rp age out | |
968 | step("wait till bsm rp age out") | |
969 | clear_bsrp_data(tgen, topo) | |
970 | ||
971 | # check if mroute uninstalled because of rp age out | |
972 | step("check if mroute uninstalled because of rp age out in i1") | |
973 | result = verify_ip_mroutes( | |
974 | tgen, "i1", src_addr, GROUP_ADDRESS, iif, oil, expected=False | |
975 | ) | |
0b25370e DS |
976 | assert ( |
977 | result is not True | |
978 | ), "Testcase {} : Failed \n " "Mroutes are still present \n Error: {}".format( | |
5cbb02eb | 979 | tc_name, result |
0b25370e | 980 | ) |
df94c7e8 KK |
981 | |
982 | # unconfigure bsm processing on f1 on f1-i1-eth2 | |
983 | step("unconfigure bsm processing on f1 in f1-i1-eth2, will drop bsm") | |
984 | result = enable_disable_pim_bsm(tgen, "f1", "f1-i1-eth2", enable=False) | |
985 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
986 | ||
987 | # Use scapy to send pre-defined packet from senser to receiver | |
988 | step("Send BSM packet from b1") | |
989 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
990 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
991 | ||
992 | # Verify bsr state in FHR | |
993 | step("Verify if b1 chosen as BSR in f1") | |
994 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
995 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
996 | ||
997 | # Verify bsr state in i1 | |
998 | step("Verify if b1 is not chosen as BSR in i1") | |
999 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip, expected=False) | |
0b25370e DS |
1000 | assert ( |
1001 | result is not True | |
1002 | ), "Testcase {} : Failed \n " "b1 is chosen as BSR in i1 \n Error: {}".format( | |
5cbb02eb | 1003 | tc_name, result |
0b25370e | 1004 | ) |
df94c7e8 KK |
1005 | |
1006 | # check if mroute still not installed because of rp not available | |
1007 | step("check if mroute still not installed because of rp not available") | |
1008 | result = verify_ip_mroutes( | |
1009 | tgen, "i1", src_addr, GROUP_ADDRESS, iif, oil, expected=False | |
1010 | ) | |
0b25370e DS |
1011 | assert result is not True, ( |
1012 | "Testcase {} : Failed \n " | |
1013 | "mroute installed but rp not available \n Error: {}".format(tc_name, result) | |
1014 | ) | |
df94c7e8 KK |
1015 | |
1016 | # configure bsm processing on i1 on f1-i1-eth2 | |
1017 | step("configure bsm processing on f1 in f1-i1-eth2, will accept bsm") | |
1018 | result = enable_disable_pim_bsm(tgen, "f1", "f1-i1-eth2", enable=True) | |
1019 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1020 | ||
1021 | # Use scapy to send pre-defined packet from senser to receiver | |
1022 | step("Send BSM packet again from b1") | |
1023 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet2") | |
1024 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1025 | ||
1026 | # Verify again if BSR is installed from bsm forwarded by f1 | |
1027 | step("Verify again if BSR is installed from bsm forwarded by f1") | |
1028 | result = verify_pim_bsr(tgen, topo, "i1", bsr_ip) | |
1029 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1030 | ||
1031 | # verify ip mroute populated | |
1032 | step("Verify ip mroute") | |
1033 | result = verify_ip_mroutes(tgen, "i1", src_addr, GROUP_ADDRESS, iif, oil) | |
1034 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1035 | ||
1036 | # Shut/No shut the bsm rpf interface and check mroute on lhr(l1) | |
1037 | step("Shut/No shut the bsm rpf interface and check mroute on lhr(l1)") | |
1038 | intf = "l1-i1-eth0" | |
1039 | shutdown_bringup_interface(tgen, "l1", intf, False) | |
1040 | shutdown_bringup_interface(tgen, "l1", intf, True) | |
1041 | ||
1042 | iif = "l1-i1-eth0" | |
1043 | oil = "l1-r1-eth1" | |
1044 | ||
1045 | result = verify_ip_mroutes(tgen, "l1", src_addr, GROUP_ADDRESS, iif, oil) | |
1046 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1047 | ||
1048 | step("clear BSM database before moving to next case") | |
1049 | clear_bsrp_data(tgen, topo) | |
1050 | ||
1051 | write_test_footer(tc_name) | |
1052 | ||
1053 | ||
1054 | def test_static_rp_override_p1(request): | |
1055 | """ | |
1056 | Verify static RP is preferred over BSR | |
1057 | ||
1058 | Topology used: | |
1059 | b1_____ | |
1060 | | | |
1061 | | | |
1062 | s1-----f1-----i1-----l1----r1 | |
1063 | | | |
1064 | ______| | |
1065 | b2 | |
1066 | ||
1067 | b1 - BSR 1 | |
1068 | b2 - BSR 2 | |
1069 | s1 - Source | |
1070 | f1 - FHR | |
1071 | i1 - Intermediate Router (also RP) | |
1072 | r1 - Receiver | |
1073 | ||
1074 | """ | |
1075 | ||
1076 | tgen = get_topogen() | |
1077 | tc_name = request.node.name | |
1078 | write_test_header(tc_name) | |
1079 | ||
1080 | kill_iperf(tgen) | |
1081 | clear_ip_mroute(tgen) | |
1082 | reset_config_on_routers(tgen) | |
1083 | clear_ip_pim_interface_traffic(tgen, topo) | |
1084 | ||
1085 | # Don"t run this test if we have any failure. | |
1086 | if tgen.routers_have_failure(): | |
1087 | pytest.skip(tgen.errors) | |
1088 | ||
1089 | reset_config_on_routers(tgen) | |
1090 | ||
1091 | result = pre_config_to_bsm( | |
1092 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1093 | ) | |
1094 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1095 | ||
1096 | result = pre_config_to_bsm( | |
1097 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1098 | ) | |
1099 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1100 | ||
1101 | GROUP_ADDRESS = "225.1.1.1" | |
1102 | # Use scapy to send pre-defined packet from senser to receiver | |
1103 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1104 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1105 | ||
1106 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
1107 | time.sleep(1) | |
1108 | ||
1109 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1110 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1111 | ||
1112 | # Verify bsr state in FHR | |
1113 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1114 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1115 | ||
1116 | # Check igmp groups | |
1117 | step("Verify IGMP groups in LHR") | |
1118 | dut = "l1" | |
1119 | intf = "l1-r1-eth1" | |
1120 | result = verify_igmp_groups(tgen, dut, intf, GROUP_ADDRESS) | |
1121 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1122 | ||
1123 | group = "225.1.1.1/32" | |
1124 | ||
1125 | # Find the elected rp from bsrp-info | |
1126 | step("Find the elected rp from bsrp-info in LHR l1") | |
1127 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1128 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1129 | ||
1130 | # Check RP detail in LHR | |
1131 | step("Verify that BS RP in LHR l1") | |
1132 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
1133 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1134 | ||
1135 | iif = "l1-i1-eth0" | |
1136 | # Verify upstream rpf for 225.1.1.1 is chosen as rp1 | |
1137 | step("Verify upstream rpf for 225.1.1.1 is chosen as bsrp") | |
1138 | result = verify_ip_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, rp[group]) | |
1139 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1140 | ||
1141 | # Configure a static rp for the group 225.1.1.1/32 | |
1142 | step("Configure a static rp 33.33.33.33 for the group 225.1.1.1/32 in l1") | |
1143 | input_dict = { | |
1144 | "l1": { | |
1145 | "pim": { | |
1146 | "rp": [ | |
5980ad0a DS |
1147 | { |
1148 | "rp_addr": "33.33.33.33", | |
1149 | "group_addr_range": ["225.1.1.1/32"], | |
1150 | } | |
df94c7e8 KK |
1151 | ] |
1152 | } | |
1153 | } | |
1154 | } | |
1155 | result = create_pim_config(tgen, topo, input_dict) | |
1156 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1157 | ||
1158 | # Verify that static rp is configured over bsrp | |
1159 | static_rp = "33.33.33.33" | |
1160 | step("Verify that Static RP in LHR in l1") | |
1161 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "Static", static_rp) | |
1162 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1163 | ||
1164 | # Verify if upstream also reflects the static rp | |
1165 | step("Verify upstream rpf for 225.1.1.1 is chosen as static in l1") | |
1166 | result = verify_ip_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, static_rp) | |
1167 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1168 | ||
1169 | # delete static rp for the group 225.1.1.1/32 | |
1170 | step("Delete static rp 33.33.33.33 for the group 225.1.1.1/32 in l1") | |
1171 | input_dict = { | |
1172 | "l1": { | |
1173 | "pim": { | |
1174 | "rp": [ | |
1175 | { | |
1176 | "rp_addr": "33.33.33.33", | |
1177 | "group_addr_range": ["225.1.1.1/32"], | |
1178 | "delete": True, | |
1179 | } | |
1180 | ] | |
1181 | } | |
1182 | } | |
1183 | } | |
1184 | result = create_pim_config(tgen, topo, input_dict) | |
1185 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1186 | ||
1187 | # Verify if bsrp is installed back for the group 225.1.1.1/32 | |
1188 | step("Verify that BS RP in installed in LHR") | |
1189 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
1190 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1191 | ||
1192 | # Verify upstream rpf for 225.1.1.1 is chosen as bsrp | |
1193 | step("Verify upstream rpf for 225.1.1.1 is chosen as bsrp in l1") | |
1194 | result = verify_ip_pim_upstream_rpf(tgen, topo, dut, iif, GROUP_ADDRESS, rp[group]) | |
1195 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1196 | ||
1197 | step("clear BSM database before moving to next case") | |
1198 | clear_bsrp_data(tgen, topo) | |
1199 | ||
1200 | write_test_footer(tc_name) | |
1201 | ||
1202 | ||
1203 | def test_bsmp_stress_add_del_restart_p2(request): | |
1204 | """ | |
1205 | 1. Verify adding/deleting the group to rp mapping and RP priority | |
1206 | multiple times | |
1207 | 2. Verify RP and (*,G) detail after PIM process restart on FRR node | |
1208 | ||
1209 | Topology used: | |
1210 | b1_____ | |
1211 | | | |
1212 | | | |
1213 | s1-----f1-----i1-----l1----r1 | |
1214 | | | |
1215 | ______| | |
1216 | b2 | |
1217 | ||
1218 | b1 - BSR 1 | |
1219 | b2 - BSR 2 | |
1220 | s1 - Source | |
1221 | f1 - FHR | |
1222 | i1 - Intermediate Router (also RP) | |
1223 | r1 - Receiver | |
1224 | ||
1225 | """ | |
1226 | ||
1227 | tgen = get_topogen() | |
1228 | tc_name = request.node.name | |
1229 | write_test_header(tc_name) | |
1230 | ||
1231 | kill_iperf(tgen) | |
1232 | clear_ip_mroute(tgen) | |
1233 | reset_config_on_routers(tgen) | |
1234 | clear_ip_pim_interface_traffic(tgen, topo) | |
1235 | ||
1236 | # Don"t run this test if we have any failure. | |
1237 | if tgen.routers_have_failure(): | |
1238 | pytest.skip(tgen.errors) | |
1239 | ||
1240 | reset_config_on_routers(tgen) | |
1241 | ||
1242 | result = pre_config_to_bsm( | |
1243 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1244 | ) | |
1245 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1246 | ||
1247 | result = pre_config_to_bsm( | |
1248 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1249 | ) | |
1250 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1251 | ||
1252 | GROUP_ADDRESS = "225.1.1.1" | |
1253 | ||
1254 | # Use scapy to send pre-defined packet from senser to receiver | |
1255 | step("Send BSR packet from b1 to FHR") | |
1256 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1257 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1258 | ||
1259 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
1260 | time.sleep(1) | |
1261 | ||
1262 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1263 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1264 | ||
1265 | # Verify bsr state in FHR | |
1266 | step("Verify if b1 is chosen as bsr in f1") | |
1267 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1268 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1269 | ||
1270 | dut = "l1" | |
1271 | group = "225.1.1.0/24" | |
1272 | # Find the elected rp from bsrp-info | |
1273 | step("Find the elected rp from bsrp-info in LHR l1") | |
1274 | rp1 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1275 | assert rp1 is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1276 | ||
1277 | # Check RP detail in LHR | |
1278 | step("Verify RP in LHR l1") | |
1279 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp1[group]) | |
1280 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1281 | ||
1282 | # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24 | |
1283 | step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24") | |
1284 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet6") | |
1285 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1286 | ||
1287 | # Find the elected rp from bsrp-info | |
1288 | step("Find the elected rp from bsrp-info in LHR l1") | |
1289 | rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1290 | assert rp2 is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1291 | logger.info("RP old: %s RP2 new: %s", rp1[group], rp2[group]) | |
1292 | ||
1293 | # Verify is the rp is different now | |
1294 | assert rp1[group] != rp2[group], "Testcase {} :Failed \n Error {}".format( | |
1295 | tc_name, result | |
1296 | ) | |
1297 | ||
1298 | rp_add1 = rp1[group] | |
1299 | rp_add2 = rp2[group] | |
1300 | ||
1301 | # Verify if that rp is installed | |
1302 | step("Verify new RP in LHR installed") | |
1303 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add2) | |
1304 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1305 | ||
1306 | step("Change rp priority in the bsm and send multiple times") | |
1307 | ||
1308 | for i in range(4): | |
1309 | # Send BSR pkt from b1 after putting back high prio rp for 225.1.1.0/24 | |
1310 | step("Send BSM from b1 to FHR put back high prio rp for 225.1.1.0/24") | |
1311 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1312 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1313 | ||
1314 | # Find the elected rp from bsrp-info | |
1315 | step("Find the elected rp from bsrp-info in LHR") | |
1316 | rp2 = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1317 | assert rp2 is not {}, "Testcase {} :Failed \n Error : RP not Found".format( | |
1318 | tc_name | |
1319 | ) | |
1320 | ||
1321 | # Verify is the rp is different now | |
1322 | step("Verify now old RP is elected again") | |
1323 | assert ( | |
1324 | rp_add1 == rp2[group] | |
1325 | ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format( | |
5980ad0a DS |
1326 | tc_name, |
1327 | rp_add1, | |
df94c7e8 KK |
1328 | ) |
1329 | ||
1330 | # Verify if that rp is installed | |
1331 | step("Verify old RP in LHR installed") | |
1332 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add1) | |
1333 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1334 | ||
1335 | # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24 | |
1336 | step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24") | |
1337 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet6") | |
1338 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1339 | ||
1340 | # Verify if that rp is installed | |
1341 | step("Verify new RP(rp2) in LHR installed") | |
1342 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add2) | |
1343 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1344 | ||
1345 | # Restart pimd | |
1346 | step("Restarting pimd in LHR") | |
1347 | kill_router_daemons(tgen, "l1", ["pimd"]) | |
1348 | start_router_daemons(tgen, "l1", ["pimd"]) | |
1349 | logger.info("Restarting done") | |
1350 | ||
1351 | # Verify if that rp is installed | |
1352 | step("Verify old RP in LHR installed") | |
1353 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp_add2) | |
1354 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1355 | ||
1356 | # Send IGMP join to LHR | |
1357 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1358 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1359 | ||
1360 | do_countdown(5) | |
1361 | ||
1362 | # VErify mroute created after pimd restart | |
1363 | step("VErify mroute created after pimd restart") | |
1364 | iif = "l1-i1-eth0" | |
1365 | src_addr = "*" | |
1366 | oil = "l1-r1-eth1" | |
1367 | result = verify_ip_mroutes(tgen, "l1", src_addr, GROUP_ADDRESS, iif, oil) | |
1368 | assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result) | |
1369 | ||
1370 | write_test_footer(tc_name) | |
1371 | ||
1372 | ||
1373 | def test_BSM_timeout_p0(request): | |
1374 | """ | |
1375 | Verify BSM timeout on FRR1 | |
1376 | Verify RP state in FRR1 after Bootstrap timer expiry | |
1377 | ||
1378 | Topology used: | |
1379 | b1_____ | |
1380 | | | |
1381 | | | |
1382 | s1-----f1-----i1-----l1----r1 | |
1383 | | | |
1384 | ______| | |
1385 | b2 | |
1386 | ||
1387 | b1 - BSR 1 | |
1388 | b2 - BSR 2 | |
1389 | s1 - Source | |
1390 | f1 - FHR | |
1391 | i1 - Intermediate Router (also RP) | |
1392 | r1 - Receiver | |
1393 | ||
1394 | """ | |
1395 | ||
1396 | tgen = get_topogen() | |
1397 | tc_name = request.node.name | |
1398 | write_test_header(tc_name) | |
1399 | ||
1400 | kill_iperf(tgen) | |
1401 | clear_ip_mroute(tgen) | |
1402 | reset_config_on_routers(tgen) | |
1403 | clear_ip_pim_interface_traffic(tgen, topo) | |
1404 | ||
1405 | # Don"t run this test if we have any failure. | |
1406 | if tgen.routers_have_failure(): | |
1407 | pytest.skip(tgen.errors) | |
1408 | ||
1409 | result = pre_config_to_bsm( | |
1410 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1411 | ) | |
1412 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1413 | ||
1414 | result = pre_config_to_bsm( | |
1415 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1416 | ) | |
1417 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1418 | ||
1419 | GROUP_ADDRESS = "225.1.1.1" | |
1420 | ||
1421 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
1422 | ||
1423 | # Use scapy to send pre-defined packet from senser to receiver | |
1424 | step("send BSR packet from b1") | |
1425 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1426 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1427 | ||
1428 | # Send IGMP join for group 225.1.1.1 from receiver | |
1429 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1430 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1431 | ||
1432 | # Verify bsr state in FHR | |
1433 | step("Verify bsr state in FHR f1") | |
1434 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1435 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1436 | ||
1437 | # Verify ip mroute in LHR | |
1438 | step(" Verify ip mroute in LHR l1") | |
1439 | dut = "l1" | |
1440 | iif = "l1-i1-eth0" | |
1441 | src_addr = "*" | |
1442 | oil = "l1-r1-eth1" | |
1443 | result = verify_ip_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil) | |
1444 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1445 | ||
1446 | # Verify join state and join timer | |
1447 | step("Verify join state and join timer in lhr l1") | |
1448 | result = verify_join_state_and_timer(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
1449 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1450 | ||
1451 | # Verify upstream IIF interface | |
1452 | step("Verify upstream IIF interface in LHR l1") | |
1453 | result = verify_upstream_iif(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
1454 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1455 | ||
1456 | # Verify RP mapping | |
1457 | dut = "l1" | |
1458 | group = "225.1.1.1/32" | |
1459 | step("Verify RP mapping in LHR l1") | |
1460 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1461 | assert rp != {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1462 | ||
1463 | logger.info("Waiting for 130 secs to check BSR timeout") | |
1464 | clear_bsrp_data(tgen, topo) | |
1465 | ||
1466 | # Verify if bsr has aged out | |
1467 | step("Verify if bsr has aged out in f1") | |
1468 | no_bsr_ip = "0.0.0.0" | |
1469 | result = verify_pim_bsr(tgen, topo, "f1", no_bsr_ip) | |
1470 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1471 | ||
1472 | result = verify_pim_grp_rp_source( | |
1473 | tgen, topo, "f1", group, rp_source="BSR", expected=False | |
1474 | ) | |
1475 | ||
0b25370e DS |
1476 | assert ( |
1477 | result is not True | |
1478 | ), "Testcase {} : Failed \n " "bsr has not aged out in f1 \n Error: {}".format( | |
5cbb02eb | 1479 | tc_name, result |
0b25370e | 1480 | ) |
df94c7e8 KK |
1481 | |
1482 | # Verify RP mapping removed after hold timer expires | |
1483 | group = "225.1.1.1/32" | |
1484 | step("Verify RP mapping removed after hold timer expires in l1") | |
1485 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1486 | assert rp == {}, "Testcase {} :Failed \n Error : RP found when not expected".format( | |
1487 | tc_name | |
1488 | ) | |
1489 | ||
1490 | # Verify iif is unknown after RP timeout | |
1491 | step("Verify iif is unknown after RP timeout in l1") | |
1492 | iif = "Unknown" | |
1493 | result = verify_upstream_iif( | |
1494 | tgen, dut, iif, src_addr, GROUP_ADDRESS, joinState="NotJoined" | |
1495 | ) | |
1496 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1497 | ||
1498 | # Verify join state and join timer | |
1499 | step("Verify join state and join timer in l1") | |
1500 | iif = "l1-i1-eth0" | |
1501 | result = verify_join_state_and_timer( | |
1502 | tgen, dut, iif, src_addr, GROUP_ADDRESS, expected=False | |
1503 | ) | |
0b25370e DS |
1504 | assert result is not True, ( |
1505 | "Testcase {} : Failed \n " | |
5cbb02eb | 1506 | "join state is up and join timer is running in l1 \n Error: {}".format( |
0b25370e DS |
1507 | tc_name, result |
1508 | ) | |
1509 | ) | |
df94c7e8 KK |
1510 | |
1511 | # Verify ip mroute is not installed | |
1512 | step("Verify mroute not installed in l1") | |
1513 | result = verify_ip_mroutes( | |
1514 | tgen, dut, src_addr, GROUP_ADDRESS, iif, oil, expected=False | |
1515 | ) | |
0b25370e DS |
1516 | assert ( |
1517 | result is not True | |
1518 | ), "Testcase {} : Failed \n " "mroute installed in l1 \n Error: {}".format( | |
5cbb02eb | 1519 | tc_name, result |
0b25370e | 1520 | ) |
df94c7e8 KK |
1521 | |
1522 | step("clear BSM database before moving to next case") | |
1523 | clear_bsrp_data(tgen, topo) | |
1524 | ||
1525 | write_test_footer(tc_name) | |
1526 | ||
1527 | ||
1528 | def test_iif_join_state_p0(request): | |
1529 | """ | |
1530 | 1. Verify upstream interfaces(IIF) and join state are updated properly | |
1531 | after BSM received for FRR | |
1532 | 2. Verify IIF and OIL in "show ip pim state" updated properly after | |
1533 | BSM received | |
1534 | ||
1535 | Topology used: | |
1536 | b1_____ | |
1537 | | | |
1538 | | | |
1539 | s1-----f1-----i1-----l1----r1 | |
1540 | | | |
1541 | ______| | |
1542 | b2 | |
1543 | ||
1544 | b1 - BSR 1 | |
1545 | b2 - BSR 2 | |
1546 | s1 - Source | |
1547 | f1 - FHR | |
1548 | i1 - Intermediate Router (also RP) | |
1549 | r1 - Receiver | |
1550 | ||
1551 | """ | |
1552 | ||
1553 | tgen = get_topogen() | |
1554 | tc_name = request.node.name | |
1555 | write_test_header(tc_name) | |
1556 | ||
1557 | kill_iperf(tgen) | |
1558 | clear_ip_mroute(tgen) | |
1559 | reset_config_on_routers(tgen) | |
1560 | clear_ip_pim_interface_traffic(tgen, topo) | |
1561 | ||
1562 | # Don"t run this test if we have any failure. | |
1563 | if tgen.routers_have_failure(): | |
1564 | pytest.skip(tgen.errors) | |
1565 | ||
1566 | reset_config_on_routers(tgen) | |
1567 | ||
1568 | result = pre_config_to_bsm( | |
1569 | tgen, topo, tc_name, "b1", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1570 | ) | |
1571 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1572 | ||
1573 | result = pre_config_to_bsm( | |
1574 | tgen, topo, tc_name, "b2", "s1", "r1", "f1", "i1", "l1", "packet1" | |
1575 | ) | |
1576 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1577 | ||
1578 | GROUP_ADDRESS = "225.1.1.1" | |
1579 | ||
1580 | # Use scapy to send pre-defined packet from senser to receiver | |
1581 | result = scapy_send_bsr_raw_packet(tgen, topo, "b1", "f1", "packet1") | |
1582 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1583 | ||
1584 | bsr_ip = topo["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0] | |
1585 | time.sleep(1) | |
1586 | ||
1587 | result = iperfSendIGMPJoin(tgen, "r1", GROUP_ADDRESS, join_interval=1) | |
1588 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1589 | ||
1590 | # Verify bsr state in FHR | |
1591 | result = verify_pim_bsr(tgen, topo, "f1", bsr_ip) | |
1592 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1593 | ||
1594 | # Check igmp groups | |
1595 | step("Verify IGMP groups in LHR l1") | |
1596 | dut = "l1" | |
1597 | intf = "l1-r1-eth1" | |
1598 | result = verify_igmp_groups(tgen, dut, intf, GROUP_ADDRESS) | |
1599 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1600 | ||
1601 | group = "225.1.1.1/32" | |
1602 | ||
1603 | # Find the elected rp from bsrp-info | |
1604 | step("Find the elected rp from bsrp-info in LHR l1") | |
1605 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1606 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1607 | ||
1608 | # Check RP detail in LHR | |
1609 | step("Verify RP in LHR l1") | |
1610 | result = verify_pim_grp_rp_source(tgen, topo, dut, group, "BSR", rp[group]) | |
1611 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1612 | ||
1613 | # Verify join state and join timer | |
1614 | step("Verify join state and join timer l1") | |
1615 | iif = "l1-i1-eth0" | |
1616 | src_addr = "*" | |
1617 | result = verify_join_state_and_timer(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
1618 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1619 | ||
1620 | # Verify upstream IIF interface | |
1621 | step("Verify upstream IIF interface l1") | |
1622 | result = verify_upstream_iif(tgen, dut, iif, src_addr, GROUP_ADDRESS) | |
1623 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1624 | ||
1625 | # Verify IIF/OIL in pim state | |
1626 | oil = "l1-r1-eth1" | |
1627 | result = verify_pim_state(tgen, dut, iif, oil, GROUP_ADDRESS) | |
1628 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1629 | ||
1630 | # Verify ip mroute | |
1631 | src_addr = "*" | |
1632 | step("Verify ip mroute in l1") | |
1633 | result = verify_ip_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil) | |
1634 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1635 | ||
1636 | # Make RP unreachanble in LHR | |
1637 | step("Make RP unreachanble in LHR l1") | |
1638 | rp = find_rp_from_bsrp_info(tgen, dut, bsr_ip, group) | |
1639 | assert rp is not {}, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1640 | ||
1641 | next_hop_lhr = topo["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0] | |
1642 | ||
1643 | rp_ip = rp[group] + "/32" | |
1644 | input_dict = { | |
1645 | "l1": { | |
1646 | "static_routes": [ | |
1647 | {"network": rp_ip, "next_hop": next_hop_lhr, "delete": True} | |
1648 | ] | |
1649 | } | |
1650 | } | |
1651 | result = create_static_routes(tgen, input_dict) | |
1652 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1653 | ||
1654 | # Check RP unreachable | |
1655 | step("Check RP unreachability") | |
1656 | iif = "Unknown" | |
1657 | result = verify_upstream_iif( | |
1658 | tgen, dut, iif, src_addr, GROUP_ADDRESS, joinState="NotJoined" | |
1659 | ) | |
1660 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1661 | ||
1662 | # Verify that it is not installed | |
1663 | step("Verify that it is not installed") | |
1664 | iif = "<iif?>" | |
1665 | result = verify_pim_state(tgen, dut, iif, oil, GROUP_ADDRESS, installed_fl=0) | |
1666 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1667 | ||
1668 | # Verify mroute not installed | |
1669 | step("Verify mroute not installed") | |
1670 | result = verify_ip_mroutes( | |
1671 | tgen, dut, src_addr, GROUP_ADDRESS, iif, oil, expected=False | |
1672 | ) | |
0b25370e DS |
1673 | assert ( |
1674 | result is not True | |
1675 | ), "Testcase {} : Failed \n " "mroute installed in l1 \n Error: {}".format( | |
5cbb02eb | 1676 | tc_name, result |
0b25370e | 1677 | ) |
df94c7e8 KK |
1678 | |
1679 | # Add back route for RP to make it reachable | |
1680 | step("Add back route for RP to make it reachable") | |
1681 | input_dict = { | |
5980ad0a DS |
1682 | "l1": { |
1683 | "static_routes": [ | |
1684 | { | |
1685 | "network": rp_ip, | |
1686 | "next_hop": next_hop_lhr, | |
1687 | } | |
1688 | ] | |
1689 | } | |
df94c7e8 KK |
1690 | } |
1691 | result = create_static_routes(tgen, input_dict) | |
1692 | assert result is True, "Testcase {} :Failed \n Error {}".format(tc_name, result) | |
1693 | ||
1694 | # Verify that (*,G) installed in mroute again | |
1695 | iif = "l1-i1-eth0" | |
1696 | result = verify_ip_mroutes(tgen, dut, src_addr, GROUP_ADDRESS, iif, oil) | |
1697 | assert result is True, "Testcase {}:Failed \n Error: {}".format(tc_name, result) | |
1698 | ||
1699 | step("clear BSM database before moving to next case") | |
1700 | clear_bsrp_data(tgen, topo) | |
1701 | ||
1702 | write_test_footer(tc_name) | |
1703 | ||
1704 | ||
1705 | if __name__ == "__main__": | |
1706 | args = ["-s"] + sys.argv[1:] | |
1707 | sys.exit(pytest.main(args)) |