-
Notifications
You must be signed in to change notification settings - Fork 1.5k
ospfd,tests: fix OSPF connected overlapping prefix bug #21510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
donaldsharp
merged 2 commits into
FRRouting:master
from
opensourcerouting:ospf-overlap-connected
Apr 16, 2026
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
15 changes: 15 additions & 0 deletions
15
tests/topotests/ospf_connected_overlapping_prefix/r1/frr.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| interface r1-eth0 | ||
| ip address 10.0.0.1/24 | ||
| ip ospf area 0 | ||
| ip ospf dead-interval 8 | ||
| ip ospf hello-interval 2 | ||
| exit | ||
| ! | ||
| interface r1-eth1 | ||
| ip address 10.0.0.129/30 | ||
| exit | ||
| ! | ||
| router ospf | ||
| ospf router-id 10.254.254.1 | ||
| redistribute connected | ||
| exit |
10 changes: 10 additions & 0 deletions
10
tests/topotests/ospf_connected_overlapping_prefix/r2/frr.conf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| interface r2-eth0 | ||
| ip address 10.0.0.2/24 | ||
| ip ospf area 0 | ||
| ip ospf dead-interval 8 | ||
| ip ospf hello-interval 2 | ||
| exit | ||
| ! | ||
| router ospf | ||
| ospf router-id 10.254.254.2 | ||
| exit |
132 changes: 132 additions & 0 deletions
132
tests/topotests/ospf_connected_overlapping_prefix/test_ospf_connected_overlapping_prefix.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| #!/usr/bin/env python | ||
| # SPDX-License-Identifier: ISC | ||
|
|
||
| # | ||
| # test_ospf_connected_overlapping_prefix.py | ||
| # Part of NetDEF Topology Tests | ||
| # | ||
| # Copyright (c) 2026 by | ||
| # Network Device Education Foundation, Inc. ("NetDEF") | ||
| # | ||
|
|
||
| """ | ||
| test_ospf_connected_overlapping_prefix.py: test OSPF overlapping prefix bug. | ||
| """ | ||
|
|
||
| import os | ||
| import sys | ||
| from functools import partial | ||
| 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, get_topogen | ||
|
|
||
| pytestmark = [pytest.mark.ospfd] | ||
|
|
||
|
|
||
| def setup_module(mod): | ||
| topodef = { | ||
| "s1": ("r1", "r2"), | ||
| "s2": "r1" | ||
| } | ||
|
|
||
| tgen = Topogen(topodef, mod.__name__) | ||
| tgen.start_topology() | ||
|
|
||
| router_list = tgen.routers() | ||
| for rname, router in router_list.items(): | ||
| router.load_frr_config(f"{CWD}/{rname}/frr.conf") | ||
|
|
||
| tgen.start_router() | ||
|
|
||
|
|
||
| def expect_ospf_neighbor(router, neighbor): | ||
| tgen = get_topogen() | ||
|
|
||
| expected = { | ||
| "neighbors": { | ||
| neighbor: [{ | ||
| "converged": "Full" | ||
| }] | ||
| } | ||
| } | ||
| test_func = partial( | ||
| topotest.router_json_cmp, | ||
| tgen.gears[router], | ||
| "show ip ospf neighbor json", | ||
| expected) | ||
| _, result = topotest.run_and_expect(test_func, None, count=60, wait=1) | ||
| assert result is None, f"Router {router} failed to converge" | ||
|
|
||
|
|
||
| def test_ospf_neighbor_convergence(): | ||
| tgen = get_topogen() | ||
| if tgen.routers_have_failure(): | ||
| pytest.skip(tgen.errors) | ||
|
|
||
| expect_ospf_neighbor("r1", "10.254.254.2") | ||
| expect_ospf_neighbor("r2", "10.254.254.1") | ||
|
|
||
|
|
||
| def test_ospf_connected_overlapping_prefix(): | ||
| tgen = get_topogen() | ||
| if tgen.routers_have_failure(): | ||
| pytest.skip(tgen.errors) | ||
|
|
||
| def expect_r2_route(): | ||
| out = tgen.gears["r2"].vtysh_cmd("show ip ospf route json", isjson=True) | ||
| return topotest.json_cmp(out, { | ||
| "10.0.0.128/30": { | ||
| "routeType": "N E2" | ||
| } | ||
| }) | ||
|
|
||
| # Expect that the overlapped connected route shows up as external | ||
| _, result = topotest.run_and_expect(expect_r2_route, None, count=30, wait=1) | ||
| assert result is None, f"Router r2 should have learned external route" | ||
|
|
||
|
|
||
| def test_ospf_connected_prefix_not_in_external(): | ||
| tgen = get_topogen() | ||
| if tgen.routers_have_failure(): | ||
| pytest.skip(tgen.errors) | ||
|
|
||
| def expect_r2_route(): | ||
| out = tgen.gears["r2"].vtysh_cmd("show ip ospf route json", isjson=True) | ||
| return topotest.json_cmp(out, { | ||
| "10.0.0.0/24": { | ||
| "routeType": "N" | ||
| } | ||
| }) | ||
|
|
||
| # Expect that the connected route shows up as non external | ||
| _, result = topotest.run_and_expect(expect_r2_route, None, count=30, wait=1) | ||
| assert result is None, f"Router r2 should not have learned external route" | ||
|
|
||
|
|
||
| def teardown_module(): | ||
| "Teardown the pytest environment" | ||
| tgen = get_topogen() | ||
| tgen.stop_topology() | ||
|
|
||
|
|
||
| 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)) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.