Skip to content

OSPF support for OpenBSD devices#2697

Merged
ipspace merged 4 commits intoipspace:devfrom
remilocherer:dev
Sep 23, 2025
Merged

OSPF support for OpenBSD devices#2697
ipspace merged 4 commits intoipspace:devfrom
remilocherer:dev

Conversation

@remilocherer
Copy link
Collaborator

This adds OSPFv2 and OSPFv3 support for OpenBSD.

I had to change the role from 'host' to 'router'. Overwriting it in the topology did not work (ospf templates were not evalutated).

ipspace added a commit that referenced this pull request Sep 22, 2025
@ipspace
Copy link
Owner

ipspace commented Sep 22, 2025

I had to change the role from 'host' to 'router'. Overwriting it in the topology did not work (ospf templates were not evalutated).

Topology-level modules are copied into router nodes that do not have a module attribute. That's not done for host nodes because it's assumed hosts usually just do IP routing.

We would have to set role: router on dut device in all OSPF integration tests, but that doesn't make much sense. Once a node supports a routing protocol, it's a router ;) Setting role on OpenBSD device is a much better solution.

Copy link
Owner

@ipspace ipspace left a comment

Choose a reason for hiding this comment

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

Thanks a million. Great job!

I made a number of suggestions (plus the "|default(x)" thing which I think we need). I could fix them if you're short on time.

A bunch of OSPFv3 integration tests were failing, but it seems to be a timing thing. For example, I retried the 01-network test and the failing "is prefix there" test succeeded in 11 seconds (just above the 10-second deadline).

https://tests.netlab.tools/openbsd/libvirt/ospf/ospfv3/01-network.yml-validate.log

You probably need to tweak a few SPF/LSA origination timers.

spf-holdtime msec 200
{% if ospf_data.default is defined %}
{% set dfd = ospf_data.default %}
redistribute default set {{ '{' }} metric {{ dfd.cost or '100' }} type {{ dfd.type.replace('e','') or '1' }} {{ '}' }}
Copy link
Owner

Choose a reason for hiding this comment

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

You can use { or } as simple text, no need to make an expression out of it. Jinja2 reacts just to {{ / }} and {% / %}

Copy link
Owner

Choose a reason for hiding this comment

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

Also, see the comment on using |default(x) in OSPFv3 template

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

makes sense.
I can adapt it towards the end of the week. Feel free to adapt if you have the time earlier.

{% for a in areas %}
area {{ a }} {{ '{' }}
{% for l in intf_data if l.ospf.area is defined and l.ospf.area is eq a and 'ipv4' in l %}
{% if l.ifname == "lo0" %}
Copy link
Owner

Choose a reason for hiding this comment

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

Is this specific to "lo0" or all loopback interfaces? If it applies to all loopback interfaces, I'd go with if l.type == "loopback"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is specific to lo0. Otherwise 127.0.0.1 would be advertised ...

{% else %}
interface {{ l.ifname }} {{ '{ '}}
{% endif %}
{% if l.ospf.network_type is defined and l.ospf.network_type == 'point-to-point' %}
Copy link
Owner

Choose a reason for hiding this comment

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

Does OpenBSD support just "network" and "point-to-point"? We also have "point-to-multipoint" (but it's rarely implemented and thus not tested anywhere).

If OpenBSD supports "point-to-multipoint" then you might want to use a keyword map similar to what Junos does

{% set KW_NETWORK_TYPE = {'point-to-point': 'p2p','point-to-multipoint': 'p2mp', 'non-broadcast': 'nbma' } %}

You can also define the keyword map in device group_vars if you hate having hard-coded stuff in templates.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nbma is not in the OpenBSD OSPF implementation.

spf-holdtime 1
{% if ospf_data.default is defined %}
{% set dfd = ospf_data.default %}
redistribute default set {{ '{' }} metric {{ dfd.cost or '100' }} type {{ dfd.type.replace('e','') or '1' }} {{ '}' }}
Copy link
Owner

Choose a reason for hiding this comment

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

Default cost could be undefined. It would be better to use "dfd.cost|default(100)". Same for dfd.type

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

makes sense. thanks for catching this!

Copy link
Owner

@ipspace ipspace left a comment

Choose a reason for hiding this comment

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

Implemented all suggested changes, added device quirks, documentation, and changes to integration tests

@ipspace ipspace merged commit be14c76 into ipspace:dev Sep 23, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants