Skip to content

Validate the AS number of BGP peers - #14976

Open
MitchDrage wants to merge 1 commit into
apache:mainfrom
MitchDrage:bgp-peer-asn
Open

MitchDrage wants to merge 1 commit into
apache:mainfrom
MitchDrage:bgp-peer-asn

Conversation

@MitchDrage

@MitchDrage MitchDrage commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR adds AS number validation to createBgpPeer and updateBgpPeer, which currently accept any value.
I created a peer with AS 0, and FRR 8.4.4 rejected its neighbour line, so the peer existed in CloudStack but was never configured on the router.

  • New RoutedIpv4Manager.validateBgpPeerAsNumber accepts 1 to 4294967295 and refuses 23456 (AS_TRANS, RFC 6793), 65535 and 4294967295 (RFC 7300).
    • Private (RFC 6996: 64512-65534, 4200000000-4294967294) and documentation (RFC 5398: 64496-64511, 65536-65551) AS numbers are still accepted.
  • createBgpPeer always checks the AS number. updateBgpPeer checks it only when it changes, so an existing peer with an invalid AS number can still have its other fields updated.
  • The error is "AS number is not valid."
  • New unit test class RoutedIpv4ManagerImplBgpPeerAsnTest.

Fixes: #14939

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):

How Has This Been Tested?

  • RoutedIpv4ManagerImplBgpPeerAsnTest (15 tests) and RoutedIpv4ManagerImplTest (57 tests) pass. On main without this change, the 7 tests that expect a refusal fail and the 8 that expect a valid AS number to be accepted pass.
  • On a 4.22.1.1 lab with this change applied to the management server:
Call AS number Result
createBgpPeer 0, 23456, 65535, 4294967295, 4294967296 Refused
createBgpPeer 64496, 65551, 4200000100 Created
updateBgpPeer 23456, 4294967296 Refused
updateBgpPeer 64601, then 64601 again Saved
updateBgpPeer address only Saved

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

  • Updated a peer without asnumber, and with its current AS number, to check the update path still saves.

@sudo87 sudo87 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.

clgtm

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.

Validate the AS number of BGP peers

2 participants