Skip to content

[RT-7.8] update BGP community and policy configuration - #6028

Closed
LiamWalsh98 wants to merge 9 commits into
openconfig:mainfrom
b4firex:bgp-oc-yml-main-rt-7-8-v2
Closed

[RT-7.8] update BGP community and policy configuration#6028
LiamWalsh98 wants to merge 9 commits into
openconfig:mainfrom
b4firex:bgp-oc-yml-main-rt-7-8-v2

Conversation

@LiamWalsh98

Copy link
Copy Markdown
Contributor

Summary

Update RT-7.8 for the current BGP OpenConfig model.

send-community configuration

Remove the RT-7.8 assignment:

skip_bgp_send_community_type: true

This changes community configuration from:

/network-instances/network-instance/protocols/protocol/bgp/peer-groups/peer-group/config/send-community

to:

/network-instances/network-instance/protocols/protocol/bgp/peer-groups/peer-group/afi-safis/afi-safi/config/send-community-type

The test configures this path for both IPv4 and IPv6.

import/export policy configuration

Replace complete apply-policy parents instead of individual import-policy and export-policy leaf lists.

Neighbor path:

/network-instances/network-instance/protocols/protocol/bgp/neighbors/neighbor/afi-safis/afi-safi/apply-policy/config

Peer-group path:

/network-instances/network-instance/protocols/protocol/bgp/peer-groups/peer-group/afi-safis/afi-safi/apply-policy/config

When the test moves the policy to a peer group, it deletes the complete former neighbor apply-policy parent.

BGP OpenConfig uprev

The updated model places peer-group send-community-type under AFI-SAFI. It also requires policy changes through the complete containing apply-policy configuration.

Ported-from: bgp-oc-yml-migration-infra@7df1f7d5f69bb258ef2a3b42f0e6220af1a8e690

Traceability-ID: INFRA-MAIN-001
Ported-from: 4541fc75d
Traceability-ID: F23627-014
Ported-from: bf98d2562
Traceability-ID: F23627-014
Traceability-ID: REST-23627-DEFAULTS
Traceability-ID: REST-BGP-UPREV-DEVIATIONS
Ported-from: 6fd3e3c
Traceability-ID: BGP-UPREV-DEFAULT-RT-7-8
Traceability-ID: BGP-UPREV-DEFAULT-RT-7-8
@LiamWalsh98
LiamWalsh98 requested a review from a team as a code owner September 11, 2026 16:23
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the BGP configuration logic to comply with recent changes in the OpenConfig model. The modifications primarily involve relocating community type settings and refactoring how routing policies are applied to neighbors and peer groups to ensure compatibility with the updated schema.

Highlights

  • BGP OpenConfig Uprev: Updated BGP configuration paths to align with the latest OpenConfig model, specifically moving send-community-type under AFI-SAFI.
  • Policy Configuration Refactoring: Switched from configuring individual import/export policy leaf lists to replacing the complete apply-policy parent configuration for both neighbors and peer groups.
  • Deviation Cleanup: Removed the skip_bgp_send_community_type deviation as part of the model update.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the BGP community match action test to align with the new BGP OpenConfig model by removing the "skip_bgp_send_community_type" deviation and refactoring how apply policies are configured using "gnmi.BatchReplace". The review feedback recommends simplifying the conditional block in "bgpCreateNbr" by removing a redundant "else if" check that has identical logic to the "else" block, and refactoring the duplicated configuration logic for IPv4 and IPv6 AFI-SAFI apply policies into a single loop.

