Skip to content
Open
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
43 changes: 43 additions & 0 deletions api/cisco/nx/v1alpha1/system_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ type SystemSpec struct {
// +optional
// +kubebuilder:default={relayServerIdOverrideDisable:false}
DHCP DHCP `json:"dhcp,omitzero"`

// L2RIB groups L2RIB (Layer-2 Routing Information Base) system settings.
// Configures duplicate host IP address detection
// (CLI: "l2rib dup-host-ip-addr-detection").
// +optional
// +kubebuilder:default={moves:5,durationSeconds:180,recoveryTimeoutSeconds:30,recoveryCount:5}
L2RIB L2RIB `json:"l2rib,omitzero"`
}

// DHCP groups DHCP-related system settings. These require the dhcp feature,
Expand All @@ -71,6 +78,42 @@ type DHCP struct {
RelayServerIDOverrideDisable bool `json:"relayServerIdOverrideDisable"`
}

// L2RIB groups L2RIB duplicate host IP address detection settings,
// realized as "l2rib dup-host-ip-addr-detection" on the device.
type L2RIB struct {
// Moves is the number of host IP moves allowed within DurationSeconds before
// the host IP address is flagged as a duplicate (CLI: num-moves).
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=1000
// +kubebuilder:default=5
Moves int32 `json:"moves"`

// DurationSeconds is the detection window in seconds during which moves are
// counted (CLI: num-moves-interval).
// +optional
// +kubebuilder:validation:Minimum=2
// +kubebuilder:validation:Maximum=36000
// +kubebuilder:default=180
DurationSeconds int32 `json:"durationSeconds"`

// RecoveryTimeoutSeconds is the time in seconds after which a duplicate-marked
// host IP address is re-evaluated (CLI: retry-timeout). Minimum is 30.
// +optional
// +kubebuilder:validation:Minimum=30
// +kubebuilder:validation:Maximum=36000
// +kubebuilder:default=30
RecoveryTimeoutSeconds int32 `json:"recoveryTimeoutSeconds"`

// RecoveryCount is the number of recovery attempts before the duplicate
// detection is considered permanent (CLI: retry-count).
// +optional
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=3000
// +kubebuilder:default=5
RecoveryCount int32 `json:"recoveryCount"`
}

