-
Notifications
You must be signed in to change notification settings - Fork 1.8k
bgp: add local_as support to BGP_NEIGHBOR template #26556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,9 @@ | |||||
| ! | ||||||
| neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }} | ||||||
| neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }} | ||||||
| {% if bgp_session['local_as'] is defined %} | ||||||
| neighbor {{ neighbor_addr }} local-as {{ bgp_session['local_as'] }} no-prepend replace-as | ||||||
|
||||||
| neighbor {{ neighbor_addr }} local-as {{ bgp_session['local_as'] }} no-prepend replace-as | |
| neighbor {{ neighbor_addr }} local-as {{ bgp_session['local_as'] }}{% if bgp_session['local_as_no_prepend'] is defined and bgp_session['local_as_no_prepend'] | int != 0 %} no-prepend{% endif %}{% if bgp_session['local_as_replace_as'] is defined and bgp_session['local_as_replace_as'] | int != 0 %} replace-as{% endif %} |
Copilot
AI
Apr 4, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new template behavior isn’t covered by existing bgpcfgd unit tests (e.g., src/sonic-bgpcfgd/tests/test_bgp.py adds peers but doesn’t assert the rendered config for new attributes). Adding a test that sets local_asn (and the optional local_as_no_prepend / local_as_replace_as flags if supported) and asserts the generated neighbor ... local-as ... line would prevent regressions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The template checks/uses
bgp_session['local_as'], but the upstream CONFIG_DB/YANG schema for BGP neighbors useslocal_asn(seesrc/sonic-yang-models/yang-models/sonic-bgp-common.yangandsrc/sonic-yang-models/tests/files/sample_config_db.json). As written, settinglocal_asnonBGP_NEIGHBORwill not render anyneighbor ... local-as ...line. Consider switching tolocal_asn(and optionally supporting both keys for backward compatibility).