]> git.puffer.fish Git - matthieu/frr.git/commitdiff
tests: Check for 0.0.0.0/1 in bgp_default_route
authorXiao Liang <shaw.leon@gmail.com>
Mon, 18 Dec 2023 06:57:22 +0000 (14:57 +0800)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Mon, 18 Dec 2023 14:17:59 +0000 (14:17 +0000)
Ensure that 0.0.0.0/1 route can be advertised along with
default-originate.

Signed-off-by: Xiao Liang <shaw.leon@gmail.com>
(cherry picked from commit 4538247c995e551aed0c08c4bb20b187ce95f5f2)

tests/topotests/bgp_default_route/r1/bgpd.conf
tests/topotests/bgp_default_route/r1/zebra.conf
tests/topotests/bgp_default_route/test_bgp_default-originate.py

index 8699d62ff2de74c6e7e2cbb306ffc8b029983ba5..10ced3610a023771d14cab8dd7923aabeb9f5d21 100644 (file)
@@ -3,6 +3,7 @@ router bgp 65000
   neighbor 192.168.255.2 remote-as 65001
   neighbor 192.168.255.2 timers 3 10
   address-family ipv4 unicast
+    network 0.0.0.0/1
     neighbor 192.168.255.2 default-originate
   exit-address-family
 !
index 0a283c06d57c15d87fe3c0a2807105fbe1f4a21b..fbf97b0520ceed7a730a151a1ef104689b4d63cc 100644 (file)
@@ -1,4 +1,6 @@
 !
+ip route 0.0.0.0/1 blackhole
+!
 interface lo
  ip address 172.16.255.254/32
 !
index b2d530b423fe3b0726b4a8302a68a379864cbbaf..05ba39092436cbd3c0eedb101c0f236d87322369 100644 (file)
@@ -82,18 +82,18 @@ def test_bgp_default_originate_route_map():
         expected = {
             "192.168.255.1": {
                 "bgpState": "Established",
-                "addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 1}},
+                "addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 2}},
             }
         }
         return topotest.json_cmp(output, expected)
 
     def _bgp_check_if_originated():
         output = json.loads(tgen.gears["r1"].vtysh_cmd("show ip bgp summary json"))
-        expected = {"ipv4Unicast": {"peers": {"192.168.255.2": {"pfxSnt": 1}}}}
+        expected = {"ipv4Unicast": {"peers": {"192.168.255.2": {"pfxSnt": 2}}}}
         return topotest.json_cmp(output, expected)
 
-    def _bgp_default_route_is_valid(router):
-        output = json.loads(router.vtysh_cmd("show ip bgp 0.0.0.0/0 json"))
+    def _bgp_route_is_valid(router, prefix):
+        output = json.loads(router.vtysh_cmd("show ip bgp {} json".format(prefix)))
         expected = {"paths": [{"valid": True}]}
         return topotest.json_cmp(output, expected)
 
@@ -105,10 +105,14 @@ def test_bgp_default_originate_route_map():
     success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
     assert result is None, "No 0.0.0.0/0 from r1 to r2"
 
-    test_func = functools.partial(_bgp_default_route_is_valid, tgen.gears["r2"])
+    test_func = functools.partial(_bgp_route_is_valid, tgen.gears["r2"], "0.0.0.0/0")
     success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
     assert result is None, "Failed to see 0.0.0.0/0 in r2"
 
+    test_func = functools.partial(_bgp_route_is_valid, tgen.gears["r2"], "0.0.0.0/1")
+    success, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "Failed to see 0.0.0.0/1 in r2"
+
 
 if __name__ == "__main__":
     args = ["-s"] + sys.argv[1:]