Skip to content

Add static default routes when originating BGP default routes#3527

Merged
ipspace merged 2 commits into
devfrom
bgp-default
Jun 29, 2026
Merged

Add static default routes when originating BGP default routes#3527
ipspace merged 2 commits into
devfrom
bgp-default

Conversation

@ipspace

@ipspace ipspace commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Some devices (Junos, BIRD) need a default route in the routing table to originate a BGP default route. To simplify the configuration templates, the bgp.session plugin adds the necessary static routes and activates the 'routing' module on the affected node(s).

Working:

  • Global and VRF static routes are added
  • Deduplication of added static routes

Still missing:

  • Dual-stack/IPv6 checks
  • Using existing defaults

@ipspace ipspace marked this pull request as draft June 25, 2026 05:51
continue

append_to_list(ndata,'module','routing') # Activate the routing module in the node
append_to_list(topology,'module','routing') # ... assuming the developer setting BGP features was sane ;)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hope this doesn't activate the routing module on all nodes in the topology?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Of course not. This is done late in the process (well after the topology.module is copied into node.module). The same two calls are used to add static routes to hosts.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

In that case, what breaks if we don’t set this? Why is this necessary?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

In that case, what breaks if we don’t set this? Why is this necessary?

The static routes are not configured 🤷🏻‍♂️

Some devices (Junos, BIRD) need a default route in the routing table
to originate a BGP default route. To simplify the configuration
templates, the bgp.session plugin adds the necessary static routes
and activates the 'routing' module on the affected node(s).

The functionality is used to implement BGP default routes for BIRD

Also added:
* Coverage test to check all potential scenarios (IPv4, IPv6, DS,
  single neighbor, multiple neighbors, routing module active or not)
* Non-default-route BGP neighbors in the integration test to check
  whether the default route is propagated only to the correct
  neighbors
@ipspace ipspace changed the title WIP: Add static default routes when originating BGP default routes Add static default routes when originating BGP default routes Jun 29, 2026
@ipspace ipspace marked this pull request as ready for review June 29, 2026 07:56
@ipspace ipspace requested a review from Copilot June 29, 2026 07:56

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.

Pull request overview

This PR updates the bgp.session plugin and BIRD templates to support devices that require an existing default route in the routing table before they can originate a BGP default route, by auto-adding discard static defaults (global/VRF) and enabling the routing module where needed.

Changes:

  • Extend bgp.session plugin post-transform logic to inject per-AF discard static default routes (global and per-VRF) when default_originate is used on devices requiring static.
  • Simplify BIRD BGP configuration by removing the per-neighbor “static reject default” helper and relying on routing/static-route infrastructure instead.
  • Add integration and coverage tests validating default-originate behavior and route propagation/non-propagation.

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/integration/bgp.session/04-default-originate.yml Expands the integration scenario to test default-originate propagation and non-propagation across additional peers (global + VRF).
tests/coverage/input/bgp-default.yml Adds a coverage input topology exercising multiple global/VRF/IPv4/IPv6 default-originate combinations.
tests/coverage/expected/bgp-default.yml Captures the expected transformed topology, including injected discard static defaults and auto-enabled routing module.
netsim/extra/bgp.session/plugin.py Implements static default route injection and routing module activation for devices requiring static defaults to originate.
netsim/daemons/bird/bgp.macros.j2 Removes the old “static reject default” macro and adjusts default-route handling in the export prefix selection function.
netsim/daemons/bird/bgp.j2 Drops invocation of the removed default-originate static macro.
netsim/daemons/bird.yml Changes BIRD default_originate feature to static to trigger static-default injection behavior.

Comment on lines +174 to +176
route_list = [ # Find relevant static routes based on neighbor AFs
BGP_DEFAULT[af] for af in log.AF_LIST if af in ngb
]

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Probably not applicable, but I nevertheless rewrote the SR creation code

@ipspace ipspace merged commit 860c7cd into dev Jun 29, 2026
12 checks passed
@ipspace ipspace deleted the bgp-default branch June 29, 2026 08:27
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.

3 participants