Skip to content

Conversation

@paulyufan2
Copy link
Contributor

@paulyufan2 paulyufan2 commented Nov 20, 2025

Reason for Change:

This PR is to fix dualnic windows duplicated route issues

Once DNS config sets skipDefaultRoute to True, then do not set default route on this interface. For example:
eth0(skipDefaultRoute=False) -> CNI sets default route to eth0 interface
eth1(skipDefaultRoute=True) -> CNI does not set default route to eth1 interface and leave Routes field as empty.

We are providing two HCN endpoints to HNS:
Endpoint 1 (eth0) – includes a default route.
Endpoint 2 (eth1) – the Routes field is empty, i.e. we are not supplying any route for this endpoint. The only default route we configure is on the first HCN endpoint.

Issue Fixed:

Requirements:

Notes:

Copilot AI review requested due to automatic review settings November 20, 2025 16:20
@paulyufan2 paulyufan2 requested a review from a team as a code owner November 20, 2025 16:20
@paulyufan2 paulyufan2 added the cni Related to CNI. label Nov 20, 2025
Copilot finished reviewing on behalf of paulyufan2 November 20, 2025 16:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR addresses duplicated route issues in dual NIC Windows scenarios by introducing a conditional check on the SkipDefaultRoutes flag before adding default routes in multitenancy configurations. The fix refactors the routing logic to be more defensive about when routes are added, preventing HNS (Host Network Service) from receiving duplicate default routes.

Key Changes:

  • Introduced new addDefaultRoute method on the Multitenancy struct with IPv4 gateway validation and proper error handling
  • Added conditional route addition based on SkipDefaultRoutes flag to prevent duplicate routes in dual NIC scenarios
  • Enhanced test coverage with a new test case verifying that routes are not added when SkipDefaultRoutes=true

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
cni/network/multitenancy.go Added new receiver method addDefaultRoute with IP validation; refactored SetupRoutingForMultitenancy to check SkipDefaultRoutes before adding default routes; removed DNS SNAT route handling from the non-SNAT path
cni/network/multitenancy_test.go Updated existing test case name for clarity; added new test case for SkipDefaultRoutes=true scenario; improved code formatting and added missing multitenancyClient initialization

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

paulyufan2 and others added 2 commits November 24, 2025 12:37
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Paul Yu <[email protected]>
Co-authored-by: Copilot <[email protected]>
Signed-off-by: Paul Yu <[email protected]>
@Azure Azure deleted a comment from Copilot AI Nov 24, 2025
@Azure Azure deleted a comment from Copilot AI Nov 24, 2025
@paulyufan2
Copy link
Contributor Author

/azp run Azure Container Networking PR

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@paulyufan2
Copy link
Contributor Author

/azp run Azure Container Networking PR

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@paulyufan2
Copy link
Contributor Author

/azp run Azure Container Networking PR

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@paulyufan2
Copy link
Contributor Author

/azp run Azure Container Networking PR

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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.

3 participants