Implement IPv6 support for secondary network#7762
Implement IPv6 support for secondary network#7762wenqiq wants to merge 4 commits intoantrea-io:mainfrom
Conversation
a9f62c3 to
cb2d979
Compare
cb2d979 to
ae70c9c
Compare
There was a problem hiding this comment.
Pull request overview
This pull request implements IPv6 support for secondary networks in Antrea IPAM, extending the existing IPv4-only implementation to support IPv6 and dual-stack (IPv4+IPv6) configurations. The PR is marked as "[WIP]" (Work in Progress), indicating it may not be complete.
Changes:
- Extended IPAM controller to support multiple IP pool allocators instead of a single allocator, enabling dual-stack configurations
- Updated test helpers to dynamically determine IP version (IPv4 vs IPv6) and added test cases for IPv6 and dual-stack scenarios
- Enhanced documentation with IPv6 and dual-stack configuration examples
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/agent/secondarynetwork/podwatch/controller_test.go | Added test helper for dual-stack IPAM results and new test cases for IPv6 VLAN, dual-stack VLAN, and IPv6 SR-IOV networks |
| pkg/agent/cniserver/ipam/antrea_ipam_test.go | Added test cases for IPv6 pool allocation, dual-stack pool allocation, and static IPv6 address configuration |
| pkg/agent/cniserver/ipam/antrea_ipam_controller.go | Refactored getPoolAllocatorByPod to getPoolAllocatorsByPod to return multiple allocators and removed IPv4-only restriction |
| pkg/agent/cniserver/ipam/antrea_ipam.go | Enhanced Add, Check, and owns functions to handle multiple allocators; added findMatchingIP helper for IP family matching; implemented rollback on allocation failure |
| docs/antrea-ipam.md | Added documentation sections for IPv6 and dual-stack secondary network configurations with complete examples |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "type": "antrea", | ||
| "networkType": "vlan", | ||
| "mtu": 1200, | ||
| "mtu": 1300, |
There was a problem hiding this comment.
RFC 8200 mandates a minimum MTU of 1280 for IPv6.
| } | ||
|
|
||
| return mineTrue, allocator, ips, reservedOwner, err | ||
| return mineTrue, allocators, ips, reservedOwner, nil |
There was a problem hiding this comment.
Can a Pod get >1 v4 or v6 allocators?
There was a problem hiding this comment.
This comment refers to the same issue as the comment #7762 (comment) ?
|
|
||
| ipConfig, defaultRoute := generateIPConfig(ip, int(subnetInfo.PrefixLength), gwIP) | ||
| result.Routes = append(result.Routes, defaultRoute) | ||
| result.IPs = append(result.IPs, ipConfig) |
There was a problem hiding this comment.
Cannot we get >1 v4 or v6 IPs?
There was a problem hiding this comment.
Yes, I think it’s possible. Current code returns allocators for all valid pools from the annotation (getPoolAllocatorsByPod), and we append one IPConfig per allocator. It’s intended for dual-stack (one v4 + one v6) but it doesn’t enforce ‘one pool per family’, so multiple v4/v6 can happen.
There was a problem hiding this comment.
I think we should allocate at most 1 v4 and 1 v6 IP.
And probably we should report an error if no v4 / v6 IP is available, but the Pod does have a v4 / v6 pool specified.
There was a problem hiding this comment.
Updated. Please help check it again. Thanks.
|
|
||
| // Test dual-stack allocation for primary network: a pod in a namespace | ||
| // annotated with both an IPv4 and an IPv6 pool should receive two IPs. | ||
| testAddDualStack := func(test string, expectedIPv4, expectedGWv4, expectedMaskv4, expectedIPv6, expectedGWv6, expectedMaskv6 string) { |
There was a problem hiding this comment.
Is it possible to enhance and share code with existing teatAdd/Del/Check?
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Add IPv6 and dual-stack support for secondary network
Previously, Antrea IPAM only supported IPv4 for secondary networks.
This change removes that restriction by allowing multiple IPPool
allocators (one per IP family) to be used during address allocation.
TestDone:

vlan-pod1:
vlan-pod3: