Skip to content

Support IPv6 for SubnetPort #1439

Open
yanjunz97 wants to merge 3 commits into
vmware-tanzu:mainfrom
yanjunz97:subnetport-ipv6
Open

Support IPv6 for SubnetPort #1439
yanjunz97 wants to merge 3 commits into
vmware-tanzu:mainfrom
yanjunz97:subnetport-ipv6

Conversation

@yanjunz97
Copy link
Copy Markdown
Contributor

@yanjunz97 yanjunz97 commented May 21, 2026

This PR focuses on happy path for IPv6/Dual Stack in SubnetPort
It contains the following changes

  • Support multiple status.networkInterfaceConfig.ipAddresses and spec.addressBindings in SubnetPort
  • Support StaticIPAllocationType in SubnetPort
  • Support AllocatePortFromSubnet for IPv6 and dual stack

Testing done:
Tested regression case for Pod/VM with IPv4

@yanjunz97 yanjunz97 force-pushed the subnetport-ipv6 branch 2 times, most recently from af22382 to ced00a0 Compare May 21, 2026 07:30
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 21, 2026

Codecov Report

❌ Patch coverage is 65.80407% with 185 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.81%. Comparing base (7244967) to head (8eab5f5).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...kg/controllers/subnetport/subnetport_controller.go 48.95% 23 Missing and 26 partials ⚠️
pkg/nsx/services/subnetport/subnetport.go 54.54% 17 Missing and 23 partials ⚠️
pkg/nsx/services/subnet/subnet.go 73.75% 8 Missing and 13 partials ⚠️
.../controllers/networkinfo/networkinfo_controller.go 65.30% 6 Missing and 11 partials ⚠️
pkg/nsx/services/subnet/builder.go 74.00% 3 Missing and 10 partials ⚠️
pkg/controllers/subnetset/subnetset_controller.go 52.63% 2 Missing and 7 partials ⚠️
pkg/controllers/common/utils.go 85.45% 4 Missing and 4 partials ⚠️
pkg/controllers/subnet/subnet_controller.go 58.82% 2 Missing and 5 partials ⚠️
pkg/nsx/services/subnetport/builder.go 84.84% 0 Missing and 5 partials ⚠️
pkg/nsx/util/utils.go 50.00% 0 Missing and 5 partials ⚠️
... and 4 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1439      +/-   ##
==========================================
- Coverage   77.03%   73.81%   -3.22%     
==========================================
  Files         156      169      +13     
  Lines       22221    23689    +1468     
==========================================
+ Hits        17118    17487     +369     
- Misses       3891     4030     +139     
- Partials     1212     2172     +960     
Flag Coverage Δ
unit-tests 73.81% <65.80%> (-3.22%) ⬇️
Files with missing lines Coverage Δ
pkg/nsx/services/common/types.go 100.00% <ø> (ø)
pkg/util/utils.go 82.95% <100.00%> (-4.05%) ⬇️
pkg/nsx/services/subnetport/store.go 73.12% <0.00%> (-14.06%) ⬇️
pkg/controllers/subnetset/subnetset_webhook.go 62.88% <84.61%> (-16.48%) ⬇️
pkg/controllers/pod/pod_controller.go 60.13% <71.42%> (-2.37%) ⬇️
pkg/nsx/services/subnet/compare.go 83.78% <71.42%> (-8.53%) ⬇️
pkg/nsx/services/subnetport/builder.go 68.99% <84.84%> (-20.36%) ⬇️
pkg/nsx/util/utils.go 56.92% <50.00%> (-31.09%) ⬇️
pkg/controllers/subnet/subnet_controller.go 52.76% <58.82%> (-18.93%) ⬇️
pkg/controllers/common/utils.go 66.74% <85.45%> (-17.75%) ⬇️
... and 6 more

... and 19 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@yanjunz97 yanjunz97 force-pushed the subnetport-ipv6 branch 4 times, most recently from 43882e8 to abfbb5a Compare May 22, 2026 02:48
@yanjunz97 yanjunz97 marked this pull request as ready for review May 22, 2026 02:55
@yanjunz97 yanjunz97 changed the title [WIP] Support IPv6 for SubnetPort Support IPv6 for SubnetPort May 22, 2026
// is only updated after the updating succeeds.
updatedSubnet := *vpcSubnets[i] // #nosec G602
updatedSubnet.Tags = newTags
updatedSubnet.IpAddressType = String(controllercommon.ConvertCRIPAddressTypeToNSX(subnetsetCR.Spec.IPAddressType))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IpAddressType is overwritten unconditionally on every UpdateSubnetSet call. If spec.ipAddressType is not set (empty string), ConvertCRIPAddressTypeToNSX defaults to "IPV4", silently changing the address type of existing IPv6 or dual-stack NSX subnets ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this shall be fine as here we only update Subnet created by NSX Operator.
And before we introduce ipAddressType to Subnet CRD, NSX Operator only creates IPv4 Subnet, so there is no existing IPv6 or dual-stack NSX subnets will be updated to IPv4 in this case?

Comment on lines +498 to +501
case model.VpcSubnet_IP_ADDRESS_TYPE_IPV4_IPV6:
info.dirtyCount += 1
info.dirtyCountIPv6 += 1
log.Trace("Allocate Subnetport to dual-stack Subnet", "Subnet", *subnet.Path, "dirtyPortCount", info.dirtyCount, "dirtyPortCountIPv6", info.dirtyCountIPv6)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When using dual-stack allocation, both dirtyCount and dirtyCountIPv6 will be incremented simultaneously. However, it seems that ReleasePortInSubnet only decrements dirtyCount?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good caught. Yes, ReleasePortInSubnet needs to consume ipAddressType and decrement dirtyCount accordingly.

Comment thread pkg/nsx/services/subnetport/subnetport.go
if macAddress == "" && binding.Binding.MacAddress != nil {
macAddress = strings.Trim(*binding.Binding.MacAddress, "\"")
}
subnetPort.Status.NetworkInterfaceConfig.IPAddresses[i].IPAddress = *binding.Binding.IpAddress
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Writes values by index here, Could it possibly panic or use the wrong address family?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

By design we should not get out of index error, but it makes sense to defense here. I changed it to append when it is out of index and record in log.

yanjunz97 added 2 commits May 27, 2026 14:27
Signed-off-by: Yanjun Zhou <yanjun.zhou@broadcom.com>
Signed-off-by: Yanjun Zhou <yanjun.zhou@broadcom.com>
Signed-off-by: Yanjun Zhou <yanjun.zhou@broadcom.com>
@TaoZou1
Copy link
Copy Markdown
Contributor

TaoZou1 commented May 29, 2026

/e2e

2 similar comments
@TaoZou1
Copy link
Copy Markdown
Contributor

TaoZou1 commented May 29, 2026

/e2e

@TaoZou1
Copy link
Copy Markdown
Contributor

TaoZou1 commented May 29, 2026

/e2e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants