Skip to content

bgp: add local_as support to BGP_NEIGHBOR template#26556

Open
briantopping wants to merge 1 commit intosonic-net:masterfrom
briantopping:bgp-local-as-support
Open

bgp: add local_as support to BGP_NEIGHBOR template#26556
briantopping wants to merge 1 commit intosonic-net:masterfrom
briantopping:bgp-local-as-support

Conversation

@briantopping
Copy link
Copy Markdown

Summary

  • Add local_as attribute support to the general BGP neighbor instance template
  • When local_as is defined in BGP_NEIGHBOR CONFIG_DB table, renders neighbor <addr> local-as <asn> no-prepend replace-as in FRR config
  • Three-line template change, no Python code changes needed (bgpcfgd already passes all CONFIG_DB attributes to the template as bgp_session)

Motivation

Operators running iBGP internally with a private AS need to present a different (public) AS to upstream PE routers via local-as. This is a standard BGP deployment pattern for multi-site networks.

Dell Enterprise SONiC already supports the local_as attribute in BGP_NEIGHBOR and BGP_PEER_GROUP tables. This patch brings the same capability to community SONiC by adding the corresponding template logic.

Example CONFIG_DB usage

sonic-db-cli CONFIG_DB hset 'BGP_NEIGHBOR|default|10.0.0.1' local_as 64512

Produces in FRR:

neighbor 10.0.0.1 local-as 64512 no-prepend replace-as

Test plan

  • Verified on Quanta IX8-56X (BCM56870) with FRR 10.6-dev
  • PE BGP sessions establish correctly with local-as presenting AS 10595 while router runs AS 65001
  • Neighbors without local_as attribute are unaffected (conditional renders nothing)

🤖 Generated with Claude Code

Add support for the local_as attribute in the BGP_NEIGHBOR CONFIG_DB table.
When local_as is defined for a neighbor, the template renders:
  neighbor <addr> local-as <asn> no-prepend replace-as

This enables operators to present a different AS number to specific peers
while using a single internal AS for iBGP. Common use case: sites running
iBGP internally with a private AS while presenting a public AS to upstream
PE routers.

Matches the local_as attribute schema used in Dell Enterprise SONiC for
the BGP_NEIGHBOR and BGP_PEER_GROUP tables.
@briantopping briantopping requested a review from lguohan as a code owner April 4, 2026 03:22
@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla bot commented Apr 4, 2026

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: briantopping / name: Brian Topping (b13e249)

@mssonicbld
Copy link
Copy Markdown
Collaborator

/azp run Azure.sonic-buildimage

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

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.

2 participants