diff --git a/api/core/v1alpha1/bfd_types.go b/api/core/v1alpha1/bfd_types.go new file mode 100644 index 000000000..21d762f52 --- /dev/null +++ b/api/core/v1alpha1/bfd_types.go @@ -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"` +} diff --git a/api/core/v1alpha1/bgp_peer_types.go b/api/core/v1alpha1/bgp_peer_types.go index ef53ddacf..f75e7547a 100644 --- a/api/core/v1alpha1/bgp_peer_types.go +++ b/api/core/v1alpha1/bgp_peer_types.go @@ -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. + // +optional + BFD *BFD `json:"bfd,omitempty"` } // BGPPeerASNumberExternal is the value of BGPPeerSpec.ASNumber that requests a dynamic diff --git a/api/core/v1alpha1/interface_types.go b/api/core/v1alpha1/interface_types.go index 7eb2466f3..a529fadc7 100644 --- a/api/core/v1alpha1/interface_types.go +++ b/api/core/v1alpha1/interface_types.go @@ -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. diff --git a/api/core/v1alpha1/zz_generated.deepcopy.go b/api/core/v1alpha1/zz_generated.deepcopy.go index 50819327a..1ab06c4b5 100644 --- a/api/core/v1alpha1/zz_generated.deepcopy.go +++ b/api/core/v1alpha1/zz_generated.deepcopy.go @@ -859,6 +859,11 @@ func (in *BGPPeerSpec) DeepCopyInto(out *BGPPeerSpec) { *out = new(int32) **out = **in } + if in.BFD != nil { + in, out := &in.BFD, &out.BFD + *out = new(BFD) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new BGPPeerSpec. diff --git a/charts/network-operator/templates/crd/bgppeers.networking.metal.ironcore.dev.yaml b/charts/network-operator/templates/crd/bgppeers.networking.metal.ironcore.dev.yaml index c9f16e358..99c2cf961 100644 --- a/charts/network-operator/templates/crd/bgppeers.networking.metal.ironcore.dev.yaml +++ b/charts/network-operator/templates/crd/bgppeers.networking.metal.ironcore.dev.yaml @@ -299,6 +299,43 @@ spec: The special value "external" configures a dynamic AS number, accepting any AS number that differs from the local one. It is only valid together with InterfaceRef. x-kubernetes-int-or-string: true + bfd: + description: |- + BFD defines the Bidirectional Forwarding Detection configuration for the interface. + BFD is only applicable for Layer 3 interfaces. + properties: + desiredMinimumTxInterval: + description: |- + 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. + pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string + detectionMultiplier: + description: |- + 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. + format: int32 + maximum: 255 + minimum: 1 + type: integer + enabled: + description: Enabled indicates whether BFD is enabled on the network + object. + type: boolean + requiredMinimumReceive: + description: |- + 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. + pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string + required: + - enabled + type: object bgpRef: description: |- BgpRef is a reference to the BGP instance this peer belongs to. diff --git a/charts/network-operator/templates/crd/interfaces.networking.metal.ironcore.dev.yaml b/charts/network-operator/templates/crd/interfaces.networking.metal.ironcore.dev.yaml index 3ebd2238c..e0681b4c7 100644 --- a/charts/network-operator/templates/crd/interfaces.networking.metal.ironcore.dev.yaml +++ b/charts/network-operator/templates/crd/interfaces.networking.metal.ironcore.dev.yaml @@ -181,7 +181,8 @@ spec: minimum: 1 type: integer enabled: - description: Enabled indicates whether BFD is enabled on the interface. + description: Enabled indicates whether BFD is enabled on the network + object. type: boolean requiredMinimumReceive: description: |- diff --git a/config/crd/bases/networking.metal.ironcore.dev_bgppeers.yaml b/config/crd/bases/networking.metal.ironcore.dev_bgppeers.yaml index b776f7bfc..463270deb 100644 --- a/config/crd/bases/networking.metal.ironcore.dev_bgppeers.yaml +++ b/config/crd/bases/networking.metal.ironcore.dev_bgppeers.yaml @@ -296,6 +296,43 @@ spec: The special value "external" configures a dynamic AS number, accepting any AS number that differs from the local one. It is only valid together with InterfaceRef. x-kubernetes-int-or-string: true + bfd: + description: |- + BFD defines the Bidirectional Forwarding Detection configuration for the interface. + BFD is only applicable for Layer 3 interfaces. + properties: + desiredMinimumTxInterval: + description: |- + 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. + pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string + detectionMultiplier: + description: |- + 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. + format: int32 + maximum: 255 + minimum: 1 + type: integer + enabled: + description: Enabled indicates whether BFD is enabled on the network + object. + type: boolean + requiredMinimumReceive: + description: |- + 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. + pattern: ^([0-9]+(\.[0-9]+)?(ns|us|µs|ms|s|m|h))+$ + type: string + required: + - enabled + type: object bgpRef: description: |- BgpRef is a reference to the BGP instance this peer belongs to. diff --git a/config/crd/bases/networking.metal.ironcore.dev_interfaces.yaml b/config/crd/bases/networking.metal.ironcore.dev_interfaces.yaml index e7e887c1a..2b98439ca 100644 --- a/config/crd/bases/networking.metal.ironcore.dev_interfaces.yaml +++ b/config/crd/bases/networking.metal.ironcore.dev_interfaces.yaml @@ -178,7 +178,8 @@ spec: minimum: 1 type: integer enabled: - description: Enabled indicates whether BFD is enabled on the interface. + description: Enabled indicates whether BFD is enabled on the network + object. type: boolean requiredMinimumReceive: description: |- diff --git a/docs/api-reference/index.md b/docs/api-reference/index.md index 5523fc29b..b14ca68cf 100644 --- a/docs/api-reference/index.md +++ b/docs/api-reference/index.md @@ -767,16 +767,17 @@ _Appears in:_ -BFD defines the Bidirectional Forwarding Detection configuration for an interface. +BFD defines the Bidirectional Forwarding Detection configuration for interfaces, bgp peerings and static routes. _Appears in:_ +- [BGPPeerSpec](#bgppeerspec) - [InterfaceSpec](#interfacespec) | Field | Description | Default | Validation | | --- | --- | --- | --- | -| `enabled` _boolean_ | Enabled indicates whether BFD is enabled on the interface. | | Required: \{\}
| +| `enabled` _boolean_ | Enabled indicates whether BFD is enabled on the network object. | | Required: \{\}
| | `desiredMinimumTxInterval` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#duration-v1-meta)_ | 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. | | Pattern: `^([0-9]+(\.[0-9]+)?(ns\|us\|µs\|ms\|s\|m\|h))+$`
Type: string
Optional: \{\}
| | `requiredMinimumReceive` _[Duration](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.35/#duration-v1-meta)_ | 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. | | Pattern: `^([0-9]+(\.[0-9]+)?(ns\|us\|µs\|ms\|s\|m\|h))+$`
Type: string
Optional: \{\}
| | `detectionMultiplier` _integer_ | 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. | | Maximum: 255
Minimum: 1
Optional: \{\}
| @@ -1067,6 +1068,7 @@ _Appears in:_ | `addressFamilies` _[BGPPeerAddressFamilies](#bgppeeraddressfamilies)_ | AddressFamilies configures address family specific settings for this BGP peer.
Controls which address families are enabled and their specific configuration. | | Optional: \{\}
| | `localAS` _[LocalAS](#localas)_ | LocalAS configures the local AS number and how it factors into BGP announcements for this peer. | | Optional: \{\}
| | `ttl` _integer_ | TTL sets the time-to-live for eBGP sessions that span multiple hops.
When set, allows establishing eBGP sessions with non-directly-connected peers
by setting the IP TTL of outgoing BGP packets to this value.
When unset, eBGP multihop is disabled (equivalent to TTL=1 — directly connected peers only). | | Maximum: 255
Minimum: 2
Optional: \{\}
| +| `bfd` _[BFD](#bfd)_ | BFD defines the Bidirectional Forwarding Detection configuration for the interface.
BFD is only applicable for Layer 3 interfaces. | | Optional: \{\}
| #### BGPPeerStatus diff --git a/internal/provider/cisco/iosxr/bgp_peer.go b/internal/provider/cisco/iosxr/bgp_peer.go index f612a5e69..1b1bf1a74 100644 --- a/internal/provider/cisco/iosxr/bgp_peer.go +++ b/internal/provider/cisco/iosxr/bgp_peer.go @@ -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 diff --git a/internal/provider/cisco/iosxr/provider.go b/internal/provider/cisco/iosxr/provider.go index 5b12a1cb3..32ae5a4d0 100644 --- a/internal/provider/cisco/iosxr/provider.go +++ b/internal/provider/cisco/iosxr/provider.go @@ -7,6 +7,7 @@ import ( "context" "errors" "fmt" + "math" "net" "time" @@ -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") } diff --git a/internal/provider/cisco/nxos/bgp.go b/internal/provider/cisco/nxos/bgp.go index f1c336ab5..39b1bfde6 100644 --- a/internal/provider/cisco/nxos/bgp.go +++ b/internal/provider/cisco/nxos/bgp.go @@ -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" ) @@ -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 + // 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"` + 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 @@ -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" +) + type BorderGatewayPeerType string const ( diff --git a/internal/provider/cisco/nxos/bgp_test.go b/internal/provider/cisco/nxos/bgp_test.go index ddb107fef..5235c4ea3 100644 --- a/internal/provider/cisco/nxos/bgp_test.go +++ b/internal/provider/cisco/nxos/bgp_test.go @@ -51,6 +51,7 @@ func init() { Name: "EVPN peering with spine", Addr: "1.1.1.1", SrcIf: "lo0", + BfdType: BfdTypeNone, } bgpPeer.AfItems.PeerAfList.Set(&BGPPeerAfItem{ Ctrl: Option[string]{Value: new(RouteReflectorClient)}, @@ -68,6 +69,7 @@ func init() { AsnType: PeerAsnTypeExternal, Name: "Unnumbered peering with spine", ID: "eth1/1", + BfdType: BfdTypeNone, } bgpPeerIf.AfItems.PeerAfList.Set(&BGPPeerAfItem{ SendComExt: AdminStDisabled, @@ -83,6 +85,7 @@ func init() { Asn: "65020", AsnType: PeerAsnTypeNone, ID: "eth1/2", + BfdType: BfdTypeNone, } Register("bgp_peer_if_asn", bgpPeerIfAsn) @@ -95,6 +98,7 @@ func init() { Asn: "65000", AsnType: PeerAsnTypeNone, Addr: "10.0.0.1", + BfdType: BfdTypeNone, } bgpPeerRpAf := &BGPPeerAfItem{ SendComExt: AdminStDisabled, @@ -111,7 +115,8 @@ func init() { AdminSt: AdminStEnabled, Asn: "65001", AsnType: PeerAsnTypeNone, - Addr: "1.1.1.1", + Addr: "10.0.0.2", + BfdType: BfdTypeNone, } bgpPeerLocalAs.LocalAsnItems.AsnPropagate = AsnPropagateNone bgpPeerLocalAs.LocalAsnItems.LocalAsn = "65002" @@ -124,5 +129,6 @@ func init() { Asn: "65000", AsnType: PeerAsnTypeNone, TTL: NewOption[int32](2), + BfdType: BfdTypeNone, }) } diff --git a/internal/provider/cisco/nxos/provider.go b/internal/provider/cisco/nxos/provider.go index 3ec0183ca..cc228306c 100644 --- a/internal/provider/cisco/nxos/provider.go +++ b/internal/provider/cisco/nxos/provider.go @@ -88,6 +88,8 @@ type Provider struct { // timeout is the default timeout for all HTTP/gRPC requests made by the provider. const timeout = 30 * time.Second +const featureBFD = "bfd" + func NewProvider() provider.Provider { return &Provider{} } @@ -804,6 +806,8 @@ func (p *Provider) deleteBGP(ctx context.Context, vrfName string) error { } func (p *Provider) EnsureBGPPeer(ctx context.Context, req *provider.EnsureBGPPeerRequest) error { + sb := new(gnmiext.SetBuilder).Limit(maxSetOperations) + // Ensure that the BGP domain exists before configuring a peer under it. bgp := new(BGPDom) bgp.Name = DefaultVRFName @@ -840,9 +844,45 @@ func (p *Provider) EnsureBGPPeer(ctx context.Context, req *provider.EnsureBGPPee AsnType: asnType, Name: req.BGPPeer.Spec.Description, LocalAsnItems: localAsn, + BfdType: BfdTypeNone, } base.AfItems.PeerAfList = bgpPeerAfItems(req) + if req.BGPPeer.Spec.BFD != nil && req.BGPPeer.Spec.BFD.Enabled { + // As PeerControl and BfdMultihop are only set when BFD is configured in the spec, this will not + // work with a gnmiext.Client.Patch call if somebody outside of the network operator configures BFD. + // "mhbfdintvl-items" would appear in the unmarshaled response and thus we would detect a config + // drift and reconcile over and over again. + + bfd, err := NewBGPNeighborBfd(req.BGPPeer.Spec.BFD) + if err != nil { + return err + } + + base.PeerControl = NewOption(PeerControlType) + + // Force the BGP BFD session type to multihop. + // + // NX-OS supports two BFD session types for a BGP neighbor: single-hop and + // multihop (enum bgp_BfdSessionType). With no keyword, NX-OS defaults to + // single-hop when the peer is directly connected and multihop otherwise. + // + // We pin multihop for consistency: the session type then does not depend on + // whether the peer happens to be directly connected, so a peer that is later + // reached over a routed path keeps working. + // Single-hop and multihop BFD use different UDP ports (3784 vs 4784), so BOTH + // ends must agree — if the remote end is single-hop, the session will not form + // and BGP silently loses fast failure detection. Ensure the peer is also multihop. + + base.BfdType = BfdTypeMultiHop + base.BfdMultihop = bfd + + f := new(Feature) + f.Name = featureBFD + f.AdminSt = AdminStEnabled + sb.Update(f) + } + // Unnumbered peers are identified by the interface they are reachable over instead // of by an address, and are configured under a separate list on the device. if req.PeerInterface != "" { @@ -850,8 +890,8 @@ func (p *Provider) EnsureBGPPeer(ctx context.Context, req *provider.EnsureBGPPee if err != nil { return fmt.Errorf("bgp peer: invalid peer interface name %q: %w", req.PeerInterface, err) } - - return p.client.Update(ctx, &BGPPeerIf{BGPPeer: base, ID: id}) + sb.Update(&BGPPeerIf{BGPPeer: base, ID: id}) + return p.client.Do(ctx, sb) } pe := &BGPPeerAddr{BGPPeer: base, Addr: req.BGPPeer.Spec.Address} @@ -869,8 +909,8 @@ func (p *Provider) EnsureBGPPeer(ctx context.Context, req *provider.EnsureBGPPee } pe.SrcIf = srcIf } - - return p.client.Update(ctx, pe) + sb.Update(pe) + return p.client.Do(ctx, sb) } // bgpPeerLocalAsn builds the local AS configuration shared by both peer kinds. @@ -1926,7 +1966,7 @@ func (p *Provider) EnsureInterface(ctx context.Context, req *provider.EnsureInte switch { case req.Interface.Spec.BFD != nil && req.Interface.Spec.BFD.Enabled: f := new(Feature) - f.Name = "bfd" + f.Name = featureBFD f.AdminSt = AdminStEnabled sb.Update(f) @@ -1959,7 +1999,7 @@ func (p *Provider) EnsureInterface(ctx context.Context, req *provider.EnsureInte case req.Interface.Spec.BFD != nil && !req.Interface.Spec.BFD.Enabled: f := new(Feature) - f.Name = "bfd" + f.Name = featureBFD f.AdminSt = AdminStEnabled sb.Update(f) @@ -2229,7 +2269,7 @@ func (p *Provider) EnsureISIS(ctx context.Context, req *provider.EnsureISISReque return intf.Spec.BFD != nil && intf.Spec.BFD.Enabled }) { f := new(Feature) - f.Name = "bfd" + f.Name = featureBFD f.AdminSt = AdminStEnabled sb.Update(f) } @@ -2581,7 +2621,7 @@ func (p *Provider) EnsureOSPF(ctx context.Context, req *provider.EnsureOSPFReque // BFD-specific fields. Activate it via a separate Set RPC to ensure // the feature is present before the OSPF interface is configured. fb := new(Feature) - fb.Name = "bfd" + fb.Name = featureBFD fb.AdminSt = AdminStEnabled if err := p.client.Update(ctx, fb); err != nil { return err diff --git a/internal/provider/cisco/nxos/testdata/bgp_dom_rp.json b/internal/provider/cisco/nxos/testdata/bgp_dom_rp.json index 10cfba46f..060fe05ff 100644 --- a/internal/provider/cisco/nxos/testdata/bgp_dom_rp.json +++ b/internal/provider/cisco/nxos/testdata/bgp_dom_rp.json @@ -14,6 +14,8 @@ "asn": "65000", "asnType": "none", "ttl": "DME_UNSET_PROPERTY_MARKER", + "bfdType": "none", + "ctrl": "DME_UNSET_PROPERTY_MARKER", "af-items": { "PeerAf-list": [ { diff --git a/internal/provider/cisco/nxos/testdata/bgp_peer.json b/internal/provider/cisco/nxos/testdata/bgp_peer.json index 3787039e6..5cd416c47 100644 --- a/internal/provider/cisco/nxos/testdata/bgp_peer.json +++ b/internal/provider/cisco/nxos/testdata/bgp_peer.json @@ -12,6 +12,8 @@ "adminSt": "enabled", "asn": "65000", "asnType": "none", + "ctrl": "DME_UNSET_PROPERTY_MARKER", + "bfdType": "none", "name": "EVPN peering with spine", "srcIf": "lo0", "ttl": "DME_UNSET_PROPERTY_MARKER", diff --git a/internal/provider/cisco/nxos/testdata/bgp_peer_ebgp_multihop.json b/internal/provider/cisco/nxos/testdata/bgp_peer_ebgp_multihop.json index b6159e377..9b242652b 100644 --- a/internal/provider/cisco/nxos/testdata/bgp_peer_ebgp_multihop.json +++ b/internal/provider/cisco/nxos/testdata/bgp_peer_ebgp_multihop.json @@ -12,6 +12,8 @@ "adminSt": "enabled", "asn": "65000", "asnType": "none", + "ctrl": "DME_UNSET_PROPERTY_MARKER", + "bfdType": "none", "ttl": 2 } ] diff --git a/internal/provider/cisco/nxos/testdata/bgp_peer_if.json b/internal/provider/cisco/nxos/testdata/bgp_peer_if.json index 76e50f92c..fc7735080 100644 --- a/internal/provider/cisco/nxos/testdata/bgp_peer_if.json +++ b/internal/provider/cisco/nxos/testdata/bgp_peer_if.json @@ -12,6 +12,8 @@ "adminSt": "enabled", "asnType": "external", "name": "Unnumbered peering with spine", + "ctrl": "DME_UNSET_PROPERTY_MARKER", + "bfdType": "none", "af-items": { "PeerAf-list": [ { diff --git a/internal/provider/cisco/nxos/testdata/bgp_peer_if_asn.json b/internal/provider/cisco/nxos/testdata/bgp_peer_if_asn.json index fcba03ef7..089f70df7 100644 --- a/internal/provider/cisco/nxos/testdata/bgp_peer_if_asn.json +++ b/internal/provider/cisco/nxos/testdata/bgp_peer_if_asn.json @@ -11,7 +11,9 @@ "id": "eth1/2", "adminSt": "enabled", "asn": "65020", - "asnType": "none" + "asnType": "none", + "ctrl": "DME_UNSET_PROPERTY_MARKER", + "bfdType": "none" } ] } diff --git a/internal/provider/cisco/nxos/testdata/bgp_peer_local_as.json b/internal/provider/cisco/nxos/testdata/bgp_peer_local_as.json index 5228311e6..d70649622 100644 --- a/internal/provider/cisco/nxos/testdata/bgp_peer_local_as.json +++ b/internal/provider/cisco/nxos/testdata/bgp_peer_local_as.json @@ -9,11 +9,13 @@ "peer-items": { "Peer-list": [ { - "addr": "1.1.1.1", + "addr": "10.0.0.2", "adminSt": "enabled", "asn": "65001", "asnType": "none", "ttl": "DME_UNSET_PROPERTY_MARKER", + "ctrl": "DME_UNSET_PROPERTY_MARKER", + "bfdType": "none", "localasn-items": { "asnPropagate": "none", "localAsn": "65002" diff --git a/test/gnmi/testdata/nx.cisco.networking.metal.ironcore.dev/bgp_peer.txtar b/test/gnmi/testdata/nx.cisco.networking.metal.ironcore.dev/bgp_peer.txtar index 161af39f3..b4b288b3b 100644 --- a/test/gnmi/testdata/nx.cisco.networking.metal.ironcore.dev/bgp_peer.txtar +++ b/test/gnmi/testdata/nx.cisco.networking.metal.ironcore.dev/bgp_peer.txtar @@ -186,6 +186,8 @@ spec: "adminSt": "enabled", "asn": "65000", "asnType": "none", + "ctrl": "DME_UNSET_PROPERTY_MARKER", + "bfdType": "none", "name": "EVPN peering with spine1", "srcIf": "lo0", "ttl": 2, diff --git a/test/gnmi/testdata/nx.cisco.networking.metal.ironcore.dev/bgp_peer_unnumbered.txtar b/test/gnmi/testdata/nx.cisco.networking.metal.ironcore.dev/bgp_peer_unnumbered.txtar index 909c1ae7a..cdd793354 100644 --- a/test/gnmi/testdata/nx.cisco.networking.metal.ironcore.dev/bgp_peer_unnumbered.txtar +++ b/test/gnmi/testdata/nx.cisco.networking.metal.ironcore.dev/bgp_peer_unnumbered.txtar @@ -164,6 +164,8 @@ spec: "id": "eth1/1", "adminSt": "enabled", "asnType": "external", + "ctrl": "DME_UNSET_PROPERTY_MARKER", + "bfdType": "none", "name": "Unnumbered peering with spine1", "af-items": { "PeerAf-list": [