]> git.proxmox.com Git - mirror_frr.git/commitdiff
tests: Check if routes are not sent back from the sender
authorDonatas Abraitis <donatas@opensourcerouting.org>
Thu, 5 Jan 2023 08:24:47 +0000 (10:24 +0200)
committerDonatas Abraitis <donatas@opensourcerouting.org>
Sat, 14 Jan 2023 19:30:07 +0000 (21:30 +0200)
Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
tests/topotests/bgp_sender_as_path_loop_detection/r1/bgpd.conf
tests/topotests/bgp_sender_as_path_loop_detection/r1/zebra.conf
tests/topotests/bgp_sender_as_path_loop_detection/r2/bgpd.conf
tests/topotests/bgp_sender_as_path_loop_detection/r3/bgpd.conf
tests/topotests/bgp_sender_as_path_loop_detection/test_bgp_sender-as-path-loop-detection.py

index 719d76392d33b8d94b4c90bd0a64c336b9cd68a7..409be747408809541992422902b4bea3ea1792ac 100644 (file)
@@ -1,14 +1,19 @@
 ! exit1
 router bgp 65001
-  no bgp ebgp-requires-policy
-  neighbor 192.168.255.1 remote-as 65002
-  neighbor 192.168.255.1 timers 3 10
-  address-family ipv4 unicast
-    neighbor 192.168.255.1 route-map prepend out
-    redistribute connected
-  exit-address-family
-  !
+ no bgp ebgp-requires-policy
+ neighbor 192.168.255.1 remote-as 65002
+ neighbor 192.168.255.1 timers 3 10
+ address-family ipv4 unicast
+  neighbor 192.168.255.1 route-map prepend out
+  redistribute connected
+ exit-address-family
+ !
+!
+ip prefix-list p1 seq 5 permit 172.16.255.253/32
 !
 route-map prepend permit 10
-  set as-path prepend 65003
+ match ip address prefix-list p1
+ set as-path prepend 65003
+!
+route-map prepend permit 20
 !
index 9904bb4e16f40c28e4e101cc2e2cb4c74a093cbc..74489a057110d48d27ff7119d22bf195fec008d5 100644 (file)
@@ -1,5 +1,6 @@
 ! exit1
 interface lo
+ ip address 172.16.255.253/32
  ip address 172.16.255.254/32
 !
 interface r1-eth0
index a4a654d7b5c24f458a5dc2fa144df451f9417f93..dcb52a2e7dbcfaff7bba5373eaf1502263145864 100644 (file)
@@ -1,11 +1,10 @@
 ! spine
 router bgp 65002
-  no bgp ebgp-requires-policy
-  neighbor 192.168.255.2 remote-as 65001
-  neighbor 192.168.255.2 timers 3 10
-  neighbor 192.168.255.2 solo
-  neighbor 192.168.254.2 remote-as 65003
-  neighbor 192.168.254.2 timers 3 10
-  neighbor 192.168.254.2 solo
-  neighbor 192.168.254.2 sender-as-path-loop-detection
+ no bgp ebgp-requires-policy
+ neighbor 192.168.255.2 remote-as 65001
+ neighbor 192.168.255.2 timers 3 10
+ neighbor 192.168.255.2 sender-as-path-loop-detection
+ neighbor 192.168.254.2 remote-as 65003
+ neighbor 192.168.254.2 timers 3 10
+ neighbor 192.168.254.2 sender-as-path-loop-detection
 !
index 2e24de0b2d89ca48fa02267a8fb25a911e0e86c9..519273d30d7ff79132c92efbe46ef21cba55b541 100644 (file)
@@ -1,6 +1,6 @@
 ! exit2
 router bgp 65003
 no bgp ebgp-requires-policy
 neighbor 192.168.254.1 remote-as 65002
 neighbor 192.168.254.1 timers 3 10
+ no bgp ebgp-requires-policy
+ neighbor 192.168.254.1 remote-as 65002
+ neighbor 192.168.254.1 timers 3 10
 !
index b5c33f359bfc538846a38e6a2805fc17a2fc2afb..ebeab05648e9670372b469b10f64825bd642701f 100644 (file)
@@ -85,20 +85,20 @@ def test_bgp_sender_as_path_loop_detection():
     if tgen.routers_have_failure():
         pytest.skip(tgen.errors)
 
-    router = tgen.gears["r2"]
+    r2 = tgen.gears["r2"]
 
-    def _bgp_converge(router):
-        output = json.loads(router.vtysh_cmd("show ip bgp neighbor 192.168.255.2 json"))
+    def _bgp_converge():
+        output = json.loads(r2.vtysh_cmd("show ip bgp neighbor 192.168.255.2 json"))
         expected = {
             "192.168.255.2": {
                 "bgpState": "Established",
-                "addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 2}},
+                "addressFamilyInfo": {"ipv4Unicast": {"acceptedPrefixCounter": 3}},
             }
         }
         return topotest.json_cmp(output, expected)
 
-    def _bgp_has_route_from_r1(router):
-        output = json.loads(router.vtysh_cmd("show ip bgp 172.16.255.254/32 json"))
+    def _bgp_has_route_from_r1():
+        output = json.loads(r2.vtysh_cmd("show ip bgp 172.16.255.253/32 json"))
         expected = {
             "paths": [
                 {
@@ -111,31 +111,35 @@ def test_bgp_sender_as_path_loop_detection():
         }
         return topotest.json_cmp(output, expected)
 
-    def _bgp_suppress_route_to_r3(router):
+    def _bgp_suppress_route_to_r1():
         output = json.loads(
-            router.vtysh_cmd(
-                "show ip bgp neighbor 192.168.254.2 advertised-routes json"
-            )
+            r2.vtysh_cmd("show ip bgp neighbor 192.168.255.2 advertised-routes json")
         )
         expected = {"totalPrefixCounter": 0}
         return topotest.json_cmp(output, expected)
 
-    test_func = functools.partial(_bgp_converge, router)
-    success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
-
-    assert result is None, 'Failed bgp convergence in "{}"'.format(router)
+    def _bgp_suppress_route_to_r3():
+        output = json.loads(
+            r2.vtysh_cmd("show ip bgp neighbor 192.168.254.2 advertised-routes json")
+        )
+        expected = {"totalPrefixCounter": 2}
+        return topotest.json_cmp(output, expected)
 
-    test_func = functools.partial(_bgp_has_route_from_r1, router)
-    success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    test_func = functools.partial(_bgp_converge)
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "Failed bgp to convergence"
 
-    assert result is None, 'Failed to see a route from r1 in "{}"'.format(router)
+    test_func = functools.partial(_bgp_has_route_from_r1)
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "Failed to see a route from r1"
 
-    test_func = functools.partial(_bgp_suppress_route_to_r3, router)
-    success, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5)
+    test_func = functools.partial(_bgp_suppress_route_to_r3)
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "Route 172.16.255.253/32 should not be sent to r3 from r2"
 
-    assert (
-        result is None
-    ), 'Route 172.16.255.254/32 should not be sent to r3 "{}"'.format(router)
+    test_func = functools.partial(_bgp_suppress_route_to_r1)
+    _, result = topotest.run_and_expect(test_func, None, count=30, wait=0.5)
+    assert result is None, "Routes should not be sent to r1 from r2"
 
 
 if __name__ == "__main__":