Comment on lines +226 to 232
} else if deviations.SkipBgpPeerGroupSendCommunityType(dut) {
as4.SetSendCommunityType([]oc.E_Bgp_CommunityType{oc.Bgp_CommunityType_STANDARD})
as6.SetSendCommunityType([]oc.E_Bgp_CommunityType{oc.Bgp_CommunityType_STANDARD})
} else {
if deviations.SkipBgpPeerGroupSendCommunityType(dut) {
as4.SetSendCommunityType([]oc.E_Bgp_CommunityType{oc.Bgp_CommunityType_STANDARD})
as6.SetSendCommunityType([]oc.E_Bgp_CommunityType{oc.Bgp_CommunityType_STANDARD})
} else {
pg.SetSendCommunityType([]oc.E_Bgp_CommunityType{oc.Bgp_CommunityType_STANDARD})
}
as4.SetSendCommunityType([]oc.E_Bgp_CommunityType{oc.Bgp_CommunityType_STANDARD})
as6.SetSendCommunityType([]oc.E_Bgp_CommunityType{oc.Bgp_CommunityType_STANDARD})
}

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.

medium

The else if and else blocks are identical and perform the exact same configuration. Since the new BGP OpenConfig model always places send-community-type under AFI-SAFI, the deviation check SkipBgpPeerGroupSendCommunityType is no longer needed here. We can simplify this block by removing the redundant else if check.

		} else {
			as4.SetSendCommunityType([]oc.E_Bgp_CommunityType{oc.Bgp_CommunityType_STANDARD})
			as6.SetSendCommunityType([]oc.E_Bgp_CommunityType{oc.Bgp_CommunityType_STANDARD})
		}
References
  1. Follow Go Code Review Comments, Effective Go, and Google Go Style Guide for writing readable Go code with a consistent look and feel. (link)

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.

This is intentional to keep any possible future changes to SkipBgpPeerGroupSendCommunityType separate from default behaviour

Comment on lines +371 to +376
applyPolicyV4 := &oc.NetworkInstance_Protocol_Bgp_PeerGroup_AfiSafi_ApplyPolicy{}
applyPolicyV4.SetImportPolicy([]string{policyName})
applyPolicyV6 := &oc.NetworkInstance_Protocol_Bgp_PeerGroup_AfiSafi_ApplyPolicy{}
applyPolicyV6.SetImportPolicy([]string{policyName})
gnmi.BatchReplace(batchConfig, bgpPath.PeerGroup(pgName).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).ApplyPolicy().Config(), applyPolicyV4)
gnmi.BatchReplace(batchConfig, bgpPath.PeerGroup(pgName).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).ApplyPolicy().Config(), applyPolicyV6)

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.

medium

The configuration logic for IPv4 and IPv6 AFI-SAFI apply policies is identical. Simplify this by using a single loop over the AFI-SAFI types to apply the policy, which improves maintainability and reduces code duplication.

Suggested change
applyPolicyV4 := &oc.NetworkInstance_Protocol_Bgp_PeerGroup_AfiSafi_ApplyPolicy{}
applyPolicyV4.SetImportPolicy([]string{policyName})
applyPolicyV6 := &oc.NetworkInstance_Protocol_Bgp_PeerGroup_AfiSafi_ApplyPolicy{}
applyPolicyV6.SetImportPolicy([]string{policyName})
gnmi.BatchReplace(batchConfig, bgpPath.PeerGroup(pgName).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST).ApplyPolicy().Config(), applyPolicyV4)
gnmi.BatchReplace(batchConfig, bgpPath.PeerGroup(pgName).AfiSafi(oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST).ApplyPolicy().Config(), applyPolicyV6)
applyPolicy := &oc.NetworkInstance_Protocol_Bgp_PeerGroup_AfiSafi_ApplyPolicy{}
applyPolicy.SetImportPolicy([]string{policyName})
for _, afiSafi := range []oc.E_BgpTypes_AFI_SAFI_TYPE{oc.BgpTypes_AFI_SAFI_TYPE_IPV4_UNICAST, oc.BgpTypes_AFI_SAFI_TYPE_IPV6_UNICAST} {
gnmi.BatchReplace(batchConfig, bgpPath.PeerGroup(pgName).AfiSafi(afiSafi).ApplyPolicy().Config(), applyPolicy)
}
References
  1. Simplify identical logic for different entities (e.g., dut1 and dut2) by using a single loop over a combined data structure or a helper function to improve maintainability.

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.

matches the style of the remainder of the suite

@LiamWalsh98

Copy link
Copy Markdown
Contributor Author

superseded by #6031

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants