summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/subdir.am2
-rw-r--r--tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py7
-rw-r--r--tests/topotests/bgp_rpki_topo1/r2/bgpd.conf6
-rw-r--r--tests/topotests/bgp_rpki_topo1/r2/zebra.conf3
-rw-r--r--tests/topotests/bgp_rpki_topo1/r4/bgpd.conf6
-rw-r--r--tests/topotests/bgp_rpki_topo1/r4/zebra.conf4
-rw-r--r--tests/topotests/bgp_rpki_topo1/test_bgp_rpki_topo1.py48
-rw-r--r--tests/topotests/bgp_srv6l3vpn_route_leak/pe1/results/vrf20_ipv4.json2
-rw-r--r--tests/topotests/bgp_vrf_route_leak_basic/r1/bgpd.conf17
-rw-r--r--tests/topotests/bgp_vrf_route_leak_basic/r1/zebra.conf10
-rw-r--r--tests/topotests/bgp_vrf_route_leak_basic/setup_vrfs1
-rw-r--r--tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py313
-rw-r--r--tests/topotests/mgmt_notif/test_notif.py2
-rw-r--r--tests/topotests/ospf_multi_vrf_bgp_route_leak/r1/zebra-vrf-default.txt2
-rw-r--r--tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-default.txt2
-rw-r--r--tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-ray.txt4
-rw-r--r--tests/topotests/ospfapi/test_ospf_clientapi.py64
-rw-r--r--tests/topotests/static_vrf/r1/frr.conf18
-rw-r--r--tests/topotests/static_vrf/test_static_vrf.py126
19 files changed, 598 insertions, 39 deletions
diff --git a/tests/lib/subdir.am b/tests/lib/subdir.am
index 9247ac3358..82314ccc04 100644
--- a/tests/lib/subdir.am
+++ b/tests/lib/subdir.am
@@ -25,7 +25,7 @@ copy_script: tests/lib/script1.lua
$(INSTALL_SCRIPT) $< tests/lib/script1.lua
##############################################################################
-GRPC_TESTS_LDADD = staticd/libstatic.a grpc/libfrrgrpc_pb.la -lgrpc++ -lprotobuf $(ALL_TESTS_LDADD) $(LIBYANG_LIBS) -lm
+GRPC_TESTS_LDADD = mgmtd/libmgmt_be_nb.la staticd/libstatic.a grpc/libfrrgrpc_pb.la -lgrpc++ -lprotobuf $(ALL_TESTS_LDADD) $(LIBYANG_LIBS) -lm
if GRPC
check_PROGRAMS += tests/lib/test_grpc
diff --git a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py
index 28047f7b2d..217657d358 100644
--- a/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py
+++ b/tests/topotests/bgp_l3vpn_to_bgp_vrf/scripts/check_routes.py
@@ -891,4 +891,11 @@ luCommand(
"pass",
"Redundant route 2 details",
)
+luCommand(
+ "r1",
+ 'vtysh -c "show ip route vrf r1-cust5 5.1.0.0/24"',
+ "Known via .bgp., distance 200, .* vrf r1-cust5, best",
+ "pass",
+ "Recursive route leak details",
+)
# done
diff --git a/tests/topotests/bgp_rpki_topo1/r2/bgpd.conf b/tests/topotests/bgp_rpki_topo1/r2/bgpd.conf
index 95b1e5bdc1..87d7214972 100644
--- a/tests/topotests/bgp_rpki_topo1/r2/bgpd.conf
+++ b/tests/topotests/bgp_rpki_topo1/r2/bgpd.conf
@@ -4,6 +4,12 @@ router bgp 65002
neighbor 192.0.2.1 timers connect 1
neighbor 192.0.2.1 ebgp-multihop 3
neighbor 192.0.2.1 update-source 192.0.2.2
+ neighbor 192.168.4.4 remote-as internal
+ neighbor 192.168.4.4 timers 1 3
+ neighbor 192.168.4.4 timers connect 1
+ address-family ipv4 unicast
+ neighbor 192.168.4.4 next-hop-self
+ exit-address-family
!
router bgp 65002 vrf vrf10
no bgp ebgp-requires-policy
diff --git a/tests/topotests/bgp_rpki_topo1/r2/zebra.conf b/tests/topotests/bgp_rpki_topo1/r2/zebra.conf
index d44a8a9088..785dbc6ce5 100644
--- a/tests/topotests/bgp_rpki_topo1/r2/zebra.conf
+++ b/tests/topotests/bgp_rpki_topo1/r2/zebra.conf
@@ -10,3 +10,6 @@ interface r2-eth0
interface r2-eth1 vrf vrf10
ip address 192.168.2.2/24
!
+interface r2-eth2
+ ip address 192.168.4.2/24
+!
diff --git a/tests/topotests/bgp_rpki_topo1/r4/bgpd.conf b/tests/topotests/bgp_rpki_topo1/r4/bgpd.conf
new file mode 100644
index 0000000000..80dc9ca86f
--- /dev/null
+++ b/tests/topotests/bgp_rpki_topo1/r4/bgpd.conf
@@ -0,0 +1,6 @@
+router bgp 65002
+ no bgp ebgp-requires-policy
+ neighbor 192.168.4.2 remote-as internal
+ neighbor 192.168.4.2 timers 1 3
+ neighbor 192.168.4.2 timers connect 1
+!
diff --git a/tests/topotests/bgp_rpki_topo1/r4/zebra.conf b/tests/topotests/bgp_rpki_topo1/r4/zebra.conf
new file mode 100644
index 0000000000..ed793aeb43
--- /dev/null
+++ b/tests/topotests/bgp_rpki_topo1/r4/zebra.conf
@@ -0,0 +1,4 @@
+!
+interface r4-eth0
+ ip address 192.168.4.4/24
+!
diff --git a/tests/topotests/bgp_rpki_topo1/test_bgp_rpki_topo1.py b/tests/topotests/bgp_rpki_topo1/test_bgp_rpki_topo1.py
index 0416148b27..a12204f240 100644
--- a/tests/topotests/bgp_rpki_topo1/test_bgp_rpki_topo1.py
+++ b/tests/topotests/bgp_rpki_topo1/test_bgp_rpki_topo1.py
@@ -22,7 +22,7 @@ pytestmark = [pytest.mark.bgpd]
def build_topo(tgen):
- for routern in range(1, 4):
+ for routern in range(1, 5):
tgen.add_router("r{}".format(routern))
switch = tgen.add_switch("s1")
@@ -33,6 +33,10 @@ def build_topo(tgen):
switch.add_link(tgen.gears["r2"])
switch.add_link(tgen.gears["r3"])
+ switch = tgen.add_switch("s3")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r4"])
+
def setup_module(mod):
tgen = Topogen(build_topo, mod.__name__)
@@ -402,6 +406,48 @@ router bgp 65002 vrf vrf10
assert result is None, "Unexpected prefixes RPKI state on {}".format(rname)
+def test_bgp_ecommunity_rpki():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ r2 = tgen.gears["r2"]
+ r4 = tgen.gears["r4"]
+
+ # Flush all the states what was before and try sending out the prefixes
+ # with RPKI extended community.
+ r2.vtysh_cmd("clear ip bgp 192.168.4.4 soft out")
+
+ def _bgp_check_ecommunity_rpki(community=None):
+ output = json.loads(r4.vtysh_cmd("show bgp ipv4 unicast 198.51.100.0/24 json"))
+ expected = {
+ "paths": [
+ {
+ "extendedCommunity": community,
+ }
+ ]
+ }
+ return topotest.json_cmp(output, expected)
+
+ test_func = functools.partial(_bgp_check_ecommunity_rpki, {"string": "OVS:valid"})
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert result is None, "Didn't receive RPKI extended community"
+
+ r2.vtysh_cmd(
+ """
+ configure terminal
+ router bgp 65002
+ address-family ipv4 unicast
+ no neighbor 192.168.4.4 send-community extended rpki
+ """
+ )
+
+ test_func = functools.partial(_bgp_check_ecommunity_rpki)
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert result is None, "Received RPKI extended community"
+
+
if __name__ == "__main__":
args = ["-s"] + sys.argv[1:]
sys.exit(pytest.main(args))
diff --git a/tests/topotests/bgp_srv6l3vpn_route_leak/pe1/results/vrf20_ipv4.json b/tests/topotests/bgp_srv6l3vpn_route_leak/pe1/results/vrf20_ipv4.json
index 9f78447255..2ce936b291 100644
--- a/tests/topotests/bgp_srv6l3vpn_route_leak/pe1/results/vrf20_ipv4.json
+++ b/tests/topotests/bgp_srv6l3vpn_route_leak/pe1/results/vrf20_ipv4.json
@@ -12,7 +12,7 @@
{
"fib": true,
"directlyConnected": true,
- "interfaceName": "eth0",
+ "interfaceName": "vrf10",
"vrf": "vrf10",
"active": true
}
diff --git a/tests/topotests/bgp_vrf_route_leak_basic/r1/bgpd.conf b/tests/topotests/bgp_vrf_route_leak_basic/r1/bgpd.conf
index 03dfbf9322..f52f56b0e0 100644
--- a/tests/topotests/bgp_vrf_route_leak_basic/r1/bgpd.conf
+++ b/tests/topotests/bgp_vrf_route_leak_basic/r1/bgpd.conf
@@ -1,10 +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
@@ -12,5 +21,13 @@ router bgp 99 vrf EVA
address-family ipv4 unicast
redistribute connected
import vrf DONNA
+ import vrf NOTEXISTING
+ !
+!
+router bgp 99 vrf NOTEXISTING
+ no bgp ebgp-requires-policy
+ no bgp network import-check
+ address-family ipv4 unicast
+ network 172.16.101.0/24
!
!
diff --git a/tests/topotests/bgp_vrf_route_leak_basic/r1/zebra.conf b/tests/topotests/bgp_vrf_route_leak_basic/r1/zebra.conf
index 35038557df..4de9e895a2 100644
--- a/tests/topotests/bgp_vrf_route_leak_basic/r1/zebra.conf
+++ b/tests/topotests/bgp_vrf_route_leak_basic/r1/zebra.conf
@@ -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
@@ -16,3 +20,9 @@ int dummy4
ip address 10.0.3.1/24
no shut
!
+int EVA
+ no shut
+!
+int DONNA
+ no shut
+!
diff --git a/tests/topotests/bgp_vrf_route_leak_basic/setup_vrfs b/tests/topotests/bgp_vrf_route_leak_basic/setup_vrfs
index fb67953fe3..f62c5cd211 100644
--- a/tests/topotests/bgp_vrf_route_leak_basic/setup_vrfs
+++ b/tests/topotests/bgp_vrf_route_leak_basic/setup_vrfs
@@ -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
diff --git a/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py b/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py
index fd7ffff17c..ef813e9541 100644
--- a/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py
+++ b/tests/topotests/bgp_vrf_route_leak_basic/test_bgp-vrf-route-leak-basic.py
@@ -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.
@@ -81,11 +81,59 @@ def test_vrf_route_leak():
}
],
"10.0.1.0/24": [
- {"protocol": "bgp", "selected": True, "nexthops": [{"fib": True}]}
+ {
+ "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}]}
+ {
+ "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",
+ },
+ ],
+ },
],
}
@@ -95,10 +143,31 @@ 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": [
- {"protocol": "bgp", "selected": True, "nexthops": [{"fib": True}]}
+ {
+ "protocol": "bgp",
+ "selected": True,
+ "nexthops": [
+ {
+ "fib": True,
+ "interfaceName": "DONNA",
+ "vrf": "DONNA",
+ "active": True,
+ },
+ ],
+ },
],
"10.0.1.0/24": [
{
@@ -106,13 +175,36 @@ def test_vrf_route_leak():
}
],
"10.0.2.0/24": [
- {"protocol": "bgp", "selected": True, "nexthops": [{"fib": True}]}
+ {
+ "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",
+ },
+ ],
+ },
+ ],
}
test_func = partial(
@@ -122,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()
diff --git a/tests/topotests/mgmt_notif/test_notif.py b/tests/topotests/mgmt_notif/test_notif.py
index 2f923e398c..c85e7ba795 100644
--- a/tests/topotests/mgmt_notif/test_notif.py
+++ b/tests/topotests/mgmt_notif/test_notif.py
@@ -92,7 +92,7 @@ def test_backend_notification(tgen):
pytest.skip("No mgmtd_testc")
output = r1.cmd_raises(
- be_client_path + " --timeout 20 --log file:mgmt_testc.log --listen frr-ripd"
+ be_client_path + " --timeout 20 --log file:mgmt_testc.log --listen /frr-ripd"
)
jsout = json.loads(output)
diff --git a/tests/topotests/ospf_multi_vrf_bgp_route_leak/r1/zebra-vrf-default.txt b/tests/topotests/ospf_multi_vrf_bgp_route_leak/r1/zebra-vrf-default.txt
index ca9ca77bf5..248375dc6c 100644
--- a/tests/topotests/ospf_multi_vrf_bgp_route_leak/r1/zebra-vrf-default.txt
+++ b/tests/topotests/ospf_multi_vrf_bgp_route_leak/r1/zebra-vrf-default.txt
@@ -7,5 +7,5 @@ O>* 10.0.4.0/24 [110/20] via 10.0.20.2, r1-eth1, weight 1, XX:XX:XX
O 10.0.20.0/24 [110/10] is directly connected, r1-eth1, weight 1, XX:XX:XX
C>* 10.0.20.0/24 is directly connected, r1-eth1, XX:XX:XX
L>* 10.0.20.1/32 is directly connected, r1-eth1, XX:XX:XX
-B>* 10.0.30.0/24 [20/0] is directly connected, r1-eth2 (vrf neno), weight 1, XX:XX:XX
+B>* 10.0.30.0/24 [20/0] is directly connected, neno (vrf neno), weight 1, XX:XX:XX
O>* 10.0.40.0/24 [110/20] via 10.0.20.2, r1-eth1, weight 1, XX:XX:XX
diff --git a/tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-default.txt b/tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-default.txt
index 70ae987894..d7d31434c6 100644
--- a/tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-default.txt
+++ b/tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-default.txt
@@ -9,4 +9,4 @@ O 10.0.20.0/24 [110/10] is directly connected, r2-eth1, weight 1, XX:XX:XX
C>* 10.0.20.0/24 is directly connected, r2-eth1, XX:XX:XX
L>* 10.0.20.2/32 is directly connected, r2-eth1, XX:XX:XX
O>* 10.0.30.0/24 [110/20] via 10.0.20.1, r2-eth1, weight 1, XX:XX:XX
-B>* 10.0.40.0/24 [20/0] is directly connected, r2-eth2 (vrf ray), weight 1, XX:XX:XX
+B>* 10.0.40.0/24 [20/0] is directly connected, ray (vrf ray), weight 1, XX:XX:XX
diff --git a/tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-ray.txt b/tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-ray.txt
index 1495c88936..6ab1bb8f92 100644
--- a/tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-ray.txt
+++ b/tests/topotests/ospf_multi_vrf_bgp_route_leak/r2/zebra-vrf-ray.txt
@@ -1,9 +1,9 @@
VRF ray:
B 10.0.1.0/24 [20/20] via 10.0.20.1, r2-eth1 (vrf default) inactive, weight 1, XX:XX:XX
-B 10.0.2.0/24 [20/0] is directly connected, r2-eth0 (vrf default) inactive, weight 1, XX:XX:XX
+B 10.0.2.0/24 [20/0] is directly connected, lo (vrf default) inactive, weight 1, XX:XX:XX
B>* 10.0.3.0/24 [20/20] via 10.0.20.1, r2-eth1 (vrf default), weight 1, XX:XX:XX
O>* 10.0.4.0/24 [110/20] via 10.0.40.4, r2-eth2, weight 1, XX:XX:XX
-B 10.0.20.0/24 [20/0] is directly connected, r2-eth1 (vrf default) inactive, weight 1, XX:XX:XX
+B 10.0.20.0/24 [20/0] is directly connected, lo (vrf default) inactive, weight 1, XX:XX:XX
B>* 10.0.30.0/24 [20/20] via 10.0.20.1, r2-eth1 (vrf default), weight 1, XX:XX:XX
O 10.0.40.0/24 [110/10] is directly connected, r2-eth2, weight 1, XX:XX:XX
C>* 10.0.40.0/24 is directly connected, r2-eth2, XX:XX:XX
diff --git a/tests/topotests/ospfapi/test_ospf_clientapi.py b/tests/topotests/ospfapi/test_ospf_clientapi.py
index 41c18df7d3..49dd34d650 100644
--- a/tests/topotests/ospfapi/test_ospf_clientapi.py
+++ b/tests/topotests/ospfapi/test_ospf_clientapi.py
@@ -277,7 +277,9 @@ def _test_add_data(tgen, apibin):
"linkStateId": "230.0.0.2",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000001",
- "opaqueData": "00000202",
+ "opaqueValues": {
+ "opaqueData": "00000202"
+ }
},
],
}
@@ -327,7 +329,9 @@ def _test_add_data(tgen, apibin):
"linkStateId": "231.0.0.1",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000001",
- "opaqueData": "00010101",
+ "opaqueValues": {
+ "opaqueData": "00010101",
+ }
},
],
}
@@ -376,7 +380,9 @@ def _test_add_data(tgen, apibin):
"linkStateId": "232.0.0.3",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000001",
- "opaqueData": "deadbeaf01234567",
+ "opaqueValues": {
+ "opaqueData": "deadbeaf01234567",
+ }
},
]
}
@@ -427,7 +433,9 @@ def _test_add_data(tgen, apibin):
"linkStateId": "232.0.0.3",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000002",
- "opaqueData": "ebadf00d",
+ "opaqueValues": {
+ "opaqueData": "ebadf00d",
+ }
},
]
}
@@ -574,7 +582,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "76bf",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "230.0.0.2",
@@ -583,7 +591,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "8aa2",
"length": 24,
"opaqueId": 2,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
]
}
@@ -599,7 +607,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5bd8",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "231.0.0.2",
@@ -607,7 +615,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "7690",
"length": 28,
- "opaqueDataLength": 8,
+ "opaqueLength": 8,
},
],
},
@@ -621,7 +629,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5ed5",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "232.0.0.2",
@@ -629,7 +637,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "d9bd",
"length": 24,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
],
},
@@ -734,7 +742,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "76bf",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "230.0.0.2",
@@ -744,7 +752,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "8aa2",
"length": 24,
"opaqueId": 2,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
]
}
@@ -760,7 +768,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5bd8",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"lsaAge": 3600,
@@ -770,7 +778,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "4fe2",
# data removed
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
],
},
@@ -785,7 +793,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5ed5",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "232.0.0.2",
@@ -793,7 +801,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "d9bd",
"length": 24,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
],
},
@@ -827,7 +835,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "76bf",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "230.0.0.2",
@@ -837,7 +845,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "8aa2",
"length": 24,
"opaqueId": 2,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
]
}
@@ -854,7 +862,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5bd8",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"lsaAge": 3600,
@@ -864,7 +872,7 @@ def _test_opaque_add_del(tgen, apibin):
"checksum": "4fe2",
# data removed
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
],
},
@@ -879,7 +887,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "5ed5",
"length": 20,
- "opaqueDataLength": 0,
+ "opaqueLength": 0,
},
{
"linkStateId": "232.0.0.2",
@@ -888,7 +896,7 @@ def _test_opaque_add_del(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "d9bd",
"length": 24,
- "opaqueDataLength": 4,
+ "opaqueLength": 4,
},
],
},
@@ -1044,7 +1052,7 @@ def _test_opaque_add_restart_add(tgen, apibin):
"lsaSeqNumber": "80000001",
"checksum": "b07a",
"length": 28,
- "opaqueDataLength": 8,
+ "opaqueLength": 8,
},
],
},
@@ -1100,7 +1108,7 @@ def _test_opaque_add_restart_add(tgen, apibin):
"lsaSeqNumber": "80000003",
"checksum": "cb27",
"length": 28,
- "opaqueDataLength": 8,
+ "opaqueLength": 8,
},
],
},
@@ -1655,7 +1663,9 @@ def _test_opaque_link_local_lsa_crash(tgen, apibin):
"linkStateId": "230.0.0.1",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000001",
- "opaqueData": "feedaceedeadbeef",
+ "opaqueValues": {
+ "opaqueData": "feedaceedeadbeef",
+ }
},
],
}
@@ -1684,7 +1694,9 @@ def _test_opaque_link_local_lsa_crash(tgen, apibin):
"linkStateId": "230.0.0.1",
"advertisingRouter": "1.0.0.0",
"lsaSeqNumber": "80000001",
- "opaqueData": "feedaceecafebeef",
+ "opaqueValues": {
+ "opaqueData": "feedaceecafebeef",
+ }
},
],
}
diff --git a/tests/topotests/static_vrf/r1/frr.conf b/tests/topotests/static_vrf/r1/frr.conf
new file mode 100644
index 0000000000..bb373b962a
--- /dev/null
+++ b/tests/topotests/static_vrf/r1/frr.conf
@@ -0,0 +1,18 @@
+interface r1-eth0 vrf red
+ ip address 192.0.2.1/23
+exit
+
+interface r1-eth1 vrf blue
+ ip address 192.0.2.129/24
+exit
+
+ip route 198.51.100.1/32 192.0.2.2 nexthop-vrf red
+ip route 198.51.100.1/32 192.0.2.130 nexthop-vrf blue
+ip route 198.51.100.2/32 r1-eth0 nexthop-vrf red
+ip route 198.51.100.2/32 r1-eth1 nexthop-vrf blue
+
+ip route 203.0.113.1/32 192.0.2.130 vrf red nexthop-vrf blue
+ip route 203.0.113.2/32 r1-eth1 vrf red nexthop-vrf blue
+
+ip route 203.0.113.129/32 192.0.2.2 vrf blue nexthop-vrf red
+ip route 203.0.113.130/32 r1-eth0 vrf blue nexthop-vrf red
diff --git a/tests/topotests/static_vrf/test_static_vrf.py b/tests/topotests/static_vrf/test_static_vrf.py
new file mode 100644
index 0000000000..97c0800133
--- /dev/null
+++ b/tests/topotests/static_vrf/test_static_vrf.py
@@ -0,0 +1,126 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 eval: (blacken-mode 1) -*-
+# SPDX-License-Identifier: ISC
+#
+# Copyright (c) 2024 NFWare Inc.
+#
+# noqa: E501
+#
+"""
+Test static route functionality
+"""
+
+import ipaddress
+
+import pytest
+from lib.topogen import Topogen
+from lib.common_config import retry
+
+pytestmark = [pytest.mark.staticd, pytest.mark.mgmtd]
+
+
+@pytest.fixture(scope="module")
+def tgen(request):
+ "Setup/Teardown the environment and provide tgen argument to tests"
+
+ topodef = {"s1": ("r1",), "s2": ("r1",)}
+
+ tgen = Topogen(topodef, request.module.__name__)
+ tgen.start_topology()
+
+ router_list = tgen.routers()
+ for rname, router in router_list.items():
+ # Setup VRF red
+ router.net.add_l3vrf("red", 10)
+ router.net.attach_iface_to_l3vrf(rname + "-eth0", "red")
+ # Setup VRF blue
+ router.net.add_l3vrf("blue", 20)
+ router.net.attach_iface_to_l3vrf(rname + "-eth1", "blue")
+ # Load configuration
+ router.load_frr_config("frr.conf")
+
+ tgen.start_router()
+ yield tgen
+ tgen.stop_topology()
+
+
+@retry(retry_timeout=1, initial_wait=0.1)
+def check_kernel(r1, prefix, nexthops, vrf, expected_p=True, expected_nh=True):
+ vrfstr = f" vrf {vrf}" if vrf else ""
+
+ net = ipaddress.ip_network(prefix)
+ if net.version == 6:
+ kernel = r1.run(f"ip -6 route show{vrfstr} {prefix}")
+ else:
+ kernel = r1.run(f"ip -4 route show{vrfstr} {prefix}")
+
+ if expected_p:
+ assert prefix in kernel, f"Failed to find \n'{prefix}'\n in \n'{kernel:.1920}'"
+ else:
+ assert (
+ prefix not in kernel
+ ), f"Failed found \n'{prefix}'\n in \n'{kernel:.1920}'"
+
+ if not expected_p:
+ return
+
+ for nh in nexthops:
+ if expected_nh:
+ assert f"{nh}" in kernel, f"Failed to find \n'{nh}'\n in \n'{kernel:.1920}'"
+ else:
+ assert (
+ f"{nh}" not in kernel
+ ), f"Failed found \n'{nh}'\n in \n'{kernel:.1920}'"
+
+
+def test_static_vrf(tgen):
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ r1 = tgen.gears["r1"]
+
+ # Check initial configuration
+ check_kernel(r1, "198.51.100.1", ["192.0.2.2", "192.0.2.130"], None)
+ check_kernel(r1, "198.51.100.2", ["r1-eth0", "r1-eth1"], None)
+ check_kernel(r1, "203.0.113.1", ["192.0.2.130"], "red")
+ check_kernel(r1, "203.0.113.2", ["r1-eth1"], "red")
+ check_kernel(r1, "203.0.113.129", ["192.0.2.2"], "blue")
+ check_kernel(r1, "203.0.113.130", ["r1-eth0"], "blue")
+
+ # Delete VRF red
+ r1.net.del_iface("red")
+
+ # Check that "red" nexthops are removed, "blue" nexthops are still there
+ check_kernel(r1, "198.51.100.1", ["192.0.2.2"], None, expected_nh=False)
+ check_kernel(r1, "198.51.100.1", ["192.0.2.130"], None)
+ check_kernel(r1, "198.51.100.2", ["r1-eth0"], None, expected_nh=False)
+ check_kernel(r1, "198.51.100.2", ["r1-eth1"], None)
+ check_kernel(r1, "203.0.113.129", ["192.0.2.2"], "blue", expected_p=False)
+ check_kernel(r1, "203.0.113.130", ["r1-eth0"], "blue", expected_p=False)
+
+ # Delete VRF blue
+ r1.net.del_iface("blue")
+
+ # Check that "blue" nexthops are removed
+ check_kernel(r1, "198.51.100.1", ["192.0.2.130"], None, expected_p=False)
+ check_kernel(r1, "198.51.100.2", ["r1-eth1"], None, expected_p=False)
+
+ # Add VRF red back, attach "eth0" to it
+ r1.net.add_l3vrf("red", 10)
+ r1.net.attach_iface_to_l3vrf("r1-eth0", "red")
+
+ # Check that "red" nexthops are restored
+ check_kernel(r1, "198.51.100.1", ["192.0.2.2"], None)
+ check_kernel(r1, "198.51.100.2", ["r1-eth0"], None)
+
+ # Add VRF blue back, attach "eth1" to it
+ r1.net.add_l3vrf("blue", 20)
+ r1.net.attach_iface_to_l3vrf("r1-eth1", "blue")
+
+ # Check that everything is restored
+ check_kernel(r1, "198.51.100.1", ["192.0.2.2", "192.0.2.130"], None)
+ check_kernel(r1, "198.51.100.2", ["r1-eth0", "r1-eth1"], None)
+ check_kernel(r1, "203.0.113.1", ["192.0.2.130"], "red")
+ check_kernel(r1, "203.0.113.2", ["r1-eth1"], "red")
+ check_kernel(r1, "203.0.113.129", ["192.0.2.2"], "blue")
+ check_kernel(r1, "203.0.113.130", ["r1-eth0"], "blue")