Skip to content

[draft] Handle route update as add instead of replace - #41391

Draft
FetoiuCatalin wants to merge 6 commits into
masterfrom
user/cfetoiu/handle_update_as_add
Draft

[draft] Handle route update as add instead of replace#41391
FetoiuCatalin wants to merge 6 commits into
masterfrom
user/cfetoiu/handle_update_as_add

Conversation

@FetoiuCatalin

Copy link
Copy Markdown
Contributor

Summary of the Pull Request

PR Checklist

  • Closes: Link to issue #xxx
  • Communication: I've discussed this with core contributors already. If work hasn't been agreed, this work might be rejected
  • Tests: Added/updated if needed and all pass
  • Localization: All end user facing strings can be localized
  • Dev docs: Added/updated if needed
  • Documentation updated: If checked, please file a pull request on our docs repo and link it here: #xxx

Detailed Description of the Pull Request / Additional comments

Validation Steps Performed

Copilot AI lite review requested due to automatic review settings August 19, 2026 21:38
@FetoiuCatalin FetoiuCatalin changed the title Handle route update as add instead of replace [draft] Handle route update as add instead of replace Aug 19, 2026

Copilot AI left a comment

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.

Pull request overview

This draft PR changes Linux route “Update” handling in netlinkutil to avoid inadvertently replacing another interface’s route when multiple routes share the same destination/metric key, and adds a Windows networking test to validate the new behavior.

Changes:

  • Update route modification logic to omit NLM_F_REPLACE for Update operations (treat Update as “ensure exists” / add-only).
  • Add a regression test that creates two same-metric default routes on different interfaces and verifies both persist after an Update.

Reviewed changes

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

File Description
src/linux/netlinkutil/RoutingTable.cpp Changes Update route flags to avoid NLM_F_REPLACE overwriting another interface’s route.
test/windows/NetworkTests.cpp Adds a WSL2 test validating that updating eth0’s default route does not remove another interface’s same-metric default route.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/linux/netlinkutil/RoutingTable.cpp Outdated
Comment thread test/windows/NetworkTests.cpp Outdated
Copilot AI review requested due to automatic review settings August 19, 2026 21:42

Copilot AI left a comment

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.

Pull request overview

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

Suppressed comments (1)

src/linux/netlinkutil/RoutingTable.cpp:103

  • Remove the leftover commented-out assignment (// flags = NLM_F_CREATE;). It’s redundant with the next line and makes it look like the code is mid-edit.
        // Note: The EEXIST error is already treated as non-fatal.
        // flags = NLM_F_CREATE;
        flags = NLM_F_CREATE;

Copilot AI review requested due to automatic review settings August 19, 2026 22:49

Copilot AI left a comment

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.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (1)

src/windows/service/exe/WslMirroredNetworking.cpp:1415

  • In the refresh-all-routes retry path, the code sets SyncStatus = PendingUpdate, but this PR now treats PendingUpdate identically to PendingAdd (both send ModifyRequestType::Add). Setting PendingAdd here would better reflect the actual retry operation and avoid future confusion when debugging route-sync state transitions.
                    hr = SendRouteRequestToGns(endpoint, trackedRoute, hns::ModifyRequestType::Add);
                    if (FAILED(hr.value()))
                    {
                        trackedRoute.SyncStatus = PendingUpdate;
                        trackedRoute.SyncRetryCount = TrackedRoute::MaxSyncRetryCount;
                    }

Copilot AI review requested due to automatic review settings August 19, 2026 23:36

Copilot AI left a comment

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.

Pull request overview

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

Suppressed comments (1)

src/windows/service/exe/WslMirroredNetworking.cpp:1416

  • In the refresh-all-routes retry path, the code now only ever sends ModifyRequestType::Add, but on failure it sets SyncStatus = PendingUpdate. Since PendingUpdate no longer results in an Update request (it’s handled identically to PendingAdd), keeping the status as PendingUpdate is misleading and makes future debugging harder. Consider using PendingAdd here (or renaming the enum more broadly) to match the actual behavior.
                    hr = SendRouteRequestToGns(endpoint, trackedRoute, hns::ModifyRequestType::Add);
                    if (FAILED(hr.value()))
                    {
                        trackedRoute.SyncStatus = PendingUpdate;
                        trackedRoute.SyncRetryCount = TrackedRoute::MaxSyncRetryCount;
                    }

Copilot AI review requested due to automatic review settings August 20, 2026 20:42

Copilot AI left a comment

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.

Pull request overview

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

Suppressed comments (1)

src/windows/service/exe/WslMirroredNetworking.cpp:1403

  • Grammar: use "A" (not "An") before "ModifyRequestType::Add".
            // An ModifyRequestType::Add plumbs a new route or leaves an existing one in place (EEXIST is ignored),

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.

2 participants