ip prefix-list p1 seq 5 permit 172.16.255.1/32
ip prefix-list p3 seq 5 permit 172.16.255.3/32
ip prefix-list p4 seq 5 permit 172.16.255.4/32
+ip prefix-list p5 seq 5 permit 172.16.255.5/32
+ip prefix-list p6 seq 5 permit 172.16.255.6/32
!
route-map r2 permit 10
match ip address prefix-list p1
set community 65001:10 65001:12 65001:13
exit
route-map r2 permit 40
+ match ip address prefix-list p5
+ set community 65001:13 65001:14
+exit
+route-map r2 permit 50
+ match ip address prefix-list p6
+ set community 65001:16 65001:17 65001:18 65001:19
+exit
+route-map r2 permit 60
exit
!
assert result is None, "Failed to filter BGP UPDATES with community-list on R3"
+def test_bgp_comm_list_limit_match():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ router = tgen.gears["r3"]
+ router.vtysh_cmd(
+ """
+ configure terminal
+ route-map r1 permit 20
+ match community-limit 3
+ """
+ )
+
+ def _bgp_count():
+ output = json.loads(router.vtysh_cmd("show bgp ipv4 json"))
+ expected = {
+ "vrfName": "default",
+ "routerId": "192.168.1.3",
+ "localAS": 65003,
+ "totalRoutes": 3,
+ "totalPaths": 3,
+ }
+ return topotest.json_cmp(output, expected)
+
+ step("Check that 3 routes have been received on R3")
+ test_func = functools.partial(_bgp_count)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert result is None, "Failed to check that 3 routes have been received on R3"
+
+
+def test_bgp_comm_list_reset_limit_match():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ router = tgen.gears["r3"]
+ router.vtysh_cmd(
+ """
+ configure terminal
+ route-map r1 permit 20
+ no match community-limit
+ """
+ )
+
+ def _bgp_count_two():
+ output = json.loads(router.vtysh_cmd("show bgp ipv4 json"))
+ expected = {
+ "vrfName": "default",
+ "routerId": "192.168.1.3",
+ "localAS": 65003,
+ "totalRoutes": 4,
+ "totalPaths": 4,
+ }
+ return topotest.json_cmp(output, expected)
+
+ step("Check that 4 routes have been received on R3")
+ test_func = functools.partial(_bgp_count_two)
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+ assert result is None, "Failed to check that 4 routes have been received on R3"
+
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))