Skip to content

ipam: add AllowFirstLastIPs option to ipallocator.NewCIDRRange#45025

Merged
tklauser merged 1 commit intomainfrom
pr/HadrienPatte/AllowFirstLastIPs
Mar 31, 2026
Merged

ipam: add AllowFirstLastIPs option to ipallocator.NewCIDRRange#45025
tklauser merged 1 commit intomainfrom
pr/HadrienPatte/AllowFirstLastIPs

Conversation

@HadrienPatte
Copy link
Copy Markdown
Member

Extend NewCIDRRange with a WithAllowFirstLastIPs functional option that includes the first and last IPs of a CIDR in the allocatable range. This is needed for AWS ENI prefix delegation where /28 prefixes are exclusively assigned to a node and all 16 IPs are usable as there is no shared network segment requiring base/broadcast reservation.

Also refactor ForEach to use r.base directly instead of assuming a +1 offset from the CIDR base, making it correct for both default and AllowFirstLastIPs ranges.

Relates to cilium/design-cfps#87

Followup to #34618

See #28637 (comment)

@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Mar 27, 2026
@HadrienPatte HadrienPatte added the release-note/misc This PR makes changes that have no direct user impact. label Mar 27, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Mar 27, 2026
@HadrienPatte
Copy link
Copy Markdown
Member Author

/test

1 similar comment
@cilium-ariane
Copy link
Copy Markdown

cilium-ariane bot commented Mar 27, 2026

/test

@HadrienPatte HadrienPatte marked this pull request as ready for review March 27, 2026 19:22
@HadrienPatte HadrienPatte requested a review from a team as a code owner March 27, 2026 19:22
@HadrienPatte HadrienPatte requested a review from pippolo84 March 27, 2026 19:22
@HadrienPatte HadrienPatte added the area/ipam IP address management, including cloud IPAM label Mar 27, 2026
Copy link
Copy Markdown
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Left some comments about the unneeded extra field in Range.

@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/AllowFirstLastIPs branch from 2572234 to 0bbca8a Compare March 30, 2026 11:45
Extend `NewCIDRRange` with a `WithAllowFirstLastIPs` functional option
that includes the first and last IPs of a CIDR in the allocatable range.
This is needed for AWS ENI prefix delegation where /28 prefixes are
exclusively assigned to a node and all 16 IPs are usable as there is no
shared network segment requiring base/broadcast reservation.

Also refactor `ForEach` to use `r.base` directly instead of assuming a +1
offset from the CIDR base, making it correct for both default and
`AllowFirstLastIPs` ranges.

