Skip to content

T9658: static_routes: handle interface-only next-hops - #524

Draft
rasty94 wants to merge 5 commits into
vyos:mainfrom
rasty94:T9658/static-routes-interface-next-hop
Draft

rasty94 wants to merge 5 commits into
vyos:mainfrom
rasty94:T9658/static-routes-interface-next-hop

Conversation

@rasty94

@rasty94 rasty94 commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Change Summary

vyos_static_routes keyed next-hops on forward_router_address, which is empty for interface next-hops (set protocols static route 10.0.0.0/8 interface eth0):

  • with two interface next-hops the second was merged into the first (name lost, distance applied to the wrong hop);
  • with three, fact gathering failed with 'NoneType' object does not support item assignment;
  • generating commands for an interface-only next-hop with admin_distance or enabled: false failed with KeyError: 'forward_router_address'.

Hops are now keyed on the address or the interface name, and interface-only hops are addressed as interface Y distance N / interface Y disable (interface-route ... next-hop-interface Y on 1.3).

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

Related PR(s)

Component(s) name

vyos_static_routes

Proposed changes

  • facts parser: each hop keyed on ("next-hop", address) or ("interface", name) (also accepts 1.3 next-hop-interface); distance/disable attach to that hop; next-hop X interface Y now keeps both the address and the interface.
  • config: new _hop_attrib_command() builds distance/disable commands addressing the hop by address or by interface.
  • Unit tests: 5 new cases on 1.4+ and 1 on 1.3 (interface-route), a new fixture, load_fixtures honours filename; changelog fragment.

How to test

pytest tests/unit/modules/network/vyos/test_vyos_static_routes.py tests/unit/modules/network/vyos/test_vyos_static_routes14.py

Test results

20 passed

Without the change 6 of these fail (facts crash on 1.4+, KeyError: 'forward_router_address' on 1.3). Full unit suite: 604 passed.

  • Sanity tests passed
  • Unit tests passed

Tested against VyOS versions:

  • Unit tests only, not yet tested against a live router.

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the ansible sanity and unit tests
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have added unit tests to cover my changes
  • I have added a file to changelogs/fragments to describe the changes

Facts merged next-hops on forward_router_address, which is None for
'route X interface Y' hops, so a second interface hop overwrote the first
and a third crashed fact gathering. Key hops on the gateway address or the
interface name instead.

Command generation for distance/disable read hop['forward_router_address']
and raised KeyError for interface-only hops; address them as
'interface Y' (1.4+) or 'interface-route ... next-hop-interface Y' (1.3).
Copilot AI balanced review requested due to automatic review settings November 20, 2026 09:17
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 20, 2026 09:17

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 22, 2026 19:40

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@omnom62 omnom62 added legacy Exempt from per-commit T-ID check (title T-ID still required); grandfathered PRs and removed invalid-task-id labels Nov 22, 2026
Copilot AI balanced review requested due to automatic review settings November 22, 2026 20:15

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI balanced review requested due to automatic review settings November 23, 2026 22:49

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

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

Labels

legacy Exempt from per-commit T-ID check (title T-ID still required); grandfathered PRs

Development

Successfully merging this pull request may close these issues.

3 participants