Skip to content

Add support for ospf auto cost configuration - #1693

Merged
troglobit merged 4 commits into
mainfrom
add-support-for-ospf-auto-cost-configuration
Oct 13, 2026
Merged

troglobit merged 4 commits into
mainfrom
add-support-for-ospf-auto-cost-configuration

Conversation

@saba8814

@saba8814 saba8814 commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Description

All OSPF routers in a domain need the same auto-cost reference bandwidth
to agree on link costs. Other vendors use other defaults than Frr, so
the value has to be configurable. Resolves #1576.

The auto-cost container from ietf-ospf is now supported, for OSPFv2
and OSPFv3:

  • reference-bandwidth defaults to 100000 Mbit/s, the Frr default used
    so far. Link costs do not change on upgrade, so no migration script
    is needed.
  • enabled is always true. Frr has no way to turn auto-cost off, so
    setting it to false is rejected. An explicit interface cost still
    overrides the calculated one.
  • The value in use can be read from the operational datastore and is
    shown by show ip ospf and show ipv6 ospf.

The new test ospf_auto_cost runs for both OSPF versions. It sets the
reference bandwidth on both routers and checks the interface cost. On
a 1 Gbit/s link, 100000, 10000 and 1000 Mbit/s give the costs 100, 10
and 1.

Checklist

Tick relevant boxes, this PR is-a or has-a:

  • Bugfix
    • Regression tests
    • ChangeLog updates (for next release)
  • Feature
    • YANG model change => revision updated?
    • Regression tests added?
    • ChangeLog updates (for next release)
    • Documentation added?
  • Test changes
    • Checked in changed Readme.adoc (make test-spec)
    • Added new test to group Readme.adoc and yaml file
  • Code style update (formatting, renaming)
  • Refactoring (please detail in commit messages)
  • Build related changes
  • Documentation content changes
    • ChangeLog updated (for major changes)
  • Other (please describe):

@saba8814 saba8814 added the ci:main Build default defconfig, not minimal label Oct 7, 2026

@troglobit troglobit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comments, mostly for internal discussion.

Comment thread src/confd/yang/confd/infix-routing.yang Outdated
Comment thread src/confd/yang/confd/infix-routing.yang
@saba8814
saba8814 force-pushed the add-support-for-ospf-auto-cost-configuration branch 3 times, most recently from 22355ea to a46aefa Compare October 8, 2026 16:06
@jovatn jovatn added the cn:styx Common Name: Styx Project label Oct 12, 2026

@jovatn jovatn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Slight changes to the documentation is suggested.
Also, can we take a look at the YANG changes to auto-cost (agnostic to OSPFv2 or OSPFv3?) and the location of its documentation (under OSPFv2).

Comment thread doc/routing.md
Comment thread doc/routing.md Outdated
Comment thread doc/routing.md Outdated
Comment thread test/case/routing/ospf_auto_cost/test.py
All routers in an OSPF domain must use the same reference bandwidth to
agree on link costs, and other vendors default to other values than
Frr.  Until now the value was fixed at the Frr default.

Enable the ietf-ospf auto-cost feature for OSPFv2 and OSPFv3.  The
reference-bandwidth leaf defaults to 100000 Mbit/s, the value used so
far, so link costs do not change on upgrade and no migration is
needed.  Frr can not turn auto-cost off, so the enabled leaf defaults
to true and false is rejected.

Resolves: #1576
Signed-off-by: Ejub Sabic <ejub1946@outlook.com>
To check that the reference bandwidth matches across the domain it has
to be readable.  Frr has no JSON for it, so read it from the daemon's
running-config, which lists it only when it differs from the default.

Report it for OSPFv2 and OSPFv3, and show it in 'show ip ospf' and
'show ipv6 ospf'.

Signed-off-by: Ejub Sabic <ejub1946@outlook.com>
Verify that the interface cost follows the reference bandwidth, for
OSPFv2 and OSPFv3.  The expected cost is derived from the link speed,
so the test works on hardware and on virtual links of unknown speed.
On a 1 Gbit/s link the reference bandwidths 100000, 10000 and 1000
Mbit/s give the costs 100, 10 and 1.

Signed-off-by: Ejub Sabic <ejub1946@outlook.com>
@saba8814
saba8814 force-pushed the add-support-for-ospf-auto-cost-configuration branch 2 times, most recently from b205faa to 4bdbb34 Compare October 13, 2026 12:14
Explain why the reference bandwidth must match across the domain, how
the interface cost is calculated, and where to read the value.

Signed-off-by: Ejub Sabic <ejub1946@outlook.com>
@saba8814
saba8814 force-pushed the add-support-for-ospf-auto-cost-configuration branch from 4bdbb34 to 7b5c82a Compare October 13, 2026 12:16
@jovatn

jovatn commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

LGTM!

@troglobit

Copy link
Copy Markdown
Contributor

LGTM!

Yeah me too, approved the PR for merge!

@jovatn we should probably create a doc-task to "consolidate and refactor" routing-dokumentationen. Kan du lägga upp ett?

@troglobit
troglobit merged commit 7804a88 into main Oct 13, 2026
10 checks passed
@troglobit
troglobit deleted the add-support-for-ospf-auto-cost-configuration branch October 13, 2026 19:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:main Build default defconfig, not minimal cn:styx Common Name: Styx Project

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add configuration support for OSPF auto-cost reference bandwidth

3 participants