Relates to [cilium/design-cfps#87](cilium/design-cfps#87)

Followup to #34618

See #28637 (comment)

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
@HadrienPatte HadrienPatte force-pushed the pr/HadrienPatte/AllowFirstLastIPs branch from 0bbca8a to 10f6fa5 Compare March 30, 2026 11:47
@HadrienPatte
Copy link
Copy Markdown
Member Author

@pippolo84 thanks for the review 🙇 Updated to remove firstLastIPsIncluded field and GetIndexedIP function

@HadrienPatte HadrienPatte requested a review from pippolo84 March 30, 2026 12:29
Copy link
Copy Markdown
Member

@pippolo84 pippolo84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice (and thoroughly tested too)! Thanks! 💯

@pippolo84
Copy link
Copy Markdown
Member

/test

@HadrienPatte HadrienPatte added dont-merge/bad-bot To prevent MLH from marking ready-to-merge. and removed dont-merge/bad-bot To prevent MLH from marking ready-to-merge. labels Mar 30, 2026
@maintainer-s-little-helper maintainer-s-little-helper bot added ready-to-merge This PR has passed all tests and received consensus from code owners to merge. labels Mar 30, 2026
@tklauser tklauser added this pull request to the merge queue Mar 31, 2026
Merged via the queue into main with commit 2ccd855 Mar 31, 2026
601 of 605 checks passed
@tklauser tklauser deleted the pr/HadrienPatte/AllowFirstLastIPs branch March 31, 2026 14:21
HadrienPatte added a commit that referenced this pull request Mar 31, 2026
Add an `allowFirstLastIPs` parameter to `cidrPool` that propagates the
`WithAllowFirstLastIPs` option to `ipallocator.NewCIDRRange` when
creating new CIDR allocators in `updatePool`. This allows pools used for
delegated prefixes (e.g. AWS /28 prefix delegation) to allocate all IPs
in the range without reserving the first and last addresses.

Existing multi-pool callers pass false to preserve current behavior.

Relates to [cilium/design-cfps#87](cilium/design-cfps#87)

This is a direct followup to #45025 and a small setup step before the
larger migration or ENI IPAM from the CRD allocator to the multipool
allocator.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
github-merge-queue bot pushed a commit that referenced this pull request Apr 1, 2026
Add an `allowFirstLastIPs` parameter to `cidrPool` that propagates the
`WithAllowFirstLastIPs` option to `ipallocator.NewCIDRRange` when
creating new CIDR allocators in `updatePool`. This allows pools used for
delegated prefixes (e.g. AWS /28 prefix delegation) to allocate all IPs
in the range without reserving the first and last addresses.

Existing multi-pool callers pass false to preserve current behavior.

Relates to [cilium/design-cfps#87](cilium/design-cfps#87)

This is a direct followup to #45025 and a small setup step before the
larger migration or ENI IPAM from the CRD allocator to the multipool
allocator.

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit to DataDog/cilium that referenced this pull request Apr 3, 2026
Replace the CRD allocator with the multi-pool allocator for ENI IPAM mode
on the agent side. Previous PRs cilium#45110 and cilium#45124 ensure the operator
already supports this new agent setup.

The new `eniMultiPoolAllocator` is a light wrapper on the standard
`multiPoolAllocator` that enriches `AllocationResult` with ENI-specific
required metadata via `buildENIAllocationResult` (see cilium#45089).

Key differences from the standard multi-pool allocator:
* `AllowFirstLastIPs` is enabled so /28 prefix delegation ranges are
  fully allocatable (see cilium#45025 and cilium#45082).
* `LinearPreAlloc` uses a simple `inUse + preAlloc` formula for demand
  computation instead of `neededIPCeil` rounding. This matches the CRD
  allocator's `calculateNeededIPs` semantics and is necessary to ensure
  the operator can recover the exact IP usage from the demand signal
  (requested - preAllocate) (see cilium#45124).
* No dependency on `CiliumPodIPPool` CRDs, pools are managed by the
  operator via Spec.IPAM.Pools.Allocated (see cilium#45110).

The agents now read CIDRs from `Spec.IPAM.Pools.Allocated`, allocate IPs
locally, and write aggregate demand to `Spec.IPAM.Pools.Requested`. They
no longer writes per-IP usage to `Status.IPAM.Used`, achieving a
reduction of kubernetes API pressure.

Relates to cilium/design-cfps#87

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit to DataDog/cilium that referenced this pull request Apr 3, 2026
Replace the CRD allocator with the multi-pool allocator for ENI IPAM mode
on the agent side. Previous PRs cilium#45110 and cilium#45124 ensure the operator
already supports this new agent setup.

The new `eniMultiPoolAllocator` is a light wrapper on the standard
`multiPoolAllocator` that enriches `AllocationResult` with ENI-specific
required metadata via `buildENIAllocationResult` (see cilium#45089).

Key differences from the standard multi-pool allocator:
* `AllowFirstLastIPs` is enabled so /28 prefix delegation ranges are
  fully allocatable (see cilium#45025 and cilium#45082).
* `LinearPreAlloc` uses a simple `inUse + preAlloc` formula for demand
  computation instead of `neededIPCeil` rounding. This matches the CRD
  allocator's `calculateNeededIPs` semantics and is necessary to ensure
  the operator can recover the exact IP usage from the demand signal
  (requested - preAllocate) (see cilium#45124).
* No dependency on `CiliumPodIPPool` CRDs, pools are managed by the
  operator via Spec.IPAM.Pools.Allocated (see cilium#45110).

The agents now read CIDRs from `Spec.IPAM.Pools.Allocated`, allocate IPs
locally, and write aggregate demand to `Spec.IPAM.Pools.Requested`. They
no longer writes per-IP usage to `Status.IPAM.Used`, achieving a
reduction of kubernetes API pressure.

Relates to cilium/design-cfps#87

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit that referenced this pull request Apr 3, 2026
Replace the CRD allocator with the multi-pool allocator for ENI IPAM mode
on the agent side. Previous PRs #45110 and #45124 ensure the operator
already supports this new agent setup.

The new `eniMultiPoolAllocator` is a light wrapper on the standard
`multiPoolAllocator` that enriches `AllocationResult` with ENI-specific
required metadata via `buildENIAllocationResult` (see #45089).

Key differences from the standard multi-pool allocator:
* `AllowFirstLastIPs` is enabled so /28 prefix delegation ranges are
  fully allocatable (see #45025 and #45082).
* `LinearPreAlloc` uses a simple `inUse + preAlloc` formula for demand
  computation instead of `neededIPCeil` rounding. This matches the CRD
  allocator's `calculateNeededIPs` semantics and is necessary to ensure
  the operator can recover the exact IP usage from the demand signal
  (requested - preAllocate) (see #45124).
* No dependency on `CiliumPodIPPool` CRDs, pools are managed by the
  operator via Spec.IPAM.Pools.Allocated (see #45110).

The agents now read CIDRs from `Spec.IPAM.Pools.Allocated`, allocate IPs
locally, and write aggregate demand to `Spec.IPAM.Pools.Requested`. They
no longer writes per-IP usage to `Status.IPAM.Used`, achieving a
reduction of kubernetes API pressure.

Relates to cilium/design-cfps#87

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit that referenced this pull request Apr 4, 2026
Replace the CRD allocator with the multi-pool allocator for ENI IPAM mode
on the agent side. Previous PRs #45110 and #45124 ensure the operator
already supports this new agent setup.

The new `eniMultiPoolAllocator` is a light wrapper on the standard
`multiPoolAllocator` that enriches `AllocationResult` with ENI-specific
required metadata via `buildENIAllocationResult` (see #45089).

Key differences from the standard multi-pool allocator:
* `AllowFirstLastIPs` is enabled so /28 prefix delegation ranges are
  fully allocatable (see #45025 and #45082).
* `LinearPreAlloc` uses a simple `inUse + preAlloc` formula for demand
  computation instead of `neededIPCeil` rounding. This matches the CRD
  allocator's `calculateNeededIPs` semantics and is necessary to ensure
  the operator can recover the exact IP usage from the demand signal
  (requested - preAllocate) (see #45124).
* No dependency on `CiliumPodIPPool` CRDs, pools are managed by the
  operator via Spec.IPAM.Pools.Allocated (see #45110).

The agents now read CIDRs from `Spec.IPAM.Pools.Allocated`, allocate IPs
locally, and write aggregate demand to `Spec.IPAM.Pools.Requested`. They
no longer writes per-IP usage to `Status.IPAM.Used`, achieving a
reduction of kubernetes API pressure.

Relates to cilium/design-cfps#87

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit that referenced this pull request Apr 4, 2026
Replace the CRD allocator with the multi-pool allocator for ENI IPAM mode
on the agent side. Previous PR #45124 ensures the operator already
supports this new agent setup.

The new `eniMultiPoolAllocator` is a light wrapper on the standard
`multiPoolAllocator` that enriches `AllocationResult` with ENI-specific
required metadata via `buildENIAllocationResult` (see #45089).

Key differences from the standard multi-pool allocator:
* `AllowFirstLastIPs` is enabled so /28 prefix delegation ranges are
  fully allocatable (see #45025 and #45082).
* `LinearPreAlloc` uses a simple `inUse + preAlloc` formula for demand
  computation instead of `neededIPCeil` rounding. This matches the CRD
  allocator's `calculateNeededIPs` semantics and is necessary to ensure
  the operator can recover the exact IP usage from the demand signal
  (requested - preAllocate) (see #45124).
* No dependency on `CiliumPodIPPool` CRDs, pools are instead populated
  by the agent from `Status.ENI.ENIs` which is maintained by the
  operator.

The agents now read CIDRs from `Status.ENI.ENIs`, allocate IPs locally,
and write aggregate demand to `Spec.IPAM.Pools.Requested`. They
no longer writes per-IP usage to `Status.IPAM.Used`, achieving a
reduction of kubernetes API pressure.

Relates to cilium/design-cfps#87

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit that referenced this pull request Apr 4, 2026
Replace the CRD allocator with the multi-pool allocator for ENI IPAM mode
on the agent side. Previous PR #45124 ensures the operator already
supports this new agent setup.

The new `eniMultiPoolAllocator` is a light wrapper on the standard
`multiPoolAllocator` that enriches `AllocationResult` with ENI-specific
required metadata via `buildENIAllocationResult` (see #45089).

Key differences from the standard multi-pool allocator:
* `AllowFirstLastIPs` is enabled so /28 prefix delegation ranges are
  fully allocatable (see #45025 and #45082).
* `LinearPreAlloc` uses a simple `inUse + preAlloc` formula for demand
  computation instead of `neededIPCeil` rounding. This matches the CRD
  allocator's `calculateNeededIPs` semantics and is necessary to ensure
  the operator can recover the exact IP usage from the demand signal
  (requested - preAllocate) (see #45124).
* No dependency on `CiliumPodIPPool` CRDs, pools are instead populated
  by the agent from `Status.ENI.ENIs` which is maintained by the
  operator.

The agents now read CIDRs from `Status.ENI.ENIs`, allocate IPs locally,
and write aggregate demand to `Spec.IPAM.Pools.Requested`. They
no longer writes per-IP usage to `Status.IPAM.Used`, achieving a
reduction of kubernetes API pressure.

Relates to cilium/design-cfps#87

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
HadrienPatte added a commit that referenced this pull request Apr 5, 2026
Replace the CRD allocator with the multi-pool allocator for ENI IPAM mode
on the agent side. Previous PR #45124 ensures the operator already
supports this new agent setup.

The new `eniMultiPoolAllocator` is a light wrapper on the standard
`multiPoolAllocator` that enriches `AllocationResult` with ENI-specific
required metadata via `buildENIAllocationResult` (see #45089).

Key differences from the standard multi-pool allocator:
* `AllowFirstLastIPs` is enabled so /28 prefix delegation ranges are
  fully allocatable (see #45025 and #45082).
* `LinearPreAlloc` uses a simple `inUse + preAlloc` formula for demand
  computation instead of `neededIPCeil` rounding. This matches the CRD
  allocator's `calculateNeededIPs` semantics and is necessary to ensure
  the operator can recover the exact IP usage from the demand signal
  (requested - preAllocate) (see #45124).
* No dependency on `CiliumPodIPPool` CRDs, pools are instead populated
  by the agent from `Status.ENI.ENIs` which is maintained by the
  operator.

The agents now read CIDRs from `Status.ENI.ENIs`, allocate IPs locally,
and write aggregate demand to `Spec.IPAM.Pools.Requested`. They
no longer writes per-IP usage to `Status.IPAM.Used`, achieving a
reduction of kubernetes API pressure.

Relates to cilium/design-cfps#87

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ipam IP address management, including cloud IPAM ready-to-merge This PR has passed all tests and received consensus from code owners to merge. release-note/misc This PR makes changes that have no direct user impact.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants