Skip to content

pkg/ipam: Migrate Subnet from net.IPNet to netip.Prefix #39335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025

Conversation

HadrienPatte
Copy link
Member

Migrate the CIDR and IPv6CIDR fields of the ipamTypes.Subnet struct from *cidr.CIDR to *netip.Prefix (cidr.CIDR is a light wrapper on top of net.IPNet).

The CIDR.AvailableIPs() method is migrated from the cidr package to the azure/api one as that's the only place where it's used and updated to work with netip.Prefix instead of CIDR.

The DeepEqual and DeepCopy methods for ipamTypes.Subnet are no longer autogenerated as they can't be since the Subnet struct now depends on an external netip.Prefix type that does not implement those methods.

Related: #24246


Please ensure your pull request adheres to the following guidelines:

  • For first time contributors, read Submitting a pull request
  • All code is covered by unit and/or runtime tests where feasible.
  • All commits contain a well written commit description including a title,
    description and a Fixes: #XXX line if the commit addresses a particular
    GitHub issue.
  • If your commit description contains a Fixes: <commit-id> tag, then
    please add the commit author[s] as reviewer[s] to this issue.
  • All commits are signed off. See the section Developer’s Certificate of Origin
  • Provide a title or release-note blurb suitable for the release notes.
  • Are you a user of Cilium? Please add yourself to the Users doc
  • Thanks for contributing!
pkg/ipam: Migrate Subnet from net.IPNet to netip.Prefix

@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 May 5, 2025
@HadrienPatte HadrienPatte force-pushed the ipam-netip branch 2 times, most recently from 4fdeddc to d8d224f Compare May 5, 2025 13:59
@HadrienPatte
Copy link
Member Author

/test

@HadrienPatte HadrienPatte marked this pull request as ready for review May 5, 2025 15:01
@HadrienPatte HadrienPatte requested review from a team as code owners May 5, 2025 15:01
Copy link
Member

@gandro gandro left a comment

Choose a reason for hiding this comment

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

Awesome work, thank you! Two bits of feedback

Migrate the `CIDR` and `IPv6CIDR` of the `ipamTypes.Subnet` struct from
`*cidr.CIDR` to `*netip.Prefix` (`cidr.CIDR` is a light wrapper on top of
`net.IPNet`).

The `CIDR.AvailableIPs()` method is migrated from the `cidr` package to
the `azure/api` one as that's the only place where it's used and updated
to work with `netip.Prefix` instead of `CIDR`.

The `DeepEqual` and `DeepCopy` methods for `ipamTypes.Subnet` are no
longer autogenerated as they can't be since the `Subnet` struct now
depends on an external `netip.Prefix` type that does not implement those
methods.

Related: cilium#24246

Signed-off-by: Hadrien Patte <hadrien.patte@datadoghq.com>
Copy link
Member

@gandro gandro left a comment

Choose a reason for hiding this comment

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

Thanks!

@gandro gandro added kind/cleanup This includes no functional changes. release-note/misc This PR makes changes that have no direct user impact. labels May 6, 2025
@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 May 6, 2025
@gandro
Copy link
Member

gandro commented May 6, 2025

/test

@gandro gandro enabled auto-merge May 6, 2025 12:41
@gandro gandro added this pull request to the merge queue May 7, 2025
Merged via the queue into cilium:main with commit 47fd633 May 7, 2025
66 of 67 checks passed
@HadrienPatte HadrienPatte deleted the ipam-netip branch May 7, 2025 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup This includes no functional changes. 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