Skip to content

Add non-persistent HNS network support for ACI#4355

Merged
behzad-mir merged 1 commit intomasterfrom
behzadm/hns-non-persistent-v1
May 5, 2026
Merged

Add non-persistent HNS network support for ACI#4355
behzad-mir merged 1 commit intomasterfrom
behzadm/hns-non-persistent-v1

Conversation

@behzad-mir
Copy link
Copy Markdown
Contributor

@behzad-mir behzad-mir commented Apr 15, 2026

Summary

Enable the EnableNonPersistent flag for all HNS v2 networks created via the CNI network package. This ensures networks are automatically removed after host reboot, preventing stale network accumulation.

Changes

Modified configureHcnNetwork() in network_windows.go to set hcn.EnableNonPersistent on all HCN networks
Refactored the FrontendNIC (transparent network) path to use |= for flag combination

Motivation

HNS networks that persist across reboots can accumulate and cause issues. By making all networks non-persistent, we ensure clean state after host restarts.

Test

The Test shows Flags: 8 for the HCN network in non-persistant.

ActivityId             : 43B2A68F-19B5-4322-9D1F-3EB1385C2F0F
AdditionalParams       :
CurrentEndpointCount   : 1
Extensions             : {@{Id=E7C3B2F0-F3C5-48DF-AF2B-10FED6D72E7A; IsEnabled=False; Name=Microsoft Windows Filtering Platform}, @{Id=F74F241B-440F-4433-BB28-00F89EAD20D8; IsEnabled=True; Name=Microsoft Azure VFP Switch Extension},
                         @{Id=430BDADD-BAB0-41AB-A369-94B67FA5BE0A; IsEnabled=True; Name=Microsoft NDIS Capture}}
Flags                  : 8
Health                 : @{LastErrorCode=0; LastUpdateTime=134219707288520535}
ID                     : 333813B5-4CCC-47C4-8901-83BC65777196
IPv6                   : False
LayeredOn              : 92469209-8B69-480F-AF7B-D80FCF9FC0F6
MacPools               : {@{EndMacAddress=00-15-5D-9C-DF-FF; StartMacAddress=00-15-5D-9C-D0-00}}
ManagementIP           : 10.0.0.4
MaxConcurrentEndpoints : 1
Name                   : byovnetbridge-vlan1-172-16-1-0_24
NetworkAdapterName     : Ethernet 2
Policies               : {}
State                  : 1
Subnets                : {@{AdditionalParams=; AddressPrefix=172.16.1.0/24; Flags=0; GatewayAddress=172.16.1.1; Health=; ID=7BFEDF51-A65A-45B6-9DBD-0AE88822D8F3; IpSubnets=System.Object[]; ObjectType=5; Policies=System.Object[];
                         State=0}}
TotalEndpoints         : 1
Type                   : L2Bridge
Version                : 55834574851
Resources              : @{AdditionalParams=; AllocationOrder=0; CompartmentOperationTime=0; Flags=0; Health=; ID=43B2A68F-19B5-4322-9D1F-3EB1385C2F0F; PortOperationTime=0; State=1; SwitchOperationTime=0; VfpOperationTime=0;
                         parentId=4C4AF374-8BC5-4D68-A7EC-7D6977AEEE5C

@daschott
Copy link
Copy Markdown

lgtm

- Add HNSFlagEnableNonPersistent constant (value 8) for HNS v1 API
- Modify createHnsNetwork() to accept nonPersistent parameter
- CreateHnsNetwork() now always creates non-persistent networks for ACI
- CreateDefaultExtNetwork() creates persistent networks (ext network)
- Use anonymous struct to inject Flags field into HNS v1 JSON payload
@behzad-mir behzad-mir force-pushed the behzadm/hns-non-persistent-v1 branch from 81c0d4e to 089346b Compare April 28, 2026 21:46
@behzad-mir behzad-mir marked this pull request as ready for review April 29, 2026 21:33
@behzad-mir behzad-mir requested a review from a team as a code owner April 29, 2026 21:33
@behzad-mir behzad-mir requested review from Copilot and skosuri1 and removed request for Copilot April 29, 2026 21:33
@behzad-mir behzad-mir added the cni Related to CNI. label Apr 29, 2026
@behzad-mir behzad-mir enabled auto-merge May 5, 2026 20:09
@behzad-mir behzad-mir added this pull request to the merge queue May 5, 2026
Merged via the queue into master with commit 164124d May 5, 2026
88 checks passed
@behzad-mir behzad-mir deleted the behzadm/hns-non-persistent-v1 branch May 5, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cni Related to CNI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants