]>
git.proxmox.com Git - mirror_frr.git/blob - tests/topotests/bgp_vrf_leaking_rt_change_route_maps/test_bgp_vrf_leaking_rt_change_route_maps.py
2 # SPDX-License-Identifier: ISC
5 # Copyright (c) 2022 by
6 # Donatas Abraitis <donatas@opensourcerouting.org>
10 If we overwrite import/export RT list via route-maps or even flush by using
11 `set extcommunity none`, then we must withdraw old paths from VRFs to avoid
21 CWD
= os
.path
.dirname(os
.path
.realpath(__file__
))
22 sys
.path
.append(os
.path
.join(CWD
, "../"))
24 # pylint: disable=C0413
25 from lib
import topotest
26 from lib
.topogen
import Topogen
, TopoRouter
, get_topogen
27 from lib
.common_config
import step
29 pytestmark
= [pytest
.mark
.bgpd
]
36 def setup_module(mod
):
37 tgen
= Topogen(build_topo
, mod
.__name
__)
40 router
= tgen
.gears
["r1"]
41 router
.cmd_raises("ip link add vrf1 type vrf table 10")
42 router
.cmd_raises("ip link set up dev vrf1")
43 router
.cmd_raises("ip link add vrf2 type vrf table 20")
44 router
.cmd_raises("ip link set up dev vrf2")
45 router
.load_config(TopoRouter
.RD_ZEBRA
, os
.path
.join(CWD
, "r1/zebra.conf"))
46 router
.load_config(TopoRouter
.RD_BGP
, os
.path
.join(CWD
, "r1/bgpd.conf"))
50 def teardown_module(mod
):
55 def test_bgp_vrf_leaking_rt_change_route_maps():
58 router
= tgen
.gears
["r1"]
60 if tgen
.routers_have_failure():
61 pytest
.skip(tgen
.errors
)
63 def _bgp_check_path():
64 output
= json
.loads(router
.vtysh_cmd("show bgp vrf vrf2 ipv4 unicast json"))
65 expected
= {"routes": {"192.168.100.100/32": [{"nhVrfName": "vrf1"}]}}
66 return topotest
.json_cmp(output
, expected
)
68 step("Initial converge")
69 test_func
= functools
.partial(_bgp_check_path
)
70 _
, result
= topotest
.run_and_expect(test_func
, None, count
=60, wait
=0.5)
71 assert result
is None, "Can't see 192.168.100.100/32 leaked from vrf1 into vrf2."
73 step("Overwrite RT list (remove rt 65500:11990 from route-map)")
77 route-map rm permit 10
78 set extcommunity rt 65500:10100
83 step("Check if 192.168.100.100/32 was removed from vrf2")
84 test_func
= functools
.partial(_bgp_check_path
)
85 _
, result
= topotest
.run_and_expect(test_func
, not None, count
=20, wait
=0.5)
86 assert result
is not None, "192.168.100.100/32 still exists in vrf2 as stale."
89 if __name__
== "__main__":
90 args
= ["-s"] + sys
.argv
[1:]
91 sys
.exit(pytest
.main(args
))