Skip to content

Add BGP redistribute static support - #662

Merged
adamtrizuljak-sap merged 2 commits into
mainfrom
feat/bgp-redistribute-static
Oct 28, 2026
Merged

adamtrizuljak-sap merged 2 commits into
mainfrom
feat/bgp-redistribute-static

Conversation

@adamtrizuljak-sap

Copy link
Copy Markdown
Contributor

Summary

Adds support for redistribute static route-map {RM} under the BGP VRF IPv4/IPv6 unicast address-families. This mirrors the existing redistribute direct feature end-to-end and is realized by both providers (Cisco NX-OS and OpenConfig), since the API field is provider-agnostic.

Note: This PR added the feature to the existing Openconfig BGP provider, since the Nokia BGP provider is not yet implemented. This keeps feature parity with the NX-OS provider, but will have to be migrated.

Changes

  • API (api/core/v1alpha1/bgp_types.go): new optional redistributeStaticRoutes.routingPolicyRef field on BGPUnicastAddressFamily (same shape as redistributeDirectRoutes). Regenerated CRD, deepcopy, and Helm chart.
  • Cisco NX-OS (internal/provider/cisco/nxos): added NewInterLeakPStatic (proto=static) and wired it into both AF blocks. The static entry coexists with direct as a distinct InterLeakP-list entry (keyed by proto), so no MarshalJSON change was required.
  • OpenConfig (internal/provider/openconfig/bgp.go): added PolicyTypeStatic, emit a STATIC table-connection, and clean it up in DeleteBGP. The two redistribution loops were factored into a shared helper.
  • Controller (internal/controller/core/bgp_controller.go): generalized the redistribute policy resolver to handle both direct and static refs, and broadened the field index so a RoutingPolicy change re-reconciles any BGP that references it for either kind.

Behavior notes

  • Idempotent: after the initial Set, repeated reconciles produce no further gNMI Sets when the config is unchanged (the gnmiext Get-and-Check diff only compares fields the provider writes). The device's platform defaults on the entry (scope=inter, srv6PrefixType=unspecified) do not cause false diffs.
  • The referenced RoutingPolicy must exist and belong to the same device; otherwise the BGP reports Ready=False with WaitingForDependencies or CrossDeviceReference, consistent with the direct path.

Testing

  • Unit: NX-OS payload golden (bgp_dom_af_rdst_static.json) covering direct+static coexistence on one AF.
  • Controller envtest: static routingPolicyRef waiting → ready transition.
  • gNMI golden (bgp_redistribute.txtar) for both providers, covering the expected device state and cleanup on delete.
  • make vet lint test test-gnmi all pass (openconfig 23/23, nx.cisco 44/44).

Tested against a simulated Cisco N9K-C9300v in Clabernetes using the provided bgp-rdst BGP sample.

Clean state:

% gnmic -a 127.0.0.1 --port 9339 -u *** -p *** --skip-verify get -e json --values-only get \
  --path 'System/bgp-items/inst-items/dom-items/Dom-list[name=default]/af-items/DomAf-list[type=ipv4-ucast]/interleak-items/InterLeakP-list' \
  --path 'System/bgp-items/inst-items/dom-items/Dom-list[name=default]/af-items/DomAf-list[type=ipv6-ucast]/interleak-items/InterLeakP-list'
[
  null,
  null
]

After deploying the bgp-rdst BGP sample without the redistributeStaticRoutes block (for both ipv4Unicast and ipv6Unicast):

% gnmic -a 127.0.0.1 --port 9339 -u *** -p *** --skip-verify get -e json --values-only get \
  --path 'System/bgp-items/inst-items/dom-items/Dom-list[name=default]/af-items/DomAf-list[type=ipv4-ucast]/interleak-items/InterLeakP-list' \
  --path 'System/bgp-items/inst-items/dom-items/Dom-list[name=default]/af-items/DomAf-list[type=ipv6-ucast]/interleak-items/InterLeakP-list'
[
  [
    {
      "asn": "none",
      "inst": "none",
      "proto": "direct",
      "rtMap": "BGP-IMPORT",
      "scope": "inter",
      "srv6PrefixType": "unspecified"
    }
  ],
  [
    {
      "asn": "none",
      "inst": "none",
      "proto": "direct",
      "rtMap": "BGP-IMPORT",
      "scope": "inter",
      "srv6PrefixType": "unspecified"
    }
  ]
]

After deploying the bgp-rdst BGP sample with the redistributeStaticRoutes block (for both ipv4Unicast and ipv6Unicast), the entries with "proto": "static" are added successfully

