]> git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/ospfv3_basic_functionality/test_ospfv3_asbr_summary_topo1.py
Merge pull request #12645 from gpnaveen/ospf_error_msg_enhancements
[mirror_frr.git] / tests / topotests / ospfv3_basic_functionality / test_ospfv3_asbr_summary_topo1.py
1 #!/usr/bin/python
2 # SPDX-License-Identifier: ISC
3
4 #
5 # Copyright (c) 2021 by VMware, Inc. ("VMware")
6 # Used Copyright (c) 2018 by Network Device Education Foundation, Inc.
7 # ("NetDEF") in this file.
8 #
9
10
11 """OSPF Summarisation Functionality Automation."""
12 import os
13 import sys
14 import time
15 import pytest
16
17 # Save the Current Working Directory to find configuration files.
18 CWD = os.path.dirname(os.path.realpath(__file__))
19 sys.path.append(os.path.join(CWD, "../"))
20 sys.path.append(os.path.join(CWD, "../lib/"))
21
22 # pylint: disable=C0413
23 # Import topogen and topotest helpers
24 from lib.topogen import Topogen, get_topogen
25 import ipaddress
26 from time import sleep
27
28 # Import topoJson from lib, to create topology and initial configuration
29 from lib.common_config import (
30 start_topology,
31 write_test_header,
32 kill_router_daemons,
33 write_test_footer,
34 reset_config_on_routers,
35 stop_router,
36 start_router,
37 verify_rib,
38 create_static_routes,
39 step,
40 start_router_daemons,
41 create_route_maps,
42 shutdown_bringup_interface,
43 create_prefix_lists,
44 create_route_maps,
45 create_interfaces_cfg,
46 )
47 from lib.topolog import logger
48 from lib.topojson import build_config_from_json
49 from lib.ospf import (
50 verify_ospf6_neighbor,
51 clear_ospf,
52 verify_ospf6_rib,
53 create_router_ospf,
54 verify_ospf_summary,
55 )
56
57 pytestmark = [pytest.mark.ospfd, pytest.mark.staticd]
58
59 # Global variables
60 topo = None
61
62 NETWORK = {
63 "ipv4": [
64 "11.0.20.1/32",
65 "11.0.20.2/32",
66 "11.0.20.3/32",
67 "11.0.20.4/32",
68 "11.0.20.5/32",
69 ],
70 "ipv6": [
71 "2011:0:20::1/128",
72 "2011:0:20::2/128",
73 "2011:0:20::3/128",
74 "2011:0:20::4/128",
75 "2011:0:20::5/128",
76 ],
77 }
78 NETWORK_11 = {
79 "ipv4": ["11.0.20.6/32", "11.0.20.7/32"],
80 "ipv6": ["2011:0:20::6/128", "2011:0:20::7/128"],
81 }
82
83 NETWORK2 = {
84 "ipv4": [
85 "12.0.20.1/32",
86 "12.0.20.2/32",
87 "12.0.20.3/32",
88 "12.0.20.4/32",
89 "12.0.20.5/32",
90 ],
91 "ipv6": [
92 "2012:0:20::1/128",
93 "2012:0:20::2/128",
94 "2012:0:20::3/128",
95 "2012:0:20::4/128",
96 "2012:0:20::5/128",
97 ],
98 }
99 SUMMARY = {
100 "ipv4": ["11.0.0.0/8", "12.0.0.0/8", "11.0.0.0/24"],
101 "ipv6": ["2011::/32", "2012::/32", "2011::/64", "2011::/24"],
102 }
103 """
104 TOPOOLOGY =
105 Please view in a fixed-width font such as Courier.
106 +---+ A0 +---+
107 +R1 +------------+R2 |
108 +-+-+- +--++
109 | -- -- |
110 | -- A0 -- |
111 A0| ---- |
112 | ---- | A0
113 | -- -- |
114 | -- -- |
115 +-+-+- +-+-+
116 +R0 +-------------+R3 |
117 +---+ A0 +---+
118
119 TESTCASES =
120 1. OSPF summarisation functionality.
121 2. OSPF summarisation with advertise and no advertise option
122 3. OSPF summarisation with route map modification of metric type.
123 4. OSPF CLI Show verify ospf ASBR summary config and show commands behaviours.
124 5. OSPF summarisation Chaos.
125 """
126
127
128 def setup_module(mod):
129 """
130 Sets up the pytest environment
131
132 * `mod`: module name
133 """
134 testsuite_run_time = time.asctime(time.localtime(time.time()))
135 logger.info("Testsuite start time: {}".format(testsuite_run_time))
136 logger.info("=" * 40)
137
138 logger.info("Running setup_module to create topology")
139
140 # This function initiates the topology build with Topogen...
141 json_file = "{}/ospfv3_asbr_summary_topo1.json".format(CWD)
142 tgen = Topogen(json_file, mod.__name__)
143 global topo
144 topo = tgen.json_topo
145 # ... and here it calls Mininet initialization functions.
146
147 # Starting topology, create tmp files which are loaded to routers
148 # to start daemons and then start routers
149 start_topology(tgen)
150
151 # Creating configuration from JSON
152 build_config_from_json(tgen, topo)
153
154 # Don't run this test if we have any failure.
155 if tgen.routers_have_failure():
156 pytest.skip(tgen.errors)
157 # Api call verify whether OSPF is converged
158 ospf_covergence = verify_ospf6_neighbor(tgen, topo)
159 assert ospf_covergence is True, "setup_module :Failed \n Error: {}".format(
160 ospf_covergence
161 )
162
163 logger.info("Running setup_module() done")
164
165
166 def teardown_module(mod):
167 """
168 Teardown the pytest environment.
169
170 * `mod`: module name
171 """
172
173 logger.info("Running teardown_module to delete topology")
174
175 tgen = get_topogen()
176
177 # Stop toplogy and Remove tmp files
178 tgen.stop_topology()
179
180 logger.info(
181 "Testsuite end time: {}".format(time.asctime(time.localtime(time.time())))
182 )
183 logger.info("=" * 40)
184
185
186 def red_static(dut, config=True):
187 """
188 Local 'def' for Redstribute static routes inside ospf.
189
190 Parameters
191 ----------
192 * `dut` : DUT on which configs have to be made.
193 * `config` : True or False, True by default for configure, set False for
194 unconfiguration.
195 """
196 global topo
197 tgen = get_topogen()
198 if config:
199 ospf_red = {dut: {"ospf6": {"redistribute": [{"redist_type": "static"}]}}}
200 else:
201 ospf_red = {
202 dut: {
203 "ospf6": {"redistribute": [{"redist_type": "static", "delete": True}]}
204 }
205 }
206 result = create_router_ospf(tgen, topo, ospf_red)
207 assert result is True, "Testcase : Failed \n Error: {}".format(result)
208
209
210 def red_connected(dut, config=True):
211 """
212 Local 'def' for Redstribute connected routes inside ospf
213
214 Parameters
215 ----------
216 * `dut` : DUT on which configs have to be made.
217 * `config` : True or False, True by default for configure, set False for
218 unconfiguration.
219 """
220 global topo
221 tgen = get_topogen()
222 if config:
223 ospf_red = {dut: {"ospf6": {"redistribute": [{"redist_type": "connected"}]}}}
224 else:
225 ospf_red = {
226 dut: {
227 "ospf6": {
228 "redistribute": [{"redist_type": "connected", "delete": True}]
229 }
230 }
231 }
232 result = create_router_ospf(tgen, topo, ospf_red)
233 assert result is True, "Testcase: Failed \n Error: {}".format(result)
234
235
236 # ##################################
237 # Test cases start here.
238 # ##################################
239
240
241 def test_ospfv3_type5_summary_tc42_p0(request):
242 """OSPF summarisation functionality."""
243 tc_name = request.node.name
244 write_test_header(tc_name)
245 tgen = get_topogen()
246
247 # Don't run this test if we have any failure.
248 if tgen.routers_have_failure():
249 pytest.skip(tgen.errors)
250
251 global topo
252 step("Bring up the base config as per the topology")
253 reset_config_on_routers(tgen)
254
255 protocol = "ospf"
256
257 step(
258 "Configure 5 static routes from the same network on R0"
259 "5 static routes from different networks and redistribute in R0"
260 )
261 input_dict_static_rtes = {
262 "r0": {
263 "static_routes": [
264 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
265 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
266 ]
267 }
268 }
269 result = create_static_routes(tgen, input_dict_static_rtes)
270 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
271
272 dut = "r0"
273 red_static(dut)
274
275 step("Verify that routes are learnt on R1.")
276 dut = "r1"
277
278 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
279 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
280 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
281 assert (
282 result is True
283 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
284
285 step(
286 "Configure External Route summary in R0 to summarise 5"
287 " routes to one route. with aggregate timer as 6 sec"
288 )
289
290 ospf_summ_r1 = {
291 "r0": {
292 "ospf6": {
293 "summary-address": [
294 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
295 ],
296 "aggr_timer": 6,
297 }
298 }
299 }
300 result = create_router_ospf(tgen, topo, ospf_summ_r1)
301 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
302
303 step(
304 "Verify that external routes are summarised to configured summary "
305 "address on R0 after 5 secs of delay timer expiry and only one "
306 "route is sent to R1."
307 )
308 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
309 dut = "r1"
310
311 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
312 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
313
314 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
315 assert (
316 result is True
317 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
318
319 step("Verify that show ip ospf summary should show the summaries.")
320 input_dict = {
321 SUMMARY["ipv6"][0]: {
322 "summaryAddress": SUMMARY["ipv6"][0],
323 "metricType": "E2",
324 "Metric": 20,
325 "Tag": 0,
326 "externalRouteCount": 5,
327 }
328 }
329 dut = "r0"
330 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
331 assert (
332 result is True
333 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
334
335 step("Verify that originally advertised routes are withdraw from there peer.")
336 input_dict = {
337 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
338 }
339 dut = "r1"
340 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
341 assert (
342 result is not True
343 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
344 tc_name, result
345 )
346
347 result = verify_rib(
348 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
349 )
350 assert (
351 result is not True
352 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
353
354 step("Delete the configured summary")
355 ospf_summ_r1 = {
356 "r0": {
357 "ospf6": {
358 "summary-address": [
359 {
360 "prefix": SUMMARY["ipv6"][0].split("/")[0],
361 "mask": "32",
362 "del_aggr_timer": True,
363 "delete": True,
364 }
365 ]
366 }
367 }
368 }
369 result = create_router_ospf(tgen, topo, ospf_summ_r1)
370 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
371
372 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
373 dut = "r1"
374 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
375 assert (
376 result is not True
377 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
378 tc_name, result
379 )
380
381 result = verify_rib(
382 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
383 )
384 assert (
385 result is not True
386 ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name)
387
388 step("show ip ospf summary should not have any summary address.")
389 input_dict = {
390 SUMMARY["ipv6"][0]: {
391 "summaryAddress": SUMMARY["ipv6"][0],
392 "metricType": "E2",
393 "Metric": 20,
394 "Tag": 0,
395 "externalRouteCount": 5,
396 }
397 }
398 dut = "r0"
399 result = verify_ospf_summary(
400 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
401 )
402 assert (
403 result is not True
404 ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name)
405
406 dut = "r1"
407 step("All 5 routes are advertised after deletion of configured summary.")
408
409 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
410 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
411
412 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
413 assert (
414 result is True
415 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
416
417 step("configure the summary again and delete static routes .")
418 ospf_summ_r1 = {
419 "r0": {
420 "ospf6": {
421 "summary-address": [
422 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
423 ]
424 }
425 }
426 }
427 result = create_router_ospf(tgen, topo, ospf_summ_r1)
428 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
429
430 input_dict = {
431 SUMMARY["ipv6"][0]: {
432 "summaryAddress": SUMMARY["ipv6"][0],
433 "metricType": "E2",
434 "Metric": 20,
435 "Tag": 0,
436 "externalRouteCount": 5,
437 }
438 }
439 dut = "r0"
440 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
441 assert (
442 result is True
443 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
444
445 input_dict = {
446 "r0": {
447 "static_routes": [
448 {"network": NETWORK["ipv6"], "next_hop": "blackhole", "delete": True}
449 ]
450 }
451 }
452 result = create_static_routes(tgen, input_dict)
453 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
454
455 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
456 step("Verify that summary route is withdrawn from R1.")
457
458 dut = "r1"
459 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
460 assert (
461 result is not True
462 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
463 tc_name, result
464 )
465
466 result = verify_rib(
467 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
468 )
469 assert (
470 result is not True
471 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
472
473 step("Add back static routes.")
474 input_dict_static_rtes = {
475 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
476 }
477 result = create_static_routes(tgen, input_dict_static_rtes)
478 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
479
480 step(
481 "Verify that external routes are summarised to configured summary"
482 " address on R0 and only one route is sent to R1."
483 )
484 dut = "r1"
485
486 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes, expected=False)
487 assert (
488 result is not True
489 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
490 tc_name, result
491 )
492
493 result = verify_rib(
494 tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol, expected=False
495 )
496 assert (
497 result is not True
498 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
499
500 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
501 dut = "r1"
502
503 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
504 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
505
506 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
507 assert (
508 result is True
509 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
510
511 step("Verify that show ip ospf summary should show configure summaries.")
512
513 input_dict = {
514 SUMMARY["ipv6"][0]: {
515 "summaryAddress": SUMMARY["ipv6"][0],
516 "metricType": "E2",
517 "Metric": 20,
518 "Tag": 0,
519 "externalRouteCount": 5,
520 }
521 }
522 dut = "r0"
523 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
524 assert (
525 result is True
526 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
527
528 step("Configure new static route which is matching configured summary.")
529 input_dict_static_rtes = {
530 "r0": {
531 "static_routes": [{"network": NETWORK_11["ipv6"], "next_hop": "blackhole"}]
532 }
533 }
534 result = create_static_routes(tgen, input_dict_static_rtes)
535 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
536
537 # step("verify that summary lsa is not refreshed.")
538 # show ip ospf database command is not working, waiting for DEV fix.
539
540 step("Delete one of the static route.")
541 input_dict_static_rtes = {
542 "r0": {
543 "static_routes": [
544 {"network": NETWORK_11["ipv6"], "next_hop": "blackhole", "delete": True}
545 ]
546 }
547 }
548 result = create_static_routes(tgen, input_dict_static_rtes)
549 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
550
551 # step("verify that summary lsa is not refreshed.")
552 # show ip ospf database command is not working, waiting for DEV fix.
553
554 # step("Verify that deleted static route is removed from ospf LSDB.")
555 # show ip ospf database command is not working, waiting for DEV fix.
556
557 step(
558 "Configure redistribute connected and configure ospf external"
559 " summary address to summarise the connected routes."
560 )
561
562 dut = "r0"
563 red_connected(dut)
564 clear_ospf(tgen, dut, ospf="ospf6")
565
566 ip = topo["routers"]["r0"]["links"]["r3"]["ipv6"]
567
568 ip_net = str(ipaddress.ip_interface(u"{}".format(ip)).network)
569 ospf_summ_r1 = {
570 "r0": {
571 "ospf6": {
572 "summary-address": [{"prefix": ip_net.split("/")[0], "mask": "8"}]
573 }
574 }
575 }
576 result = create_router_ospf(tgen, topo, ospf_summ_r1)
577 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
578
579 step(
580 "Verify that external routes are summarised to configured "
581 "summary address on R0 and only one route is sent to R1."
582 )
583
584 input_dict_summary = {"r0": {"static_routes": [{"network": "fd00::/64"}]}}
585 dut = "r1"
586 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
587 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
588
589 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
590 assert (
591 result is True
592 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
593
594 step("Shut one of the interface")
595 intf = topo["routers"]["r0"]["links"]["r3-link0"]["interface"]
596 shutdown_bringup_interface(tgen, dut, intf, False)
597
598 # step("verify that summary lsa is not refreshed.")
599 # show ip ospf database command is not working, waiting for DEV fix.
600
601 # step("Verify that deleted connected route is removed from ospf LSDB.")
602 # show ip ospf database command is not working, waiting for DEV fix.
603
604 step("Un do shut the interface")
605 shutdown_bringup_interface(tgen, dut, intf, True)
606
607 # step("verify that summary lsa is not refreshed.")
608 # show ip ospf database command is not working, waiting for DEV fix.
609
610 # step("Verify that deleted connected route is removed from ospf LSDB.")
611 # show ip ospf database command is not working, waiting for DEV fix.
612
613 step("Delete OSPF process.")
614 ospf_del = {"r0": {"ospf6": {"delete": True}}}
615 result = create_router_ospf(tgen, topo, ospf_del)
616 assert result is True, "Testcase : Failed \n Error: {}".format(result)
617
618 step("Reconfigure ospf process with summary")
619 reset_config_on_routers(tgen)
620
621 input_dict_static_rtes = {
622 "r0": {
623 "static_routes": [
624 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
625 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
626 ]
627 }
628 }
629 result = create_static_routes(tgen, input_dict_static_rtes)
630 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
631
632 dut = "r0"
633 red_static(dut)
634 red_connected(dut)
635 ospf_summ_r1 = {
636 "r0": {
637 "ospf6": {
638 "summary-address": [
639 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
640 ]
641 }
642 }
643 }
644 result = create_router_ospf(tgen, topo, ospf_summ_r1)
645 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
646 step(
647 "Verify that external routes are summarised to configured summary "
648 "address on R0 and only one route is sent to R1."
649 )
650
651 input_dict = {
652 SUMMARY["ipv6"][0]: {
653 "summaryAddress": SUMMARY["ipv6"][0],
654 "metricType": "E2",
655 "Metric": 20,
656 "Tag": 0,
657 "externalRouteCount": 5,
658 }
659 }
660 dut = "r0"
661 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
662 assert (
663 result is True
664 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
665
666 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
667
668 dut = "r1"
669 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
670 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
671
672 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
673 assert (
674 result is True
675 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
676
677 ospf_summ_r1 = {
678 "r0": {
679 "ospf6": {
680 "summary-address": [
681 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
682 ]
683 }
684 }
685 }
686 result = create_router_ospf(tgen, topo, ospf_summ_r1)
687 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
688
689 # step("verify that summary lsa is not refreshed.")
690 # show ip ospf database command is not working, waiting for DEV fix.
691
692 step("Delete the redistribute command in ospf.")
693 dut = "r0"
694 red_connected(dut, config=False)
695 red_static(dut, config=False)
696
697 step("Verify that summary route is withdrawn from the peer.")
698
699 dut = "r1"
700 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
701 assert (
702 result is not True
703 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
704 tc_name, result
705 )
706
707 result = verify_rib(
708 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
709 )
710 assert (
711 result is not True
712 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
713
714 ospf_summ_r1 = {
715 "r0": {
716 "ospf6": {
717 "summary-address": [
718 {
719 "prefix": SUMMARY["ipv6"][0].split("/")[0],
720 "mask": "32",
721 "metric": "1234",
722 }
723 ]
724 }
725 }
726 }
727 result = create_router_ospf(tgen, topo, ospf_summ_r1)
728 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
729
730 write_test_footer(tc_name)
731
732
733 def test_ospfv3_type5_summary_tc43_p0(request):
734 """OSPF summarisation with metric type 2."""
735 tc_name = request.node.name
736 write_test_header(tc_name)
737 tgen = get_topogen()
738
739 # Don't run this test if we have any failure.
740 if tgen.routers_have_failure():
741 pytest.skip(tgen.errors)
742
743 global topo
744 step("Bring up the base config as per the topology")
745 reset_config_on_routers(tgen)
746
747 protocol = "ospf"
748
749 step(
750 "Configure 5 static routes from the same network on R0"
751 "5 static routes from different networks and redistribute in R0"
752 )
753 input_dict_static_rtes = {
754 "r0": {
755 "static_routes": [
756 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
757 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
758 ]
759 }
760 }
761 result = create_static_routes(tgen, input_dict_static_rtes)
762 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
763
764 dut = "r0"
765 red_static(dut)
766
767 step("Verify that routes are learnt on R1.")
768 dut = "r1"
769
770 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
771 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
772 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
773 assert (
774 result is True
775 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
776
777 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
778 ospf_summ_r1 = {
779 "r0": {
780 "ospf6": {
781 "summary-address": [
782 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
783 ]
784 }
785 }
786 }
787 result = create_router_ospf(tgen, topo, ospf_summ_r1)
788 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
789 step(
790 "Verify that external routes are summarised to configured summary "
791 "address on R0 after 5 secs of delay timer expiry and only one "
792 "route is sent to R1."
793 )
794 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
795 dut = "r1"
796
797 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
798 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
799
800 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
801 assert (
802 result is True
803 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
804
805 step("Verify that show ip ospf summary should show the summaries.")
806 input_dict = {
807 SUMMARY["ipv6"][0]: {
808 "summaryAddress": SUMMARY["ipv6"][0],
809 "metricType": "E2",
810 "Metric": 20,
811 "Tag": 0,
812 "externalRouteCount": 5,
813 }
814 }
815 dut = "r0"
816 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
817 assert (
818 result is True
819 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
820
821 step("Change the summary address mask to lower match (ex - 16 to 8)")
822 ospf_summ_r1 = {
823 "r0": {
824 "ospf6": {
825 "summary-address": [
826 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "16"},
827 {
828 "prefix": SUMMARY["ipv6"][0].split("/")[0],
829 "mask": "32",
830 "delete": True,
831 },
832 ]
833 }
834 }
835 }
836 result = create_router_ospf(tgen, topo, ospf_summ_r1)
837 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
838
839 sleep(5)
840
841 input_dict = {
842 "2011::/16": {
843 "summaryAddress": "2011::/16",
844 "metricType": "E2",
845 "Metric": 20,
846 "Tag": 0,
847 "externalRouteCount": 5,
848 }
849 }
850 dut = "r0"
851 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
852 assert (
853 result is True
854 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
855
856 step(
857 "Verify that external routes(static / connected) are summarised"
858 " to configured summary address with newly configured mask."
859 )
860
861 input_dict_summary = {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
862 dut = "r1"
863
864 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
865 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
866
867 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
868 assert (
869 result is True
870 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
871
872 step("Change the summary address mask to higher match (ex - 8 to 24)")
873 ospf_summ_r1 = {
874 "r0": {
875 "ospf6": {
876 "summary-address": [
877 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
878 ]
879 }
880 }
881 }
882 result = create_router_ospf(tgen, topo, ospf_summ_r1)
883 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
884
885 input_dict = {
886 "2011::/32": {
887 "summaryAddress": "2011::/32",
888 "metricType": "E2",
889 "Metric": 20,
890 "Tag": 0,
891 "externalRouteCount": 0,
892 }
893 }
894 dut = "r0"
895 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
896 assert (
897 result is True
898 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
899
900 step(
901 "Verify that external routes(static / connected) are summarised"
902 " to configured summary address with newly configured mask."
903 )
904 step("Configure 2 summary address with different mask of same network.")
905 step(
906 "Verify that external routes(static / connected) are summarised "
907 "to configured summary address with highest match."
908 )
909
910 input_dict_summary = {"r0": {"static_routes": [{"network": "2011::0/32"}]}}
911 dut = "r1"
912
913 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
914 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
915
916 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
917 assert (
918 result is True
919 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
920
921 step(" Un configure one of the summary address.")
922 ospf_summ_r1 = {
923 "r0": {
924 "ospf6": {
925 "summary-address": [
926 {
927 "prefix": SUMMARY["ipv6"][0].split("/")[0],
928 "mask": "32",
929 "delete": True,
930 }
931 ]
932 }
933 }
934 }
935 result = create_router_ospf(tgen, topo, ospf_summ_r1)
936 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
937
938 sleep(5)
939
940 step(
941 "Verify that external routes(static / connected) are summarised"
942 " to configured summary address with newly configured mask."
943 )
944
945 input_dict_summary = {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
946 dut = "r1"
947
948 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
949 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
950
951 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
952 assert (
953 result is True
954 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
955
956 ospf_summ_r1 = {
957 "r0": {
958 "ospf6": {
959 "summary-address": [
960 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "16"}
961 ]
962 }
963 }
964 }
965 result = create_router_ospf(tgen, topo, ospf_summ_r1)
966 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
967
968 step(
969 "Verify that external routes(static / connected) are summarised "
970 "to configured summary address with highest match."
971 )
972 input_dict_summary = {"r0": {"static_routes": [{"network": "2011::0/16"}]}}
973 dut = "r1"
974
975 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
976 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
977
978 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
979 assert (
980 result is True
981 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
982
983 write_test_footer(tc_name)
984
985
986 def ospfv3_type5_summary_tc45_p0(request):
987 """OSPF summarisation with Tag option"""
988 tc_name = request.node.name
989 write_test_header(tc_name)
990 tgen = get_topogen()
991
992 # Don't run this test if we have any failure.
993 if tgen.routers_have_failure():
994 pytest.skip(tgen.errors)
995
996 global topo
997 step("Bring up the base config as per the topology")
998 step("Configure OSPF on all the routers of the topology.")
999 reset_config_on_routers(tgen)
1000
1001 protocol = "ospf"
1002
1003 step(
1004 "Configure 5 static routes from the same network on R0"
1005 "5 static routes from different networks and redistribute in R0"
1006 )
1007 input_dict_static_rtes = {
1008 "r0": {
1009 "static_routes": [
1010 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1011 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1012 ]
1013 }
1014 }
1015 result = create_static_routes(tgen, input_dict_static_rtes)
1016 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1017
1018 dut = "r0"
1019 red_static(dut)
1020
1021 step("Verify that routes are learnt on R1.")
1022 dut = "r1"
1023
1024 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1025 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1026 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1027 assert (
1028 result is True
1029 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1030
1031 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
1032 ospf_summ_r1 = {
1033 "r0": {
1034 "ospf6": {
1035 "summary-address": [
1036 {
1037 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1038 "mask": "32",
1039 "tag": "1234",
1040 }
1041 ]
1042 }
1043 }
1044 }
1045 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1046 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1047
1048 step(
1049 "Verify that external routes are summarised to configured summary"
1050 " address on R0 and only one route is sent to R1 with configured tag."
1051 )
1052 input_dict_summary = {
1053 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "1234"}]}
1054 }
1055 dut = "r1"
1056
1057 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1058 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1059
1060 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1061 assert (
1062 result is True
1063 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1064
1065 step("Verify that show ip ospf summary should show the summaries with tag.")
1066 input_dict = {
1067 SUMMARY["ipv6"][0]: {
1068 "summaryAddress": SUMMARY["ipv6"][0],
1069 "metricType": "E2",
1070 "Metric": 20,
1071 "Tag": 1234,
1072 "externalRouteCount": 5,
1073 }
1074 }
1075 dut = "r0"
1076 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1077 assert (
1078 result is True
1079 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
1080
1081 step("Delete the configured summary")
1082 ospf_summ_r1 = {
1083 "r0": {
1084 "ospf6": {
1085 "summary-address": [
1086 {
1087 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1088 "mask": "32",
1089 "tag": "1234",
1090 "delete": True,
1091 }
1092 ]
1093 }
1094 }
1095 }
1096 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1097 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1098
1099 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1100 dut = "r1"
1101 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
1102 assert (
1103 result is not True
1104 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1105 tc_name, result
1106 )
1107
1108 result = verify_rib(
1109 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1110 )
1111 assert (
1112 result is not True
1113 ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name)
1114
1115 step("show ip ospf summary should not have any summary address.")
1116 input_dict = {
1117 SUMMARY["ipv6"][0]: {
1118 "summaryAddress": SUMMARY["ipv6"][0],
1119 "metricType": "E2",
1120 "Metric": 20,
1121 "Tag": 1234,
1122 "externalRouteCount": 5,
1123 }
1124 }
1125 dut = "r0"
1126 result = verify_ospf_summary(
1127 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1128 )
1129 assert (
1130 result is not True
1131 ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name)
1132
1133 step("Configure Min tag value")
1134 ospf_summ_r1 = {
1135 "r0": {
1136 "ospf6": {
1137 "summary-address": [
1138 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32", "tag": 1}
1139 ]
1140 }
1141 }
1142 }
1143 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1144 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1145 input_dict_summary = {
1146 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "1"}]}
1147 }
1148 dut = "r1"
1149
1150 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1151 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1152
1153 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1154 assert (
1155 result is True
1156 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1157
1158 step("Verify that show ip ospf summary should show the summaries with tag.")
1159 input_dict = {
1160 SUMMARY["ipv6"][0]: {
1161 "summaryAddress": SUMMARY["ipv6"][0],
1162 "metricType": "E2",
1163 "Metric": 20,
1164 "Tag": 1,
1165 "externalRouteCount": 5,
1166 }
1167 }
1168 dut = "r0"
1169 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1170 assert (
1171 result is True
1172 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
1173
1174 step("Configure Max Tag Value")
1175 ospf_summ_r1 = {
1176 "r0": {
1177 "ospf6": {
1178 "summary-address": [
1179 {
1180 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1181 "mask": "32",
1182 "tag": 4294967295,
1183 }
1184 ]
1185 }
1186 }
1187 }
1188 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1189 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1190
1191 input_dict_summary = {
1192 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "4294967295"}]}
1193 }
1194 dut = "r1"
1195
1196 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1197 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1198
1199 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1200 assert (
1201 result is True
1202 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1203
1204 step(
1205 "Verify that boundary values tags are used for summary route"
1206 " using show ip ospf route command."
1207 )
1208 input_dict = {
1209 SUMMARY["ipv6"][0]: {
1210 "summaryAddress": SUMMARY["ipv6"][0],
1211 "metricType": "E2",
1212 "Metric": 20,
1213 "Tag": 4294967295,
1214 "externalRouteCount": 5,
1215 }
1216 }
1217 dut = "r0"
1218 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1219 assert (
1220 result is True
1221 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
1222
1223 step("configure new static route with different tag.")
1224 input_dict_static_rtes_11 = {
1225 "r0": {
1226 "static_routes": [
1227 {"network": NETWORK_11["ipv6"], "next_hop": "blackhole", "tag": "88888"}
1228 ]
1229 }
1230 }
1231 result = create_static_routes(tgen, input_dict_static_rtes_11)
1232 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1233
1234 step("New tag has not been used by summary address.")
1235
1236 input_dict_summary = {
1237 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "88888"}]}
1238 }
1239 dut = "r1"
1240
1241 result = verify_ospf6_rib(
1242 tgen, dut, input_dict_summary, tag="88888", expected=False
1243 )
1244 assert (
1245 result is not True
1246 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1247 tc_name, result
1248 )
1249
1250 result = verify_rib(
1251 tgen,
1252 "ipv6",
1253 dut,
1254 input_dict_summary,
1255 protocol=protocol,
1256 tag="88888",
1257 expected=False,
1258 )
1259 assert (
1260 result is not True
1261 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
1262
1263 step(
1264 "Verify that boundary values tags are used for summary route"
1265 " using show ip ospf route command."
1266 )
1267 input_dict = {
1268 SUMMARY["ipv6"][0]: {
1269 "summaryAddress": SUMMARY["ipv6"][0],
1270 "metricType": "E2",
1271 "Metric": 20,
1272 "Tag": 88888,
1273 "externalRouteCount": 5,
1274 }
1275 }
1276 dut = "r0"
1277 result = verify_ospf_summary(
1278 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1279 )
1280 assert (
1281 result is not True
1282 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
1283
1284 step("Delete the configured summary address")
1285 ospf_summ_r1 = {
1286 "r0": {
1287 "ospf6": {
1288 "summary-address": [
1289 {
1290 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1291 "mask": "32",
1292 "tag": 4294967295,
1293 "delete": True,
1294 }
1295 ]
1296 }
1297 }
1298 }
1299 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1300 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1301
1302 step(
1303 "Verify that 6 routes are advertised to neighbour with 5 routes"
1304 " without any tag, 1 route with tag."
1305 )
1306
1307 dut = "r1"
1308 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1309 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1310 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1311 assert (
1312 result is True
1313 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1314
1315 step("Verify that summary address is flushed from neighbor.")
1316
1317 dut = "r1"
1318 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
1319 assert (
1320 result is not True
1321 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1322 tc_name, result
1323 )
1324
1325 result = verify_rib(
1326 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1327 )
1328 assert (
1329 result is not True
1330 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
1331
1332 step("Configure summary first & then configure matching static route.")
1333
1334 input_dict_static_rtes = {
1335 "r0": {
1336 "static_routes": [
1337 {"network": NETWORK["ipv6"], "next_hop": "blackhole", "delete": True},
1338 {"network": NETWORK2["ipv6"], "next_hop": "blackhole", "delete": True},
1339 ]
1340 }
1341 }
1342 result = create_static_routes(tgen, input_dict_static_rtes)
1343 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1344
1345 ospf_summ_r1 = {
1346 "r0": {
1347 "ospf6": {
1348 "summary-address": [
1349 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
1350 ]
1351 }
1352 }
1353 }
1354 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1355 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1356
1357 input_dict_static_rtes = {
1358 "r0": {
1359 "static_routes": [
1360 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1361 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1362 ]
1363 }
1364 }
1365 result = create_static_routes(tgen, input_dict_static_rtes)
1366 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1367
1368 step("Repeat steps 1 to 10 of summarisation in non Back bone area.")
1369 reset_config_on_routers(tgen)
1370
1371 step("Change the area id on the interface on R0")
1372 input_dict = {
1373 "r0": {
1374 "links": {
1375 "r1": {
1376 "interface": topo["routers"]["r0"]["links"]["r1"]["interface"],
1377 "ospf6": {"area": "0.0.0.0"},
1378 "delete": True,
1379 }
1380 }
1381 }
1382 }
1383
1384 result = create_interfaces_cfg(tgen, input_dict)
1385 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1386
1387 input_dict = {
1388 "r0": {
1389 "links": {
1390 "r1": {
1391 "interface": topo["routers"]["r0"]["links"]["r1"]["interface"],
1392 "ospf6": {"area": "0.0.0.1"},
1393 }
1394 }
1395 }
1396 }
1397
1398 result = create_interfaces_cfg(tgen, input_dict)
1399 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1400
1401 step("Change the area id on the interface ")
1402 input_dict = {
1403 "r1": {
1404 "links": {
1405 "r0": {
1406 "interface": topo["routers"]["r1"]["links"]["r0"]["interface"],
1407 "ospf6": {"area": "0.0.0.0"},
1408 "delete": True,
1409 }
1410 }
1411 }
1412 }
1413
1414 result = create_interfaces_cfg(tgen, input_dict)
1415 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1416
1417 input_dict = {
1418 "r1": {
1419 "links": {
1420 "r0": {
1421 "interface": topo["routers"]["r1"]["links"]["r0"]["interface"],
1422 "ospf6": {"area": "0.0.0.1"},
1423 }
1424 }
1425 }
1426 }
1427
1428 result = create_interfaces_cfg(tgen, input_dict)
1429 assert result is True, "Testcase {} :Failed \n Error: {}".format(tc_name, result)
1430
1431 ospf_covergence = verify_ospf6_neighbor(tgen, topo)
1432 assert ospf_covergence is True, "Testcase {} :Failed \n Error: {}".format(
1433 tc_name, ospf_covergence
1434 )
1435
1436 step(
1437 "Configure 5 static routes from the same network on R0"
1438 "5 static routes from different networks and redistribute in R0"
1439 )
1440 input_dict_static_rtes = {
1441 "r0": {
1442 "static_routes": [
1443 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1444 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1445 ]
1446 }
1447 }
1448 result = create_static_routes(tgen, input_dict_static_rtes)
1449 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1450
1451 dut = "r0"
1452 red_static(dut)
1453
1454 step("Verify that routes are learnt on R1.")
1455 dut = "r1"
1456
1457 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1458 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1459 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1460 assert (
1461 result is True
1462 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1463
1464 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
1465 ospf_summ_r1 = {
1466 "r0": {
1467 "ospf6": {
1468 "summary-address": [
1469 {
1470 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1471 "mask": "32",
1472 "tag": "1234",
1473 }
1474 ]
1475 }
1476 }
1477 }
1478 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1479 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1480
1481 step(
1482 "Verify that external routes are summarised to configured summary"
1483 " address on R0 and only one route is sent to R1 with configured tag."
1484 )
1485 input_dict_summary = {
1486 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "1234"}]}
1487 }
1488 dut = "r1"
1489
1490 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1491 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1492
1493 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1494 assert (
1495 result is True
1496 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1497
1498 step("Verify that show ip ospf summary should show the summaries with tag.")
1499 input_dict = {
1500 SUMMARY["ipv6"][0]: {
1501 "summaryAddress": SUMMARY["ipv6"][0],
1502 "metricType": "E2",
1503 "Metric": 20,
1504 "Tag": 1234,
1505 "externalRouteCount": 5,
1506 }
1507 }
1508 dut = "r0"
1509 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1510 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1511
1512 step("Delete the configured summary")
1513 ospf_summ_r1 = {
1514 "r0": {
1515 "ospf6": {
1516 "summary-address": [
1517 {
1518 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1519 "mask": "32",
1520 "delete": True,
1521 }
1522 ]
1523 }
1524 }
1525 }
1526 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1527 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1528
1529 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1530 dut = "r1"
1531 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
1532 assert (
1533 result is not True
1534 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1535 tc_name, result
1536 )
1537
1538 result = verify_rib(
1539 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1540 )
1541 assert (
1542 result is not True
1543 ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name)
1544
1545 step("show ip ospf summary should not have any summary address.")
1546 input_dict = {
1547 SUMMARY["ipv6"][0]: {
1548 "summaryAddress": SUMMARY["ipv6"][0],
1549 "metricType": "E2",
1550 "Metric": 20,
1551 "Tag": 1234,
1552 "externalRouteCount": 5,
1553 }
1554 }
1555 dut = "r0"
1556 result = verify_ospf_summary(
1557 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1558 )
1559 assert (
1560 result is not True
1561 ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name)
1562
1563 step("Configure Min tag value")
1564 ospf_summ_r1 = {
1565 "r0": {
1566 "ospf6": {
1567 "summary-address": [
1568 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32", "tag": 1}
1569 ]
1570 }
1571 }
1572 }
1573 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1574 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1575 input_dict_summary = {
1576 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "1"}]}
1577 }
1578 dut = "r1"
1579
1580 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1581 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1582
1583 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1584 assert (
1585 result is True
1586 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1587
1588 step("Verify that show ip ospf summary should show the summaries with tag.")
1589 input_dict = {
1590 SUMMARY["ipv6"][0]: {
1591 "summaryAddress": SUMMARY["ipv6"][0],
1592 "metricType": "E2",
1593 "Metric": 20,
1594 "Tag": 1,
1595 "externalRouteCount": 5,
1596 }
1597 }
1598 dut = "r0"
1599 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1600 assert (
1601 result is True
1602 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
1603
1604 step("Configure Max Tag Value")
1605 ospf_summ_r1 = {
1606 "r0": {
1607 "ospf6": {
1608 "summary-address": [
1609 {
1610 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1611 "mask": "32",
1612 "tag": 4294967295,
1613 }
1614 ]
1615 }
1616 }
1617 }
1618 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1619 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1620
1621 input_dict_summary = {
1622 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "4294967295"}]}
1623 }
1624 dut = "r1"
1625
1626 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
1627 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1628
1629 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
1630 assert (
1631 result is True
1632 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1633
1634 step(
1635 "Verify that boundary values tags are used for summary route"
1636 " using show ip ospf route command."
1637 )
1638 input_dict = {
1639 SUMMARY["ipv6"][0]: {
1640 "summaryAddress": SUMMARY["ipv6"][0],
1641 "metricType": "E2",
1642 "Metric": 20,
1643 "Tag": 4294967295,
1644 "externalRouteCount": 5,
1645 }
1646 }
1647 dut = "r0"
1648 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1649 assert (
1650 result is True
1651 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
1652
1653 step("configure new static route with different tag.")
1654 input_dict_static_rtes_11 = {
1655 "r0": {
1656 "static_routes": [
1657 {"network": NETWORK_11["ipv6"], "next_hop": "blackhole", "tag": "88888"}
1658 ]
1659 }
1660 }
1661 result = create_static_routes(tgen, input_dict_static_rtes_11)
1662 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1663
1664 step("New tag has not been used by summary address.")
1665
1666 input_dict_summary = {
1667 "r0": {"static_routes": [{"network": SUMMARY["ipv6"][0], "tag": "88888"}]}
1668 }
1669 dut = "r1"
1670
1671 result = verify_ospf6_rib(
1672 tgen, dut, input_dict_summary, tag="88888", expected=False
1673 )
1674 assert (
1675 result is not True
1676 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1677 tc_name, result
1678 )
1679
1680 result = verify_rib(
1681 tgen,
1682 "ipv6",
1683 dut,
1684 input_dict_summary,
1685 protocol=protocol,
1686 tag="88888",
1687 expected=False,
1688 )
1689 assert (
1690 result is not True
1691 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
1692
1693 step(
1694 "Verify that boundary values tags are used for summary route"
1695 " using show ip ospf route command."
1696 )
1697 input_dict = {
1698 SUMMARY["ipv6"][0]: {
1699 "summaryAddress": SUMMARY["ipv6"][0],
1700 "metricType": "E2",
1701 "Metric": 20,
1702 "Tag": 88888,
1703 "externalRouteCount": 5,
1704 }
1705 }
1706 dut = "r0"
1707 result = verify_ospf_summary(
1708 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1709 )
1710 assert (
1711 result is not True
1712 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
1713
1714 step("Delete the configured summary address")
1715 ospf_summ_r1 = {
1716 "r0": {
1717 "ospf6": {
1718 "summary-address": [
1719 {
1720 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1721 "mask": "32",
1722 "tag": 4294967295,
1723 "delete": True,
1724 }
1725 ]
1726 }
1727 }
1728 }
1729 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1730 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1731
1732 step(
1733 "Verify that 6 routes are advertised to neighbour with 5 routes"
1734 " without any tag, 1 route with tag."
1735 )
1736
1737 dut = "r1"
1738 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1739 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1740 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1741 assert (
1742 result is True
1743 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1744
1745 step("Verify that summary address is flushed from neighbor.")
1746
1747 dut = "r1"
1748 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
1749 assert (
1750 result is not True
1751 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1752 tc_name, result
1753 )
1754
1755 result = verify_rib(
1756 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1757 )
1758 assert (
1759 result is not True
1760 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
1761
1762 step("Configure summary first & then configure matching static route.")
1763
1764 input_dict_static_rtes = {
1765 "r0": {
1766 "static_routes": [
1767 {"network": NETWORK["ipv6"], "next_hop": "blackhole", "delete": True},
1768 {"network": NETWORK2["ipv6"], "next_hop": "blackhole", "delete": True},
1769 ]
1770 }
1771 }
1772 result = create_static_routes(tgen, input_dict_static_rtes)
1773 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1774
1775 ospf_summ_r1 = {
1776 "r0": {
1777 "ospf6": {
1778 "summary-address": [
1779 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
1780 ]
1781 }
1782 }
1783 }
1784 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1785 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1786
1787 input_dict_static_rtes = {
1788 "r0": {
1789 "static_routes": [
1790 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1791 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1792 ]
1793 }
1794 }
1795 result = create_static_routes(tgen, input_dict_static_rtes)
1796 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1797
1798 write_test_footer(tc_name)
1799
1800
1801 def test_ospfv3_type5_summary_tc46_p0(request):
1802 """OSPF summarisation with advertise and no advertise option"""
1803 tc_name = request.node.name
1804 write_test_header(tc_name)
1805 tgen = get_topogen()
1806
1807 # Don't run this test if we have any failure.
1808 if tgen.routers_have_failure():
1809 pytest.skip(tgen.errors)
1810
1811 global topo
1812 step("Bring up the base config as per the topology")
1813 step("Configure OSPF on all the routers of the topology.")
1814 reset_config_on_routers(tgen)
1815
1816 protocol = "ospf"
1817
1818 step(
1819 "Configure 5 static routes from the same network on R0"
1820 "5 static routes from different networks and redistribute in R0"
1821 )
1822 input_dict_static_rtes = {
1823 "r0": {
1824 "static_routes": [
1825 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
1826 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
1827 ]
1828 }
1829 }
1830 result = create_static_routes(tgen, input_dict_static_rtes)
1831 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1832
1833 dut = "r0"
1834 red_static(dut)
1835
1836 step("Verify that routes are learnt on R1.")
1837 dut = "r1"
1838
1839 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
1840 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1841 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
1842 assert (
1843 result is True
1844 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
1845
1846 step(
1847 "Configure External Route summary in R0 to summarise 5"
1848 " routes to one route with no advertise option."
1849 )
1850 ospf_summ_r1 = {
1851 "r0": {
1852 "ospf6": {
1853 "summary-address": [
1854 {
1855 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1856 "mask": "32",
1857 "advertise": False,
1858 }
1859 ]
1860 }
1861 }
1862 }
1863 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1864 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1865
1866 step(
1867 "Verify that external routes are summarised to configured summary"
1868 " address on R0 and summary route is not advertised to neighbor as"
1869 " no advertise is configured.."
1870 )
1871
1872 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
1873 dut = "r1"
1874
1875 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
1876 assert (
1877 result is not True
1878 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1879 tc_name, result
1880 )
1881
1882 result = verify_rib(
1883 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1884 )
1885 assert (
1886 result is not True
1887 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
1888
1889 step("Verify that show ip ospf summary should show the configured summaries.")
1890 input_dict = {
1891 SUMMARY["ipv6"][0]: {
1892 "summaryAddress": SUMMARY["ipv6"][0],
1893 "externalRouteCount": 5,
1894 }
1895 }
1896 dut = "r0"
1897 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
1898 assert (
1899 result is True
1900 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
1901
1902 step("Delete the configured summary")
1903 ospf_summ_r1 = {
1904 "r0": {
1905 "ospf6": {
1906 "summary-address": [
1907 {
1908 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1909 "mask": "32",
1910 "delete": True,
1911 }
1912 ]
1913 }
1914 }
1915 }
1916 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1917 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1918
1919 step("Summary has 5 sec delay timer, sleep 5 secs...")
1920 sleep(5)
1921
1922 step("Verify that summary lsa is withdrawn from R1 and deleted from R0.")
1923 dut = "r1"
1924 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
1925 assert (
1926 result is not True
1927 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1928 tc_name, result
1929 )
1930
1931 result = verify_rib(
1932 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1933 )
1934 assert (
1935 result is not True
1936 ), "Testcase {} : Failed Error: Summary Route still present in RIB".format(tc_name)
1937
1938 step("show ip ospf summary should not have any summary address.")
1939 input_dict = {
1940 SUMMARY["ipv6"][0]: {
1941 "summaryAddress": SUMMARY["ipv6"][0],
1942 "metricType": "E2",
1943 "Metric": 20,
1944 "Tag": 1234,
1945 "externalRouteCount": 5,
1946 }
1947 }
1948 dut = "r0"
1949 result = verify_ospf_summary(
1950 tgen, topo, dut, input_dict, ospf="ospf6", expected=False
1951 )
1952 assert (
1953 result is not True
1954 ), "Testcase {} : Failed Error: Summary still present in DB".format(tc_name)
1955
1956 step("Reconfigure summary with no advertise.")
1957 ospf_summ_r1 = {
1958 "r0": {
1959 "ospf6": {
1960 "summary-address": [
1961 {
1962 "prefix": SUMMARY["ipv6"][0].split("/")[0],
1963 "mask": "32",
1964 "advertise": False,
1965 }
1966 ]
1967 }
1968 }
1969 }
1970 result = create_router_ospf(tgen, topo, ospf_summ_r1)
1971 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
1972
1973 step(
1974 "Verify that external routes are summarised to configured summary"
1975 " address on R0 and summary route is not advertised to neighbor as"
1976 " no advertise is configured.."
1977 )
1978
1979 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
1980 dut = "r1"
1981
1982 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
1983 assert (
1984 result is not True
1985 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
1986 tc_name, result
1987 )
1988
1989 result = verify_rib(
1990 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
1991 )
1992 assert (
1993 result is not True
1994 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
1995
1996 step("Verify that show ip ospf summary should show the configured summaries.")
1997 input_dict = {
1998 SUMMARY["ipv6"][0]: {
1999 "summaryAddress": SUMMARY["ipv6"][0],
2000 "externalRouteCount": 5,
2001 }
2002 }
2003 dut = "r0"
2004 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2005 assert (
2006 result is True
2007 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
2008
2009 step(
2010 "Change summary address from no advertise to advertise "
2011 "(summary-address 10.0.0.0 255.255.0.0)"
2012 )
2013
2014 ospf_summ_r1 = {
2015 "r0": {
2016 "ospf6": {
2017 "summary-address": [
2018 {
2019 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2020 "mask": "32",
2021 "advertise": False,
2022 }
2023 ]
2024 }
2025 }
2026 }
2027 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2028 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2029
2030 ospf_summ_r1 = {
2031 "r0": {
2032 "ospf6": {
2033 "summary-address": [
2034 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
2035 ]
2036 }
2037 }
2038 }
2039 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2040 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2041
2042 step(
2043 "Verify that external routes are summarised to configured summary "
2044 "address on R0 after 5 secs of delay timer expiry and only one "
2045 "route is sent to R1."
2046 )
2047 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2048 dut = "r1"
2049
2050 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2051 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2052
2053 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2054 assert (
2055 result is True
2056 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
2057
2058 step("Verify that show ip ospf summary should show the summaries.")
2059 input_dict = {
2060 SUMMARY["ipv6"][0]: {
2061 "summaryAddress": SUMMARY["ipv6"][0],
2062 "metricType": "E2",
2063 "Metric": 20,
2064 "Tag": 0,
2065 "externalRouteCount": 5,
2066 }
2067 }
2068 dut = "r0"
2069 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2070 assert (
2071 result is True
2072 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
2073
2074 step("Verify that originally advertised routes are withdraw from there peer.")
2075 output = tgen.gears["r0"].vtysh_cmd(
2076 "show ipv6 ospf6 database as-external json", isjson=True
2077 )
2078
2079 output = tgen.gears["r1"].vtysh_cmd(
2080 "show ipv6 ospf6 database as-external json", isjson=True
2081 )
2082
2083 input_dict = {
2084 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
2085 }
2086 dut = "r1"
2087 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
2088 assert (
2089 result is not True
2090 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2091 tc_name, result
2092 )
2093
2094 result = verify_rib(
2095 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
2096 )
2097 assert (
2098 result is not True
2099 ), "Testcase {} : Failed Error: Routes is present in RIB".format(tc_name)
2100
2101 write_test_footer(tc_name)
2102
2103
2104 def test_ospfv3_type5_summary_tc48_p0(request):
2105 """OSPF summarisation with route map modification of metric type."""
2106 tc_name = request.node.name
2107 write_test_header(tc_name)
2108 tgen = get_topogen()
2109
2110 # Don't run this test if we have any failure.
2111 if tgen.routers_have_failure():
2112 pytest.skip(tgen.errors)
2113
2114 global topo
2115 step("Bring up the base config as per the topology")
2116 reset_config_on_routers(tgen)
2117
2118 protocol = "ospf"
2119
2120 step(
2121 "Configure 5 static routes from the same network on R0"
2122 "5 static routes from different networks and redistribute in R0"
2123 )
2124 input_dict_static_rtes = {
2125 "r0": {
2126 "static_routes": [
2127 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
2128 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
2129 ]
2130 }
2131 }
2132 result = create_static_routes(tgen, input_dict_static_rtes)
2133 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2134
2135 dut = "r0"
2136 red_static(dut)
2137
2138 step("Verify that routes are learnt on R1.")
2139 dut = "r1"
2140
2141 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
2142 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2143 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
2144 assert (
2145 result is True
2146 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
2147
2148 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
2149
2150 ospf_summ_r1 = {
2151 "r0": {
2152 "ospf6": {
2153 "summary-address": [
2154 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
2155 ]
2156 }
2157 }
2158 }
2159 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2160 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2161
2162 step(
2163 "Verify that external routes are summarised to configured summary "
2164 "address on R0 after 5 secs of delay timer expiry and only one "
2165 "route is sent to R1."
2166 )
2167 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2168 dut = "r1"
2169
2170 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2171 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2172
2173 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2174 assert (
2175 result is True
2176 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
2177
2178 step("Verify that show ip ospf summary should show the summaries.")
2179 input_dict = {
2180 SUMMARY["ipv6"][0]: {
2181 "summaryAddress": SUMMARY["ipv6"][0],
2182 "metricType": "E2",
2183 "Metric": 20,
2184 "Tag": 0,
2185 "externalRouteCount": 5,
2186 }
2187 }
2188 dut = "r0"
2189 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2190 assert (
2191 result is True
2192 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
2193
2194 step("Verify that originally advertised routes are withdraw from there peer.")
2195 input_dict = {
2196 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
2197 }
2198 dut = "r1"
2199 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
2200 assert (
2201 result is not True
2202 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2203 tc_name, result
2204 )
2205
2206 result = verify_rib(
2207 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
2208 )
2209 assert (
2210 result is not True
2211 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
2212
2213 step(
2214 "Configure route map and & rule to permit configured summary address,"
2215 " redistribute static & connected routes with the route map."
2216 )
2217 step("Configure prefixlist to permit the static routes, add to route map.")
2218 # Create ip prefix list
2219 pfx_list = {
2220 "r0": {
2221 "prefix_lists": {
2222 "ipv6": {
2223 "pf_list_1_ipv6": [
2224 {"seqid": 10, "network": "any", "action": "permit"}
2225 ]
2226 }
2227 }
2228 }
2229 }
2230 result = create_prefix_lists(tgen, pfx_list)
2231 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2232
2233 routemaps = {
2234 "r0": {
2235 "route_maps": {
2236 "rmap_ipv6": [
2237 {
2238 "action": "permit",
2239 "seq_id": "1",
2240 "match": {"ipv6": {"prefix_lists": "pf_list_1_ipv6"}},
2241 }
2242 ]
2243 }
2244 }
2245 }
2246 result = create_route_maps(tgen, routemaps)
2247 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2248
2249 ospf_red_r1 = {
2250 "r0": {
2251 "ospf6": {
2252 "redistribute": [{"redist_type": "static", "route_map": "rmap_ipv6"}]
2253 }
2254 }
2255 }
2256 result = create_router_ospf(tgen, topo, ospf_red_r1)
2257 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2258
2259 step(
2260 "Verify that external routes are summarised to configured"
2261 "summary address on R0 and only one route is sent to R1. Verify that "
2262 "show ip ospf summary should show the configure summaries."
2263 )
2264
2265 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2266 dut = "r1"
2267
2268 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2269 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2270
2271 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2272 assert (
2273 result is True
2274 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
2275
2276 input_dict = {
2277 SUMMARY["ipv6"][0]: {
2278 "summaryAddress": SUMMARY["ipv6"][0],
2279 "metricType": "E2",
2280 "Metric": 20,
2281 "Tag": 0,
2282 "externalRouteCount": 5,
2283 }
2284 }
2285 dut = "r0"
2286 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2287 assert (
2288 result is True
2289 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
2290
2291 step("Configure metric type as 1 in route map.")
2292
2293 routemaps = {
2294 "r0": {
2295 "route_maps": {
2296 "rmap_ipv6": [
2297 {
2298 "seq_id": "1",
2299 "action": "permit",
2300 "set": {"metric-type": "type-1"},
2301 }
2302 ]
2303 }
2304 }
2305 }
2306 result = create_route_maps(tgen, routemaps)
2307 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2308
2309 step(
2310 "Verify that external routes(static / connected) are summarised"
2311 " to configured summary address with metric type 2."
2312 )
2313 input_dict = {
2314 SUMMARY["ipv6"][0]: {
2315 "summaryAddress": SUMMARY["ipv6"][0],
2316 "metricType": "E2",
2317 "Metric": 20,
2318 "Tag": 0,
2319 "externalRouteCount": 5,
2320 }
2321 }
2322 dut = "r0"
2323 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2324 assert (
2325 result is True
2326 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
2327
2328 step("Un configure metric type from route map.")
2329
2330 routemaps = {
2331 "r0": {
2332 "route_maps": {
2333 "rmap_ipv6": [
2334 {
2335 "action": "permit",
2336 "seq_id": "1",
2337 "set": {"metric-type": "type-1", "delete": True},
2338 }
2339 ]
2340 }
2341 }
2342 }
2343 result = create_route_maps(tgen, routemaps)
2344 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2345
2346 step(
2347 "Verify that external routes(static / connected) are summarised"
2348 " to configured summary address with metric type 2."
2349 )
2350 input_dict = {
2351 SUMMARY["ipv6"][0]: {
2352 "summaryAddress": SUMMARY["ipv6"][0],
2353 "metricType": "E2",
2354 "Metric": 20,
2355 "Tag": 0,
2356 "externalRouteCount": 5,
2357 }
2358 }
2359 dut = "r0"
2360 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2361 assert (
2362 result is True
2363 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
2364
2365 step("Change rule from permit to deny in prefix list.")
2366 pfx_list = {
2367 "r0": {
2368 "prefix_lists": {
2369 "ipv6": {
2370 "pf_list_1_ipv6": [
2371 {"seqid": 10, "network": "any", "action": "deny"}
2372 ]
2373 }
2374 }
2375 }
2376 }
2377 result = create_prefix_lists(tgen, pfx_list)
2378 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2379
2380 step(
2381 "Verify that previously originated summary lsa "
2382 "is withdrawn from the neighbor."
2383 )
2384 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2385 dut = "r1"
2386
2387 step("summary route has delay of 5 secs, wait for 5 secs")
2388
2389 sleep(5)
2390
2391 result = verify_ospf6_rib(tgen, dut, input_dict_summary, expected=False)
2392 assert (
2393 result is not True
2394 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2395 tc_name, result
2396 )
2397
2398 result = verify_rib(
2399 tgen, "ipv6", dut, input_dict_summary, protocol=protocol, expected=False
2400 )
2401 assert (
2402 result is not True
2403 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
2404
2405 write_test_footer(tc_name)
2406
2407
2408 def test_ospfv3_type5_summary_tc51_p2(request):
2409 """OSPF CLI Show.
2410
2411 verify ospf ASBR summary config and show commands behaviours.
2412 """
2413 tc_name = request.node.name
2414 write_test_header(tc_name)
2415 tgen = get_topogen()
2416
2417 # Don't run this test if we have any failure.
2418 if tgen.routers_have_failure():
2419 pytest.skip(tgen.errors)
2420
2421 global topo
2422 step("Bring up the base config as per the topology")
2423 reset_config_on_routers(tgen)
2424
2425 step("Configure all the supported OSPF ASBR summary commands on DUT.")
2426 ospf_summ_r1 = {
2427 "r0": {
2428 "ospf6": {
2429 "summary-address": [
2430 {
2431 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2432 "mask": "32",
2433 "tag": 4294967295,
2434 },
2435 {
2436 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2437 "mask": "16",
2438 "advertise": True,
2439 },
2440 {
2441 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2442 "mask": "24",
2443 "advertise": False,
2444 },
2445 {
2446 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2447 "mask": "24",
2448 "advertise": False,
2449 },
2450 ]
2451 }
2452 }
2453 }
2454 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2455 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2456
2457 step("Configure and re configure all the commands 10 times in a loop.")
2458
2459 for itrate in range(0, 10):
2460 ospf_summ_r1 = {
2461 "r0": {
2462 "ospf6": {
2463 "summary-address": [
2464 {
2465 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2466 "mask": "8",
2467 "tag": 4294967295,
2468 },
2469 {
2470 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2471 "mask": "16",
2472 "advertise": True,
2473 },
2474 {
2475 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2476 "mask": "24",
2477 "advertise": False,
2478 },
2479 {
2480 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2481 "mask": "24",
2482 "advertise": False,
2483 },
2484 ]
2485 }
2486 }
2487 }
2488 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2489 assert result is True, "Testcase {} : Failed \n Error: {}".format(
2490 tc_name, result
2491 )
2492
2493 ospf_summ_r1 = {
2494 "r0": {
2495 "ospf6": {
2496 "summary-address": [
2497 {
2498 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2499 "mask": "8",
2500 "tag": 4294967295,
2501 "delete": True,
2502 },
2503 {
2504 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2505 "mask": "16",
2506 "advertise": True,
2507 "delete": True,
2508 },
2509 {
2510 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2511 "mask": "24",
2512 "advertise": False,
2513 "delete": True,
2514 },
2515 {
2516 "prefix": SUMMARY["ipv6"][0].split("/")[0],
2517 "mask": "24",
2518 "advertise": False,
2519 "delete": True,
2520 },
2521 ]
2522 }
2523 }
2524 }
2525 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2526 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2527
2528 step("Verify the show commands")
2529
2530 input_dict = {
2531 SUMMARY["ipv6"][3]: {
2532 "summaryAddress": SUMMARY["ipv6"][3],
2533 "metricType": "E2",
2534 "Metric": 20,
2535 "Tag": 0,
2536 "externalRouteCount": 0,
2537 }
2538 }
2539 dut = "r0"
2540 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2541 assert (
2542 result is True
2543 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
2544
2545 write_test_footer(tc_name)
2546
2547
2548 def test_ospfv3_type5_summary_tc49_p2(request):
2549 """OSPF summarisation Chaos."""
2550 tc_name = request.node.name
2551 write_test_header(tc_name)
2552 tgen = get_topogen()
2553
2554 # Don't run this test if we have any failure.
2555 if tgen.routers_have_failure():
2556 pytest.skip(tgen.errors)
2557
2558 global topo
2559 step("Bring up the base config as per the topology")
2560 reset_config_on_routers(tgen)
2561
2562 protocol = "ospf"
2563
2564 step(
2565 "Configure 5 static routes from the same network on R0"
2566 "5 static routes from different networks and redistribute in R0"
2567 )
2568 input_dict_static_rtes = {
2569 "r0": {
2570 "static_routes": [
2571 {"network": NETWORK["ipv6"], "next_hop": "blackhole"},
2572 {"network": NETWORK2["ipv6"], "next_hop": "blackhole"},
2573 ]
2574 }
2575 }
2576 result = create_static_routes(tgen, input_dict_static_rtes)
2577 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2578
2579 dut = "r0"
2580 red_static(dut)
2581
2582 step("Verify that routes are learnt on R1.")
2583 dut = "r1"
2584
2585 result = verify_ospf6_rib(tgen, dut, input_dict_static_rtes)
2586 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2587 result = verify_rib(tgen, "ipv6", dut, input_dict_static_rtes, protocol=protocol)
2588 assert (
2589 result is True
2590 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
2591
2592 step("Configure External Route summary in R0 to summarise 5 routes to one route.")
2593
2594 ospf_summ_r1 = {
2595 "r0": {
2596 "ospf6": {
2597 "summary-address": [
2598 {"prefix": SUMMARY["ipv6"][0].split("/")[0], "mask": "32"}
2599 ]
2600 }
2601 }
2602 }
2603 result = create_router_ospf(tgen, topo, ospf_summ_r1)
2604 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2605
2606 step(
2607 "Verify that external routes are summarised to configured summary "
2608 "address on R0 after 5 secs of delay timer expiry and only one "
2609 "route is sent to R1."
2610 )
2611 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2612 dut = "r1"
2613
2614 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2615 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2616
2617 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2618 assert (
2619 result is True
2620 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
2621
2622 step("Verify that show ip ospf summary should show the summaries.")
2623 input_dict = {
2624 SUMMARY["ipv6"][0]: {
2625 "summaryAddress": SUMMARY["ipv6"][0],
2626 "metricType": "E2",
2627 "Metric": 20,
2628 "Tag": 0,
2629 "externalRouteCount": 5,
2630 }
2631 }
2632 dut = "r0"
2633 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2634 assert (
2635 result is True
2636 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
2637
2638 step("Verify that originally advertised routes are withdraw from there peer.")
2639 input_dict = {
2640 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
2641 }
2642 dut = "r1"
2643 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
2644 assert (
2645 result is not True
2646 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2647 tc_name, result
2648 )
2649
2650 result = verify_rib(
2651 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
2652 )
2653 assert (
2654 result is not True
2655 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
2656
2657 step("Reload the FRR router")
2658 # stop/start -> restart FRR router and verify
2659 stop_router(tgen, "r0")
2660 start_router(tgen, "r0")
2661
2662 step(
2663 "Verify that external routes are summarised to configured summary "
2664 "address on R0 after 5 secs of delay timer expiry and only one "
2665 "route is sent to R1."
2666 )
2667 input_dict_summary = {"r0": {"static_routes": [{"network": SUMMARY["ipv6"][0]}]}}
2668 dut = "r1"
2669
2670 result = verify_ospf6_rib(tgen, dut, input_dict_summary)
2671 assert result is True, "Testcase {} : Failed \n Error: {}".format(tc_name, result)
2672
2673 result = verify_rib(tgen, "ipv6", dut, input_dict_summary, protocol=protocol)
2674 assert (
2675 result is True
2676 ), "Testcase {} : Failed Error: Routes is missing in RIB".format(tc_name)
2677
2678 step("Verify that show ip ospf summary should show the summaries.")
2679 input_dict = {
2680 SUMMARY["ipv6"][0]: {
2681 "summaryAddress": SUMMARY["ipv6"][0],
2682 "metricType": "E2",
2683 "Metric": 20,
2684 "Tag": 0,
2685 "externalRouteCount": 5,
2686 }
2687 }
2688 dut = "r0"
2689 result = verify_ospf_summary(tgen, topo, dut, input_dict, ospf="ospf6")
2690 assert (
2691 result is True
2692 ), "Testcase {} : Failed Error: Summary missing in OSPF DB".format(tc_name)
2693
2694 step("Verify that originally advertised routes are withdraw from there peer.")
2695 input_dict = {
2696 "r0": {"static_routes": [{"network": NETWORK["ipv6"], "next_hop": "blackhole"}]}
2697 }
2698 dut = "r1"
2699 result = verify_ospf6_rib(tgen, dut, input_dict, expected=False)
2700 assert (
2701 result is not True
2702 ), "Testcase {} : Failed \n Error: Routes still present in OSPF RIB {}".format(
2703 tc_name, result
2704 )
2705
2706 result = verify_rib(
2707 tgen, "ipv6", dut, input_dict, protocol=protocol, expected=False
2708 )
2709 assert (
2710 result is not True
2711 ), "Testcase {} : Failed Error: Routes still present in RIB".format(tc_name)
2712
2713 write_test_footer(tc_name)
2714
2715
2716 if __name__ == "__main__":
2717 args = ["-s"] + sys.argv[1:]
2718 sys.exit(pytest.main(args))