]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotest: add a test to control the community-list count 17836/head
authorPhilippe Guibert <philippe.guibert@6wind.com>
Fri, 10 Jan 2025 16:46:56 +0000 (17:46 +0100)
committerPhilippe Guibert <philippe.guibert@6wind.com>
Tue, 14 Jan 2025 12:59:45 +0000 (13:59 +0100)
Add a test to control the community-list count.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
tests/topotests/bgp_comm_list_match/r1/bgpd.conf
tests/topotests/bgp_comm_list_match/r1/zebra.conf
tests/topotests/bgp_comm_list_match/test_bgp_comm_list_match.py
yang/frr-bgp-route-map.yang

index bac84120881892c927e2b7c72a8b4f5c21128709..d7d58d22aee60753d0094ebbac1318790d310a46 100644 (file)
@@ -12,6 +12,8 @@ router bgp 65001
 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
@@ -24,5 +26,13 @@ route-map r2 permit 30
  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
 !
index 4219a7ca3a4e4f4e7464fce9be3d84c35a72aec4..1b19a4a12bd26d04fa720de00c3a29bab92c7096 100644 (file)
@@ -4,6 +4,8 @@ interface lo
  ip address 172.16.255.2/32
  ip address 172.16.255.3/32
  ip address 172.16.255.4/32
+ ip address 172.16.255.5/32
+ ip address 172.16.255.6/32
 !
 interface r1-eth0
  ip address 192.168.0.1/24
index d0cab26e1afe96a46354e58887560f3ce77a39ae..c14ef6b8c365981fbe754fa8623b6f461e802954 100644 (file)
@@ -133,6 +133,70 @@ def test_bgp_comm_list_match_any():
     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))
index 233b55ff58d2c14818ee77fec76cd29746f5de34..efb0b2fa085127918a317f50d28d75d50e396ef0 100644 (file)
@@ -148,6 +148,12 @@ module frr-bgp-route-map {
       "Match BGP community list";
   }
 
+  identity match-community-limit {
+    base frr-route-map:rmap-match-type;
+    description
+      "Match BGP community limit count";
+  }
+
   identity match-large-community {
     base frr-route-map:rmap-match-type;
     description