diff --git a/pkg/nodeipam/ipam/cloud_allocator.go b/pkg/nodeipam/ipam/cloud_allocator.go index 94b374c..56c2b78 100644 --- a/pkg/nodeipam/ipam/cloud_allocator.go +++ b/pkg/nodeipam/ipam/cloud_allocator.go @@ -628,8 +628,10 @@ func (r *cloudAllocator) addCIDRSet(cidr string) error { } mask = 80 - case mask > 120: + case mask > 123: return fmt.Errorf("CIDRv6 is too small: %v", subnet.String()) + case mask > 119: + break default: mask += 16 } diff --git a/pkg/nodeipam/ipam/cloud_allocator_test.go b/pkg/nodeipam/ipam/cloud_allocator_test.go index 49ec073..ba24660 100644 --- a/pkg/nodeipam/ipam/cloud_allocator_test.go +++ b/pkg/nodeipam/ipam/cloud_allocator_test.go @@ -65,11 +65,23 @@ func TestAddCIDRSet(t *testing.T) { expectedClusterCIDR: netip.MustParsePrefix("2000::aaaa:bbbb:cccc:0/112"), }, { - name: "CIDRv6 with mask size 120", + name: "CIDRv6 with mask size 120, 256 pods", cidr: "2000::aaaa:bbbb:cccc:123/120", expectedSize: 1, expectedClusterCIDR: netip.MustParsePrefix("2000::aaaa:bbbb:cccc:100/120"), }, + { + name: "CIDRv6 with mask size 122, 64 pods", + cidr: "2000::aaaa:bbbb:cccc:123/122", + expectedSize: 1, + expectedClusterCIDR: netip.MustParsePrefix("2000::aaaa:bbbb:cccc:100/122"), + }, + { + name: "CIDRv6 with mask size 123, 32 pods", + cidr: "2000::aaaa:bbbb:cccc:123/123", + expectedSize: 1, + expectedClusterCIDR: netip.MustParsePrefix("2000::aaaa:bbbb:cccc:120/123"), + }, { name: "CIDRv6 with mask size 124", cidr: "2000::aaaa:bbbb:cccc:123/124",