8000 fix(frr_bgp): adapt BGP modules to os-frr 2.0 (OPNsense 26.7) by nerrehmit · Pull Request #487 · O-X-L/ansible-opnsense · GitHub
[go: up one dir, main page]

Skip to content

fix(frr_bgp): adapt BGP modules to os-frr 2.0 (OPNsense 26.7) - #487

Open
nerrehmit wants to merge 2 commits into
O-X-L:latestfrom
nerrehmit:claude/project-thread-s7ikui
Open

nerrehmit wants to merge 2 commits into
O-X-L:latestfrom
nerrehmit:claude/project-thread-s7ikui

Conversation

@nerrehmit
Copy link
Copy Markdown
Contributor

Before: on OPNsense 26.7 (os-frr 2.0) frr_bgp_neighbor fails on every existing neighbor with "Failed to translate API entry ... Failed field: 'multiprotocol'". frr_bgp_route_map reports changed on every run when it links several entries of one as-path, community or prefix-list, or any entry but the first one of a list.

After: neighbors take the new family option (ipv4, ipv6 or both), and the route-map module compares the linked lists, so it settles after the first run.

Upstream changes behind each fix

Module Change in the collection Upstream cause (os-frr 2.0 changelog)
frr_bgp_neighbor family added (list of ipv4/ipv6). It defaults to the family of the neighbor IP, as the os-frr migration does. multi_protocol is kept as a deprecated shortcut: true means both families, and it can't be combined with family "Add address family dropdown to neighbors, replacing implicit Multi-Protocol toggle" (opnsense/plugins#5648, f7a268594): multiprotocol removed, family added as a required multi-select
frr_bgp_route_map as_path_list, community_list and prefix_list are compared by the lists they link (as-path/community number, prefix-list name), not by entry UUID. Diffs show descriptions and names instead of UUIDs "Reimplement handling policy list entries as logical groups" (opnsense/plugins#5745, 9cc363edc): the links became GroupedModelRelationField, so the API returns only the first entry of each list as selected
frr_bgp_peer_group name is validated as ^[a-zA-Z0-9._-]{1,64}$ "Tighten routing model field validation" (opnsense/plugins c8e6e93d8) added this mask
docs Notes on the above, plus that BGP networks must now be strict CIDR networks (host bits zero) and the router ID an IPv4 address same commit c8e6e93d8
tests, docs examples The AS numbers 1337, 1338 and 1339 are replaced by 64496, 64497 and 64498 from the range reserved for documentation (RFC 5398). 1337 is an assigned public AS number not an upstream change

The other link changes need no change in the collection. Prefix-lists and route-maps used by neighbors, peer groups and redistributions also became grouped, but those modules already link the first entry of a list, which is the entry the API now reports. This was checked on a 26.7.7 box.

How

frr_bgp_neighbor sets family in check() before matching. frr_bgp_route_map resolves the given entries to UUIDs as before. If the resulting lists are the same as the stored ones, it keeps the stored UUIDs, so nothing is sent. FRR itself has always rendered these links per list (match as-path <number>, match ip address prefix-list <name>), on 26.1 too, so this changes no behavior there either.

Checked

  • Integration tests on a live OPNsense 26.7.7 with os-frr 2.0_1: all 8 frr_bgp_* playbooks pass, also in check mode. On latest, frr_bgp_neighbor fails on the same box.
  • After switching to the documentation AS numbers, frr_bgp_general, frr_bgp_neighbor and frr_bgp_peer_group were rerun unmodified on 26.7.7: all pass, also in check mode.
  • New tests cover an IPv6 neighbor without family, multi_protocol matching both families, and family together with multi_protocol failing. Further new tests cover route-maps that link two prefix-list entries, two as-paths of one number, or only the second community-list entry of a number. All three "nothing changed" checks fail on latest against 26.7.7 and pass with this change.
  • On OPNsense 26.1.11 (os-frr 1.53) everything passes except frr_bgp_neighbor, whic 8000 h can't read the missing family field.

- frr_bgp_neighbor: replace the removed 'multiprotocol' toggle with the
  'family' multi-select (opnsense/plugins f7a268594). 'family' defaults
  to the family of the neighbor IP, like the os-frr migration does.
  'multi_protocol: true' still works and maps to both families.
- frr_bgp_route_map: os-frr groups as-path and community lists by number
  and prefix-lists by name and the API returns only one entry per group
  (opnsense/plugins 9cc363edc). Compare the linked groups instead of the
  entry UUIDs, so linking several entries of one group no longer reports
  'changed' on every run. Diffs show descriptions/names instead of UUIDs.
- frr_bgp_peer_group: validate the name like os-frr does now
  (opnsense/plugins c8e6e93d8).
- docs: note the changes and the stricter network/router-id validation.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019pqWdGsBoRhwRi6rcxCFmc
Replace the AS numbers 1337, 1338 and 1339 in the BGP tests, the BGP
cleanup and the BGP docs examples with 64496, 64497 and 64498 from the
range reserved for documentation (RFC 5398). 1337 is an assigned
public AS number.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019pqWdGsBoRhwRi6rcxCFmc
@superstes
Copy link
Copy Markdown
Member

Note: I will have to take some time reviewing this PR as there are a lot of changes.. Hope I find time for it sometime soon.

zarinbal added a commit to zarinbal/ansible-opnsense that referenced this pull request Oct 28, 2026
…s-frr 2.0

The BGP neighbor and process models of os-frr 2.0 (OPNsense 26.7) carry
options the modules had no parameter for, so they could only be set in the
WebUI and were invisible to a run - a neighbor's 'Soft reconfiguration
inbound' being the one that made us look.

frr_bgp_neighbor: local_as, soft_reconfiguration_inbound, bfd_strict,
remove_private_as, allow_as_in, attribute_unchanged, capabilities and
peer_group. The peer group is given by name and resolved to its uuid like the
prefix-lists and route-maps; 'remove_private_as' takes the option-names of
the model and maps them to the FRR arguments the API stores; 'bfd_strict'
without 'bfd' fails before the API call.

frr_bgp_general: enforce_first_as, bestpath, maximum_paths and
maximum_paths_ibgp. 'enforce_first_as' defaults to true like the model, so an
existing configuration reads back unchanged.

All of them are change-fields, so the full state is enforced as for every
other option of these modules.

The 26.7 model also dropped 'multiprotocol' for 'family', which the released
module cannot read at all. That adaptation is the subject of O-X-L#487 by
nerrehmit; this commit carries the same change so it can be tested on 26.7
on its own, and will be rebased onto O-X-L#487 once that is merged.

Tests: a mocked BgpController reproducing the 26.7 response shape, unit-tests
for both modules (translation of the new fields, posted payload, idempotency,
every field changing on its own, the peer-group lookup, bfd_strict guard,
check mode, list output) and the functional tests extended with the new
options, a peer-group link and the failure cases. Docs tables and examples
updated.
@zarinbal
Copy link
Copy Markdown
Contributor

Thanks for this - we hit the same multiprotocol failure on our 26.7.7 pair, and without this change the neighbor module cannot be used there at all.

I have opened #504 on top of it: the remaining options of the os-frr 2.0 model that the modules had no parameter for (frr_bgp_neighbor: local_as, soft_reconfiguration_inbound, bfd_strict, remove_private_as, allow_as_in, attribute_unchanged, capabilities, peer_group; frr_bgp_general: enforce_first_as, bestpath, maximum_paths, maximum_paths_ibgp), with a mocked BgpController and unit tests for both modules. It carries the same family adaptation so it can be tested on its own, and I will rebase it onto this one as soon as it is merged - so the two can be reviewed together if that is easier.

nerrehmit pushed a commit to nerrehmit/collection_opnsense that referenced this pull request Nov 21, 2026
@superstes
Copy link
Copy Markdown
Member

/review

(FYI: Just testing the Review-Bot I am just adding)

@github-actions
github-actions Bot commented Dec 5, 2026
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@superstes

Copy link
Copy Markdown
Member

/change-summary

@github-actions
github-actions Bot commented Dec 5, 2026
Copy link
Copy Markdown

PR Change Summary

Category Files Changed Lines Added Lines Removed
🦾 Unit-Tests 2 $\color{green}{+113}$ 0
🤖 Integration-Tests 5 $\color{green}{+204}$ $\color{red}{-38}$
📘 Documentation 1 $\color{green}{+28}$ $\color{red}{-17}$
🔄 Modules 4 $\color{green}{+63}$ $\color{red}{-8}$
Total 12 $\color{green}{\mathbf{+408}}$ $\color{red}{\mathbf{-63}}$

Generated by /change-summary

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0