]> git.puffer.fish Git - mirror/frr.git/commitdiff
topotests: test leak from the default vrf 15255/head
authorLouis Scalbert <louis.scalbert@6wind.com>
Thu, 1 Feb 2024 10:44:06 +0000 (11:44 +0100)
committerLouis Scalbert <louis.scalbert@6wind.com>
Thu, 1 Feb 2024 10:46:56 +0000 (11:46 +0100)
Add tests in bgp_vrf_route_leak_basic topotest to check that route
leaking from the default VRF results in an operational route.

Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
tests/topotests/bgp_vrf_route_leak_basic/r1/bgpd.conf
tests/topotests/bgp_vrf_route_leak_basic/r1/zebra.conf
tests/topotests/bgp_vrf_route_leak_basic/setup_vrfs
tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py

index ff217b3f2f6e7913e3d6f481372a5fa306e1dd92..f52f56b0e06bff7ccbe2abf5e44ca1228cfa8820 100644 (file)
@@ -1,11 +1,19 @@
 hostname r1
 
+router bgp 99
+  no bgp ebgp-requires-policy
+  address-family ipv4 unicast
+    redistribute connected
+    import vrf DONNA
+  !
+!
 router bgp 99 vrf DONNA
   no bgp ebgp-requires-policy
   address-family ipv4 unicast
     redistribute connected
     import vrf EVA
     import vrf NOTEXISTING
+    import vrf default
   !
 !
 router bgp 99 vrf EVA
index 731a00829d4e83ff984b9ddc12ed1571fc50b8ef..4de9e895a2c43453d846ed02ebc64e164a76e160 100644 (file)
@@ -1,5 +1,9 @@
 hostname r1
 
+int dummy0
+  ip address 10.0.4.1/24
+  no shut
+!
 int dummy1
   ip address 10.0.0.1/24
   no shut
index fb67953fe3959a0db9a188167202a9f074373877..f62c5cd211158904426bd5ea717e223ba3f638e8 100644 (file)
@@ -3,6 +3,7 @@
 ip link add DONNA type vrf table 1001
 ip link add EVA type vrf table 1002
 
+ip link add dummy0 type dummy # vrf default
 ip link add dummy1 type dummy
 ip link add dummy2 type dummy
 ip link add dummy3 type dummy
index 4803bf64c4d24d63e564e3106c679fe2e2cffba4..ef813e9541822a12590d1457753cd41c7e617c2a 100644 (file)
@@ -64,7 +64,7 @@ def teardown_module(mod):
     tgen.stop_topology()
 
 
-def test_vrf_route_leak():
+def test_vrf_route_leak_donna():
     logger.info("Ensure that routes are leaked back and forth")
     tgen = get_topogen()
     # Don't run this test if we have any failure.
@@ -109,6 +109,20 @@ def test_vrf_route_leak():
                 ],
             },
         ],
+        "10.0.4.0/24": [
+            {
+                "protocol": "bgp",
+                "selected": True,
+                "nexthops": [
+                    {
+                        "fib": True,
+                        "interfaceName": "lo",
+                        "vrf": "default",
+                        "active": True,
+                    },
+                ],
+            },
+        ],
         "172.16.101.0/24": [
             {
                 "protocol": "bgp",
@@ -129,6 +143,16 @@ def test_vrf_route_leak():
     result, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
     assert result, "BGP VRF DONNA check failed:\n{}".format(diff)
 
+
+def test_vrf_route_leak_eva():
+    logger.info("Ensure that routes are leaked back and forth")
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    r1 = tgen.gears["r1"]
+
     # Test EVA VRF.
     expect = {
         "10.0.0.0/24": [
@@ -190,6 +214,217 @@ def test_vrf_route_leak():
     assert result, "BGP VRF EVA check failed:\n{}".format(diff)
 
 
+def test_vrf_route_leak_donna():
+    logger.info("Ensure that routes are leaked back and forth")
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    r1 = tgen.gears["r1"]
+
+    # Test DONNA VRF.
+    expect = {
+        "10.0.0.0/24": [
+            {
+                "protocol": "connected",
+            }
+        ],
+        "10.0.1.0/24": [
+            {
+                "protocol": "bgp",
+                "selected": True,
+                "nexthops": [
+                    {
+                        "fib": True,
+                        "interfaceName": "EVA",
+                        "vrf": "EVA",
+                        "active": True,
+                    },
+                ],
+            },
+        ],
+        "10.0.2.0/24": [{"protocol": "connected"}],
+        "10.0.3.0/24": [
+            {
+                "protocol": "bgp",
+                "selected": True,
+                "nexthops": [
+                    {
+                        "fib": True,
+                        "interfaceName": "EVA",
+                        "vrf": "EVA",
+                        "active": True,
+                    },
+                ],
+            },
+        ],
+        "10.0.4.0/24": [
+            {
+                "protocol": "bgp",
+                "selected": True,
+                "nexthops": [
+                    {
+                        "fib": True,
+                        "interfaceName": "lo",
+                        "vrf": "default",
+                        "active": True,
+                    },
+                ],
+            },
+        ],
+        "172.16.101.0/24": [
+            {
+                "protocol": "bgp",
+                "nexthops": [
+                    {
+                        "interfaceIndex": 0,
+                        "interfaceName": "unknown",
+                        "vrf": "Unknown",
+                    },
+                ],
+            },
+        ],
+    }
+
+    test_func = partial(
+        topotest.router_json_cmp, r1, "show ip route vrf DONNA json", expect
+    )
+    result, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
+    assert result, "BGP VRF DONNA check failed:\n{}".format(diff)
+
+
+def test_vrf_route_leak_eva():
+    logger.info("Ensure that routes are leaked back and forth")
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    r1 = tgen.gears["r1"]
+
+    # Test EVA VRF.
+    expect = {
+        "10.0.0.0/24": [
+            {
+                "protocol": "bgp",
+                "selected": True,
+                "nexthops": [
+                    {
+                        "fib": True,
+                        "interfaceName": "DONNA",
+                        "vrf": "DONNA",
+                        "active": True,
+                    },
+                ],
+            },
+        ],
+        "10.0.1.0/24": [
+            {
+                "protocol": "connected",
+            }
+        ],
+        "10.0.2.0/24": [
+            {
+                "protocol": "bgp",
+                "selected": True,
+                "nexthops": [
+                    {
+                        "fib": True,
+                        "interfaceName": "DONNA",
+                        "vrf": "DONNA",
+                        "active": True,
+                    },
+                ],
+            },
+        ],
+        "10.0.3.0/24": [
+            {
+                "protocol": "connected",
+            }
+        ],
+        "172.16.101.0/24": [
+            {
+                "protocol": "bgp",
+                "nexthops": [
+                    {
+                        "interfaceIndex": 0,
+                        "interfaceName": "unknown",
+                        "vrf": "Unknown",
+                    },
+                ],
+            },
+        ],
+    }
+
+
+def test_vrf_route_leak_default():
+    logger.info("Ensure that routes are leaked back and forth")
+    tgen = get_topogen()
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    r1 = tgen.gears["r1"]
+
+    # Test default VRF.
+    expect = {
+        "10.0.0.0/24": [
+            {
+                "protocol": "bgp",
+                "selected": True,
+                "nexthops": [
+                    {
+                        "fib": True,
+                        "interfaceName": "DONNA",
+                        "vrf": "DONNA",
+                        "active": True,
+                    },
+                ],
+            },
+        ],
+        "10.0.2.0/24": [
+            {
+                "protocol": "bgp",
+                "selected": True,
+                "nexthops": [
+                    {
+                        "fib": True,
+                        "interfaceName": "DONNA",
+                        "vrf": "DONNA",
+                        "active": True,
+                    },
+                ],
+            },
+        ],
+        "10.0.4.0/24": [
+            {
+                "protocol": "connected",
+            }
+        ],
+    }
+
+    test_func = partial(topotest.router_json_cmp, r1, "show ip route json", expect)
+    result, diff = topotest.run_and_expect(test_func, None, count=10, wait=0.5)
+    assert result, "BGP VRF default check failed:\n{}".format(diff)
+
+
+def test_ping():
+    "Simple ping tests"
+
+    tgen = get_topogen()
+
+    # Don't run this test if we have any failure.
+    if tgen.routers_have_failure():
+        pytest.skip(tgen.errors)
+
+    r1 = tgen.gears["r1"]
+
+    logger.info("Ping from default to DONNA")
+    output = r1.run("ping -c 4 -w 4 -I 10.0.4.1 10.0.0.1")
+    assert " 0% packet loss" in output, "Ping default->DONNA FAILED"
+
+
 def test_memory_leak():
     "Run the memory leak test and report results."
     tgen = get_topogen()