4 # Copyright (c) 2020 by VMware, Inc. ("VMware")
5 # Used Copyright (c) 2018 by Network Device Education Foundation,
6 # Inc. ("NetDEF") in this file.
8 # Permission to use, copy, modify, and/or distribute this software
9 # for any purpose with or without fee is hereby granted, provided
10 # that the above copyright notice and this permission notice appear
13 # THE SOFTWARE IS PROVIDED "AS IS" AND VMWARE DISCLAIMS ALL WARRANTIES
14 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL VMWARE BE LIABLE FOR
16 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
17 # DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18 # WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
19 # ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
24 Following tests are covered to test BGP Multi-VRF:
27 Within each VRF, each address must be unambiguous on DUT.
29 Different VRFs can have ambiguous/overlapping
32 Create static routes(IPv4+IPv6) associated to specific VRFs
33 and verify on DUT that same prefixes are present in corresponding
36 Each VRF should be mapped with a unique VLAN on DUT
37 for traffic segregation, when using a single physical interface.
39 Advertise same set of prefixes from different VRFs
40 and verify on remote router that these prefixes are not
43 Redistribute Static routes and verify on remote routers
44 that routes are advertised within specific VRF instance, which
45 those static routes belong to.
47 Test end to end traffic isolation based on VRF tables.
49 Use static routes for inter-vrf communication
50 (route-leaking) on DUT.
52 Verify intra-vrf and inter-vrf communication between
55 Verify intra-vrf and inter-vrf communication
58 Configure route-maps within a VRF, to alter BGP attributes.
59 Verify that route-map doesn't affect any other VRF instances'
62 Configure route-maps within a VRF, to alter BGP attributes.
63 Verify that route-map doesn't affect any other VRF instances'
66 Configure route-maps within a VRF, to alter BGP attributes.
67 Verify that route-map doesn't affect any other VRF instances'
70 Configure route-maps within a VRF, to alter BGP attributes.
71 Verify that route-map doesn't affect any other VRF instances'
74 Configure route-maps within a VRF, to alter BGP attributes.
75 Verify that route-map doesn't affect any other VRF instances'
78 Configure route-maps within a VRF, to alter BGP attributes.
79 Verify that route-map doesn't affect any other VRF instances'
82 Configure a route-map on DUT to match traffic based
85 Test VRF-lite with Static+BGP originated routes.
87 Configure prefix-lists on DUT and apply to BGP peers to
90 Configure a route-map on DUT to match traffic based various
93 Configure a route-map on DUT to match traffic based various
96 Configure a route-map on DUT to match traffic based various
105 from copy
import deepcopy
107 # Save the Current Working Directory to find configuration files.
108 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
109 sys
.path
.append(os
.path
.join(CWD
, "../"))
110 sys
.path
.append(os
.path
.join(CWD
, "../lib/"))
112 # Required to instantiate the topology builder class.
114 # pylint: disable=C0413
115 # Import topogen and topotest helpers
116 from lib
.topogen
import Topogen
, get_topogen
117 from mininet
.topo
import Topo
118 from lib
.topotest
import iproute2_is_vrf_capable
119 from lib
.common_config
import (
126 reset_config_on_routers
,
128 create_static_routes
,
130 create_interface_in_kernel
,
131 create_bgp_community_lists
,
134 required_linux_kernel_version
,
137 from lib
.topolog
import logger
138 from lib
.bgp
import (
142 verify_bgp_community
,
143 verify_bgp_convergence
,
144 verify_best_path_as_per_bgp_attribute
,
146 from lib
.topojson
import build_topo_from_json
, build_config_from_json
148 # Reading the data from JSON File for topology creation
149 jsonFile
= "{}/bgp_multi_vrf_topo1.json".format(CWD
)
152 with
open(jsonFile
, "r") as topoJson
:
153 topo
= json
.load(topoJson
)
155 assert False, "Could not read file {}".format(jsonFile
)
158 NETWORK1_1
= {"ipv4": "1.1.1.1/32", "ipv6": "1::1/128"}
159 NETWORK1_2
= {"ipv4": "1.1.1.2/32", "ipv6": "1::2/128"}
160 NETWORK2_1
= {"ipv4": "2.1.1.1/32", "ipv6": "2::1/128"}
161 NETWORK2_2
= {"ipv4": "2.1.1.2/32", "ipv6": "2::2/128"}
162 NETWORK3_1
= {"ipv4": "3.1.1.1/32", "ipv6": "3::1/128"}
163 NETWORK3_2
= {"ipv4": "3.1.1.2/32", "ipv6": "3::2/128"}
164 NETWORK4_1
= {"ipv4": "4.1.1.1/32", "ipv6": "4::1/128"}
165 NETWORK4_2
= {"ipv4": "4.1.1.2/32", "ipv6": "4::2/128"}
166 NETWORK5_1
= {"ipv4": "5.1.1.1/32", "ipv6": "5::1/128"}
167 NETWORK5_2
= {"ipv4": "5.1.1.2/32", "ipv6": "5::2/128"}
168 NETWORK6_1
= {"ipv4": "6.1.1.1/32", "ipv6": "6::1/128"}
169 NETWORK6_2
= {"ipv4": "6.1.1.2/32", "ipv6": "6::2/128"}
170 NETWORK7_1
= {"ipv4": "7.1.1.1/32", "ipv6": "7::1/128"}
171 NETWORK7_2
= {"ipv4": "7.1.1.2/32", "ipv6": "7::2/128"}
172 NETWORK8_1
= {"ipv4": "8.1.1.1/32", "ipv6": "8::1/128"}
173 NETWORK8_2
= {"ipv4": "8.1.1.2/32", "ipv6": "8::2/128"}
175 NEXT_HOP_IP
= {"ipv4": "Null0", "ipv6": "Null0"}
178 "ipv4": "10.10.10.10/32",
179 "ipv6": "10::10:10/128",
180 "ipv4_mask": "255.255.255.255",
184 "ipv4": "20.20.20.20/32",
185 "ipv6": "20::20:20/128",
186 "ipv4_mask": "255.255.255.255",
191 class CreateTopo(Topo
):
193 Test BasicTopo - topology 1
195 * `Topo`: Topology object
198 def build(self
, *_args
, **_opts
):
200 tgen
= get_topogen(self
)
202 # Building topology from json file
203 build_topo_from_json(tgen
, topo
)
206 def setup_module(mod
):
208 Sets up the pytest environment
212 # Required linux kernel version for this suite to run.
213 result
= required_linux_kernel_version("4.15")
214 if result
is not True:
215 pytest
.skip("Kernel requirements are not met")
217 # iproute2 needs to support VRFs for this suite to run.
218 if not iproute2_is_vrf_capable():
219 pytest
.skip("Installed iproute2 version does not support VRFs")
221 testsuite_run_time
= time
.asctime(time
.localtime(time
.time()))
222 logger
.info("Testsuite start time: {}".format(testsuite_run_time
))
223 logger
.info("=" * 40)
225 logger
.info("Running setup_module to create topology")
227 # This function initiates the topology build with Topogen...
228 tgen
= Topogen(CreateTopo
, mod
.__name
__)
229 # ... and here it calls Mininet initialization functions.
231 # Starting topology, create tmp files which are loaded to routers
232 # to start deamons and then start routers
235 # Creating configuration from JSON
236 build_config_from_json(tgen
, topo
)
238 global BGP_CONVERGENCE
240 ADDR_TYPES
= check_address_types()
242 BGP_CONVERGENCE
= verify_bgp_convergence(tgen
, topo
)
243 assert BGP_CONVERGENCE
is True, "setup_module : Failed \n Error: {}".format(
247 logger
.info("Running setup_module() done")
250 def teardown_module():
251 """Teardown the pytest environment"""
253 logger
.info("Running teardown_module to delete topology")
257 # Stop toplogy and Remove tmp files
261 "Testsuite end time: {}".format(time
.asctime(time
.localtime(time
.time())))
263 logger
.info("=" * 40)
266 #####################################################
270 #####################################################
273 def test_address_unambiguous_within_each_vrf_p0(request
):
276 Within each VRF, each address must be unambiguous on DUT.
280 tc_name
= request
.node
.name
281 write_test_header(tc_name
)
283 if tgen
.routers_have_failure():
284 check_router_status(tgen
)
286 step("Configure a set of static routes(IPv4+IPv6) in " "RED_A on router RED-1")
288 for addr_type
in ADDR_TYPES
:
293 "network": NETWORK1_1
[addr_type
],
294 "next_hop": NEXT_HOP_IP
[addr_type
],
300 result
= create_static_routes(tgen
, input_dict_1
)
301 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
306 "Configure the same static routes(IPv4+IPv6) with a TAG value"
307 "of 500 in RED_A on router RED-1"
310 for addr_type
in ADDR_TYPES
:
315 "network": NETWORK1_1
[addr_type
],
316 "next_hop": NEXT_HOP_IP
[addr_type
],
323 result
= create_static_routes(tgen
, input_dict_2
)
324 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
328 step("Redistribute static..")
336 "ipv4": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
337 "ipv6": {"unicast": {"redistribute": [{"redist_type": "static"}]}},
343 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
344 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
347 "Verify that static routes(IPv4+IPv6) is overridden and doesn't"
348 " have duplicate entries within VRF RED_A on router RED-1"
351 for addr_type
in ADDR_TYPES
:
357 "network": NETWORK1_1
[addr_type
],
358 "next_hop": NEXT_HOP_IP
[addr_type
],
366 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, tag
=500)
367 assert result
is True, "Testcase {} : Failed \n Error {}".format(
371 step("Make sure routes are not present in global routing table")
373 for addr_type
in ADDR_TYPES
:
379 "network": NETWORK1_1
[addr_type
],
380 "next_hop": NEXT_HOP_IP
[addr_type
],
386 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
387 assert result
is not True, (
388 "Testcase {} : Failed \n Expected Behaviour: Routes are not "
389 "present on Global Routing table \n Error {}".format(tc_name
, result
)
392 write_test_footer(tc_name
)
395 def test_ambiguous_overlapping_addresses_in_different_vrfs_p0(request
):
398 Different VRFs can have ambiguous/overlapping
403 tc_name
= request
.node
.name
404 write_test_header(tc_name
)
405 reset_config_on_routers(tgen
)
407 if tgen
.routers_have_failure():
408 check_router_status(tgen
)
410 step("Configure a set of static routes(IPv4+IPv6) in vrf RED_A" "on router RED-1")
412 for addr_type
in ADDR_TYPES
:
417 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
418 "next_hop": NEXT_HOP_IP
[addr_type
],
424 result
= create_static_routes(tgen
, input_dict_1
)
425 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
430 "Configure the same static routes(IPv4+IPv6) with a"
431 " TAG value of 500 in vrf RED_B on router RED-1"
434 for addr_type
in ADDR_TYPES
:
439 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
440 "next_hop": NEXT_HOP_IP
[addr_type
],
447 result
= create_static_routes(tgen
, input_dict_2
)
448 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
452 step("Redistribute static..")
456 temp
= {dut
: {"bgp": []}}
457 input_dict_3
.update(temp
)
460 VRFS
= ["RED_A", "RED_B"]
463 VRFS
= ["BLUE_A", "BLUE_B"]
466 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
467 temp
[dut
]["bgp"].append(
473 "unicast": {"redistribute": [{"redist_type": "static"}]}
476 "unicast": {"redistribute": [{"redist_type": "static"}]}
482 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
483 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
485 step("Verify that RED_A has the static routes without any" " TAG value")
487 for addr_type
in ADDR_TYPES
:
493 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
494 "next_hop": NEXT_HOP_IP
[addr_type
],
501 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
502 assert result
is True, "Testcase {} : Failed \n Error {}".format(
506 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, tag
=500, expected
=False)
507 assert result
is not True, (
508 "Testcase {} : Failed \n "
509 "Routes are present with tag value 500 \n Error: {}".format(tc_name
, result
)
511 logger
.info("Expected Behavior: {}".format(result
))
514 "Verify that RED_B has the same routes with TAG value "
515 "500 on same device RED-1"
518 for addr_type
in ADDR_TYPES
:
524 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
525 "next_hop": NEXT_HOP_IP
[addr_type
],
533 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, tag
=500)
534 assert result
is True, "Testcase {} : Failed \n Error {}".format(
538 step("Make sure routes are not present in global routing table")
540 for addr_type
in ADDR_TYPES
:
546 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
547 "next_hop": NEXT_HOP_IP
[addr_type
],
553 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
554 assert result
is not True, (
555 "Testcase {} : Failed \n Expected Behaviour: Routes are not "
556 "present on Global Routing table \n Error {}".format(tc_name
, result
)
559 write_test_footer(tc_name
)
562 def test_static_routes_associated_to_specific_vrfs_p0(request
):
565 Create static routes(IPv4+IPv6) associated to specific VRFs
566 and verify on DUT that same prefixes are present in corresponding
571 tc_name
= request
.node
.name
572 write_test_header(tc_name
)
573 reset_config_on_routers(tgen
)
575 if tgen
.routers_have_failure():
576 check_router_status(tgen
)
579 "Configure a set of unique static(IPv4+IPv6) routes in vrf"
580 " RED_A on router RED-1"
583 for addr_type
in ADDR_TYPES
:
588 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
589 "next_hop": NEXT_HOP_IP
[addr_type
],
593 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
594 "next_hop": NEXT_HOP_IP
[addr_type
],
600 result
= create_static_routes(tgen
, input_dict_1
)
601 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
606 "Configure set of unique static routes(IPv4+IPv6) in vrf "
607 "RED_B on router RED-1"
610 for addr_type
in ADDR_TYPES
:
615 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
616 "next_hop": NEXT_HOP_IP
[addr_type
],
620 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
621 "next_hop": NEXT_HOP_IP
[addr_type
],
627 result
= create_static_routes(tgen
, input_dict_2
)
628 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
632 step("Redistribute static..")
635 for dut
in ["red1", "blue1"]:
636 temp
= {dut
: {"bgp": []}}
637 input_dict_3
.update(temp
)
640 VRFS
= ["RED_A", "RED_B"]
643 VRFS
= ["BLUE_A", "BLUE_B"]
646 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
647 temp
[dut
]["bgp"].append(
653 "unicast": {"redistribute": [{"redist_type": "static"}]}
656 "unicast": {"redistribute": [{"redist_type": "static"}]}
662 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
663 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
666 "Verify that static routes 1.x.x.x/32 and 1::x/128 appear " "in VRF RED_A table"
669 "Verify that static routes 2.x.x.x/32 and 2::x/128 appear " "in VRF RED_B table"
672 for addr_type
in ADDR_TYPES
:
678 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
679 "next_hop": NEXT_HOP_IP
[addr_type
],
683 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
684 "next_hop": NEXT_HOP_IP
[addr_type
],
691 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
692 assert result
is True, "Testcase {} : Failed \n Error {}".format(
697 "Verify that static routes 1.x.x.x/32 and 1::x/128 appear "
698 "in VRF BLUE_A table"
701 "Verify that static routes 2.x.x.x/32 and 2::x/128 appear "
702 "in VRF BLUE_B table"
705 for addr_type
in ADDR_TYPES
:
711 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
712 "next_hop": NEXT_HOP_IP
[addr_type
],
716 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
717 "next_hop": NEXT_HOP_IP
[addr_type
],
724 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
725 assert result
is True, "Testcase {} : Failed \n Error {}".format(
729 step("Make sure routes are not present in global routing table")
731 for addr_type
in ADDR_TYPES
:
737 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
738 "next_hop": NEXT_HOP_IP
[addr_type
],
741 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
742 "next_hop": NEXT_HOP_IP
[addr_type
],
748 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
749 assert result
is not True, (
750 "Testcase {} : Failed \n Expected Behaviour: Routes are not "
751 "present on Global Routing table \n Error {}".format(tc_name
, result
)
754 write_test_footer(tc_name
)
757 def test_vrf_with_unique_physical_interface_p0(request
):
760 Each VRF should be mapped with a unique VLAN on DUT
761 for traffic segregation, when using a single physical interface.
763 Each VRF should be mapped to a unique physical
764 interface(without VLAN tagging) on DUT for traffic segregation.
768 tc_name
= request
.node
.name
769 write_test_header(tc_name
)
770 reset_config_on_routers(tgen
)
772 if tgen
.routers_have_failure():
773 check_router_status(tgen
)
776 "R1 is receiving routes in 4 VRFs instances "
777 "(RED_A, RED_B, BLUE_A, BLUE_B) from RED_1 and BLUE_1."
780 for addr_type
in ADDR_TYPES
:
785 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
786 "next_hop": NEXT_HOP_IP
[addr_type
],
790 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
791 "next_hop": NEXT_HOP_IP
[addr_type
],
797 result
= create_static_routes(tgen
, input_dict_1
)
798 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
803 "Advertise a set of unique BGP prefixes(IPv4+IPv6) from "
804 "routers RED_1 & BLUE_1 in each VRF using static redistribution"
807 for addr_type
in ADDR_TYPES
:
812 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
813 "next_hop": NEXT_HOP_IP
[addr_type
],
817 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
818 "next_hop": NEXT_HOP_IP
[addr_type
],
824 result
= create_static_routes(tgen
, input_dict_2
)
825 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
829 step("Redistribute static..")
832 for dut
in ["red1", "blue1"]:
833 temp
= {dut
: {"bgp": []}}
834 input_dict_3
.update(temp
)
837 VRFS
= ["RED_A", "RED_B"]
840 VRFS
= ["BLUE_A", "BLUE_B"]
843 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
844 temp
[dut
]["bgp"].append(
850 "unicast": {"redistribute": [{"redist_type": "static"}]}
853 "unicast": {"redistribute": [{"redist_type": "static"}]}
859 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
860 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
863 "Each VRF table on R2 should maintain it's associated "
864 "routes and and accordingly install in zebra"
867 for addr_type
in ADDR_TYPES
:
873 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
874 "next_hop": NEXT_HOP_IP
[addr_type
],
878 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
879 "next_hop": NEXT_HOP_IP
[addr_type
],
890 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
891 "next_hop": NEXT_HOP_IP
[addr_type
],
895 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
896 "next_hop": NEXT_HOP_IP
[addr_type
],
903 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
904 assert result
is True, "Testcase {} : Failed \n Error {}".format(
908 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
909 assert result
is True, "Testcase {} : Failed \n Error {}".format(
913 write_test_footer(tc_name
)
916 def test_prefixes_leaking_p0(request
):
919 Advertise same set of prefixes from different VRFs
920 and verify on remote router that these prefixes are not
921 leaking to each other
925 tc_name
= request
.node
.name
926 write_test_header(tc_name
)
927 reset_config_on_routers(tgen
)
929 if tgen
.routers_have_failure():
930 check_router_status(tgen
)
932 step("Configure a set of static routes(IPv4+IPv6) in vrf " "RED_A on router RED-1")
934 for addr_type
in ADDR_TYPES
:
939 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
940 "next_hop": NEXT_HOP_IP
[addr_type
],
948 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
949 "next_hop": NEXT_HOP_IP
[addr_type
],
955 result
= create_static_routes(tgen
, input_dict_1
)
956 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
961 "Configure a set of static routes(IPv4+IPv6) in vrf " "BLUE_A on router BLUE-1"
964 for addr_type
in ADDR_TYPES
:
969 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
970 "next_hop": NEXT_HOP_IP
[addr_type
],
978 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
979 "next_hop": NEXT_HOP_IP
[addr_type
],
985 result
= create_static_routes(tgen
, input_dict_2
)
986 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
991 "Configure the same set of static routes with a "
992 "metric value of 123 in vrf RED_B on router RED-1"
995 "Configure the same set of static routes with a "
996 "metric value of 123 in vrf BLUE_B on router BLUE-1"
1007 "unicast": {"redistribute": [{"redist_type": "static"}]}
1010 "unicast": {"redistribute": [{"redist_type": "static"}]}
1022 "redist_type": "static",
1023 "attribute": {"metric": 123},
1032 "redist_type": "static",
1033 "attribute": {"metric": 123},
1049 "unicast": {"redistribute": [{"redist_type": "static"}]}
1052 "unicast": {"redistribute": [{"redist_type": "static"}]}
1064 "redist_type": "static",
1065 "attribute": {"metric": 123},
1074 "redist_type": "static",
1075 "attribute": {"metric": 123},
1086 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1087 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1090 "Verify on R1 that RED_A doesn't receive any static "
1091 "route with metric value 123"
1094 for addr_type
in ADDR_TYPES
:
1100 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1101 "next_hop": NEXT_HOP_IP
[addr_type
],
1109 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1110 "next_hop": NEXT_HOP_IP
[addr_type
],
1121 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1122 "next_hop": NEXT_HOP_IP
[addr_type
],
1130 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1131 "next_hop": NEXT_HOP_IP
[addr_type
],
1138 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
1139 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1143 result
= verify_rib(
1144 tgen
, addr_type
, dut
, input_dict_1
, metric
=123, expected
=False
1146 assert result
is not True, (
1147 "Testcase {} : Failed \n "
1148 "Routes are present with metric value 123 \n Error: {}".format(
1152 logger
.info("Expected Behavior: {}".format(result
))
1154 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, metric
=123)
1155 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1159 result
= verify_rib(
1160 tgen
, addr_type
, dut
, input_dict_2
, metric
=0, expected
=False
1162 assert result
is not True, (
1163 "Testcase {} : Failed \n "
1164 "Routes are present with metric value 0 \n Error: {}".format(
1168 logger
.info("Expected Behavior: {}".format(result
))
1170 write_test_footer(tc_name
)
1173 def test_static_routes_advertised_within_specific_vrf_p0(request
):
1176 Redistribute Static routes and verify on remote routers
1177 that routes are advertised within specific VRF instance, which
1178 those static routes belong to.
1181 tgen
= get_topogen()
1182 tc_name
= request
.node
.name
1183 write_test_header(tc_name
)
1184 reset_config_on_routers(tgen
)
1186 if tgen
.routers_have_failure():
1187 check_router_status(tgen
)
1190 "Advertise a set of unique BGP prefixes(IPv4+IPv6) "
1191 "through static redistribution into VRF RED_A and RED_B"
1192 " from router RED-1."
1195 for addr_type
in ADDR_TYPES
:
1200 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1201 "next_hop": NEXT_HOP_IP
[addr_type
],
1205 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1206 "next_hop": NEXT_HOP_IP
[addr_type
],
1212 result
= create_static_routes(tgen
, input_dict_1
)
1213 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1218 "Advertise same as above set of BGP prefixes(IPv4+IPv6) "
1219 "through static redistribution into VRF BLUE_A and BLUE_B"
1220 " from router BLUE-1."
1223 for addr_type
in ADDR_TYPES
:
1228 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1229 "next_hop": NEXT_HOP_IP
[addr_type
],
1233 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1234 "next_hop": NEXT_HOP_IP
[addr_type
],
1240 result
= create_static_routes(tgen
, input_dict_2
)
1241 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1245 step("Redistribute static..")
1248 for dut
in ["red1", "blue1"]:
1249 temp
= {dut
: {"bgp": []}}
1250 input_dict_3
.update(temp
)
1253 VRFS
= ["RED_A", "RED_B"]
1256 VRFS
= ["BLUE_A", "BLUE_B"]
1259 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
1260 temp
[dut
]["bgp"].append(
1266 "unicast": {"redistribute": [{"redist_type": "static"}]}
1269 "unicast": {"redistribute": [{"redist_type": "static"}]}
1275 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1276 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1279 "Verify that static routes are installed into vrfs RED_A"
1280 "and RED_B tables only, not in global routing table of RED_1"
1283 for addr_type
in ADDR_TYPES
:
1289 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1290 "next_hop": NEXT_HOP_IP
[addr_type
],
1294 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1295 "next_hop": NEXT_HOP_IP
[addr_type
],
1302 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, protocol
="static")
1303 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1308 "Verify that static routes are installed into vrfs BLUE_A and"
1309 "BLUE_B tables only, not in global routing table of BLUE_1."
1312 for addr_type
in ADDR_TYPES
:
1318 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1319 "next_hop": NEXT_HOP_IP
[addr_type
],
1323 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1324 "next_hop": NEXT_HOP_IP
[addr_type
],
1331 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, protocol
="static")
1332 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1337 "Verify on router R1, that each set of prefixes is received"
1338 " into associated vrf tables only."
1341 result
= verify_bgp_convergence(tgen
, topo
)
1342 assert result
is True, "Testcase {} : Failed \n Error {}".format(tc_name
, result
)
1344 for addr_type
in ADDR_TYPES
:
1350 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1351 "next_hop": NEXT_HOP_IP
[addr_type
],
1355 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1356 "next_hop": NEXT_HOP_IP
[addr_type
],
1367 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1368 "next_hop": NEXT_HOP_IP
[addr_type
],
1372 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1373 "next_hop": NEXT_HOP_IP
[addr_type
],
1380 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
1381 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1385 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
1386 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1390 write_test_footer(tc_name
)
1393 def test_end_to_end_traffic_isolation_p0(request
):
1396 Test end to end traffic isolation based on VRF tables.
1399 tgen
= get_topogen()
1400 tc_name
= request
.node
.name
1401 write_test_header(tc_name
)
1402 reset_config_on_routers(tgen
)
1404 if tgen
.routers_have_failure():
1405 check_router_status(tgen
)
1408 "Advertise unique BGP prefixes(IPv4+IPv6) from RED_1 "
1409 "in vrf instances(RED_A and RED_B)."
1412 for addr_type
in ADDR_TYPES
:
1417 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1418 "next_hop": NEXT_HOP_IP
[addr_type
],
1422 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1423 "next_hop": NEXT_HOP_IP
[addr_type
],
1429 result
= create_static_routes(tgen
, input_dict_1
)
1430 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1435 "Advertise unique BGP prefixes(IPv4+IPv6) from from BLUE_1 in"
1436 " vrf instances(BLUE_A and BLUE_B)."
1439 for addr_type
in ADDR_TYPES
:
1444 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
1445 "next_hop": NEXT_HOP_IP
[addr_type
],
1449 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
1450 "next_hop": NEXT_HOP_IP
[addr_type
],
1456 result
= create_static_routes(tgen
, input_dict_2
)
1457 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1461 step("Redistribute static..")
1464 for dut
in ["red1", "blue1"]:
1465 temp
= {dut
: {"bgp": []}}
1466 input_dict_3
.update(temp
)
1469 VRFS
= ["RED_A", "RED_B"]
1472 VRFS
= ["BLUE_A", "BLUE_B"]
1475 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
1476 temp
[dut
]["bgp"].append(
1482 "unicast": {"redistribute": [{"redist_type": "static"}]}
1485 "unicast": {"redistribute": [{"redist_type": "static"}]}
1491 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1492 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1495 "Use below commands to send prefixes with as-path prepend"
1496 "VRF BLUE_A and BLUE_B from router BLUE-1."
1499 for addr_type
in ADDR_TYPES
:
1503 "ASP_{}".format(addr_type
): [
1506 "set": {"path": {"as_num": 123, "as_action": "prepend"}},
1512 result
= create_route_maps(tgen
, input_dict_4
)
1513 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1517 step("Apply route-map to neighbours")
1610 result
= create_router_bgp(tgen
, topo
, input_dict_5
)
1611 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1614 "Verify on R1 that BLUE_A and BLUE_B VRFs are receiving the"
1615 " prefixes with as-path 123 prepended."
1618 for addr_type
in ADDR_TYPES
:
1624 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1625 "next_hop": NEXT_HOP_IP
[addr_type
],
1629 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
1630 "next_hop": NEXT_HOP_IP
[addr_type
],
1637 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_6
)
1638 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1642 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_6
)
1643 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1647 for addr_type
in ADDR_TYPES
:
1653 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1654 "next_hop": NEXT_HOP_IP
[addr_type
],
1658 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
1659 "next_hop": NEXT_HOP_IP
[addr_type
],
1666 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_7
)
1667 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1671 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_7
)
1672 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1677 "Use below commands to send prefixes with as-path prepend VRF"
1678 " BLUE_A and BLUE_B from router BLUE-1."
1694 "allowas-in": {"number_occurences": 2}
1707 "allowas-in": {"number_occurences": 2}
1726 "allowas-in": {"number_occurences": 2}
1739 "allowas-in": {"number_occurences": 2}
1762 "allowas-in": {"number_occurences": 2}
1775 "allowas-in": {"number_occurences": 2}
1794 "allowas-in": {"number_occurences": 2}
1807 "allowas-in": {"number_occurences": 2}
1820 result
= create_router_bgp(tgen
, topo
, input_dict_6
)
1821 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1823 step("Verify that router RED-2 receives the prefixes in respective" " VRF tables.")
1825 for addr_type
in ADDR_TYPES
:
1831 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
1832 "next_hop": NEXT_HOP_IP
[addr_type
],
1836 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
1837 "next_hop": NEXT_HOP_IP
[addr_type
],
1844 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_6
)
1845 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1849 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_6
)
1850 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1854 for addr_type
in ADDR_TYPES
:
1860 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
1861 "next_hop": NEXT_HOP_IP
[addr_type
],
1865 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
1866 "next_hop": NEXT_HOP_IP
[addr_type
],
1873 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_7
)
1874 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1878 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_7
)
1879 assert result
is True, "Testcase {} : Failed \n Error {}".format(
1883 write_test_footer(tc_name
)
1886 def test_static_routes_for_inter_vrf_route_leaking_p0(request
):
1889 Use static routes for inter-vrf communication
1890 (route-leaking) on DUT.
1893 tgen
= get_topogen()
1894 tc_name
= request
.node
.name
1895 write_test_header(tc_name
)
1896 reset_config_on_routers(tgen
)
1898 if tgen
.routers_have_failure():
1899 check_router_status(tgen
)
1902 "Configure unique loopback interfaces in VRFs RED_A "
1903 "and RED_B on router RED_1."
1906 for addr_type
in ADDR_TYPES
:
1907 create_interface_in_kernel(
1911 LOOPBACK_1
[addr_type
],
1913 LOOPBACK_1
["{}_mask".format(addr_type
)],
1915 create_interface_in_kernel(
1919 LOOPBACK_2
[addr_type
],
1921 LOOPBACK_2
["{}_mask".format(addr_type
)],
1925 "Create a static routes in vrf RED_B on router RED_1 pointing"
1926 " next-hop as interface's IP in vrf RED_A"
1929 intf_red1_r11
= topo
["routers"]["red1"]["links"]["r1-link1"]["interface"]
1930 intf_red1_r10
= topo
["routers"]["red1"]["links"]["r1-link2"]["interface"]
1931 for addr_type
in ADDR_TYPES
:
1936 "network": LOOPBACK_1
[addr_type
],
1937 "interface": intf_red1_r10
,
1938 "nexthop_vrf": "RED_B",
1942 "network": LOOPBACK_2
[addr_type
],
1943 "interface": intf_red1_r11
,
1944 "nexthop_vrf": "RED_A",
1950 result
= create_static_routes(tgen
, input_dict_1
)
1951 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
1955 step("Redistribute static..")
1958 for dut
in ["red1"]:
1959 temp
= {dut
: {"bgp": []}}
1960 input_dict_3
.update(temp
)
1963 VRFS
= ["RED_A", "RED_B"]
1966 VRFS
= ["BLUE_A", "BLUE_B"]
1969 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
1970 temp
[dut
]["bgp"].append(
1976 "unicast": {"redistribute": [{"redist_type": "static"}]}
1979 "unicast": {"redistribute": [{"redist_type": "static"}]}
1985 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
1986 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
1989 "Verify that static routes are installed into vrfs RED_A"
1990 "and RED_B tables only, not in global routing table of RED_1"
1992 for addr_type
in ADDR_TYPES
:
1998 "network": LOOPBACK_1
[addr_type
],
1999 "interface": intf_red1_r10
,
2000 "nexthop_vrf": "RED_B",
2004 "network": LOOPBACK_2
[addr_type
],
2005 "interface": intf_red1_r11
,
2006 "nexthop_vrf": "RED_A",
2013 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, protocol
="static")
2014 assert result
is True, "Testcase {} : Failed \n Error {}".format(
2018 write_test_footer(tc_name
)
2021 def test_inter_vrf_and_intra_vrf_communication_iBGP_p0(request
):
2024 Verify intra-vrf and inter-vrf communication between
2028 tgen
= get_topogen()
2029 tc_name
= request
.node
.name
2030 write_test_header(tc_name
)
2031 reset_config_on_routers(tgen
)
2033 if tgen
.routers_have_failure():
2034 check_router_status(tgen
)
2037 "Configure unique loopback IP(IPv4+IPv6) in vrf RED_A on router"
2038 " R1 and advertise it in BGP process using redistribute "
2039 "connected command."
2042 for addr_type
in ADDR_TYPES
:
2043 create_interface_in_kernel(
2047 LOOPBACK_1
[addr_type
],
2049 LOOPBACK_1
["{}_mask".format(addr_type
)],
2052 create_interface_in_kernel(
2056 LOOPBACK_2
[addr_type
],
2058 LOOPBACK_2
["{}_mask".format(addr_type
)],
2062 "Create a static routes in vrf RED_B on router RED_1 pointing"
2063 " next-hop as interface's IP in vrf RED_A"
2066 intf_r2_r12
= topo
["routers"]["r2"]["links"]["r1-link1"]["interface"]
2067 intf_r2_r10
= topo
["routers"]["r2"]["links"]["r1-link3"]["interface"]
2068 for addr_type
in ADDR_TYPES
:
2073 "network": LOOPBACK_2
[addr_type
],
2074 "interface": intf_r2_r10
,
2075 "nexthop_vrf": "BLUE_A",
2079 "network": LOOPBACK_1
[addr_type
],
2080 "interface": intf_r2_r12
,
2081 "nexthop_vrf": "RED_A",
2087 result
= create_static_routes(tgen
, input_dict_1
)
2088 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2092 step("Redistribute connected..")
2096 temp
= {dut
: {"bgp": []}}
2097 input_dict_3
.update(temp
)
2099 VRFS
= ["RED_A", "BLUE_A"]
2102 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2103 temp
[dut
]["bgp"].append(
2109 "unicast": {"redistribute": [{"redist_type": "connected"}]}
2112 "unicast": {"redistribute": [{"redist_type": "connected"}]}
2118 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2119 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2121 step("Redistribute static..")
2125 temp
= {dut
: {"bgp": []}}
2126 input_dict_3
.update(temp
)
2128 VRFS
= ["RED_A", "BLUE_A"]
2131 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2132 temp
[dut
]["bgp"].append(
2138 "unicast": {"redistribute": [{"redist_type": "static"}]}
2141 "unicast": {"redistribute": [{"redist_type": "static"}]}
2147 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2148 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2151 "Verify that static routes are installed into vrfs RED_A"
2152 "and RED_B tables only, not in global routing table of RED_1"
2155 for addr_type
in ADDR_TYPES
:
2161 "network": LOOPBACK_2
[addr_type
],
2162 "interface": intf_r2_r10
,
2163 "nexthop_vrf": "BLUE_A",
2167 "network": LOOPBACK_1
[addr_type
],
2168 "interface": intf_r2_r12
,
2169 "nexthop_vrf": "RED_A",
2176 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
)
2177 assert result
is True, "Testcase {} : Failed \n Error {}".format(
2181 write_test_footer(tc_name
)
2184 def test_inter_vrf_and_intra_vrf_communication_eBGP_p0(request
):
2187 Verify intra-vrf and inter-vrf communication
2191 tgen
= get_topogen()
2192 tc_name
= request
.node
.name
2193 write_test_header(tc_name
)
2194 reset_config_on_routers(tgen
)
2196 if tgen
.routers_have_failure():
2197 check_router_status(tgen
)
2200 "Configure unique loopback IP(IPv4+IPv6) in vrf RED_A on router"
2201 " R2 and advertise it in BGP process using redistribute "
2202 "connected command."
2206 "Configure unique loopback IP(IPv4+IPv6) in vrf BLUE_A on router"
2207 " R2 and advertise it in BGP process using redistribute "
2208 "connected command."
2211 for addr_type
in ADDR_TYPES
:
2212 create_interface_in_kernel(
2216 LOOPBACK_1
[addr_type
],
2218 LOOPBACK_1
["{}_mask".format(addr_type
)],
2220 create_interface_in_kernel(
2224 LOOPBACK_2
[addr_type
],
2226 LOOPBACK_2
["{}_mask".format(addr_type
)],
2230 "Create a static routes in vrf RED_B on router RED_1 pointing"
2231 " next-hop as interface's IP in vrf RED_A"
2234 intf_r3_r21
= topo
["routers"]["r3"]["links"]["r2-link1"]["interface"]
2235 intf_r3_r23
= topo
["routers"]["r3"]["links"]["r2-link3"]["interface"]
2236 for addr_type
in ADDR_TYPES
:
2241 "network": LOOPBACK_2
[addr_type
],
2242 "interface": intf_r3_r23
,
2243 "nexthop_vrf": "BLUE_A",
2247 "network": LOOPBACK_1
[addr_type
],
2248 "interface": intf_r3_r21
,
2249 "nexthop_vrf": "RED_A",
2255 result
= create_static_routes(tgen
, input_dict_1
)
2256 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2260 step("Redistribute static..")
2264 temp
= {dut
: {"bgp": []}}
2265 input_dict_3
.update(temp
)
2267 VRFS
= ["RED_A", "BLUE_A"]
2270 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2271 temp
[dut
]["bgp"].append(
2277 "unicast": {"redistribute": [{"redist_type": "static"}]}
2280 "unicast": {"redistribute": [{"redist_type": "static"}]}
2286 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2287 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2289 step("Redistribute connected..")
2293 temp
= {dut
: {"bgp": []}}
2294 input_dict_3
.update(temp
)
2296 VRFS
= ["RED_A", "BLUE_A"]
2299 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2300 temp
[dut
]["bgp"].append(
2306 "unicast": {"redistribute": [{"redist_type": "connected"}]}
2309 "unicast": {"redistribute": [{"redist_type": "connected"}]}
2315 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2316 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2319 "Verify that static routes are installed into vrfs RED_A"
2320 "and RED_B tables only, not in global routing table of RED_1"
2323 for addr_type
in ADDR_TYPES
:
2329 "network": LOOPBACK_2
[addr_type
],
2330 "interface": intf_r3_r23
,
2331 "nexthop_vrf": "BLUE_A",
2335 "network": LOOPBACK_1
[addr_type
],
2336 "interface": intf_r3_r21
,
2337 "nexthop_vrf": "RED_A",
2344 result
= verify_rib(tgen
, addr_type
, dut
, input_dict
)
2345 assert result
is True, "Testcase {} : Failed \n Error {}".format(
2349 write_test_footer(tc_name
)
2352 def test_route_map_within_vrf_to_alter_bgp_attribute_nexthop_p0(request
):
2355 Configure route-maps within a VRF, to alter BGP attributes.
2356 Verify that route-map doesn't affect any other VRF instances'
2360 tgen
= get_topogen()
2361 tc_name
= request
.node
.name
2362 write_test_header(tc_name
)
2363 reset_config_on_routers(tgen
)
2365 if tgen
.routers_have_failure():
2366 check_router_status(tgen
)
2369 "Advertise a set of BGP prefixes(IPv4+IPv6) from RED_1 and"
2370 " RED_2 in vrf instances(RED_A and RED_B)."
2373 for addr_type
in ADDR_TYPES
:
2378 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2379 "next_hop": NEXT_HOP_IP
[addr_type
],
2383 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2384 "next_hop": NEXT_HOP_IP
[addr_type
],
2390 result
= create_static_routes(tgen
, input_dict_1
)
2391 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2396 "Advertise same set of BGP prefixes(IPv4+IPv6) from BLUE_1 and"
2397 "BLUE_2 in vrf instances(BLUE_A and BLUE_B)"
2400 for addr_type
in ADDR_TYPES
:
2405 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2406 "next_hop": NEXT_HOP_IP
[addr_type
],
2410 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2411 "next_hop": NEXT_HOP_IP
[addr_type
],
2417 result
= create_static_routes(tgen
, input_dict_2
)
2418 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2422 step("Redistribute static..")
2425 for dut
in ["red1", "blue1"]:
2426 temp
= {dut
: {"bgp": []}}
2427 input_dict_3
.update(temp
)
2430 VRFS
= ["RED_A", "RED_B"]
2433 VRFS
= ["BLUE_A", "BLUE_B"]
2436 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2437 temp
[dut
]["bgp"].append(
2443 "unicast": {"redistribute": [{"redist_type": "static"}]}
2446 "unicast": {"redistribute": [{"redist_type": "static"}]}
2452 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2453 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2456 "Verify that within vrf instances, BGP best path selection"
2457 " algorithm remains intact and doesn't affect any other VRFs"
2458 " routing decision."
2461 for addr_type
in ADDR_TYPES
:
2467 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2468 "next_hop": NEXT_HOP_IP
[addr_type
],
2472 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2473 "next_hop": NEXT_HOP_IP
[addr_type
],
2484 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2485 "next_hop": NEXT_HOP_IP
[addr_type
],
2489 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2490 "next_hop": NEXT_HOP_IP
[addr_type
],
2497 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
2498 assert result
is True, "Testcase {} : Failed \n Error {}".format(
2502 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
2503 assert result
is True, "Testcase {} : Failed \n Error {}".format(
2507 step("Delete nexthop-self configure from r1")
2521 "r1-link1": {"next_hop_self": False}
2532 "r1-link1": {"next_hop_self": False}
2549 "r1-link2": {"next_hop_self": False}
2560 "r1-link2": {"next_hop_self": False}
2577 "r1-link3": {"next_hop_self": False}
2588 "r1-link3": {"next_hop_self": False}
2605 "r1-link4": {"next_hop_self": False}
2616 "r1-link4": {"next_hop_self": False}
2628 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
2629 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2632 "Verify that within vrf instances, BGP best path selection"
2633 " algorithm remains intact and doesn't affect any other VRFs"
2634 " routing decision."
2637 for addr_type
in ADDR_TYPES
:
2643 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2644 "next_hop": NEXT_HOP_IP
[addr_type
],
2648 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2649 "next_hop": NEXT_HOP_IP
[addr_type
],
2660 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2661 "next_hop": NEXT_HOP_IP
[addr_type
],
2665 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2666 "next_hop": NEXT_HOP_IP
[addr_type
],
2673 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
, expected
=False)
2676 ), "Testcase {} : Failed \n Expected Behaviour: Routes are rejected because nexthop-self config is deleted \n Error {}".format(tc_name
, result
)
2678 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
2681 ), "Testcase {} : Failed \n Expected Behaviour: Routes are rejected because nexthop-self config is deleted \n Error {}".format(tc_name
, result
)
2683 write_test_footer(tc_name
)
2686 @pytest.mark
.parametrize("attribute", ["locPrf", "weight", "metric"])
2687 def test_route_map_within_vrf_to_alter_bgp_attribute_p0(request
, attribute
):
2690 Configure route-maps within a VRF, to alter BGP attributes.
2691 Verify that route-map doesn't affect any other VRF instances'
2695 tgen
= get_topogen()
2696 tc_name
= request
.node
.name
2697 write_test_header(tc_name
)
2698 reset_config_on_routers(tgen
)
2700 if tgen
.routers_have_failure():
2701 check_router_status(tgen
)
2704 "Advertise a set of BGP prefixes(IPv4+IPv6) from RED_1 and"
2705 " RED_2 in vrf instances(RED_A and RED_B)."
2708 for addr_type
in ADDR_TYPES
:
2713 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2714 "next_hop": NEXT_HOP_IP
[addr_type
],
2718 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2719 "next_hop": NEXT_HOP_IP
[addr_type
],
2727 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2728 "next_hop": NEXT_HOP_IP
[addr_type
],
2732 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2733 "next_hop": NEXT_HOP_IP
[addr_type
],
2739 result
= create_static_routes(tgen
, input_dict_1
)
2740 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2745 "Advertise same set of BGP prefixes(IPv4+IPv6) from BLUE_1 and"
2746 "BLUE_2 in vrf instances(BLUE_A and BLUE_B)"
2749 for addr_type
in ADDR_TYPES
:
2754 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2755 "next_hop": NEXT_HOP_IP
[addr_type
],
2759 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2760 "next_hop": NEXT_HOP_IP
[addr_type
],
2768 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
2769 "next_hop": NEXT_HOP_IP
[addr_type
],
2773 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
2774 "next_hop": NEXT_HOP_IP
[addr_type
],
2780 result
= create_static_routes(tgen
, input_dict_2
)
2781 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2785 step("Redistribute static..")
2788 for dut
in ["red1", "red2", "blue1", "blue2"]:
2789 temp
= {dut
: {"bgp": []}}
2790 input_dict_3
.update(temp
)
2793 VRFS
= ["RED_A", "RED_B"]
2796 VRFS
= ["BLUE_A", "BLUE_B"]
2799 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
2800 temp
[dut
]["bgp"].append(
2806 "unicast": {"redistribute": [{"redist_type": "static"}]}
2809 "unicast": {"redistribute": [{"redist_type": "static"}]}
2815 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
2816 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
2818 step("Configure a route-maps to influence BGP parameters - " " Local Preference")
2820 for addr_type
in ADDR_TYPES
:
2824 "rmap_r1_{}".format(addr_type
): [
2825 {"action": "permit", "set": {attribute
: 120}}
2827 "rmap_r3_{}".format(addr_type
): [
2828 {"action": "permit", "set": {attribute
: 150}}
2834 result
= create_route_maps(tgen
, input_dict_4
)
2835 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
2839 step("Configure neighbor for route map")
2855 "name": "rmap_r1_ipv4",
2867 "name": "rmap_r3_ipv4",
2885 "name": "rmap_r1_ipv6",
2897 "name": "rmap_r3_ipv6",
2921 "name": "rmap_r1_ipv4",
2933 "name": "rmap_r3_ipv4",
2951 "name": "rmap_r1_ipv6",
2963 "name": "rmap_r3_ipv6",
2987 "name": "rmap_r1_ipv4",
2999 "name": "rmap_r3_ipv4",
3017 "name": "rmap_r1_ipv6",
3029 "name": "rmap_r3_ipv6",
3053 "name": "rmap_r1_ipv4",
3065 "name": "rmap_r3_ipv4",
3083 "name": "rmap_r1_ipv6",
3095 "name": "rmap_r3_ipv6",
3111 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
3112 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3115 "Verify that within vrf instances, BGP best path selection"
3116 " algorithm remains intact and doesn't affect any other VRFs"
3117 " routing decision."
3121 for addr_type
in ADDR_TYPES
:
3126 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3127 "next_hop": NEXT_HOP_IP
[addr_type
],
3131 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3132 "next_hop": NEXT_HOP_IP
[addr_type
],
3143 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3144 "next_hop": NEXT_HOP_IP
[addr_type
],
3148 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3149 "next_hop": NEXT_HOP_IP
[addr_type
],
3156 result
= verify_best_path_as_per_bgp_attribute(
3157 tgen
, addr_type
, dut
, input_dict_1
, attribute
3159 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3163 result
= verify_best_path_as_per_bgp_attribute(
3164 tgen
, addr_type
, dut
, input_dict_2
, attribute
3166 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3170 write_test_footer(tc_name
)
3173 def test_route_map_within_vrf_to_alter_bgp_attribute_aspath_p0(request
):
3176 Configure route-maps within a VRF, to alter BGP attributes.
3177 Verify that route-map doesn't affect any other VRF instances'
3181 tgen
= get_topogen()
3182 tc_name
= request
.node
.name
3183 write_test_header(tc_name
)
3184 reset_config_on_routers(tgen
)
3186 if tgen
.routers_have_failure():
3187 check_router_status(tgen
)
3190 "Advertise a set of BGP prefixes(IPv4+IPv6) from RED_1 and"
3191 " RED_2 in vrf instances(RED_A and RED_B)."
3194 for addr_type
in ADDR_TYPES
:
3199 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3200 "next_hop": NEXT_HOP_IP
[addr_type
],
3204 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3205 "next_hop": NEXT_HOP_IP
[addr_type
],
3213 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3214 "next_hop": NEXT_HOP_IP
[addr_type
],
3218 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3219 "next_hop": NEXT_HOP_IP
[addr_type
],
3225 result
= create_static_routes(tgen
, input_dict_1
)
3226 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3231 "Advertise same set of BGP prefixes(IPv4+IPv6) from BLUE_1 and"
3232 "BLUE_2 in vrf instances(BLUE_A and BLUE_B)"
3235 for addr_type
in ADDR_TYPES
:
3240 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3241 "next_hop": NEXT_HOP_IP
[addr_type
],
3245 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3246 "next_hop": NEXT_HOP_IP
[addr_type
],
3254 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3255 "next_hop": NEXT_HOP_IP
[addr_type
],
3259 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3260 "next_hop": NEXT_HOP_IP
[addr_type
],
3266 result
= create_static_routes(tgen
, input_dict_2
)
3267 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3271 step("Redistribute static..")
3274 for dut
in ["red1", "red2", "blue1", "blue2"]:
3275 temp
= {dut
: {"bgp": []}}
3276 input_dict_3
.update(temp
)
3279 VRFS
= ["RED_A", "RED_B"]
3282 VRFS
= ["BLUE_A", "BLUE_B"]
3285 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
3286 temp
[dut
]["bgp"].append(
3292 "unicast": {"redistribute": [{"redist_type": "static"}]}
3295 "unicast": {"redistribute": [{"redist_type": "static"}]}
3301 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
3302 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3304 step("Configure a route-maps to influence BGP parameters - " " Local Preference")
3306 for addr_type
in ADDR_TYPES
:
3310 "rmap_r1_{}".format(addr_type
): [
3314 "path": {"as_num": "111 222", "as_action": "prepend"}
3321 result
= create_route_maps(tgen
, input_dict_4
)
3322 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3326 step("Configure neighbor for route map")
3342 "name": "rmap_r1_ipv4",
3349 "r3": {"dest_link": {"r2-link1": {}}},
3361 "name": "rmap_r1_ipv6",
3368 "r3": {"dest_link": {"r2-link1": {}}},
3386 "name": "rmap_r1_ipv4",
3393 "r3": {"dest_link": {"r2-link2": {}}},
3405 "name": "rmap_r1_ipv6",
3412 "r3": {"dest_link": {"r2-link2": {}}},
3430 "name": "rmap_r1_ipv4",
3437 "r3": {"dest_link": {"r2-link3": {}}},
3449 "name": "rmap_r1_ipv6",
3456 "r3": {"dest_link": {"r2-link3": {}}},
3474 "name": "rmap_r1_ipv4",
3481 "r3": {"dest_link": {"r2-link4": {}}},
3493 "name": "rmap_r1_ipv6",
3500 "r3": {"dest_link": {"r2-link4": {}}},
3510 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
3511 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3514 "Verify that within vrf instances, BGP best path selection"
3515 " algorithm remains intact and doesn't affect any other VRFs"
3516 " routing decision."
3521 for addr_type
in ADDR_TYPES
:
3526 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3527 "next_hop": NEXT_HOP_IP
[addr_type
],
3531 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3532 "next_hop": NEXT_HOP_IP
[addr_type
],
3543 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3544 "next_hop": NEXT_HOP_IP
[addr_type
],
3548 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3549 "next_hop": NEXT_HOP_IP
[addr_type
],
3556 result
= verify_best_path_as_per_bgp_attribute(
3557 tgen
, addr_type
, dut
, input_dict_1
, attribute
3559 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3563 result
= verify_best_path_as_per_bgp_attribute(
3564 tgen
, addr_type
, dut
, input_dict_2
, attribute
3566 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3570 write_test_footer(tc_name
)
3573 def test_route_map_within_vrf_to_alter_bgp_attribute_lcomm_p0(request
):
3576 Configure route-maps within a VRF, to alter BGP attributes.
3577 Verify that route-map doesn't affect any other VRF instances'
3581 tgen
= get_topogen()
3582 tc_name
= request
.node
.name
3583 write_test_header(tc_name
)
3584 reset_config_on_routers(tgen
)
3586 if tgen
.routers_have_failure():
3587 check_router_status(tgen
)
3590 "Advertise a set of BGP prefixes(IPv4+IPv6) from RED_1 and"
3591 " RED_2 in vrf instances(RED_A and RED_B)."
3594 for addr_type
in ADDR_TYPES
:
3599 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3600 "next_hop": NEXT_HOP_IP
[addr_type
],
3604 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3605 "next_hop": NEXT_HOP_IP
[addr_type
],
3613 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3614 "next_hop": NEXT_HOP_IP
[addr_type
],
3618 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3619 "next_hop": NEXT_HOP_IP
[addr_type
],
3625 result
= create_static_routes(tgen
, input_dict_1
)
3626 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3631 "Advertise same set of BGP prefixes(IPv4+IPv6) from BLUE_1 and"
3632 "BLUE_2 in vrf instances(BLUE_A and BLUE_B)"
3635 for addr_type
in ADDR_TYPES
:
3640 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3641 "next_hop": NEXT_HOP_IP
[addr_type
],
3645 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3646 "next_hop": NEXT_HOP_IP
[addr_type
],
3654 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
3655 "next_hop": NEXT_HOP_IP
[addr_type
],
3659 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
3660 "next_hop": NEXT_HOP_IP
[addr_type
],
3666 result
= create_static_routes(tgen
, input_dict_2
)
3667 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3671 step("Redistribute static..")
3674 for dut
in ["red1", "red2", "blue1", "blue2"]:
3675 temp
= {dut
: {"bgp": []}}
3676 input_dict_3
.update(temp
)
3679 VRFS
= ["RED_A", "RED_B"]
3682 VRFS
= ["BLUE_A", "BLUE_B"]
3685 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
3686 temp
[dut
]["bgp"].append(
3692 "unicast": {"redistribute": [{"redist_type": "static"}]}
3695 "unicast": {"redistribute": [{"redist_type": "static"}]}
3701 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
3702 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3704 step("Configure a route-maps to influence BGP parameters - " " Large-community")
3706 step("Create standard large commumity-list in r2")
3708 for addr_type
in ADDR_TYPES
:
3711 "bgp_community_lists": [
3713 "community_type": "standard",
3715 "name": "rmap_lcomm_{}".format(addr_type
),
3716 "value": "1:1:1 1:2:3 2:1:1 2:2:2",
3722 result
= create_bgp_community_lists(tgen
, input_dict_1
)
3723 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3727 step("Create route-maps in red1 and r1")
3729 for addr_type
in ADDR_TYPES
:
3733 "rmap_red1_{}".format(addr_type
): [
3737 "large_community": {"num": "1:1:1 1:2:3 2:1:1 2:2:2"}
3745 "rmap_r1_{}".format(addr_type
): [
3749 "large_community_list": {
3750 "id": "rmap_lcomm_" + addr_type
3758 result
= create_route_maps(tgen
, input_dict_4
)
3759 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
3763 step("Configure neighbor for route map in red1")
3780 "name": "rmap_red1_ipv4",
3798 "name": "rmap_red1_ipv6",
3822 "name": "rmap_red1_ipv4",
3840 "name": "rmap_red1_ipv6",
3856 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
3857 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
3859 step("Configure neighbor for route map in r2")
3876 "name": "rmap_r1_ipv4",
3894 "name": "rmap_r1_ipv6",
3918 "name": "rmap_r1_ipv4",
3936 "name": "rmap_r1_ipv6",
3960 "name": "rmap_r1_ipv4",
3978 "name": "rmap_r1_ipv6",
4002 "name": "rmap_r1_ipv4",
4020 "name": "rmap_r1_ipv6",
4036 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
4037 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
4040 "All the prefixes advertised from RED_1 and BLUE_1 should carry"
4041 " attributes set by outbound route-maps within specific vrfs. "
4042 "Router R1 should be able to match and permit/deny those "
4043 "prefixes based on received attributes. Please use below "
4044 "commands to verify."
4048 "largeCommunity": "1:1:1 1:2:3 2:1:1 2:2:2",
4051 for addr_type
in ADDR_TYPES
:
4053 routes
= [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]]
4054 result
= verify_bgp_community(tgen
, addr_type
, "r2", routes
, input_dict
, vrf
)
4055 assert result
is True, "Test case {} : Failed \n Error: {}".format(
4059 for addr_type
in ADDR_TYPES
:
4061 routes
= [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]]
4062 result
= verify_bgp_community(tgen
, addr_type
, "r2", routes
, input_dict
, vrf
)
4063 assert result
is True, "Test case {} : Failed \n Error: {}".format(
4067 write_test_footer(tc_name
)
4070 def test_route_map_match_traffic_based_on_vrf_p0(request
):
4073 Configure a route-map on DUT to match traffic based
4074 on a VRF interfaces.
4077 tgen
= get_topogen()
4078 tc_name
= request
.node
.name
4079 write_test_header(tc_name
)
4080 reset_config_on_routers(tgen
)
4082 if tgen
.routers_have_failure():
4083 check_router_status(tgen
)
4086 "Advertise unique BGP prefixes(IPv4+IPv6) from RED_1 "
4087 "in vrf instances(RED_A and RED_B)."
4090 for addr_type
in ADDR_TYPES
:
4095 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4096 "next_hop": NEXT_HOP_IP
[addr_type
],
4100 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
4101 "next_hop": NEXT_HOP_IP
[addr_type
],
4107 result
= create_static_routes(tgen
, input_dict_1
)
4108 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
4113 "Advertise unique BGP prefixes(IPv4+IPv6) from from BLUE_1 in"
4114 " vrf instances(BLUE_A and BLUE_B)."
4117 for addr_type
in ADDR_TYPES
:
4122 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
4123 "next_hop": NEXT_HOP_IP
[addr_type
],
4127 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
4128 "next_hop": NEXT_HOP_IP
[addr_type
],
4134 result
= create_static_routes(tgen
, input_dict_2
)
4135 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
4139 step("Redistribute static..")
4142 for dut
in ["red1", "blue1"]:
4143 temp
= {dut
: {"bgp": []}}
4144 input_dict_3
.update(temp
)
4147 VRFS
= ["RED_A", "RED_B"]
4150 VRFS
= ["BLUE_A", "BLUE_B"]
4153 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
4154 temp
[dut
]["bgp"].append(
4160 "unicast": {"redistribute": [{"redist_type": "static"}]}
4163 "unicast": {"redistribute": [{"redist_type": "static"}]}
4169 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
4170 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
4173 "Configure a route-map on R1 to match the prefixes "
4174 "coming from vrf RED_A and set as-prepend to these routes."
4183 "match": {"source-vrf": "RED_A"},
4184 "set": {"path": {"as_num": 1, "as_action": "prepend"}},
4190 result
= create_route_maps(tgen
, input_dict_4
)
4191 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
4194 "On R1, import the routes form vrf RED_A and RED_B to BLUE_A and"
4195 " apply the route-map under vrf BLUE_A while importing"
4201 "router bgp 100 vrf BLUE_A",
4202 "address-family ipv4 unicast",
4205 "import vrf route-map ABC",
4206 "address-family ipv6 unicast",
4209 "import vrf route-map ABC",
4213 result
= apply_raw_config(tgen
, raw_config
)
4214 assert result
is True, "Testcase {} : Failed Error: {}".format(tc_name
, result
)
4217 "All the prefixes advertised from RED_1 and BLUE_1 in vrfs "
4218 "RED_B and BLUE_B must prepend the AS number in as-path on R2."
4221 for addr_type
in ADDR_TYPES
:
4226 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4227 "next_hop": NEXT_HOP_IP
[addr_type
],
4231 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
4232 "next_hop": NEXT_HOP_IP
[addr_type
],
4239 result
= verify_bgp_rib(tgen
, addr_type
, "r1", input_dict_7
)
4240 assert result
is True, "Testcase {} : Failed \n Error {}".format(
4244 write_test_footer(tc_name
)
4247 def test_vrf_lite_with_static_bgp_originated_routes_p0(request
):
4250 Test VRF-lite with Static+BGP originated routes.
4253 tgen
= get_topogen()
4254 tc_name
= request
.node
.name
4255 write_test_header(tc_name
)
4256 reset_config_on_routers(tgen
)
4258 if tgen
.routers_have_failure():
4259 check_router_status(tgen
)
4262 "Advertise unique BGP prefixes(IPv4+IPv6) from from RED_1"
4263 " in vrf instances(RED_A and RED_B)."
4266 for addr_type
in ADDR_TYPES
:
4271 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4272 "next_hop": NEXT_HOP_IP
[addr_type
],
4276 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
4277 "next_hop": NEXT_HOP_IP
[addr_type
],
4283 result
= create_static_routes(tgen
, input_dict_1
)
4284 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
4289 "Advertise unique BGP prefixes(IPv4+IPv6) from from BLUE_1 in"
4290 " vrf instances(BLUE_A and BLUE_B)."
4293 for addr_type
in ADDR_TYPES
:
4298 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4299 "next_hop": NEXT_HOP_IP
[addr_type
],
4303 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
4304 "next_hop": NEXT_HOP_IP
[addr_type
],
4310 result
= create_static_routes(tgen
, input_dict_2
)
4311 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
4324 "advertise_networks": [
4326 "network": [NETWORK5_1
["ipv4"]]
4327 + [NETWORK5_2
["ipv4"]]
4330 "redistribute": [{"redist_type": "static"}],
4335 "advertise_networks": [
4337 "network": [NETWORK5_1
["ipv6"]]
4338 + [NETWORK5_2
["ipv6"]]
4341 "redistribute": [{"redist_type": "static"}],
4352 "advertise_networks": [
4354 "network": [NETWORK6_1
["ipv4"]]
4355 + [NETWORK6_2
["ipv4"]]
4358 "redistribute": [{"redist_type": "static"}],
4363 "advertise_networks": [
4365 "network": [NETWORK6_1
["ipv6"]]
4366 + [NETWORK6_2
["ipv6"]]
4369 "redistribute": [{"redist_type": "static"}],
4384 "advertise_networks": [
4386 "network": [NETWORK7_1
["ipv4"]]
4387 + [NETWORK7_2
["ipv4"]]
4390 "redistribute": [{"redist_type": "static"}],
4395 "advertise_networks": [
4397 "network": [NETWORK7_1
["ipv6"]]
4398 + [NETWORK7_2
["ipv6"]]
4401 "redistribute": [{"redist_type": "static"}],
4412 "advertise_networks": [
4414 "network": [NETWORK8_1
["ipv4"]]
4415 + [NETWORK8_2
["ipv4"]]
4418 "redistribute": [{"redist_type": "static"}],
4423 "advertise_networks": [
4425 "network": [NETWORK8_1
["ipv6"]]
4426 + [NETWORK8_2
["ipv6"]]
4429 "redistribute": [{"redist_type": "static"}],
4438 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
4439 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
4441 step("Static routes must be installed in associated VRF" " table only.")
4443 for addr_type
in ADDR_TYPES
:
4445 result
= verify_bgp_rib(tgen
, addr_type
, dut
, input_dict_3
)
4446 assert result
is True, "Testcase {} : Failed \n Error {}".format(
4451 "All the routers must receive advertised as well as "
4452 "redistributed(static) prefixes in associated VRF tables."
4455 for addr_type
in ADDR_TYPES
:
4461 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4462 "next_hop": NEXT_HOP_IP
[addr_type
],
4466 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
4467 "next_hop": NEXT_HOP_IP
[addr_type
],
4478 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4479 "next_hop": NEXT_HOP_IP
[addr_type
],
4483 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
4484 "next_hop": NEXT_HOP_IP
[addr_type
],
4491 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
4492 assert result
is True, "Testcase {} : Failed \n Error {}".format(
4496 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
4497 assert result
is True, "Testcase {} : Failed \n Error {}".format(
4501 write_test_footer(tc_name
)
4504 def test_prefix_list_to_permit_deny_prefixes_p0(request
):
4507 Configure prefix-lists on DUT and apply to BGP peers to
4508 permit/deny prefixes.
4511 tgen
= get_topogen()
4512 tc_name
= request
.node
.name
4513 write_test_header(tc_name
)
4514 reset_config_on_routers(tgen
)
4516 if tgen
.routers_have_failure():
4517 check_router_status(tgen
)
4520 "Advertise unique BGP prefixes(IPv4+IPv6) from from RED_1"
4521 " in vrf instances(RED_A and RED_B)."
4524 for addr_type
in ADDR_TYPES
:
4529 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4530 "next_hop": NEXT_HOP_IP
[addr_type
],
4534 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
4535 "next_hop": NEXT_HOP_IP
[addr_type
],
4541 result
= create_static_routes(tgen
, input_dict_1
)
4542 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
4547 "Advertise unique BGP prefixes(IPv4+IPv6) from from BLUE_1 in"
4548 " vrf instances(BLUE_A and BLUE_B)."
4551 for addr_type
in ADDR_TYPES
:
4556 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4557 "next_hop": NEXT_HOP_IP
[addr_type
],
4561 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
4562 "next_hop": NEXT_HOP_IP
[addr_type
],
4568 result
= create_static_routes(tgen
, input_dict_2
)
4569 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
4573 step("Redistribute static..")
4576 for dut
in ["red1", "blue1"]:
4577 temp
= {dut
: {"bgp": []}}
4578 input_dict_3
.update(temp
)
4581 VRFS
= ["RED_A", "RED_B"]
4584 VRFS
= ["BLUE_A", "BLUE_B"]
4587 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
4588 temp
[dut
]["bgp"].append(
4594 "unicast": {"redistribute": [{"redist_type": "static"}]}
4597 "unicast": {"redistribute": [{"redist_type": "static"}]}
4603 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
4604 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
4606 step("Verify routes are present before applying prefix-list")
4607 for addr_type
in ADDR_TYPES
:
4613 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4614 "next_hop": NEXT_HOP_IP
[addr_type
],
4618 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
4619 "next_hop": NEXT_HOP_IP
[addr_type
],
4630 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
4631 "next_hop": NEXT_HOP_IP
[addr_type
],
4635 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
4636 "next_hop": NEXT_HOP_IP
[addr_type
],
4643 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
4644 assert result
is True, "Testcase {} : Failed \n Error {}".format(
4648 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
)
4649 assert result
is True, "Testcase {} : Failed \n Error {}".format(
4654 "On routers RED_1 and BLUE_1, configure prefix-lists to permit"
4655 " 4 prefixes and deny 1 prefix x.x.x.5. Apply these in outbound"
4656 "direction for each neighbour."
4659 for addr_type
in ADDR_TYPES
:
4664 "pflist_red1_{}".format(addr_type
): [
4667 "network": NETWORK1_1
[addr_type
],
4672 "network": NETWORK2_1
[addr_type
],
4677 "network": NETWORK1_2
[addr_type
],
4682 "network": NETWORK2_2
[addr_type
],
4692 "pflist_blue1_{}".format(addr_type
): [
4695 "network": NETWORK1_1
[addr_type
],
4700 "network": NETWORK2_1
[addr_type
],
4705 "network": NETWORK1_2
[addr_type
],
4710 "network": NETWORK2_2
[addr_type
],
4720 "pflist_r1_{}".format(addr_type
): [
4723 "network": NETWORK1_1
[addr_type
],
4728 "network": NETWORK2_1
[addr_type
],
4736 result
= create_prefix_lists(tgen
, input_dict_4
)
4737 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
4756 "name": "pflist_red1_ipv4",
4774 "name": "pflist_red1_ipv6",
4798 "name": "pflist_red1_ipv4",
4816 "name": "pflist_red1_ipv6",
4844 "name": "pflist_blue1_ipv4",
4862 "name": "pflist_blue1_ipv6",
4886 "name": "pflist_blue1_ipv4",
4904 "name": "pflist_blue1_ipv6",
4920 result
= create_router_bgp(tgen
, topo
, input_dict_5
)
4921 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
4924 "Verify that within vrf instances, each BGP neighbor receives 1"
4925 " prefixes in routing table and drops (x.x.x.2)."
4928 for addr_type
in ADDR_TYPES
:
4930 permitted_routes
= {
4933 {"network": [NETWORK1_1
[addr_type
]], "vrf": "RED_A"},
4934 {"network": [NETWORK2_1
[addr_type
]], "vrf": "RED_B"},
4942 {"network": [NETWORK1_2
[addr_type
]], "vrf": "RED_A"},
4943 {"network": [NETWORK2_2
[addr_type
]], "vrf": "RED_B"},
4948 result
= verify_rib(tgen
, addr_type
, dut
, permitted_routes
)
4949 assert result
is True, "Testcase {} : Failed \n Error {}".format(
4953 result
= verify_rib(tgen
, addr_type
, dut
, denied_routes
, expected
=False)
4954 assert result
is not True, "Testcase {} : Failed \n"
4955 "{}:Expected behaviour: Routes are denied by prefix-list \nError {}".format(tc_name
, result
)
4958 "On router R1, configure prefix-lists to permit 2 "
4959 "prefixes(x.x.x.1-2) and deny 2 prefix(x.x.x.3-4). Apply"
4960 " these in inbound direction for each neighbour."
4978 "name": "pflist_r1_ipv4",
4996 "name": "pflist_r1_ipv6",
5020 "name": "pflist_r1_ipv4",
5038 "name": "pflist_r1_ipv6",
5062 "name": "pflist_r1_ipv4",
5080 "name": "pflist_r1_ipv6",
5104 "name": "pflist_r1_ipv4",
5122 "name": "pflist_r1_ipv6",
5138 result
= create_router_bgp(tgen
, topo
, input_dict_6
)
5139 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
5142 "Verify that within vrf instances, each BGP neighbor installs"
5143 " only 1 prefix (x.x.x.1)."
5145 for addr_type
in ADDR_TYPES
:
5147 permitted_routes
= {
5149 "static_routes": [{"network": [NETWORK1_1
[addr_type
]], "vrf": "RED_A"}]
5155 "static_routes": [{"network": [NETWORK2_1
[addr_type
]], "vrf": "RED_A"}]
5159 result
= verify_rib(tgen
, addr_type
, dut
, permitted_routes
)
5160 assert result
is True, "Testcase {} : Failed \n Error {}".format(
5164 result
= verify_rib(tgen
, addr_type
, dut
, denied_routes
, expected
=False)
5165 assert result
is not True, "Testcase {} : Failed \nExpected behaviour: Routes are denied by prefix-list \nError {}".format(tc_name
, result
)
5167 write_test_footer(tc_name
)
5170 def test_route_map_set_and_match_tag_p0(request
):
5173 Configure a route-map on DUT to match traffic based various
5177 tgen
= get_topogen()
5178 tc_name
= request
.node
.name
5179 write_test_header(tc_name
)
5180 reset_config_on_routers(tgen
)
5182 if tgen
.routers_have_failure():
5183 check_router_status(tgen
)
5186 "Advertise unique BGP prefixes(IPv4+IPv6) from RED_1"
5187 " in vrf instances(RED_A and RED_B)."
5190 for addr_type
in ADDR_TYPES
:
5195 "network": [NETWORK1_1
[addr_type
]],
5196 "next_hop": NEXT_HOP_IP
[addr_type
],
5201 "network": [NETWORK1_2
[addr_type
]],
5202 "next_hop": NEXT_HOP_IP
[addr_type
],
5206 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
5207 "next_hop": NEXT_HOP_IP
[addr_type
],
5213 result
= create_static_routes(tgen
, input_dict_1
)
5214 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
5219 "Advertise same set of BGP prefixes(IPv4+IPv6) from BLUE_1 and"
5220 "BLUE_2 in vrf instances(BLUE_A and BLUE_B)"
5223 for addr_type
in ADDR_TYPES
:
5228 "network": [NETWORK3_1
[addr_type
]],
5229 "next_hop": NEXT_HOP_IP
[addr_type
],
5234 "network": [NETWORK3_2
[addr_type
]],
5235 "next_hop": NEXT_HOP_IP
[addr_type
],
5239 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
5240 "next_hop": NEXT_HOP_IP
[addr_type
],
5246 result
= create_static_routes(tgen
, input_dict_2
)
5247 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
5251 step("Redistribute static..")
5254 for dut
in ["red1", "blue1"]:
5255 temp
= {dut
: {"bgp": []}}
5256 input_dict_3
.update(temp
)
5259 VRFS
= ["RED_A", "RED_B"]
5262 VRFS
= ["BLUE_A", "BLUE_B"]
5265 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
5266 temp
[dut
]["bgp"].append(
5272 "unicast": {"redistribute": [{"redist_type": "static"}]}
5275 "unicast": {"redistribute": [{"redist_type": "static"}]}
5281 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
5282 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
5284 step("Configure a route-maps to match tag")
5286 for addr_type
in ADDR_TYPES
:
5290 "rmap1_{}".format(addr_type
): [
5291 {"action": "permit", "match": {addr_type
: {"tag": "4001"}}}
5296 result
= create_route_maps(tgen
, input_dict_4
)
5297 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
5301 step("Configure neighbor for route map")
5317 "name": "rmap1_ipv4",
5335 "name": "rmap1_ipv6",
5359 "name": "rmap1_ipv4",
5377 "name": "rmap1_ipv6",
5393 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
5394 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
5397 "Verify that within vrf instances, BGP best path selection"
5398 " algorithm remains intact and doesn't affect any other VRFs"
5399 " routing decision."
5403 for addr_type
in ADDR_TYPES
:
5408 "network": [NETWORK1_1
[addr_type
]],
5409 "next_hop": NEXT_HOP_IP
[addr_type
],
5417 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
5418 assert result
is True, "Testcase {} : Failed \n Error {}".format(
5422 for addr_type
in ADDR_TYPES
:
5427 "network": [NETWORK1_2
[addr_type
]],
5428 "next_hop": NEXT_HOP_IP
[addr_type
],
5432 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
5433 "next_hop": NEXT_HOP_IP
[addr_type
],
5440 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
5443 ), "Testcase {} : Failed \n Expected Behavior: Routes are denied \nError {}".format(tc_name
, result
)
5445 write_test_footer(tc_name
)
5448 def test_route_map_set_and_match_metric_p0(request
):
5451 Configure a route-map on DUT to match traffic based various
5455 tgen
= get_topogen()
5456 tc_name
= request
.node
.name
5457 write_test_header(tc_name
)
5458 reset_config_on_routers(tgen
)
5460 if tgen
.routers_have_failure():
5461 check_router_status(tgen
)
5464 "Advertise unique BGP prefixes(IPv4+IPv6) from RED_1"
5465 " in vrf instances(RED_A and RED_B)."
5468 for addr_type
in ADDR_TYPES
:
5473 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
5474 "next_hop": NEXT_HOP_IP
[addr_type
],
5478 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
5479 "next_hop": NEXT_HOP_IP
[addr_type
],
5485 result
= create_static_routes(tgen
, input_dict_1
)
5486 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
5491 "Advertise same set of BGP prefixes(IPv4+IPv6) from BLUE_1 and"
5492 "BLUE_2 in vrf instances(BLUE_A and BLUE_B)"
5495 for addr_type
in ADDR_TYPES
:
5500 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
5501 "next_hop": NEXT_HOP_IP
[addr_type
],
5505 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
5506 "next_hop": NEXT_HOP_IP
[addr_type
],
5512 result
= create_static_routes(tgen
, input_dict_2
)
5513 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
5517 step("Redistribute static..")
5530 "redist_type": "static",
5531 "attribute": {"metric": 123},
5540 "redist_type": "static",
5541 "attribute": {"metric": 123},
5553 "unicast": {"redistribute": [{"redist_type": "static"}]}
5556 "unicast": {"redistribute": [{"redist_type": "static"}]}
5572 "redist_type": "static",
5573 "attribute": {"metric": 123},
5582 "redist_type": "static",
5583 "attribute": {"metric": 123},
5595 "unicast": {"redistribute": [{"redist_type": "static"}]}
5598 "unicast": {"redistribute": [{"redist_type": "static"}]}
5606 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
5607 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
5609 step("Configure a route-maps to match tag")
5611 for addr_type
in ADDR_TYPES
:
5615 "rmap1_{}".format(addr_type
): [
5616 {"action": "permit", "match": {"metric": 123}}
5621 result
= create_route_maps(tgen
, input_dict_4
)
5622 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
5626 step("Configure neighbor for route map")
5642 "name": "rmap1_ipv4",
5660 "name": "rmap1_ipv6",
5684 "name": "rmap1_ipv4",
5702 "name": "rmap1_ipv6",
5726 "name": "rmap1_ipv4",
5744 "name": "rmap1_ipv6",
5768 "name": "rmap1_ipv4",
5786 "name": "rmap1_ipv6",
5802 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
5803 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
5806 "Verify that within vrf instances, BGP best path selection"
5807 " algorithm remains intact and doesn't affect any other VRFs"
5808 " routing decision."
5812 for addr_type
in ADDR_TYPES
:
5817 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
5818 "next_hop": NEXT_HOP_IP
[addr_type
],
5825 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_1
)
5826 assert result
is True, "Testcase {} : Failed \n Error {}".format(
5830 for addr_type
in ADDR_TYPES
:
5835 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
5836 "next_hop": NEXT_HOP_IP
[addr_type
],
5843 result
= verify_rib(tgen
, addr_type
, dut
, input_dict_2
, expected
=False)
5846 ), "Testcase {} : Failed \n Expected Behavior: Routes are denied \nError {}".format(tc_name
, result
)
5848 write_test_footer(tc_name
)
5851 def test_route_map_set_and_match_community_p0(request
):
5854 Configure a route-map on DUT to match traffic based various
5858 tgen
= get_topogen()
5859 tc_name
= request
.node
.name
5860 write_test_header(tc_name
)
5861 reset_config_on_routers(tgen
)
5863 if tgen
.routers_have_failure():
5864 pytest
.skip(tgen
.errors
)
5867 "Advertise unique BGP prefixes(IPv4+IPv6) from RED_1"
5868 " in vrf instances(RED_A and RED_B)."
5871 for addr_type
in ADDR_TYPES
:
5876 "network": [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]],
5877 "next_hop": NEXT_HOP_IP
[addr_type
],
5881 "network": [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]],
5882 "next_hop": NEXT_HOP_IP
[addr_type
],
5888 result
= create_static_routes(tgen
, input_dict_1
)
5889 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
5894 "Advertise same set of BGP prefixes(IPv4+IPv6) from BLUE_1 and"
5895 "BLUE_2 in vrf instances(BLUE_A and BLUE_B)"
5898 for addr_type
in ADDR_TYPES
:
5903 "network": [NETWORK3_1
[addr_type
]] + [NETWORK3_2
[addr_type
]],
5904 "next_hop": NEXT_HOP_IP
[addr_type
],
5908 "network": [NETWORK4_1
[addr_type
]] + [NETWORK4_2
[addr_type
]],
5909 "next_hop": NEXT_HOP_IP
[addr_type
],
5915 result
= create_static_routes(tgen
, input_dict_2
)
5916 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
5920 step("Redistribute static..")
5923 for dut
in ["red1", "blue1"]:
5924 temp
= {dut
: {"bgp": []}}
5925 input_dict_3
.update(temp
)
5928 VRFS
= ["RED_A", "RED_B"]
5931 VRFS
= ["BLUE_A", "BLUE_B"]
5934 for vrf
, as_num
in zip(VRFS
, AS_NUM
):
5935 temp
[dut
]["bgp"].append(
5941 "unicast": {"redistribute": [{"redist_type": "static"}]}
5944 "unicast": {"redistribute": [{"redist_type": "static"}]}
5950 result
= create_router_bgp(tgen
, topo
, input_dict_3
)
5951 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
5953 step("Create community-list")
5955 for addr_type
in ADDR_TYPES
:
5958 "bgp_community_lists": [
5960 "community_type": "standard",
5962 "name": "rmap_lcomm_{}".format(addr_type
),
5963 "value": "1:1 1:2 1:3 1:4 1:5",
5968 result
= create_bgp_community_lists(tgen
, input_dict_4
)
5969 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
5973 step("Configure a route-maps to match tag")
5975 step("Create route-maps in red1 and r1")
5977 for addr_type
in ADDR_TYPES
:
5981 "rmap_red1_{}".format(addr_type
): [
5984 "set": {"community": {"num": "1:1 1:2 1:3 1:4 1:5"}},
5991 "rmap1_{}".format(addr_type
): [
5995 "community_list": {"id": "rmap_lcomm_" + addr_type
}
6002 result
= create_route_maps(tgen
, input_dict_4
)
6003 assert result
is True, "Testcase {} : Failed \n Error: {}".format(
6007 step("Configure neighbor for route map")
6023 "name": "rmap_red1_ipv4",
6041 "name": "rmap_red1_ipv6",
6065 "name": "rmap_red1_ipv4",
6083 "name": "rmap_red1_ipv6",
6111 "name": "rmap1_ipv4",
6129 "name": "rmap1_ipv6",
6153 "name": "rmap1_ipv4",
6171 "name": "rmap1_ipv6",
6195 "name": "rmap1_ipv4",
6213 "name": "rmap1_ipv6",
6237 "name": "rmap1_ipv4",
6255 "name": "rmap1_ipv6",
6271 result
= create_router_bgp(tgen
, topo
, input_dict_4
)
6272 assert result
is True, "Testcase {} : Failed \n Error: {}".format(tc_name
, result
)
6275 "All the prefixes advertised from RED_1 and BLUE_1 should carry"
6276 " attributes set by outbound route-maps within specific vrfs. "
6277 "Router R1 should be able to match and permit/deny those "
6278 "prefixes based on received attributes. Please use below "
6279 "commands to verify."
6283 "community": "1:1 1:2 1:3 1:4 1:5",
6286 for addr_type
in ADDR_TYPES
:
6288 routes
= [NETWORK1_1
[addr_type
]] + [NETWORK1_2
[addr_type
]]
6289 result
= verify_bgp_community(tgen
, addr_type
, "r1", routes
, input_dict
, vrf
)
6290 assert result
is True, "Test case {} : Failed \n Error: {}".format(
6294 for addr_type
in ADDR_TYPES
:
6296 routes
= [NETWORK2_1
[addr_type
]] + [NETWORK2_2
[addr_type
]]
6297 result
= verify_bgp_community(tgen
, addr_type
, "r1", routes
, input_dict
, vrf
)
6298 assert result
is True, "Test case {} : Failed \n Error: {}".format(
6302 write_test_footer(tc_name
)
6305 if __name__
== "__main__":
6306 args
= ["-s"] + sys
.argv
[1:]
6307 sys
.exit(pytest
.main(args
))