summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/topotests/bgp_aggregate_address_topo1/r1/bgp_192_168_0_1.json41
-rw-r--r--tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py19
-rw-r--r--tests/topotests/bgp_table_direct_topo1/__init__.py0
-rw-r--r--tests/topotests/bgp_table_direct_topo1/r1/frr.conf31
-rw-r--r--tests/topotests/bgp_table_direct_topo1/r2/frr.conf10
-rw-r--r--tests/topotests/bgp_table_direct_topo1/r3/frr.conf10
-rw-r--r--tests/topotests/bgp_table_direct_topo1/test_bgp_table_direct_topo1.py201
-rw-r--r--tests/topotests/bgp_table_map/r1/frr.conf22
-rw-r--r--tests/topotests/bgp_table_map/r2/frr.conf18
-rw-r--r--tests/topotests/bgp_table_map/test_bgp_table_map.py129
-rw-r--r--tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_advertised_10_125_0_2.json105
-rw-r--r--tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py38
-rw-r--r--tests/topotests/isis_srv6_topo1/test_isis_srv6_topo1.py16
-rw-r--r--tests/topotests/mgmt_tests/test_yang_mgmt.py20
-rwxr-xr-xtests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_transit_router_topo3.py6
-rw-r--r--tests/topotests/ospf_prune_next_hop/r1/frr.conf23
-rw-r--r--tests/topotests/ospf_prune_next_hop/r2/frr.conf23
-rw-r--r--tests/topotests/ospf_prune_next_hop/r3/frr.conf35
-rw-r--r--tests/topotests/ospf_prune_next_hop/r4/frr.conf34
-rw-r--r--tests/topotests/ospf_prune_next_hop/r5/frr.conf34
-rw-r--r--tests/topotests/ospf_prune_next_hop/r6/frr.conf34
-rw-r--r--tests/topotests/ospf_prune_next_hop/r7/frr.conf14
-rw-r--r--tests/topotests/ospf_prune_next_hop/r8/frr.conf14
-rw-r--r--tests/topotests/ospf_prune_next_hop/test_ospf_prune_next_hop.py343
-rw-r--r--tests/topotests/static_simple/test_static_simple.py72
25 files changed, 1249 insertions, 43 deletions
diff --git a/tests/topotests/bgp_aggregate_address_topo1/r1/bgp_192_168_0_1.json b/tests/topotests/bgp_aggregate_address_topo1/r1/bgp_192_168_0_1.json
new file mode 100644
index 0000000000..8c0da8dc92
--- /dev/null
+++ b/tests/topotests/bgp_aggregate_address_topo1/r1/bgp_192_168_0_1.json
@@ -0,0 +1,41 @@
+{
+ "prefix":"192.168.0.1/32",
+ "paths":[
+ {
+ "aspath":{
+ "string":"65001",
+ "segments":[
+ {
+ "type":"as-sequence",
+ "list":[
+ 65001
+ ]
+ }
+ ],
+ "length":1
+ },
+ "suppressed":true,
+ "origin":"IGP",
+ "metric":10,
+ "valid":true,
+ "bestpath":{
+ "overall":true,
+ "selectionReason":"First path received"
+ },
+ "nexthops":[
+ {
+ "ip":"10.0.0.2",
+ "afi":"ipv4",
+ "metric":0,
+ "accessible":true,
+ "used":true
+ }
+ ],
+ "peer":{
+ "peerId":"10.0.0.2",
+ "routerId":"10.254.254.3",
+ "type":"external"
+ }
+ }
+ ]
+}
diff --git a/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py b/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py
index 370d01e525..a0a1027c98 100644
--- a/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py
+++ b/tests/topotests/bgp_aggregate_address_topo1/test_bgp_aggregate_address_topo1.py
@@ -13,6 +13,7 @@
Test BGP aggregate address features.
"""
+import json
import os
import sys
import pytest
@@ -265,6 +266,24 @@ match ip address acl-sup-three
)
+def test_check_bgp_attribute():
+ "Dump the suppressed attribute of the 192.168.0.1/32 prefix in r1."
+ tgen = get_topogen()
+
+ logger.info("Test that the BGP path to 192.168.0.1 is as expected.")
+ expected = json.loads(open("{}/r1/bgp_192_168_0_1.json".format(CWD)).read())
+
+ test_func = functools.partial(
+ topotest.router_json_cmp,
+ tgen.gears["r1"],
+ "show bgp ipv4 192.168.0.1/32 json",
+ expected,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
+ assertmsg = '"r1" BGP 192.168.0.1 route output failed'
+ assert result is None, assertmsg
+
+
def test_memory_leak():
"Run the memory leak test and report results."
tgen = get_topogen()
diff --git a/tests/topotests/bgp_table_direct_topo1/__init__.py b/tests/topotests/bgp_table_direct_topo1/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/topotests/bgp_table_direct_topo1/__init__.py
diff --git a/tests/topotests/bgp_table_direct_topo1/r1/frr.conf b/tests/topotests/bgp_table_direct_topo1/r1/frr.conf
new file mode 100644
index 0000000000..c45e3456a4
--- /dev/null
+++ b/tests/topotests/bgp_table_direct_topo1/r1/frr.conf
@@ -0,0 +1,31 @@
+log commands
+!
+debug bgp zebra
+debug zebra events
+!
+ip route 10.254.254.1/32 lo table 2000
+ip route 10.254.254.2/32 lo table 2000
+ip route 10.254.254.3/32 lo table 2000
+!
+interface r1-eth0
+ ip address 192.168.10.1/24
+!
+interface r1-eth1 vrf blue
+ ip address 192.168.20.1/24
+!
+router bgp 65001
+ no bgp ebgp-requires-policy
+ no bgp network import-check
+ neighbor 192.168.10.2 remote-as external
+ address-family ipv4 unicast
+ redistribute table-direct 2000
+ exit-address-family
+!
+router bgp 65001 vrf blue
+ no bgp ebgp-requires-policy
+ no bgp network import-check
+ neighbor 192.168.20.2 remote-as external
+ address-family ipv4 unicast
+ redistribute table-direct 2000
+ exit-address-family
+! \ No newline at end of file
diff --git a/tests/topotests/bgp_table_direct_topo1/r2/frr.conf b/tests/topotests/bgp_table_direct_topo1/r2/frr.conf
new file mode 100644
index 0000000000..04787be0b3
--- /dev/null
+++ b/tests/topotests/bgp_table_direct_topo1/r2/frr.conf
@@ -0,0 +1,10 @@
+log commands
+!
+interface r2-eth0
+ ip address 192.168.10.2/24
+!
+router bgp 65002
+ no bgp ebgp-requires-policy
+ no bgp network import-check
+ neighbor 192.168.10.1 remote-as external
+! \ No newline at end of file
diff --git a/tests/topotests/bgp_table_direct_topo1/r3/frr.conf b/tests/topotests/bgp_table_direct_topo1/r3/frr.conf
new file mode 100644
index 0000000000..2530b28bfd
--- /dev/null
+++ b/tests/topotests/bgp_table_direct_topo1/r3/frr.conf
@@ -0,0 +1,10 @@
+log commands
+!
+interface r3-eth0
+ ip address 192.168.20.2/24
+!
+router bgp 65003
+ no bgp ebgp-requires-policy
+ no bgp network import-check
+ neighbor 192.168.20.1 remote-as external
+! \ No newline at end of file
diff --git a/tests/topotests/bgp_table_direct_topo1/test_bgp_table_direct_topo1.py b/tests/topotests/bgp_table_direct_topo1/test_bgp_table_direct_topo1.py
new file mode 100644
index 0000000000..70257be3e7
--- /dev/null
+++ b/tests/topotests/bgp_table_direct_topo1/test_bgp_table_direct_topo1.py
@@ -0,0 +1,201 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
+
+#
+# test_bgp_table_direct_topo1.py
+# Part of NetDEF Topology Tests
+#
+# Copyright (c) 2025 by
+# Network Device Education Foundation, Inc. ("NetDEF")
+#
+
+"""
+test_bgp_table_direct_topo1.py: Test the FRR PIM MSDP peer.
+"""
+
+import os
+import sys
+import json
+from functools import partial
+import re
+import pytest
+
+# Save the Current Working Directory to find configuration files.
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
+# pylint: disable=C0413
+# Import topogen and topotest helpers
+from lib import topotest
+
+# Required to instantiate the topology builder class.
+from lib.topogen import Topogen, TopoRouter, get_topogen
+from lib.topolog import logger
+
+from lib.pim import McastTesterHelper
+
+pytestmark = [pytest.mark.bgpd, pytest.mark.pimd]
+
+app_helper = McastTesterHelper()
+
+
+def build_topo(tgen):
+ """
+ +----+ +----+
+ | r1 | <-> | r2 |
+ +----+ +----+
+ |
+ | +----+
+ --------| r3 |
+ +----+
+ """
+
+ # Create 3 routers
+ for routern in range(1, 4):
+ tgen.add_router(f"r{routern}")
+
+ switch = tgen.add_switch("s1")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+
+ switch = tgen.add_switch("s2")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r3"])
+
+
+def setup_module(mod):
+ "Sets up the pytest environment"
+ tgen = Topogen(build_topo, mod.__name__)
+ tgen.start_topology()
+
+ router_list = tgen.routers()
+ for _, router in router_list.items():
+ router.load_frr_config(os.path.join(CWD, f"{router.name}/frr.conf"))
+
+ tgen.gears["r1"].run("ip link add blue type vrf table 10")
+ tgen.gears["r1"].run("ip link set blue up")
+ tgen.gears["r1"].run("ip link set r1-eth1 master blue")
+
+ # Initialize all routers.
+ tgen.start_router()
+
+ app_helper.init(tgen)
+
+
+def teardown_module():
+ "Teardown the pytest environment"
+ tgen = get_topogen()
+ app_helper.cleanup()
+ tgen.stop_topology()
+
+
+def expect_bgp_route(router, iptype, route, missing=False):
+ "Wait until route is present on RIB for protocol."
+ if missing:
+ logger.info("waiting route {} go missing in {}".format(route, router))
+ else:
+ logger.info("waiting route {} in {}".format(route, router))
+
+ tgen = get_topogen()
+ expected_output = {route: [{"protocol": "bgp"}]}
+ wait_time = 130
+ if missing:
+ expected_output = {route: None}
+ wait_time = 5
+
+ test_func = partial(
+ topotest.router_json_cmp,
+ tgen.gears[router],
+ "show {} route json".format(iptype),
+ expected_output
+ )
+
+ _, result = topotest.run_and_expect(test_func, None, count=130, wait=1)
+ assertmsg = f'"{router}" convergence failure'
+ assert result is None, assertmsg
+
+
+def test_bgp_convergence():
+ "Wait for BGP protocol convergence"
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ logger.info("waiting for protocols to converge")
+
+ # Wait for R2
+ expect_bgp_route("r2", "ip", "10.254.254.1/32")
+ expect_bgp_route("r2", "ip", "10.254.254.2/32")
+ expect_bgp_route("r2", "ip", "10.254.254.3/32")
+
+ # Wait for R3
+ expect_bgp_route("r3", "ip", "10.254.254.1/32")
+ expect_bgp_route("r3", "ip", "10.254.254.2/32")
+ expect_bgp_route("r3", "ip", "10.254.254.3/32")
+
+
+def test_route_change_convergence():
+ "Change routes in table 2000 to test zebra redistribution."
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ tgen.gears["r1"].vtysh_cmd("""
+ configure terminal
+ no ip route 10.254.254.2/32 lo table 2000
+ ip route 10.254.254.10/32 lo table 2000
+ """)
+
+ # Check R2
+ expect_bgp_route("r2", "ip", "10.254.254.2/32", missing=True)
+ expect_bgp_route("r2", "ip", "10.254.254.10/32")
+
+ # Check R3
+ expect_bgp_route("r3", "ip", "10.254.254.2/32", missing=True)
+ expect_bgp_route("r3", "ip", "10.254.254.10/32")
+
+
+def test_configuration_removal_convergence():
+ "Remove table direct configuration and check if routes went missing."
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ tgen.gears["r1"].vtysh_cmd("""
+ configure terminal
+ router bgp 65001
+ address-family ipv4 unicast
+ no redistribute table-direct 2000
+ exit-address-family
+ exit
+
+ router bgp 65001 vrf blue
+ address-family ipv4 unicast
+ no redistribute table-direct 2000
+ exit-address-family
+ exit
+ """)
+
+ # Check R2
+ expect_bgp_route("r2", "ip", "10.254.254.1/32", missing=True)
+ expect_bgp_route("r2", "ip", "10.254.254.3/32", missing=True)
+ expect_bgp_route("r2", "ip", "10.254.254.10/32", missing=True)
+
+ # Check R3
+ expect_bgp_route("r3", "ip", "10.254.254.1/32", missing=True)
+ expect_bgp_route("r3", "ip", "10.254.254.3/32", missing=True)
+ expect_bgp_route("r3", "ip", "10.254.254.10/32", missing=True)
+
+
+def test_memory_leak():
+ "Run the memory leak test and report results."
+ tgen = get_topogen()
+ if not tgen.is_memleak_enabled():
+ pytest.skip("Memory leak test/report is disabled")
+
+ tgen.report_memory_leaks()
+
+
+if __name__ == "__main__":
+ args = ["-s"] + sys.argv[1:]
+ sys.exit(pytest.main(args))
diff --git a/tests/topotests/bgp_table_map/r1/frr.conf b/tests/topotests/bgp_table_map/r1/frr.conf
new file mode 100644
index 0000000000..f74440c384
--- /dev/null
+++ b/tests/topotests/bgp_table_map/r1/frr.conf
@@ -0,0 +1,22 @@
+!
+int r1-eth0
+ ip address 10.255.0.1/24
+!
+access-list AccList seq 5 permit 10.0.0.1/32
+!
+route-map TableMap permit 10
+ match ip address AccList
+exit
+!
+router bgp 65001
+ bgp router-id 10.255.0.1
+ no bgp ebgp-requires-policy
+ neighbor 10.255.0.2 remote-as external
+ neighbor 10.255.0.2 timers 1 3
+ neighbor 10.255.0.2 timers connect 1
+ !
+ address-family ipv4 unicast
+ table-map TableMap
+ exit-address-family
+exit
+!
diff --git a/tests/topotests/bgp_table_map/r2/frr.conf b/tests/topotests/bgp_table_map/r2/frr.conf
new file mode 100644
index 0000000000..4523fe49ea
--- /dev/null
+++ b/tests/topotests/bgp_table_map/r2/frr.conf
@@ -0,0 +1,18 @@
+!
+int r2-eth0
+ ip address 10.255.0.2/24
+!
+router bgp 65002
+ bgp router-id 10.255.0.2
+ no bgp ebgp-requires-policy
+ no bgp network import-check
+ neighbor 10.255.0.1 remote-as external
+ neighbor 10.255.0.1 timers 1 3
+ neighbor 10.255.0.1 timers connect 1
+ !
+ address-family ipv4 unicast
+ network 10.0.0.1/32
+ network 10.0.0.2/32
+ exit-address-family
+exit
+!
diff --git a/tests/topotests/bgp_table_map/test_bgp_table_map.py b/tests/topotests/bgp_table_map/test_bgp_table_map.py
new file mode 100644
index 0000000000..b10680f741
--- /dev/null
+++ b/tests/topotests/bgp_table_map/test_bgp_table_map.py
@@ -0,0 +1,129 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
+
+import functools, json, os, pytest, re, sys
+
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
+from lib import topotest
+from lib.topogen import Topogen, get_topogen
+
+pytestmark = [pytest.mark.bgpd]
+
+
+def setup_module(mod):
+ topodef = {"s1": ("r1", "r2")}
+ tgen = Topogen(topodef, mod.__name__)
+ tgen.start_topology()
+
+ router_list = tgen.routers()
+
+ for _, (rname, router) in enumerate(router_list.items(), 1):
+ router.load_frr_config(
+ os.path.join(CWD, "{}/frr.conf".format(rname))
+ )
+
+ tgen.start_router()
+
+
+def teardown_module(mod):
+ tgen = get_topogen()
+ tgen.stop_topology()
+
+
+def test_bgp_table_map():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ r1 = tgen.gears["r1"]
+
+ def _bgp_converge():
+ output = json.loads(
+ r1.vtysh_cmd( "show bgp ipv4 unicast summary json")
+ )
+ expected = {
+ "peers": {
+ "10.255.0.2": {
+ "remoteAs": 65002,
+ "state": "Established",
+ "peerState": "OK",
+ },
+ },
+ "totalPeers": 1,
+ }
+
+ return topotest.json_cmp(output, expected)
+
+ test_func = functools.partial(
+ _bgp_converge,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=30, wait=1)
+ assert result is None, "Can't converge initial state"
+
+ def _bgp_with_table_map():
+ output = json.loads(r1.vtysh_cmd("show ip fib json"))
+ expected = {
+ "10.0.0.1/32": [],
+ "10.0.0.2/32": None,
+ }
+
+ return topotest.json_cmp(output, expected)
+
+ test_func = functools.partial(
+ _bgp_with_table_map,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
+ assert result is None, "Should contain only one of two shared networks"
+
+ #
+ # Unset table-map
+ #
+ r1.vtysh_cmd(
+ """
+ configure terminal
+ router bgp 65001
+ address-family ipv4 unicast
+ no table-map TableMap
+ """
+ )
+
+ def _bgp_without_table_map():
+ output = json.loads(r1.vtysh_cmd("show ip fib json"))
+ expected = {
+ "10.0.0.1/32": [],
+ "10.0.0.2/32": [],
+ }
+
+ return topotest.json_cmp(output, expected)
+
+ test_func = functools.partial(
+ _bgp_without_table_map,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
+ assert result is None, "Shouldn't contain both shared routes"
+
+ #
+ # Reset table-map
+ #
+ r1.vtysh_cmd(
+ """
+ configure terminal
+ router bgp 65001
+ address-family ipv4 unicast
+ table-map TableMap
+ """
+ )
+
+ test_func = functools.partial(
+ _bgp_with_table_map,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
+ assert result is None, "Should contain only one of two shared networks"
+
+
+if __name__ == "__main__":
+ args = ["-s"] + sys.argv[1:]
+ sys.exit(pytest.main(args))
diff --git a/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_advertised_10_125_0_2.json b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_advertised_10_125_0_2.json
new file mode 100644
index 0000000000..7891982653
--- /dev/null
+++ b/tests/topotests/bgp_vpnv4_noretain/r1/ipv4_vpn_routes_advertised_10_125_0_2.json
@@ -0,0 +1,105 @@
+{
+ "bgpLocalRouterId":"192.0.2.1",
+ "defaultLocPrf":100,
+ "localAS":65500,
+ "advertisedRoutes":{
+ "192.0.2.1:1":{
+ "rd":"192.0.2.1:1",
+ "10.101.0.0/24":{
+ "prefix":"10.101.0.0/24",
+ "advertisedTo":{
+ "10.125.0.2":{
+ "hostname":"r2"
+ }
+ },
+ "paths":[{
+ "aspath":{
+ "string":"Local",
+ "segments":[],
+ "length":0
+ },
+ "nhVrfName":"vrf1",
+ "announceNexthopSelf":true,
+ "origin":"incomplete",
+ "metric":0,
+ "locPrf":100,
+ "weight":32768,
+ "valid":true,
+ "sourced":true,
+ "local":true,
+ "bestpath":{
+ "overall":true,
+ "selectionReason":"First path received"
+ },
+ "extendedCommunity":{
+ "string":"RT:192.0.2.1:100"
+ },
+ "originatorId":"192.0.2.1",
+ "remoteLabel":101,
+ "nexthops":[{
+ "ip":"0.0.0.0",
+ "hostname":"r1",
+ "afi":"ipv4",
+ "metric":0,
+ "accessible":true,
+ "used":true
+ }],
+ "peer":{
+ "peerId":"0.0.0.0",
+ "routerId":"192.0.2.1"
+ }
+ }]
+ }
+ },
+ "192.0.2.1:3":{
+ "rd":"192.0.2.1:3",
+ "10.103.0.0/24":{
+ "prefix":"10.103.0.0/24",
+ "advertisedTo":{
+ "10.125.0.2":{
+ "hostname":"r2"
+ }
+ },
+ "paths":[{
+ "aspath":{
+ "string":"Local",
+ "segments":[],
+ "length":0
+ },
+ "nhVrfName":"vrf3",
+ "announceNexthopSelf":true,
+ "origin":"incomplete",
+ "metric":0,
+ "locPrf":100,
+ "weight":32768,
+ "valid":true,
+ "sourced":true,
+ "local":true,
+ "bestpath":{
+ "overall":true,
+ "selectionReason":"First path received"
+ },
+ "extendedCommunity":{
+ "string":"RT:192.0.2.1:300"
+ },
+ "originatorId":"192.0.2.1",
+ "remoteLabel":103,
+ "nexthops":[{
+ "ip":"0.0.0.0",
+ "hostname":"r1",
+ "afi":"ipv4",
+ "metric":0,
+ "accessible":true,
+ "used":true
+ }],
+ "peer":{
+ "peerId":"0.0.0.0",
+ "routerId":"192.0.2.1"
+ }
+ }]
+ }
+ }
+ },
+ "totalPrefixCounter":2,
+ "filteredPrefixCounter":0
+}
diff --git a/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py b/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py
index ee84e375fb..ada37c28c1 100644
--- a/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py
+++ b/tests/topotests/bgp_vpnv4_noretain/test_bgp_vpnv4_noretain.py
@@ -218,6 +218,29 @@ def check_show_bgp_ipv4_vpn(rname, json_file):
assert result is None, assertmsg
+def check_show_bgp_ipv4_vpn_peer_advertised_routes(rname, peer, json_file):
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+ router = tgen.gears[rname]
+
+ logger.info(
+ "Checking VPNv4 advertised routes for on {} for peer {}".format(rname, peer)
+ )
+
+ json_file = "{}/{}/{}".format(CWD, router.name, json_file)
+ expected = json.loads(open(json_file).read())
+ test_func = partial(
+ topotest.router_json_cmp,
+ router,
+ "show bgp ipv4 vpn neighbors {} advertised-routes detail json".format(peer),
+ expected,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=20, wait=1)
+ assertmsg = '"{}" JSON output mismatches'.format(router.name)
+ assert result is None, assertmsg
+
+
def check_show_bgp_vrf_ipv4(rname, json_file):
tgen = get_topogen()
if tgen.routers_have_failure():
@@ -563,6 +586,21 @@ router bgp 65500
check_show_bgp_vrf_ipv4(rname, "ipv4_vrf_all_routes_init.json")
+def test_bgp_advertised_routes_step13():
+ """
+ Dump advertised routes from r1 to r2
+ Check that the localpref attribute is set on the show command
+ """
+
+ tgen = get_topogen()
+ if tgen.routers_have_failure():
+ pytest.skip(tgen.errors)
+
+ check_show_bgp_ipv4_vpn_peer_advertised_routes(
+ "r1", "10.125.0.2", "ipv4_vpn_routes_advertised_10_125_0_2.json"
+ )
+
+
def test_memory_leak():
"Run the memory leak test and report results."
tgen = get_topogen()
diff --git a/tests/topotests/isis_srv6_topo1/test_isis_srv6_topo1.py b/tests/topotests/isis_srv6_topo1/test_isis_srv6_topo1.py
index 9c1a23f54f..d17b4702f7 100644
--- a/tests/topotests/isis_srv6_topo1/test_isis_srv6_topo1.py
+++ b/tests/topotests/isis_srv6_topo1/test_isis_srv6_topo1.py
@@ -245,7 +245,7 @@ def check_ping6(name, dest_addr, expect_connected):
if match not in output:
return "ping fail"
- match = "{} packet loss".format("0%" if expect_connected else "100%")
+ match = "{} packet loss".format(", 0%" if expect_connected else ", 100%")
logger.info("[+] check {} {} {}".format(name, dest_addr, match))
tgen = get_topogen()
func = functools.partial(_check, name, dest_addr, match)
@@ -333,7 +333,7 @@ def test_ping_step1():
# Setup encap route on rt1, decap route on rt2
tgen.gears["rt1"].vtysh_cmd(
- "sharp install seg6-routes fc00:0:9::1 nexthop-seg6 2001:db8:1::2 encap fc00:0:1:2:6:f00d:: 1"
+ "sharp install seg6-routes fc00:0:9::1 nexthop-seg6 2001:db8:1::2 encap fc00:0:2:6:f00d:: 1"
)
tgen.gears["rt6"].vtysh_cmd(
"sharp install seg6local-routes fc00:0:f00d:: nexthop-seg6local eth-dst End_DT6 254 1"
@@ -443,7 +443,8 @@ def test_ping_step2():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- check_ping6("rt1", "fc00:0:9::1", False)
+ # ping should pass because route to fc00:0:2:6:f00d:: is still valid
+ check_ping6("rt1", "fc00:0:9::1", True)
#
@@ -643,7 +644,8 @@ def test_ping_step4():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- check_ping6("rt1", "fc00:0:9::1", False)
+ # ping should pass because route to fc00:0:2:6:f00d:: is still valid
+ check_ping6("rt1", "fc00:0:9::1", True)
#
@@ -838,7 +840,8 @@ def test_ping_step6():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- check_ping6("rt1", "fc00:0:9::1", False)
+ # ping should pass because route to fc00:0:2:6:f00d:: is still valid
+ check_ping6("rt1", "fc00:0:9::1", True)
#
@@ -1033,7 +1036,8 @@ def test_ping_step8():
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
- check_ping6("rt1", "fc00:0:9::1", False)
+ # ping should pass because route to fc00:0:2:6:f00d:: is still valid
+ check_ping6("rt1", "fc00:0:9::1", True)
#
diff --git a/tests/topotests/mgmt_tests/test_yang_mgmt.py b/tests/topotests/mgmt_tests/test_yang_mgmt.py
index 52f6ba4db7..7b74eab6b7 100644
--- a/tests/topotests/mgmt_tests/test_yang_mgmt.py
+++ b/tests/topotests/mgmt_tests/test_yang_mgmt.py
@@ -181,7 +181,7 @@ def test_mgmt_commit_check(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.2/32'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/bh-type unspec",
+ "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.2/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/bh-type unspec",
"mgmt commit check",
]
}
@@ -194,7 +194,7 @@ def test_mgmt_commit_check(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.2/32'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/bh-type unspec",
+ "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.2/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/bh-type unspec",
"mgmt commit check",
]
}
@@ -245,7 +245,7 @@ def test_mgmt_commit_apply(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.20/32'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/vrf default",
+ "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.20/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/vrf default",
"mgmt commit apply",
]
}
@@ -258,7 +258,7 @@ def test_mgmt_commit_apply(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.20/32'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/vrf default",
+ "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.20/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/vrf default",
"mgmt commit apply",
]
}
@@ -298,7 +298,7 @@ def test_mgmt_commit_abort(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.3/32'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/vrf default",
+ "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.1.3/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/vrf default",
"mgmt commit abort",
]
}
@@ -350,7 +350,7 @@ def test_mgmt_delete_config(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.168.1.3/32'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/vrf default",
+ "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.168.1.3/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/vrf default",
"mgmt commit apply",
]
}
@@ -381,7 +381,7 @@ def test_mgmt_delete_config(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt delete-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.168.1.3/32'][afi-safi='frr-routing:ipv4-unicast']",
+ "mgmt delete-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.168.1.3/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']",
"mgmt commit apply",
]
}
@@ -657,7 +657,7 @@ def test_mgmt_chaos_stop_start_frr(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.11.200/32'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/bh-type unspec",
+ "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.11.200/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/bh-type unspec",
"mgmt commit apply",
]
}
@@ -689,7 +689,7 @@ def test_mgmt_chaos_stop_start_frr(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt delete-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.11.200/32'][afi-safi='frr-routing:ipv4-unicast']",
+ "mgmt delete-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.11.200/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']",
"mgmt commit apply",
]
}
@@ -733,7 +733,7 @@ def test_mgmt_chaos_kill_daemon(request):
raw_config = {
"r1": {
"raw_config": [
- "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.11.200/32'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/bh-type unspec",
+ "mgmt set-config /frr-routing:routing/control-plane-protocols/control-plane-protocol[type='frr-staticd:staticd'][name='staticd'][vrf='default']/frr-staticd:staticd/route-list[prefix='192.1.11.200/32'][src-prefix='::/0'][afi-safi='frr-routing:ipv4-unicast']/path-list[table-id='0'][distance='1']/frr-nexthops/nexthop[nh-type='blackhole'][vrf='default'][gateway=''][interface='(null)']/bh-type unspec",
"mgmt commit apply",
]
}
diff --git a/tests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_transit_router_topo3.py b/tests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_transit_router_topo3.py
index 8d91826022..a32b82c7f4 100755
--- a/tests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_transit_router_topo3.py
+++ b/tests/topotests/multicast_pim_dr_nondr_test/test_pim_dr_nondr_with_transit_router_topo3.py
@@ -638,12 +638,6 @@ def pre_config_for_source_dr_tests(
"interfaceName": "r5-r4-eth1",
"weight": 1,
},
- {
- "ip": "10.0.3.1",
- "afi": "ipv4",
- "interfaceName": "r5-r4-eth1",
- "weight": 1,
- },
],
}
]
diff --git a/tests/topotests/ospf_prune_next_hop/r1/frr.conf b/tests/topotests/ospf_prune_next_hop/r1/frr.conf
new file mode 100644
index 0000000000..130872e8d0
--- /dev/null
+++ b/tests/topotests/ospf_prune_next_hop/r1/frr.conf
@@ -0,0 +1,23 @@
+!
+hostname r1
+ip forwarding
+!
+interface r1-eth0
+ ip address 10.1.1.1/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r1-eth1
+ ip address 10.1.2.1/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+!
+!
+router ospf
+ ospf router-id 1.1.1.1
+ distance 20
+ network 10.1.1.0/24 area 0
+ network 10.1.2.0/24 area 0
diff --git a/tests/topotests/ospf_prune_next_hop/r2/frr.conf b/tests/topotests/ospf_prune_next_hop/r2/frr.conf
new file mode 100644
index 0000000000..4268aea857
--- /dev/null
+++ b/tests/topotests/ospf_prune_next_hop/r2/frr.conf
@@ -0,0 +1,23 @@
+!
+hostname r2
+ip forwarding
+!
+interface r2-eth0
+ ip address 10.1.1.2/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r2-eth1
+ ip address 10.1.2.1/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+!
+!
+router ospf
+ ospf router-id 2.2.2.2
+ distance 20
+ network 10.1.1.0/24 area 0
+ network 10.1.2.0/24 area 0
diff --git a/tests/topotests/ospf_prune_next_hop/r3/frr.conf b/tests/topotests/ospf_prune_next_hop/r3/frr.conf
new file mode 100644
index 0000000000..21d6506d7c
--- /dev/null
+++ b/tests/topotests/ospf_prune_next_hop/r3/frr.conf
@@ -0,0 +1,35 @@
+!
+hostname r3
+ip forwarding
+!
+interface r3-eth0
+ ip address 20.1.3.3/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r3-eth1
+ ip address 10.1.3.3/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r3-eth2
+ ip address 10.1.2.3/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+!
+!
+router ospf
+ ospf router-id 3.3.3.3
+ distance 20
+ network 10.1.2.0/24 area 0
+ network 10.1.3.0/24 area 0
+ network 20.1.3.0/24 area 1
+ area 1 range 20.1.0.0/16
+ redistribute static
+!
+!
+ip route 100.100.100.100/32 Null0
diff --git a/tests/topotests/ospf_prune_next_hop/r4/frr.conf b/tests/topotests/ospf_prune_next_hop/r4/frr.conf
new file mode 100644
index 0000000000..e66e93e20c
--- /dev/null
+++ b/tests/topotests/ospf_prune_next_hop/r4/frr.conf
@@ -0,0 +1,34 @@
+!
+hostname r4
+ip forwarding
+!
+interface r4-eth0
+ ip address 20.1.4.4/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r4-eth1
+ ip address 10.1.3.4/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r4-eth2
+ ip address 10.1.2.4/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+!
+router ospf
+ ospf router-id 4.4.4.4
+ distance 20
+ network 10.1.2.0/24 area 0
+ network 10.1.3.0/24 area 0
+ network 20.1.4.0/24 area 1
+ area 1 range 20.1.0.0/16
+ redistribute static
+!
+!
+ip route 100.100.100.100/32 Null0
diff --git a/tests/topotests/ospf_prune_next_hop/r5/frr.conf b/tests/topotests/ospf_prune_next_hop/r5/frr.conf
new file mode 100644
index 0000000000..2d1dad9925
--- /dev/null
+++ b/tests/topotests/ospf_prune_next_hop/r5/frr.conf
@@ -0,0 +1,34 @@
+!
+hostname r5
+ip forwarding
+!
+interface r5-eth0
+ ip address 20.1.5.5/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r5-eth1
+ ip address 10.1.3.5/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r5-eth2
+ ip address 10.1.2.5/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+!
+router ospf
+ ospf router-id 5.5.5.5
+ distance 20
+ network 10.1.2.0/24 area 0
+ network 10.1.3.0/24 area 0
+ network 20.1.5.0/24 area 1
+ area 1 range 20.1.0.0/16
+ redistribute static
+!
+!
+ip route 100.100.100.100/32 Null0
diff --git a/tests/topotests/ospf_prune_next_hop/r6/frr.conf b/tests/topotests/ospf_prune_next_hop/r6/frr.conf
new file mode 100644
index 0000000000..f343ee7c35
--- /dev/null
+++ b/tests/topotests/ospf_prune_next_hop/r6/frr.conf
@@ -0,0 +1,34 @@
+!
+hostname r6
+ip forwarding
+!
+interface r6-eth0
+ ip address 20.1.6.6/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r6-eth1
+ ip address 10.1.3.6/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+interface r6-eth2
+ ip address 10.1.2.6/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+!
+router ospf
+ ospf router-id 6.6.6.6
+ distance 20
+ network 10.1.2.0/24 area 0
+ network 10.1.3.0/24 area 0
+ network 20.1.6.0/24 area 1
+ area 1 range 20.1.0.0/16
+ redistribute static
+!
+!
+ip route 100.100.100.100/32 Null0
diff --git a/tests/topotests/ospf_prune_next_hop/r7/frr.conf b/tests/topotests/ospf_prune_next_hop/r7/frr.conf
new file mode 100644
index 0000000000..1eeb88c9d0
--- /dev/null
+++ b/tests/topotests/ospf_prune_next_hop/r7/frr.conf
@@ -0,0 +1,14 @@
+!
+hostname r7
+ip forwarding
+!
+interface r7-eth0
+ ip address 10.1.3.7/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+router ospf
+ ospf router-id 7.7.7.7
+ distance 20
+ network 10.1.3.0/24 area 0
diff --git a/tests/topotests/ospf_prune_next_hop/r8/frr.conf b/tests/topotests/ospf_prune_next_hop/r8/frr.conf
new file mode 100644
index 0000000000..d8facbc01f
--- /dev/null
+++ b/tests/topotests/ospf_prune_next_hop/r8/frr.conf
@@ -0,0 +1,14 @@
+!
+hostname r8
+ip forwarding
+!
+interface r8-eth0
+ ip address 10.1.3.8/24
+ ip ospf network broadcast
+ ip ospf hello-interval 1
+ ip ospf dead-interval 10
+!
+router ospf
+ ospf router-id 8.8.8.8
+ distance 20
+ network 10.1.3.0/24 area 0
diff --git a/tests/topotests/ospf_prune_next_hop/test_ospf_prune_next_hop.py b/tests/topotests/ospf_prune_next_hop/test_ospf_prune_next_hop.py
new file mode 100644
index 0000000000..88aa6b2e36
--- /dev/null
+++ b/tests/topotests/ospf_prune_next_hop/test_ospf_prune_next_hop.py
@@ -0,0 +1,343 @@
+#!/usr/bin/env python
+# SPDX-License-Identifier: ISC
+
+#
+# test_ospf_prune_next_hop
+#
+# Copyright (c) 2025 LabN Consulting
+# Acee Lindem
+#
+
+import os
+import sys
+from functools import partial
+import pytest
+
+# pylint: disable=C0413
+# Import topogen and topotest helpers
+from lib import topotest
+from lib.topogen import Topogen, get_topogen
+from lib.topolog import logger
+
+from lib.common_config import (
+ step,
+)
+
+
+"""
+test_ospf_metric_propagation.py: Test OSPF/BGP metric propagation
+"""
+
+TOPOLOGY = """
+ 20.1.3.0 20.1.4.0 20.1.5.0 20.1.6.0
+ eth0 | .3 eth0 | .4 eth0 | .5 eth0 | .6
+ +--+-+ +--+-+ +--+-+ +--+-+
+10.1 3.0 | R3 | | R4 | | R5 | | R6 |
+ +-----+ | | |eth1 | |eth1 | | 10.1.3.0/24
+ | | | | +---- | |--- + -+---+
+ | +--+-+ +--+-+ +--+-+ +--+-+ |
+ | eth2 | .3 eth2 | .4 eth2 | .5 eth2 | |
+eth0| | | | | | eth0
+ +--+--+ ++-------+ Switch Network +---------++ +--+---+
+ | R7 | | 10.1.2.0/24 | | R8 |
+ +-----+ +------------------------------------+ +------+
+ eth1 | .2
+ +--+--+
+ | R2 |
+ +--+--+
+ eth0 | .2
+ 10.1.1.0/24 |
+ eth0 | .1
+ +--+--+
+ | R1 |
+ +-----+
+
+"""
+
+# Save the Current Working Directory to find configuration files.
+CWD = os.path.dirname(os.path.realpath(__file__))
+sys.path.append(os.path.join(CWD, "../"))
+
+# Required to instantiate the topology builder class.
+
+pytestmark = [pytest.mark.ospfd, pytest.mark.bgpd]
+
+
+def build_topo(tgen):
+ "Build function"
+
+ # Create 8 routers
+ tgen.add_router("r1")
+ tgen.add_router("r2")
+ tgen.add_router("r3")
+ tgen.add_router("r4")
+ tgen.add_router("r5")
+ tgen.add_router("r6")
+ tgen.add_router("r7")
+ tgen.add_router("r8")
+
+ # Interconect router 1, 2 (0)
+ switch = tgen.add_switch("s1-1-2")
+ switch.add_link(tgen.gears["r1"])
+ switch.add_link(tgen.gears["r2"])
+
+ # Add standalone networks to router 3
+ switch = tgen.add_switch("s2-3")
+ switch.add_link(tgen.gears["r3"])
+
+ # Add standalone network to router 4
+ switch = tgen.add_switch("s3-4")
+ switch.add_link(tgen.gears["r4"])
+
+ # Add standalone network to router 5
+ switch = tgen.add_switch("s4-5")
+ switch.add_link(tgen.gears["r5"])
+
+ # Add standalone network to router 6
+ switch = tgen.add_switch("s5-6")
+ switch.add_link(tgen.gears["r6"])
+
+ # Interconect routers 3, 4, 5, and 6
+ switch = tgen.add_switch("s6-3")
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r7"])
+ switch = tgen.add_switch("s7-4")
+ switch.add_link(tgen.gears["r4"])
+ switch = tgen.add_switch("s8-5")
+ switch.add_link(tgen.gears["r5"])
+ switch = tgen.add_switch("s9-6")
+ switch.add_link(tgen.gears["r6"])
+ switch.add_link(tgen.gears["r8"])
+
+ # Interconect routers 2, 3, 4, 5, and 6
+ switch = tgen.add_switch("s10-lan")
+ switch.add_link(tgen.gears["r2"])
+ switch.add_link(tgen.gears["r3"])
+ switch.add_link(tgen.gears["r4"])
+ switch.add_link(tgen.gears["r5"])
+ switch.add_link(tgen.gears["r6"])
+
+
+def setup_module(mod):
+ logger.info("OSPF Prune Next Hops:\n {}".format(TOPOLOGY))
+
+ tgen = Topogen(build_topo, mod.__name__)
+ tgen.start_topology()
+
+ # Starting Routers
+ router_list = tgen.routers()
+
+ for rname, router in router_list.items():
+ logger.info("Loading router %s" % rname)
+ router.load_frr_config(os.path.join(CWD, "{}/frr.conf".format(rname)))
+
+ # Initialize all routers.
+ tgen.start_router()
+
+
+def teardown_module():
+ "Teardown the pytest environment"
+ tgen = get_topogen()
+ tgen.stop_topology()
+
+
+def test_intra_area_route_prune():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip("Skipped because of router(s) failure")
+
+ step("Test OSPF intra-area route 10.1.3.0/24 duplicate nexthops already pruned")
+ # Verify OSPF route 10.1.3.0/24 nexthops pruned already.
+ r1 = tgen.gears["r1"]
+ input_dict = {
+ "10.1.3.0/24": {
+ "routeType": "N",
+ "transit": True,
+ "cost": 30,
+ "area": "0.0.0.0",
+ "nexthops": [
+ {"ip": "10.1.1.2", "via": "r1-eth0", "advertisedRouter": "8.8.8.8"}
+ ],
+ }
+ }
+ test_func = partial(
+ topotest.router_json_cmp, r1, "show ip ospf route detail json", input_dict
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
+ assertmsg = "OSPF Intra-Area route 10.1.3.0/24 mismatch on router r1"
+ assert result is None, assertmsg
+
+ step("Test IP route 10.1.3.0/24 installed")
+ input_dict = {
+ "10.1.3.0/24": [
+ {
+ "prefix": "10.1.3.0/24",
+ "prefixLen": 24,
+ "protocol": "ospf",
+ "vrfName": "default",
+ "distance": 20,
+ "metric": 30,
+ "installed": True,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "ip": "10.1.1.2",
+ "afi": "ipv4",
+ "interfaceName": "r1-eth0",
+ "active": True,
+ "weight": 1,
+ }
+ ],
+ }
+ ]
+ }
+ test_func = partial(
+ topotest.router_json_cmp, r1, "show ip route 10.1.3.0/24 json", input_dict
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
+ assertmsg = "IP route 10.1.3.0/24 mismatch on router r1"
+ assert result is None, assertmsg
+
+
+def test_inter_area_route_prune():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip("Skipped because of router(s) failure")
+
+ step("Test OSPF inter-area route 20.1.0.0/16 duplicate nexthops installed")
+ # Verify OSPF route 20.1.0.0/16 duplication nexthops
+ r1 = tgen.gears["r1"]
+ input_dict = {
+ "20.1.0.0/16": {
+ "routeType": "N IA",
+ "cost": 30,
+ "area": "0.0.0.0",
+ "nexthops": [
+ {"ip": "10.1.1.2", "via": "r1-eth0", "advertisedRouter": "3.3.3.3"},
+ {"ip": "10.1.1.2", "via": "r1-eth0", "advertisedRouter": "4.4.4.4"},
+ {"ip": "10.1.1.2", "via": "r1-eth0", "advertisedRouter": "5.5.5.5"},
+ {"ip": "10.1.1.2", "via": "r1-eth0", "advertisedRouter": "6.6.6.6"},
+ ],
+ }
+ }
+ test_func = partial(
+ topotest.router_json_cmp, r1, "show ip ospf route detail json", input_dict
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
+ assertmsg = "OSPF Inter-Area route 20.1.0.0/16 mismatch on router r1"
+ assert result is None, assertmsg
+
+ step("Test IP route 10.1.3.0/24 installed with pruned next-hops")
+ input_dict = {
+ "20.1.0.0/16": [
+ {
+ "prefix": "20.1.0.0/16",
+ "prefixLen": 16,
+ "protocol": "ospf",
+ "vrfName": "default",
+ "distance": 20,
+ "metric": 30,
+ "installed": True,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "ip": "10.1.1.2",
+ "afi": "ipv4",
+ "interfaceName": "r1-eth0",
+ "active": True,
+ "weight": 1,
+ }
+ ],
+ }
+ ]
+ }
+ test_func = partial(
+ topotest.router_json_cmp, r1, "show ip route 20.1.0.0/16 json", input_dict
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
+ assertmsg = "IP route 20.1.1.0/24 mismatch on router r1"
+ assert result is None, assertmsg
+
+
+def test_as_external_route_prune():
+ tgen = get_topogen()
+
+ if tgen.routers_have_failure():
+ pytest.skip("Skipped because of router(s) failure")
+
+ step("Test OSPF AS external route 100.100.100.100 duplicate nexthops installed")
+ # Verify OSPF route 20.1.0.0/16 duplication nexthops
+ r1 = tgen.gears["r1"]
+ input_dict = {
+ "100.100.100.100/32": {
+ "routeType": "N E2",
+ "cost": 20,
+ "type2cost": 20,
+ "tag": 0,
+ "nexthops": [
+ {"ip": "10.1.1.2", "via": "r1-eth0", "advertisedRouter": "3.3.3.3"},
+ {"ip": "10.1.1.2", "via": "r1-eth0", "advertisedRouter": "4.4.4.4"},
+ {"ip": "10.1.1.2", "via": "r1-eth0", "advertisedRouter": "5.5.5.5"},
+ {"ip": "10.1.1.2", "via": "r1-eth0", "advertisedRouter": "6.6.6.6"},
+ ],
+ }
+ }
+ test_func = partial(
+ topotest.router_json_cmp, r1, "show ip ospf route detail json", input_dict
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
+ assertmsg = "OSPF AS external route 100.100.100.100/32 mismatch on router r1"
+ assert result is None, assertmsg
+
+ step("Test IP route 100.100.100.100/32 installed with pruned next-hops")
+ input_dict = {
+ "100.100.100.100/32": [
+ {
+ "prefix": "100.100.100.100/32",
+ "prefixLen": 32,
+ "protocol": "ospf",
+ "vrfName": "default",
+ "distance": 20,
+ "metric": 20,
+ "installed": True,
+ "internalNextHopNum": 1,
+ "internalNextHopActiveNum": 1,
+ "nexthops": [
+ {
+ "ip": "10.1.1.2",
+ "afi": "ipv4",
+ "interfaceName": "r1-eth0",
+ "active": True,
+ "weight": 1,
+ }
+ ],
+ }
+ ]
+ }
+ test_func = partial(
+ topotest.router_json_cmp,
+ r1,
+ "show ip route 100.100.100.100/32 json",
+ input_dict,
+ )
+ _, result = topotest.run_and_expect(test_func, None, count=60, wait=1)
+ assertmsg = "IP route 100.100.100.100/32 mismatch on router r1"
+ assert result is None, assertmsg
+
+
+def test_memory_leak():
+ "Run the memory leak test and report results."
+ tgen = get_topogen()
+ if not tgen.is_memleak_enabled():
+ pytest.skip("Memory leak test/report is disabled")
+
+ tgen.report_memory_leaks()
+
+
+if __name__ == "__main__":
+ args = ["-s"] + sys.argv[1:]
+ sys.exit(pytest.main(args))
diff --git a/tests/topotests/static_simple/test_static_simple.py b/tests/topotests/static_simple/test_static_simple.py
index bb3580a1d8..afde58fbf7 100644
--- a/tests/topotests/static_simple/test_static_simple.py
+++ b/tests/topotests/static_simple/test_static_simple.py
@@ -61,6 +61,15 @@ def get_ip_networks(super_prefix, count):
return tuple(network.subnets(count_log2))[0:count]
+def get_src_networks(src_prefix, count, default=""):
+ if src_prefix is not None:
+ for net in get_ip_networks(src_prefix, count):
+ yield " from {}".format(net)
+ else:
+ for i in range(0, count):
+ yield default
+
+
def enable_debug(router):
router.vtysh_cmd("debug northbound callbacks configuration")
@@ -70,7 +79,7 @@ def disable_debug(router):
@retry(retry_timeout=30, initial_wait=0.1)
-def check_kernel(r1, super_prefix, count, add, is_blackhole, vrf, matchvia):
+def check_kernel(r1, super_prefix, src_prefix, count, add, is_blackhole, vrf, matchvia):
network = ipaddress.ip_network(super_prefix)
vrfstr = f" vrf {vrf}" if vrf else ""
if network.version == 6:
@@ -79,26 +88,30 @@ def check_kernel(r1, super_prefix, count, add, is_blackhole, vrf, matchvia):
kernel = r1.run(f"ip -4 route show{vrfstr}")
logger.debug("checking kernel routing table%s:\n%s", vrfstr, kernel)
- for _, net in enumerate(get_ip_networks(super_prefix, count)):
+ for net, srcnet in zip(
+ get_ip_networks(super_prefix, count), get_src_networks(src_prefix, count)
+ ):
+ netfull = str(net) + srcnet
if not add:
- assert str(net) not in kernel
+ assert netfull + " nhid" not in kernel
+ assert netfull + " via" not in kernel
continue
if is_blackhole:
- route = f"blackhole {str(net)} proto (static|196) metric 20"
+ route = f"blackhole {netfull}(?: dev lo)? proto (static|196) metric 20"
else:
route = (
- f"{str(net)}(?: nhid [0-9]+)? {matchvia} "
- "proto (static|196) metric 20"
+ f"{netfull}(?: nhid [0-9]+)? {matchvia} proto (static|196) metric 20"
)
assert re.search(route, kernel), f"Failed to find \n'{route}'\n in \n'{kernel}'"
-def do_config(
+def do_config_inner(
r1,
count,
add=True,
do_ipv6=False,
+ do_sadr=False,
via=None,
vrf=None,
use_cli=False,
@@ -109,11 +122,18 @@ def do_config(
#
# Set the route details
#
-
- if vrf:
- super_prefix = "2002::/48" if do_ipv6 else "20.0.0.0/8"
+ src_prefs = [None, None]
+ if do_ipv6 and do_sadr:
+ # intentionally using overlapping prefix
+ super_prefs = ["2001::/48", "2002::/48"]
+ src_prefs = ["2001:db8:1111::/48", "2001:db8:2222::/48"]
+ elif do_ipv6:
+ super_prefs = ["2001::/48", "2002::/48"]
else:
- super_prefix = "2001::/48" if do_ipv6 else "10.0.0.0/8"
+ super_prefs = ["10.0.0.0/8", "20.0.0.0/8"]
+
+ super_prefix = super_prefs[1 if vrf else 0]
+ src_prefix = src_prefs[1 if vrf else 0]
matchvia = ""
if via == "blackhole":
@@ -144,11 +164,13 @@ def do_config(
if vrf:
f.write("vrf {}\n".format(vrf))
- for _, net in enumerate(get_ip_networks(super_prefix, count)):
+ for net, srcnet in zip(
+ get_ip_networks(super_prefix, count), get_src_networks(src_prefix, count)
+ ):
if add:
- f.write("ip route {} {}\n".format(net, via))
+ f.write("ip route {}{} {}\n".format(net, srcnet, via))
else:
- f.write("no ip route {} {}\n".format(net, via))
+ f.write("no ip route {}{} {}\n".format(net, srcnet, via))
#
# Load config file.
@@ -165,7 +187,9 @@ def do_config(
#
# Verify the results are in the kernel
#
- check_kernel(r1, super_prefix, count, add, via == "blackhole", vrf, matchvia)
+ check_kernel(
+ r1, super_prefix, src_prefix, count, add, via == "blackhole", vrf, matchvia
+ )
optyped = "added" if add else "removed"
logger.debug(
@@ -175,6 +199,12 @@ def do_config(
)
+def do_config(*args, **kwargs):
+ do_config_inner(*args, do_ipv6=False, do_sadr=False, **kwargs)
+ do_config_inner(*args, do_ipv6=True, do_sadr=False, **kwargs)
+ do_config_inner(*args, do_ipv6=True, do_sadr=True, **kwargs)
+
+
def guts(tgen, vrf, use_cli):
if tgen.routers_have_failure():
pytest.skip(tgen.errors)
@@ -183,20 +213,20 @@ def guts(tgen, vrf, use_cli):
count = 10
step(f"add {count} via gateway", reset=True)
- do_config(r1, count, True, False, vrf=vrf, use_cli=use_cli)
+ do_config(r1, count, True, vrf=vrf, use_cli=use_cli)
step(f"remove {count} via gateway")
- do_config(r1, count, False, False, vrf=vrf, use_cli=use_cli)
+ do_config(r1, count, False, vrf=vrf, use_cli=use_cli)
via = f"lo-{vrf}" if vrf else "lo"
step("add via loopback")
- do_config(r1, 1, True, False, via=via, vrf=vrf, use_cli=use_cli)
+ do_config(r1, 1, True, via=via, vrf=vrf, use_cli=use_cli)
step("remove via loopback")
- do_config(r1, 1, False, False, via=via, vrf=vrf, use_cli=use_cli)
+ do_config(r1, 1, False, via=via, vrf=vrf, use_cli=use_cli)
step("add via blackhole")
- do_config(r1, 1, True, False, via="blackhole", vrf=vrf, use_cli=use_cli)
+ do_config(r1, 1, True, via="blackhole", vrf=vrf, use_cli=use_cli)
step("remove via blackhole")
- do_config(r1, 1, False, False, via="blackhole", vrf=vrf, use_cli=use_cli)
+ do_config(r1, 1, False, via="blackhole", vrf=vrf, use_cli=use_cli)
def test_static_cli(tgen):