Add IPv6 support for SecurityPolicy/NetworkPolicy#1394
Add IPv6 support for SecurityPolicy/NetworkPolicy#1394wenqiq wants to merge 1 commit intovmware-tanzu:mainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1394 +/- ##
==========================================
+ Coverage 76.75% 76.81% +0.05%
==========================================
Files 151 151
Lines 21308 21329 +21
==========================================
+ Hits 16356 16383 +27
+ Misses 3783 3773 -10
- Partials 1169 1173 +4
🚀 New features to boost your workflow:
|
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
03550cd to
44036e2
Compare
| ) | ||
|
|
||
| const ( | ||
| NsIPv6Policy = "e2e-ipv6-policy" |
There was a problem hiding this comment.
NsIPv6Policy = "e2e-ipv6-policy"+getRandomString()
Let's add a random suffix to avoid the ns failed to be deleted in previous e2e test blocking the following e2e tests.
| defer deadlineCancel() | ||
|
|
||
| ns := NsIPv6Policy | ||
| setupNamespace(t, ns) |
There was a problem hiding this comment.
As all the tests share the same namespace, maybe we can create the namespace in test/e2e/e2e_namespaces.go and run the tests parallel here?
| return ip.To4() == nil | ||
| } | ||
|
|
||
| func CalculateIPFromCIDRs(IPAddresses []string) (int, error) { |
There was a problem hiding this comment.
This function may not fully support ipv6 as int is not large enough for all ipv6 subnet size. As this function is not used for security policy, may be we can leave a comment here to mention this and re-valuate it when nsx ipv6 support for subnet is ready.
| return ip | ||
| } | ||
|
|
||
| func calculateOffsetIP(ip net.IP, offset int) (net.IP, error) { |
There was a problem hiding this comment.
it looks like this function never returns error, maybe change (net.IP, error) -> net.IP?
Add IPv6 support for SecurityPolicy and NetworkPolicy ipBlocks
Refactor IP arithmetic utilities in pkg/util/ip.go to use math/big
instead of uint32, enabling dual-stack (IPv4/IPv6) support for CIDR
range calculations including the except/exclusion logic. The previous
implementation was hardcoded to 32-bit IPv4 addresses, causing failures
when processing IPv6 CIDRs.