-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ipcache/md: Convert metadata key to netip.Prefix
This commit moves most of the newer ipcache logic over to "net/ipnet" so that we can have stronger types when dealing with later additions to the core IP structures. Previously with the string keys, the expectation was that users of the metadata cache would insert IP addresses rather than prefixes. However, features like CIDR policy need to insert using prefixes. We could ambiguously insert with either IPs or CIDRs like the main IPCache structure does, but this can easily introduce subtle bugs. Instead, swap out the key for the ipcache.metadata structure for netip.Prefix to force use of prefixes as the key even for existing use cases that are based around IP addresses. As a side benefit, netip can be used as map keys and it's supposed to be more efficient than the prior net types. This commit does not currently swap the main IPCache structure over to net/ipnet, as this would force us to deal with conflicts between IP and prefix keys in the main map. We can first introduce this in the metadata cache, then introduce a newer IPCache metadata API that handles conflicts (upcoming commit), migrate the existing codepaths that inject into the ipcache to the new API, and then finally migrate the main IPCache structure over to net/netip types. Co-authored-by: Chris Tarazi <chris@isovalent.com> Signed-off-by: Chris Tarazi <chris@isovalent.com> Signed-off-by: Joe Stringer <joe@cilium.io>
- Loading branch information
1 parent
98a7b60
commit 3828475
Showing
8 changed files
with
190 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.