2 # SPDX-License-Identifier: ISC
4 # Copyright (c) 2020 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation,
6 # Inc. ("NetDEF") in this file.
10 Following tests are covered to test PIM BSM processing basic functionality:
13 - Create topology (setup module)
16 Tests covered in this suite
17 1. Verify FRR router select higher IP BSR , when 2 BSR present in the network
18 2. Verify BSR and RP updated correctly after configuring as black hole address
19 3.1 Verify when new router added to the topology, FRR node will send
20 unicast BSM to new router
21 3.2 Verify if no forwarding bit is set , FRR is not forwarding the
23 3.3 Verify multicast BSM is sent to new router when unicast BSM is disabled
24 4.1 Verify BSM arrived on non bsm capable interface is dropped and
26 4.2 Verify group to RP info updated correctly in FRR node, after shut and
27 no-shut of BSM enable interfaces
28 5. Verify static RP is preferred over BSR
29 6.1 Verify adding/deleting the group to rp mapping and RP priority
31 6.2 Verify RP and (*,G) detail after PIM process restart on FRR node
32 7.1 Verify BSM timeout on FRR1
33 7.2 Verify RP state in FRR1 after Bootstrap timer expiry
34 8.1 Verify upstream interfaces(IIF) and join state are updated properly
35 after BSM received for FRR
36 8.2 Verify IIF and OIL in "show ip pim state" updated properly after
45 # Save the Current Working Directory to find configuration files.
46 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
47 sys
.path
.append(os
.path
.join(CWD
, "../"))
48 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
50 # Required to instantiate the topology builder class.
52 # pylint: disable=C0413
53 # Import topogen and topotest helpers
54 from lib
.topogen
import Topogen
, get_topogen
56 from lib
.common_config
import (
65 shutdown_bringup_interface
,
68 reset_config_on_routers
,
72 required_linux_kernel_version
,
78 add_rp_interfaces_and_pim_config
,
80 scapy_send_bsr_raw_packet
,
81 find_rp_from_bsrp_info
,
82 verify_pim_grp_rp_source
,
85 verify_join_state_and_timer
,
89 verify_pim_upstream_rpf
,
90 enable_disable_pim_unicast_bsm
,
91 enable_disable_pim_bsm
,
93 clear_pim_interface_traffic
,
94 get_pim_interface_traffic
,
98 from lib
.topolog
import logger
99 from lib
.topojson
import build_config_from_json
102 pytestmark
= [pytest
.mark
.pimd
, pytest
.mark
.staticd
]
109 s1-----f1-----i1-----l1----r1
118 i1 - Intermediate Router (also RP)
123 NEXT_HOP1
= "70.0.0.1"
124 NEXT_HOP2
= "65.0.0.1"
126 BSR_IP_2
= "10.2.1.1"
127 BSR1_ADDR
= "1.1.2.7/32"
128 BSR2_ADDR
= "10.2.1.1/32"
131 def setup_module(mod
):
133 Sets up the pytest environment
138 # Required linux kernel version for this suite to run.
139 result
= required_linux_kernel_version("4.15")
140 if result
is not True:
141 pytest
.skip("Kernel version should be >= 4.15")
143 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
144 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
145 logger
.info("=" * 40)
146 logger
.info("Master Topology: \n {}".format(TOPOLOGY
))
148 logger
.info("Running setup_module to create topology")
150 # This function initiates the topology build with Topogen...
151 json_file
= "{}/mcast_pim_bsmp_01.json".format(CWD
)
152 tgen
= Topogen(json_file
, mod
.__name
__)
154 topo
= tgen
.json_topo
155 # ... and here it calls Mininet initialization functions.
157 # Starting topology, create tmp files which are loaded to routers
158 # to start daemons and then start routers
161 # Don"t run this test if we have any failure.
162 if tgen
.routers_have_failure():
163 pytest
.skip(tgen
.errors
)
165 # Creating configuration from JSON
166 build_config_from_json(tgen
, topo
)
168 # Verify PIM neighbors
169 result
= verify_pim_neighbors(tgen
, topo
)
170 assert result
is True, " Verify PIM neighbor: Failed Error: {}".format(result
)
172 # XXX Replace this using "with McastTesterHelper()... " in each test if possible.
174 app_helper
= McastTesterHelper(tgen
)
176 logger
.info("Running setup_module() done")
179 def teardown_module():
180 """Teardown the pytest environment"""
182 logger
.info("Running teardown_module to delete topology")
188 # Stop toplogy and Remove tmp files
192 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
194 logger
.info("=" * 40)
197 #####################################################
201 #####################################################
204 def clear_bsrp_data(tgen
, topo
):
207 clear bsm databas after test"
210 * `tgen`: topogen object
214 result = clear_bsrp_data(tgen, topo)
217 errormsg(str) or True
220 for dut
in tgen
.routers():
222 rnode
= tgen
.routers()[dut
]
224 logger
.info("[DUT: %s]: clear_bsrp_data")
226 run_frr_cmd(rnode
, "clear ip pim bsr-data")
231 def verify_state_incremented(state_before
, state_after
):
233 API to compare interface traffic state incrementing
237 * `state_before` : State dictionary for any particular instance
238 * `state_after` : State dictionary for any particular instance
241 for router
, state_data
in state_before
.items():
242 for state
, value
in state_data
.items():
243 if state_before
[router
][state
] >= state_after
[router
][state
]:
245 "[DUT: %s]: state %s value has not"
246 " incremented, Initial value: %s, "
247 "Current value: %s [FAILED!!]"
251 state_before
[router
][state
],
252 state_after
[router
][state
],
258 "[DUT: %s]: State %s value is "
259 "incremented, Initial value: %s, Current value: %s"
263 state_before
[router
][state
],
264 state_after
[router
][state
],
270 def pre_config_to_bsm(tgen
, topo
, tc_name
, bsr
, sender
, receiver
, fhr
, rp
, lhr
, packet
):
272 API to do required configuration to send and receive BSR packet
275 # Re-configure interfaces as per BSR packet
276 result
= reconfig_interfaces(tgen
, topo
, bsr
, fhr
, packet
)
277 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
279 # Create static routes
280 if "bsr" in topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]:
281 bsr_route
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["bsr"]
282 next_hop
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["src_ip"].split(
285 next_hop_rp
= topo
["routers"][fhr
]["links"][rp
]["ipv4"].split("/")[0]
286 next_hop_lhr
= topo
["routers"][rp
]["links"][lhr
]["ipv4"].split("/")[0]
290 rp
: {"static_routes": [{"network": bsr_route
, "next_hop": next_hop_rp
}]},
291 lhr
: {"static_routes": [{"network": bsr_route
, "next_hop": next_hop_lhr
}]},
294 result
= create_static_routes(tgen
, input_dict
)
295 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
297 # Verifying static routes are installed
298 for dut
, _nexthop
in zip([rp
, lhr
], [next_hop_rp
, next_hop_lhr
]):
299 input_routes
= {dut
: input_dict
[dut
]}
301 tgen
, "ipv4", dut
, input_routes
, _nexthop
, protocol
="static"
303 assert result
is True, "Testcase {} : Failed \n Error {}".format(
308 rp_mapping
= topo
["routers"][bsr
]["bsm"]["bsr_packets"][packet
]["rp_mapping"]
310 # Add interfaces in RP for all the RPs
311 result
= add_rp_interfaces_and_pim_config(tgen
, topo
, "lo", rp
, rp_mapping
)
312 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
314 # Add kernel routes to sender and receiver
315 for group
, rp_list
in rp_mapping
.items():
316 mask
= group
.split("/")[1]
318 group
= group
.split("/")[0]
320 # Add static routes for RPs in FHR and LHR
321 next_hop_fhr
= topo
["routers"][rp
]["links"][fhr
]["ipv4"].split("/")[0]
322 next_hop_lhr
= topo
["routers"][rp
]["links"][lhr
]["ipv4"].split("/")[0]
324 fhr
: {"static_routes": [{"network": rp_list
, "next_hop": next_hop_fhr
}]},
326 result
= create_static_routes(tgen
, input_dict
)
327 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
329 # Verifying static routes are installed
331 tgen
, "ipv4", fhr
, input_dict
, next_hop_fhr
, protocol
="static"
333 assert result
is True, "Testcase {} : Failed \n Error {}".format(
338 lhr
: {"static_routes": [{"network": rp_list
, "next_hop": next_hop_lhr
}]},
340 result
= create_static_routes(tgen
, input_dict
)
341 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
343 # Verifying static routes are installed
345 tgen
, "ipv4", lhr
, input_dict
, next_hop_lhr
, protocol
="static"
347 assert result
is True, "Testcase {} : Failed \n Error {}".format(
354 #####################################################
358 #####################################################
361 def test_BSR_higher_prefer_ip_p0(request
):
363 Verify FRR router select higher IP BSR , when 2 BSR present in the network
369 s1-----f1-----i1-----l1----r1
378 i1 - Intermediate Router (also RP)
383 tc_name
= request
.node
.name
384 write_test_header(tc_name
)
386 # Don"t run this test if we have any failure.
387 if tgen
.routers_have_failure():
388 pytest
.skip(tgen
.errors
)
390 app_helper
.stop_all_hosts()
392 reset_config_on_routers(tgen
)
393 clear_pim_interface_traffic(tgen
, topo
)
395 step("pre-configure BSM packet")
396 step("Configure cisco-1 as BSR1 1.1.2.7")
397 result
= pre_config_to_bsm(
398 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
400 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
401 step("Configure cisco-1 as BSR1 10.2.1.1")
402 result
= pre_config_to_bsm(
403 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
405 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
406 step("configuring loopback address of b1 and b2 as BSR")
407 intf_lo_addr_b1
= topo
["routers"]["b1"]["links"]["lo"]["ipv4"]
408 intf_lo_addr_b2
= topo
["routers"]["b2"]["links"]["lo"]["ipv4"]
414 "no ip address {}".format(intf_lo_addr_b1
),
415 "ip address {}".format(BSR1_ADDR
),
422 "no ip address {}".format(intf_lo_addr_b2
),
423 "ip address {}".format(BSR2_ADDR
),
428 result
= apply_raw_config(tgen
, raw_config
)
429 assert result
is True, "Testcase {} : Failed Error: {}".format(tc_name
, result
)
431 GROUP_ADDRESS
= "225.200.100.100"
432 step("configuring static routes for both the BSR")
434 next_hop_rp
= topo
["routers"]["f1"]["links"]["i1"]["ipv4"].split("/")[0]
435 next_hop_lhr
= topo
["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0]
440 {"network": BSR1_ADDR
, "next_hop": NEXT_HOP1
},
441 {"network": BSR2_ADDR
, "next_hop": NEXT_HOP2
},
446 {"network": BSR1_ADDR
, "next_hop": next_hop_rp
},
447 {"network": BSR2_ADDR
, "next_hop": next_hop_rp
},
452 {"network": BSR1_ADDR
, "next_hop": next_hop_lhr
},
453 {"network": BSR2_ADDR
, "next_hop": next_hop_lhr
},
458 result
= create_static_routes(tgen
, input_dict
)
459 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
461 # Verifying static routes are installed
462 for dut
, _nexthop
in zip(["i1", "l1"], [next_hop_rp
, next_hop_lhr
]):
463 input_routes
= {dut
: input_dict
[dut
]}
465 tgen
, "ipv4", dut
, input_routes
, _nexthop
, protocol
="static"
467 assert result
is True, "Testcase {} : Failed \n Error {}".format(
471 for bsr_add
, next_hop
in zip([BSR1_ADDR
, BSR2_ADDR
], [NEXT_HOP1
, NEXT_HOP2
]):
473 "f1": {"static_routes": [{"network": bsr_add
, "next_hop": next_hop
}]}
476 tgen
, "ipv4", "f1", input_routes
, next_hop
, protocol
="static"
478 assert result
is True, "Testcase {} : Failed \n Error {}".format(
482 # Use scapy to send pre-defined packet from senser to receiver
483 step("Send BSR packet from b1 to FHR")
484 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
485 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
487 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
488 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
492 step("Verify if b1 chosen as BSR in f1")
493 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_1
)
494 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
496 group
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
497 step("Find the elected rp from bsrp-info in LHR l1")
498 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_1
, group
)
499 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
501 step("Verify RP in LHR")
502 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
503 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
505 step("Send BSR packet from b2 to FHR")
506 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b2", "f1", "packet3")
507 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
510 step("Verify if b2 chosen as BSR in f1")
511 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_2
)
512 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
514 step("Find the elected rp from bsrp-info in LHR l1")
515 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_2
, group
)
516 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
518 step("Verify RP in LHR")
519 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
520 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
522 step("Shut higher prefer BSR2 link f1 to b2")
524 f1_b2_eth1
= topo
["routers"]["f1"]["links"]["b2"]["interface"]
525 shutdown_bringup_interface(tgen
, "f1", "f1-b2-eth1", False)
527 step("clearing bsr to timeout old BSR")
528 clear_bsrp_data(tgen
, topo
)
530 step("Send BSR packet from b1 and b2 to FHR")
531 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
532 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
534 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b2", "f1", "packet3")
535 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
537 step("sleeping for 3 sec to leran new packet")
539 step("verify BSR1 has become preferred RP")
542 step("Verify if b1 chosen as BSR in f1")
543 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_1
)
544 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
546 step("Find the elected rp from bsrp-info in LHR l1")
547 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_1
, group
)
548 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
550 step("Verify RP in LHR")
551 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
552 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
554 step("NoShut higher prefer BSR2 link f1 to b2")
555 step("sleeping for 3 min to leran new packet")
557 f1_b2_eth1
= topo
["routers"]["f1"]["links"]["b2"]["interface"]
558 shutdown_bringup_interface(tgen
, "f1", "f1-b2-eth1", True)
559 step("verify BSR2 has become preferred RP")
562 step("Send BSR packet from b1 and b2 to FHR")
563 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
564 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
566 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b2", "f1", "packet3")
567 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
569 step("Verify if b2 chosen as BSR in f1")
570 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_2
)
571 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
573 step("Find the elected rp from bsrp-info in LHR l1")
574 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_2
, group
)
575 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
577 step("Verify RP in LHR")
578 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
579 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
581 step("Clear BSM database before moving to next case")
582 clear_bsrp_data(tgen
, topo
)
584 write_test_footer(tc_name
)
587 def test_BSR_CRP_with_blackhole_address_p1(request
):
589 Verify BSR and RP updated correctly after configuring as black hole address
595 s1-----f1-----i1-----l1----r1
604 i1 - Intermediate Router (also RP)
609 tc_name
= request
.node
.name
610 write_test_header(tc_name
)
612 # Don"t run this test if we have any failure.
613 if tgen
.routers_have_failure():
614 pytest
.skip(tgen
.errors
)
616 app_helper
.stop_all_hosts()
618 reset_config_on_routers(tgen
)
619 clear_pim_interface_traffic(tgen
, topo
)
621 step("pre-configure BSM packet")
622 step("Configure cisco-1 as BSR1 1.1.2.7")
623 result
= pre_config_to_bsm(
624 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
626 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
628 step("configuring loopback address of b1 and b2 as BSR")
629 intf_lo_addr_b1
= topo
["routers"]["b1"]["links"]["lo"]["ipv4"]
635 "no ip address {}".format(intf_lo_addr_b1
),
636 "ip address {}".format(BSR1_ADDR
),
641 result
= apply_raw_config(tgen
, raw_config
)
642 assert result
is True, "Testcase {} : Failed Error: {}".format(tc_name
, result
)
644 GROUP_ADDRESS
= "225.200.100.100"
645 step("configuring static routes for both the BSR")
647 next_hop_rp
= topo
["routers"]["f1"]["links"]["i1"]["ipv4"].split("/")[0]
648 next_hop_lhr
= topo
["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0]
649 next_hop_fhr
= topo
["routers"]["i1"]["links"]["f1"]["ipv4"].split("/")[0]
650 CRP
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["candidate_rp"]
653 "i1": {"static_routes": [{"network": BSR1_ADDR
, "next_hop": next_hop_rp
}]},
654 "l1": {"static_routes": [{"network": BSR1_ADDR
, "next_hop": next_hop_lhr
}]},
657 {"network": CRP
, "next_hop": next_hop_fhr
, "delete": True}
662 result
= create_static_routes(tgen
, input_dict
)
663 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
665 # Verifying static routes are installed
666 for dut
, _nexthop
in zip(["i1", "l1"], [next_hop_rp
, next_hop_lhr
]):
667 input_routes
= {dut
: input_dict
[dut
]}
669 tgen
, "ipv4", dut
, input_routes
, _nexthop
, protocol
="static"
671 assert result
is True, "Testcase {} : Failed \n Error {}".format(
676 "f1": {"static_routes": [{"network": CRP
, "next_hop": next_hop_fhr
}]}
679 tgen
, "ipv4", "f1", input_routes
, protocol
="static", expected
=False
681 assert result
is not True, (
682 "Testcase {} : Failed \n "
683 "Expected: Routes should not be present in {} RIB \n "
684 "Found: {}".format(tc_name
, "f1", result
)
687 # Use scapy to send pre-defined packet from senser to receiver
689 group
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
690 step("waiting for BSR to timeout before configuring blackhole route")
691 clear_bsrp_data(tgen
, topo
)
693 step("Configure black-hole address for BSR and candidate RP")
696 "static_routes": [{"network": [BSR1_ADDR
, CRP
], "next_hop": "blackhole"}]
700 result
= create_static_routes(tgen
, input_dict
)
701 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
703 # Verifying static routes are installed
704 result
= verify_rib(tgen
, "ipv4", "f1", input_dict
, protocol
="static")
705 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
707 intf_f1_i1
= topo
["routers"]["f1"]["links"]["i1"]["interface"]
708 step("Verify bsm transit count is not increamented" "show ip pim interface traffic")
709 state_dict
= {"f1": {intf_f1_i1
: ["bsmTx"]}}
711 state_before
= get_pim_interface_traffic(tgen
, state_dict
)
714 ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
718 step("Sending BSR after Configure black hole address for BSR and candidate RP")
719 step("Send BSR packet from b1 to FHR")
720 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
721 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
724 step("Find the elected rp from bsrp-info in LHR l1")
725 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_1
, group
)
726 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
728 step("Verify if b1 chosen as BSR in l1")
729 result
= verify_pim_bsr(tgen
, topo
, "l1", BSR_IP_1
, expected
=False)
730 assert result
is not True, (
731 "Testcase {} : Failed \n "
732 "Expected: b1 should be chosen as BSR in {} \n "
733 "Found: {}".format(tc_name
, "l1", result
)
736 state_after
= get_pim_interface_traffic(tgen
, state_dict
)
739 ), "Testcase{} : Failed \n state_before is not dictionary \n Error: {}".format(
743 result
= verify_state_incremented(state_before
, state_after
)
744 assert result
is not True, "Testcase{} : Failed Error: {}".format(tc_name
, result
)
746 step("Remove black-hole address for BSR and candidate RP")
750 {"network": [BSR1_ADDR
, CRP
], "next_hop": "blackhole", "delete": True},
751 {"network": BSR1_ADDR
, "next_hop": NEXT_HOP1
},
756 result
= create_static_routes(tgen
, input_dict
)
757 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
759 # Verifying static routes are installed
761 "f1": {"static_routes": [{"network": BSR1_ADDR
, "next_hop": NEXT_HOP1
}]}
763 result
= verify_rib(tgen
, "ipv4", "f1", input_dict
, NEXT_HOP1
, protocol
="static")
764 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
769 {"network": [BSR1_ADDR
, CRP
], "next_hop": "blackhole", "delete": True}
774 tgen
, "ipv4", "f1", input_dict
, protocol
="static", expected
=False
776 assert result
is not True, (
777 "Testcase {} : Failed \n "
778 "Expected: Routes should not be present in {} RIB \n "
779 "Found: {}".format(tc_name
, "f1", result
)
782 step("Sending BSR after removing black-hole address for BSR and candidate RP")
783 step("Send BSR packet from b1 to FHR")
784 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet9")
785 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
787 step("Verify if b1 chosen as BSR in f1")
788 result
= verify_pim_bsr(tgen
, topo
, "f1", BSR_IP_1
)
789 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
792 group
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet9"]["group"]
793 step("Find the elected rp from bsrp-info in LHR l1")
794 rp
= find_rp_from_bsrp_info(tgen
, dut
, BSR_IP_1
, group
)
795 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
797 step("Verify RP in LHR l1")
798 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
799 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
801 step("clear BSM database before moving to next case")
802 clear_bsrp_data(tgen
, topo
)
804 write_test_footer(tc_name
)
807 def test_new_router_fwd_p0(request
):
809 1. Verify when new router added to the topology, FRR node will send
810 unicast BSM to new router
811 2. Verify if no forwarding bit is set , FRR is not forwarding the
812 BSM to other PIM nbrs
813 3. Verify multicast BSM is sent to new router when unicast BSM is disabled
819 s1-----f1-----i1-----l1----r1
828 i1 - Intermediate Router (also RP)
834 tc_name
= request
.node
.name
835 write_test_header(tc_name
)
837 # Don"t run this test if we have any failure.
838 if tgen
.routers_have_failure():
839 pytest
.skip(tgen
.errors
)
841 app_helper
.stop_all_hosts()
843 reset_config_on_routers(tgen
)
844 clear_pim_interface_traffic(tgen
, topo
)
846 result
= pre_config_to_bsm(
847 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
849 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
851 result
= pre_config_to_bsm(
852 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
854 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
856 GROUP_ADDRESS
= "225.1.1.1"
858 # Use scapy to send pre-defined packet from senser to receiver
859 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
860 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
862 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
865 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
866 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
868 # Verify bsr state in FHR
869 step("Verify if b1 chosen as BSR in f1")
870 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
871 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
873 # Verify bsr state in i1
874 step("Verify if b1 chosen as BSR in i1")
875 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
876 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
883 step("Verify mroute populated on l1")
884 result
= verify_mroutes(tgen
, "l1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
885 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
888 step("Reloading i1 and l1. Stop both. bring up l1 and then i1")
889 stop_router(tgen
, "i1")
890 start_router(tgen
, "i1")
891 stop_router(tgen
, "l1")
892 start_router(tgen
, "l1")
894 # Verify bsr state in i1
895 step("Verify BSR in i1 after restart while no new bsm sent from b1")
896 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
897 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
899 # Verify bsr state in l1
900 step("Verify no BSR in l1 as i1 would not forward the no-forward bsm")
901 result
= verify_pim_bsr(tgen
, topo
, "l1", bsr_ip
, expected
=False)
902 assert result
is not True, (
903 "Testcase {} : Failed \n "
904 "Expected: [{}]: BSR data should not be present after no-forward bsm \n "
905 "Found: {}".format(tc_name
, "l1", result
)
908 # unconfigure unicast bsm on f1-i1-eth2
909 step("unconfigure unicast bsm on f1-i1-eth2, will forward with only mcast")
910 enable_disable_pim_unicast_bsm(tgen
, "f1", "f1-i1-eth2", enable
=False)
912 # Reboot i1 to check if still bsm received with multicast address
913 step("Reboot i1 to check if still bsm received with multicast address")
914 stop_router(tgen
, "i1")
915 start_router(tgen
, "i1")
917 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
918 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
920 # Verify again if BSR is installed from bsm forwarded by f1
921 step("Verify again if BSR is installed from bsm forwarded by f1")
922 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
923 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
925 # Use scapy to send pre-defined packet from senser to receiver
926 step("Send another BSM packet from b1 which will reach l1(LHR)")
927 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet2")
928 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
931 step("Verify again if BSR is installed from bsm forwarded by i1")
932 result
= verify_pim_bsr(tgen
, topo
, "l1", bsr_ip
)
933 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
935 # Verify ip mroute populated again
936 step("Verify mroute again on l1 (lhr)")
937 result
= verify_mroutes(tgen
, "l1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
938 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
940 step("clear BSM database before moving to next case")
941 clear_bsrp_data(tgen
, topo
)
943 write_test_footer(tc_name
)
946 def test_int_bsm_config_p1(request
):
948 1. Verify BSM arrived on non bsm capable interface is dropped and
950 2. Verify group to RP info updated correctly in FRR node, after shut and
951 no-shut of BSM enable interfaces
957 s1-----f1-----i1-----l1----r1
966 i1 - Intermediate Router (also RP)
972 tc_name
= request
.node
.name
973 write_test_header(tc_name
)
975 # Don"t run this test if we have any failure.
976 if tgen
.routers_have_failure():
977 pytest
.skip(tgen
.errors
)
979 app_helper
.stop_all_hosts()
981 reset_config_on_routers(tgen
)
982 clear_pim_interface_traffic(tgen
, topo
)
984 result
= pre_config_to_bsm(
985 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
987 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
989 result
= pre_config_to_bsm(
990 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
992 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
994 GROUP_ADDRESS
= "225.1.1.1"
996 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
999 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1000 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1002 # Use scapy to send pre-defined packet from senser to receiver
1003 step("Send BSM packet from b1")
1004 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1005 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1007 # Verify bsr state in i1
1008 step("Verify if b1 is chosen as BSR in i1")
1009 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
1010 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1012 # check if mroute installed
1013 step("check if mroute installed in i1")
1018 result
= verify_mroutes(tgen
, "i1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
1019 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1021 # wait till bsm rp age out
1022 step("wait till bsm rp age out")
1023 clear_bsrp_data(tgen
, topo
)
1025 # check if mroute uninstalled because of rp age out
1026 step("check if mroute uninstalled because of rp age out in i1")
1027 result
= verify_mroutes(
1028 tgen
, "i1", src_addr
, GROUP_ADDRESS
, iif
, oil
, expected
=False
1030 assert result
is not True, (
1031 "Testcase {} : Failed \n "
1032 "Expected: [{}]: mroute (S, G) should be cleared from mroute table\n "
1033 "Found: {}".format(tc_name
, "i1", result
)
1036 # unconfigure bsm processing on f1 on f1-i1-eth2
1037 step("unconfigure bsm processing on f1 in f1-i1-eth2, will drop bsm")
1038 result
= enable_disable_pim_bsm(tgen
, "f1", "f1-i1-eth2", enable
=False)
1039 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1041 # Use scapy to send pre-defined packet from senser to receiver
1042 step("Send BSM packet from b1")
1043 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1044 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1046 # Verify bsr state in FHR
1047 step("Verify if b1 chosen as BSR in f1")
1048 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1049 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1051 # Verify bsr state in i1
1052 step("Verify if b1 is not chosen as BSR in i1")
1053 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
, expected
=False)
1054 assert result
is not True, (
1055 "Testcase {} : Failed \n "
1056 "Expected: [{}]: b1 should not be chosen as BSR \n "
1057 "Found: {}".format(tc_name
, "i1", result
)
1060 # check if mroute still not installed because of rp not available
1061 step("check if mroute still not installed because of rp not available")
1062 result
= verify_mroutes(
1063 tgen
, "i1", src_addr
, GROUP_ADDRESS
, iif
, oil
, expected
=False
1065 assert result
is not True, (
1066 "Testcase {} : Failed \n "
1067 "Expected: [{}]: mroute (S, G) should not be installed as RP is not available\n "
1068 "Found: {}".format(tc_name
, "i1", result
)
1071 # configure bsm processing on i1 on f1-i1-eth2
1072 step("configure bsm processing on f1 in f1-i1-eth2, will accept bsm")
1073 result
= enable_disable_pim_bsm(tgen
, "f1", "f1-i1-eth2", enable
=True)
1074 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1076 # Use scapy to send pre-defined packet from senser to receiver
1077 step("Send BSM packet again from b1")
1078 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet2")
1079 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1081 # Verify again if BSR is installed from bsm forwarded by f1
1082 step("Verify again if BSR is installed from bsm forwarded by f1")
1083 result
= verify_pim_bsr(tgen
, topo
, "i1", bsr_ip
)
1084 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1086 # verify ip mroute populated
1087 step("Verify ip mroute")
1088 result
= verify_mroutes(tgen
, "i1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
1089 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1091 # Shut/No shut the bsm rpf interface and check mroute on lhr(l1)
1092 step("Shut/No shut the bsm rpf interface and check mroute on lhr(l1)")
1094 shutdown_bringup_interface(tgen
, "l1", intf
, False)
1095 shutdown_bringup_interface(tgen
, "l1", intf
, True)
1100 result
= verify_mroutes(tgen
, "l1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
1101 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1103 step("clear BSM database before moving to next case")
1104 clear_bsrp_data(tgen
, topo
)
1106 write_test_footer(tc_name
)
1109 def test_static_rp_override_p1(request
):
1111 Verify static RP is preferred over BSR
1117 s1-----f1-----i1-----l1----r1
1126 i1 - Intermediate Router (also RP)
1131 tgen
= get_topogen()
1132 tc_name
= request
.node
.name
1133 write_test_header(tc_name
)
1135 # Don"t run this test if we have any failure.
1136 if tgen
.routers_have_failure():
1137 pytest
.skip(tgen
.errors
)
1139 app_helper
.stop_all_hosts()
1141 reset_config_on_routers(tgen
)
1142 clear_pim_interface_traffic(tgen
, topo
)
1144 result
= pre_config_to_bsm(
1145 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1147 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1149 result
= pre_config_to_bsm(
1150 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
1152 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1154 GROUP_ADDRESS
= "225.1.1.1"
1155 # Use scapy to send pre-defined packet from senser to receiver
1156 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1157 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1159 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
1162 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1163 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1165 # Verify bsr state in FHR
1166 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1167 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1170 step("Verify IGMP groups in LHR")
1173 result
= verify_igmp_groups(tgen
, dut
, intf
, GROUP_ADDRESS
)
1174 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1176 group
= "225.1.1.1/32"
1178 # Find the elected rp from bsrp-info
1179 step("Find the elected rp from bsrp-info in LHR l1")
1180 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1181 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1183 # Check RP detail in LHR
1184 step("Verify that BS RP in LHR l1")
1185 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
1186 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1189 # Verify upstream rpf for 225.1.1.1 is chosen as rp1
1190 step("Verify upstream rpf for 225.1.1.1 is chosen as bsrp")
1191 result
= verify_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, rp
[group
])
1192 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1194 # Configure a static rp for the group 225.1.1.1/32
1195 step("Configure a static rp 33.33.33.33 for the group 225.1.1.1/32 in l1")
1201 "rp_addr": "33.33.33.33",
1202 "group_addr_range": ["225.1.1.1/32"],
1208 result
= create_pim_config(tgen
, topo
, input_dict
)
1209 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1211 # Verify that static rp is configured over bsrp
1212 static_rp
= "33.33.33.33"
1213 step("Verify that Static RP in LHR in l1")
1214 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "Static", static_rp
)
1215 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1217 # Verify if upstream also reflects the static rp
1218 step("Verify upstream rpf for 225.1.1.1 is chosen as static in l1")
1219 result
= verify_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, static_rp
)
1220 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1222 # delete static rp for the group 225.1.1.1/32
1223 step("Delete static rp 33.33.33.33 for the group 225.1.1.1/32 in l1")
1229 "rp_addr": "33.33.33.33",
1230 "group_addr_range": ["225.1.1.1/32"],
1237 result
= create_pim_config(tgen
, topo
, input_dict
)
1238 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1240 # Verify if bsrp is installed back for the group 225.1.1.1/32
1241 step("Verify that BS RP in installed in LHR")
1242 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
1243 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1245 # Verify upstream rpf for 225.1.1.1 is chosen as bsrp
1246 step("Verify upstream rpf for 225.1.1.1 is chosen as bsrp in l1")
1247 result
= verify_pim_upstream_rpf(tgen
, topo
, dut
, iif
, GROUP_ADDRESS
, rp
[group
])
1248 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1250 step("clear BSM database before moving to next case")
1251 clear_bsrp_data(tgen
, topo
)
1253 write_test_footer(tc_name
)
1256 def test_bsmp_stress_add_del_restart_p2(request
):
1258 1. Verify adding/deleting the group to rp mapping and RP priority
1260 2. Verify RP and (*,G) detail after PIM process restart on FRR node
1266 s1-----f1-----i1-----l1----r1
1275 i1 - Intermediate Router (also RP)
1280 tgen
= get_topogen()
1281 tc_name
= request
.node
.name
1282 write_test_header(tc_name
)
1284 # Don"t run this test if we have any failure.
1285 if tgen
.routers_have_failure():
1286 pytest
.skip(tgen
.errors
)
1288 app_helper
.stop_all_hosts()
1290 reset_config_on_routers(tgen
)
1291 clear_pim_interface_traffic(tgen
, topo
)
1293 result
= pre_config_to_bsm(
1294 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1296 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1298 result
= pre_config_to_bsm(
1299 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
1301 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1303 GROUP_ADDRESS
= "225.1.1.1"
1305 # Use scapy to send pre-defined packet from senser to receiver
1306 step("Send BSR packet from b1 to FHR")
1307 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1308 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1310 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
1313 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1314 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1316 # Verify bsr state in FHR
1317 step("Verify if b1 is chosen as bsr in f1")
1318 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1319 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1322 group
= "225.1.1.0/24"
1323 # Find the elected rp from bsrp-info
1324 step("Find the elected rp from bsrp-info in LHR l1")
1325 rp1
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1326 assert rp1
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1328 # Check RP detail in LHR
1329 step("Verify RP in LHR l1")
1330 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp1
[group
])
1331 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1333 # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24
1334 step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24")
1335 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet6")
1336 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1338 # Find the elected rp from bsrp-info
1339 step("Find the elected rp from bsrp-info in LHR l1")
1340 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1341 assert rp2
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1342 logger
.info("RP old: %s RP2 new: %s", rp1
[group
], rp2
[group
])
1344 # Verify is the rp is different now
1345 assert rp1
[group
] != rp2
[group
], "Testcase {} :Failed \n Error {}".format(
1349 rp_add1
= rp1
[group
]
1350 rp_add2
= rp2
[group
]
1352 # Verify if that rp is installed
1353 step("Verify new RP in LHR installed")
1354 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add2
)
1355 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1357 step("Change rp priority in the bsm and send multiple times")
1360 # Send BSR pkt from b1 after putting back high prio rp for 225.1.1.0/24
1361 step("Send BSM from b1 to FHR put back high prio rp for 225.1.1.0/24")
1362 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1363 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1365 # Find the elected rp from bsrp-info
1366 step("Find the elected rp from bsrp-info in LHR")
1367 rp2
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1368 assert rp2
is not {}, "Testcase {} :Failed \n Error : RP not Found".format(
1372 # Verify is the rp is different now
1373 step("Verify now old RP is elected again")
1375 rp_add1
== rp2
[group
]
1376 ), "Testcase {} :Failed \n Error : rp expected {} rp received {}".format(
1377 tc_name
, rp_add1
, rp2
[group
]
1380 # Verify if that rp is installed
1381 step("Verify old RP in LHR installed")
1382 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add1
)
1383 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1385 # Send BSR packet from b1 after deleting high prio rp for 225.1.1.0/24
1386 step("Send BSM from b1 to FHR deleting high prio rp for 225.1.1.0/24")
1387 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet6")
1388 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1390 # Verify if that rp is installed
1391 step("Verify new RP(rp2) in LHR installed")
1392 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add2
)
1393 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1396 step("Restarting pimd in LHR")
1397 kill_router_daemons(tgen
, "l1", ["pimd"])
1398 start_router_daemons(tgen
, "l1", ["pimd"])
1399 logger
.info("Restarting done")
1401 # Verify if that rp is installed
1402 step("Verify old RP in LHR installed")
1403 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp_add2
)
1404 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1406 # Send IGMP join to LHR
1407 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1408 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1412 # VErify mroute created after pimd restart
1413 step("VErify mroute created after pimd restart")
1417 result
= verify_mroutes(tgen
, "l1", src_addr
, GROUP_ADDRESS
, iif
, oil
)
1418 assert result
is True, "Testcase {} :Failed \n Error: {}".format(tc_name
, result
)
1420 write_test_footer(tc_name
)
1423 def test_BSM_timeout_p0(request
):
1425 Verify BSM timeout on FRR1
1426 Verify RP state in FRR1 after Bootstrap timer expiry
1432 s1-----f1-----i1-----l1----r1
1441 i1 - Intermediate Router (also RP)
1446 tgen
= get_topogen()
1447 tc_name
= request
.node
.name
1448 write_test_header(tc_name
)
1450 # Don"t run this test if we have any failure.
1451 if tgen
.routers_have_failure():
1452 pytest
.skip(tgen
.errors
)
1454 app_helper
.stop_all_hosts()
1456 reset_config_on_routers(tgen
)
1457 clear_pim_interface_traffic(tgen
, topo
)
1459 result
= pre_config_to_bsm(
1460 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1462 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1464 result
= pre_config_to_bsm(
1465 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
1467 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1469 GROUP_ADDRESS
= "225.1.1.1"
1471 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
1473 # Use scapy to send pre-defined packet from senser to receiver
1474 step("send BSR packet from b1")
1475 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1476 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1478 # Send IGMP join for group 225.1.1.1 from receiver
1479 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1480 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1482 # Verify bsr state in FHR
1483 step("Verify bsr state in FHR f1")
1484 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1485 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1487 # Verify ip mroute in LHR
1488 step(" Verify ip mroute in LHR l1")
1493 result
= verify_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
1494 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1496 # Verify join state and join timer
1497 step("Verify join state and join timer in lhr l1")
1498 result
= verify_join_state_and_timer(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
1499 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1501 # Verify upstream IIF interface
1502 step("Verify upstream IIF interface in LHR l1")
1503 result
= verify_upstream_iif(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
1504 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1508 group
= "225.1.1.1/32"
1509 step("Verify RP mapping in LHR l1")
1510 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1511 assert rp
!= {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1513 logger
.info("Waiting for 130 secs to check BSR timeout")
1514 clear_bsrp_data(tgen
, topo
)
1516 # Verify if bsr has aged out
1517 step("Verify if bsr has aged out in f1")
1518 no_bsr_ip
= "0.0.0.0"
1519 result
= verify_pim_bsr(tgen
, topo
, "f1", no_bsr_ip
)
1520 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1522 result
= verify_pim_grp_rp_source(
1523 tgen
, topo
, "f1", group
, rp_source
="BSR", expected
=False
1525 assert result
is not True, (
1526 "Testcase {} : Failed \n "
1527 "Expected: [{}]: bsr should be aged out \n "
1528 "Found: {}".format(tc_name
, "f1", result
)
1531 # Verify RP mapping removed after hold timer expires
1532 group
= "225.1.1.1/32"
1533 step("Verify RP mapping removed after hold timer expires in l1")
1534 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1535 assert rp
== {}, "Testcase {} :Failed \n Error : RP found when not expected".format(
1539 # Verify iif is unknown after RP timeout
1540 step("Verify iif is unknown after RP timeout in l1")
1542 result
= verify_upstream_iif(
1543 tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
, joinState
="NotJoined"
1545 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1547 # Verify join state and join timer
1548 step("Verify join state and join timer in l1")
1550 result
= verify_join_state_and_timer(
1551 tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
, expected
=False
1553 assert result
is not True, (
1554 "Testcase {} : Failed \n "
1555 "Expected: [{}]: Upstream Join State timer should not run\n "
1556 "Found: {}".format(tc_name
, dut
, result
)
1559 # Verify ip mroute is not installed
1560 step("Verify mroute not installed in l1")
1561 result
= verify_mroutes(
1562 tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
, expected
=False
1564 assert result
is not True, (
1565 "Testcase {} : Failed \n "
1566 "Expected: [{}]: mroute (S, G) should not be installed \n "
1567 "Found: {}".format(tc_name
, dut
, result
)
1570 step("clear BSM database before moving to next case")
1571 clear_bsrp_data(tgen
, topo
)
1573 write_test_footer(tc_name
)
1576 def test_iif_join_state_p0(request
):
1578 1. Verify upstream interfaces(IIF) and join state are updated properly
1579 after BSM received for FRR
1580 2. Verify IIF and OIL in "show ip pim state" updated properly after
1587 s1-----f1-----i1-----l1----r1
1596 i1 - Intermediate Router (also RP)
1601 tgen
= get_topogen()
1602 tc_name
= request
.node
.name
1603 write_test_header(tc_name
)
1605 # Don"t run this test if we have any failure.
1606 if tgen
.routers_have_failure():
1607 pytest
.skip(tgen
.errors
)
1609 app_helper
.stop_all_hosts()
1611 reset_config_on_routers(tgen
)
1612 clear_pim_interface_traffic(tgen
, topo
)
1614 result
= pre_config_to_bsm(
1615 tgen
, topo
, tc_name
, "b1", "s1", "r1", "f1", "i1", "l1", "packet1"
1617 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1619 result
= pre_config_to_bsm(
1620 tgen
, topo
, tc_name
, "b2", "s1", "r1", "f1", "i1", "l1", "packet1"
1622 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1624 GROUP_ADDRESS
= "225.1.1.1"
1626 # Use scapy to send pre-defined packet from senser to receiver
1627 result
= scapy_send_bsr_raw_packet(tgen
, topo
, "b1", "f1", "packet1")
1628 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1630 bsr_ip
= topo
["routers"]["b1"]["bsm"]["bsr_packets"]["packet1"]["bsr"].split("/")[0]
1633 result
= app_helper
.run_join("r1", GROUP_ADDRESS
, "l1")
1634 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1636 # Verify bsr state in FHR
1637 result
= verify_pim_bsr(tgen
, topo
, "f1", bsr_ip
)
1638 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1641 step("Verify IGMP groups in LHR l1")
1644 result
= verify_igmp_groups(tgen
, dut
, intf
, GROUP_ADDRESS
)
1645 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1647 group
= "225.1.1.1/32"
1649 # Find the elected rp from bsrp-info
1650 step("Find the elected rp from bsrp-info in LHR l1")
1651 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1652 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1654 # Check RP detail in LHR
1655 step("Verify RP in LHR l1")
1656 result
= verify_pim_grp_rp_source(tgen
, topo
, dut
, group
, "BSR", rp
[group
])
1657 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1659 # Verify join state and join timer
1660 step("Verify join state and join timer l1")
1663 result
= verify_join_state_and_timer(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
1664 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1666 # Verify upstream IIF interface
1667 step("Verify upstream IIF interface l1")
1668 result
= verify_upstream_iif(tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
)
1669 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1671 # Verify IIF/OIL in pim state
1673 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
)
1674 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1678 step("Verify ip mroute in l1")
1679 result
= verify_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
1680 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1682 # Make RP unreachanble in LHR
1683 step("Make RP unreachanble in LHR l1")
1684 rp
= find_rp_from_bsrp_info(tgen
, dut
, bsr_ip
, group
)
1685 assert rp
is not {}, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1687 next_hop_lhr
= topo
["routers"]["i1"]["links"]["l1"]["ipv4"].split("/")[0]
1689 rp_ip
= rp
[group
] + "/32"
1693 {"network": rp_ip
, "next_hop": next_hop_lhr
, "delete": True}
1697 result
= create_static_routes(tgen
, input_dict
)
1698 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1700 # Verifying static routes are installed
1701 result
= verify_rib(
1702 tgen
, "ipv4", "l1", input_dict
, protocol
="static", expected
=False
1704 assert result
is not True, (
1705 "Testcase {} : Failed \n "
1706 "Expected: Routes should not be present in {} BGP RIB \n "
1707 "Found: {}".format(tc_name
, "l1", result
)
1710 # Check RP unreachable
1711 step("Check RP unreachability")
1713 result
= verify_upstream_iif(
1714 tgen
, dut
, iif
, src_addr
, GROUP_ADDRESS
, joinState
="NotJoined"
1716 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1718 # Verify that it is not installed
1719 step("Verify that it is not installed")
1721 result
= verify_pim_state(tgen
, dut
, iif
, oil
, GROUP_ADDRESS
, installed_fl
=0)
1722 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1724 # Verify mroute not installed
1725 step("Verify mroute not installed")
1726 result
= verify_mroutes(
1727 tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
, expected
=False
1729 assert result
is not True, (
1730 "Testcase {} : Failed \n "
1731 "Expected: [{}]: mroute (S, G) should not be installed \n "
1732 "Found: {}".format(tc_name
, dut
, result
)
1735 # Add back route for RP to make it reachable
1736 step("Add back route for RP to make it reachable")
1742 "next_hop": next_hop_lhr
,
1747 result
= create_static_routes(tgen
, input_dict
)
1748 assert result
is True, "Testcase {} :Failed \n Error {}".format(tc_name
, result
)
1750 # Verifying static routes are installed
1751 result
= verify_rib(tgen
, "ipv4", "l1", input_dict
, next_hop_lhr
, protocol
="static")
1752 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1754 # Verify that (*,G) installed in mroute again
1756 result
= verify_mroutes(tgen
, dut
, src_addr
, GROUP_ADDRESS
, iif
, oil
)
1757 assert result
is True, "Testcase {}:Failed \n Error: {}".format(tc_name
, result
)
1759 step("clear BSM database before moving to next case")
1760 clear_bsrp_data(tgen
, topo
)
1762 write_test_footer(tc_name
)
1765 if __name__
== "__main__":
1766 args
= ["-s"] + sys
.argv
[1:]
1767 sys
.exit(pytest
.main(args
))