// SystemStatus defines the observed state of System.
type SystemStatus struct {
// The conditions are a list of status objects that describe the state of the Banner.
Expand Down
16 changes: 16 additions & 0 deletions api/cisco/nx/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.

5 changes: 5 additions & 0 deletions config/samples/cisco/nx/v1alpha1_system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ spec:
vlanLongName: true
dhcp:
relayServerIdOverrideDisable: true
l2rib:
moves: 5
durationSeconds: 180
recoveryTimeoutSeconds: 30
recoveryCount: 5
42 changes: 42 additions & 0 deletions internal/provider/cisco/nxos/l2rib.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

package nxos

import "github.com/ironcore-dev/network-operator/internal/transport/gnmiext"

var (
_ gnmiext.DataElement = (*HMMFwdEvpn)(nil)
_ gnmiext.Defaultable = (*HMMFwdEvpn)(nil)
)

const (
hmmFwdEvpnDefaultMoves uint16 = 5
hmmFwdEvpnDefaultDuration uint16 = 180
hmmFwdEvpnDefaultRecoveryTimeout uint16 = 30
hmmFwdEvpnDefaultRecoveryCount uint16 = 5
)

// HMMFwdEvpn represents the L2RIB duplicate host IP address detection settings
// ("l2rib dup-host-ip-addr-detection").
// Writes System/hmm-items/fwdinst-items/evpn-items. Must use only PATCH operations
// so that FabricFwd's data at the parent path is not clobbered.
type HMMFwdEvpn struct {
AdminSt AdminSt `json:"adminSt"`
DdHmmoves uint16 `json:"ddHmmoves"`
DdHnsecs uint16 `json:"ddHnsecs"`
Dhrtimeout uint16 `json:"dhrtimeout"`
Dhrcount uint16 `json:"dhrcount"`
}

func (*HMMFwdEvpn) XPath() string {
return "System/hmm-items/fwdinst-items/evpn-items"
}

func (h *HMMFwdEvpn) Default() {
h.AdminSt = AdminStEnabled
h.DdHmmoves = hmmFwdEvpnDefaultMoves
h.DdHnsecs = hmmFwdEvpnDefaultDuration
h.Dhrtimeout = hmmFwdEvpnDefaultRecoveryTimeout
h.Dhrcount = hmmFwdEvpnDefaultRecoveryCount
}
14 changes: 14 additions & 0 deletions internal/provider/cisco/nxos/l2rib_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and IronCore contributors
// SPDX-License-Identifier: Apache-2.0

package nxos

func init() {
Register("l2rib", &HMMFwdEvpn{
AdminSt: AdminStEnabled,
DdHmmoves: 10,
DdHnsecs: 300,
Dhrtimeout: 60,
Dhrcount: 3,
})
}
10 changes: 9 additions & 1 deletion internal/provider/cisco/nxos/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3595,7 +3595,14 @@

sys := new(SystemJumboMTU)
*sys = SystemJumboMTU(s.Spec.JumboMTU)
sb.Patch(long, res, sys)

sb.Patch(long, res, sys, &HMMFwdEvpn{
AdminSt: AdminStEnabled,
DdHmmoves: cmp.Or(uint16(s.Spec.L2RIB.Moves), hmmFwdEvpnDefaultMoves), //nolint:gosec // validated: max 1000 fits uint16

Check failure on line 3601 in internal/provider/cisco/nxos/provider.go

View workflow job for this annotation

GitHub Actions / Check Go Code

File is not properly formatted (gofmt)
DdHnsecs: cmp.Or(uint16(s.Spec.L2RIB.DurationSeconds), hmmFwdEvpnDefaultDuration), //nolint:gosec // validated: max 36000 fits uint16
Dhrtimeout: cmp.Or(uint16(s.Spec.L2RIB.RecoveryTimeoutSeconds), hmmFwdEvpnDefaultRecoveryTimeout), //nolint:gosec // validated: max 36000 fits uint16
Dhrcount: cmp.Or(uint16(s.Spec.L2RIB.RecoveryCount), hmmFwdEvpnDefaultRecoveryCount), //nolint:gosec // validated: max 3000 fits uint16
})

// The override leaf lives under the dhcp feature tree, which only exists while the
// feature is enabled. Read the current feature state to decide how to realize it.
Expand Down Expand Up @@ -3631,6 +3638,7 @@
new(VLANReservation),
new(SystemJumboMTU),
new(DHCPRelayServerIDOverrideDisable),
new(HMMFwdEvpn),
)
}

Expand Down
13 changes: 13 additions & 0 deletions internal/provider/cisco/nxos/testdata/l2rib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"hmm-items": {
"fwdinst-items": {
"evpn-items": {
"adminSt": "enabled",
"ddHmmoves": 10,
"ddHnsecs": 300,
"dhrtimeout": 60,
"dhrcount": 3
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ spec:
"inst-items": {
"systemJumboMtu": 9214
}
},
"hmm-items": {
"fwdinst-items": {
"evpn-items": {
"adminSt": "enabled",
"ddHmmoves": 5,
"ddHnsecs": 180,
"dhrtimeout": 30,
"dhrcount": 5
}
}
}
}
}
Expand All @@ -66,6 +77,17 @@ spec:
"inst-items": {
"systemJumboMtu": 9216
}
},
"hmm-items": {
"fwdinst-items": {
"evpn-items": {
"adminSt": "enabled",
"ddHmmoves": 5,
"ddHnsecs": 180,
"dhrtimeout": 30,
"dhrcount": 5
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ spec:
"inst-items": {
"relayInformationOptionServerIdOverrideDisableEnabled": 1
}
},
"hmm-items": {
"fwdinst-items": {
"evpn-items": {
"adminSt": "enabled",
"ddHmmoves": 5,
"ddHnsecs": 180,
"dhrtimeout": 30,
"dhrcount": 5
}
}
}
}
}
Expand Down Expand Up @@ -89,6 +100,17 @@ spec:
},
"dhcp-items": {
"inst-items": {}
},
"hmm-items": {
"fwdinst-items": {
"evpn-items": {
"adminSt": "enabled",
"ddHmmoves": 5,
"ddHnsecs": 180,
"dhrtimeout": 30,
"dhrcount": 5
}
}
}
}
}
Loading
Loading