Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions api/core/v1alpha1/bfd_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// BFD defines the Bidirectional Forwarding Detection configuration for interfaces, bgp peerings and static routes.
type BFD struct {
// Enabled indicates whether BFD is enabled on the network object.
// +required
Enabled bool `json:"enabled"`

// DesiredMinimumTxInterval is the minimum interval between transmission of BFD control
// packets that the operator desires. This value is advertised to the peer.
// The actual interval used is the maximum of this value and the remote
// required-minimum-receive interval value.
// +optional
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
DesiredMinimumTxInterval *metav1.Duration `json:"desiredMinimumTxInterval,omitempty"`

// RequiredMinimumReceive is the minimum interval between received BFD control packets
// that this system should support. This value is advertised to the remote peer to
// indicate the maximum frequency between BFD control packets that is acceptable
// to the local system.
// +optional
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
RequiredMinimumReceive *metav1.Duration `json:"requiredMinimumReceive,omitempty"`

// DetectionMultiplier is the number of packets that must be missed to declare
// this session as down. The detection interval for the BFD session is calculated
// by multiplying the value of the negotiated transmission interval by this value.
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=255
DetectionMultiplier *int32 `json:"detectionMultiplier,omitempty"`
}
5 changes: 5 additions & 0 deletions api/core/v1alpha1/bgp_peer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ type BGPPeerSpec struct {
// +kubebuilder:validation:Minimum=2
// +kubebuilder:validation:Maximum=255
TTL *int32 `json:"ttl,omitempty"`

// BFD defines the Bidirectional Forwarding Detection configuration for the interface.
// BFD is only applicable for Layer 3 interfaces.
Comment thread
sven-rosenzweig marked this conversation as resolved.
Resolved
// +optional
BFD *BFD `json:"bfd,omitempty"`
}

// BGPPeerASNumberExternal is the value of BGPPeerSpec.ASNumber that requests a dynamic
Expand Down
33 changes: 0 additions & 33 deletions api/core/v1alpha1/interface_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,39 +316,6 @@ type InterfaceIPv6 struct {
UseLinkLocalOnly bool `json:"useLinkLocalOnly,omitempty"`
}

// BFD defines the Bidirectional Forwarding Detection configuration for an interface.
type BFD struct {
// Enabled indicates whether BFD is enabled on the interface.
// +required
Enabled bool `json:"enabled"`

// DesiredMinimumTxInterval is the minimum interval between transmission of BFD control
// packets that the operator desires. This value is advertised to the peer.
// The actual interval used is the maximum of this value and the remote
// required-minimum-receive interval value.
// +optional
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
DesiredMinimumTxInterval *metav1.Duration `json:"desiredMinimumTxInterval,omitempty"`

// RequiredMinimumReceive is the minimum interval between received BFD control packets
// that this system should support. This value is advertised to the remote peer to
// indicate the maximum frequency between BFD control packets that is acceptable
// to the local system.
// +optional
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern="^([0-9]+(\\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$"
RequiredMinimumReceive *metav1.Duration `json:"requiredMinimumReceive,omitempty"`

// DetectionMultiplier is the number of packets that must be missed to declare
// this session as down. The detection interval for the BFD session is calculated
// by multiplying the value of the negotiated transmission interval by this value.
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=255
DetectionMultiplier *int32 `json:"detectionMultiplier,omitempty"`
}

