Skip to content

feat: Implement BFD for BGPPeers#438

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

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.

Signed-off-by: Sven Rosenzweig <sven.rosenzweig@sap.com>
Comment on lines +4 to +7
// Package v1alpha1 contains API Schema definitions for the networking.metal.ironcore.dev v1alpha1 API group.
// +kubebuilder:validation:Required
// +kubebuilder:object:generate=true
// +groupName=networking.metal.ironcore.dev

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.

These comments shouldn't be here. They are only meant to be there once for the entire package, which doc.go already does.

Comment on lines +68 to +69
// BFD defines the Bidirectional Forwarding Detection configuration for the interface.
// BFD is only applicable for Layer 3 interfaces.

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.

Interface vs. BGPPeer. Probably just copy+paste.

MinTxIntvlMs uint32 `json:"minTxMs"`
}

func NewBGPNeighborBfd(peer *v1alpha1.BGPPeerSpec) (*BGPNeighborBfd, error) {

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.

It is weird to only pass the spec here. Either I would pass the whole *v1alpha1.BGPPeer object, or otherwise, just a *v1alpha.BFD (.spec.bfd).

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?


// BFD enablement
PeerControl string `json:"ctrl"`
// Bfd Type: none (default), single-hop, multi-hop

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 would create a proper enum for these string values instead of documenting supported values in a comment.

}
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.

Comment on lines +418 to +424
const (
// PeerControlBFD enables BFD on BGP peer
PeerControlBFD = "bfd"
// BfdTypeNone relies on default BFD session type selection
BfdTypeNone = "none"
)

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 would make this a proper enum instead of constants:

type PeerControlType string

const (
	PeerControlTypeBFD PeerControlType = "bfd"
	PeerControlTypeNone PeerControlType = "none"
)

Comment on lines +542 to +552

if req.BGPPeer.Spec.BFD != nil && req.BGPPeer.Spec.BFD.Enabled {
bfd, err := NewBGPNeighborBfd(&req.BGPPeer.Spec)
if err != nil {
return err
}
pe.PeerControl = PeerControlBFD
pe.BfdType = BfdTypeNone
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.

Suggested change
if req.BGPPeer.Spec.BFD != nil && req.BGPPeer.Spec.BFD.Enabled {
bfd, err := NewBGPNeighborBfd(&req.BGPPeer.Spec)
if err != nil {
return err
}
pe.PeerControl = PeerControlBFD
pe.BfdType = BfdTypeNone
pe.BfdMultihop = bfd
}
pe.BfdType = BfdTypeNone
if req.BGPPeer.Spec.BFD != nil && req.BGPPeer.Spec.BFD.Enabled {
bfd, err := NewBGPNeighborBfd(&req.BGPPeer.Spec)
if err != nil {
return err
}
pe.PeerControl = PeerControlBFD
pe.BfdType = "multihop"
pe.BfdMultihop = bfd
}

we have to set the default values unconditionally, otherwise we risk trigger a diff → update cycle on every reconcile.

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