feat: Implement BFD for BGPPeers#438
Conversation
169ea1e to
3400add
Compare
Signed-off-by: Sven Rosenzweig <sven.rosenzweig@sap.com>
3400add to
37e3c78
Compare
| // 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 |
There was a problem hiding this comment.
These comments shouldn't be here. They are only meant to be there once for the entire package, which doc.go already does.
| // BFD defines the Bidirectional Forwarding Detection configuration for the interface. | ||
| // BFD is only applicable for Layer 3 interfaces. |
There was a problem hiding this comment.
Interface vs. BGPPeer. Probably just copy+paste.
| MinTxIntvlMs uint32 `json:"minTxMs"` | ||
| } | ||
|
|
||
| func NewBGPNeighborBfd(peer *v1alpha1.BGPPeerSpec) (*BGPNeighborBfd, error) { |
There was a problem hiding this comment.
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"` |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 | ||
|
|
There was a problem hiding this comment.
weird formatting.
| const ( | ||
| // PeerControlBFD enables BFD on BGP peer | ||
| PeerControlBFD = "bfd" | ||
| // BfdTypeNone relies on default BFD session type selection | ||
| BfdTypeNone = "none" | ||
| ) | ||
|
|
There was a problem hiding this comment.
I would make this a proper enum instead of constants:
type PeerControlType string
const (
PeerControlTypeBFD PeerControlType = "bfd"
PeerControlTypeNone PeerControlType = "none"
)|
|
||
| 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 | ||
| } | ||
|
|
There was a problem hiding this comment.
| 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.
No description provided.