// Ethernet defines the ethernet-specific configuration for physical interfaces.
type Ethernet struct {
// FECMode specifies the Forward Error Correction mode for the interface.
Expand Down
5 changes: 5 additions & 0 deletions api/core/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions config/crd/bases/networking.metal.ironcore.dev_bgppeers.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions docs/api-reference/index.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions internal/provider/cisco/iosxr/bgp_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ type BGPPeer struct {
Name string `json:"vrf-name"`
RD RouteDistinguisher `json:"rd,omitzero"`
Neighbors NeighborList `json:"neighbors,omitzero"`
BFD *BFD `json:"bfd,omitzero"`
}

type BFD struct {
MinInterval uint32 `json:"minimum-interval,omitempty"`
Multiplier uint32 `json:"multiplier,omitempty"`
}

// ActivatedAddressFamilies is required for IOS XR to activate the Address-Family under the BGP process
Expand Down
26 changes: 26 additions & 0 deletions internal/provider/cisco/iosxr/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"context"
"errors"
"fmt"
"math"
"net"
"time"

Expand Down Expand Up @@ -498,6 +499,31 @@ func (p *Provider) EnsureBGPPeer(ctx context.Context, req *provider.EnsureBGPPee
RD: rd,
}

if req.BGPPeer.Spec.BFD != nil && req.BGPPeer.Spec.BFD.Enabled {
bfd := &BFD{}
if req.BGPPeer.Spec.BFD.RequiredMinimumReceive != nil {
ms := req.BGPPeer.Spec.BFD.RequiredMinimumReceive.Duration
if ms < 0 || ms > math.MaxUint32 {
return apistatus.NewInvalidArgumentError(apistatus.FieldViolation{
Field: "spec.bfd.requiredMinimumReceive",
Description: "BFD minimum receive interval must be between 0ms and 4294967295ms",
})
}
bfd.MinInterval = uint32(ms)
}
if req.BGPPeer.Spec.BFD.DetectionMultiplier != nil {
multiplier := *req.BGPPeer.Spec.BFD.DetectionMultiplier
if multiplier < 0 {
return apistatus.NewInvalidArgumentError(apistatus.FieldViolation{
Field: "spec.bfd.detectionMultiplier",
Description: "BFD detection multiplier must be non-negative",
})
}
bfd.Multiplier = uint32(multiplier)
}
peer.BFD = bfd
}

if req.BGPPeer.Spec.AddressFamilies != nil && (req.BGPPeer.Spec.AddressFamilies.Ipv6Unicast != nil || req.BGPPeer.Spec.AddressFamilies.L2vpnEvpn != nil) {
return errors.New("bgp peer: ipv6 unicast or l2vpnEvpn address family is currently not supported")
}
Expand Down
61 changes: 61 additions & 0 deletions internal/provider/cisco/nxos/bgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

nxv1alpha1 "github.com/ironcore-dev/network-operator/api/cisco/nx/v1alpha1"
"github.com/ironcore-dev/network-operator/api/core/v1alpha1"
"github.com/ironcore-dev/network-operator/internal/apistatus"
"github.com/ironcore-dev/network-operator/internal/transport/gnmiext"
)

Expand Down Expand Up @@ -227,6 +228,55 @@ type BGPPeer struct {
AfItems struct {
PeerAfList gnmiext.List[AddressFamily, *BGPPeerAfItem] `json:"PeerAf-list,omitzero"`
} `json:"af-items,omitzero"`

// BFD enablement
PeerControl Option[string] `json:"ctrl"`
// Bfd Type: none (default), single-hop, multi-hop
Comment thread
sven-rosenzweig marked this conversation as resolved.
Resolved
// Rely on default, if peer is directly connected then a single hop session is selected,
// if the peer is not connected then a multi hop session type is selected
BfdType BfdType `json:"bfdType"`
Comment thread
sven-rosenzweig marked this conversation as resolved.
Resolved
BfdMultihop *BGPNeighborBfd `json:"mhbfdintvl-items,omitzero"`
}

type BGPNeighborBfd struct {
DetectMult uint32 `json:"multiplier"`
MinRxIntvlMs uint32 `json:"minRxMs"`
MinTxIntvlMs uint32 `json:"minTxMs"`
}

func NewBGPNeighborBfd(peer *v1alpha1.BFD) (*BGPNeighborBfd, error) {
bfd := &BGPNeighborBfd{}
if peer.DetectionMultiplier != nil {
multiplier := *peer.DetectionMultiplier
if multiplier < 0 {
return nil, apistatus.NewInvalidArgumentError(apistatus.FieldViolation{
Field: "spec.bfd.detectionMultiplier",
Description: "BFD detection multiplier must be non-negative",
})
}
bfd.DetectMult = uint32(multiplier)
}
if peer.RequiredMinimumReceive != nil {
ms := peer.RequiredMinimumReceive.Milliseconds()
if ms < 250 || ms > 999 {
return nil, apistatus.NewInvalidArgumentError(apistatus.FieldViolation{
Field: "spec.bfd.requiredMinimumReceive",
Description: "BFD minimum receive interval must be between 250ms and 999ms",
})
}
bfd.MinRxIntvlMs = uint32(ms)
}
if peer.DesiredMinimumTxInterval != nil {
ms := peer.DesiredMinimumTxInterval.Milliseconds()
if ms < 250 || ms > 999 {
return nil, apistatus.NewInvalidArgumentError(apistatus.FieldViolation{
Field: "spec.bfd.desiredMinimumTxInterval",
Description: "BFD desired minimum transmit interval must be between 250ms and 999ms",
})
}
bfd.MinTxIntvlMs = uint32(ms)
}
return bfd, nil
}

// BGPPeerAddr is a BGP peer reached at an address of its own, optionally sourced from a
Expand Down Expand Up @@ -429,6 +479,17 @@ const (

const RouteReflectorClient = "rr-client"

const PeerControlType = "bfd"

type BfdType string

const (
// BfdTypeNone relies on default BFD session type selection
BfdTypeNone BfdType = "none"
BfdTypeSingleHop BfdType = "singlehop"
BfdTypeMultiHop BfdType = "multihop"
)

Comment thread
sven-rosenzweig marked this conversation as resolved.
Resolved
type BorderGatewayPeerType string

const (
Expand Down
Loading
Loading