% gnmic -a 127.0.0.1 --port 9339 -u *** -p *** --skip-verify get -e json --values-only get \
  --path 'System/bgp-items/inst-items/dom-items/Dom-list[name=default]/af-items/DomAf-list[type=ipv4-ucast]/interleak-items/InterLeakP-list' \
  --path 'System/bgp-items/inst-items/dom-items/Dom-list[name=default]/af-items/DomAf-list[type=ipv6-ucast]/interleak-items/InterLeakP-list'
[
  [
    {
      "asn": "none",
      "inst": "none",
      "proto": "static",
      "rtMap": "BGP-IMPORT",
      "scope": "inter",
      "srv6PrefixType": "unspecified"
    }
  ],
  [
    {
      "asn": "none",
      "inst": "none",
      "proto": "direct",
      "rtMap": "BGP-IMPORT",
      "scope": "inter",
      "srv6PrefixType": "unspecified"
    }
  ],
  [
    {
      "asn": "none",
      "inst": "none",
      "proto": "direct",
      "rtMap": "BGP-IMPORT",
      "scope": "inter",
      "srv6PrefixType": "unspecified"
    }
  ],
  [
    {
      "asn": "none",
      "inst": "none",
      "proto": "static",
      "rtMap": "BGP-IMPORT",
      "scope": "inter",
      "srv6PrefixType": "unspecified"
    }
  ]
]

@github-actions

Copy link
Copy Markdown

Merging this branch changes the coverage (2 decrease, 4 increase)

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1 2.38% (-0.01%) 👎
github.com/ironcore-dev/network-operator/internal/controller/core 61.89% (+0.21%) 👍
github.com/ironcore-dev/network-operator/internal/controller/evpn 81.95% (+0.75%) 👍
github.com/ironcore-dev/network-operator/internal/controller/overlay 70.91% (+4.55%) 👍
github.com/ironcore-dev/network-operator/internal/controller/pool 74.05% (-1.48%) 👎
github.com/ironcore-dev/network-operator/internal/provider 0.00% (ø)
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos 17.57% (+0.00%) 👍
github.com/ironcore-dev/network-operator/internal/provider/openconfig 9.44% (-0.10%) 👎
Coverage details

Compared to commit a138cb3 (run #39623849807)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1/bgp_types.go 12.50% (ø) 8 1 7
github.com/ironcore-dev/network-operator/api/core/v1alpha1/zz_generated.deepcopy.go 0.00% (ø) 2980 (+11) 0 2980 (+11)
github.com/ironcore-dev/network-operator/internal/controller/core/bgp_controller.go 70.08% (+0.91%) 254 (+14) 178 (+12) 76 (+2) 👍
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/bgp.go 20.93% (+0.93%) 86 (+1) 18 (+1) 68 👍
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/ospf.go 25.00% (ø) 16 4 12
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/provider.go 4.31% (-0.01%) 2530 (+4) 109 2421 (+4) 👎
github.com/ironcore-dev/network-operator/internal/provider/openconfig/bgp.go 16.05% (-1.52%) 81 (+7) 13 68 (+7) 👎
github.com/ironcore-dev/network-operator/internal/provider/provider.go 0.00% (ø) 58 0 58

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

Changed unit test files:

  • github.com/ironcore-dev/network-operator/internal/controller/core/bgp_controller_test.go
  • github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/bgp_test.go

@felix-kaestner felix-kaestner added the review-scheduled The PR is being reviewed. label Oct 22, 2026
felix-kaestner
felix-kaestner previously approved these changes Oct 27, 2026
Comment thread internal/provider/openconfig/bgp.go Resolved
nikatza
nikatza previously approved these changes Oct 27, 2026

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

🚀

Wire up `redistribute static route-map {RM}` under the BGP VRF
IPv4/IPv6 unicast address-families, mirroring the existing
redistribute direct path across both providers.

- API: add redistributeStaticRoutes to BGPUnicastAddressFamily
- NX-OS: emit a proto=static InterLeakP entry alongside direct
- OpenConfig: emit a STATIC table-connection and clean it up on delete
- Controller: resolve the static RoutingPolicy ref and re-reconcile
  when it changes, via a shared resolver and route-policy index

Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
Signed-off-by: Adam Trizuljak <adam.trizuljak@sap.com>
@adamtrizuljak-sap
adamtrizuljak-sap force-pushed the feat/bgp-redistribute-static branch from 049fe7c to cbea2f1 Compare October 28, 2026 09:36
@adamtrizuljak-sap
adamtrizuljak-sap enabled auto-merge (squash) October 28, 2026 09:37
@adamtrizuljak-sap
adamtrizuljak-sap merged commit a35238f into main Oct 28, 2026
24 of 25 checks passed
@adamtrizuljak-sap
adamtrizuljak-sap deleted the feat/bgp-redistribute-static branch October 28, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-scheduled The PR is being reviewed. size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants