Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cns/restserver/ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ func (service *HTTPRestService) requestIPConfigHandlerHelperStandalone(ctx conte
NICType: resp[i].NetworkInterfaceInfo.NICType,
NetworkContainerPrimaryIPConfig: resp[i].IPConfiguration,
NetworkContainerID: resp[i].NetworkContainerID,
SkipDefaultRoutes: resp[i].SkipDefaultRoutes,
}
podIPInfoList = append(podIPInfoList, podIPInfo)
if resp[i].AllowHostToNCCommunication || resp[i].AllowNCToHostCommunication {
Expand Down
11 changes: 11 additions & 0 deletions network/endpoint_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,17 @@ func (nw *network) configureHcnEndpoint(epInfo *EndpointInfo) (*hcn.HostComputeE
hcnEndpoint.Routes = append(hcnEndpoint.Routes, hcnRoute)
}

if epInfo.SkipDefaultRoutes && len(hcnEndpoint.Routes) == 0 {
logger.Info("Adding dummy default route for SkipDefaultRoutes=true",
zap.String("endpoint", infraEpName),
zap.String("nicType", string(epInfo.NICType)))

hcnEndpoint.Routes = append(hcnEndpoint.Routes, hcn.Route{
NextHop: "0.0.0.0", // Dummy gateway
DestinationPrefix: "0.0.0.0/0", // Default route
})
}
Comment on lines +349 to +358
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The condition len(hcnEndpoint.Routes) == 0 may not cover all multi-NIC scenarios where Windows might add implicit default routes. According to the PR description, this dummy route is added to prevent Windows from implicitly adding a default route when SkipDefaultRoutes is true. However, if epInfo.Routes contains non-default routes (such as specific subnet routes from networkConfig.Routes or networkConfig.CnetAddressSpace), this dummy route won't be added, and Windows might still implicitly add a default route.

Consider whether the condition should be:

  • if epInfo.SkipDefaultRoutes && !hasDefaultRoute(hcnEndpoint.Routes) - to explicitly check if a default route already exists rather than checking if the route list is empty
  • Or clarify in a comment why this workaround is only needed when there are no routes at all

Additionally, this new behavior lacks test coverage. Consider adding a test case in endpoint_windows_test.go that verifies the dummy route is added when SkipDefaultRoutes is true and no routes are configured.

Copilot uses AI. Check for mistakes.

for _, ipAddress := range epInfo.IPAddresses {
prefixLength, _ := ipAddress.Mask.Size()
ipConfiguration := hcn.IpConfig{
Expand Down
Loading