Skip to content

Commit

Permalink
Merge pull request #105 from telekom/feature/prohibit-vni-zero
Browse files Browse the repository at this point in the history
Prohibit usage of vni zero
  • Loading branch information
Cellebyte authored Mar 19, 2024
2 parents f839b23 + 3ad9d06 commit f14ef14
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions api/v1alpha1/layer2networkconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type Layer2NetworkConfigurationSpec struct {
MTU int `json:"mtu"`

// +kubebuilder:validation:Required
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Maximum=16777215
// 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 @@ -130,6 +130,8 @@ spec:
x-kubernetes-map-type: atomic
vni:
description: VXLAN VNI Id for the layer 2 network
maximum: 16777215
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 && vni > 16777215 {
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 f14ef14

Please sign in to comment.