Skip to content

virtual router: Apply BGP peer changes with frr-reload - #14841

Open
MitchDrage wants to merge 10 commits into
apache:mainfrom
MitchDrage:bgp-frr-reload
Open

MitchDrage wants to merge 10 commits into
apache:mainfrom
MitchDrage:bgp-frr-reload

Conversation

@MitchDrage

@MitchDrage MitchDrage commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

When a BGP peer's configuration is changed in CloudStack, the virtual router restarts FRR, which drops every BGP session on the router. This PR applies the change with frr-reload.py, so only the changed neighbours are touched. It prepares the router for #14687.

  • CsBgpPeers reloads FRR once bgpd is running. It restarts FRR only to start bgpd, or when frr-reload.py is missing or fails. frr-reload.py logs to its own output, so the peer passwords it applies are not written to /var/log/frr/frr-reload.log.
  • The rendered file states ebgp-requires-policy, network import-check and the kernel's current forwarding setting for IPv4 and IPv6, so a reload never changes them. It has no frr version line.
  • The systemvm template installs frr-pythontools, which ships frr-reload.py.

Please note, this needs a new systemvm template with frr-pythontools installed. Routers on an older template will continue to restart FRR, which affects all peers at once when one peer's configuration changes.

The minimum hold time setting and the FRR files in router diagnostics were part of this PR. The hold time setting has moved to #14869, and the diagnostics files to #14884.

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • build/CI
  • test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Screenshots (if appropriate):

N/A

How Has This Been Tested?

  • New unit tests in TestCsBgpPeers for the reload, the restart fallbacks and the forwarding lines. Its fixture is updated for the new lines.
  • Tested in a lab environment: CloudStack 4.22.1.1 with KVM hosts, systemvm template 4.22.0, a ROUTED VPC with Dynamic routing, and these router scripts.
    • Without frr-pythontools, the router logged "frr-reload.py not found, restarting frr" and applied the new file.
    • With frr-pythontools installed, adding and then removing a second peer with a password went through frr-reload.py. bgpd's pid stayed the same and the first peer's session stayed up throughout.
    • No frr-reload.log was written, and no file under /var/log/frr contained the peer password.
    • IPv4 and IPv6 forwarding stayed unchanged through every reload.
    • After a router stop and start, later peer configuration changes still went through frr-reload.py with bgpd's pid unchanged.

How did you try to break this feature and the system with this change?

  • Removed frr-reload.py, or made it fail: the router falls back to a restart and still applies the config.
  • Configured the first peer on a router with bgpd off: FRR restarts to start bgpd.
  • Reloaded main's file on FRR 8.4.4 with IPv6 forwarding off: the reload turned it on. The file now states the kernel's setting, and the unit tests cover both states.
  • Ran frr-reload.py without --stdout after a password change: it wrote the password to frr-reload.log. With --stdout no such file is written.

hostname r-1001-VM
service integrated-vtysh-config
ip forwarding
ipv6 forwarding

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

are these needed ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, they're needed once changes go through frr-reload. zebra shows the kernel's forwarding state in the running config, so an IPv4-only router has no ipv6 forwarding there, and frr-reload deletes any running line the file doesn't state.
When I reloaded main's file unchanged on 8.4.4, net.ipv6.conf.all.forwarding went from 0 to 1.
The router already wrote the IPv6 line from the kernel's setting, and I've changed it to do the same for IPv4.
This fixture is just the dual-stack snapshot for test_full_frr_conf. The behaviour itself is covered by two new tests in TestCsBgpPeersFrr, test_operator_states_forwarding_off_from_kernel and ..._on_from_kernel.

@wido
wido self-requested a review November 24, 2026 12:21
@wido

wido commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Overall I think a good PR, but you are doing 3 things in one PR. The reload of FRR is an enhancement to the way FRR works. Yes, this should be a proper reload, but the PR then also changes other things.

This makes it more difficult to merge the PR. Would you see the possibility to make this a set of 3 PRs? Especially the reload one can be merged easier is my idea.

"""Returns the installed FRR package version, or None when it cannot tell."""
try:
out = subprocess.check_output(["dpkg-query", "-W", "-f=${Version}", "frr"], stderr=subprocess.DEVNULL)
except (OSError, subprocess.CalledProcessError):

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.

Why? We know which version of FRR is there. We ship the template. We can make assumptions in the code.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I added it so the tenant BGP work in the upcoming PRs could tell which routers have frr-reload.py and bfdd before enabling it. You're right that the template version gives us that, so I'll remove the capability line and its tests.

You might have already noticed the file check in CsBgpPeers.py. You didn't ask about it but for the record, that's there because routers still on an older template run this PR's version of it before they are rebuilt, and those templates have no frr-reload.py. It restarts FRR when the file is missing, which I tested on a 4.22.0 template on KVM.

@MitchDrage

MitchDrage commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Overall I think a good PR, but you are doing 3 things in one PR. The reload of FRR is an enhancement to the way FRR works. Yes, this should be a proper reload, but the PR then also changes other things.

This makes it more difficult to merge the PR. Would you see the possibility to make this a set of 3 PRs? Especially the reload one can be merged easier is my idea.

Yes, that makes sense. I'll split it into three:

  1. This PR: apply BGP peer changes with frr-reload, with frr-pythontools in the template.
  2. The minimum hold time setting: virtual router: Add a minimum BGP hold time setting #14869.
  3. The FRR log and a masked frr.conf in router diagnostics: virtual router: Collect the FRR log and a masked frr.conf in router diagnostics #14884.

This PR is ready for review again. I'll link the other two here once they're open. All PRs linked.

@MitchDrage MitchDrage changed the title virtual router: Apply BGP peer changes with frr-reload and add a minimum hold time virtual router: Apply BGP peer changes with frr-reload Nov 25, 2026
@MitchDrage
MitchDrage requested a review from wido November 25, 2026 11:50
@MitchDrage

Copy link
Copy Markdown
Contributor Author

This should be good to review again now. The last commits were cleaning up some of the tests.

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.

3 participants