Skip to content

feat: Implement BFD for BGPPeers - #438

Open
sven-rosenzweig wants to merge 1 commit into
mainfrom
feat/bfd_for_bgppeer
Open

feat: Implement BFD for BGPPeers#438
sven-rosenzweig wants to merge 1 commit into
mainfrom
feat/bfd_for_bgppeer

Conversation

@sven-rosenzweig

Copy link
Copy Markdown
Contributor

No description provided.

@sven-rosenzweig
sven-rosenzweig force-pushed the feat/bfd_for_bgppeer branch 2 times, most recently from 3400add to 37e3c78 Compare July 10, 2026 10:38
Comment thread api/core/v1alpha1/bfd_types.go Outdated
Comment thread api/core/v1alpha1/bgp_peer_types.go
Comment thread internal/provider/cisco/nxos/bgp.go Outdated
Comment thread internal/provider/cisco/nxos/bgp.go Outdated
SrcIf string `json:"srcIf,omitempty"`

// BFD enablement
PeerControl string `json:"ctrl"`

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.

I don't see this field at all in the YANG model. Should we delete it?

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.

I somehow have in my had, this was needed to activate the BFD feature.

This should be the field:
https://github.com/YangModels/yang/blob/559418adbd5f05860c36b1d2ffa590ef8ee0309e/vendor/cisco/nx/10.6-2/Cisco-NX-OS-device.yang#L48686-L48690

Comment thread internal/provider/cisco/nxos/bgp.go
}
if peer.BFD.RequiredMinimumReceive != nil {
ms := peer.BFD.RequiredMinimumReceive.Duration

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.

Suggested change

weird formatting.

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.

Still valid.

Comment thread internal/provider/cisco/nxos/bgp.go
Comment thread internal/provider/cisco/nxos/provider.go
@sven-rosenzweig
sven-rosenzweig marked this pull request as ready for review July 22, 2026 12:08
Signed-off-by: Sven Rosenzweig <sven.rosenzweig@sap.com>
@github-actions

Copy link
Copy Markdown

Merging this branch will decrease overall coverage

Impacted Packages Coverage Δ 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1 0.00% (ø)
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr 34.75% (-1.32%) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos 9.17% (-0.08%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/ironcore-dev/network-operator/api/core/v1alpha1/bfd_types.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/api/core/v1alpha1/bgp_peer_types.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/api/core/v1alpha1/interface_types.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/api/core/v1alpha1/zz_generated.deepcopy.go 0.00% (ø) 0 0 0
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/bgp_peer.go 50.00% (ø) 38 19 19
github.com/ironcore-dev/network-operator/internal/provider/cisco/iosxr/provider.go 21.36% (-1.34%) 220 (+13) 47 173 (+13) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/bgp.go 18.99% (-5.21%) 79 (+17) 15 64 (+17) 👎
github.com/ironcore-dev/network-operator/internal/provider/cisco/nxos/provider.go 0.05% (-0.00%) 2041 (+7) 1 2040 (+7) 👎

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/provider/cisco/nxos/bgp_test.go

SrcIf string `json:"srcIf,omitempty"`

// BFD enablement
PeerControl PeerControlType `json:"ctrl,omitempty"`

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.

Do we really want this to be omitempty? Does this not have a platform default value that is always present? If not and it's completely omitted from the json payload, than we should rather use the Option[T] type we have in this nxos package.

if err != nil {
return err
}
pe.PeerControl = PeerControlTypeBFD

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.

If this field is only conditionally present, it should rather use the Option type than be omitempty.

return err
}
pe.PeerControl = PeerControlTypeBFD
pe.BfdMultihop = bfd

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.

As this field is only set, when bfd is in the spec and never set or reset otherwise, please add a comment that this will not work with a gnmiext.Client.Patch call. The reason is that bfd might have been configured outside of the network operator and thus, the "mhbfdintvl-items" entry is present. However, as we don't set it (because the spec doesn't specify it), we would unmarshal the response and detect a drift/diff on every reconcile, making gnmi set calls over and over again to Patch the configuration. Currently this is not the case, as we are Updating/Replacing the configuration, however with a Patch we would have a problem here. So I would prefer if we document this in a little comment.

SrcIf string `json:"srcIf,omitempty"`

// BFD enablement
PeerControl PeerControlType `json:"ctrl,omitempty"`

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.

I don't see this field being present in the payload at all:

leaf1(config-router-neighbor)# sh run | sec '^router bgp'
router bgp 65000
  neighbor 10.1.1.1
    bfd multihop interval 999 min_rx 999 multiplier 10
$ gnmic --skip-verify get --type config --values-only --path 'System/bgp-items/inst-items/dom-items/Dom-list[name=default]/peer-items/Peer-list[addr=10.1.1.1]'
[
  [
    {
      "addr": "10.1.1.1",
      "adminSt": "enabled",
      "asnType": "none",
      "bfdType": "none",
      "bmpSrvId1St": "disabled",
      "bmpSrvId2St": "disabled",
      "capSuppr4ByteAsn": "disabled",
      "dscp": "cs6",
      "epe": "disabled",
      "holdIntvl": 180,
      "internalVpnClient": "disabled",
      "kaIntvl": 60,
      "logNbrChgs": "none",
      "lowMemExempt": "disabled",
      "mhbfdintvl-items": {
        "minRxMs": 999,
        "minTxMs": 999,
        "multiplier": 10
      },
      "passwdType": "LINE",
      "peerType": "fabric-internal",
      "privateASctrl": "none"
    }
  ]
]


pe.BfdType = BfdTypeNone
if req.BGPPeer.Spec.BFD != nil && req.BGPPeer.Spec.BFD.Enabled {
bfd, err := NewBGPNeighborBfd(req.BGPPeer.Spec.BFD)

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.

You have to make sure that the bfd feature is also enabled here, otherwise the gnmi call will fail. I assume bfd was already enabled elsewhere on the device you were testing against?

You can just take the logic for enabling bfd from the EnsureInterface func.

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.

2 participants