]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/multicast_pim6_static_rp_topo1/test_multicast_pim6_static_rp2.py
Merge pull request #12634 from anlancs/fix/lib-seq-adjust-return-value
[mirror_frr.git] / tests / topotests / multicast_pim6_static_rp_topo1 / test_multicast_pim6_static_rp2.py
1 #!/usr/bin/env python
2
3 #
4 # Copyright (c) 2022 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation,
6 # Inc. ("NetDEF") in this file.
7 #
8 # Permission to use, copy, modify, and/or distribute this software
9 # for any purpose with or without fee is hereby granted, provided
10 # that the above copyright notice and this permission notice appear
11 # in all copies.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
20 # OF THIS SOFTWARE.
21 #
22
23 """
24 Following tests are covered to test Multicast basic functionality:
25
26 Topology:
27
28 _______r2_____
29 | |
30 iperf | | iperf
31 r0-----r1-------------r3-----r5
32 | |
33 |_____________|
34 r4
35
36 Test steps
37 - Create topology (setup module)
38 - Bring up topology
39
40 1. Configure multiple groups (10 grps) with same RP address
41 2. Verify IIF and OIL in updated in mroute when upstream interface
42 configure as RP
43 3. Verify RP info and (*,G) mroute after deleting the RP and shut /
44 no shut the RPF interface.
45 """
46
47 import os
48 import sys
49 import json
50 import time
51 import pytest
52
53 # Save the Current Working Directory to find configuration files.
54 CWD = os.path.dirname(os.path.realpath(__file__))
55 sys.path.append(os.path.join(CWD, "../"))
56 sys.path.append(os.path.join(CWD, "../lib/"))
57
58 # Required to instantiate the topology builder class.
59
60 # pylint: disable=C0413
61 # Import topogen and topotest helpers
62 from lib.topogen import Topogen, get_topogen
63
64 from lib.common_config import (
65 start_topology,
66 write_test_header,
67 write_test_footer,
68 reset_config_on_routers,
69 step,
70 shutdown_bringup_interface,
71 kill_router_daemons,
72 start_router_daemons,
73 create_static_routes,
74 check_router_status,
75 socat_send_mld_join,
76 socat_send_pim6_traffic,
77 kill_socat,
78 create_debug_log_config,
79 )
80 from lib.pim import (
81 create_pim_config,
82 verify_upstream_iif,
83 verify_join_state_and_timer,
84 verify_mroutes,
85 verify_pim_neighbors,
86 verify_pim_interface_traffic,
87 verify_pim_rp_info,
88 verify_pim_state,
89 clear_pim6_interface_traffic,
90 clear_pim6_mroute,
91 verify_pim6_neighbors,
92 get_pim6_interface_traffic,
93 clear_pim6_interfaces,
94 verify_mld_groups,
95 )
96 from lib.topolog import logger
97 from lib.topojson import build_topo_from_json, build_config_from_json
98
99 # Global variables
100 GROUP_RANGE_1 = "ff08::/64"
101 GROUP_ADDRESS_1 = "ff08::1"
102 GROUP_RANGE_3 = "ffaa::/64"
103 GROUP_ADDRESS_3 = "ffaa::1"
104 GROUP_RANGE_LIST_1 = [
105 "ffaa::1/128",
106 "ffaa::2/128",
107 "ffaa::3/128",
108 "ffaa::4/128",
109 "ffaa::5/128",
110 ]
111 GROUP_RANGE_LIST_2 = [
112 "ffaa::6/128",
113 "ffaa::7/128",
114 "ffaa::8/128",
115 "ffaa::9/128",
116 "ffaa::10/128",
117 ]
118 GROUP_ADDRESS_LIST_1 = ["ffaa::1", "ffaa::2", "ffaa::3", "ffaa::4", "ffaa::5"]
119 GROUP_ADDRESS_LIST_2 = ["ffaa::6", "ffaa::7", "ffaa::8", "ffaa::9", "ffaa::10"]
120 STAR = "*"
121 SOURCE = "Static"
122 ASSERT_MSG = "Testcase {} : Failed Error: {}"
123
124 pytestmark = [pytest.mark.pim6d]
125
126
127 def build_topo(tgen):
128 """Build function"""
129
130 # Building topology from json file
131 build_topo_from_json(tgen, TOPO)
132
133
134 def setup_module(mod):
135 """
136 Sets up the pytest environment
137
138 * `mod`: module name
139 """
140
141 testsuite_run_time = time.asctime(time.localtime(time.time()))
142 logger.info("Testsuite start time: %s", testsuite_run_time)
143 logger.info("=" * 40)
144
145 topology = """
146
147 _______r2_____
148 | |
149 iperf | | iperf
150 r0-----r1-------------r3-----r5
151 | |
152 |_____________|
153 r4
154
155 """
156 logger.info("Master Topology: \n %s", topology)
157
158 logger.info("Running setup_module to create topology")
159
160 # This function initiates the topology build with Topogen...
161 json_file = "{}/multicast_pim6_static_rp.json".format(CWD)
162 tgen = Topogen(json_file, mod.__name__)
163 global TOPO
164 TOPO = tgen.json_topo
165
166 # ... and here it calls Mininet initialization functions.
167
168 # Starting topology, create tmp files which are loaded to routers
169 # to start daemons and then start routers
170 start_topology(tgen)
171
172 # Don"t run this test if we have any failure.
173 if tgen.routers_have_failure():
174 pytest.skip(tgen.errors)
175
176 # Creating configuration from JSON
177 build_config_from_json(tgen, TOPO)
178
179 # Verify PIM6 neighbors
180 result = verify_pim6_neighbors(tgen, TOPO)
181 assert result is True, "setup_module :Failed \n Error:" " {}".format(result)
182
183 logger.info("Running setup_module() done")
184
185
186 def teardown_module():
187 """Teardown the pytest environment"""
188
189 logger.info("Running teardown_module to delete topology")
190 tgen = get_topogen()
191
192 # Stop toplogy and Remove tmp files
193 tgen.stop_topology()
194
195 logger.info("Testsuite end time: %s", time.asctime(time.localtime(time.time())))
196 logger.info("=" * 40)
197
198
199 #####################################################
200 #
201 # Local API
202 #
203 #####################################################
204
205
206 def verify_state_incremented(state_before, state_after):
207 """
208 API to compare interface traffic state incrementing
209
210 Parameters
211 ----------
212 * `state_before` : State dictionary for any particular instance
213 * `state_after` : State dictionary for any particular instance
214 """
215
216 for router, state_data in state_before.items():
217 for state, value in state_data.items():
218 if state_before[router][state] >= state_after[router][state]:
219 errormsg = (
220 "[DUT: %s]: state %s value has not"
221 " incremented, Initial value: %s, "
222 "Current value: %s [FAILED!!]"
223 % (
224 router,
225 state,
226 state_before[router][state],
227 state_after[router][state],
228 )
229 )
230 return errormsg
231
232 logger.info(
233 "[DUT: %s]: State %s value is "
234 "incremented, Initial value: %s, Current value: %s"
235 " [PASSED!!]",
236 router,
237 state,
238 state_before[router][state],
239 state_after[router][state],
240 )
241
242 return True
243
244
245 #####################################################
246 #
247 # Testcases
248 #
249 #####################################################
250
251
252 def test_pim6_multiple_groups_same_RP_address_p2(request):
253 """
254 Configure multiple groups (10 grps) with same RP address
255
256 Topology used:
257 ________r2_____
258 | |
259 iperf | | iperf
260 r0-----r1-------------r3-----r5
261
262 r1 : LHR
263 r2 : RP
264 r3 : FHR
265 """
266
267 tgen = get_topogen()
268 tc_name = request.node.name
269 write_test_header(tc_name)
270
271 # Don"t run this test if we have any failure.
272 if tgen.routers_have_failure():
273 pytest.skip(tgen.errors)
274
275 step("Creating configuration from JSON")
276 reset_config_on_routers(tgen)
277
278 input_dict = {
279 "r1": {"debug": {"log_file": "r1_debug.log", "enable": ["pim6d"]}},
280 "r2": {"debug": {"log_file": "r2_debug.log", "enable": ["pim6d"]}},
281 "r3": {"debug": {"log_file": "r3_debug.log", "enable": ["pim6d"]}},
282 "r4": {"debug": {"log_file": "r4_debug.log", "enable": ["pim6d"]}},
283 }
284
285 result = create_debug_log_config(tgen, input_dict)
286
287 step("Enable MLD on r1 interface")
288 step("Enable the PIM6 on all the interfaces of r1, r2, r3 and r4 routers")
289 step("r2: Configure r2 as RP")
290 input_dict = {
291 "r2": {
292 "pim6": {
293 "rp": [
294 {
295 "rp_addr": TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split(
296 "/"
297 )[0],
298 "group_addr_range": GROUP_RANGE_3,
299 }
300 ]
301 }
302 }
303 }
304
305 result = create_pim_config(tgen, TOPO, input_dict)
306 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
307
308 step("r2: verify rp-info")
309 dut = "r2"
310 oif = "lo"
311 rp_address = TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split("/")[0]
312 result = verify_pim_rp_info(tgen, TOPO, dut, GROUP_RANGE_3, oif, rp_address, SOURCE)
313 assert result is True, ASSERT_MSG.format(tc_name, result)
314
315 group_address_list = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2
316 step("r0: Send MLD join for 10 groups")
317 intf = TOPO["routers"]["r0"]["links"]["r1"]["interface"]
318 intf_ip = TOPO["routers"]["r0"]["links"]["r1"]["ipv6"].split("/")[0]
319 result = socat_send_mld_join(
320 tgen, "r0", "UDP6-RECV", group_address_list, intf, intf_ip
321 )
322 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
323
324 step("r1: Verify MLD groups")
325 dut = "r1"
326 intf_r1_r0 = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
327 result = verify_mld_groups(tgen, dut, intf_r1_r0, group_address_list)
328 assert result is True, ASSERT_MSG.format(tc_name, result)
329
330 step("r5: Send multicast traffic for group {}".format(group_address_list))
331 intf = TOPO["routers"]["r5"]["links"]["r3"]["interface"]
332 SOURCE_ADDRESS = TOPO["routers"]["r5"]["links"]["r3"]["ipv6"].split("/")[0]
333 result = socat_send_pim6_traffic(tgen, "r5", "UDP6-SEND", group_address_list, intf)
334 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
335
336 step("r1: Verify (*, G) upstream IIF interface")
337 dut = "r1"
338 iif = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
339 result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list)
340 assert result is True, ASSERT_MSG.format(tc_name, result)
341
342 step("r1: Verify (*, G) upstream join state and join timer")
343 result = verify_join_state_and_timer(
344 tgen, dut, iif, STAR, group_address_list, addr_type="ipv6"
345 )
346 assert result is True, ASSERT_MSG.format(tc_name, result)
347
348 step("r1: Verify (*, G) ip mroutes")
349 oif = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
350 result = verify_mroutes(tgen, dut, STAR, group_address_list, iif, oif)
351 assert result is True, ASSERT_MSG.format(tc_name, result)
352
353 step("r1: Verify (S, G) ip mroutes")
354 iif = TOPO["routers"]["r1"]["links"]["r3"]["interface"]
355 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
356 assert result is True, ASSERT_MSG.format(tc_name, result)
357
358 step("r1: Verify (S, G) upstream IIF interface")
359 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list)
360 assert result is True, ASSERT_MSG.format(tc_name, result)
361
362 step("r1: Verify (S, G) upstream join state and join timer")
363 result = verify_join_state_and_timer(
364 tgen, dut, iif, SOURCE_ADDRESS, group_address_list, addr_type="ipv6"
365 )
366 assert result is True, ASSERT_MSG.format(tc_name, result)
367
368 step("r2: Verify (*, G) upstream IIF interface")
369 dut = "r2"
370 iif = "lo"
371 result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list)
372 assert result is True, ASSERT_MSG.format(tc_name, result)
373
374 step("r2: Verify (*, G) upstream join state and join timer")
375 result = verify_join_state_and_timer(
376 tgen, dut, iif, STAR, group_address_list, addr_type="ipv6"
377 )
378 assert result is True, ASSERT_MSG.format(tc_name, result)
379
380 step("r2: Verify (*, G) ip mroutes")
381 oif = TOPO["routers"]["r2"]["links"]["r1"]["interface"]
382 result = verify_mroutes(tgen, dut, STAR, group_address_list, iif, oif)
383 assert result is True, ASSERT_MSG.format(tc_name, result)
384
385 step("r3: Verify (S, G) upstream IIF interface")
386 dut = "r3"
387 iif = TOPO["routers"]["r3"]["links"]["r5"]["interface"]
388 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list)
389 assert result is True, ASSERT_MSG.format(tc_name, result)
390
391 step("r3: Verify (S, G) upstream join state and join timer")
392 result = verify_join_state_and_timer(
393 tgen,
394 dut,
395 iif,
396 SOURCE_ADDRESS,
397 group_address_list,
398 addr_type="ipv6",
399 expected=False,
400 )
401 assert result is not True, (
402 "Testcase {} : Failed \n "
403 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
404 tc_name, result
405 )
406 )
407
408 step("r3: Verify (S, G) ip mroutes")
409 oif = TOPO["routers"]["r3"]["links"]["r1"]["interface"]
410 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
411 assert result is True, ASSERT_MSG.format(tc_name, result)
412
413 step("r2: Verify (S, G) upstream IIF interface")
414 dut = "r2"
415 iif = TOPO["routers"]["r2"]["links"]["r3"]["interface"]
416 result = verify_upstream_iif(
417 tgen, dut, iif, SOURCE_ADDRESS, group_address_list, joinState="NotJoined"
418 )
419 assert result is True, ASSERT_MSG.format(tc_name, result)
420
421 step("r2: Verify (S, G) upstream join state and join timer")
422 result = verify_join_state_and_timer(
423 tgen,
424 dut,
425 iif,
426 SOURCE_ADDRESS,
427 group_address_list,
428 addr_type="ipv6",
429 expected=False,
430 )
431 assert result is not True, (
432 "Testcase {} : Failed \n "
433 "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
434 tc_name, result
435 )
436 )
437
438 step("r2: Verify (S, G) ip mroutes")
439 oif = "none"
440 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
441 assert result is True, ASSERT_MSG.format(tc_name, result)
442
443 step("r1: Delete RP configuration")
444 input_dict = {
445 "r1": {
446 "pim6": {
447 "rp": [
448 {
449 "rp_addr": TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split(
450 "/"
451 )[0],
452 "group_addr_range": GROUP_RANGE_3,
453 "delete": True,
454 }
455 ]
456 }
457 }
458 }
459
460 result = create_pim_config(tgen, TOPO, input_dict)
461 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
462
463 step("r1: Shut the interface r1-r2-eth1 from R1 to R2")
464 dut = "r1"
465 intf = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
466 shutdown_bringup_interface(tgen, dut, intf, False)
467
468 step("r1: No Shut the interface r1-r2-eth1 from R1 to R2")
469 shutdown_bringup_interface(tgen, dut, intf, True)
470
471 step("r1: Configure RP")
472 input_dict = {
473 "r1": {
474 "pim6": {
475 "rp": [
476 {
477 "rp_addr": TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split(
478 "/"
479 )[0],
480 "group_addr_range": GROUP_RANGE_3,
481 }
482 ]
483 }
484 }
485 }
486
487 result = create_pim_config(tgen, TOPO, input_dict)
488 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
489
490 step("r1: Shut the interface r1-r0-eth0 from R1 to R2")
491 intf = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
492 shutdown_bringup_interface(tgen, dut, intf, False)
493
494 step("r1: No Shut the interface r1-r0-eth0 from R1 to R2")
495 shutdown_bringup_interface(tgen, dut, intf, True)
496
497 step("r1: Verify (*, G) upstream IIF interface")
498 dut = "r1"
499 iif = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
500 result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list)
501 assert result is True, ASSERT_MSG.format(tc_name, result)
502
503 step("r1: Verify (*, G) upstream join state and join timer")
504 result = verify_join_state_and_timer(
505 tgen, dut, iif, STAR, group_address_list, addr_type="ipv6"
506 )
507 assert result is True, ASSERT_MSG.format(tc_name, result)
508
509 step("r1: Verify (*, G) ip mroutes")
510 oif = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
511 result = verify_mroutes(tgen, dut, STAR, group_address_list, iif, oif)
512 assert result is True, ASSERT_MSG.format(tc_name, result)
513
514 step("r1: Verify (S, G) upstream IIF interface")
515 iif = TOPO["routers"]["r1"]["links"]["r3"]["interface"]
516 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list)
517 assert result is True, ASSERT_MSG.format(tc_name, result)
518
519 step("r1: Verify (S, G) upstream join state and join timer")
520 result = verify_join_state_and_timer(
521 tgen, dut, iif, SOURCE_ADDRESS, group_address_list, addr_type="ipv6"
522 )
523 assert result is True, ASSERT_MSG.format(tc_name, result)
524
525 step("r1: Verify (S, G) ip mroutes")
526 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
527 assert result is True, ASSERT_MSG.format(tc_name, result)
528
529 step("r2: Verify (*, G) upstream IIF interface")
530 dut = "r2"
531 iif = "lo"
532 result = verify_upstream_iif(tgen, dut, iif, STAR, group_address_list)
533 assert result is True, ASSERT_MSG.format(tc_name, result)
534
535 step("r2: Verify (*, G) upstream join state and join timer")
536 result = verify_join_state_and_timer(
537 tgen, dut, iif, STAR, group_address_list, addr_type="ipv6"
538 )
539 assert result is True, ASSERT_MSG.format(tc_name, result)
540
541 step("r2: Verify (*, G) ip mroutes")
542 oif = TOPO["routers"]["r2"]["links"]["r1"]["interface"]
543 result = verify_mroutes(tgen, dut, STAR, group_address_list, iif, oif)
544 assert result is True, ASSERT_MSG.format(tc_name, result)
545
546 step("r3: Verify (S, G) upstream IIF interface")
547 dut = "r3"
548 iif = TOPO["routers"]["r3"]["links"]["r5"]["interface"]
549 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, group_address_list)
550 assert result is True, ASSERT_MSG.format(tc_name, result)
551
552 step("r3: Verify (S, G) upstream join state and join timer")
553 result = verify_join_state_and_timer(
554 tgen,
555 dut,
556 iif,
557 SOURCE_ADDRESS,
558 group_address_list,
559 addr_type="ipv6",
560 expected=False,
561 )
562 assert result is not True, (
563 "Testcase {} : Failed \n "
564 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
565 tc_name, result
566 )
567 )
568
569 step("r3: Verify (S, G) ip mroutes")
570 oif = TOPO["routers"]["r3"]["links"]["r1"]["interface"]
571 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, group_address_list, iif, oif)
572 assert result is True, ASSERT_MSG.format(tc_name, result)
573
574 write_test_footer(tc_name)
575
576
577 def test_pim6_multiple_groups_different_RP_address_p2(request):
578 """
579 Verify IIF and OIL in updated in mroute when upstream interface
580 configure as RP
581
582 Topology used:
583 ________r2_____
584 | |
585 iperf | | iperf
586 r0-----r1-------------r3-----r5
587 | |
588 |_____________|
589 r4
590 r1 : LHR
591 r2 & r4 : RP
592 r3 : FHR
593 """
594
595 tgen = get_topogen()
596 tc_name = request.node.name
597 write_test_header(tc_name)
598
599 # Don"t run this test if we have any failure.
600 if tgen.routers_have_failure():
601 pytest.skip(tgen.errors)
602
603 step("Creating configuration from JSON")
604 reset_config_on_routers(tgen)
605
606 step("Enable MLD on r1 interface")
607 step("Enable the PIM6 on all the interfaces of r1, r2, r3 and r4 routers")
608 step("r2: Configure r2 as RP")
609 step("r4: Configure r4 as RP")
610 input_dict = {
611 "r2": {
612 "pim6": {
613 "rp": [
614 {
615 "rp_addr": TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split(
616 "/"
617 )[0],
618 "group_addr_range": GROUP_RANGE_LIST_1,
619 }
620 ]
621 }
622 },
623 "r4": {
624 "pim6": {
625 "rp": [
626 {
627 "rp_addr": TOPO["routers"]["r4"]["links"]["lo"]["ipv6"].split(
628 "/"
629 )[0],
630 "group_addr_range": GROUP_RANGE_LIST_2,
631 }
632 ]
633 }
634 },
635 }
636
637 result = create_pim_config(tgen, TOPO, input_dict)
638 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
639
640 step("r2: Verify RP info")
641 dut = "r2"
642 oif = "lo"
643 rp_address = TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split("/")[0]
644 result = verify_pim_rp_info(
645 tgen, TOPO, dut, GROUP_RANGE_LIST_1, oif, rp_address, SOURCE
646 )
647 assert result is True, ASSERT_MSG.format(tc_name, result)
648
649 step("r4: Verify RP info")
650 dut = "r4"
651 rp_address = TOPO["routers"]["r4"]["links"]["lo"]["ipv6"].split("/")[0]
652 result = verify_pim_rp_info(
653 tgen, TOPO, dut, GROUP_RANGE_LIST_2, oif, rp_address, SOURCE
654 )
655 assert result is True, ASSERT_MSG.format(tc_name, result)
656
657 group_address_list = GROUP_ADDRESS_LIST_1 + GROUP_ADDRESS_LIST_2
658 step("r0: Send MLD join for 10 groups")
659 intf = TOPO["routers"]["r0"]["links"]["r1"]["interface"]
660 intf_ip = TOPO["routers"]["r0"]["links"]["r1"]["ipv6"].split("/")[0]
661 result = socat_send_mld_join(
662 tgen, "r0", "UDP6-RECV", group_address_list, intf, intf_ip
663 )
664 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
665
666 step("r1: Verify MLD groups")
667 dut = "r1"
668 intf_r1_r0 = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
669 result = verify_mld_groups(tgen, dut, intf_r1_r0, group_address_list)
670 assert result is True, ASSERT_MSG.format(tc_name, result)
671
672 step("r5: Send multicast traffic for group {}".format(group_address_list))
673 intf = TOPO["routers"]["r5"]["links"]["r3"]["interface"]
674 SOURCE_ADDRESS = TOPO["routers"]["r5"]["links"]["r3"]["ipv6"].split("/")[0]
675 result = socat_send_pim6_traffic(tgen, "r5", "UDP6-SEND", group_address_list, intf)
676 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
677
678 step("r1: Verify (*, G) upstream IIF interface")
679 dut = "r1"
680 iif1 = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
681 iif2 = TOPO["routers"]["r1"]["links"]["r4"]["interface"]
682
683 for _iif, _group in zip([iif1, iif2], [GROUP_ADDRESS_LIST_1, GROUP_ADDRESS_LIST_2]):
684 result = verify_upstream_iif(tgen, dut, _iif, STAR, _group)
685 assert result is True, ASSERT_MSG.format(tc_name, result)
686
687 step("r1: Verify (*, G) upstream join state and join timer")
688 result = verify_join_state_and_timer(
689 tgen, dut, _iif, STAR, _group, addr_type="ipv6"
690 )
691 assert result is True, ASSERT_MSG.format(tc_name, result)
692
693 step("r1: Verify (*, G) ip mroutes")
694 iif = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
695 oif = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
696 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_1, iif, oif)
697 assert result is True, ASSERT_MSG.format(tc_name, result)
698
699 step("r1: Verify (S, G) upstream IIF interface")
700 iif = TOPO["routers"]["r1"]["links"]["r3"]["interface"]
701 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1)
702 assert result is True, ASSERT_MSG.format(tc_name, result)
703
704 step("r1: Verify (S, G) upstream join state and join timer")
705 result = verify_join_state_and_timer(
706 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, addr_type="ipv6"
707 )
708 assert result is True, ASSERT_MSG.format(tc_name, result)
709
710 step("r1: Verify (S, G) ip mroutes")
711 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif)
712 assert result is True, ASSERT_MSG.format(tc_name, result)
713
714 step("r2: Verify (*, G) upstream IIF interface")
715 dut = "r2"
716 iif = "lo"
717 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
718 assert result is True, ASSERT_MSG.format(tc_name, result)
719
720 step("r2: Verify (*, G) upstream join state and join timer")
721 result = verify_join_state_and_timer(
722 tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1, addr_type="ipv6"
723 )
724 assert result is True, ASSERT_MSG.format(tc_name, result)
725
726 step("r2: Verify (*, G) ip mroutes")
727 oif = TOPO["routers"]["r2"]["links"]["r1"]["interface"]
728 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_1, iif, oif)
729 assert result is True, ASSERT_MSG.format(tc_name, result)
730
731 step("r2: Verify (S, G) upstream IIF interface")
732 iif = TOPO["routers"]["r2"]["links"]["r3"]["interface"]
733 result = verify_upstream_iif(
734 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, joinState="NotJoined"
735 )
736 assert result is True, ASSERT_MSG.format(tc_name, result)
737
738 step("r2: Verify (S, G) upstream join state and join timer")
739 result = verify_join_state_and_timer(
740 tgen,
741 dut,
742 iif,
743 SOURCE_ADDRESS,
744 GROUP_ADDRESS_LIST_1,
745 addr_type="ipv6",
746 expected=False,
747 )
748 assert result is not True, (
749 "Testcase {} : Failed \n "
750 "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
751 tc_name, result
752 )
753 )
754
755 step("r2: Verify (S, G) ip mroutes")
756 oif = "none"
757 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif)
758 assert result is True, ASSERT_MSG.format(tc_name, result)
759
760 step("r3: Verify (S, G) upstream IIF interface")
761 dut = "r3"
762 iif = TOPO["routers"]["r3"]["links"]["r5"]["interface"]
763 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1)
764 assert result is True, ASSERT_MSG.format(tc_name, result)
765
766 step("r3: Verify (S, G) upstream join state and join timer")
767 result = verify_join_state_and_timer(
768 tgen,
769 dut,
770 iif,
771 SOURCE_ADDRESS,
772 GROUP_ADDRESS_LIST_1,
773 addr_type="ipv6",
774 expected=False,
775 )
776 assert result is not True, (
777 "Testcase {} : Failed \n "
778 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
779 tc_name, result
780 )
781 )
782
783 step("r3: Verify (S, G) ip mroutes")
784 oif = TOPO["routers"]["r3"]["links"]["r1"]["interface"]
785 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif)
786 assert result is True, ASSERT_MSG.format(tc_name, result)
787
788 step("r1: Verify (*, G) upstream IIF interface")
789 dut = "r1"
790 iif = TOPO["routers"]["r1"]["links"]["r4"]["interface"]
791 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
792 assert result is True, ASSERT_MSG.format(tc_name, result)
793
794 step("r1: Verify (*, G) upstream join state and join timer")
795 result = verify_join_state_and_timer(
796 tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2, addr_type="ipv6"
797 )
798 assert result is True, ASSERT_MSG.format(tc_name, result)
799
800 step("r1: Verify (*, G) ip mroutes")
801 oif = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
802 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_2, iif, oif)
803 assert result is True, ASSERT_MSG.format(tc_name, result)
804
805 step("r1: Verify (S, G) upstream IIF interface")
806 iif = TOPO["routers"]["r1"]["links"]["r3"]["interface"]
807 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2)
808 assert result is True, ASSERT_MSG.format(tc_name, result)
809
810 step("r1: Verify (S, G) upstream join state and join timer")
811 result = verify_join_state_and_timer(
812 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, addr_type="ipv6"
813 )
814 assert result is True, ASSERT_MSG.format(tc_name, result)
815
816 step("r1: Verify (S, G) ip mroutes")
817 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif)
818 assert result is True, ASSERT_MSG.format(tc_name, result)
819
820 step("r4: Verify (*, G) upstream IIF interface")
821 dut = "r4"
822 iif = "lo"
823 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
824 assert result is True, ASSERT_MSG.format(tc_name, result)
825
826 step("r4: Verify (*, G) upstream join state and join timer")
827 result = verify_join_state_and_timer(
828 tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2, addr_type="ipv6"
829 )
830 assert result is True, ASSERT_MSG.format(tc_name, result)
831
832 step("r4: Verify (*, G) ip mroutes")
833 oif = TOPO["routers"]["r4"]["links"]["r1"]["interface"]
834 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_2, iif, oif)
835 assert result is True, ASSERT_MSG.format(tc_name, result)
836
837 step("r4: Verify (S, G) upstream IIF interface")
838 iif = TOPO["routers"]["r4"]["links"]["r3"]["interface"]
839 result = verify_upstream_iif(
840 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, joinState="NotJoined"
841 )
842 assert result is True, ASSERT_MSG.format(tc_name, result)
843
844 step("r4: Verify (S, G) upstream join state and join timer")
845 result = verify_join_state_and_timer(
846 tgen,
847 dut,
848 iif,
849 SOURCE_ADDRESS,
850 GROUP_ADDRESS_LIST_2,
851 addr_type="ipv6",
852 expected=False,
853 )
854 assert result is not True, (
855 "Testcase {} : Failed \n "
856 "r4: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
857 tc_name, result
858 )
859 )
860
861 step("r4: Verify (S, G) ip mroutes")
862 oif = "none"
863 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif)
864 assert result is True, ASSERT_MSG.format(tc_name, result)
865
866 step("r3: Verify (S, G) upstream IIF interface")
867 dut = "r3"
868 iif = TOPO["routers"]["r3"]["links"]["r5"]["interface"]
869 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2)
870 assert result is True, ASSERT_MSG.format(tc_name, result)
871
872 step("r3: Verify (S, G) upstream join state and join timer")
873 result = verify_join_state_and_timer(
874 tgen,
875 dut,
876 iif,
877 SOURCE_ADDRESS,
878 GROUP_ADDRESS_LIST_2,
879 addr_type="ipv6",
880 expected=False,
881 )
882 assert result is not True, "Testcase {} :Failed \n Error: {}".format(
883 tc_name, result
884 )
885
886 step("r3: Verify (S, G) ip mroutes")
887 oif = TOPO["routers"]["r3"]["links"]["r1"]["interface"]
888 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif)
889 assert result is True, ASSERT_MSG.format(tc_name, result)
890
891 step("Delete RP configuration")
892 input_dict = {
893 "r2": {
894 "pim6": {
895 "rp": [
896 {
897 "rp_addr": TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split(
898 "/"
899 )[0],
900 "group_addr_range": GROUP_RANGE_LIST_1,
901 "delete": True,
902 }
903 ]
904 }
905 },
906 "r4": {
907 "pim6": {
908 "rp": [
909 {
910 "rp_addr": TOPO["routers"]["r4"]["links"]["lo"]["ipv6"].split(
911 "/"
912 )[0],
913 "group_addr_range": GROUP_RANGE_LIST_2,
914 "delete": True,
915 }
916 ]
917 }
918 },
919 }
920
921 result = create_pim_config(tgen, TOPO, input_dict)
922 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
923
924 step("r1, r2, r3, r4: Re-configure RP")
925 input_dict = {
926 "r2": {
927 "pim6": {
928 "rp": [
929 {
930 "rp_addr": TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split(
931 "/"
932 )[0],
933 "group_addr_range": GROUP_RANGE_LIST_1,
934 }
935 ]
936 }
937 },
938 "r4": {
939 "pim6": {
940 "rp": [
941 {
942 "rp_addr": TOPO["routers"]["r4"]["links"]["lo"]["ipv6"].split(
943 "/"
944 )[0],
945 "group_addr_range": GROUP_RANGE_LIST_2,
946 }
947 ]
948 }
949 },
950 }
951
952 result = create_pim_config(tgen, TOPO, input_dict)
953 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
954
955 step("r1: Shut/No Shut the interfacesfrom R1 to R2, R4 and R0")
956 dut = "r1"
957 intf1 = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
958 intf2 = TOPO["routers"]["r1"]["links"]["r4"]["interface"]
959 intf3 = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
960 for intf in [intf1, intf2, intf3]:
961 shutdown_bringup_interface(tgen, dut, intf, False)
962 shutdown_bringup_interface(tgen, dut, intf, True)
963
964 step("r1: Verify (*, G) upstream IIF interface")
965 dut = "r1"
966 iif = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
967 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
968 assert result is True, ASSERT_MSG.format(tc_name, result)
969
970 step("r1: Verify (*, G) upstream join state and join timer")
971 result = verify_join_state_and_timer(
972 tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1, addr_type="ipv6"
973 )
974 assert result is True, ASSERT_MSG.format(tc_name, result)
975
976 step("r1: Verify (*, G) ip mroutes")
977 oif = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
978 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_1, iif, oif)
979 assert result is True, ASSERT_MSG.format(tc_name, result)
980
981 step("r1: Verify (S, G) upstream IIF interface")
982 iif = TOPO["routers"]["r1"]["links"]["r3"]["interface"]
983 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1)
984 assert result is True, ASSERT_MSG.format(tc_name, result)
985
986 step("r1: Verify (S, G) upstream join state and join timer")
987 result = verify_join_state_and_timer(
988 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, addr_type="ipv6"
989 )
990 assert result is True, ASSERT_MSG.format(tc_name, result)
991
992 step("r1: Verify (S, G) ip mroutes")
993 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif)
994 assert result is True, ASSERT_MSG.format(tc_name, result)
995
996 step("r2: Verify (*, G) upstream IIF interface")
997 dut = "r2"
998 iif = "lo"
999 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1)
1000 assert result is True, ASSERT_MSG.format(tc_name, result)
1001
1002 step("r2: Verify (*, G) upstream join state and join timer")
1003 result = verify_join_state_and_timer(
1004 tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_1, addr_type="ipv6"
1005 )
1006 assert result is True, ASSERT_MSG.format(tc_name, result)
1007
1008 step("r2: Verify (*, G) ip mroutes")
1009 oif = TOPO["routers"]["r2"]["links"]["r1"]["interface"]
1010 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_1, iif, oif)
1011 assert result is True, ASSERT_MSG.format(tc_name, result)
1012
1013 step("r2: Verify (S, G) upstream IIF interface")
1014 iif = TOPO["routers"]["r2"]["links"]["r3"]["interface"]
1015 result = verify_upstream_iif(
1016 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, joinState="NotJoined"
1017 )
1018 assert result is True, ASSERT_MSG.format(tc_name, result)
1019
1020 step("r2: Verify (S, G) upstream join state and join timer")
1021 result = verify_join_state_and_timer(
1022 tgen,
1023 dut,
1024 iif,
1025 SOURCE_ADDRESS,
1026 GROUP_ADDRESS_LIST_1,
1027 addr_type="ipv6",
1028 expected=False,
1029 )
1030 assert result is not True, (
1031 "Testcase {} : Failed \n "
1032 "r2: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
1033 tc_name, result
1034 )
1035 )
1036
1037 step("r2: Verify (S, G) ip mroutes")
1038 oif = "none"
1039 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif)
1040 assert result is True, ASSERT_MSG.format(tc_name, result)
1041
1042 step("r3: Verify (S, G) upstream IIF interface")
1043 dut = "r3"
1044 iif = TOPO["routers"]["r3"]["links"]["r5"]["interface"]
1045 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1)
1046 assert result is True, ASSERT_MSG.format(tc_name, result)
1047
1048 step("r3: Verify (S, G) upstream join state and join timer")
1049 result = verify_join_state_and_timer(
1050 tgen,
1051 dut,
1052 iif,
1053 SOURCE_ADDRESS,
1054 GROUP_ADDRESS_LIST_1,
1055 addr_type="ipv6",
1056 expected=False,
1057 )
1058 assert result is not True, (
1059 "Testcase {} : Failed \n "
1060 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
1061 tc_name, result
1062 )
1063 )
1064
1065 step("r3: Verify (S, G) ip mroutes")
1066 oif = TOPO["routers"]["r3"]["links"]["r1"]["interface"]
1067 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_1, iif, oif)
1068 assert result is True, ASSERT_MSG.format(tc_name, result)
1069
1070 step("r1: Verify (*, G) upstream IIF interface")
1071 dut = "r1"
1072 iif = TOPO["routers"]["r1"]["links"]["r4"]["interface"]
1073 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
1074 assert result is True, ASSERT_MSG.format(tc_name, result)
1075
1076 step("r1: Verify (*, G) upstream join state and join timer")
1077 result = verify_join_state_and_timer(
1078 tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2, addr_type="ipv6"
1079 )
1080 assert result is True, ASSERT_MSG.format(tc_name, result)
1081
1082 step("r1: Verify (*, G) ip mroutes")
1083 oif = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
1084 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_2, iif, oif)
1085 assert result is True, ASSERT_MSG.format(tc_name, result)
1086
1087 step("r1: Verify (S, G) upstream IIF interface")
1088 iif = TOPO["routers"]["r1"]["links"]["r3"]["interface"]
1089 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2)
1090 assert result is True, ASSERT_MSG.format(tc_name, result)
1091
1092 step("r1: Verify (S, G) upstream join state and join timer")
1093 result = verify_join_state_and_timer(
1094 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, addr_type="ipv6"
1095 )
1096 assert result is True, ASSERT_MSG.format(tc_name, result)
1097
1098 step("r1: Verify (S, G) ip mroutes")
1099 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif)
1100 assert result is True, ASSERT_MSG.format(tc_name, result)
1101
1102 step("r4: Verify (*, G) upstream IIF interface")
1103 dut = "r4"
1104 iif = "lo"
1105 result = verify_upstream_iif(tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2)
1106 assert result is True, ASSERT_MSG.format(tc_name, result)
1107
1108 step("r4: Verify (*, G) upstream join state and join timer")
1109 result = verify_join_state_and_timer(
1110 tgen, dut, iif, STAR, GROUP_ADDRESS_LIST_2, addr_type="ipv6"
1111 )
1112 assert result is True, ASSERT_MSG.format(tc_name, result)
1113
1114 step("r4: Verify (*, G) ip mroutes")
1115 oif = TOPO["routers"]["r4"]["links"]["r1"]["interface"]
1116 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_LIST_2, iif, oif)
1117 assert result is True, ASSERT_MSG.format(tc_name, result)
1118
1119 step("r4: Verify (S, G) upstream IIF interface")
1120 iif = TOPO["routers"]["r4"]["links"]["r3"]["interface"]
1121 result = verify_upstream_iif(
1122 tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, joinState="NotJoined"
1123 )
1124 assert result is True, ASSERT_MSG.format(tc_name, result)
1125
1126 step("r4: Verify (S, G) upstream join state and join timer")
1127 result = verify_join_state_and_timer(
1128 tgen,
1129 dut,
1130 iif,
1131 SOURCE_ADDRESS,
1132 GROUP_ADDRESS_LIST_2,
1133 addr_type="ipv6",
1134 expected=False,
1135 )
1136 assert result is not True, (
1137 "Testcase {} : Failed \n "
1138 "r4: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
1139 tc_name, result
1140 )
1141 )
1142
1143 step("r4: Verify (S, G) ip mroutes")
1144 oif = "none"
1145 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif)
1146 assert result is True, ASSERT_MSG.format(tc_name, result)
1147
1148 step("r3: Verify (S, G) upstream IIF interface")
1149 dut = "r3"
1150 iif = TOPO["routers"]["r3"]["links"]["r5"]["interface"]
1151 result = verify_upstream_iif(tgen, dut, iif, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2)
1152 assert result is True, ASSERT_MSG.format(tc_name, result)
1153
1154 step("r3: Verify (S, G) upstream join state and join timer")
1155 result = verify_join_state_and_timer(
1156 tgen,
1157 dut,
1158 iif,
1159 SOURCE_ADDRESS,
1160 GROUP_ADDRESS_LIST_2,
1161 addr_type="ipv6",
1162 expected=False,
1163 )
1164 assert result is not True, (
1165 "Testcase {} : Failed \n "
1166 "r3: (S,G) upstream state is joined and join timer is running\n Error: {}".format(
1167 tc_name, result
1168 )
1169 )
1170
1171 step("r3: Verify (S, G) ip mroutes")
1172 oif = TOPO["routers"]["r3"]["links"]["r1"]["interface"]
1173 result = verify_mroutes(tgen, dut, SOURCE_ADDRESS, GROUP_ADDRESS_LIST_2, iif, oif)
1174 assert result is True, ASSERT_MSG.format(tc_name, result)
1175
1176 write_test_footer(tc_name)
1177
1178
1179 def test_pim6_delete_RP_shut_noshut_upstream_interface_p1(request):
1180 """
1181 Verify RP info and (*,G) mroute after deleting the RP and shut /
1182 no shut the RPF interface.
1183
1184 Topology used:
1185 ________r2_____
1186 | |
1187 iperf | |
1188 r0-----r1-------------r3
1189 """
1190
1191 tgen = get_topogen()
1192 tc_name = request.node.name
1193 write_test_header(tc_name)
1194
1195 # Don"t run this test if we have any failure.
1196 if tgen.routers_have_failure():
1197 pytest.skip(tgen.errors)
1198
1199 step("Creating configuration from JSON")
1200 reset_config_on_routers(tgen)
1201
1202 step("Enable MLD on r1 interface")
1203 step("Enable the PIM6 on all the interfaces of r1, r2, r3 and r4 routers")
1204 step("r2: Configure r2 as RP")
1205 input_dict = {
1206 "r2": {
1207 "pim6": {
1208 "rp": [
1209 {
1210 "rp_addr": TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split(
1211 "/"
1212 )[0],
1213 "group_addr_range": GROUP_RANGE_1,
1214 }
1215 ]
1216 }
1217 }
1218 }
1219
1220 result = create_pim_config(tgen, TOPO, input_dict)
1221 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1222
1223 step("r2: verify rp-info")
1224 dut = "r2"
1225 oif = "lo"
1226 rp_address = TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split("/")[0]
1227 result = verify_pim_rp_info(
1228 tgen, TOPO, dut, GROUP_ADDRESS_1, oif, rp_address, SOURCE
1229 )
1230 assert result is True, ASSERT_MSG.format(tc_name, result)
1231
1232 step("r0: Send MLD join")
1233 intf = TOPO["routers"]["r0"]["links"]["r1"]["interface"]
1234 intf_ip = TOPO["routers"]["r0"]["links"]["r1"]["ipv6"].split("/")[0]
1235 result = socat_send_mld_join(
1236 tgen, "r0", "UDP6-RECV", GROUP_ADDRESS_1, intf, intf_ip
1237 )
1238 assert result is True, "Testcase {}: Failed Error: {}".format(tc_name, result)
1239
1240 step("r1: Verify MLD groups")
1241 dut = "r1"
1242 intf_r1_r0 = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
1243 result = verify_mld_groups(tgen, dut, intf_r1_r0, GROUP_ADDRESS_1)
1244 assert result is True, ASSERT_MSG.format(tc_name, result)
1245
1246 step("r1: Verify (*, G) ip mroutes created")
1247 iif = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
1248 oif = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
1249 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_1, iif, oif)
1250 assert result is True, ASSERT_MSG.format(tc_name, result)
1251
1252 step("r2: Verify (*, G) ip mroutes created")
1253 dut = "r2"
1254 iif = "lo"
1255 oif = TOPO["routers"]["r2"]["links"]["r1"]["interface"]
1256 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_1, iif, oif)
1257 assert result is True, ASSERT_MSG.format(tc_name, result)
1258
1259 step("r1: Delete RP configuration")
1260 input_dict = {
1261 "r1": {
1262 "pim6": {
1263 "rp": [
1264 {
1265 "rp_addr": TOPO["routers"]["r2"]["links"]["lo"]["ipv6"].split(
1266 "/"
1267 )[0],
1268 "group_addr_range": GROUP_RANGE_1,
1269 "delete": True,
1270 }
1271 ]
1272 }
1273 }
1274 }
1275
1276 result = create_pim_config(tgen, TOPO, input_dict)
1277 assert result is True, "Testcase {} : Failed Error: {}".format(tc_name, result)
1278
1279 step("r1: Shut/No Shut the interface r1-r2-eth1/r1-r0-eth0 from R1 to R2")
1280 dut = "r1"
1281 intf1 = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
1282 intf2 = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
1283 for intf in [intf1, intf2]:
1284 shutdown_bringup_interface(tgen, dut, intf, False)
1285 shutdown_bringup_interface(tgen, dut, intf, True)
1286
1287 step("r2: Shut the RP interface lo")
1288 dut = "r2"
1289 intf = "lo"
1290 shutdown_bringup_interface(tgen, dut, intf, False)
1291
1292 step("r1: Shut the interface r1-r2-eth1/r1-r3-eth2 towards RP")
1293 intf3 = TOPO["routers"]["r1"]["links"]["r3"]["interface"]
1294 for intf in [intf1, intf3]:
1295 shutdown_bringup_interface(tgen, dut, intf, False)
1296
1297 step("r1: Verify (*, G) ip mroutes cleared")
1298 dut = "r1"
1299 iif = TOPO["routers"]["r1"]["links"]["r2"]["interface"]
1300 oif = TOPO["routers"]["r1"]["links"]["r0"]["interface"]
1301 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_1, iif, oif, expected=False)
1302 assert result is not True, (
1303 "Testcase {} : Failed \n "
1304 "r1: (*,G) mroutes are not cleared after shut of R1 to R0 link\n Error: {}".format(
1305 tc_name, result
1306 )
1307 )
1308
1309 step("r2: Verify (*, G) ip mroutes cleared")
1310 dut = "r2"
1311 iif = "lo"
1312 oif = TOPO["routers"]["r2"]["links"]["r1"]["interface"]
1313 result = verify_mroutes(tgen, dut, STAR, GROUP_ADDRESS_1, iif, oif, expected=False)
1314 assert result is not True, (
1315 "Testcase {} : Failed \n "
1316 "r2: (*,G) mroutes are not cleared after shut of R1 to R0 link\n Error: {}".format(
1317 tc_name, result
1318 )
1319 )
1320
1321 write_test_footer(tc_name)
1322
1323
1324 if __name__ == "__main__":
1325 args = ["-s"] + sys.argv[1:]
1326 sys.exit(pytest.main(args))