Skip to content

Commit

Permalink
prohibit usage of vni zero
Browse files Browse the repository at this point in the history
  • Loading branch information
Haven456 committed Mar 15, 2024
1 parent e000db3 commit bfdc62a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/v1alpha1/layer2networkconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Layer2NetworkConfigurationSpec struct {
MTU int `json:"mtu"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Minimum=1
// VXLAN VNI Id for the layer 2 network
VNI int `json:"vni"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ spec:
x-kubernetes-map-type: atomic
vni:
description: VXLAN VNI Id for the layer 2 network
minimum: 1
type: integer
vrf:
description: VRF to attach Layer2 network to, default if not set
Expand Down
6 changes: 6 additions & 0 deletions pkg/reconciler/layer3.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ func (r *reconcile) createVrfConfigMap(l3vnis []networkv1alpha1.VRFRouteConfigur
continue
}

if vni == 0 {
err := fmt.Errorf("VNI can not be set to 0")
r.Logger.Error(err, "VNI can not be set to 0, ignoring", "vrf", spec.VRF, "name", l3vnis[i].ObjectMeta.Name, "namespace", l3vnis[i].ObjectMeta.Namespace)
continue
}

cfg, err := createVrfConfig(vrfConfigMap, &spec, vni, rt)
if err != nil {
return nil, err
Expand Down

0 comments on commit bfdc62a

Please sign in to comment.