Skip to content

Commit

Permalink
Allow overlapping ranges in case of single stack IPv6. (gardener#10584)
Browse files Browse the repository at this point in the history
* Allow overlapping ranges in case of single stack IPv6

* Remove IPv6 overlap test.

* Add a test case that overlapping ranges are allowed for IPv6.
  • Loading branch information
axel7born authored Sep 26, 2024
1 parent 7089c07 commit 94d197b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pkg/apis/extensions/validation/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,10 @@ func ValidateNetworkSpec(spec *extensionsv1alpha1.NetworkSpec, fldPath *field.Pa

allErrs = append(allErrs, cidrvalidation.ValidateCIDRParse(cidrs...)...)
allErrs = append(allErrs, cidrvalidation.ValidateCIDRIPFamily(cidrs, string(primaryIPFamily))...)
allErrs = append(allErrs, cidrvalidation.ValidateCIDROverlap(cidrs, false)...)

if !(len(spec.IPFamilies) == 1 && spec.IPFamilies[0] == extensionsv1alpha1.IPFamilyIPv6) {
allErrs = append(allErrs, cidrvalidation.ValidateCIDROverlap(cidrs, false)...)
}
return allErrs
}

Expand Down
7 changes: 2 additions & 5 deletions pkg/apis/extensions/validation/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,12 @@ var _ = Describe("Network validation tests", func() {
}))))
})

It("should forbid Network with overlapping pod and service CIDRs", func() {
It("should allow Network with overlapping pod and service CIDRs", func() {
network.Spec.ServiceCIDR = "2001:db8:3::/48"
network.Spec.PodCIDR = network.Spec.ServiceCIDR

errorList := ValidateNetwork(network)
Expect(errorList).To(ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
"Type": Equal(field.ErrorTypeInvalid),
"Field": Equal("spec.serviceCIDR"),
}))))
Expect(errorList).To(BeEmpty())
})
})
})
Expand Down

0 comments on commit 94d197b

Please sign in to comment.